]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add: die if both --dry-run and --interactive are given
authorØystein Walle <oystwa@gmail.com>
Wed, 5 May 2021 14:52:04 +0000 (16:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 May 2021 21:14:04 +0000 (06:14 +0900)
The interactive machinery does not obey --dry-run. Die appropriately
if both flags are passed.

Signed-off-by: Øystein Walle <oystwa@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
t/t3700-add.sh

index afccf2fd55431ab0210a81f662ceeca4981d867e..5cea3dc857eee12a0e50b4a2fcdf1788a7bfae77 100644 (file)
@@ -459,6 +459,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        if (patch_interactive)
                add_interactive = 1;
        if (add_interactive) {
+               if (show_only)
+                       die(_("--dry-run is incompatible with --interactive/--patch"));
                if (pathspec_from_file)
                        die(_("--pathspec-from-file is incompatible with --interactive/--patch"));
                exit(interactive_add(argv + 1, prefix, patch_interactive));
index b3b122ff977c20895df9e3d84b9511e603a435d3..171b323f50bbb15c436f2f4c2b7f2b4836a67169 100755 (executable)
@@ -343,6 +343,10 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
        test_cmp expect.err actual.err
 '
 
+test_expect_success 'git add --dry-run --interactive should fail' '
+       test_must_fail git add --dry-run --interactive
+'
+
 test_expect_success 'git add empty string should fail' '
        test_must_fail git add ""
 '