Skip to content

Commit

Permalink
rebase -i: do not fail when there is no commit to cherry-pick
Browse files Browse the repository at this point in the history
In case there is no commit to apply (for example because you rebase to
upstream and all your local patches have been applied there), do not
fail.  The non-interactive rebase already behaves that way.

Do this by introducing a new command, "noop", which is substituted for
an empty commit list, so that deleting the commit list can still abort
as before.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Johannes Schindelin authored and Shawn O. Pearce committed Oct 10, 2008
1 parent b8eecaf commit ff74126
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ do_next () {
"$DOTEST"/amend || exit
read command sha1 rest < "$TODO"
case "$command" in
'#'*|'')
'#'*|''|noop)
mark_action_done
;;
pick|p)
Expand Down Expand Up @@ -584,6 +584,7 @@ first and then run 'git rebase --continue' again."
--abbrev=7 --reverse --left-right --cherry-pick \
$UPSTREAM...$HEAD | \
sed -n "s/^>/pick /p" > "$TODO"
test -s "$TODO" || echo noop >> "$TODO"
cat >> "$TODO" << EOF
# Rebase $SHORTUPSTREAM..$SHORTHEAD onto $SHORTONTO
Expand Down
11 changes: 11 additions & 0 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,15 @@ test_expect_success 'rebase with a file named HEAD in worktree' '
'

test_expect_success 'do "noop" when there is nothing to cherry-pick' '
git checkout -b branch4 HEAD &&
GIT_EDITOR=: git commit --amend \
--author="Somebody else <somebody@else.com>"
test $(git rev-parse branch3) != $(git rev-parse branch4) &&
git rebase -i branch3 &&
test $(git rev-parse branch3) = $(git rev-parse branch4)
'

test_done

0 comments on commit ff74126

Please sign in to comment.