diff options
author | Junio C Hamano <junkio@cox.net> | 2006-12-17 18:08:52 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-12-17 18:26:53 -0800 |
commit | 26cdd1e7c7a21b6d71ebc201fc2472a6a68f5ce4 (patch) | |
tree | 58070ab966c87e69050274f8308adab01c789eb7 /builtin-show-ref.c | |
parent | ed9f7c954c26ec6d517bdca3d8e4b895278d1b2b (diff) | |
download | git-26cdd1e7c7a21b6d71ebc201fc2472a6a68f5ce4.tar.gz git-26cdd1e7c7a21b6d71ebc201fc2472a6a68f5ce4.tar.xz |
avoid accessing _all_ loose refs in git-show-ref --verify
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>
Diffstat (limited to 'builtin-show-ref.c')
-rw-r--r-- | builtin-show-ref.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/builtin-show-ref.c b/builtin-show-ref.c index b36f15eea..23e0ff8fb 100644 --- a/builtin-show-ref.c +++ b/builtin-show-ref.c @@ -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); |