{"thread":{"id":"11955","subject":"Bug in git rebase -i where <upstream> is \"HEAD\" in 1.5.4?","startedAt":"2008-02-07T21:47:27Z","lastAt":"2008-02-07T23:32:44Z","messageCount":2,"participants":["Adam Roben","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"67866","messageId":"D94A5309-3EB0-46FA-9114-D11376585DBB@apple.com","threadId":"11955","inReplyTo":null,"subject":"Bug in git rebase -i where <upstream> is \"HEAD\" in 1.5.4?","fromName":"Adam Roben","fromEmail":"aroben@apple.com","sentAt":"2008-02-07T21:47:27Z","receivedAt":"2008-02-07T21:47:27Z","isPatch":false,"sender":{"key":"aroben@apple.com","avatar":"https://gravatar.com/avatar/9d3697e1de53890adf241331f4b970bdd2b18962b2ff0b8028ebb00e085807f8?d=mp&s=160"},"body":"Hi all-\n    I've discovered a difference in behavior between `git rebase` and  \n`git rebase -i`, and I believe the behavior exhibited by `git rebase - \ni` is incorrect and should be changed to match `git rebase`. The  \nbehavior difference occurs when running the command in the form:\n\ngit rebase [-i] <upstream> <branch>\n\n    If <upstream> is \"HEAD\", `git rebase` seems to perform these  \n(correct) steps:\n\nA=$(git rev-parse HEAD)\ngit checkout <branch>\ngit rebase $A\n\n    However, `git rebase -i` seems to perform these (incorrect) steps:\n\ngit checkout <branch>\ngit rebase -i HEAD\n\n    The problem is that `git checkout` changes the meaning of HEAD  \n(naturally), and so these steps are not equivalent. The end result is  \nthat `git rebase -i HEAD <branch>` just checks out <branch> and prints  \n\"Nothing to do\", while when -i is omitted the rebase occurs as  \nexpected. Below is a transcript that shows exactly what I mean.\n\n-Adam\n\n\n% git init\nInitialized empty Git repository in .git/\n% touch onmaster\n% git add onmaster\n% git commit -m \"Added onmaster\"\nCreated initial commit 7c3e0f1: Added onmaster\n  0 files changed, 0 insertions(+), 0 deletions(-)\n  create mode 100644 onmaster\n% touch onmaster2\n% git add onmaster2\n% git commit -m \"Added onmaster2\"\nCreated commit c19019b: Added onmaster2\n  0 files changed, 0 insertions(+), 0 deletions(-)\n  create mode 100644 onmaster2\n% git checkout -b work HEAD^\nSwitched to a new branch \"work\"\n% touch onwork\n% git add onwork\n% git commit -m \"Added onwork\"\nCreated commit ae14495: Added onwork\n  0 files changed, 0 insertions(+), 0 deletions(-)\n  create mode 100644 onwork\n% touch onwork2\n% git add onwork2\n% git commit -m \"Added onwork2\"\nCreated commit 64b3dc0: Added onwork2\n  0 files changed, 0 insertions(+), 0 deletions(-)\n  create mode 100644 onwork2\n% ls\nonmaster onwork   onwork2\n% git checkout master\nSwitched to branch \"master\"\n% ls\nonmaster  onmaster2\n% git rebase -i HEAD work\nNothing to do\n% ls\nonmaster onwork   onwork2\n"},{"id":"67875","messageId":"7vlk5wmjfn.fsf@gitster.siamese.dyndns.org","threadId":"11955","inReplyTo":"D94A5309-3EB0-46FA-9114-D11376585DBB@apple.com","subject":"Re: Bug in git rebase -i where <upstream> is \"HEAD\" in 1.5.4?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-07T23:32:44Z","receivedAt":"2008-02-07T23:32:44Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Roben <aroben@apple.com> writes:\n\n>    I've discovered a difference in behavior between `git rebase` and\n> `git rebase -i`, and I believe the behavior exhibited by `git rebase -\n> i` is incorrect and should be changed to match `git rebase`. The\n> behavior difference occurs when running the command in the form:\n>\n> git rebase [-i] <upstream> <branch>\n>\n>    If <upstream> is \"HEAD\", `git rebase` seems to perform these\n> (correct) steps:\n>\n> A=$(git rev-parse HEAD)\n> git checkout <branch>\n> git rebase $A\n\nYes, I remember writing that side carefully, taking exactly this\nissue into account.\n\n>    However, `git rebase -i` seems to perform these (incorrect) steps:\n\nYeah, I see that interactive side is sloppier.  In\ngit-rebase--interactive.sh, if you move\n\n        HEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n        UPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n\naround l.481 up so that they come before if test !  -z \"$2\",\nyou would be Ok, although I didn't test it.\n"}]}