summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd91429)
raw | patch | inline | side by side (parent: dd91429)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 18 Dec 2006 03:27:49 +0000 (19:27 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 18 Dec 2006 03:36:50 +0000 (19:36 -0800) |
An earlier optimization for --verify broke a lot of stuff
because it did not take interaction with other flags into
account.
This also fixes an unrelated argument parsing error; --hash=8
should mean the same as "--hash --abbrev=8".
Signed-off-by: Junio C Hamano <junkio@cox.net>
because it did not take interaction with other flags into
account.
This also fixes an unrelated argument parsing error; --hash=8
should mean the same as "--hash --abbrev=8".
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-show-ref.c | patch | blob | history |
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 0fd606f392263c641da61ffe6b9ce4b89943fe07..296070628c0d631ea5af1124415ce71e71c11c08 100644 (file)
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
found_match = 0, verify = 0, quiet = 0, hash_only = 0, abbrev = 0;
static const char **pattern;
+static void show_one(const char *refname, const unsigned char *sha1)
+{
+ const char *hex = find_unique_abbrev(sha1, abbrev);
+ if (hash_only)
+ printf("%s\n", hex);
+ else
+ printf("%s %s\n", hex, refname);
+}
+
static int show_ref(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
{
struct object *obj;
if (quiet)
return 0;
- hex = find_unique_abbrev(sha1, abbrev);
- if (hash_only)
- printf("%s\n", hex);
- else
- printf("%s %s\n", hex, refname);
+ show_one(refname, sha1);
if (!deref_tags)
return 0;
if (!strncmp(arg, "--hash=", 7) ||
(!strncmp(arg, "--abbrev", 8) &&
(arg[8] == '=' || arg[8] == '\0'))) {
- if (arg[3] != 'h' && !arg[8])
+ if (arg[2] != 'h' && !arg[8])
/* --abbrev only */
abbrev = DEFAULT_ABBREV;
else {
/* --hash= or --abbrev= */
char *end;
- if (arg[3] == 'h') {
+ if (arg[2] == 'h') {
hash_only = 1;
arg += 7;
}
unsigned char sha1[20];
while (*pattern) {
- if (resolve_ref(*pattern, sha1, 1, NULL)) {
+ if (!strncmp(*pattern, "refs/", 5) &&
+ resolve_ref(*pattern, sha1, 1, NULL)) {
if (!quiet)
- printf("%s %s\n",
- sha1_to_hex(sha1), *pattern);
+ show_one(*pattern, sha1);
}
else if (!quiet)
die("'%s' - not a valid ref", *pattern);