Skip to content

Commit

Permalink
avoid accessing _all_ loose refs in git-show-ref --verify
Browse files Browse the repository at this point in the history
If you want to verify a ref, it is overkill to first read all loose refs
into a linked list, and then check if the desired ref is there.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
  • Loading branch information
Junio C Hamano committed Dec 18, 2006
1 parent ed9f7c9 commit 26cdd1e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions builtin-show-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,23 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
return exclude_existing(arg + 19);
usage(show_ref_usage);
}

if (verify) {
unsigned char sha1[20];

while (*pattern) {
if (resolve_ref(*pattern, sha1, 1, NULL))
printf("%s %s\n", sha1_to_hex(sha1),
*pattern);
else if (!quiet)
die("'%s' - not a valid ref", *pattern);
else
return 1;
pattern++;
}
return 0;
}

if (show_head)
head_ref(show_ref, NULL);
for_each_ref(show_ref, NULL);
Expand Down

0 comments on commit 26cdd1e

Please sign in to comment.