git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: What's cooking in git.git (topics)

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 2, 2007, 07:21 UTC
Message-ID
<7vlkamm16s.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<vpq641qroae.fsf@bauges.imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
> I'm also concerned about the possibility of stash/unstash to fail:
> that means the user has to deal with two kinds of conflicts (rebase
> can conflict, unstash can also), which can be confusing.

Unstash should be invoked automatically _only_ after rebase completes, so I do not forsee such confusion.

But the trouble I have with the auto unstashing is more at the conceptual and workflow level. You start rebasing a branch, and your work tree is dirty. What branch should the local modification belong to?

Logically, it is with the branch you were on when you typed "git rebase" command.

But when "rebase" successfully concludes (either with or without manual fix-ups), you can be either on your original branch (if you said "git rebase base") or something totally unrelated (if you said "git rebase base other"). Currently we auto-unstash in both cases. I _think_ the former case should auto-unstash, but the latter shouldn't.

However, this auto-stash uses the new "git stash create" command that does not update the reflog for "refs/stash", specifically so that the auto-stashing does _not_ interfere with the normal stash the end user uses. Which means that it is a bit cumbersome to give the autostashed state back to the user if we do _not_ unstash upon completion of rebase.

Perhaps a good compromise would be to
 * not to do the autostash, but fail as we have always done,
   when "git rebase base other" form was used, first instructing
   rebase to switch to another branch;
 * autostash when "git rebase base" form was used, and auto
   unstash upon completion.
Show 14 quoted lines
> But the current behavior can be greatly improved by just making the
> error message better. Currently, I have this:
>
> $ git rebase branch
> foo.txt: needs update
> $ _
>
> I'd prefer something like
>
> $ git rebase branch
> cannot rebase: the working tree is not clean.
> foo.txt: Changed but not updated
> Commit your changes, or put them appart with "git stash" and retry.
> $ _

You forgot 'needs merge' case, so that would not fly very well, but something like this might be a good starting point.

---
 git-rebase.sh |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 058fcac..4f8aeb9 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -252,7 +252,10 @@ else
 fi
 
 # The tree must be really really clean.
-git update-index --refresh || exit
+o=$(git update-index -q --refresh) || {
+	printf "cannot rebase: the work tree is not clean.\n%s\n" "$o"
+	exit 1
+}
 diff=$(git diff-index --cached --name-status -r HEAD)
 case "$diff" in
 ?*)	echo "cannot rebase: your index is not up-to-date"
Previous: Matthieu MoyNext: David Kågedal
Message 37 of 44 in “What's cooking in git.git (topics)”
  1. Junio C HamanoSep 6, 2007
  2. Shawn O. PearceSep 14, 2007
  3. Shawn O. PearceSep 15, 2007
  4. Shawn O. PearceSep 16, 2007
  5. Johannes SchindelinSep 14, 2007
  6. Carlos RicaSep 26, 2007
  7. Junio C HamanoSep 26, 2007
  8. Johannes SchindelinSep 26, 2007
  9. Tom ClarkeSep 26, 2007
  10. Jeff KingSep 27, 2007
  11. David KastrupSep 27, 2007
  12. David KastrupSep 27, 2007
  13. Jeff KingSep 27, 2007
  14. David KastrupSep 27, 2007
  15. Jeff KingOct 2, 2007
  16. Junio C HamanoOct 2, 2007
  17. Jeff KingOct 2, 2007
  18. Jeff KingOct 2, 2007
  19. David KastrupOct 2, 2007
  20. Jeff KingOct 2, 2007
  21. David KastrupOct 2, 2007
  22. Jeff KingOct 2, 2007
  23. David KastrupOct 2, 2007
  24. Linus TorvaldsOct 3, 2007
  25. Jeff KingOct 3, 2007
  26. Linus TorvaldsOct 3, 2007
  27. David KastrupOct 3, 2007
  28. Jeff KingOct 3, 2007
  29. Linus TorvaldsOct 3, 2007
  30. David KastrupOct 3, 2007
  31. Junio C HamanoOct 4, 2007
  32. Daniel BarkalowSep 28, 2007
  33. Junio C HamanoOct 2, 2007
  34. Steven GrimmOct 2, 2007
  35. Steffen ProhaskaOct 2, 2007
  36. Matthieu MoyOct 2, 2007
  37. Junio C HamanoOct 2, 2007
  38. David KågedalOct 2, 2007
  39. Matthieu MoyOct 2, 2007
  40. Junio C HamanoOct 2, 2007
  41. rebase: make the warning more useful when the work tree is unclean.Junio C Hamano, Oct 3, 2007
  42. Matthieu MoyOct 3, 2007
  43. Johannes SchindelinOct 2, 2007
  44. Daniel BarkalowOct 2, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.