git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] commit: add a commit.allowEmpty config variable
@ 2018-11-03 11:25 tanushree27
  2018-11-03 11:53 ` [[PATCH v2]] commit: add a commit.allowempty " tanushree27
  0 siblings, 1 reply; 14+ messages in thread
From: tanushree27 @ 2018-11-03 11:25 UTC (permalink / raw)
  To: git; +Cc: tanushree27

Add commit.allowEmpty configuration variable as a convenience for those
who always prefer --allow-empty.

Add tests to check the behavior introduced by this commit.

This closes https://github.com/git-for-windows/git/issues/1854

Signed-off-by: tanushree27 <tanushreetumane@gmail.com>
---
 Documentation/config.txt     |  5 +++++
 Documentation/git-commit.txt |  3 ++-
 builtin/commit.c             |  8 ++++++++
 t/t7500-commit.sh            | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c0727b7866..ac63b12ab3 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1467,6 +1467,11 @@ commit.verbose::
 	A boolean or int to specify the level of verbose with `git commit`.
 	See linkgit:git-commit[1].
 
+commit.allowempty::
+	A boolean to specify whether empty commits are allowed with `git
+	commit`. See linkgit:git-commit[1]. 
+	Defaults to false.
+
 credential.helper::
 	Specify an external helper to be called when a username or
 	password credential is needed; the helper may consult external
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index f970a43422..07a5b60ab9 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -176,7 +176,8 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
 	Usually recording a commit that has the exact same tree as its
 	sole parent commit is a mistake, and the command prevents you
 	from making such a commit.  This option bypasses the safety, and
-	is primarily for use by foreign SCM interface scripts.
+	is primarily for use by foreign SCM interface scripts. See
+	`commit.allowempty` in linkgit:git-config[1].
 
 --allow-empty-message::
        Like --allow-empty this command is primarily for use by foreign
diff --git a/builtin/commit.c b/builtin/commit.c
index 67fa949204..4516309ac2 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -101,6 +101,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;
 static int edit_flag = -1; /* unspecified */
 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
 static int config_commit_verbose = -1; /* unspecified */
+static int config_commit_allow_empty = -1; /* unspecified */
 static int no_post_rewrite, allow_empty_message;
 static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
 static char *sign_commit;
@@ -1435,6 +1436,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
 		config_commit_verbose = git_config_bool_or_int(k, v, &is_bool);
 		return 0;
 	}
+	if (!strcmp(k, "commit.allowempty")) {
+		config_commit_allow_empty = git_config_bool(k, v);
+		return 0;
+	}
 
 	status = git_gpg_config(k, v, NULL);
 	if (status)
@@ -1556,6 +1561,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (verbose == -1)
 		verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
 
+	if (config_commit_allow_empty >= 0)  /* if allowEmpty is allowed in config*/
+		allow_empty = config_commit_allow_empty;
+	
 	if (dry_run)
 		return dry_run_commit(argc, argv, prefix, current_head, &s);
 	index_file = prepare_index(argc, argv, prefix, current_head, 0);
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 170b4810e0..fb9bfbfb03 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -359,4 +359,36 @@ test_expect_success 'new line found before status message in commit template' '
 	test_i18ncmp expected-template editor-input
 '
 
+# Tests for commit.allowempty config
+
+test_expect_success "no commit.allowempty and no --allow-empty" "
+	test_must_fail git commit -m 'test'
+"
+
+test_expect_success "no commit.allowempty and --allow-empty" "
+	git commit --allow-empty -m 'test'
+"
+
+for i in true 1
+do
+	test_expect_success "commit.allowempty=$i and no --allow-empty" "
+		git -c commit.allowempty=$i commit -m 'test'
+	"
+
+	test_expect_success "commit.allowempty=$i and --allow-empty" "
+		git -c commit.allowempty=$i commit --allow-empty -m 'test'
+	"
+done
+
+for i in false 0
+do
+	test_expect_success "commit.allowempty=$i and no --allow-empty" "
+		test_must_fail git -c commit.allowempty=$i commit -m 'test'
+	"
+
+	test_expect_success "commit.allowempty=$i and --allow-empty" "
+		test_must_fail git -c commit.allowempty=$i commit --allow-empty -m 'test'
+	"
+done
+
 test_done
-- 
2.19.1.windows.1.495.gd17cbd8b09


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [[PATCH v2]] commit: add a commit.allowempty config variable
  2018-11-03 11:25 [PATCH] commit: add a commit.allowEmpty config variable tanushree27
@ 2018-11-03 11:53 ` tanushree27
  2018-11-03 14:43   ` Duy Nguyen
  0 siblings, 1 reply; 14+ messages in thread
From: tanushree27 @ 2018-11-03 11:53 UTC (permalink / raw)
  To: git; +Cc: tanushree27

Add commit.allowempty configuration variable as a convenience for those
who always prefer --allow-empty.

Add tests to check the behavior introduced by this commit.

This closes https://github.com/git-for-windows/git/issues/1854

Signed-off-by: tanushree27 <tanushreetumane@gmail.com>
---
 Documentation/config.txt     |  5 +++++
 Documentation/git-commit.txt |  3 ++-
 builtin/commit.c             |  8 ++++++++
 t/t7500-commit.sh            | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c0727b7866..ac63b12ab3 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1467,6 +1467,11 @@ commit.verbose::
 	A boolean or int to specify the level of verbose with `git commit`.
 	See linkgit:git-commit[1].
 
+commit.allowempty::
+	A boolean to specify whether empty commits are allowed with `git
+	commit`. See linkgit:git-commit[1]. 
+	Defaults to false.
+
 credential.helper::
 	Specify an external helper to be called when a username or
 	password credential is needed; the helper may consult external
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index f970a43422..07a5b60ab9 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -176,7 +176,8 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
 	Usually recording a commit that has the exact same tree as its
 	sole parent commit is a mistake, and the command prevents you
 	from making such a commit.  This option bypasses the safety, and
-	is primarily for use by foreign SCM interface scripts.
+	is primarily for use by foreign SCM interface scripts. See
+	`commit.allowempty` in linkgit:git-config[1].
 
 --allow-empty-message::
        Like --allow-empty this command is primarily for use by foreign
diff --git a/builtin/commit.c b/builtin/commit.c
index 67fa949204..4516309ac2 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -101,6 +101,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;
 static int edit_flag = -1; /* unspecified */
 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
 static int config_commit_verbose = -1; /* unspecified */
+static int config_commit_allow_empty = -1; /* unspecified */
 static int no_post_rewrite, allow_empty_message;
 static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
 static char *sign_commit;
@@ -1435,6 +1436,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
 		config_commit_verbose = git_config_bool_or_int(k, v, &is_bool);
 		return 0;
 	}
+	if (!strcmp(k, "commit.allowempty")) {
+		config_commit_allow_empty = git_config_bool(k, v);
+		return 0;
+	}
 
 	status = git_gpg_config(k, v, NULL);
 	if (status)
@@ -1556,6 +1561,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (verbose == -1)
 		verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
 
+	if (config_commit_allow_empty >= 0)  /* if allowEmpty is allowed in config*/
+		allow_empty = config_commit_allow_empty;
+	
 	if (dry_run)
 		return dry_run_commit(argc, argv, prefix, current_head, &s);
 	index_file = prepare_index(argc, argv, prefix, current_head, 0);
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 170b4810e0..fb9bfbfb03 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -359,4 +359,36 @@ test_expect_success 'new line found before status message in commit template' '
 	test_i18ncmp expected-template editor-input
 '
 
+# Tests for commit.allowempty config
+
+test_expect_success "no commit.allowempty and no --allow-empty" "
+	test_must_fail git commit -m 'test'
+"
+
+test_expect_success "no commit.allowempty and --allow-empty" "
+	git commit --allow-empty -m 'test'
+"
+
+for i in true 1
+do
+	test_expect_success "commit.allowempty=$i and no --allow-empty" "
+		git -c commit.allowempty=$i commit -m 'test'
+	"
+
+	test_expect_success "commit.allowempty=$i and --allow-empty" "
+		git -c commit.allowempty=$i commit --allow-empty -m 'test'
+	"
+done
+
+for i in false 0
+do
+	test_expect_success "commit.allowempty=$i and no --allow-empty" "
+		test_must_fail git -c commit.allowempty=$i commit -m 'test'
+	"
+
+	test_expect_success "commit.allowempty=$i and --allow-empty" "
+		test_must_fail git -c commit.allowempty=$i commit --allow-empty -m 'test'
+	"
+done
+
 test_done
-- 
2.19.1.windows.1.495.gd17cbd8b09


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [[PATCH v2]] commit: add a commit.allowempty config variable
  2018-11-03 11:53 ` [[PATCH v2]] commit: add a commit.allowempty " tanushree27
