move "--follow needs one pathspec" rule to diff_setup_done
[gitweb.git] / diff.c
diff --git a/diff.c b/diff.c
index e34bf971207f7737c3b1a10968acd8ffb3ecf93d..a99b925ac74bc4f513bd9d860e757f385cca871b 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -3317,6 +3317,9 @@ void diff_setup_done(struct diff_options *options)
                options->output_format = DIFF_FORMAT_NO_OUTPUT;
                DIFF_OPT_SET(options, EXIT_WITH_STATUS);
        }
+
+       if (DIFF_OPT_TST(options, FOLLOW_RENAMES) && options->pathspec.nr != 1)
+               die(_("--follow requires exactly one pathspec"));
 }
 
 static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val)