From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.5 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id CC0021F87F for ; Tue, 13 Nov 2018 19:24:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726295AbeKNFXg (ORCPT ); Wed, 14 Nov 2018 00:23:36 -0500 Received: from mout.gmx.net ([212.227.17.22]:47467 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725748AbeKNFXg (ORCPT ); Wed, 14 Nov 2018 00:23:36 -0500 Received: from [192.168.0.129] ([37.201.193.149]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MIQlv-1gKjPx3DGJ-004FPn; Tue, 13 Nov 2018 20:24:02 +0100 Date: Tue, 13 Nov 2018 20:24:02 +0100 (STD) From: Johannes Schindelin X-X-Sender: virtualbox@gitforwindows.org To: Tanushree Tumane cc: avarab@gmail.com, git@vger.kernel.org, pclouds@gmail.com Subject: Re: [PATCH v4] commit: add a commit.allowEmpty config variable In-Reply-To: <20181113155656.22975-1-tanushreetumane@gmail.com> Message-ID: References: <87d0rm7zeo.fsf@evledraar.gmail.com> <20181113155656.22975-1-tanushreetumane@gmail.com> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K1:AEKsovnfn01OcD4/hglaKYMvNoZqX2z/Cn9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GPmKf3T1igF+ohVwWEsp6j23ji72LPVBJmv2a8tKbEBdrOBMCsMRydAsVVkcKw yWAYEU3x2lpPga/PvttI0qyXrc3dJNrKN8laThOx2qblO4UkZCbB7HGWyOe9v5rG8+nsFgPWZ C/J88A1jwTg== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi, On Tue, 13 Nov 2018, Tanushree Tumane wrote: > From: tanushree27 > > 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 > Signed-off-by: Tanushree Tumane > --- > 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 > >