@ 2018-11-03 14:43   ` Duy Nguyen
  2018-11-03 15:12     ` [PATCH v3] commit: add a commit.allowEmpty " tanushree27
  0 siblings, 1 reply; 14+ messages in thread
From: Duy Nguyen @ 2018-11-03 14:43 UTC (permalink / raw)
  To: tanushreetumane; +Cc: Git Mailing List

On Sat, Nov 3, 2018 at 12:55 PM tanushree27 <tanushreetumane@gmail.com> wrote:
>
> Add commit.allowempty configuration variable as a convenience for those
> who always prefer --allow-empty.
>
> Add tests to check the behavior introduced by this commit.
>
> This closes https://github.com/git-for-windows/git/issues/1854
>
> Signed-off-by: tanushree27 <tanushreetumane@gmail.com>
> ---
>  Documentation/config.txt     |  5 +++++
>  Documentation/git-commit.txt |  3 ++-
>  builtin/commit.c             |  8 ++++++++
>  t/t7500-commit.sh            | 32 ++++++++++++++++++++++++++++++++
>  4 files changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index c0727b7866..ac63b12ab3 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1467,6 +1467,11 @@ commit.verbose::
>         A boolean or int to specify the level of verbose with `git commit`.
>         See linkgit:git-commit[1].
>
> +commit.allowempty::

The current naming convention is camelCase. So this should be commit.allowEmpty.

> +       A boolean to specify whether empty commits are allowed with `git
> +       commit`. See linkgit:git-commit[1].
> +       Defaults to false.
> +
>  credential.helper::
>         Specify an external helper to be called when a username or
>         password credential is needed; the helper may consult external
> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
> index f970a43422..07a5b60ab9 100644
> --- a/Documentation/git-commit.txt
> +++ b/Documentation/git-commit.txt
> @@ -176,7 +176,8 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
>         Usually recording a commit that has the exact same tree as its
>         sole parent commit is a mistake, and the command prevents you
>         from making such a commit.  This option bypasses the safety, and
> -       is primarily for use by foreign SCM interface scripts.
> +       is primarily for use by foreign SCM interface scripts. See
> +       `commit.allowempty` in linkgit:git-config[1].

Same.

>
>  --allow-empty-message::
>         Like --allow-empty this command is primarily for use by foreign

