git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] [Outreachy] commit: display advice hints when commit fails
@ 2019-12-17  9:17 Heba Waly via GitGitGadget
  2019-12-17  9:17 ` [PATCH 1/1] " Heba Waly via GitGitGadget
  2019-12-19  9:16 ` [PATCH v2 0/1] [Outreachy] " Heba Waly via GitGitGadget
  0 siblings, 2 replies; 27+ messages in thread
From: Heba Waly via GitGitGadget @ 2019-12-17  9:17 UTC (permalink / raw)
  To: git; +Cc: Heba Waly, Junio C Hamano

Display hints to the user when trying to commit without staging the modified
files first (when advice.statusHints is set to true). Change the output of
the unsuccessful commit from e.g:

[...]
=====

Changes not staged for commit:
==============================

modified: builtin/commit.c
==========================

 #

no changes added to commit
==========================

to:

[...]
=====

Changes not staged for commit:
==============================

(use "git add ..." to update what will be committed)
====================================================

(use "git checkout -- ..." to discard changes in working directory)
===================================================================

 #

modified: ../builtin/commit.c
=============================

 #

no changes added to commit (use "git add" and/or "git commit -a")
=================================================================

In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
2013-09-12) the intent was to disable status hints when writing to
COMMIT_EDITMSG, but in fact the implementation disabled status messages in
more locations, e.g in case the commit wasn't successful, status hints will
still be disabled and no hints will be displayed to the user although
advice.statusHints is set to true.

Signed-off-by: Heba Waly heba.waly@gmail.com [heba.waly@gmail.com]

Heba Waly (1):
  commit: display advice hints when commit fails

 builtin/commit.c                          | 1 +
 t/t7500-commit-template-squash-signoff.sh | 9 +++++++++
 2 files changed, 10 insertions(+)


base-commit: ad05a3d8e5a6a06443836b5e40434262d992889a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-495%2FHebaWaly%2Fhints-for-unsuccessful-commit-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-495/HebaWaly/hints-for-unsuccessful-commit-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/495
-- 
gitgitgadget

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

* [PATCH 1/1] commit: display advice hints when commit fails
  2019-12-17  9:17 [PATCH 0/1] [Outreachy] commit: display advice hints when commit fails Heba Waly via GitGitGadget
@ 2019-12-17  9:17 ` Heba Waly via GitGitGadget
  2019-12-17 22:41   ` Junio C Hamano
                     ` (2 more replies)
  2019-12-19  9:16 ` [PATCH v2 0/1] [Outreachy] " Heba Waly via GitGitGadget
  1 sibling, 3 replies; 27+ messages in thread
From: Heba Waly via GitGitGadget @ 2019-12-17  9:17 UTC (permalink / raw)
  To: git; +Cc: Heba Waly, Junio C Hamano, Heba Waly

From: Heba Waly <heba.waly@gmail.com>

Display hints to the user when trying to commit without staging the modified
files first (when advice.statusHints is set to true). Change the output of the
unsuccessful commit from e.g:

  # [...]
  # Changes not staged for commit:
  #   modified:   builtin/commit.c
  #
  # no changes added to commit

to:

  # [...]
  # Changes not staged for commit:
  #   (use "git add <file>..." to update what will be committed)
  #   (use "git checkout -- <file>..." to discard changes in working directory)
  #
  #   modified:   ../builtin/commit.c
  #
  # no changes added to commit (use "git add" and/or "git commit -a")

In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
2013-09-12) the intent was to disable status hints when writing to
COMMIT_EDITMSG, but in fact the implementation disabled status messages in
more locations, e.g in case the commit wasn't successful, status hints
will still be disabled and no hints will be displayed to the user although
advice.statusHints is set to true.

Signed-off-by: Heba Waly <heba.waly@gmail.com>
---
 builtin/commit.c                          | 1 +
 t/t7500-commit-template-squash-signoff.sh | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/builtin/commit.c b/builtin/commit.c
index 2db2ad0de4..4439666465 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -961,6 +961,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	 */
 	if (!committable && whence != FROM_MERGE && !allow_empty &&
 	    !(amend && is_a_merge(current_head))) {
+		s->hints = advice_status_hints;
 		s->display_comment_prefix = old_display_comment_prefix;
 		run_status(stdout, index_file, prefix, 0, s);
 		if (amend)
diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
index 46a5cd4b73..3d76e8ebbd 100755
--- a/t/t7500-commit-template-squash-signoff.sh
+++ b/t/t7500-commit-template-squash-signoff.sh
@@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' '
 	)
 '
 
+test_expect_success 'commit without staging files fails and displays hints' '
+	echo "initial" >>file &&
+	git add file &&
+	git commit -m initial &&
+	echo "changes" >>file &&
+	test_must_fail git commit -m initial >actual &&
+	test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
+'
+
 test_done
-- 
gitgitgadget

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

* Re: [PATCH 1/1] commit: display advice hints when commit fails
  2019-12-17  9:17 ` [PATCH 1/1] " Heba Waly via GitGitGadget
@ 2019-12-17 22:41   ` Junio C Hamano
  2019-12-17 22:45   ` Emily Shaffer
  2019-12-18  3:13   ` Jonathan Tan
  2 siblings, 0 replies; 27+ messages in thread
From: Junio C Hamano @ 2019-12-17 22:41 UTC (permalink / raw)
  To: Heba Waly via GitGitGadget; +Cc: git, Heba Waly

"Heba Waly via GitGitGadget" <gitgitgadget@gmail.com> writes:

> diff --git a/builtin/commit.c b/builtin/commit.c
> index 2db2ad0de4..4439666465 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -961,6 +961,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  	 */
>  	if (!committable && whence != FROM_MERGE && !allow_empty &&
>  	    !(amend && is_a_merge(current_head))) {
> +		s->hints = advice_status_hints;
>  		s->display_comment_prefix = old_display_comment_prefix;
>  		run_status(stdout, index_file, prefix, 0, s);
>  		if (amend)

It almost tempts me to say why this is not done inside run_status(),
which has other callers, but I think the answer is because we do not
want these hints when we are actually committing (iow, the ongoing
commit must be aborted before the user can actually say "git add"
etc. that are suggested).  

So the change makes sense to me.

Will queue.

> diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
> index 46a5cd4b73..3d76e8ebbd 100755
> --- a/t/t7500-commit-template-squash-signoff.sh
> +++ b/t/t7500-commit-template-squash-signoff.sh
> @@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' '
>  	)
>  '
>  
> +test_expect_success 'commit without staging files fails and displays hints' '
> +	echo "initial" >>file &&
> +	git add file &&
> +	git commit -m initial &&
> +	echo "changes" >>file &&
> +	test_must_fail git commit -m initial >actual &&
> +	test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
> +'
> +
>  test_done

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

* Re: [PATCH 1/1] commit: display advice hints when commit fails
  2019-12-17  9:17 ` [PATCH 1/1] " Heba Waly via GitGitGadget
  2019-12-17 22:41   ` Junio C Hamano
@ 2019-12-17 22:45   ` Emily Shaffer
  2019-12-19  3:47     ` Heba Waly
  2019-12-18  3:13   ` Jonathan Tan
  2 siblings, 1 reply; 27+ messages in thread
From: Emily Shaffer @ 2019-12-17 22:45 UTC (permalink / raw)
  To: Heba Waly via GitGitGadget; +Cc: git, Heba Waly, Junio C Hamano

On Tue, Dec 17, 2019 at 09:17:22AM +0000, Heba Waly via GitGitGadget wrote:
> From: Heba Waly <heba.waly@gmail.com>
> 
> Display hints to the user when trying to commit without staging the modified
> files first (when advice.statusHints is set to true). Change the output of the
> unsuccessful commit from e.g:
> 
>   # [...]
>   # Changes not staged for commit:
>   #   modified:   builtin/commit.c
>   #
>   # no changes added to commit
> 
> to:
> 
>   # [...]
>   # Changes not staged for commit:
>   #   (use "git add <file>..." to update what will be committed)
>   #   (use "git checkout -- <file>..." to discard changes in working directory)
>   #
>   #   modified:   ../builtin/commit.c
>   #
>   # no changes added to commit (use "git add" and/or "git commit -a")
> 
> In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
> 2013-09-12) the intent was to disable status hints when writing to
> COMMIT_EDITMSG, but in fact the implementation disabled status messages in
> more locations, e.g in case the commit wasn't successful, status hints
> will still be disabled and no hints will be displayed to the user although
> advice.statusHints is set to true.
> 
> Signed-off-by: Heba Waly <heba.waly@gmail.com>
> ---
>  builtin/commit.c                          | 1 +
>  t/t7500-commit-template-squash-signoff.sh | 9 +++++++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 2db2ad0de4..4439666465 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -961,6 +961,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  	 */
>  	if (!committable && whence != FROM_MERGE && !allow_empty &&
>  	    !(amend && is_a_merge(current_head))) {
> +		s->hints = advice_status_hints;

Hm. This looks like it turns hints back on specifically for this case,
but might not fix other places where ea9882bfc4 turned them off.

I think the intent of that commit was to not put hints into the editor,
so does it make sense to instead wrap this guy:

  /*                                                                       
   * Most hints are counter-productive when the commit has                 
   * already started.                                                      
   */                                                                      
  s->hints = 0;  

in "if (use_editor)"?

I didn't try it on my end. Maybe it won't help much, because we think
we're going to use the editor right up until we realize it's not
committable?

I wonder which other cases that commit got rid of hints for by accident.

 - Emily

>  		s->display_comment_prefix = old_display_comment_prefix;
>  		run_status(stdout, index_file, prefix, 0, s);
>  		if (amend)
> diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
> index 46a5cd4b73..3d76e8ebbd 100755
> --- a/t/t7500-commit-template-squash-signoff.sh
> +++ b/t/t7500-commit-template-squash-signoff.sh
> @@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' '
>  	)
>  '
>  
> +test_expect_success 'commit without staging files fails and displays hints' '
> +	echo "initial" >>file &&
> +	git add file &&
> +	git commit -m initial &&
> +	echo "changes" >>file &&
> +	test_must_fail git commit -m initial >actual &&
> +	test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
> +'
> +
>  test_done
> -- 
> gitgitgadget

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

* Re: [PATCH 1/1] commit: display advice hints when commit fails
  2019-12-17  9:17 ` [PATCH 1/1] " Heba Waly via GitGitGadget
  2019-12-17 22:41   ` Junio C Hamano
  2019-12-17 22:45   ` Emily Shaffer
