{"thread":{"id":"9337","subject":"git rebase--interactive, doesn't ignore commits already in upstream","startedAt":"2007-08-01T11:28:22Z","lastAt":"2007-08-01T14:59:35Z","messageCount":2,"participants":["Mark Levedahl","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"49300","messageId":"46B06E56.2040206@gmail.com","threadId":"9337","inReplyTo":null,"subject":"git rebase--interactive, doesn't ignore commits already in upstream","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2007-08-01T11:28:22Z","receivedAt":"2007-08-01T11:28:22Z","isPatch":false,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"git rebase -i does not correctly ignore commits in the local branch that \nare also in upstream. For example, create a branch that is two commits \nback from upstream, add one of those on to the local branch\n\nupstream=83b3df7d58\ngit checkout -f $upstream\ngit checkout -b foo $upstream~2\ngit cherry-pick $upstream~1\ngit rebase -i  $upstream\n\n\"git rebase -i\" happily presents commit \"$upstream~1\" in the list to be \napplied to upstream. This of course results in a conflict. Should the \nuser simply delete the offending commit from the presented list, git \nrebase -i then refuses to do anything, saying \"Nothing to do.\"\n\nBare \"git rebase\" handles this case correctly (essentially fast forwards \nthe branch to upstream.\n\nMark\n"},{"id":"49314","messageId":"Pine.LNX.4.64.0708011505010.14781@racer.site","threadId":"9337","inReplyTo":"46B06E56.2040206@gmail.com","subject":"[PATCH] rebase -i: ignore patches that are in upstream already","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-01T14:59:35Z","receivedAt":"2007-08-01T14:59:35Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nNon-interactive rebase had this already, exploiting format-patch's option\n--ignore-if-in-upstream.  We replicate the same behaviour here with\n--cherry-pick.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Wed, 1 Aug 2007, Mark Levedahl wrote:\n\n\t> git rebase -i does not correctly ignore commits in the local \n\t> branch that are also in upstream. For example, create a branch \n\t> that is two commits back from upstream, add one of those on to \n\t> the local branch\n\t> \n\t> upstream=83b3df7d58\n\t> git checkout -f $upstream\n\t> git checkout -b foo $upstream~2\n\t> git cherry-pick $upstream~1\n\t> git rebase -i  $upstream\n\t> \n\t> \"git rebase -i\" happily presents commit \"$upstream~1\" in the \n\t> list to be applied to upstream. This of course results in a \n\t> conflict. Should the user simply delete the offending commit \n\t> from the presented list, git rebase -i then refuses to do \n\t> anything, saying \"Nothing to do.\"\n\t> \n\t> Bare \"git rebase\" handles this case correctly (essentially fast \n\t> forwards the branch to upstream.\n\n\tRight.\n\n git-rebase--interactive.sh    |    5 +++--\n t/t3404-rebase-interactive.sh |   15 +++++++++++++++\n 2 files changed, 18 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 061cd0a..d3addd4 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -463,8 +463,9 @@ do\n #\n EOF\n \t\tgit rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n-\t\t\t--abbrev=7 --reverse $UPSTREAM..$HEAD | \\\n-\t\t\tsed \"s/^/pick /\" >> \"$TODO\"\n+\t\t\t--abbrev=7 --reverse --left-right --cherry-pick \\\n+\t\t\t$UPSTREAM...$HEAD | \\\n+\t\t\tsed -n \"s/^>/pick /p\" >> \"$TODO\"\n \n \t\ttest -z \"$(grep -ve '^$' -e '^#' < $TODO)\" &&\n \t\t\tdie_abort \"Nothing to do\"\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 817f614..dc436d7 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -68,6 +68,9 @@ test \"\\$1\" = .git/COMMIT_EDITMSG && {\n \ttest -z \"\\$FAKE_COMMIT_AMEND\" || echo \"\\$FAKE_COMMIT_AMEND\" >> \"\\$1\"\n \texit\n }\n+test -z \"\\$EXPECT_COUNT\" ||\n+\ttest \"\\$EXPECT_COUNT\" = \\$(grep -ve \"^#\" -e \"^$\" < \"\\$1\" | wc -l) ||\n+\texit\n test -z \"\\$FAKE_LINES\" && exit\n grep -v \"^#\" < \"\\$1\" > \"\\$1\".tmp\n rm \"\\$1\"\n@@ -251,4 +254,16 @@ test_expect_success 'interrupted squash works as expected' '\n \ttest $one = $(git rev-parse HEAD~2)\n '\n \n+test_expect_success 'ignore patch if in upstream' '\n+\tHEAD=$(git rev-parse HEAD) &&\n+\tgit checkout -b has-cherry-picked HEAD^ &&\n+\techo unrelated > file7 &&\n+\tgit add file7 &&\n+\ttest_tick &&\n+\tgit commit -m \"unrelated change\" &&\n+\tgit cherry-pick $HEAD &&\n+\tEXPECT_COUNT=1 git rebase -i $HEAD &&\n+\ttest $HEAD = $(git rev-parse HEAD^)\n+'\n+\n test_done\n-- \n1.5.3.rc3.112.gf60b6\n"}]}