-- 
Duy

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3] commit: add a commit.allowEmpty config variable
  2018-11-03 14:43   ` Duy Nguyen
@ 2018-11-03 15:12     ` tanushree27
  2018-11-03 19:07       ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 14+ messages in thread
From: tanushree27 @ 2018-11-03 15:12 UTC (permalink / raw)
  To: pclouds; +Cc: git, tanushreetumane

Add commit.allowEmpty configuration variable as a convenience for those
who always prefer --allow-empty.

Add tests to check the behavior introduced by this commit.

This closes https://github.com/git-for-windows/git/issues/1854

Signed-off-by: tanushree27 <tanushreetumane@gmail.com>
---
 Documentation/config.txt     |  5 +++++
 Documentation/git-commit.txt |  3 ++-
 builtin/commit.c             |  8 ++++++++
 t/t7500-commit.sh            | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c0727b7866..f3828518a5 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1467,6 +1467,11 @@ commit.verbose::
 	A boolean or int to specify the level of verbose with `git commit`.
 	See linkgit:git-commit[1].
 
+commit.allowEmpty::
+	A boolean to specify whether empty commits are allowed with `git
+	commit`. See linkgit:git-commit[1]. 
+	Defaults to false.
+
 credential.helper::
 	Specify an external helper to be called when a username or
 	password credential is needed; the helper may consult external
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index f970a43422..5d3bbf017a 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -176,7 +176,8 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
 	Usually recording a commit that has the exact same tree as its
 	sole parent commit is a mistake, and the command prevents you
 	from making such a commit.  This option bypasses the safety, and
-	is primarily for use by foreign SCM interface scripts.
+	is primarily for use by foreign SCM interface scripts. See
+	`commit.allowEmpty` in linkgit:git-config[1].
 
 --allow-empty-message::
        Like --allow-empty this command is primarily for use by foreign
diff --git a/builtin/commit.c b/builtin/commit.c
index 67fa949204..4516309ac2 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -101,6 +101,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;
 static int edit_flag = -1; /* unspecified */
 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
 static int config_commit_verbose = -1; /* unspecified */
+static int config_commit_allow_empty = -1; /* unspecified */
 static int no_post_rewrite, allow_empty_message;
 static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
 static char *sign_commit;
@@ -1435,6 +1436,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
 		config_commit_verbose = git_config_bool_or_int(k, v, &is_bool);
 		return 0;
 	}
+	if (!strcmp(k, "commit.allowempty")) {
+		config_commit_allow_empty = git_config_bool(k, v);
+		return 0;
+	}
 
 	status = git_gpg_config(k, v, NULL);
 	if (status)
@@ -1556,6 +1561,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (verbose == -1)
 		verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
 
+	if (config_commit_allow_empty >= 0)  /* if allowEmpty is allowed in config*/
+		allow_empty = config_commit_allow_empty;
+	
 	if (dry_run)
 		return dry_run_commit(argc, argv, prefix, current_head, &s);
 	index_file = prepare_index(argc, argv, prefix, current_head, 0);
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 170b4810e0..25a7facd53 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -359,4 +359,36 @@ test_expect_success 'new line found before status message in commit template' '
 	test_i18ncmp expected-template editor-input
 '
 
+# Tests for commit.allowEmpty config
+
+test_expect_success "no commit.allowEmpty and no --allow-empty" "
+	test_must_fail git commit -m 'test'
+"
+
+test_expect_success "no commit.allowEmpty and --allow-empty" "
+	git commit --allow-empty -m 'test'
+"
+
+for i in true 1
+do
+	test_expect_success "commit.allowEmpty=$i and no --allow-empty" "
+		git -c commit.allowEmpty=$i commit -m 'test'
+	"
+
+	test_expect_success "commit.allowEmpty=$i and --allow-empty" "
+		git -c commit.allowEmpty=$i commit --allow-empty -m 'test'
+	"
+done
+
+for i in false 0
+do
+	test_expect_success "commit.allowEmpty=$i and no --allow-empty" "
+		test_must_fail git -C commit.allowEmpty=$i commit -m 'test'
+	"
+
+	test_expect_success "commit.allowEmpty=$i and --allow-empty" "
+		test_must_fail git -c commit.allowEmpty=$i commit --allow-empty -m 'test'
+	"
+done
+
 test_done
-- 
2.19.1.windows.1.495.g9597888df3.dirty


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v3] commit: add a commit.allowEmpty config variable
  2018-11-03 15:12     ` [PATCH v3] commit: add a commit.allowEmpty " tanushree27
@ 2018-11-03 19:07       ` Ævar Arnfjörð Bjarmason
  2018-11-05  0:30         ` Junio C Hamano
  2018-11-13 15:56         ` [PATCH v4] " Tanushree Tumane
  0 siblings, 2 replies; 14+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-11-03 19:07 UTC (permalink / raw)
  To: tanushree27; +Cc: pclouds, git


On Sat, Nov 03 2018, tanushree27 wrote:

> +commit.allowEmpty::
> +	A boolean to specify whether empty commits are allowed with `git
> +	commit`. See linkgit:git-commit[1].
> +	Defaults to false.
> +

Good.

> +	if (config_commit_allow_empty >= 0)  /* if allowEmpty is allowed in config*/
> +		allow_empty = config_commit_allow_empty;
> +

This works, but != -1 is our usual idiom for this as you initialize it
to -1. I think that comment can also go then, since it's clear what's
going on.

