add: die if both --dry-run and --interactive are given
PATCH 1/1 add: die if both --dry-run and --interactive are given
The interactive machinery does not obey --dry-run. Die appropriate if both flags are passed.
---
I think a better solution would be to allow this and improve the interactive machinery to handle --dry-run. This is what I could muster up at the moment.
builtin/add.c | 2 ++ t/t3700-add.sh | 4 ++++ 2 files changed, 6 insertions(+)
builtin/add.c +2 -0
@@ -457,6 +457,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));
t/t3700-add.sh +4 -0
@@ -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 "" '
Signature · 1 line
2.27.0
Hi, Øystein Walle,
Quoted 43 lines · Øystein Walle <[email protected]> 于2021年5月5日周三 下午10:53写道:
The interactive machinery does not obey --dry-run. Die appropriate if both flags are passed.
Signed-off-by Øystein Walle <[email protected]>---
I think a better solution would be to allow this and improve the interactive machinery to handle --dry-run. This is what I could muster up at the moment.builtin/add.c | 2 ++ t/t3700-add.sh | 4 ++++ 2 files changed, 6 insertions(+)builtin/add.c +2
-0@@ -457,6 +457,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));t/t3700-add.sh +4
-1@@ -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 "" ' --
Quoted 2 lines
2.27.0
Thank you for solving this confusion of mine. For the time being, it is an easier solution to make the two flags mutually exclusive. But if we need to make git add -i support --dry-run in the future, maybe we should passed the parameter DRY_RUN (maybe an environment variable) to the sub-process git -add--interactive.perl and finally this feature may be implemented in git apply.
Thanks!
--
ZheNing Hu
Hi, Junio and thanks for accepting the patch.
Quoted 2 lines
The interactive machinery does not obey --dry-run. Die appropriate if both flags are passed.
I just noticed a minor spelling error here: "appropriate" should be "appropriately". I can send a v2 if that's easier for you.
Øsse
Quoted 7 lines · Øystein Walle
Hi, Junio and thanks for accepting the patch.
Quoted 2 lines
The interactive machinery does not obey --dry-run. Die appropriate if both flags are passed.
I just noticed a minor spelling error here: "appropriate" should be "appropriately". I can send a v2 if that's easier for you.
Thanks, will locally amend---no need to resend.
Thanks for contributing.