@ 2019-12-18  3:13   ` Jonathan Tan
  2019-12-18 18:14     ` Junio C Hamano
  2019-12-19  3:48     ` Heba Waly
  2 siblings, 2 replies; 27+ messages in thread
From: Jonathan Tan @ 2019-12-18  3:13 UTC (permalink / raw)
  To: gitgitgadget; +Cc: git, heba.waly, gitster, Jonathan Tan

> From: Heba Waly <heba.waly@gmail.com>
> 
> Display hints to the user when trying to commit without staging the modified
> files first (when advice.statusHints is set to true). Change the output of the
> unsuccessful commit from e.g:

Wrap your commit messages at 72 characters.

>   # [...]
>   # Changes not staged for commit:
>   #   modified:   builtin/commit.c
>   #
>   # no changes added to commit
> 
> to:
> 
>   # [...]
>   # Changes not staged for commit:
>   #   (use "git add <file>..." to update what will be committed)
>   #   (use "git checkout -- <file>..." to discard changes in working directory)
>   #
>   #   modified:   ../builtin/commit.c

For tidiness, can this line also be "builtin/commit.c" (that is, without
the "../" at the beginning) to match what's before "to:"?

> In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
> 2013-09-12) the intent was to disable status hints when writing to
> COMMIT_EDITMSG, but in fact the implementation disabled status messages in
> more locations, e.g in case the commit wasn't successful, status hints
> will still be disabled and no hints will be displayed to the user although
> advice.statusHints is set to true.
> 
> Signed-off-by: Heba Waly <heba.waly@gmail.com>
> ---
>  builtin/commit.c                          | 1 +
>  t/t7500-commit-template-squash-signoff.sh | 9 +++++++++

I wondered if there was a better place to put the test, but I couldn't
find one, so this is fine.

> @@ -961,6 +961,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  	 */
>  	if (!committable && whence != FROM_MERGE && !allow_empty &&
>  	    !(amend && is_a_merge(current_head))) {
> +		s->hints = advice_status_hints;
>  		s->display_comment_prefix = old_display_comment_prefix;
>  		run_status(stdout, index_file, prefix, 0, s);
>  		if (amend)

I checked that this undoing of "s->hints = 0" is safe, because s is no
longer used in this function nor in the calling function cmd_commit()
(which is the one that declared s locally).

Still probably worth a comment, though. For example:

  This status is to be printed to stdout, so hints will be useful to the
  user. Reset s->hints to what the user configured.

The corresponding comment on "s->hints = 0" might need to be tweaked,
too, but I can't think of anything at the moment.

> +test_expect_success 'commit without staging files fails and displays hints' '
> +	echo "initial" >>file &&
> +	git add file &&
> +	git commit -m initial &&
> +	echo "changes" >>file &&
> +	test_must_fail git commit -m initial >actual &&

Use another commit message for this, since this is no longer "initial".
(Maybe "after initial" or something like that.)

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

* Re: [PATCH 1/1] commit: display advice hints when commit fails
  2019-12-18  3:13   ` Jonathan Tan
@ 2019-12-18 18:14     ` Junio C Hamano
  2019-12-19  3:48     ` Heba Waly
  1 sibling, 0 replies; 27+ messages in thread
From: Junio C Hamano @ 2019-12-18 18:14 UTC (permalink / raw)
  To: Jonathan Tan; +Cc: gitgitgadget, git, heba.waly

Jonathan Tan <jonathantanmy@google.com> writes:

>> From: Heba Waly <heba.waly@gmail.com>
>> 
>> Display hints to the user when trying to commit without staging the modified
>> files first (when advice.statusHints is set to true). Change the output of the
>> unsuccessful commit from e.g:
>
> Wrap your commit messages at 72 characters.
>
>>   # [...]
>>   # Changes not staged for commit:
>>   #   modified:   builtin/commit.c
>>   #
>>   # no changes added to commit
>> 
>> to:
>> 
>>   # [...]
>>   # Changes not staged for commit:
>>   #   (use "git add <file>..." to update what will be committed)
>>   #   (use "git checkout -- <file>..." to discard changes in working directory)
>>   #
>>   #   modified:   ../builtin/commit.c
>
> For tidiness, can this line also be "builtin/commit.c" (that is, without
> the "../" at the beginning) to match what's before "to:"?
>
>> In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
>> 2013-09-12) the intent was to disable status hints when writing to
>> COMMIT_EDITMSG, but in fact the implementation disabled status messages in
>> more locations, e.g in case the commit wasn't successful, status hints
>> will still be disabled and no hints will be displayed to the user although
>> advice.statusHints is set to true.
>> 
>> Signed-off-by: Heba Waly <heba.waly@gmail.com>
>> ---
>>  builtin/commit.c                          | 1 +
>>  t/t7500-commit-template-squash-signoff.sh | 9 +++++++++
>
> I wondered if there was a better place to put the test, but I couldn't
> find one, so this is fine.
>
>> @@ -961,6 +961,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>>  	 */
>>  	if (!committable && whence != FROM_MERGE && !allow_empty &&
>>  	    !(amend && is_a_merge(current_head))) {
>> +		s->hints = advice_status_hints;
>>  		s->display_comment_prefix = old_display_comment_prefix;
>>  		run_status(stdout, index_file, prefix, 0, s);
>>  		if (amend)
>
> I checked that this undoing of "s->hints = 0" is safe, because s is no
> longer used in this function nor in the calling function cmd_commit()
> (which is the one that declared s locally).
>
> Still probably worth a comment, though. For example:
>
>   This status is to be printed to stdout, so hints will be useful to the
>   user. Reset s->hints to what the user configured.
>
> The corresponding comment on "s->hints = 0" might need to be tweaked,
> too, but I can't think of anything at the moment.
>
>> +test_expect_success 'commit without staging files fails and displays hints' '
>> +	echo "initial" >>file &&
>> +	git add file &&
>> +	git commit -m initial &&
>> +	echo "changes" >>file &&
>> +	test_must_fail git commit -m initial >actual &&
>
> Use another commit message for this, since this is no longer "initial".
> (Maybe "after initial" or something like that.)

Thanks for a careful review.

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

* Re: [PATCH 1/1] commit: display advice hints when commit fails
  2019-12-17 22:45   ` Emily Shaffer
@ 2019-12-19  3:47     ` Heba Waly
  0 siblings, 0 replies; 27+ messages in thread
From: Heba Waly @ 2019-12-19  3:47 UTC (permalink / raw)
  To: Emily Shaffer
  Cc: Heba Waly via GitGitGadget, Git Mailing List, Junio C Hamano

On Wed, Dec 18, 2019 at 11:45 AM Emily Shaffer <emilyshaffer@google.com> wrote:
>
> On Tue, Dec 17, 2019 at 09:17:22AM +0000, Heba Waly via GitGitGadget wrote:
> > From: Heba Waly <heba.waly@gmail.com>
> >
> > Display hints to the user when trying to commit without staging the modified
> > files first (when advice.statusHints is set to true). Change the output of the
> > unsuccessful commit from e.g:
> >
> >   # [...]
> >   # Changes not staged for commit:
> >   #   modified:   builtin/commit.c
> >   #
> >   # no changes added to commit
> >
> > to:
> >
> >   # [...]
> >   # Changes not staged for commit:
> >   #   (use "git add <file>..." to update what will be committed)
> >   #   (use "git checkout -- <file>..." to discard changes in working directory)
> >   #
> >   #   modified:   ../builtin/commit.c
> >   #
> >   # no changes added to commit (use "git add" and/or "git commit -a")
> >
> > In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
> > 2013-09-12) the intent was to disable status hints when writing to
> > COMMIT_EDITMSG, but in fact the implementation disabled status messages in
> > more locations, e.g in case the commit wasn't successful, status hints
> > will still be disabled and no hints will be displayed to the user although
> > advice.statusHints is set to true.
> >
> > Signed-off-by: Heba Waly <heba.waly@gmail.com>
> > ---
> >  builtin/commit.c                          | 1 +
> >  t/t7500-commit-template-squash-signoff.sh | 9 +++++++++
> >  2 files changed, 10 insertions(+)
> >
> > diff --git a/builtin/commit.c b/builtin/commit.c
> > index 2db2ad0de4..4439666465 100644
> > --- a/builtin/commit.c
> > +++ b/builtin/commit.c
> > @@ -961,6 +961,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
> >        */
> >       if (!committable && whence != FROM_MERGE && !allow_empty &&
> >           !(amend && is_a_merge(current_head))) {
> > +             s->hints = advice_status_hints;
>
> Hm. This looks like it turns hints back on specifically for this case,
> but might not fix other places where ea9882bfc4 turned them off.
>
> I think the intent of that commit was to not put hints into the editor,
> so does it make sense to instead wrap this guy:
>
>   /*
>    * Most hints are counter-productive when the commit has
>    * already started.
>    */
>   s->hints = 0;
>
> in "if (use_editor)"?
>

That's a good idea, I tried it and it seems to be working fine.

> I didn't try it on my end. Maybe it won't help much, because we think
> we're going to use the editor right up until we realize it's not
> committable?
>
> I wonder which other cases that commit got rid of hints for by accident.
>

The number of cases is quite overwhelming because of all the options that
can be passed to the commit command, but hopefully after wrapping it in
an if condition as you suggested we'll be more certain of the affected cases.
Will send an update shortly.

>  - Emily
>
> >               s->display_comment_prefix = old_display_comment_prefix;
> >               run_status(stdout, index_file, prefix, 0, s);
> >               if (amend)
> > diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
> > index 46a5cd4b73..3d76e8ebbd 100755
> > --- a/t/t7500-commit-template-squash-signoff.sh
> > +++ b/t/t7500-commit-template-squash-signoff.sh
> > @@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' '
> >       )
> >  '
> >
> > +test_expect_success 'commit without staging files fails and displays hints' '
> > +     echo "initial" >>file &&
> > +     git add file &&
> > +     git commit -m initial &&
> > +     echo "changes" >>file &&
> > +     test_must_fail git commit -m initial >actual &&
> > +     test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
> > +'
> > +
> >  test_done
> > --
> > gitgitgadget