> +# Tests for commit.allowEmpty config
> +
> +test_expect_success "no commit.allowEmpty and no --allow-empty" "
> +	test_must_fail git commit -m 'test'
> +"
> +
> +test_expect_success "no commit.allowEmpty and --allow-empty" "
> +	git commit --allow-empty -m 'test'
> +"
> +
> +for i in true 1
> +do
> +	test_expect_success "commit.allowEmpty=$i and no --allow-empty" "
> +		git -c commit.allowEmpty=$i commit -m 'test'
> +	"
> +
> +	test_expect_success "commit.allowEmpty=$i and --allow-empty" "
> +		git -c commit.allowEmpty=$i commit --allow-empty -m 'test'
> +	"
> +done
> +
> +for i in false 0
> +do
> +	test_expect_success "commit.allowEmpty=$i and no --allow-empty" "
> +		test_must_fail git -C commit.allowEmpty=$i commit -m 'test'
> +	"
> +
> +	test_expect_success "commit.allowEmpty=$i and --allow-empty" "
> +		test_must_fail git -c commit.allowEmpty=$i commit --allow-empty -m 'test'
> +	"
> +done

Testing both 1 and "true" can be dropped here. Things that use
git_config_bool() can just assume it works, we test it more exhaustively
elsewhere.

Your patch has whitespace errors. Try with "git show --check" or apply
it with git-am, it also doesn't apply cleanly on the latest master.

But on this patch in general: I don't mind making this configurable, but
neither your commit message nor these tests make it clear what the
actual motivation is, which can be seen on the upstream GitHub bug
report.

I.e. you seemingly have no interest in using "git commit" to produce
empty commits, but are just trying to cherry-pick something and it's
failing because it (presumably, or am I missing something) cherry picks
an existing commit content ends up not changing anything.

I.e. you'd like to make the logic 37f7a85793 ("Teach commit about
CHERRY_PICK_HEAD", 2011-02-19) added a message for the default.

So let's talk about that use case, and for those of us less familiar
with this explain why it is that this needs to still be optional at
all. I.e. aren't we just exposing an implementation detail here where
cherry-pick uses the commit machinery? Should we maybe just always pass
--allow-empty on cherry-pick, if not why not?

I can think of some reasons, but the above is a hint that both this
patch + the current documentation which talks about "foreign SCM
scripts" have drifted very far from what this is actually being used
for, so let's update that.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3] commit: add a commit.allowEmpty config variable
  2018-11-03 19:07       ` Ævar Arnfjörð Bjarmason
@ 2018-11-05  0:30         ` Junio C Hamano
  2018-11-13 15:56         ` [PATCH v4] " Tanushree Tumane
  1 sibling, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2018-11-05  0:30 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: tanushree27, pclouds, git

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> I.e. you seemingly have no interest in using "git commit" to produce
> empty commits, but are just trying to cherry-pick something and it's
> failing because it (presumably, or am I missing something) cherry picks
> an existing commit content ends up not changing anything.
>
> I.e. you'd like to make the logic 37f7a85793 ("Teach commit about
> CHERRY_PICK_HEAD", 2011-02-19) added a message for the default.
>
> So let's talk about that use case, and for those of us less familiar
> with this explain why it is that this needs to still be optional at
> all. I.e. aren't we just exposing an implementation detail here where
> cherry-pick uses the commit machinery? Should we maybe just always pass
> --allow-empty on cherry-pick, if not why not?
>
> I can think of some reasons, but the above is a hint that both this
> patch + the current documentation which talks about "foreign SCM
> scripts" have drifted very far from what this is actually being used
> for, so let's update that.

The command line "--allowAnything" in general is meant to be an
escape hatch for unusual situations, and if a workflow requires
constant use of that escape hatch, there is something wrong either
in the workflow or in the tool used in the workflow, and it is what
we should first see if we can fix, I would think, before making it
easy to constantly use the escape hatch.

I didn't look at the external reference you looked at but it sounds
like your review comment is taking the topic in the right direction.

Thanks for digging for the backstory.  

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v4] commit: add a commit.allowEmpty config variable
  2018-11-03 19:07       ` Ævar Arnfjörð Bjarmason
  2018-11-05  0:30         ` Junio C Hamano
@ 2018-11-13 15:56         ` Tanushree Tumane
  2018-11-13 19:24           ` Johannes Schindelin
  1 sibling, 1 reply; 14+ messages in thread
From: Tanushree Tumane @ 2018-11-13 15:56 UTC (permalink / raw)
  To: avarab; +Cc: git, pclouds, johannes.Schindelin, tanushree27

From: tanushree27 <tanushreetumane@gmail.com>

when we cherrypick an existing commit it doesn't change anything and
therefore it fails prompting to reset (skip commit) or commit using
--allow-empty attribute and then continue.

Add commit.allowEmpty configuration variable as a convenience to skip
this process.

Add tests to check the behavior introduced by this commit.

This closes https://github.com/git-for-windows/git/issues/1854

Signed-off-by: tanushree27 <tanushreetumane@gmail.com>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
---
 Documentation/config.txt     |  5 +++++
 Documentation/git-commit.txt |  3 ++-
 builtin/commit.c             |  8 ++++++++
 t/t3500-cherry.sh            | 10 ++++++++++
 4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c0727b7866..f3828518a5 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1467,6 +1467,11 @@ commit.verbose::
 	A boolean or int to specify the level of verbose with `git commit`.
 	See linkgit:git-commit[1].
 
+commit.allowEmpty::
+	A boolean to specify whether empty commits are allowed with `git
+	commit`. See linkgit:git-commit[1]. 
+	Defaults to false.
+
 credential.helper::
 	Specify an external helper to be called when a username or
 	password credential is needed; the helper may consult external
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index f970a43422..5d3bbf017a 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -176,7 +176,8 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
 	Usually recording a commit that has the exact same tree as its
 	sole parent commit is a mistake, and the command prevents you
 	from making such a commit.  This option bypasses the safety, and
-	is primarily for use by foreign SCM interface scripts.
+	is primarily for use by foreign SCM interface scripts. See
+	`commit.allowEmpty` in linkgit:git-config[1].
 
 --allow-empty-message::
        Like --allow-empty this command is primarily for use by foreign
diff --git a/builtin/commit.c b/builtin/commit.c
index 67fa949204..4516309ac2 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -101,6 +101,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;
 static int edit_flag = -1; /* unspecified */
 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
 static int config_commit_verbose = -1; /* unspecified */
+static int config_commit_allow_empty = -1; /* unspecified */
 static int no_post_rewrite, allow_empty_message;
 static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
 static char *sign_commit;
@@ -1435,6 +1436,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
 		config_commit_verbose = git_config_bool_or_int(k, v, &is_bool);
 		return 0;
 	}
+	if (!strcmp(k, "commit.allowempty")) {
+		config_commit_allow_empty = git_config_bool(k, v);
+		return 0;
+	}
 
 	status = git_gpg_config(k, v, NULL);
 	if (status)
@@ -1556,6 +1561,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (verbose == -1)
 		verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
 
+	if (config_commit_allow_empty >= 0)  /* if allowEmpty is allowed in config*/
+		allow_empty = config_commit_allow_empty;
+	
 	if (dry_run)
 		return dry_run_commit(argc, argv, prefix, current_head, &s);
 	index_file = prepare_index(argc, argv, prefix, current_head, 0);
diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh
index f038f34b7c..11504e2d9f 100755
--- a/t/t3500-cherry.sh
+++ b/t/t3500-cherry.sh
@@ -55,4 +55,14 @@ test_expect_success \
      expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*"
 '
 
+
+# Tests for commit.allowEmpty config
+
+test_expect_success 'cherry-pick existing commit with commit.allowEmpty' '
+    test_tick &&
+	test_commit "first" &&
+	test_commit "second" &&
+	git -c commit.allowEmpty=true cherry-pick HEAD~1
+'
+
 test_done
-- 
2.19.1.windows.1.495.g7e9d1c442b.dirty


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] commit: add a commit.allowEmpty config variable
  2018-11-13 15:56         ` [PATCH v4] " Tanushree Tumane
