Skip to content

Commit 47fa106

Browse files
committed
Merge branch 'ow/no-dryrun-in-add-i'
"git add -i --dry-run" does not dry-run, which was surprising. The combination of options has taught to error out. * ow/no-dryrun-in-add-i: add: die if both --dry-run and --interactive are given
2 parents e289f68 + a1989cf commit 47fa106

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
@@ -484,6 +484,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
484484
if (patch_interactive)
485485
add_interactive = 1;
486486
if (add_interactive) {
487+
if (show_only)
488+
die(_("--dry-run is incompatible with --interactive/--patch"));
487489
if (pathspec_from_file)
488490
die(_("--pathspec-from-file is incompatible with --interactive/--patch"));
489491
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
@@ -349,6 +349,10 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
349349
test_cmp expect.err actual.err
350350
'
351351

352+
test_expect_success 'git add --dry-run --interactive should fail' '
353+
test_must_fail git add --dry-run --interactive
354+
'
355+
352356
test_expect_success 'git add empty string should fail' '
353357
test_must_fail git add ""
354358
'

0 commit comments

Comments
 (0)