Thanks,

Heba

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

* Re: [PATCH 1/1] commit: display advice hints when commit fails
  2019-12-18  3:13   ` Jonathan Tan
  2019-12-18 18:14     ` Junio C Hamano
@ 2019-12-19  3:48     ` Heba Waly
  1 sibling, 0 replies; 27+ messages in thread
From: Heba Waly @ 2019-12-19  3:48 UTC (permalink / raw)
  To: Jonathan Tan; +Cc: Heba Waly via GitGitGadget, Git Mailing List, Junio C Hamano

On Wed, Dec 18, 2019 at 4:13 PM Jonathan Tan <jonathantanmy@google.com> wrote:
>
> > From: Heba Waly <heba.waly@gmail.com>
> >
> > Display hints to the user when trying to commit without staging the modified
> > files first (when advice.statusHints is set to true). Change the output of the
> > unsuccessful commit from e.g:
>
> Wrap your commit messages at 72 characters.
>
OK

> >   # [...]
> >   # Changes not staged for commit:
> >   #   modified:   builtin/commit.c
> >   #
> >   # no changes added to commit
> >
> > to:
> >
> >   # [...]
> >   # Changes not staged for commit:
> >   #   (use "git add <file>..." to update what will be committed)
> >   #   (use "git checkout -- <file>..." to discard changes in working directory)
> >   #
> >   #   modified:   ../builtin/commit.c
>
> For tidiness, can this line also be "builtin/commit.c" (that is, without
> the "../" at the beginning) to match what's before "to:"?
>

Sure.

> > In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
> > 2013-09-12) the intent was to disable status hints when writing to
> > COMMIT_EDITMSG, but in fact the implementation disabled status messages in
> > more locations, e.g in case the commit wasn't successful, status hints
> > will still be disabled and no hints will be displayed to the user although
> > advice.statusHints is set to true.
> >
> > Signed-off-by: Heba Waly <heba.waly@gmail.com>
> > ---
> >  builtin/commit.c                          | 1 +
> >  t/t7500-commit-template-squash-signoff.sh | 9 +++++++++
>
> I wondered if there was a better place to put the test, but I couldn't
> find one, so this is fine.
>
> > @@ -961,6 +961,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
> >        */
> >       if (!committable && whence != FROM_MERGE && !allow_empty &&
> >           !(amend && is_a_merge(current_head))) {
> > +             s->hints = advice_status_hints;
> >               s->display_comment_prefix = old_display_comment_prefix;
> >               run_status(stdout, index_file, prefix, 0, s);
> >               if (amend)
>
> I checked that this undoing of "s->hints = 0" is safe, because s is no
> longer used in this function nor in the calling function cmd_commit()
> (which is the one that declared s locally).
>
> Still probably worth a comment, though. For example:
>
>   This status is to be printed to stdout, so hints will be useful to the
>   user. Reset s->hints to what the user configured.
>

Ok.

> The corresponding comment on "s->hints = 0" might need to be tweaked,
> too, but I can't think of anything at the moment.
>
> > +test_expect_success 'commit without staging files fails and displays hints' '
> > +     echo "initial" >>file &&
> > +     git add file &&
> > +     git commit -m initial &&
> > +     echo "changes" >>file &&
> > +     test_must_fail git commit -m initial >actual &&
>
> Use another commit message for this, since this is no longer "initial".
> (Maybe "after initial" or something like that.)

Makes sense.

Thank you Jonathan.

Heba


Heba

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

* [PATCH v2 0/1] [Outreachy] commit: display advice hints when commit fails
  2019-12-17  9:17 [PATCH 0/1] [Outreachy] commit: display advice hints when commit fails Heba Waly via GitGitGadget
  2019-12-17  9:17 ` [PATCH 1/1] " Heba Waly via GitGitGadget
@ 2019-12-19  9:16 ` Heba Waly via GitGitGadget
  2019-12-19  9:16   ` [PATCH v2 1/1] " Heba Waly via GitGitGadget
                     ` (2 more replies)
  1 sibling, 3 replies; 27+ messages in thread
From: Heba Waly via GitGitGadget @ 2019-12-19  9:16 UTC (permalink / raw)
  To: git; +Cc: Heba Waly, Junio C Hamano

Display hints to the user when trying to commit without staging the modified
files first (when advice.statusHints is set to true). Change the output of
the unsuccessful commit from e.g:

 . [...] . Changes not staged for commit: . modified: builtin/commit.c . .
no changes added to commit

to:

 . [...] . Changes not staged for commit: . (use "git add ..." to update
what will be committed) . (use "git checkout -- ..." to discard changes in
working directory) . . modified: ../builtin/commit.c . . no changes added to
commit (use "git add" and/or "git commit -a")

In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
2013-09-12) the intent was to disable status hints when writing to
COMMIT_EDITMSG, but in fact the implementation disabled status messages in
more locations, e.g in case the commit wasn't successful, status hints will
still be disabled and no hints will be displayed to the user although
advice.statusHints is set to true.

Signed-off-by: Heba Waly heba.waly@gmail.com [heba.waly@gmail.com]

Heba Waly (1):
  commit: display advice hints when commit fails

 builtin/commit.c                          | 18 ++++++++++++------
 t/t7500-commit-template-squash-signoff.sh |  9 +++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)


base-commit: 12029dc57db23baef008e77db1909367599210ee
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-495%2FHebaWaly%2Fhints-for-unsuccessful-commit-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-495/HebaWaly/hints-for-unsuccessful-commit-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/495

Range-diff vs v1:

 1:  f23477c5a3 ! 1:  ebec237920 commit: display advice hints when commit fails
     @@ -2,9 +2,9 @@
      
          commit: display advice hints when commit fails
      
     -    Display hints to the user when trying to commit without staging the modified
     -    files first (when advice.statusHints is set to true). Change the output of the
     -    unsuccessful commit from e.g:
     +    Display hints to the user when trying to commit without staging the
     +    modified files first (when advice.statusHints is set to true). Change
     +    the output of the unsuccessful commit from e.g:
      
            # [...]
            # Changes not staged for commit:
     @@ -19,16 +19,16 @@
            #   (use "git add <file>..." to update what will be committed)
            #   (use "git checkout -- <file>..." to discard changes in working directory)
            #
     -      #   modified:   ../builtin/commit.c
     +      #   modified:   /builtin/commit.c
            #
            # no changes added to commit (use "git add" and/or "git commit -a")
      
     -    In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
     -    2013-09-12) the intent was to disable status hints when writing to
     -    COMMIT_EDITMSG, but in fact the implementation disabled status messages in
     -    more locations, e.g in case the commit wasn't successful, status hints
     -    will still be disabled and no hints will be displayed to the user although
     -    advice.statusHints is set to true.
     +    In ea9882bfc4 (commit: disable status hints when writing to
     +    COMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when
     +    writing to COMMIT_EDITMSG, but in fact the implementation disabled
     +    status messages in more locations, e.g in case the commit wasn't
     +    successful, status hints will still be disabled and no hints will be
     +    displayed to the user although advice.statusHints is set to true.
      
          Signed-off-by: Heba Waly <heba.waly@gmail.com>
      
     @@ -36,13 +36,44 @@
       --- a/builtin/commit.c
       +++ b/builtin/commit.c
      @@
     - 	 */
     - 	if (!committable && whence != FROM_MERGE && !allow_empty &&
     - 	    !(amend && is_a_merge(current_head))) {
     -+		s->hints = advice_status_hints;
     - 		s->display_comment_prefix = old_display_comment_prefix;
     - 		run_status(stdout, index_file, prefix, 0, s);
     - 		if (amend)
     + 	old_display_comment_prefix = s->display_comment_prefix;
     + 	s->display_comment_prefix = 1;
     + 
     +-	/*
     +-	 * Most hints are counter-productive when the commit has
     +-	 * already started.
     +-	 */
     +-	s->hints = 0;
     +-
     + 	if (clean_message_contents)
     + 		strbuf_stripspace(&sb, 0);
     + 
     +@@
     + 		int saved_color_setting;
     + 		struct ident_split ci, ai;
     + 
     ++		/*
     ++		 * Most hints are counter-productive when displayed in
     ++		 * the commit message editor.
     ++		 */
     ++		s->hints = 0;
     ++
     + 		if (whence != FROM_COMMIT) {
     + 			if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
     + 				!merge_contains_scissors)
     +@@
     + 		saved_color_setting = s->use_color;
     + 		s->use_color = 0;
     + 		committable = run_status(s->fp, index_file, prefix, 1, s);
     ++		if(!committable)
     ++			/*
     ++			 Status is to be printed to stdout, so hints will be useful to the
     ++			 user. Reset s->hints to what the user configured
     ++			 */
     ++			s->hints = advice_status_hints;
     + 		s->use_color = saved_color_setting;
     + 		string_list_clear(&s->change, 1);
     + 	} else {
      
       diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
       --- a/t/t7500-commit-template-squash-signoff.sh
     @@ -56,7 +87,7 @@
      +	git add file &&
      +	git commit -m initial &&
      +	echo "changes" >>file &&
     -+	test_must_fail git commit -m initial >actual &&
     ++	test_must_fail git commit -m update >actual &&
      +	test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
      +'
      +

-- 
gitgitgadget

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

* [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-19  9:16 ` [PATCH v2 0/1] [Outreachy] " Heba Waly via GitGitGadget
@ 2019-12-19  9:16   ` Heba Waly via GitGitGadget
  2019-12-19 19:14     ` Junio C Hamano
  2019-12-19 18:26   ` [PATCH v2 0/1] [Outreachy] " Junio C Hamano
  2019-12-21  5:02   ` Heba Waly
  2 siblings, 1 reply; 27+ messages in thread
