rebase -i: ignore patches that are already in the upstream
Non-interactive rebase had this from the beginning -- match it by using --cherry-pick option to rev-list. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Aug 1, 2007 at 15:59 UTC
96ffe892e307ea512abbc633f822558c568cece1
2 files changed
+18
-2
git-rebase--interactive.sh
+3
-2
@@ -463,8 +463,9 @@ do
463
#
464
EOF
465
git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
466
- --abbrev=7 --reverse $UPSTREAM..$HEAD | \
467
- sed "s/^/pick /" >> "$TODO"
466
+ --abbrev=7 --reverse --left-right --cherry-pick \
467
+ $UPSTREAM...$HEAD | \
468
+ sed -n "s/^>/pick /p" >> "$TODO"
469
470
test -z "$(grep -ve '^$' -e '^#' < $TODO)" &&
471
die_abort "Nothing to do"
t/t3404-rebase-interactive.sh
+15
@@ -68,6 +68,9 @@ test "\$1" = .git/COMMIT_EDITMSG && {
68
test -z "\$FAKE_COMMIT_AMEND" || echo "\$FAKE_COMMIT_AMEND" >> "\$1"
69
exit
70
}
71
+test -z "\$EXPECT_COUNT" ||
72
+ test "\$EXPECT_COUNT" = \$(grep -ve "^#" -e "^$" < "\$1" | wc -l) ||
73
+ exit
74
test -z "\$FAKE_LINES" && exit
75
grep -v "^#" < "\$1" > "\$1".tmp
76
rm "\$1"
@@ -251,4 +254,16 @@ test_expect_success 'interrupted squash works as expected' '
254
test $one = $(git rev-parse HEAD~2)
255
'
256
257
+test_expect_success 'ignore patch if in upstream' '
258
+ HEAD=$(git rev-parse HEAD) &&
259
+ git checkout -b has-cherry-picked HEAD^ &&
260
+ echo unrelated > file7 &&
261
+ git add file7 &&
262
+ test_tick &&
263
+ git commit -m "unrelated change" &&
264
+ git cherry-pick $HEAD &&
265
+ EXPECT_COUNT=1 git rebase -i $HEAD &&
266
+ test $HEAD = $(git rev-parse HEAD^)
267
+'
268
+
269
test_done