Code

git-fetch: Don't trigger a bus error when given the refspec "tag"
authorKevin Ballard <kevin@sb.org>
Sat, 5 Apr 2008 18:28:53 +0000 (14:28 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sat, 5 Apr 2008 23:31:45 +0000 (16:31 -0700)
When git-fetch encounters the refspec "tag" it assumes that the next
argument will be a tag name. If there is no next argument, it should
die gracefully instead of erroring.

Signed-off-by: Kevin Ballard <kevin@sb.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fetch.c

index a11548c8943f75b8d3e9ddfa1e6e2e3d13eaa431..5841b3e51a5c908a32761398d6237968ddac4d46 100644 (file)
@@ -637,6 +637,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                        if (!strcmp(argv[i], "tag")) {
                                char *ref;
                                i++;
+                               if (i >= argc)
+                                       die("You need to specify a tag name.");
                                ref = xmalloc(strlen(argv[i]) * 2 + 22);
                                strcpy(ref, "refs/tags/");
                                strcat(ref, argv[i]);