show-ref: move --quiet handling into show_one()
Do the same with --quiet as was done with -d, to remove the need to perform this check at show_one()'s call site from the --verify branch. Signed-off-by: Vladimir Panteleev <git@thecybershadow.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Vladimir Panteleev committed
Jan 23, 2017 at 18:00 UTC
14144d3b53b913b48970aa0947accfe34e745c0f
1 file changed
+4
-5
builtin/show-ref.c
+4
-5
@@ -22,6 +22,9 @@ static void show_one(const char *refname, const struct object_id *oid)
22
const char *hex;
23
struct object_id peeled;
24
25
+ if (quiet)
26
+ return;
27
+
28
hex = find_unique_abbrev(oid->hash, abbrev);
29
if (hash_only)
30
printf("%s\n", hex);
@@ -82,9 +85,6 @@ match:
85
die("git show-ref: bad ref %s (%s)", refname,
86
oid_to_hex(oid));
87
85
- if (quiet)
86
- return 0;
87
-
88
show_one(refname, oid);
89
90
return 0;
@@ -205,8 +205,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
205
206
if ((starts_with(*pattern, "refs/") || !strcmp(*pattern, "HEAD")) &&
207
!read_ref(*pattern, oid.hash)) {
208
- if (!quiet)
209
- show_one(*pattern, &oid);
208
+ show_one(*pattern, &oid);
209
}
210
else if (!quiet)
211
die("'%s' - not a valid ref", *pattern);