Skip to content

Commit a1989cf

Browse files
Ossegitster
authored andcommitted
add: die if both --dry-run and --interactive are given
The interactive machinery does not obey --dry-run. Die appropriately if both flags are passed. Signed-off-by: Øystein Walle <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e39198 commit a1989cf

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

builtin/add.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
459459
if (patch_interactive)
460460
add_interactive = 1;
461461
if (add_interactive) {
462+
if (show_only)
463+
die(_("--dry-run is incompatible with --interactive/--patch"));
462464
if (pathspec_from_file)
463465
die(_("--pathspec-from-file is incompatible with --interactive/--patch"));
464466
exit(interactive_add(argv + 1, prefix, patch_interactive));

t/t3700-add.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
343343
test_cmp expect.err actual.err
344344
'
345345

346+
test_expect_success 'git add --dry-run --interactive should fail' '
347+
test_must_fail git add --dry-run --interactive
348+
'
349+
346350
test_expect_success 'git add empty string should fail' '
347351
test_must_fail git add ""
348352
'

0 commit comments

Comments
 (0)