diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-12-13 10:01:14 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-12-12 22:32:01 -0800 |
commit | 84baa31bcb6925b06dd1b9aaa1ed6f7a725e64cc (patch) | |
tree | 0c7c2982f0acab36132c5d29249ffd79db413a9a /sha1_name.c | |
parent | 28042dbcd60f3190d25cfeae0bf81d58a16f4771 (diff) | |
download | git-84baa31bcb6925b06dd1b9aaa1ed6f7a725e64cc.tar.gz |
get_sha1_oneline: make callers prepare the commit list to traverse
This gives callers more control, i.e. which ref will be searched from.
They must prepare the list ordered by committer date.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sha1_name.c b/sha1_name.c index 2cc7a42390..aefae1f524 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -686,13 +686,13 @@ static int handle_one_ref(const char *path, if (object->type != OBJ_COMMIT) return 0; insert_by_date((struct commit *)object, list); - object->flags |= ONELINE_SEEN; return 0; } -static int get_sha1_oneline(const char *prefix, unsigned char *sha1) +static int get_sha1_oneline(const char *prefix, unsigned char *sha1, + struct commit_list *list) { - struct commit_list *list = NULL, *backup = NULL, *l; + struct commit_list *backup = NULL, *l; int found = 0; regex_t regex; @@ -705,9 +705,10 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1) if (regcomp(®ex, prefix, REG_EXTENDED)) die("Invalid search pattern: %s", prefix); - for_each_ref(handle_one_ref, &list); - for (l = list; l; l = l->next) + for (l = list; l; l = l->next) { + l->item->object.flags |= ONELINE_SEEN; commit_list_insert(l->item, &backup); + } while (list) { char *p, *to_free = NULL; struct commit *commit; @@ -1090,9 +1091,11 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1, int stage = 0; struct cache_entry *ce; int pos; - if (namelen > 2 && name[1] == '/') - /* don't need mode for commit */ - return get_sha1_oneline(name + 2, sha1); + if (namelen > 2 && name[1] == '/') { + struct commit_list *list = NULL; + for_each_ref(handle_one_ref, &list); + return get_sha1_oneline(name + 2, sha1, list); + } if (namelen < 3 || name[2] != ':' || name[1] < '0' || '3' < name[1]) |