-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert: Save data for continuing after conflict resolution
Ever since v1.7.2-rc1~4^2~7 (revert: allow cherry-picking more than one commit, 2010-06-02), a single invocation of "git cherry-pick" or "git revert" can perform picks of several individual commits. To implement features like "--continue" to continue the whole operation, we will need to store some information about the state and the plan at the beginning. Introduce a ".git/sequencer/head" file to store this state, and ".git/sequencer/todo" file to store the plan. The head file contains the SHA-1 of the HEAD before the start of the operation, and the todo file contains an instruction sheet whose format is inspired by the format of the "rebase -i" instruction sheet. As a result, a typical todo file looks like: pick 8537f0e submodule add: test failure when url is not configured pick 4d68932 submodule add: allow relative repository path pick f22a17e submodule add: clean up duplicated code pick 59a5775 make copy_ref globally available Since SHA-1 hex is abbreviated using an find_unique_abbrev(), it is unambiguous. This does not guarantee that there will be no ambiguity when more objects are added to the repository. These two files alone are not enough to implement a "--continue" that remembers the command-line options specified; later patches in the series save them too. These new files are unrelated to the existing .git/CHERRY_PICK_HEAD, which will still be useful while committing after a conflict resolution. Inspired-by: Christian Couder <chriscool@tuxfamily.org> Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Ramkumar Ramachandra
authored and
Junio C Hamano
committed
Aug 4, 2011
1 parent
9044143
commit 04d3d3c
Showing
2 changed files
with
178 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/sh | ||
|
||
test_description='Test cherry-pick continuation features | ||
+ anotherpick: rewrites foo to d | ||
+ picked: rewrites foo to c | ||
+ unrelatedpick: rewrites unrelated to reallyunrelated | ||
+ base: rewrites foo to b | ||
+ initial: writes foo as a, unrelated as unrelated | ||
' | ||
|
||
. ./test-lib.sh | ||
|
||
pristine_detach () { | ||
rm -rf .git/sequencer && | ||
git checkout -f "$1^0" && | ||
git read-tree -u --reset HEAD && | ||
git clean -d -f -f -q -x | ||
} | ||
|
||
test_expect_success setup ' | ||
echo unrelated >unrelated && | ||
git add unrelated && | ||
test_commit initial foo a && | ||
test_commit base foo b && | ||
test_commit unrelatedpick unrelated reallyunrelated && | ||
test_commit picked foo c && | ||
test_commit anotherpick foo d && | ||
git config advice.detachedhead false | ||
' | ||
|
||
test_expect_success 'cherry-pick persists data on failure' ' | ||
pristine_detach initial && | ||
test_must_fail git cherry-pick base..anotherpick && | ||
test_path_is_dir .git/sequencer && | ||
test_path_is_file .git/sequencer/head && | ||
test_path_is_file .git/sequencer/todo | ||
' | ||
|
||
test_expect_success 'cherry-pick cleans up sequencer state upon success' ' | ||
pristine_detach initial && | ||
git cherry-pick initial..picked && | ||
test_path_is_missing .git/sequencer | ||
' | ||
|
||
test_done |