{"thread":{"id":"2845","subject":"[PATCH] Bugfixes for git-rebase","startedAt":"2005-12-14T23:36:35Z","lastAt":"2005-12-14T23:36:35Z","messageCount":1,"participants":["Lukas Sandström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"13645","messageId":"43A0AC83.5050206@etek.chalmers.se","threadId":"2845","inReplyTo":null,"subject":"[PATCH] Bugfixes for git-rebase","fromName":"Lukas Sandström","fromEmail":"lukass@etek.chalmers.se","sentAt":"2005-12-14T23:36:35Z","receivedAt":"2005-12-14T23:36:35Z","isPatch":true,"sender":{"key":"luksan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152281?v=4"},"body":"Fix bugs in git-rebase wrt rebasing another branch than\nthe current HEAD, rebasing with a dirty working dir,\nand rebasing a proper decendant of the target branch.\n\nSigned-off-by: Lukas Sandström <lukass@etek.chalmers.se>\n\n---\nWithout this patch git rebase complains about\n\"fatal: cannot read mbox\" when doing a fast-forward.\n\n git-rebase.sh |   29 +++++++++++++++++++----------\n 1 files changed, 19 insertions(+), 10 deletions(-)\n\n2c0e6289d37461abbadb878b9ca8d2bfe2ca1a1b\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 638ff0d..1e9ddde 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -18,31 +18,30 @@ 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-case \"$different\" in\n+case \"$diff\" in\n ?*)\techo \"$diff\"\n \texit 1\n \t;;\n esac\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 the branch to rebase is valid.\n+head=$(git-rev-parse --verify \"${2:-HEAD^0}\") || exit\n+\n # If the branch to rebase is given, first switch to it.\n case \"$#\" in\n 2)\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+\n+#Check if we're already rebased.\n if test \"$mb\" = \"$other\"\n then\n \techo >&2 \"Current branch `git-symbolic-ref HEAD` is up to date.\"\n@@ -51,5 +50,15 @@ fi\n \n # Rewind the head to \"$other\"\n git-reset --hard \"$other\"\n+\n+# If the previous HEAD was a proper descendant of $other, we do not even\n+# need to rebase.  Make sure we do not do needless rebase.  In such a\n+# case, merge-base should be the same as \"$head\".\n+if test \"$mb\" = \"$head\"\n+then\n+\techo >&2 \"Fast-forwarded $head to $other.\"\n+\texit 0\n+fi\n+\n git-format-patch -k --stdout --full-index \"$other\" ORIG_HEAD |\n git am --binary -3 -k\n-- \n0.99.9.GIT\n"}]}