--- git-rebase--interactive.sh | 20 ++++++++++++++++++++ t/t3404-rebase-interactive.sh | 10 ++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index b001ddf..7dac51b 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -258,6 +258,16 @@ parse_mark() { return 1 } +mark_to_sha1() { + local mark + if mark=$(parse_mark $1) + then + cat "$MARKS"/$mark + else + return 1 + fi +} + do_next () { rm -f "$DOTEST"/message "$DOTEST"/author-script \ "$DOTEST"/amend || exit @@ -352,6 +362,15 @@ do_next () { git rev-parse --verify HEAD > "$MARKS"/$mark || \ die "HEAD is invalid" ;; + reset|r) + comment_for_reflog reset + + mark_action_done + tmp=$(mark_to_sha1 $sha1) || \ + tmp=$(git rev-parse --verify $sha1) || + die "Invalid parent '$sha1' in $command $sha1 $rest" + output git reset --hard $tmp + ;; *) warn "Unknown command: $command $sha1 $rest" die_with_patch $sha1 "Please fix this in the file $TODO." @@ -569,6 +588,7 @@ do # edit = use commit, but stop for amending # squash = use commit, but meld into previous commit # mark #NUM = mark the current HEAD for later reference +# reset #NUM|commit = reset HEAD to a previous set mark or a commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 4461674..521206f 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -85,6 +85,9 @@ for line in $FAKE_LINES; do mark*) echo "mark ${line#mark}" echo "mark ${line#mark}" >> "$1";; + reset*) + echo "reset ${line#reset}" + echo "reset ${line#reset}" >> "$1";; *) echo sed -n "${line}s/^pick/$action/p" sed -n "${line}p" < "$1".tmp @@ -210,6 +213,13 @@ test_expect_success 'setting marks works' ' git rebase --abort ' +test_expect_success 'reset with nonexistent mark fails' ' + export FAKE_LINES="reset#0 1" && + test_must_fail git rebase -i HEAD~1 && + unset FAKE_LINES && + git rebase --abort +' + test_expect_success 'preserve merges with -p' ' git checkout -b to-be-preserved master^ && : > unrelated-file && -- 1.5.4.5 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html