git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Øystein Walle" <oystwa@gmail.com>
To: git@vger.kernel.org
Cc: "Øystein Walle" <oystwa@gmail.com>
Subject: [PATCH] add: die if both --dry-run and --interactive are given
Date: Wed,  5 May 2021 16:52:04 +0200	[thread overview]
Message-ID: <20210505145204.51614-1-oystwa@gmail.com> (raw)

The interactive machinery does not obey --dry-run. Die appropriate if
both flags are passed.

Signed-off-by: Øystein Walle <oystwa@gmail.com>
---
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(+)

diff --git a/builtin/add.c b/builtin/add.c
index ea762a41e3..6077eb189f 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -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));
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index b3b122ff97..171b323f50 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -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 ""
 '
-- 
2.27.0


             reply	other threads:[~2021-05-05 14:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 14:52 Øystein Walle [this message]
2021-05-06  1:05 ` [PATCH] add: die if both --dry-run and --interactive are given ZheNing Hu
2021-05-06 14:10 ` Øystein Walle
2021-05-06 21:14   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210505145204.51614-1-oystwa@gmail.com \
    --to=oystwa@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).