@ 2018-11-13 19:24           ` Johannes Schindelin
  2018-11-13 21:27             ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 14+ messages in thread
From: Johannes Schindelin @ 2018-11-13 19:24 UTC (permalink / raw)
  To: Tanushree Tumane; +Cc: avarab, git, pclouds

Hi,

On Tue, 13 Nov 2018, Tanushree Tumane wrote:

> From: tanushree27 <tanushreetumane@gmail.com>
> 
> when we cherrypick an existing commit it doesn't change anything and
> therefore it fails prompting to reset (skip commit) or commit using
> --allow-empty attribute and then continue.

This is a nice paragraph, but it might make sense to connect it to the
commit's oneline somehow. I, for one, was surprised to see the oneline
talk about `git commit` and the commit message about `git cherry-pick`.

I could imagine that an introductory paragraph, talking about why one
might want to commit empty commits, might be the best lead into the
subject, and the paragraph about `cherry-pick` could follow (and be
introduced by saying something along the lines that this config setting
has more reach than just `git commit`; it also affects `git cherry-pick`)?

Ciao,
Johannes

> 
> Add commit.allowEmpty configuration variable as a convenience to skip
> this process.
> 
> Add tests to check the behavior introduced by this commit.
> 
> This closes https://github.com/git-for-windows/git/issues/1854
> 
> Signed-off-by: tanushree27 <tanushreetumane@gmail.com>
> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
> ---
>  Documentation/config.txt     |  5 +++++
>  Documentation/git-commit.txt |  3 ++-
>  builtin/commit.c             |  8 ++++++++
>  t/t3500-cherry.sh            | 10 ++++++++++
>  4 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index c0727b7866..f3828518a5 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1467,6 +1467,11 @@ commit.verbose::
>  	A boolean or int to specify the level of verbose with `git commit`.
>  	See linkgit:git-commit[1].
>  
> +commit.allowEmpty::
> +	A boolean to specify whether empty commits are allowed with `git
> +	commit`. See linkgit:git-commit[1]. 
> +	Defaults to false.
> +
>  credential.helper::
>  	Specify an external helper to be called when a username or
>  	password credential is needed; the helper may consult external
> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
> index f970a43422..5d3bbf017a 100644
> --- a/Documentation/git-commit.txt
> +++ b/Documentation/git-commit.txt
> @@ -176,7 +176,8 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
>  	Usually recording a commit that has the exact same tree as its
>  	sole parent commit is a mistake, and the command prevents you
>  	from making such a commit.  This option bypasses the safety, and
> -	is primarily for use by foreign SCM interface scripts.
> +	is primarily for use by foreign SCM interface scripts. See
> +	`commit.allowEmpty` in linkgit:git-config[1].
>  
>  --allow-empty-message::
>         Like --allow-empty this command is primarily for use by foreign
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 67fa949204..4516309ac2 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -101,6 +101,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;
>  static int edit_flag = -1; /* unspecified */
>  static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
>  static int config_commit_verbose = -1; /* unspecified */
> +static int config_commit_allow_empty = -1; /* unspecified */
>  static int no_post_rewrite, allow_empty_message;
>  static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
>  static char *sign_commit;
> @@ -1435,6 +1436,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
>  		config_commit_verbose = git_config_bool_or_int(k, v, &is_bool);
>  		return 0;
>  	}
> +	if (!strcmp(k, "commit.allowempty")) {
> +		config_commit_allow_empty = git_config_bool(k, v);
> +		return 0;
> +	}
>  
>  	status = git_gpg_config(k, v, NULL);
>  	if (status)
> @@ -1556,6 +1561,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>  	if (verbose == -1)
>  		verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
>  
> +	if (config_commit_allow_empty >= 0)  /* if allowEmpty is allowed in config*/
> +		allow_empty = config_commit_allow_empty;
> +	
>  	if (dry_run)
>  		return dry_run_commit(argc, argv, prefix, current_head, &s);
>  	index_file = prepare_index(argc, argv, prefix, current_head, 0);
> diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh
> index f038f34b7c..11504e2d9f 100755
> --- a/t/t3500-cherry.sh
> +++ b/t/t3500-cherry.sh
> @@ -55,4 +55,14 @@ test_expect_success \
>       expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*"
>  '
>  
> +
> +# Tests for commit.allowEmpty config
> +
> +test_expect_success 'cherry-pick existing commit with commit.allowEmpty' '
> +    test_tick &&
> +	test_commit "first" &&
> +	test_commit "second" &&
> +	git -c commit.allowEmpty=true cherry-pick HEAD~1
> +'
> +
>  test_done
> -- 
> 2.19.1.windows.1.495.g7e9d1c442b.dirty
> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] commit: add a commit.allowEmpty config variable
  2018-11-13 19:24           ` Johannes Schindelin
