{"thread":{"id":"2700","subject":"rebase problems","startedAt":"2005-11-28T14:58:14Z","lastAt":"2005-11-28T21:02:07Z","messageCount":4,"participants":["Sven Verdoolaege","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"12875","messageId":"20051128145814.GW8383MdfPADPa@greensroom.kotnet.org","threadId":"2700","inReplyTo":null,"subject":"rebase problems","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2005-11-28T14:58:14Z","receivedAt":"2005-11-28T14:58:14Z","isPatch":false,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"Recently, rebasing has stopped working for me.\nHere is an example:\n\nbash-3.00$ git-show-branch origin HEAD\n! [origin] fix in which we remove the definition of index statements that are *not* used in the control vector\n ! [HEAD] propagate LinearizationType typo fix.\n--\n + [HEAD] propagate LinearizationType typo fix.\n + [HEAD^] LinearizationType: typo\n + [HEAD~2] espam::DecomposeChannels: actually decompose the channel if valid.\n + [HEAD~3] DecomposeChannels: split channel and check whether result is a pair of fifos.\n + [HEAD~4] Use proper class for LinearizationType.\n + [HEAD~5] espam/../DecomposeChannels: partial implementation.\n + [HEAD~6] espam: add flag for channel decomposition.\n+  [origin] fix in which we remove the definition of index statements that are *not* used in the control vector\n++ [HEAD~7] espam/../IndexVector::toString: include contents of IndexVector.\nbash-3.00$ git rebase origin\n\nApplying 'espam::DecomposeChannels: actually decompose the channel if valid.'\n\nerror: pa/espam/operations/transformations/DecomposeChannels.java: does not exist in index\nUsing index info to reconstruct a base tree...\nFalling back to patching base and 3-way merge...\nTrying simple merge.\nSimple merge failed, trying Automatic merge.\nERROR: pa/espam/operations/transformations/DecomposeChannels.java: Not handling case 09322db769adbc03bfd4f3ac2720c6d1db5a85b1 ->  -> 32da8b1de4205c4adb0da50648a0a00d60b67582\nfatal: merge program failed\nFailed to merge in the changes.\nPatch failed at 0007.\n0001-espam-add-flag-for-channel-decomposition.txt\n\n\nI'm not sure what rebase is doing here, but the only change in origin\nmodified a file untouched by the changes in HEAD, so there shouldn't\nbe any conflict whatsoever.\nApparently it's trying to apply the change in HEAD~2 without having\napplied the earlier changes (which and the file named above).\n\nskimo\n\nPS: I'll try and look into the gitk thing this evening.\n"},{"id":"12891","messageId":"7v4q5wttib.fsf@assigned-by-dhcp.cox.net","threadId":"2700","inReplyTo":"20051128145814.GW8383MdfPADPa@greensroom.kotnet.org","subject":"Re: rebase problems","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-28T20:19:40Z","receivedAt":"2005-11-28T20:19:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sven Verdoolaege <skimo@kotnet.org> writes:\n\n> Recently, rebasing has stopped working for me.\n> Here is an example:\n>\n> bash-3.00$ git-show-branch origin HEAD\n> ! [origin] fix in which we remove the definition of index statements that are *not* used in the control vector\n>  ! [HEAD] propagate LinearizationType typo fix.\n> --\n>  + [HEAD] propagate LinearizationType typo fix.\n>  + [HEAD^] LinearizationType: typo\n>  + [HEAD~2] espam::DecomposeChannels: actually decompose the channel if valid.\n>  + [HEAD~3] DecomposeChannels: split channel and check whether result is a pair of fifos.\n>  + [HEAD~4] Use proper class for LinearizationType.\n>  + [HEAD~5] espam/../DecomposeChannels: partial implementation.\n>  + [HEAD~6] espam: add flag for channel decomposition.\n> +  [origin] fix in which we remove the definition of index statements that are *not* used in the control vector\n> ++ [HEAD~7] espam/../IndexVector::toString: include contents of IndexVector.\n> bash-3.00$ git rebase origin\n>\n> Applying 'espam::DecomposeChannels: actually decompose the channel if valid.'\n>\n> error: pa/espam/operations/transformations/DecomposeChannels.java: does not exist in index\n> Using index info to reconstruct a base tree...\n> Falling back to patching base and 3-way merge...\n> Trying simple merge.\n> Simple merge failed, trying Automatic merge.\n> ERROR: pa/espam/operations/transformations/DecomposeChannels.java: Not handling case 09322db769adbc03bfd4f3ac2720c6d1db5a85b1 ->  -> 32da8b1de4205c4adb0da50648a0a00d60b67582\n> fatal: merge program failed\n> Failed to merge in the changes.\n> Patch failed at 0007.\n> 0001-espam-add-flag-for-channel-decomposition.txt\n>\n>\n> I'm not sure what rebase is doing here, but the only change in origin\n> modified a file untouched by the changes in HEAD, so there shouldn't\n> be any conflict whatsoever.\n> Apparently it's trying to apply the change in HEAD~2 without having\n> applied the earlier changes (which and the file named above).\n\nWhat it should be doing (although I have not seen this kind of\nbreakage myself, there could be a bug that makes rebase not to\ndo what it should be doing) is:\n\n - save the original HEAD to .git/ORIG_HEAD\n - reset the tree to origin without switching branches\n - prepare patches for changes ~6, ~5, ... brings in\n - feed that to git-am, which saves the 7 patches in\n   .dotest/0001 through .dotest/0007 and starts applying them.\n\nAs the first thing to do after you see something like this,\nplease stash away ORIG_HEAD, like this:\n\n\t$ git branch before-rebase-precious ORIG_HEAD\n\nAfter this, if you choose not to rebase for whatever reason,\nincluding \"rebase is broken X-<\", you could do\n\n\t$ git-reset --hard before-rebase-precious\n\nto come back to the state before trying rebase.\n\nThe output seems very inconsistent I am not sure why the first\nmessage says \"Applying HEAD~2\", not HEAD~6.    What patches do\nyou see in .dotest/ directory, and are they numbered in the\nright order?  HEAD~6 should be numbered 0001 and that should be\nthe first one that was applied.\n"},{"id":"12892","messageId":"20051128202428.GA8383MdfPADPa@greensroom.kotnet.org","threadId":"2700","inReplyTo":"7v4q5wttib.fsf@assigned-by-dhcp.cox.net","subject":"Re: rebase problems","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2005-11-28T20:24:29Z","receivedAt":"2005-11-28T20:24:29Z","isPatch":false,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Mon, Nov 28, 2005 at 12:19:40PM -0800, Junio C Hamano wrote:\n> The output seems very inconsistent I am not sure why the first\n> message says \"Applying HEAD~2\", not HEAD~6.    What patches do\n> you see in .dotest/ directory, and are they numbered in the\n> right order?  HEAD~6 should be numbered 0001 and that should be\n> the first one that was applied.\n\nAh!  It seems .dotest still contained some stuff from a previous\n(expectedly) failed rebase.\n\nRebase worked after rm -rf'ing .dotest\n\nMaybe rebase should clean up .dotest or at least warn about\nan existing .dotest ?\n\nThanks,\nskimo\n"},{"id":"12894","messageId":"7vhd9wscz4.fsf@assigned-by-dhcp.cox.net","threadId":"2700","inReplyTo":"20051128202428.GA8383MdfPADPa@greensroom.kotnet.org","subject":"Re: rebase problems","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-28T21:02:07Z","receivedAt":"2005-11-28T21:02:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sven Verdoolaege <skimo@kotnet.org> writes:\n\n> On Mon, Nov 28, 2005 at 12:19:40PM -0800, Junio C Hamano wrote:\n>> The output seems very inconsistent I am not sure why the first\n>> message says \"Applying HEAD~2\", not HEAD~6.    What patches do\n>> you see in .dotest/ directory, and are they numbered in the\n>> right order?  HEAD~6 should be numbered 0001 and that should be\n>> the first one that was applied.\n>\n> Ah!  It seems .dotest still contained some stuff from a previous\n> (expectedly) failed rebase.\n>\n> Rebase worked after rm -rf'ing .dotest\n>\n> Maybe rebase should clean up .dotest or at least warn about\n> an existing .dotest ?\n\nThanks, you are right.  I was coming to the same conclusion.\n\nThere are a few more problems in the current rebase.\n\n - If the branch being rebased is fully in sync with the master\n   (i.e. there is no patch to apply), it fails with a mysterious\n   message \"fatal: cannot read mbox\".\n\n - If the branch being rebased is already a proper descendant of\n   the master, it still goes ahead and rebases.  This is\n   unnecessary.\n\nI think something like this is necessary.\n\n-- >8 --\n[PATCH] rebase: one safety net, one bugfix and one optimization.\n\nWhen a .dotest from a previously failed rebase or patch\napplication exists, rebase got confused and tried to apply\nmixture of what was already there and what is being rebased.\nCheck the existence of the directory and barf.\n\nIt failed with an mysterious \"fatal: cannot read mbox\" message\nif the branch being rebased is fully in sync with the base.\nAlso if the branch is a proper descendant of the base, there is\nno need to run rebase logic.  Prevent these from happening by\nchecking where the merge-base is.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n git-rebase.sh |   28 +++++++++++++++++++++++++++-\n 1 files changed, 27 insertions(+), 1 deletions(-)\n\napplies-to: fe523a4df93cce3e5c5b0266b9d3f1cbea009afa\n7f4bd5d831ea838668d1de5f5af022f763230eee\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 2bc3a12..638ff0d 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -5,9 +5,25 @@\n \n . git-sh-setup\n \n-# The other head is given\n+# Make sure we do not have .dotest\n+if mkdir .dotest\n+then\n+\trmdir .dotest\n+else\n+\techo >&2 '\n+It seems that I cannot create a .dotest directory, and I wonder if you\n+are in the middle of patch application or another rebase.  If that is not\n+the case, please rm -fr .dotest and run me again.  I am stopping in case\n+you still have something valuable there.'\n+\texit 1\n+fi\n+\n+# The other head is given.  Make sure it is valid.\n other=$(git-rev-parse --verify \"$1^0\") || exit\n \n+# Make sure we have HEAD that is valid.\n+head=$(git-rev-parse --verify \"HEAD^0\") || exit\n+\n # The tree must be really really clean.\n git-update-index --refresh || exit\n diff=$(git-diff-index --cached --name-status -r HEAD)\n@@ -23,6 +39,16 @@ case \"$#\" in\n \tgit-checkout \"$2\" || exit\n esac\n \n+# If the HEAD is a proper descendant of $other, we do not even need\n+# to rebase.  Make sure we do not do needless rebase.  In such a\n+# case, merge-base should be the same as \"$other\".\n+mb=$(git-merge-base \"$other\" \"$head\")\n+if test \"$mb\" = \"$other\"\n+then\n+\techo >&2 \"Current branch `git-symbolic-ref HEAD` is up to date.\"\n+\texit 0\n+fi\n+\n # Rewind the head to \"$other\"\n git-reset --hard \"$other\"\n git-format-patch -k --stdout --full-index \"$other\" ORIG_HEAD |\n---\n0.99.9.GIT\n"}]}