Eliminate cryptic "needs update" error message
v2 cover Eliminate cryptic "needs update" error message
Thanks to Matthieu for reviewing round 1: all the changes he suggested are incorporated in this round.
Ramkumar Ramachandra (2):
sh-setup: Write a new require_clean_work_tree function Porcelain scripts: Rewrite cryptic "needs update" error message
git-pull.sh | 5 +---- git-rebase--interactive.sh | 21 +++++---------------- git-rebase.sh | 14 +------------- git-sh-setup.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
PATCH v2 1/2 sh-setup: Write a new require_clean_work_tree function
Write a new require_clean_work_tree function to error out when unstaged changes are present in the working tree and (optionally) uncommitted changes in the index.
--- git-sh-setup.sh | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-)
git-sh-setup.sh +28 -0
@@ -145,6 +145,34 @@ require_work_tree () { die "fatal: $0 cannot be used without a working tree." } +require_clean_work_tree () { + # Update the index + git update-index -q --ignore-submodules --refresh + err=0 + + # Disallow unstaged changes in the working tree + if ! git diff-files --quiet --ignore-submodules -- + then + echo >&2 "cannot $1: you have unstaged changes." + git diff-files --name-status -r --ignore-submodules -- >&2 + err=1 + fi + + # Disallow uncommitted changes in the index + if ! git diff-index --cached --quiet HEAD --ignore-submodules -- + then + echo >&2 "cannot $1: your index contains uncommitted changes." + git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 + err=1 + fi + + if [ $err = 1 ] + then + echo >&2 "Please commit or stash them." + exit 1 + fi +} + get_author_ident_from_commit () { pick_author_script=' /^author /{
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Quoted 6 lines · Ramkumar Ramachandra
Write a new
require_clean_work_treefunction to error out when unstaged changes are present in the working tree and (optionally) uncommitted changes in the index.Cc Matthieu Moy <[email protected]>Signed-off-by Ramkumar Ramachandra <[email protected]>
Please don't do this in-body "Cc:"; it is meaningless.
Quoted 9 lines
--- git-sh-setup.sh | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-)git-sh-setup.sh +0
-0
git-sh-setup.sh require_work_tree () { · line 154
Quoted 10 lines
git-sh-setup.sh +7
-0@@ -145,6 +145,34 @@ require_work_tree () { die "fatal: $0 cannot be used without a working tree." } +require_clean_work_tree () { + # Update the index + git update-index -q --ignore-submodules --refresh + err=0 + + # Disallow unstaged changes in the working tree + if ! git diff-files --quiet --ignore-submodules --
What is that trailing double-dash about?
git-sh-setup.sh require_work_tree () { · line 162
Quoted 8 lines
git-sh-setup.sh +8
-0+ then + echo >&2 "cannot $1: you have unstaged changes." + git diff-files --name-status -r --ignore-submodules -- >&2 + err=1 + fi + + # Disallow uncommitted changes in the index + if ! git diff-index --cached --quiet HEAD --ignore-submodules --
Do not write HEAD there that sets a wrong example; the command line arguments are flag-options, revs, double-dash and pathspec.
Contrary to what your proposed log message says, I do not see anything "optional" in the way how this check is done here... What is going on?
Unfortunately we cannot judge if unconditional check is the right thing to do without looking at the callers; why did you make this into two-patch series?
Mental note before reviewing the second patch: do all callers want the same "both working tree and index are spiffy clean" check?
git-sh-setup.sh require_work_tree () { · line 174
Quoted 12 lines
git-sh-setup.sh +12
-0+ then + echo >&2 "cannot $1: your index contains uncommitted changes." + git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 + err=1 + fi + + if [ $err = 1 ] + then + echo >&2 "Please commit or stash them." + exit 1 + fi +}
Mental note before reviewing the second patch: warning/error messages from this codepath are all written without warning: or error: prefixes.
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Hi Junio,
Thanks for the review.
Quoted 8 lines · Junio C Hamano
Quoted 6 lines
Write a new
require_clean_work_treefunction to error out when unstaged changes are present in the working tree and (optionally) uncommitted changes in the index.Cc Matthieu Moy <[email protected]>Signed-off-by Ramkumar Ramachandra <[email protected]>Please don't do this in-body "Cc:"; it is meaningless.
Oh. What I intended to say was that Matthieu reviewed my previous iteration- should I just put that information in the cover letter or is there some other notation I should use? I can't use "Reviewed-by" either because he only reviewed the previous iteration- not this one.
Quoted 12 lines
Quoted 12 lines
--- git-sh-setup.sh | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-)git-sh-setup.sh +0
-0@@ -145,6 +145,34 @@ require_work_tree () { die "fatal: $0 cannot be used without a working tree." }
Quoted 9 lines
git-sh-setup.sh require_work_tree () { · line 154
Quoted 7 lines
git-sh-setup.sh +7
-0+require_clean_work_tree () { + # Update the index + git update-index -q --ignore-submodules --refresh + err=0 + + # Disallow unstaged changes in the working tree + if ! git diff-files --quiet --ignore-submodules --What is that trailing double-dash about?
Hm, I think I got confused between the options that git-diff-index and git-diff-files take. I'll get rid of this in the next iteration.
Quoted 11 lines
git-sh-setup.sh require_work_tree () { · line 162
Quoted 8 lines
git-sh-setup.sh +8
-0+ then + echo >&2 "cannot $1: you have unstaged changes." + git diff-files --name-status -r --ignore-submodules -- >&2 + err=1 + fi + + # Disallow uncommitted changes in the index + if ! git diff-index --cached --quiet HEAD --ignore-submodules --Do not write HEAD there that sets a wrong example; the command line arguments are flag-options, revs, double-dash and pathspec.
Ok. I suppose git diff-index --cached --quiet --ignore-submodules HEAD -- is better. Should I keep the double-dash or is it unnecessary?
Quoted 2 lines
Contrary to what your proposed log message says, I do not see anything "optional" in the way how this check is done here... What is going on?
Oops, sorry about that -- it's a slightly dated log message: While writing the patch, I thought I'd be clever and pass a $2 to make this optional, but decided against it later.
Quoted 3 lines
Unfortunately we cannot judge if unconditional check is the right thing to do without looking at the callers; why did you make this into two-patch series?
Oh, ok. I'll make it a single patch in the next iteration.
Quoted 2 lines
Mental note before reviewing the second patch: do all callers want the same "both working tree and index are spiffy clean" check?
Not necessarily, but I figured that many of them want it.
Quoted 7 lines
Quoted 7 lines
git-sh-setup.sh +7
-0+ then + echo >&2 "cannot $1: your index contains uncommitted changes." + git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 + err=1 + fi + + if [ $err = 1 ]
Quoted 8 lines
git-sh-setup.sh require_work_tree () { · line 174
Quoted 5 lines
git-sh-setup.sh +5
-0+ then + echo >&2 "Please commit or stash them." + exit 1 + fi +}Mental note before reviewing the second patch: warning/error messages from this codepath are all written without warning: or error: prefixes.
As you've pointed out in the second patch, it's probably not a good idea to print out the advice here.
-- Ram
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Quoted 8 lines · Ramkumar Ramachandra
Quoted 1 line · Junio C Hamano
Please don't do this in-body "Cc:"; it is meaningless.
Oh. What I intended to say was that Matthieu reviewed my previous iteration- should I just put that information in the cover letter or is there some other notation I should use? I can't use "Reviewed-by" either because he only reviewed the previous iteration- not this one.
Some noise about Cc and Reviewed-by tags:
- I have been using Cc lines in patches to say "I consider this person something of a maintainer of the subsystem in question and would be particularly interested in his or her opinion." The idea is that if the patch does not get acked and a Cc line remains, people can tell that from the log. The benefits:
1) I remember to cc them
2) later it is easy to find who looks like a maintainer
3) the lack of ack is more obvious
Checking Linux's Documentation/SubmittingPatches, I find that that is a misuse on my part (sorry). A person passing on a patch to Linus is rather supposed to _add_ a Cc line in the rare event that they want to explain that a certain person had an opportunity to comment but did not comment (so Linus can know about their indifference to the patch, I guess).
Neither use is as important for git, where many people read the list so it is not as important to cc people to get proper review.
- I also used to abuse Cc lines to fit in contact information for a person who helped me, until I learned to use Helped-by and similar neologisms for that. Sorry.
- Again from Documentation/SubmittingPatches, I learned a while ago that Reviewed-by, unlike Acked-by, can only be offered by the reviewer and means that she is satisfied that the patch is ready for application.
If you just want to credit Matthieu, I suppose it would make sense to say "Thanks to Matthieu Moy for such-and-such" somewhere.
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Hi Jonathan,
Quoted 26 lines · Jonathan Nieder
Some noise about Cc and Reviewed-by tags:
- I have been using Cc lines in patches to say "I consider this person something of a maintainer of the subsystem in question and would be particularly interested in his or her opinion." The idea is that if the patch does not get acked and a Cc line remains, people can tell that from the log. The benefits:
1) I remember to cc them
2) later it is easy to find who looks like a maintainer
3) the lack of ack is more obviousChecking Linux's
Documentation/SubmittingPatches, I find that that is a misuse on my part (sorry). A person passing on a patch to Linus is rather supposed to _add_ a Cc line in the rare event that they want to explain that a certain person had an opportunity to comment but did not comment (so Linus can know about their indifference to the patch, I guess).Neither use is as important for git, where many people read the list so it is not as important to cc people to get proper review.
- I also used to abuse Cc lines to fit in contact information for a person who helped me, until I learned to use Helped-by and similar neologisms for that. Sorry.
Quoted 7 lines
- Again from
Documentation/SubmittingPatches, I learned a while ago that Reviewed-by, unlike Acked-by, can only be offered by the reviewer and means that she is satisfied that the patch is ready for application.If you just want to credit Matthieu, I suppose it would make sense to say "Thanks to Matthieu Moy for such-and-such" somewhere.
Thanks for the lengthy explanation. Perhaps we can document this in Git's SubmittingPatches?
Are all these tags useful? Should I include more such as "Mentored-by" or explicity mention that the contributor is free to come up with other freeform tags as she deems appropriate?
-- 8< --
Documentation/SubmittingPatches +19 -6
@@ -264,12 +264,25 @@ the change to its true author (see (2) above). Also notice that a real name is used in the Signed-off-by: line. Please don't hide your real name. -Some people also put extra tags at the end. - -"Acked-by:" says that the patch was reviewed by the person who -is more familiar with the issues and the area the patch attempts -to modify. "Tested-by:" says the patch was tested by the person -and found to have the desired effect. +Some extra tags you can use in the end along with their meanings are: + +1. "Reported-by:" is used to to credit someone who found the bug that + the patch attempts to fix. +2. "Acked-by:" says that the patch was acknowledged by the person who + is more familiar with the issues and the area the patch attempts to + modify. +3. "Reviewed-by:", unlike the other tags, can only be offered by the + reviewer and means that she is completely satisfied that the patch + is ready for application. It is usually offered only after a + detailed review. +4. "Tested-by:" is used to indicate that the person applied the patch + and found it to have the desired effect. +5. "Thanks-to:" is a more broad term used to credit someone who helped + with the patch in some way. The person perhaps gave an idea or + reviewed some part of the patch without awarding a "Reviewed-by". +6. "Based-on-patch-by:" is used to credit the person whose patch yours + is based on. The original patch was probably not considered for + inclusion due to several reasons. ------------------------------------------------ An ideal patch flow
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Quoted 1 line · Ramkumar Ramachandra
Are all these tags useful?
Probably not. :)
Documentation/SubmittingPatches the change to its true author (see (2) above). · line 267
Quoted 13 lines
Documentation/SubmittingPatches +1
-6@@ -264,12 +264,25 @@ the change to its true author (see (2) above). Also notice that a real name is used in the Signed-off-by: line. Please don't hide your real name. -Some people also put extra tags at the end. - -"Acked-by:" says that the patch was reviewed by the person who -is more familiar with the issues and the area the patch attempts -to modify. "Tested-by:" says the patch was tested by the person -and found to have the desired effect. +Some extra tags you can use in the end along with their meanings are:
I like the old "Some people" phrasing; maybe we can get the same effect (i.e., making it clear that you don't really have to use these) by saying
If you'd like, you can put extra tags at end:
Documentation/SubmittingPatches the change to its true author (see (2) above). · line 270
Quoted 2 lines
Documentation/SubmittingPatches +2
-0+1. "Reported-by:" is used to to credit someone who found the bug that + the patch attempts to fix.
Sensible.
Documentation/SubmittingPatches the change to its true author (see (2) above). · line 273
Quoted 3 lines
Documentation/SubmittingPatches +3
-0+2. "Acked-by:" says that the patch was acknowledged by the person who + is more familiar with the issues and the area the patch attempts to + modify.
Maybe liked or approved instead of acknowledged.
Documentation/SubmittingPatches the change to its true author (see (2) above). · line 277
Quoted 4 lines
Documentation/SubmittingPatches +4
-0+3. "Reviewed-by:", unlike the other tags, can only be offered by the + reviewer and means that she is completely satisfied that the patch + is ready for application. It is usually offered only after a + detailed review.
Yeah. Linux's Documentation/SubmittingPatches includes a nice "reviewer's statement of oversight" by Jonathan Corbet, explaining what exactly a reviewed-by is and is not supposed to signify.
Documentation/SubmittingPatches the change to its true author (see (2) above). · line 285
Quoted 8 lines
Documentation/SubmittingPatches +8
-0+4. "Tested-by:" is used to indicate that the person applied the patch + and found it to have the desired effect. +5. "Thanks-to:" is a more broad term used to credit someone who helped + with the patch in some way. The person perhaps gave an idea or + reviewed some part of the patch without awarding a "Reviewed-by". +6. "Based-on-patch-by:" is used to credit the person whose patch yours + is based on. The original patch was probably not considered for + inclusion due to several reasons.
These seem intuitive without explanation. I suppose Tested-by is common enough and worth encouraging, though. In the end, a person can put what they want. (e.g. the mysterious Whatevered-by:
http://lwn.net/Articles/399052/.)
Anyway, thanks for clearing this up.
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Hi Jonathan,
Quoted 5 lines · Jonathan Nieder
Quoted 1 line · Ramkumar Ramachandra
Are all these tags useful?
Probably not. :)
[...]
How about this then?
Thanks-to: Jonathan Nieder <[email protected]>
-- 8< --
Documentation/SubmittingPatches +15 -6
@@ -264,12 +264,21 @@ the change to its true author (see (2) above). Also notice that a real name is used in the Signed-off-by: line. Please don't hide your real name. -Some people also put extra tags at the end. - -"Acked-by:" says that the patch was reviewed by the person who -is more familiar with the issues and the area the patch attempts -to modify. "Tested-by:" says the patch was tested by the person -and found to have the desired effect. +If you like, you can put extra tags at the end: + +1. "Reported-by:" is used to to credit someone who found the bug that + the patch attempts to fix. +2. "Acked-by:" says that the person who is more familiar with the area + the patch attempts to modify liked the patch. +3. "Reviewed-by:", unlike the other tags, can only be offered by the + reviewer and means that she is completely satisfied that the patch + is ready for application. It is usually offered only after a + detailed review. +4. "Tested-by:" is used to indicate that the person applied the patch + and found it to have the desired effect. + +You can also create your own tag or use one that's in common usage +such as "Thanks-to:", "Based-on-patch-by:", or "Mentored-by:". ------------------------------------------------ An ideal patch flow
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Quoted 1 line · Ramkumar Ramachandra
How about this then?
[...]
Documentation/SubmittingPatches the change to its true author (see (2) above). · line 281
Quoted 2 lines
Documentation/SubmittingPatches +2
-0+You can also create your own tag or use one that's in common usage +such as "Thanks-to:", "Based-on-patch-by:", or "Mentored-by:".
I like it.
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Heya,
Wow, I totally did not notice this very interesting sub-thread!
Quoted 5 lines · Jonathan Nieder
Documentation/SubmittingPatches the change to its true author (see (2) above). · line 281
Quoted 2 lines · Ramkumar Ramachandra
Documentation/SubmittingPatches +2
-0+You can also create your own tag or use one that's in common usage +such as "Thanks-to:", "Based-on-patch-by:", or "Mentored-by:".I like it.
Thanks, Jonathan, for the looking up this stuff from the kernel's SubmittinPatches.
FWIW I like Ram's patch to SubmittingPatches too.
Signature · 3 lines
Cheers, Sverre Rabbelier
v2 cover Eliminate cryptic "needs update" error message
Thanks to Matthieu for reviewing round 1: all the changes he suggested are incorporated in this round.
Ramkumar Ramachandra (2):
sh-setup: Write a new require_clean_work_tree function Porcelain scripts: Rewrite cryptic "needs update" error message
git-pull.sh | 5 +---- git-rebase--interactive.sh | 21 +++++---------------- git-rebase.sh | 14 +------------- git-sh-setup.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
PATCH v2 1/2 sh-setup: Write a new require_clean_work_tree function
In reply to Sverre RabbelierWrite a new require_clean_work_tree function to error out when unstaged changes are present in the working tree and (optionally) uncommitted changes in the index.
--- git-sh-setup.sh | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-)
git-sh-setup.sh +28 -0
@@ -145,6 +145,34 @@ require_work_tree () { die "fatal: $0 cannot be used without a working tree." } +require_clean_work_tree () { + # Update the index + git update-index -q --ignore-submodules --refresh + err=0 + + # Disallow unstaged changes in the working tree + if ! git diff-files --quiet --ignore-submodules -- + then + echo >&2 "cannot $1: you have unstaged changes." + git diff-files --name-status -r --ignore-submodules -- >&2 + err=1 + fi + + # Disallow uncommitted changes in the index + if ! git diff-index --cached --quiet HEAD --ignore-submodules -- + then + echo >&2 "cannot $1: your index contains uncommitted changes." + git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 + err=1 + fi + + if [ $err = 1 ] + then + echo >&2 "Please commit or stash them." + exit 1 + fi +} + get_author_ident_from_commit () { pick_author_script=' /^author /{
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
Oops, please ignore the previous email- sent by mistake.
Quoted 6 lines · Ramkumar Ramachandra
Write a new
require_clean_work_treefunction to error out when unstaged changes are present in the working tree and (optionally) uncommitted changes in the index.Cc Matthieu Moy <[email protected]>Signed-off-by Ramkumar Ramachandra <[email protected]>
I'll post a new revision of this patch shortly. Will post the patch to SubmittingPatches now.
-- Ram
PATCH 1/1 SubmittingPatches: Document some extra tags used in commit messages
In reply to Sverre RabbelierDocument the meanings of the tags "Reported-by:", "Acked-by:", "Reviewed-by:" and "Tested-by:" clearly. Also mention that the user is free to use any custom tags.
--- Documentation/SubmittingPatches | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-)
Documentation/SubmittingPatches +15 -6
@@ -264,12 +264,21 @@ the change to its true author (see (2) above). Also notice that a real name is used in the Signed-off-by: line. Please don't hide your real name. -Some people also put extra tags at the end. - -"Acked-by:" says that the patch was reviewed by the person who -is more familiar with the issues and the area the patch attempts -to modify. "Tested-by:" says the patch was tested by the person -and found to have the desired effect. +If you like, you can put extra tags at the end: + +1. "Reported-by:" is used to to credit someone who found the bug that + the patch attempts to fix. +2. "Acked-by:" says that the person who is more familiar with the area + the patch attempts to modify liked the patch. +3. "Reviewed-by:", unlike the other tags, can only be offered by the + reviewer and means that she is completely satisfied that the patch + is ready for application. It is usually offered only after a + detailed review. +4. "Tested-by:" is used to indicate that the person applied the patch + and found it to have the desired effect. + +You can also create your own tag or use one that's in common usage +such as "Thanks-to:", "Based-on-patch-by:", or "Mentored-by:". ------------------------------------------------ An ideal patch flow
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
Re: [PATCH v2 1/2] sh-setup: Write a new require_clean_work_tree function
In reply to Jonathan NiederQuoted 8 lines · Jonathan Nieder
Some noise about Cc and Reviewed-by tags:
Checking Linux's
Documentation/SubmittingPatches, I find that that is a misuse on my part (sorry). A person passing on a patch to Linus is rather supposed to _add_ a Cc line in the rare event that they want to explain that a certain person had an opportunity to comment but did not comment (so Linus can know about their indifference to the patch, I guess).
Ah, that makes sense. Thanks for an explanation.
PATCH v2 2/2 Porcelain scripts: Rewrite cryptic "needs update" error message
In reply to Ramkumar RamachandraAlthough Git interally has the facility to differentiate between porcelain and plubmbing commands and appropriately print errors, several shell scripts invoke plubming commands triggering cryptic plumbing errors to be displayed on a porcelain interface. This patch replaces the "needs update" message in git-pull and git-rebase, when git update-index is run, with a more friendly message.
--- git-pull.sh | 5 +---- git-rebase--interactive.sh | 21 +++++---------------- git-rebase.sh | 14 +------------- 3 files changed, 7 insertions(+), 33 deletions(-)
git-pull.sh +1 -4
@@ -201,10 +201,7 @@ test true = "$rebase" && { die "updating an unborn branch with changes added to the index" fi else - git update-index --ignore-submodules --refresh && - git diff-files --ignore-submodules --quiet && - git diff-index --ignore-submodules --cached --quiet HEAD -- || - die "refusing to pull with rebase: your working tree is not up-to-date" + require_clean_work_tree "pull with rebase" fi oldremoteref= && . git-parse-remote &&
git-rebase--interactive.sh +5 -16
@@ -153,14 +153,6 @@ run_pre_rebase_hook () { fi } -require_clean_work_tree () { - # test if working tree is dirty - git rev-parse --verify HEAD > /dev/null && - git update-index --ignore-submodules --refresh && - git diff-files --quiet --ignore-submodules && - git diff-index --cached --quiet HEAD --ignore-submodules -- || - die "Working tree is dirty" -} ORIG_REFLOG_ACTION="$GIT_REFLOG_ACTION"
@@ -557,12 +549,9 @@ do_next () { exit "$status" fi # Run in subshell because require_clean_work_tree can die. - if ! (require_clean_work_tree) + if ! (require_clean_work_tree "rebase") then - warn "Commit or stash your changes, and then run" - warn - warn " git rebase --continue" - warn + warn "Then run git rebase --continue." exit 1 fi ;;
@@ -740,7 +729,7 @@ do die "Cannot read HEAD" git update-index --ignore-submodules --refresh && git diff-files --quiet --ignore-submodules || - die "Working tree is dirty" + die "Working tree is dirty. Please commit or stash your changes to proceed." # do we have anything to commit? if git diff-index --cached --quiet --ignore-submodules HEAD --
@@ -768,7 +757,7 @@ first and then run 'git rebase --continue' again." record_in_rewritten "$(cat "$DOTEST"/stopped-sha)" - require_clean_work_tree + require_clean_work_tree "rebase" do_rest ;; --abort)
@@ -866,7 +855,7 @@ first and then run 'git rebase --continue' again." comment_for_reflog start - require_clean_work_tree + require_clean_work_tree "rebase" if test ! -z "$1" then
git-rebase.sh +1 -13
@@ -416,19 +416,7 @@ else fi fi -# The tree must be really really clean. -if ! git update-index --ignore-submodules --refresh > /dev/null; then - echo >&2 "cannot rebase: you have unstaged changes" - git diff-files --name-status -r --ignore-submodules -- >&2 - exit 1 -fi -diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --) -case "$diff" in -?*) echo >&2 "cannot rebase: your index contains uncommitted changes" - echo >&2 "$diff" - exit 1 - ;; -esac +require_clean_work_tree "rebase" if test -z "$rebase_root" then
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
Re: [PATCH v2 2/2] Porcelain scripts: Rewrite cryptic "needs update" error message
git-pull.sh test true = "$rebase" && { · line 204
Quoted 13 lines · Ramkumar Ramachandra
git-pull.sh +1
-4@@ -201,10 +201,7 @@ test true = "$rebase" && { die "updating an unborn branch with changes added to the index" fi else - git update-index --ignore-submodules --refresh && - git diff-files --ignore-submodules --quiet && - git diff-index --ignore-submodules --cached --quiet HEAD -- || - die "refusing to pull with rebase: your working tree is not up-to-date" + require_clean_work_tree "pull with rebase"
Ok, this wants both the working tree and the index clean, and it will exit with non-zero. The original message mentioned "working tree" but by calling require_clean_work_tree the user won't see that word anymore.
Quoted 6 lines
git-rebase--interactive.sh +0
-0@@ -153,14 +153,6 @@ run_pre_rebase_hook () { fi
git-rebase--interactive.sh run_pre_rebase_hook () { · line 163
Quoted 10 lines
git-rebase--interactive.sh +0
-8} -require_clean_work_tree () { - # test if working tree is dirty - git rev-parse --verify HEAD > /dev/null && - git update-index --ignore-submodules --refresh && - git diff-files --quiet --ignore-submodules && - git diff-index --cached --quiet HEAD --ignore-submodules -- || - die "Working tree is dirty" -}
We used to test and exit early if HEAD cannot be read (e.g. empty history), but now require_clean_work_tree() will probably spit a cryptic error from diff-index it makes. Don't you need to have an equivalent check for HEAD somewhere before you make the first call to r-c-w-t?
git-rebase--interactive.sh do_next () { · line 554
Quoted 12 lines
git-rebase--interactive.sh +2
-5@@ -557,12 +549,9 @@ do_next () { exit "$status" fi # Run in subshell because require_clean_work_tree can die. - if ! (require_clean_work_tree) + if ! (require_clean_work_tree "rebase") then - warn "Commit or stash your changes, and then run" - warn - warn " git rebase --continue" - warn + warn "Then run git rebase --continue."
We will see something like:
cannot rebase: you have unstaged changes.
M Makefile
cannot rebase: you index contains uncommitted changes. M Makefile
M hello.c
M goodbye.c
... 147 other paths that make the above scroll away ... Please commit or stash them.
Then run git rebase --continue.
Is this what we really want? Also the messages seem somewhat case-challenged.
git-rebase--interactive.sh do · line 732
Quoted 9 lines
git-rebase--interactive.sh +1
-1exit 1 fi ;;@@ -740,7 +729,7 @@ do die "Cannot read HEAD" git update-index --ignore-submodules --refresh && git diff-files --quiet --ignore-submodules || - die "Working tree is dirty" + die "Working tree is dirty. Please commit or stash your changes to proceed."
I wonder if it is a good advice to choose between committing and stashing.
This codepath is for --continue, and by definition when rebase started there wasn't any local modification (otherwise it wouldn't have started and we wouldn't have come this far), so the change must have come from the end user who wanted to amend (or resolve conflicts), thought that s/he included all the changes s/he did in the working tree in the amended commit and told us to continue. We however found some leftover local modifications.
"Please commit or stash" is probably the worst advice we can give in this particular situation. It is likely to be something s/he forgot to add; the existing advice that says "Please commit them first and then ..." you can see a few lines down this part is probably better.
In other codepaths, aborting rebase and cleaning the work area first before attempting a rebase might be a better choice than either committing or stashing. Often, I find that is the least confusing choise, at least.
Quoted 12 lines
git-rebase.sh +0
-4@@ -416,19 +416,7 @@ else fi fi -# The tree must be really really clean. -if ! git update-index --ignore-submodules --refresh > /dev/null; then - echo >&2 "cannot rebase: you have unstaged changes" - git diff-files --name-status -r --ignore-submodules -- >&2
git-rebase.sh else · line 419
Quoted 10 lines
git-rebase.sh +1
-9- exit 1 -fi -diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --) -case "$diff" in -?*) echo >&2 "cannot rebase: your index contains uncommitted changes" - echo >&2 "$diff" - exit 1 - ;; -esac +require_clean_work_tree "rebase"
This side is uncontroversial, except that it has the same "is commit/stash the best advice?" issue.
Re: [PATCH v2 2/2] Porcelain scripts: Rewrite cryptic "needs update" error message
Hi again,
Quoted 11 lines · Junio C Hamano
Quoted 9 lines · Ramkumar Ramachandra
git-pull.sh +0
-1@@ -201,10 +201,7 @@ test true = "$rebase" && { die "updating an unborn branch with changes added to the index" fi else - git update-index --ignore-submodules --refresh &&
Quoted 8 lines
git-pull.sh test true = "$rebase" && { · line 204
Quoted 4 lines
git-pull.sh +1
-3- git diff-files --ignore-submodules --quiet && - git diff-index --ignore-submodules --cached --quiet HEAD -- || - die "refusing to pull with rebase: your working tree is not up-to-date" + require_clean_work_tree "pull with rebase"Ok, this wants both the working tree and the index clean, and it will exit with non-zero. The original message mentioned "working tree" but by calling
require_clean_work_treethe user won't see that word anymore.
Right. I suppose this hunk is alright.
Quoted 8 lines
Quoted 8 lines
git-rebase--interactive.sh +0
-0@@ -153,14 +153,6 @@ run_pre_rebase_hook () { fi }
Quoted 13 lines
git-rebase--interactive.sh run_pre_rebase_hook () { · line 163
Quoted 8 lines
git-rebase--interactive.sh +0
-8-require_clean_work_tree () { - # test if working tree is dirty - git rev-parse --verify HEAD > /dev/null && - git update-index --ignore-submodules --refresh && - git diff-files --quiet --ignore-submodules && - git diff-index --cached --quiet HEAD --ignore-submodules -- || - die "Working tree is dirty" -}We used to test and exit early if HEAD cannot be read (e.g. empty history), but now
require_clean_work_tree()will probably spit a cryptic error from diff-index it makes. Don't you need to have an equivalent check for HEAD somewhere before you make the first call to r-c-w-t?
Ok. I'll add that in the next iteration.
Quoted 25 lines
git-rebase--interactive.sh do_next () { · line 554
Quoted 12 lines
git-rebase--interactive.sh +2
-5@@ -557,12 +549,9 @@ do_next () { exit "$status" fi # Run in subshell because require_clean_work_tree can die. - if ! (require_clean_work_tree) + if ! (require_clean_work_tree "rebase") then - warn "Commit or stash your changes, and then run" - warn - warn " git rebase --continue" - warn + warn "Then run git rebase --continue."We will see something like:
cannot rebase: you have unstaged changes.
MMakefile
cannot rebase: you index contains uncommitted changes. MMakefile
Mhello.c
Mgoodbye.c
... 147 other paths that make the above scroll away ... Please commit or stash them.
Then run git rebase --continue.
Quoted 2 lines
Is this what we really want? Also the messages seem somewhat case-challenged.
This is one of the concerns I had while creating this iteration. What do you suggest? Should we limit the number of paths listed like this? (I've limited it to 3 paths in this example). Also, is the case alright now?
Cannot rebase: you have unstaged changes.
M Makefile
M ram.c M junio.c (and 372 more)
Cannot rebase: your index contains uncommitted changes.
M Makefile
M hello.c
M goodbye.c
(and 147 more)
Please commit or stash them.
Then run 'git rebase --continue'.
Quoted 17 lines
git-rebase--interactive.sh do · line 732
Quoted 6 lines
git-rebase--interactive.sh +1
-1@@ -740,7 +729,7 @@ do die "Cannot read HEAD" git update-index --ignore-submodules --refresh && git diff-files --quiet --ignore-submodules || - die "Working tree is dirty" + die "Working tree is dirty. Please commit or stash your changes to proceed."I wonder if it is a good advice to choose between committing and stashing.
This codepath is for --continue, and by definition when rebase started there wasn't any local modification (otherwise it wouldn't have started and we wouldn't have come this far), so the change must have come from the end user who wanted to amend (or resolve conflicts), thought that s/he included all the changes s/he did in the working tree in the amended commit and told us to continue. We however found some leftover local modifications.
Quoted 4 lines
"Please commit or stash" is probably the worst advice we can give in this particular situation. It is likely to be something s/he forgot to add; the existing advice that says "Please commit them first and then ..." you can see a few lines down this part is probably better.
Right. I didn't think about this enough.
- If it's an "edit", "squash" or "fixup" interactive rebase step, the staged changes are automatically committed to the current commit:
you don't have to explicity commit --amend.
- If the user doesn't want to squash all the changes into the current commit, he should stage the changes he wants to be included in the commit and stash the rest for use in another step.
- If it's a "reword" step, staged changes/ dirty working tree don't mean anything. The use should simply stash everything and continue in this case.
I suppose I can come up with a way to check which path was taken and print more targeted advice. Will do in the next iteration.
Quoted 3 lines
In other codepaths, aborting rebase and cleaning the work area first before attempting a rebase might be a better choice than either committing or stashing. Often, I find that is the least confusing choise, at least.
I think we should remove the advice from the r-c-w-t and add more targeted advice in the caller.
Quoted 17 lines
Quoted 17 lines
git-rebase.sh +0
-9@@ -416,19 +416,7 @@ else fi fi -# The tree must be really really clean. -if ! git update-index --ignore-submodules --refresh > /dev/null; then - echo >&2 "cannot rebase: you have unstaged changes" - git diff-files --name-status -r --ignore-submodules -- >&2 - exit 1 -fi -diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --) -case "$diff" in -?*) echo >&2 "cannot rebase: your index contains uncommitted changes"
Quoted 8 lines
git-rebase.sh else · line 419
Quoted 5 lines
git-rebase.sh +1
-4- echo >&2 "$diff" - exit 1 - ;; -esac +require_clean_work_tree "rebase"This side is uncontroversial, except that it has the same "is commit/stash the best advice?" issue.
Ok, I'll come up with something nicer in the next iteration.
-- Ram
Re: [PATCH v2 2/2] Porcelain scripts: Rewrite cryptic "needs update" error message
Quoted 2 lines · Ramkumar Ramachandra
This is one of the concerns I had while creating this iteration. What do you suggest? Should we limit the number of paths listed like this?
Personally, I do not think you should list any paths. If the program states clearly that it does not like to see a dirty working tree (or a dirty working tree is likely to be a mistake by a forgetful user), the user already has enough tools such as "git status" and "git diff" to figure out which ones are dirty.
Quoted 3 lines
- If it's an "edit", "squash" or "fixup" interactive rebase step, the staged changes are automatically committed to the current commit:
you don't have to explicity commit --amend.
It might be somewhat irritating to see "you haven't committed the amend" against "rebase --continue" after running "git add" or "git add -p" to shape what should be the final commit, and that is why the codepath runs "commit --amend" for the user, but I personally think this is an attempt to help users that is ill-thought-out. The codepath stops when there are changes to the working tree files that are not added, to avoid mistakes by a forgetful user, but what if the change the user forgot to add was an addition of a new file?
Also, this is one special case that the user has to remember.
It is too late to change this now, but it would have been a lot nicer if we insisted that the "commit --amend" is always done by the user, and never automatically by "rebase-i --continue" codepath.
Quoted 3 lines
- If it's a "reword" step, staged changes/ dirty working tree don't mean anything. The use should simply stash everything and continue in this case.
Why would "reword" involve _any_ local changes?
Quoted 2 lines
I suppose I can come up with a way to check which path was taken and print more targeted advice. Will do in the next iteration.
In general, I am mildly against giving advices like "commit or stash", especially when the program does not know the workflow the end user in each situation is using better than the end user.