From: Heba Waly via GitGitGadget @ 2019-12-19  9:16 UTC (permalink / raw)
  To: git; +Cc: Heba Waly, Junio C Hamano, Heba Waly

From: Heba Waly <heba.waly@gmail.com>

Display hints to the user when trying to commit without staging the
modified files first (when advice.statusHints is set to true). Change
the output of the unsuccessful commit from e.g:

  # [...]
  # Changes not staged for commit:
  #   modified:   builtin/commit.c
  #
  # no changes added to commit

to:

  # [...]
  # Changes not staged for commit:
  #   (use "git add <file>..." to update what will be committed)
  #   (use "git checkout -- <file>..." to discard changes in working directory)
  #
  #   modified:   /builtin/commit.c
  #
  # no changes added to commit (use "git add" and/or "git commit -a")

In ea9882bfc4 (commit: disable status hints when writing to
COMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when
writing to COMMIT_EDITMSG, but in fact the implementation disabled
status messages in more locations, e.g in case the commit wasn't
successful, status hints will still be disabled and no hints will be
displayed to the user although advice.statusHints is set to true.

Signed-off-by: Heba Waly <heba.waly@gmail.com>
---
 builtin/commit.c                          | 18 ++++++++++++------
 t/t7500-commit-template-squash-signoff.sh |  9 +++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index e48c1fd90a..868c0d7819 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -811,12 +811,6 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	old_display_comment_prefix = s->display_comment_prefix;
 	s->display_comment_prefix = 1;
 
-	/*
-	 * Most hints are counter-productive when the commit has
-	 * already started.
-	 */
-	s->hints = 0;
-
 	if (clean_message_contents)
 		strbuf_stripspace(&sb, 0);
 
@@ -837,6 +831,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		int saved_color_setting;
 		struct ident_split ci, ai;
 
+		/*
+		 * Most hints are counter-productive when displayed in
+		 * the commit message editor.
+		 */
+		s->hints = 0;
+
 		if (whence != FROM_COMMIT) {
 			if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
 				!merge_contains_scissors)
@@ -912,6 +912,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		saved_color_setting = s->use_color;
 		s->use_color = 0;
 		committable = run_status(s->fp, index_file, prefix, 1, s);
+		if(!committable)
+			/*
+			 Status is to be printed to stdout, so hints will be useful to the
+			 user. Reset s->hints to what the user configured
+			 */
+			s->hints = advice_status_hints;
 		s->use_color = saved_color_setting;
 		string_list_clear(&s->change, 1);
 	} else {
diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
index 46a5cd4b73..a8179e4074 100755
--- a/t/t7500-commit-template-squash-signoff.sh
+++ b/t/t7500-commit-template-squash-signoff.sh
@@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' '
 	)
 '
 
+test_expect_success 'commit without staging files fails and displays hints' '
+	echo "initial" >>file &&
+	git add file &&
+	git commit -m initial &&
+	echo "changes" >>file &&
+	test_must_fail git commit -m update >actual &&
+	test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
+'
+
 test_done
-- 
gitgitgadget

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

* Re: [PATCH v2 0/1] [Outreachy] commit: display advice hints when commit fails
  2019-12-19  9:16 ` [PATCH v2 0/1] [Outreachy] " Heba Waly via GitGitGadget
  2019-12-19  9:16   ` [PATCH v2 1/1] " Heba Waly via GitGitGadget
@ 2019-12-19 18:26   ` Junio C Hamano
  2019-12-19 18:54     ` Emily Shaffer
  2019-12-21  5:02   ` Heba Waly
  2 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2019-12-19 18:26 UTC (permalink / raw)
  To: Heba Waly via GitGitGadget; +Cc: git, Heba Waly

"Heba Waly via GitGitGadget" <gitgitgadget@gmail.com> writes:

>      @@ -19,16 +19,16 @@
>             #   (use "git add <file>..." to update what will be committed)
>             #   (use "git checkout -- <file>..." to discard changes in working directory)
>             #
>      -      #   modified:   ../builtin/commit.c
>      +      #   modified:   /builtin/commit.c

Really?

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

* Re: [PATCH v2 0/1] [Outreachy] commit: display advice hints when commit fails
  2019-12-19 18:26   ` [PATCH v2 0/1] [Outreachy] " Junio C Hamano
@ 2019-12-19 18:54     ` Emily Shaffer
  2019-12-19 19:23       ` Junio C Hamano
  0 siblings, 1 reply; 27+ messages in thread
From: Emily Shaffer @ 2019-12-19 18:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Heba Waly via GitGitGadget, git, Heba Waly

On Thu, Dec 19, 2019 at 10:26:40AM -0800, Junio C Hamano wrote:
> "Heba Waly via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> >      @@ -19,16 +19,16 @@
> >             #   (use "git add <file>..." to update what will be committed)
> >             #   (use "git checkout -- <file>..." to discard changes in working directory)
> >             #
> >      -      #   modified:   ../builtin/commit.c
> >      +      #   modified:   /builtin/commit.c
> 
> Really?

It's hard to know what this cryptic comment means.. :)

This was a recommended change:
https://lore.kernel.org/git/20191218031338.203382-1-jonathantanmy@google.com

Since other changes were being made at the same time, I personally don't
mind a little nit fix in the commit message.

