]> git.ipfire.org Git - thirdparty/git.git/commitdiff
am: handle --no-patch-format option
authorJeff King <peff@peff.net>
Mon, 5 Nov 2018 06:38:39 +0000 (01:38 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Nov 2018 03:55:35 +0000 (12:55 +0900)
Running "git am --no-patch-format" will currently segfault, since it
tries to parse a NULL argument. Instead, let's have it cancel any
previous --patch-format option.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c

index 3ee9a9d2a92aaa0e9716719640deaec7e260c811..dcb880b699a5c17311f0dbc083b9a3eda3a6b0fd 100644 (file)
@@ -2165,7 +2165,9 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
 {
        int *opt_value = opt->value;
 
-       if (!strcmp(arg, "mbox"))
+       if (unset)
+               *opt_value = PATCH_FORMAT_UNKNOWN;
+       else if (!strcmp(arg, "mbox"))
                *opt_value = PATCH_FORMAT_MBOX;
        else if (!strcmp(arg, "stgit"))
                *opt_value = PATCH_FORMAT_STGIT;