@ 2018-11-13 21:27             ` Ævar Arnfjörð Bjarmason
  2018-11-14  4:16               ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-11-13 21:27 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Tanushree Tumane, git, pclouds


On Tue, Nov 13 2018, Johannes Schindelin wrote:

[Comments on the v4 patch also inline, found it easier to reply just to
this one]

> On Tue, 13 Nov 2018, Tanushree Tumane wrote:
>
>> From: tanushree27 <tanushreetumane@gmail.com>
>>
>> when we cherrypick an existing commit it doesn't change anything and
>> therefore it fails prompting to reset (skip commit) or commit using
>> --allow-empty attribute and then continue.
>
> This is a nice paragraph, but it might make sense to connect it to the
> commit's oneline somehow. I, for one, was surprised to see the oneline
> talk about `git commit` and the commit message about `git cherry-pick`.
>
> I could imagine that an introductory paragraph, talking about why one
> might want to commit empty commits, might be the best lead into the
> subject, and the paragraph about `cherry-pick` could follow (and be
> introduced by saying something along the lines that this config setting
> has more reach than just `git commit`; it also affects `git cherry-pick`)?

Agreed. I'm happy to see the test for-loop gone as I noted in
https://public-inbox.org/git/87d0rm7zeo.fsf@evledraar.gmail.com/ but as
noted in that v3 feedback the whole "why would anyone want this?"
explanation is still missing, and this still smells like a workaround
for a bug we should be fixing elsewhere in the sequencing code.

[The rest of this for Tanushree]

>>
>> Add commit.allowEmpty configuration variable as a convenience to skip
>> this process.
>>
>> Add tests to check the behavior introduced by this commit.
>>
>> This closes https://github.com/git-for-windows/git/issues/1854
>>
>> Signed-off-by: tanushree27 <tanushreetumane@gmail.com>
>> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
>> ---
>>  Documentation/config.txt     |  5 +++++
>>  Documentation/git-commit.txt |  3 ++-
>>  builtin/commit.c             |  8 ++++++++
>>  t/t3500-cherry.sh            | 10 ++++++++++
>>  4 files changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/config.txt b/Documentation/config.txt
>> index c0727b7866..f3828518a5 100644
>> --- a/Documentation/config.txt
>> +++ b/Documentation/config.txt
>> @@ -1467,6 +1467,11 @@ commit.verbose::
>>  	A boolean or int to specify the level of verbose with `git commit`.
>>  	See linkgit:git-commit[1].
>>
>> +commit.allowEmpty::
>> +	A boolean to specify whether empty commits are allowed with `git
>> +	commit`. See linkgit:git-commit[1].
>> +	Defaults to false.
>> +
>>  credential.helper::
>>  	Specify an external helper to be called when a username or
>>  	password credential is needed; the helper may consult external
>> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
>> index f970a43422..5d3bbf017a 100644
>> --- a/Documentation/git-commit.txt
>> +++ b/Documentation/git-commit.txt
>> @@ -176,7 +176,8 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
>>  	Usually recording a commit that has the exact same tree as its
>>  	sole parent commit is a mistake, and the command prevents you
>>  	from making such a commit.  This option bypasses the safety, and
>> -	is primarily for use by foreign SCM interface scripts.
>> +	is primarily for use by foreign SCM interface scripts. See
>> +	`commit.allowEmpty` in linkgit:git-config[1].
>>
>>  --allow-empty-message::
>>         Like --allow-empty this command is primarily for use by foreign
>> diff --git a/builtin/commit.c b/builtin/commit.c
>> index 67fa949204..4516309ac2 100644
>> --- a/builtin/commit.c
>> +++ b/builtin/commit.c
>> @@ -101,6 +101,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;
>>  static int edit_flag = -1; /* unspecified */
>>  static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
>>  static int config_commit_verbose = -1; /* unspecified */
>> +static int config_commit_allow_empty = -1; /* unspecified */
>>  static int no_post_rewrite, allow_empty_message;
>>  static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
>>  static char *sign_commit;
>> @@ -1435,6 +1436,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
>>  		config_commit_verbose = git_config_bool_or_int(k, v, &is_bool);
>>  		return 0;
>>  	}
>> +	if (!strcmp(k, "commit.allowempty")) {
>> +		config_commit_allow_empty = git_config_bool(k, v);
>> +		return 0;
>> +	}
>>
>>  	status = git_gpg_config(k, v, NULL);
>>  	if (status)
>> @@ -1556,6 +1561,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>>  	if (verbose == -1)
>>  		verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
>>
>> +	if (config_commit_allow_empty >= 0)  /* if allowEmpty is allowed in config*/
>> +		allow_empty = config_commit_allow_empty;
>> +

I had two comments on this hunk in my v3 feedback. It's fine to go for
something different (although I still think you should change it), but
for others following along you should at least say "I had such-and-such
feedback suggesting X, but decided to go for Y anyway because...".

>>  	if (dry_run)
>>  		return dry_run_commit(argc, argv, prefix, current_head, &s);
>>  	index_file = prepare_index(argc, argv, prefix, current_head, 0);
>> diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh
>> index f038f34b7c..11504e2d9f 100755
>> --- a/t/t3500-cherry.sh
>> +++ b/t/t3500-cherry.sh
>> @@ -55,4 +55,14 @@ test_expect_success \
>>       expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*"
>>  '
>>
>> +
>> +# Tests for commit.allowEmpty config
>> +

Let's drop this comment. It's redundant to the test description.

>> +test_expect_success 'cherry-pick existing commit with commit.allowEmpty' '
>> +    test_tick &&
>> +	test_commit "first" &&
>> +	test_commit "second" &&
>> +	git -c commit.allowEmpty=true cherry-pick HEAD~1
>> +'

So now you've dropped any tests of "git commit" (even though you're
changing commit.c, and just testing revert.c. So again, if that's all we
want isn't this whole thing just a simple bugfix of:

diff --git a/builtin/commit.c b/builtin/commit.c
index 96d336ec3d..1a12cc559e 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1546,6 +1546,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        if (verbose == -1)
                verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;

+       if (whence == FROM_CHERRY_PICK)
+               allow_empty = allow_empty_message = 1;
+
        if (dry_run)
                return dry_run_commit(argc, argv, prefix, current_head, &s);
        index_file = prepare_index(argc, argv, prefix, current_head, 0);

Possibly dropping the allow_empty_message part, but it seems reasonable
that whether you're re-picking an empty commit or one with an empty
message cherry-pick should always work.

I see that fails various existing tests, and I'm going to stop digging
now, but that brings me back to the "let's explain this better" part of
the feedback. I.e. if we can't just fix it let's explain why it can't be
made a default because it breaks such-and-such, so we need the config
option.

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] commit: add a commit.allowEmpty config variable
  2018-11-13 21:27             ` Ævar Arnfjörð Bjarmason
