-
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.
Make sure that resolving a failed merge with git add records the conflicted state, committing the result keeps that state, and checking out another commit clears the state. "git ls-files" learns a new option --resolve-undo to show the recorded information. Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Junio C Hamano
committed
Dec 26, 2009
1 parent
cfc5789
commit 9d9a2f4
Showing
2 changed files
with
130 additions
and
1 deletion.
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,88 @@ | ||
#!/bin/sh | ||
|
||
test_description='undoing resolution' | ||
|
||
. ./test-lib.sh | ||
|
||
check_resolve_undo () { | ||
msg=$1 | ||
shift | ||
while case $# in | ||
0) break ;; | ||
1|2|3) die "Bug in check-resolve-undo test" ;; | ||
esac | ||
do | ||
path=$1 | ||
shift | ||
for stage in 1 2 3 | ||
do | ||
sha1=$1 | ||
shift | ||
case "$sha1" in | ||
'') continue ;; | ||
esac | ||
sha1=$(git rev-parse --verify "$sha1") | ||
printf "100644 %s %s\t%s\n" $sha1 $stage $path | ||
done | ||
done >"$msg.expect" && | ||
git ls-files --resolve-undo >"$msg.actual" && | ||
test_cmp "$msg.expect" "$msg.actual" | ||
} | ||
|
||
prime_resolve_undo () { | ||
git reset --hard && | ||
git checkout second^0 && | ||
test_tick && | ||
test_must_fail git merge third^0 && | ||
echo merge does not leave anything && | ||
check_resolve_undo empty && | ||
echo different >file && | ||
git add file && | ||
echo resolving records && | ||
check_resolve_undo recorded file initial:file second:file third:file | ||
} | ||
|
||
test_expect_success setup ' | ||
test_commit initial file first && | ||
git branch side && | ||
git branch another && | ||
test_commit second file second && | ||
git checkout side && | ||
test_commit third file third && | ||
git checkout another && | ||
test_commit fourth file fourth && | ||
git checkout master | ||
' | ||
|
||
test_expect_success 'add records switch clears' ' | ||
prime_resolve_undo && | ||
test_tick && | ||
git commit -m merged && | ||
echo committing keeps && | ||
check_resolve_undo kept file initial:file second:file third:file && | ||
git checkout second^0 && | ||
echo switching clears && | ||
check_resolve_undo cleared | ||
' | ||
|
||
test_expect_success 'rm records reset clears' ' | ||
prime_resolve_undo && | ||
test_tick && | ||
git commit -m merged && | ||
echo committing keeps && | ||
check_resolve_undo kept file initial:file second:file third:file && | ||
echo merge clears upfront && | ||
test_must_fail git merge fourth^0 && | ||
check_resolve_undo nuked && | ||
git rm -f file && | ||
echo resolving records && | ||
check_resolve_undo recorded file initial:file HEAD:file fourth:file && | ||
git reset --hard && | ||
echo resetting discards && | ||
check_resolve_undo discarded | ||
' | ||
|
||
test_done |