commit: display advice hints when commit fails
cover 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:
[...]
=====
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.
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
Signature · 1 line
gitgitgadget
PATCH 1/1 commit: display advice hints when commit fails
From: Heba Waly <[email protected]>
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.
--- builtin/commit.c | 1 + t/t7500-commit-template-squash-signoff.sh | 9 +++++++++ 2 files changed, 10 insertions(+)
builtin/commit.c +1 -0
@@ -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)
t/t7500-commit-template-squash-signoff.sh +9 -0
@@ -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
Signature · 1 line
gitgitgadget
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 967
Quoted 12 lines · Heba Waly via GitGitGadget
builtin/commit.c +1
-0@@ -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.
Quoted 18 lines
t/t7500-commit-template-squash-signoff.sh +9
-0@@ -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
Quoted 41 lines · Heba Waly via GitGitGadget
From: Heba Waly <[email protected]>
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 committo:
# [...]
# 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 toCOMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when writing toCOMMIT_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 <[email protected]>--- builtin/commit.c | 1 + t/t7500-commit-template-squash-signoff.sh | 9 +++++++++ 2 files changed, 10 insertions(+)builtin/commit.c +0
-0
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 964
Quoted 4 lines
builtin/commit.c +1
-0@@ -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
Quoted 23 lines
builtin/commit.c +0
-0s->display_comment_prefix = old_display_comment_prefix;run_status (stdout, index_file, prefix,0 , s);if (amend)t/t7500-commit-template-squash-signoff.sh +9
-0@@ -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_doneSignature · 1 line
gitgitgadget
Quoted 54 lines · Emily Shaffer
Quoted 41 lines · Heba Waly via GitGitGadget
From: Heba Waly <[email protected]>
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 committo:
# [...]
# 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 toCOMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when writing toCOMMIT_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 <[email protected]>--- builtin/commit.c | 1 + t/t7500-commit-template-squash-signoff.sh | 9 +++++++++ 2 files changed, 10 insertions(+)builtin/commit.c +0
-0builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 964
Quoted 4 lines
builtin/commit.c +1
-0@@ -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
ea9882bfc4turned 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:
Quoted 8 lines
/*
* 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.
Quoted 6 lines
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.
Quoted 13 lines
- Emily
Quoted 11 lines
builtin/commit.c +0
-0s->display_comment_prefix = old_display_comment_prefix;run_status (stdout, index_file, prefix,0 , s);if (amend)t/t7500-commit-template-squash-signoff.sh +0
-0@@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' ' ) '
Quoted 12 lines
Quoted 11 lines
t/t7500-commit-template-squash-signoff.sh +9
-1+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 --Quoted 1 line
gitgitgadget
Thanks,
Heba
Quoted 5 lines
From: Heba Waly <[email protected]>
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.
Quoted 6 lines
# [...]
# Changes not staged for commit:
# modified:builtin/commit.c
## no changes added to commit
Quoted 8 lines
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:"?
Quoted 11 lines
In
ea9882bfc4(commit: disable status hints when writing toCOMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when writing toCOMMIT_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 <[email protected]>--- 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.
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 967
Quoted 8 lines
builtin/commit.c +1
-0@@ -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.
t/t7500-commit-template-squash-signoff.sh test_expect_success 'check commit with unstaged rename and copy' ' · line 390
Quoted 6 lines
t/t7500-commit-template-squash-signoff.sh +6
-0+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.)
Quoted 62 lines · Jonathan Tan
Quoted 5 lines
From: Heba Waly <[email protected]>
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.
Quoted 6 lines
# [...]
# Changes not staged for commit:
# modified:builtin/commit.c
## no changes added to commitQuoted 8 lines
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.cFor tidiness, can this line also be "
builtin/commit.c" (that is, without the "../" at the beginning) to match what's before "to:"?Quoted 11 lines
In
ea9882bfc4(commit: disable status hints when writing toCOMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when writing toCOMMIT_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 <[email protected]>--- 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.
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 967
Quoted 8 lines
builtin/commit.c +1
-0@@ -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 functioncmd_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->hintsto 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.
Quoted 9 lines
t/t7500-commit-template-squash-signoff.sh test_expect_success 'check commit with unstaged rename and copy' ' · line 390
Quoted 6 lines
t/t7500-commit-template-squash-signoff.sh +6
-0+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.
Quoted 9 lines · Jonathan Tan
Quoted 6 lines
From: Heba Waly <[email protected]>
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
Quoted 15 lines
Quoted 6 lines
# [...]
# Changes not staged for commit:
# modified:builtin/commit.c
## no changes added to commitQuoted 8 lines
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
Quoted 3 lines
For tidiness, can this line also be "
builtin/commit.c" (that is, without the "../" at the beginning) to match what's before "to:"?
Sure.
Quoted 28 lines
Quoted 11 lines
In
ea9882bfc4(commit: disable status hints when writing toCOMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when writing toCOMMIT_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 <[email protected]>--- 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.
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 967
Quoted 8 lines
builtin/commit.c +1
-0@@ -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 functioncmd_commit()(which is the one that declared s locally).
Quoted 5 lines
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->hintsto what the user configured.
Ok.
Quoted 10 lines
The corresponding comment on "
s->hints= 0" might need to be tweaked, too, but I can't think of anything at the moment.t/t7500-commit-template-squash-signoff.sh test_expect_success 'check commit with unstaged rename and copy' ' · line 390
Quoted 6 lines
t/t7500-commit-template-squash-signoff.sh +6
-0+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 &&
Quoted 2 lines
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
v2 cover commit: display advice hints when commit fails
In reply to Heba Waly via GitGitGadgetDisplay 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.
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.
@@ -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
+'
+
Signature · 1 line
gitgitgadget
PATCH v2 1/1 commit: display advice hints when commit fails
From: Heba Waly <[email protected]>
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.
--- builtin/commit.c | 18 ++++++++++++------ t/t7500-commit-template-squash-signoff.sh | 9 +++++++++ 2 files changed, 21 insertions(+), 6 deletions(-)
builtin/commit.c +12 -6
@@ -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 {
t/t7500-commit-template-squash-signoff.sh +9 -0
@@ -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
Signature · 1 line
gitgitgadget
Quoted 5 lines · Heba Waly via GitGitGadget
builtin/commit.c +0
-0
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 819
Quoted 9 lines
builtin/commit.c +0
-6@@ -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.
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 839
Quoted 10 lines
builtin/commit.c +6
-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 ; +
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.
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 915
Quoted 5 lines
builtin/commit.c +1
-0@@ -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 "(".
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 920
Quoted 5 lines
builtin/commit.c +5
-0+/* +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?
builtin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 923
Quoted 3 lines
builtin/commit.c +0
-0s->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...
Quoted 7 lines · Junio C Hamano
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->hintsjust before callingrun_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 <[email protected]>
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.
--- builtin/commit.c | 1 + t/t7500-commit-template-squash-signoff.sh | 9 +++++++++ 2 files changed, 10 insertions(+)
builtin/commit.c +1 -0
@@ -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)
t/t7500-commit-template-squash-signoff.sh +9 -0
@@ -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
Signature · 1 line
2.24.1-732-ga9f9d4909c
t/t7500-commit-template-squash-signoff.sh test_expect_success 'check commit with unstaged rename and copy' ' · line 386
Quoted 5 lines · Junio C Hamano
In any case, here is what I tentatively have in my tree (with heavy rewrite to the proposed log message).
t/t7500-commit-template-squash-signoff.sh +2
-0+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.
Quoted 6 lines
t/t7500-commit-template-squash-signoff.sh +6
-0+ 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 +'
Quoted 11 lines · Eric Sunshine
t/t7500-commit-template-squash-signoff.sh test_expect_success 'check commit with unstaged rename and copy' ' · line 386
Quoted 5 lines · Junio C Hamano
In any case, here is what I tentatively have in my tree (with heavy rewrite to the proposed log message).
t/t7500-commit-template-squash-signoff.sh +2
-0+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.
Quoted 7 lines
Quoted 7 lines
t/t7500-commit-template-squash-signoff.sh +6
-0+ 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 +'
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Junio C Hamano
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->hintsjust before callingrun_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?
Quoted 2 lines
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 :)
Quoted 7 lines
-- >8 --
From: Heba Waly <[email protected]>
Date: Tue, 17 Dec 2019 09:17:22 +0000
Subject: [PATCH] commit: honor advice.statusHints when rejecting an empty
commit
Quoted 6 lines
In
ea9882bfc4(commit: disable status hints when writing toCOMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when writing toCOMMIT_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.
Quoted 6 lines
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
Quoted 41 lines
Signed-off-by Heba Waly <[email protected]>Signed-off-by Junio C Hamano <[email protected]>--- builtin/commit.c | 1 + t/t7500-commit-template-squash-signoff.sh | 9 +++++++++ 2 files changed, 10 insertions(+)builtin/commit.c +1
-0@@ -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)t/t7500-commit-template-squash-signoff.sh +9
-0@@ -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_doneSignature · 1 line
2.24.1-732-ga9f9d4909c
Quoted 4 lines · Emily Shaffer
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?
Quoted 6 lines
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.
Quoted 2 lines
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.
Quoted 3 lines
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.
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Emily Shaffer
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 ;)
Quoted 15 lines
Quoted 7 lines
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.
Quoted 2 lines
I'll go ahead and look through the changes to the commit message so I can learn what you're looking for too :)
Quoted 8 lines
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.
Quoted 10 lines
Quoted 4 lines
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.
Quoted 5 lines
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
Quoted 10 lines
Quoted 7 lines
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->hintsjust before callingrun_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]:
Quoted 9 lines
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;
Quoted 5 lines
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.
Quoted 6 lines · Jonathan Tan
Quoted 2 lines
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.
Quoted 9 lines
Quoted 3 lines
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)?
Quoted 6 lines
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, whens->hintsis 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.
Quoted 3 lines
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.
Quoted 11 lines
Quoted 3 lines
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 :-)
Quoted 7 lines
Quoted 5 lines
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 doneYou mean "less clear" (just double checking if I got the negation right)?
Yes, less clear - v2 is less clear than v1.
Quoted 6 lines
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.
Quoted 6 lines · Heba Waly via GitGitGadget
@@ -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?
Quoted 10 lines · Junio C Hamano
Quoted 6 lines · Heba Waly via GitGitGadget
@@ -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.cReally?
It's hard to know what this cryptic comment means.. :)
This was a recommended change:
https://lore.kernel.org/git/[email protected]
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
Quoted 17 lines · Emily Shaffer
Quoted 10 lines · Junio C Hamano
Quoted 6 lines · Heba Waly via GitGitGadget
@@ -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.cReally?
It's hard to know what this cryptic comment means.. :)
This was a recommended change:
https://lore.kernel.org/git/[email protected]
Quoted 6 lines
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*.
Quoted 22 lines · Junio C Hamano
Quoted 20 lines · Emily Shaffer
Quoted 10 lines · Junio C Hamano
Quoted 6 lines · Heba Waly via GitGitGadget
@@ -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.cReally?
It's hard to know what this cryptic comment means.. :)
This was a recommended change:
https://lore.kernel.org/git/[email protected]Since other changes were being made at the same time, I personally don't mind a little nit fix in the commit message.
Quoted 6 lines
Quoted 3 lines
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.
Quoted 3 lines · Junio C Hamano
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?
Quoted 1 line
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.
Quoted 4 lines
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
Quoted 9 lines · Heba Waly
Quoted 4 lines
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.
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/[email protected]/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/[email protected]/)
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
Quoted 141 lines · Heba Waly via GitGitGadget
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 committo:
. [...] . 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 toCOMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when writing toCOMMIT_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 [email protected] [[email protected]]Heba Waly (1):
commit: display advice hints when commit failsbuiltin/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/495Range-diff vs v1:
1:
f23477c5a3! 1:ebec237920commit: 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 toCOMMIT_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.
+ Inea9882bfc4(commit: disable status hints when writing to
+COMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when
+ writing toCOMMIT_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 <[email protected]>@@ -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);
+
+@@
+ intsaved_color_setting;
+ structident_splitci, 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. Resets->hintsto 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.shb/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_failgit commit -m initial >actual &&
++test_must_failgit commit -m update >actual &&
+test_i18ngrep"no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual +'
+--
gitgitgadget