]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff.c
Merge branch 'nd/diff-parseopt'
[thirdparty/git.git] / diff.c
diff --git a/diff.c b/diff.c
index 4d3cf83a27e5785f5fd50dd2ce6155c94eb50840..80ddc1167157d9da5d6426e9bb548f67705c2c19 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -5211,9 +5211,11 @@ static int diff_opt_unified(const struct option *opt,
 
        BUG_ON_OPT_NEG(unset);
 
-       options->context = strtol(arg, &s, 10);
-       if (*s)
-               return error(_("%s expects a numerical value"), "--unified");
+       if (arg) {
+               options->context = strtol(arg, &s, 10);
+               if (*s)
+                       return error(_("%s expects a numerical value"), "--unified");
+       }
        enable_patch_output(&options->output_format);
 
        return 0;
@@ -5272,7 +5274,7 @@ static void prep_parse_options(struct diff_options *options)
                          DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
                OPT_CALLBACK_F('U', "unified", options, N_("<n>"),
                               N_("generate diffs with <n> lines context"),
-                              PARSE_OPT_NONEG, diff_opt_unified),
+                              PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_unified),
                OPT_BOOL('W', "function-context", &options->flags.funccontext,
                         N_("generate diffs with <n> lines context")),
                OPT_BIT_F(0, "raw", &options->output_format,