-
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.
merge-recursive: honor diff.algorithm
The documentation claims that "recursive defaults to the diff.algorithm config setting", but this is currently not the case. This fixes it, ensuring that diff.algorithm is used when -Xdiff-algorithm is not supplied. This affects the following porcelain commands: "merge", "rebase", "cherry-pick", "pull", "stash", "log", "am" and "checkout". It also affects the "merge-tree" ancillary interrogator. This change refactors the initialization of merge options to introduce two functions, "init_merge_ui_options" and "init_merge_basic_options" instead of just one "init_merge_options". This design follows the approach used in diff.c, providing initialization methods for porcelain and plumbing commands respectively. Thanks to that, the "replay" and "merge-recursive" plumbing commands remain unaffected by diff.algorithm. Signed-off-by: Antonin Delpeuch <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
- Loading branch information
Showing
15 changed files
with
150 additions
and
15 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
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
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
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
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
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,60 @@ | ||
#!/bin/sh | ||
|
||
test_description='git merge and other operations that rely on merge | ||
Testing the influence of the diff algorithm on the merge output.' | ||
|
||
TEST_PASSES_SANITIZE_LEAK=true | ||
. ./test-lib.sh | ||
|
||
test_expect_success 'setup' ' | ||
cp "$TEST_DIRECTORY"/t7615/base.c file.c && | ||
git add file.c && | ||
git commit -m c0 && | ||
git tag c0 && | ||
cp "$TEST_DIRECTORY"/t7615/ours.c file.c && | ||
git add file.c && | ||
git commit -m c1 && | ||
git tag c1 && | ||
git reset --hard c0 && | ||
cp "$TEST_DIRECTORY"/t7615/theirs.c file.c && | ||
git add file.c && | ||
git commit -m c2 && | ||
git tag c2 | ||
' | ||
|
||
GIT_TEST_MERGE_ALGORITHM=recursive | ||
|
||
test_expect_success 'merge c2 to c1 with recursive merge strategy fails with the current default myers diff algorithm' ' | ||
git reset --hard c1 && | ||
test_must_fail git merge -s recursive c2 | ||
' | ||
|
||
test_expect_success 'merge c2 to c1 with recursive merge strategy succeeds with -Xdiff-algorithm=histogram' ' | ||
git reset --hard c1 && | ||
git merge --strategy recursive -Xdiff-algorithm=histogram c2 | ||
' | ||
|
||
test_expect_success 'merge c2 to c1 with recursive merge strategy succeeds with diff.algorithm = histogram' ' | ||
git reset --hard c1 && | ||
git config diff.algorithm histogram && | ||
git merge --strategy recursive c2 | ||
' | ||
|
||
test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy fails with the current default myers diff algorithm' ' | ||
git reset --hard c1 && | ||
test_must_fail git cherry-pick -s recursive c2 | ||
' | ||
|
||
test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy succeeds with -Xdiff-algorithm=histogram' ' | ||
git reset --hard c1 && | ||
git cherry-pick --strategy recursive -Xdiff-algorithm=histogram c2 | ||
' | ||
|
||
test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy succeeds with diff.algorithm = histogram' ' | ||
git reset --hard c1 && | ||
git config diff.algorithm histogram && | ||
git cherry-pick --strategy recursive c2 | ||
' | ||
|
||
test_done |
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,17 @@ | ||
int f(int x, int y) | ||
{ | ||
if (x == 0) | ||
{ | ||
return y; | ||
} | ||
return x; | ||
} | ||
|
||
int g(size_t u) | ||
{ | ||
while (u < 30) | ||
{ | ||
u++; | ||
} | ||
return u; | ||
} |
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,17 @@ | ||
int g(size_t u) | ||
{ | ||
while (u < 30) | ||
{ | ||
u++; | ||
} | ||
return u; | ||
} | ||
|
||
int h(int x, int y, int z) | ||
{ | ||
if (z == 0) | ||
{ | ||
return x; | ||
} | ||
return y; | ||
} |
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,17 @@ | ||
int f(int x, int y) | ||
{ | ||
if (x == 0) | ||
{ | ||
return y; | ||
} | ||
return x; | ||
} | ||
|
||
int g(size_t u) | ||
{ | ||
while (u > 34) | ||
{ | ||
u--; | ||
} | ||
return u; | ||
} |