@ 2018-11-14  4:16               ` Junio C Hamano
  2018-11-14 14:04                 ` Johannes Schindelin
  2018-11-15  8:40                 ` Johannes Schindelin
  0 siblings, 2 replies; 14+ messages in thread
From: Junio C Hamano @ 2018-11-14  4:16 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Johannes Schindelin, Tanushree Tumane, git, pclouds

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> Agreed. I'm happy to see the test for-loop gone as I noted in
> https://public-inbox.org/git/87d0rm7zeo.fsf@evledraar.gmail.com/ but as
> noted in that v3 feedback the whole "why would anyone want this?"
> explanation is still missing, and this still smells like a workaround
> for a bug we should be fixing elsewhere in the sequencing code.

Thanks.  I share the same impression that this is sweeping a bug
under a wrong rug.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] commit: add a commit.allowEmpty config variable
  2018-11-14  4:16               ` Junio C Hamano
@ 2018-11-14 14:04                 ` Johannes Schindelin
  2018-11-15  8:40                 ` Johannes Schindelin
  1 sibling, 0 replies; 14+ messages in thread
From: Johannes Schindelin @ 2018-11-14 14:04 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Ævar Arnfjörð Bjarmason, Tanushree Tumane, git,
	pclouds

[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]

Hi,

On Wed, 14 Nov 2018, Junio C Hamano wrote:

> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> 
> > Agreed. I'm happy to see the test for-loop gone as I noted in
> > https://public-inbox.org/git/87d0rm7zeo.fsf@evledraar.gmail.com/ but as
> > noted in that v3 feedback the whole "why would anyone want this?"
> > explanation is still missing, and this still smells like a workaround
> > for a bug we should be fixing elsewhere in the sequencing code.
> 
> Thanks.  I share the same impression that this is sweeping a bug
> under a wrong rug.

I agree that the scenario is under-explained. Of course, I have to say
that this is not Tanushree's problem; They only copied what is in
https://github.com/git-for-windows/git/issues/1854 and @chucklu did not
grace us with an explanation, either.

Based on historical context, I would wager a bet that the scenario is
that some commits that may or may not have been in a different SCM
originally and that may or may not have been empty and/or squashed in
`master` need to be cherry-picked.

But I agree that this should be clarified. I prodded the original
wish-haver.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] commit: add a commit.allowEmpty config variable
  2018-11-14  4:16               ` Junio C Hamano
  2018-11-14 14:04                 ` Johannes Schindelin
@ 2018-11-15  8:40                 ` Johannes Schindelin
  2018-11-15  9:41                   ` Jeff King
  1 sibling, 1 reply; 14+ messages in thread
From: Johannes Schindelin @ 2018-11-15  8:40 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Ævar Arnfjörð Bjarmason, Tanushree Tumane, git,
	pclouds