Or, do you mean that "now it looks like the file is at the filesystem
root, which is wrong"? It is indeed wrong now when it wasn't before. But
I, for one, can't tell what you mean by just the one word.

 - Emily

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-19  9:16   ` [PATCH v2 1/1] " Heba Waly via GitGitGadget
@ 2019-12-19 19:14     ` Junio C Hamano
  2019-12-19 19:22       ` Junio C Hamano
  0 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2019-12-19 19:14 UTC (permalink / raw)
  To: Heba Waly via GitGitGadget; +Cc: git, Heba Waly

"Heba Waly via GitGitGadget" <gitgitgadget@gmail.com> writes:

> diff --git a/builtin/commit.c b/builtin/commit.c
> index e48c1fd90a..868c0d7819 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -811,12 +811,6 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  	old_display_comment_prefix = s->display_comment_prefix;
>  	s->display_comment_prefix = 1;
>  
> -	/*
> -	 * Most hints are counter-productive when the commit has
> -	 * already started.
> -	 */
> -	s->hints = 0;
> -

Hmm.

> @@ -837,6 +831,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  		int saved_color_setting;
>  		struct ident_split ci, ai;
>  
> +		/*
> +		 * Most hints are counter-productive when displayed in
> +		 * the commit message editor.
> +		 */
> +		s->hints = 0;
> +

We no longer drop s->hints when we are not using editor and not
including status (i.e. the "else" side) because these lines are
moved inside "if".  As this change is not about that "no editor"
side, I am not 100% convinced that this is a good change.

> @@ -912,6 +912,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  		saved_color_setting = s->use_color;
>  		s->use_color = 0;
>  		committable = run_status(s->fp, index_file, prefix, 1, s);
> +		if(!committable)

Style: SP between "if" and "(".

> +			/*
> +			 Status is to be printed to stdout, so hints will be useful to the
> +			 user. Reset s->hints to what the user configured
> +			 */
> +			s->hints = advice_status_hints;

The "if" side has been changed to flip s->hints to the configured
advice hints value when !committable here.  The "else" side
(i.e. when we are not using editor and not including status) does
not do anything to s->hints after finding out if committable after
this change.  Because "s->hints = 0" was moved to "if" with this
patch, the "else" side no longer drops s->hints at all.

So the final run_status() called when the attempt to commit is
rejected will feed s->hints that is not cleared with this change.

Is that intended?  Is the updated behaviour checked with a test?

>  		s->use_color = saved_color_setting;
>  		string_list_clear(&s->change, 1);
>  	} else {

This fix was about "we do not want to unconditionally drop the
advice messages when we reject the attempt to commit and show the
output like 'git status'", wasn't it?  The earlier single-liner fix
in v1 that flips s->hints just before calling run_status() before
rejecting the attempt to commit was a lot easier to reason about, as
the fix was very focused and to the point.  Why are we seeing this
many (seemingly unrelated) changes?

Puzzled...

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-19 19:14     ` Junio C Hamano
@ 2019-12-19 19:22       ` Junio C Hamano
  2019-12-19 19:47         ` Eric Sunshine
                           ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Junio C Hamano @ 2019-12-19 19:22 UTC (permalink / raw)
  To: Heba Waly via GitGitGadget; +Cc: git, Heba Waly

Junio C Hamano <gitster@pobox.com> writes:

> This fix was about "we do not want to unconditionally drop the
> advice messages when we reject the attempt to commit and show the
> output like 'git status'", wasn't it?  The earlier single-liner fix
> in v1 that flips s->hints just before calling run_status() before
> rejecting the attempt to commit was a lot easier to reason about, as
> the fix was very focused and to the point.  Why are we seeing this
> many (seemingly unrelated) changes?

In any case, here is what I tentatively have in my tree (with heavy
rewrite to the proposed log message).

-- >8 --
From: Heba Waly <heba.waly@gmail.com>
Date: Tue, 17 Dec 2019 09:17:22 +0000
Subject: [PATCH] commit: honor advice.statusHints when rejecting an empty
 commit

In ea9882bfc4 (commit: disable status hints when writing to
COMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints
when writing to COMMIT_EDITMSG, because giving the hints in the "git
status" like output in the commit message template are too late to
be useful (they say things like "'git add' to stage", but that is
only possible after aborting the current "git commit" session).

But there is one case that the hints can be useful: When the current
attempt to commit is rejected because no change is recorded in the
index.  The message is given and "git commit" errors out, so the
hints can immediately be followed by the user.  Teach the codepath
to honor the configuration variable.

Signed-off-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/commit.c                          | 1 +
 t/t7500-commit-template-squash-signoff.sh | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/builtin/commit.c b/builtin/commit.c
index e588bc6ad3..0078faf117 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -944,6 +944,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	 */
 	if (!committable && whence != FROM_MERGE && !allow_empty &&
 	    !(amend && is_a_merge(current_head))) {
+		s->hints = advice_status_hints;
 		s->display_comment_prefix = old_display_comment_prefix;
 		run_status(stdout, index_file, prefix, 0, s);
 		if (amend)
diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
index 46a5cd4b73..a8179e4074 100755
--- a/t/t7500-commit-template-squash-signoff.sh
+++ b/t/t7500-commit-template-squash-signoff.sh
@@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' '
 	)
 '
 
+test_expect_success 'commit without staging files fails and displays hints' '
+	echo "initial" >>file &&
+	git add file &&
+	git commit -m initial &&
+	echo "changes" >>file &&
+	test_must_fail git commit -m update >actual &&
+	test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
+'
+
 test_done
-- 
2.24.1-732-ga9f9d4909c


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

* Re: [PATCH v2 0/1] [Outreachy] commit: display advice hints when commit fails
  2019-12-19 18:54     ` Emily Shaffer
@ 2019-12-19 19:23       ` Junio C Hamano
  2019-12-19 19:45         ` Junio C Hamano
  0 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2019-12-19 19:23 UTC (permalink / raw)
  To: Emily Shaffer; +Cc: Heba Waly via GitGitGadget, git, Heba Waly

Emily Shaffer <emilyshaffer@google.com> writes:

> On Thu, Dec 19, 2019 at 10:26:40AM -0800, Junio C Hamano wrote:
>> "Heba Waly via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> 
>> >      @@ -19,16 +19,16 @@
>> >             #   (use "git add <file>..." to update what will be committed)
>> >             #   (use "git checkout -- <file>..." to discard changes in working directory)
>> >             #
>> >      -      #   modified:   ../builtin/commit.c
>> >      +      #   modified:   /builtin/commit.c
>> 
>> Really?
>
> It's hard to know what this cryptic comment means.. :)
>
> This was a recommended change:
> https://lore.kernel.org/git/20191218031338.203382-1-jonathantanmy@google.com
>
> Since other changes were being made at the same time, I personally don't
> mind a little nit fix in the commit message.
>
> Or, do you mean that "now it looks like the file is at the filesystem
> root, which is wrong"? It is indeed wrong now when it wasn't before. But
> I, for one, can't tell what you mean by just the one word.

That is exactly the point.  I am not in the business of spoon
feeding answers.  I want my contributors to *think*.

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

* Re: [PATCH v2 0/1] [Outreachy] commit: display advice hints when commit fails
  2019-12-19 19:23       ` Junio C Hamano
@ 2019-12-19 19:45         ` Junio C Hamano
  2019-12-21  4:37           ` Heba Waly
  0 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2019-12-19 19:45 UTC (permalink / raw)
  To: Emily Shaffer; +Cc: Heba Waly via GitGitGadget, git, Heba Waly

Junio C Hamano <gitster@pobox.com> writes:

> Emily Shaffer <emilyshaffer@google.com> writes:
>
>> On Thu, Dec 19, 2019 at 10:26:40AM -0800, Junio C Hamano wrote:
>>> "Heba Waly via GitGitGadget" <gitgitgadget@gmail.com> writes:
>>> 
>>> >      @@ -19,16 +19,16 @@
>>> >             #   (use "git add <file>..." to update what will be committed)
>>> >             #   (use "git checkout -- <file>..." to discard changes in working directory)
>>> >             #
>>> >      -      #   modified:   ../builtin/commit.c
>>> >      +      #   modified:   /builtin/commit.c
>>> 
>>> Really?
>>
>> It's hard to know what this cryptic comment means.. :)
>>
>> This was a recommended change:
>> https://lore.kernel.org/git/20191218031338.203382-1-jonathantanmy@google.com
>>
>> Since other changes were being made at the same time, I personally don't
>> mind a little nit fix in the commit message.
>>
>> Or, do you mean that "now it looks like the file is at the filesystem
>> root, which is wrong"? It is indeed wrong now when it wasn't before. But
>> I, for one, can't tell what you mean by just the one word.
>
> That is exactly the point.  I am not in the business of spoon
> feeding answers.  I want my contributors to *think*.

And I am not being unnecessarily cryptic.  If anybody thought a bit
about what the topic was about, looking at it it would immediately
be obvious that the sample output shown there is totally bogus, due
to the leading slash.

Any contributor working on this topic should be competent enough to
realize/notice it once it is pointed out---even though lack of
proof-reading before sending may cause such a mistake by
carelessness.  And that is what I wanted to convey by deliberately
a short response.



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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-19 19:22       ` Junio C Hamano
@ 2019-12-19 19:47         ` Eric Sunshine
  2019-12-19 19:57           ` Junio C Hamano
  2019-12-20  2:31         ` Emily Shaffer
  2019-12-31  0:04         ` Jonathan Tan
  2 siblings, 1 reply; 27+ messages in thread
From: Eric Sunshine @ 2019-12-19 19:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Heba Waly via GitGitGadget, Git List, Heba Waly

On Thu, Dec 19, 2019 at 2:22 PM Junio C Hamano <gitster@pobox.com> wrote:
> In any case, here is what I tentatively have in my tree (with heavy
> rewrite to the proposed log message).
>
> +test_expect_success 'commit without staging files fails and displays hints' '
> +       echo "initial" >>file &&

The use of '>>' here rather than '>' feels wrong, especially when
"initial" is used for both the file body and the commit message,
causing a reader of the test to wonder if this test somehow depends
upon earlier tests.

> +       git add file &&
> +       git commit -m initial &&
> +       echo "changes" >>file &&
> +       test_must_fail git commit -m update >actual &&
> +       test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
> +'

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-19 19:47         ` Eric Sunshine
@ 2019-12-19 19:57           ` Junio C Hamano
  0 siblings, 0 replies; 27+ messages in thread
From: Junio C Hamano @ 2019-12-19 19:57 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Heba Waly via GitGitGadget, Git List, Heba Waly

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Thu, Dec 19, 2019 at 2:22 PM Junio C Hamano <gitster@pobox.com> wrote:
>> In any case, here is what I tentatively have in my tree (with heavy
>> rewrite to the proposed log message).
>>
>> +test_expect_success 'commit without staging files fails and displays hints' '
>> +       echo "initial" >>file &&
>
> The use of '>>' here rather than '>' feels wrong, especially when
> "initial" is used for both the file body and the commit message,
> causing a reader of the test to wonder if this test somehow depends
> upon earlier tests.

Yeah, makes sense.  This was verbatim from v1 but I think starting
the file from scratch like you suggest makes it clearer what is
going on.


>
>> +       git add file &&
>> +       git commit -m initial &&
>> +       echo "changes" >>file &&
>> +       test_must_fail git commit -m update >actual &&
>> +       test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
>> +'

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-19 19:22       ` Junio C Hamano
  2019-12-19 19:47         ` Eric Sunshine
@ 2019-12-20  2:31         ` Emily Shaffer
  2019-12-20 18:34           ` Junio C Hamano
  2019-12-31  0:04         ` Jonathan Tan
  2 siblings, 1 reply; 27+ messages in thread
From: Emily Shaffer @ 2019-12-20  2:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Heba Waly via GitGitGadget, git, Heba Waly

On Thu, Dec 19, 2019 at 11:22:38AM -0800, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > This fix was about "we do not want to unconditionally drop the
> > advice messages when we reject the attempt to commit and show the
> > output like 'git status'", wasn't it?  The earlier single-liner fix
> > in v1 that flips s->hints just before calling run_status() before
> > rejecting the attempt to commit was a lot easier to reason about, as
> > the fix was very focused and to the point.  Why are we seeing this
> > many (seemingly unrelated) changes?
> 
> In any case, here is what I tentatively have in my tree (with heavy
> rewrite to the proposed log message).

Hm. I'm surprised to see this feedback come in the form of a local
change when making the topic branch, rather than in a reply to the v1
patch. What's the reasoning? (Or is this scissors patch intended to be
the feedback?)

