diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2007-03-12 11:30:38 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-03-12 11:30:38 -0700 |
commit | 1358e7d670306a9fe8a612f1ebd1f058474d20af (patch) | |
tree | b74b1722591c0fd0702680c7f6f25be6907b014b | |
parent | 34572ed2c809c2e0b00dc660bdb2dd201c5ff85f (diff) | |
download | git-1358e7d670306a9fe8a612f1ebd1f058474d20af.tar.gz git-1358e7d670306a9fe8a612f1ebd1f058474d20af.tar.xz |
Re-fix get_sha1_oneline()
What the function wants to return is not if we saw any return
from pop_most_recent_commit(), but if we found what was asked
for.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r-- | sha1_name.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sha1_name.c b/sha1_name.c index 6b8b67b4d..bede0e5b0 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -602,10 +602,10 @@ static int handle_one_ref(const char *path, */ #define ONELINE_SEEN (1u<<20) -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 = NULL, *backup = NULL, *l; - struct commit *commit = NULL; + int retval = -1; if (prefix[0] == '!') { if (prefix[1] != '!') @@ -619,22 +619,22 @@ int get_sha1_oneline(const char *prefix, unsigned char *sha1) commit_list_insert(l->item, &backup); while (list) { char *p; + struct commit *commit; commit = pop_most_recent_commit(&list, ONELINE_SEEN); - if (!commit) - break; parse_object(commit->object.sha1); if (!commit->buffer || !(p = strstr(commit->buffer, "\n\n"))) continue; if (!prefixcmp(p + 2, prefix)) { hashcpy(sha1, commit->object.sha1); + retval = 0; break; } } free_commit_list(list); for (l = backup; l; l = l->next) clear_commit_marks(l->item, ONELINE_SEEN); - return commit == NULL; + return retval; } /* |