[-- Attachment #1: Type: text/plain, Size: 1334 bytes --]

Hi,

On Wed, 14 Nov 2018, Junio C Hamano wrote:

> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> 
> > Agreed. I'm happy to see the test for-loop gone as I noted in
> > https://public-inbox.org/git/87d0rm7zeo.fsf@evledraar.gmail.com/ but as
> > noted in that v3 feedback the whole "why would anyone want this?"
> > explanation is still missing, and this still smells like a workaround
> > for a bug we should be fixing elsewhere in the sequencing code.
> 
> Thanks.  I share the same impression that this is sweeping a bug
> under a wrong rug.

I asked for clarification at
https://github.com/git-for-windows/git/issues/1854 and in my best
imitation of Lt Tawney Madison, I report back:

From @chucklu:

> my user case is like this :
>
> When I want to cherr-pick commits from A to G (ABCDEFG), image C and E
> are merge commits.  Then I will get lots of popup like:
>
>    The previous cherry-pick is now empty, possibly due to conflict
>    resolution.
>    If you wish to commit it anyway, use:
>
>        git commit --allow-empty
>
>    If you wish to skip this commit, use:
>
>        git reset
>
>    Then "git cherry-pick --continue" will resume cherry-picking
>    the remaining commits.

My quick interpretation of this is that the user actually needs a way to
skip silently commits which are now empty.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] commit: add a commit.allowEmpty config variable
  2018-11-15  8:40                 ` Johannes Schindelin
@ 2018-11-15  9:41                   ` Jeff King
  2018-11-15 16:16                     ` Johannes Schindelin
  0 siblings, 1 reply; 14+ messages in thread
From: Jeff King @ 2018-11-15  9:41 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Tanushree Tumane, git, pclouds

On Thu, Nov 15, 2018 at 09:40:38AM +0100, Johannes Schindelin wrote:

> From @chucklu:
> 
> > my user case is like this :
> >
> > When I want to cherr-pick commits from A to G (ABCDEFG), image C and E
> > are merge commits.  Then I will get lots of popup like:
> >
> >    The previous cherry-pick is now empty, possibly due to conflict
> >    resolution.
> >    If you wish to commit it anyway, use:
> >
> >        git commit --allow-empty
> >
> >    If you wish to skip this commit, use:
> >
> >        git reset
> >
> >    Then "git cherry-pick --continue" will resume cherry-picking
> >    the remaining commits.
> 
> My quick interpretation of this is that the user actually needs a way to
> skip silently commits which are now empty.

If it's always intended to be used with cherry-pick, shouldn't
cherry-pick learn a --keep-empty (like rebase has)? That would avoid
even stopping for this case in the first place.

-Peff

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] commit: add a commit.allowEmpty config variable
  2018-11-15  9:41                   ` Jeff King
@ 2018-11-15 16:16                     ` Johannes Schindelin
  0 siblings, 0 replies; 14+ messages in thread
From: Johannes Schindelin @ 2018-11-15 16:16 UTC (permalink / raw)
  To: Jeff King
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Tanushree Tumane, git, pclouds

Hi Peff,

On Thu, 15 Nov 2018, Jeff King wrote:

> On Thu, Nov 15, 2018 at 09:40:38AM +0100, Johannes Schindelin wrote:
> 
> > From @chucklu:
> > 
> > > my user case is like this :
> > >
> > > When I want to cherr-pick commits from A to G (ABCDEFG), image C and E
> > > are merge commits.  Then I will get lots of popup like:
> > >
> > >    The previous cherry-pick is now empty, possibly due to conflict
> > >    resolution.
> > >    If you wish to commit it anyway, use:
> > >
> > >        git commit --allow-empty
> > >
> > >    If you wish to skip this commit, use:
> > >
> > >        git reset
> > >
> > >    Then "git cherry-pick --continue" will resume cherry-picking
> > >    the remaining commits.
> > 
> > My quick interpretation of this is that the user actually needs a way to
> > skip silently commits which are now empty.
> 
> If it's always intended to be used with cherry-pick, shouldn't
> cherry-pick learn a --keep-empty (like rebase has)? That would avoid
> even stopping for this case in the first place.

I'd go for the other way round: --skip-empty.

However, given the very unhappy turn in that Git for Windows ticket
(somebody asks for a feature, then just sits back, and does not even
confirm that the analysis covers their use case, let alone participates in
this discussion), I am personally not really interested in driving this
one any further.

Tanushree proved that they know how to contribute to the Git mailing list,
as a pre-requisite for the Outreachy project, and that is the positive
outcome of this thread as far as I am concerned. I am pretty happy about
that, too.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-11-15 16:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-03 11:25 [PATCH] commit: add a commit.allowEmpty config variable tanushree27
2018-11-03 11:53 ` [[PATCH v2]] commit: add a commit.allowempty " tanushree27
2018-11-03 14:43   ` Duy Nguyen
2018-11-03 15:12     ` [PATCH v3] commit: add a commit.allowEmpty " tanushree27
2018-11-03 19:07       ` Ævar Arnfjörð Bjarmason
2018-11-05  0:30         ` Junio C Hamano
2018-11-13 15:56         ` [PATCH v4] " Tanushree Tumane
2018-11-13 19:24           ` Johannes Schindelin
2018-11-13 21:27             ` Ævar Arnfjörð Bjarmason
2018-11-14  4:16               ` Junio C Hamano
2018-11-14 14:04                 ` Johannes Schindelin
2018-11-15  8:40                 ` Johannes Schindelin
2018-11-15  9:41                   ` Jeff King
2018-11-15 16:16                     ` Johannes Schindelin

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).