I ask because out of all of us, it seems the Outreachy interns can
benefit the most from advice on how and why to write their commit
messages - that is, part of the point of an internship is to learn best
practices and cultural norms in addition to coding practice. (Plus, I
find being asked to rewrite a commit message tends to force me to
understand my own change even better than before.)

I'll go ahead and look through the changes to the commit message so I
can learn what you're looking for too :)

> 
> -- >8 --
> From: Heba Waly <heba.waly@gmail.com>
> Date: Tue, 17 Dec 2019 09:17:22 +0000
> Subject: [PATCH] commit: honor advice.statusHints when rejecting an empty
>  commit
> 
> In ea9882bfc4 (commit: disable status hints when writing to
> COMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints
> when writing to COMMIT_EDITMSG, because giving the hints in the "git
> status" like output in the commit message template are too late to
> be useful (they say things like "'git add' to stage", but that is
> only possible after aborting the current "git commit" session).

More context on why the previous change was made - "by the time the
editor was open, it was too late to apply hints anyways". Sure.

> 
> But there is one case that the hints can be useful: When the current
> attempt to commit is rejected because no change is recorded in the
> index.  The message is given and "git commit" errors out, so the
> hints can immediately be followed by the user.  Teach the codepath
> to honor the configuration variable.

Expanding the "but" to supply the specific story this commit touches,
including "what happens instead" and "how are we gonna fix it".

And the copy-paste of the output before and the output now is different.
For me, I don't particularly see why we'd want to be rid of it - it sort
of feels like "a picture is worth a thousand words" to include the
actual use case in the commit message. Is there style guidance
suggesting not to do that that I missed?

 - Emily

> 
> Signed-off-by: Heba Waly <heba.waly@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  builtin/commit.c                          | 1 +
>  t/t7500-commit-template-squash-signoff.sh | 9 +++++++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/builtin/commit.c b/builtin/commit.c
> index e588bc6ad3..0078faf117 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -944,6 +944,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  	 */
>  	if (!committable && whence != FROM_MERGE && !allow_empty &&
>  	    !(amend && is_a_merge(current_head))) {
> +		s->hints = advice_status_hints;
>  		s->display_comment_prefix = old_display_comment_prefix;
>  		run_status(stdout, index_file, prefix, 0, s);
>  		if (amend)
> diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
> index 46a5cd4b73..a8179e4074 100755
> --- a/t/t7500-commit-template-squash-signoff.sh
> +++ b/t/t7500-commit-template-squash-signoff.sh
> @@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' '
>  	)
>  '
>  
> +test_expect_success 'commit without staging files fails and displays hints' '
> +	echo "initial" >>file &&
> +	git add file &&
> +	git commit -m initial &&
> +	echo "changes" >>file &&
> +	test_must_fail git commit -m update >actual &&
> +	test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
> +'
> +
>  test_done
> -- 
> 2.24.1-732-ga9f9d4909c
> 

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-20  2:31         ` Emily Shaffer
@ 2019-12-20 18:34           ` Junio C Hamano
  2019-12-20 21:39             ` Emily Shaffer
  0 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2019-12-20 18:34 UTC (permalink / raw)
  To: Emily Shaffer; +Cc: Heba Waly via GitGitGadget, git, Heba Waly

Emily Shaffer <emilyshaffer@google.com> writes:

> Hm. I'm surprised to see this feedback come in the form of a local
> change when making the topic branch, rather than in a reply to the v1
> patch. What's the reasoning? (Or is this scissors patch intended to be
> the feedback?)

You haven't seen a suggestion in the form of counter-proposal?

> I ask because out of all of us, it seems the Outreachy interns can
> benefit the most from advice on how and why to write their commit
> messages - that is, part of the point of an internship is to learn best
> practices and cultural norms in addition to coding practice. (Plus, I
> find being asked to rewrite a commit message tends to force me to
> understand my own change even better than before.)

It's something Mentors can help doing (I do not necessarily have
time for that myself), and you're welcome to use the "tenatively
queued" version as an example.

> I'll go ahead and look through the changes to the commit message so I
> can learn what you're looking for too :)

Nice.

One thing you missed in your review of the "tentatively queued"
version is the reversal of the order of presentation.  Instead of
starting with "I decided to do this" without explanation, give the
picture of status quo to set the stage, explain what issue exists in
the current behaviour, and then describe what approach was chosen to
solve the issue.

> For me, I don't particularly see why we'd want to be rid of it - it sort
> of feels like "a picture is worth a thousand words" to include the
> actual use case in the commit message.

Output coming from commands and/or options that are used only in a
bit more advanced workflow and the ones that are rarely seen, I do
agree that showing example is a good way to illustrate exactly what
you are talking about.

On the other hand, for behaviour of basic local commands like "git
add", "git commit", "git diff", ..., I do not necessarily agree, as
these should be obvious and clear to all the intended audiences,
which would be "anybody who has used Git for say more than two
weeks.

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-20 18:34           ` Junio C Hamano
@ 2019-12-20 21:39             ` Emily Shaffer
  0 siblings, 0 replies; 27+ messages in thread
From: Emily Shaffer @ 2019-12-20 21:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Heba Waly via GitGitGadget, git, Heba Waly

On Fri, Dec 20, 2019 at 10:34:28AM -0800, Junio C Hamano wrote:
> Emily Shaffer <emilyshaffer@google.com> writes:
> 
> > Hm. I'm surprised to see this feedback come in the form of a local
> > change when making the topic branch, rather than in a reply to the v1
> > patch. What's the reasoning? (Or is this scissors patch intended to be
> > the feedback?)
> 
> You haven't seen a suggestion in the form of counter-proposal?

I actually have only seen the scissors-patch as a "yes, and" in
practice. I think this is a sign I should be doing more reviews ;)

> 
> > I ask because out of all of us, it seems the Outreachy interns can
> > benefit the most from advice on how and why to write their commit
> > messages - that is, part of the point of an internship is to learn best
> > practices and cultural norms in addition to coding practice. (Plus, I
> > find being asked to rewrite a commit message tends to force me to
> > understand my own change even better than before.)
> 
> It's something Mentors can help doing (I do not necessarily have
> time for that myself), and you're welcome to use the "tenatively
> queued" version as an example.
> 
> > I'll go ahead and look through the changes to the commit message so I
> > can learn what you're looking for too :)
> 
> Nice.
> 
> One thing you missed in your review of the "tentatively queued"
> version is the reversal of the order of presentation.  Instead of
> starting with "I decided to do this" without explanation, give the
> picture of status quo to set the stage, explain what issue exists in
> the current behaviour, and then describe what approach was chosen to
> solve the issue.

Thanks for explaining this - that's a good point for me to take home.

> 
> > For me, I don't particularly see why we'd want to be rid of it - it sort
> > of feels like "a picture is worth a thousand words" to include the
> > actual use case in the commit message.
> 
> Output coming from commands and/or options that are used only in a
> bit more advanced workflow and the ones that are rarely seen, I do
> agree that showing example is a good way to illustrate exactly what
> you are talking about.
> 
> On the other hand, for behaviour of basic local commands like "git
> add", "git commit", "git diff", ..., I do not necessarily agree, as
> these should be obvious and clear to all the intended audiences,
> which would be "anybody who has used Git for say more than two
> weeks.

Hm, I see. Thanks for clarifying.

 - Emily

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

* Re: [PATCH v2 0/1] [Outreachy] commit: display advice hints when commit fails
  2019-12-19 19:45         ` Junio C Hamano
@ 2019-12-21  4:37           ` Heba Waly
  2019-12-21 23:54             ` Junio C Hamano
  0 siblings, 1 reply; 27+ messages in thread
From: Heba Waly @ 2019-12-21  4:37 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Emily Shaffer, Heba Waly via GitGitGadget, Git Mailing List

On Fri, Dec 20, 2019 at 8:45 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> That is exactly the point.  I am not in the business of spoon
> feeding answers.

Why would pointing out a typo clearly to the author be considered as
spoon feeding answers?
Rather than simply reviewing and pointing out mistakes in a clear and
a respectful way?

> I want my contributors to *think*.

Nobody is against *thinking*, and I'm sure an author who found an
issue and implemented a fix
had his/her share of thinking to get the job done.
So I hope a typo is not standing in the way of acknowledging the
author's effort.

> Any contributor working on this topic should be competent enough to
> realize/notice it once it is pointed out---even though lack of
> proof-reading before sending may cause such a mistake by
> carelessness.

I have no reason not to believe that this is crossing the line.
No matter how much a reviewer disagrees with the proposed changes, I'd
appreciate
keeping a mutually respectful discussion during the review process.

Heba

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

* Re: [PATCH v2 0/1] [Outreachy] commit: display advice hints when commit fails
  2019-12-19  9:16 ` [PATCH v2 0/1] [Outreachy] " Heba Waly via GitGitGadget
  2019-12-19  9:16   ` [PATCH v2 1/1] " Heba Waly via GitGitGadget
  2019-12-19 18:26   ` [PATCH v2 0/1] [Outreachy] " Junio C Hamano
@ 2019-12-21  5:02   ` Heba Waly
  2 siblings, 0 replies; 27+ messages in thread
From: Heba Waly @ 2019-12-21  5:02 UTC (permalink / raw)
  To: Heba Waly via GitGitGadget; +Cc: Git Mailing List, Junio C Hamano

It was brought to my attention that I should've elaborated in the
cover letter the difference between v1 and v2 and the reason behind
the change.
So I'll elaborate that here:

As pointed out by this review on v1
https://lore.kernel.org/git/xmqq36dgayma.fsf@gitster-ct.c.googlers.com/T/#m3adc84664e907bd8fcc13ac22c8702ae15925f8f

By default git honors the user's selection of displaying hints, but in
the specific case of using the editor to write
a commit message ea9882bfc4 wanted to turn it off temporarily because
while the editor is open and the commit
is in-progress, the user can't run these hints anyway
(list discussion for reference
https://lore.kernel.org/git/vpq4n9tghk5.fsf@anie.imag.fr/)

So it makes more sense to see the change made for this specific editor
case inside an if condition rather than
applying it to all the commit cases, and then flip it back once the
commit fails.

Please correct me if I'm wrong, but I think for the rest of the cases,
as long as there's no editor with status
displayed inside (hints displayed while commit in progress), there's
no need to turn off the hints.

Heba


On Thu, Dec 19, 2019 at 10:16 PM Heba Waly via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> Display hints to the user when trying to commit without staging the modified
> files first (when advice.statusHints is set to true). Change the output of
> the unsuccessful commit from e.g:
>
>  . [...] . Changes not staged for commit: . modified: builtin/commit.c . .
> no changes added to commit
>
> to:
>
>  . [...] . Changes not staged for commit: . (use "git add ..." to update
> what will be committed) . (use "git checkout -- ..." to discard changes in
> working directory) . . modified: ../builtin/commit.c . . no changes added to
> commit (use "git add" and/or "git commit -a")
>
> In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
> 2013-09-12) the intent was to disable status hints when writing to
> COMMIT_EDITMSG, but in fact the implementation disabled status messages in
> more locations, e.g in case the commit wasn't successful, status hints will
> still be disabled and no hints will be displayed to the user although
> advice.statusHints is set to true.
>
> Signed-off-by: Heba Waly heba.waly@gmail.com [heba.waly@gmail.com]
>
> Heba Waly (1):
>   commit: display advice hints when commit fails
>
>  builtin/commit.c                          | 18 ++++++++++++------
>  t/t7500-commit-template-squash-signoff.sh |  9 +++++++++
>  2 files changed, 21 insertions(+), 6 deletions(-)
>
>
> base-commit: 12029dc57db23baef008e77db1909367599210ee
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-495%2FHebaWaly%2Fhints-for-unsuccessful-commit-v2
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-495/HebaWaly/hints-for-unsuccessful-commit-v2
> Pull-Request: https://github.com/gitgitgadget/git/pull/495
>
> Range-diff vs v1:
>
>  1:  f23477c5a3 ! 1:  ebec237920 commit: display advice hints when commit fails
>      @@ -2,9 +2,9 @@
>
>           commit: display advice hints when commit fails
>
>      -    Display hints to the user when trying to commit without staging the modified
>      -    files first (when advice.statusHints is set to true). Change the output of the
>      -    unsuccessful commit from e.g:
>      +    Display hints to the user when trying to commit without staging the
>      +    modified files first (when advice.statusHints is set to true). Change
>      +    the output of the unsuccessful commit from e.g:
>
>             # [...]
>             # Changes not staged for commit:
>      @@ -19,16 +19,16 @@
>             #   (use "git add <file>..." to update what will be committed)
>             #   (use "git checkout -- <file>..." to discard changes in working directory)
>             #
>      -      #   modified:   ../builtin/commit.c
>      +      #   modified:   /builtin/commit.c
>             #
>             # no changes added to commit (use "git add" and/or "git commit -a")
>
>      -    In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG,
>      -    2013-09-12) the intent was to disable status hints when writing to
>      -    COMMIT_EDITMSG, but in fact the implementation disabled status messages in
>      -    more locations, e.g in case the commit wasn't successful, status hints
>      -    will still be disabled and no hints will be displayed to the user although
>      -    advice.statusHints is set to true.
>      +    In ea9882bfc4 (commit: disable status hints when writing to
>      +    COMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when
>      +    writing to COMMIT_EDITMSG, but in fact the implementation disabled
>      +    status messages in more locations, e.g in case the commit wasn't
>      +    successful, status hints will still be disabled and no hints will be
>      +    displayed to the user although advice.statusHints is set to true.
>
>           Signed-off-by: Heba Waly <heba.waly@gmail.com>
>
>      @@ -36,13 +36,44 @@
>        --- a/builtin/commit.c
>        +++ b/builtin/commit.c
>       @@
>      -   */
>      -  if (!committable && whence != FROM_MERGE && !allow_empty &&
>      -      !(amend && is_a_merge(current_head))) {
>      -+         s->hints = advice_status_hints;
>      -          s->display_comment_prefix = old_display_comment_prefix;
>      -          run_status(stdout, index_file, prefix, 0, s);
>      -          if (amend)
>      +  old_display_comment_prefix = s->display_comment_prefix;
>      +  s->display_comment_prefix = 1;
>      +
>      +- /*
>      +-  * Most hints are counter-productive when the commit has
>      +-  * already started.
>      +-  */
>      +- s->hints = 0;
>      +-
>      +  if (clean_message_contents)
>      +          strbuf_stripspace(&sb, 0);
>      +
>      +@@
>      +          int saved_color_setting;
>      +          struct ident_split ci, ai;
>      +
>      ++         /*
>      ++          * Most hints are counter-productive when displayed in
>      ++          * the commit message editor.
>      ++          */
>      ++         s->hints = 0;
>      ++
>      +          if (whence != FROM_COMMIT) {
>      +                  if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
>      +                          !merge_contains_scissors)
>      +@@
>      +          saved_color_setting = s->use_color;
>      +          s->use_color = 0;
>      +          committable = run_status(s->fp, index_file, prefix, 1, s);
>      ++         if(!committable)
>      ++                 /*
>      ++                  Status is to be printed to stdout, so hints will be useful to the
>      ++                  user. Reset s->hints to what the user configured
>      ++                  */
>      ++                 s->hints = advice_status_hints;
>      +          s->use_color = saved_color_setting;
>      +          string_list_clear(&s->change, 1);
>      +  } else {
>
>        diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
>        --- a/t/t7500-commit-template-squash-signoff.sh
>      @@ -56,7 +87,7 @@
>       + git add file &&
>       + git commit -m initial &&
>       + echo "changes" >>file &&
>      -+ test_must_fail git commit -m initial >actual &&
>      ++ test_must_fail git commit -m update >actual &&
>       + test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
>       +'
>       +
>
> --
> gitgitgadget

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

* Re: [PATCH v2 0/1] [Outreachy] commit: display advice hints when commit fails
  2019-12-21  4:37           ` Heba Waly
@ 2019-12-21 23:54             ` Junio C Hamano
  0 siblings, 0 replies; 27+ messages in thread
From: Junio C Hamano @ 2019-12-21 23:54 UTC (permalink / raw)
  To: Heba Waly; +Cc: Emily Shaffer, Heba Waly via GitGitGadget, Git Mailing List

Heba Waly <heba.waly@gmail.com> writes:

>> Any contributor working on this topic should be competent enough to
>> realize/notice it once it is pointed out---even though lack of
>> proof-reading before sending may cause such a mistake by
>> carelessness.
>
> I have no reason not to believe that this is crossing the line.
> No matter how much a reviewer disagrees with the proposed changes, I'd
> appreciate
> keeping a mutually respectful discussion during the review process.

I do not see any lack of respect in saying that I believed you are
competent enough that a short "Huh?"  answer was sufficient.

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-19 19:22       ` Junio C Hamano
  2019-12-19 19:47         ` Eric Sunshine
  2019-12-20  2:31         ` Emily Shaffer
@ 2019-12-31  0:04         ` Jonathan Tan
  2019-12-31 19:06           ` Junio C Hamano
  2 siblings, 1 reply; 27+ messages in thread
From: Jonathan Tan @ 2019-12-31  0:04 UTC (permalink / raw)
  To: gitster; +Cc: gitgitgadget, git, heba.waly, Jonathan Tan

> > This fix was about "we do not want to unconditionally drop the
> > advice messages when we reject the attempt to commit and show the
> > output like 'git status'", wasn't it?  The earlier single-liner fix
> > in v1 that flips s->hints just before calling run_status() before
> > rejecting the attempt to commit was a lot easier to reason about, as
> > the fix was very focused and to the point.  Why are we seeing this
> > many (seemingly unrelated) changes?
> 
> In any case, here is what I tentatively have in my tree (with heavy
> rewrite to the proposed log message).

Junio, what are your plans over what you have in your tree? If you'd
like to hear Heba's opinion on it, then she can chime in; if you'd like
a review, then I think it's good to go in.

I think the main area of discussion is whether we should go with Heba's
attempt to address Emily's comment [1]:

> I think the intent of that commit was to not put hints into the editor,
> so does it make sense to instead wrap this guy:
> 
>   /*                                                                       
>    * Most hints are counter-productive when the commit has                 
>    * already started.                                                      
>    */                                                                      
>   s->hints = 0;  
> 
> in "if (use_editor)"?
> 
> I didn't try it on my end. Maybe it won't help much, because we think
> we're going to use the editor right up until we realize it's not
> committable?

And I think the answer to that is "s" is used throughout the function in
various ways (in particular, used to print statuses both to stdout and
to the message template) so any wrapping or corralling of scope would
just make things more complicated. In particular, the way Heba did it in
v2 is more unclear - at the time of setting s->hints = 0, it's done
within a "if (use_editor && include_status)" block, but (as far as I can
tell) the commit message template might also be used when there is no
editor - for example, as input to a hook. And more importantly, when
s->hints is reset to the config, we don't know at that point that the
next status is going to stdout. So I think it's better just to use the
v1 way.

The second area of discussion I see is in the commit message. Commit
messages have to balance brevity and comprehensiveness, and this can be
a subjective matter, but I think Junio's strikes a good balance.

[1] https://lore.kernel.org/git/20191217224541.GA230678@google.com/

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-31  0:04         ` Jonathan Tan
@ 2019-12-31 19:06           ` Junio C Hamano
  2020-01-02 19:56             ` Jonathan Tan
  0 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2019-12-31 19:06 UTC (permalink / raw)
  To: Jonathan Tan; +Cc: gitgitgadget, git, heba.waly

Jonathan Tan <jonathantanmy@google.com> writes:

>> In any case, here is what I tentatively have in my tree (with heavy
>> rewrite to the proposed log message).
>
> Junio, what are your plans over what you have in your tree? If you'd
> like to hear Heba's opinion on it, then she can chime in; if you'd like
> a review, then I think it's good to go in.

On hold until anything like those happens ;-) 

A random reviewer mentioning something on a patch (either in a
line-by-line critique form or "how about doing it this way instead"
counterproposal form) without getting followed up by others
(including the original author) is a stall review thread, and it
does not change the equation if the random reviewer happens to be me.

>> I didn't try it on my end. Maybe it won't help much, because we think
>> we're going to use the editor right up until we realize it's not
>> committable?
>
> And I think the answer to that is "s" is used throughout the function in
> various ways (in particular, used to print statuses both to stdout and
> to the message template) so any wrapping or corralling of scope would
> just make things more complicated. In particular, the way Heba did it in
> v2 is more unclear - at the time of setting s->hints = 0, it's done

You mean "less clear" (just double checking if I got the negation right)?

> within a "if (use_editor && include_status)" block, but (as far as I can
> tell) the commit message template might also be used when there is no
> editor - for example, as input to a hook. And more importantly, when
> s->hints is reset to the config, we don't know at that point that the
> next status is going to stdout. So I think it's better just to use the
> v1 way.

Yeah, thanks for going back to compare v1 and v2, and I agree with
your assessment.

> The second area of discussion I see is in the commit message. Commit
> messages have to balance brevity and comprehensiveness, and this can be
> a subjective matter, but I think Junio's strikes a good balance.

As one side of the comparison is my own, I won't be a good judge on
this, but yes I tried to strick a good balance as much as possible.

I think I've merged it to 'next' yesterday, but it does not mean
that much as we are in -rc and it is not such an urgent "oops we
broke it in this cycle, let's fix it" issue.  If we see a v3 that
improves it, I do not mind at all reverting what I merged to 'next'
and use the updated one instead (either way, it will be in 'master'
during the next cycle at the earliest).

Thanks.

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

* Re: [PATCH v2 1/1] commit: display advice hints when commit fails
  2019-12-31 19:06           ` Junio C Hamano
@ 2020-01-02 19:56             ` Jonathan Tan
  0 siblings, 0 replies; 27+ messages in thread
From: Jonathan Tan @ 2020-01-02 19:56 UTC (permalink / raw)
  To: gitster; +Cc: jonathantanmy, gitgitgadget, git, heba.waly

> > Junio, what are your plans over what you have in your tree? If you'd
> > like to hear Heba's opinion on it, then she can chime in; if you'd like
> > a review, then I think it's good to go in.
> 
> On hold until anything like those happens ;-) 
> 
> A random reviewer mentioning something on a patch (either in a
> line-by-line critique form or "how about doing it this way instead"
> counterproposal form) without getting followed up by others
> (including the original author) is a stall review thread, and it
> does not change the equation if the random reviewer happens to be me.

