Skip to contentSkip to conversation

git-show-ref --verify: Fail if called without a reference

PATCH New Dmitry V. Levin 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-show-ref --verify: Fail if called without a reference

builtin-show-ref.c (cmd_show_ref): Fail if called with --verify option but without a reference.

---
 builtin-show-ref.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
builtin-show-ref.c +4 -2
index 853f13f..75211e6 100644
@@ -221,9 +221,11 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
 	}
 
 	if (verify) {
-		unsigned char sha1[20];
-
+		if (!pattern)
+			die("--verify requires a reference");
 		while (*pattern) {
+			unsigned char sha1[20];
+
 			if (!strncmp(*pattern, "refs/", 5) &&
 			    resolve_ref(*pattern, sha1, 1, NULL)) {
 				if (!quiet)
Signature · 1 line
1.5.0.1.GIT