OK :-)

> > And I think the answer to that is "s" is used throughout the function in
> > various ways (in particular, used to print statuses both to stdout and
> > to the message template) so any wrapping or corralling of scope would
> > just make things more complicated. In particular, the way Heba did it in
> > v2 is more unclear - at the time of setting s->hints = 0, it's done
> 
> You mean "less clear" (just double checking if I got the negation right)?

Yes, less clear - v2 is less clear than v1.

> I think I've merged it to 'next' yesterday, but it does not mean
> that much as we are in -rc and it is not such an urgent "oops we
> broke it in this cycle, let's fix it" issue.  If we see a v3 that
> improves it, I do not mind at all reverting what I merged to 'next'
> and use the updated one instead (either way, it will be in 'master'
> during the next cycle at the earliest).

Sounds good - thanks.

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

end of thread, other threads:[~2020-01-02 19:56 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17  9:17 [PATCH 0/1] [Outreachy] commit: display advice hints when commit fails Heba Waly via GitGitGadget
2019-12-17  9:17 ` [PATCH 1/1] " Heba Waly via GitGitGadget
2019-12-17 22:41   ` Junio C Hamano
2019-12-17 22:45   ` Emily Shaffer
2019-12-19  3:47     ` Heba Waly
2019-12-18  3:13   ` Jonathan Tan
2019-12-18 18:14     ` Junio C Hamano
2019-12-19  3:48     ` Heba Waly
2019-12-19  9:16 ` [PATCH v2 0/1] [Outreachy] " Heba Waly via GitGitGadget
2019-12-19  9:16   ` [PATCH v2 1/1] " Heba Waly via GitGitGadget
2019-12-19 19:14     ` Junio C Hamano
2019-12-19 19:22       ` Junio C Hamano
2019-12-19 19:47         ` Eric Sunshine
2019-12-19 19:57           ` Junio C Hamano
2019-12-20  2:31         ` Emily Shaffer
2019-12-20 18:34           ` Junio C Hamano
2019-12-20 21:39             ` Emily Shaffer
2019-12-31  0:04         ` Jonathan Tan
2019-12-31 19:06           ` Junio C Hamano
2020-01-02 19:56             ` Jonathan Tan
2019-12-19 18:26   ` [PATCH v2 0/1] [Outreachy] " Junio C Hamano
2019-12-19 18:54     ` Emily Shaffer
2019-12-19 19:23       ` Junio C Hamano
2019-12-19 19:45         ` Junio C Hamano
2019-12-21  4:37           ` Heba Waly
2019-12-21 23:54             ` Junio C Hamano
2019-12-21  5:02   ` Heba Waly

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