Merge branch 'en/merge-recursive-directory-rename-fixes'

When all files from some subdirectory were renamed to the root
directory, the directory rename heuristics would fail to detect that
as a rename/merge of the subdirectory to the root directory, which has
been corrected.

* en/merge-recursive-directory-rename-fixes:
  t604[236]: do not run setup in separate tests
  merge-recursive: fix merging a subdirectory into the root directory
  merge-recursive: clean up get_renamed_dir_portion()
This commit is contained in:
Junio C Hamano 2019-11-10 18:02:13 +09:00
commit d9800351d3
4 changed files with 584 additions and 338 deletions

View File

@ -1951,6 +1951,16 @@ static char *apply_dir_rename(struct dir_rename_entry *entry,
return NULL;
oldlen = strlen(entry->dir);
if (entry->new_dir.len == 0)
/*
* If someone renamed/merged a subdirectory into the root
* directory (e.g. 'some/subdir' -> ''), then we want to
* avoid returning
* '' + '/filename'
* as the rename; we need to make old_path + oldlen advance
* past the '/' character.
*/
oldlen++;
newlen = entry->new_dir.len + (strlen(old_path) - oldlen) + 1;
strbuf_grow(&new_path, newlen);
strbuf_addbuf(&new_path, &entry->new_dir);
@ -1963,8 +1973,8 @@ static void get_renamed_dir_portion(const char *old_path, const char *new_path,
char **old_dir, char **new_dir)
{
char *end_of_old, *end_of_new;
int old_len, new_len;
/* Default return values: NULL, meaning no rename */
*old_dir = NULL;
*new_dir = NULL;
@ -1975,43 +1985,91 @@ static void get_renamed_dir_portion(const char *old_path, const char *new_path,
* "a/b/c/d" was renamed to "a/b/some/thing/else"
* so, for this example, this function returns "a/b/c/d" in
* *old_dir and "a/b/some/thing/else" in *new_dir.
*
* Also, if the basename of the file changed, we don't care. We
* want to know which portion of the directory, if any, changed.
*/
/*
* If the basename of the file changed, we don't care. We want
* to know which portion of the directory, if any, changed.
*/
end_of_old = strrchr(old_path, '/');
end_of_new = strrchr(new_path, '/');
if (end_of_old == NULL || end_of_new == NULL)
/*
* If end_of_old is NULL, old_path wasn't in a directory, so there
* could not be a directory rename (our rule elsewhere that a
* directory which still exists is not considered to have been
* renamed means the root directory can never be renamed -- because
* the root directory always exists).
*/
if (end_of_old == NULL)
return; /* Note: *old_dir and *new_dir are still NULL */
/*
* If new_path contains no directory (end_of_new is NULL), then we
* have a rename of old_path's directory to the root directory.
*/
if (end_of_new == NULL) {
*old_dir = xstrndup(old_path, end_of_old - old_path);
*new_dir = xstrdup("");
return;
}
/* Find the first non-matching character traversing backwards */
while (*--end_of_new == *--end_of_old &&
end_of_old != old_path &&
end_of_new != new_path)
; /* Do nothing; all in the while loop */
/*
* If both got back to the beginning of their strings, then the
* directory didn't change at all, only the basename did.
*/
if (end_of_old == old_path && end_of_new == new_path &&
*end_of_old == *end_of_new)
return; /* Note: *old_dir and *new_dir are still NULL */
/*
* If end_of_new got back to the beginning of its string, and
* end_of_old got back to the beginning of some subdirectory, then
* we have a rename/merge of a subdirectory into the root, which
* needs slightly special handling.
*
* Note: There is no need to consider the opposite case, with a
* rename/merge of the root directory into some subdirectory
* because as noted above the root directory always exists so it
* cannot be considered to be renamed.
*/
if (end_of_new == new_path &&
end_of_old != old_path && end_of_old[-1] == '/') {
*old_dir = xstrndup(old_path, --end_of_old - old_path);
*new_dir = xstrdup("");
return;
}
/*
* We've found the first non-matching character in the directory
* paths. That means the current directory we were comparing
* represents the rename. Move end_of_old and end_of_new back
* to the full directory name.
* paths. That means the current characters we were looking at
* were part of the first non-matching subdir name going back from
* the end of the strings. Get the whole name by advancing both
* end_of_old and end_of_new to the NEXT '/' character. That will
* represent the entire directory rename.
*
* The reason for the increment is cases like
* a/b/star/foo/whatever.c -> a/b/tar/foo/random.c
* After dropping the basename and going back to the first
* non-matching character, we're now comparing:
* a/b/s and a/b/
* and we want to be comparing:
* a/b/star/ and a/b/tar/
* but without the pre-increment, the one on the right would stay
* a/b/.
*/
if (*end_of_old == '/')
end_of_old++;
if (*end_of_old != '/')
end_of_new++;
end_of_old = strchr(end_of_old, '/');
end_of_new = strchr(end_of_new, '/');
end_of_old = strchr(++end_of_old, '/');
end_of_new = strchr(++end_of_new, '/');
/*
* It may have been the case that old_path and new_path were the same
* directory all along. Don't claim a rename if they're the same.
*/
old_len = end_of_old - old_path;
new_len = end_of_new - new_path;
if (old_len != new_len || strncmp(old_path, new_path, old_len)) {
*old_dir = xstrndup(old_path, old_len);
*new_dir = xstrndup(new_path, new_len);
}
/* Copy the old and new directories into *old_dir and *new_dir. */
*old_dir = xstrndup(old_path, end_of_old - old_path);
*new_dir = xstrndup(new_path, end_of_new - new_path);
}
static void remove_hashmap_entries(struct hashmap *dir_renames,

View File

@ -5,7 +5,7 @@ test_description="recursive merge corner cases w/ renames but not criss-crosses"
. ./test-lib.sh
test_expect_success 'setup rename/delete + untracked file' '
test_setup_rename_delete_untracked () {
test_create_repo rename-delete-untracked &&
(
cd rename-delete-untracked &&
@ -29,9 +29,10 @@ test_expect_success 'setup rename/delete + untracked file' '
git commit -m track-people-instead-of-objects &&
echo "Myyy PRECIOUSSS" >ring
)
'
}
test_expect_success "Does git preserve Gollum's precious artifact?" '
test_setup_rename_delete_untracked &&
(
cd rename-delete-untracked &&
@ -49,7 +50,7 @@ test_expect_success "Does git preserve Gollum's precious artifact?" '
#
# We should be able to merge B & C cleanly
test_expect_success 'setup rename/modify/add-source conflict' '
test_setup_rename_modify_add_source () {
test_create_repo rename-modify-add-source &&
(
cd rename-modify-add-source &&
@ -70,9 +71,10 @@ test_expect_success 'setup rename/modify/add-source conflict' '
git add a &&
git commit -m C
)
'
}
test_expect_failure 'rename/modify/add-source conflict resolvable' '
test_setup_rename_modify_add_source &&
(
cd rename-modify-add-source &&
@ -88,7 +90,7 @@ test_expect_failure 'rename/modify/add-source conflict resolvable' '
)
'
test_expect_success 'setup resolvable conflict missed if rename missed' '
test_setup_break_detection_1 () {
test_create_repo break-detection-1 &&
(
cd break-detection-1 &&
@ -110,9 +112,10 @@ test_expect_success 'setup resolvable conflict missed if rename missed' '
git add a &&
git commit -m C
)
'
}
test_expect_failure 'conflict caused if rename not detected' '
test_setup_break_detection_1 &&
(
cd break-detection-1 &&
@ -135,7 +138,7 @@ test_expect_failure 'conflict caused if rename not detected' '
)
'
test_expect_success 'setup conflict resolved wrong if rename missed' '
test_setup_break_detection_2 () {
test_create_repo break-detection-2 &&
(
cd break-detection-2 &&
@ -160,9 +163,10 @@ test_expect_success 'setup conflict resolved wrong if rename missed' '
git add a &&
git commit -m E
)
'
}
test_expect_failure 'missed conflict if rename not detected' '
test_setup_break_detection_2 &&
(
cd break-detection-2 &&
@ -182,7 +186,7 @@ test_expect_failure 'missed conflict if rename not detected' '
# Commit B: rename a->b
# Commit C: rename a->b, add unrelated a
test_expect_success 'setup undetected rename/add-source causes data loss' '
test_setup_break_detection_3 () {
test_create_repo break-detection-3 &&
(
cd break-detection-3 &&
@ -202,9 +206,10 @@ test_expect_success 'setup undetected rename/add-source causes data loss' '
git add a &&
git commit -m C
)
'
}
test_expect_failure 'detect rename/add-source and preserve all data' '
test_setup_break_detection_3 &&
(
cd break-detection-3 &&
@ -231,6 +236,7 @@ test_expect_failure 'detect rename/add-source and preserve all data' '
'
test_expect_failure 'detect rename/add-source and preserve all data, merge other way' '
test_setup_break_detection_3 &&
(
cd break-detection-3 &&
@ -256,10 +262,10 @@ test_expect_failure 'detect rename/add-source and preserve all data, merge other
)
'
test_expect_success 'setup content merge + rename/directory conflict' '
test_create_repo rename-directory-1 &&
test_setup_rename_directory () {
test_create_repo rename-directory-$1 &&
(
cd rename-directory-1 &&
cd rename-directory-$1 &&
printf "1\n2\n3\n4\n5\n6\n" >file &&
git add file &&
@ -290,11 +296,12 @@ test_expect_success 'setup content merge + rename/directory conflict' '
test_tick &&
git commit -m left
)
'
}
test_expect_success 'rename/directory conflict + clean content merge' '
test_setup_rename_directory 1a &&
(
cd rename-directory-1 &&
cd rename-directory-1a &&
git checkout left-clean^0 &&
@ -320,8 +327,9 @@ test_expect_success 'rename/directory conflict + clean content merge' '
'
test_expect_success 'rename/directory conflict + content merge conflict' '
test_setup_rename_directory 1b &&
(
cd rename-directory-1 &&
cd rename-directory-1b &&
git reset --hard &&
git clean -fdqx &&
@ -358,7 +366,7 @@ test_expect_success 'rename/directory conflict + content merge conflict' '
)
'
test_expect_success 'setup content merge + rename/directory conflict w/ disappearing dir' '
test_setup_rename_directory_2 () {
test_create_repo rename-directory-2 &&
(
cd rename-directory-2 &&
@ -385,9 +393,10 @@ test_expect_success 'setup content merge + rename/directory conflict w/ disappea
test_tick &&
git commit -m left
)
'
}
test_expect_success 'disappearing dir in rename/directory conflict handled' '
test_setup_rename_directory_2 &&
(
cd rename-directory-2 &&
@ -416,10 +425,10 @@ test_expect_success 'disappearing dir in rename/directory conflict handled' '
# Commit A: rename a->b, modifying b too
# Commit B: modify a, add different b
test_expect_success 'setup rename-with-content-merge vs. add' '
test_create_repo rename-with-content-merge-and-add &&
test_setup_rename_with_content_merge_and_add () {
test_create_repo rename-with-content-merge-and-add-$1 &&
(
cd rename-with-content-merge-and-add &&
cd rename-with-content-merge-and-add-$1 &&
test_seq 1 5 >a &&
git add a &&
@ -438,11 +447,12 @@ test_expect_success 'setup rename-with-content-merge vs. add' '
git add a b &&
git commit -m B
)
'
}
test_expect_success 'handle rename-with-content-merge vs. add' '
test_setup_rename_with_content_merge_and_add AB &&
(
cd rename-with-content-merge-and-add &&
cd rename-with-content-merge-and-add-AB &&
git checkout A^0 &&
@ -483,8 +493,9 @@ test_expect_success 'handle rename-with-content-merge vs. add' '
'
test_expect_success 'handle rename-with-content-merge vs. add, merge other way' '
test_setup_rename_with_content_merge_and_add BA &&
(
cd rename-with-content-merge-and-add &&
cd rename-with-content-merge-and-add-BA &&
git reset --hard &&
git clean -fdx &&
@ -539,7 +550,7 @@ test_expect_success 'handle rename-with-content-merge vs. add, merge other way'
# * The working copy should have two files, both of form c~<unique>; does it?
# * Nothing else should be present. Is anything?
test_expect_success 'setup rename/rename (2to1) + modify/modify' '
test_setup_rename_rename_2to1 () {
test_create_repo rename-rename-2to1 &&
(
cd rename-rename-2to1 &&
@ -562,9 +573,10 @@ test_expect_success 'setup rename/rename (2to1) + modify/modify' '
git add a &&
git commit -m C
)
'
}
test_expect_success 'handle rename/rename (2to1) conflict correctly' '
test_setup_rename_rename_2to1 &&
(
cd rename-rename-2to1 &&
@ -610,7 +622,7 @@ test_expect_success 'handle rename/rename (2to1) conflict correctly' '
# Commit A: new file: a
# Commit B: rename a->b
# Commit C: rename a->c
test_expect_success 'setup simple rename/rename (1to2) conflict' '
test_setup_rename_rename_1to2 () {
test_create_repo rename-rename-1to2 &&
(
cd rename-rename-1to2 &&
@ -631,9 +643,10 @@ test_expect_success 'setup simple rename/rename (1to2) conflict' '
test_tick &&
git commit -m C
)
'
}
test_expect_success 'merge has correct working tree contents' '
test_setup_rename_rename_1to2 &&
(
cd rename-rename-1to2 &&
@ -667,7 +680,7 @@ test_expect_success 'merge has correct working tree contents' '
#
# Merging of B & C should NOT be clean; there's a rename/rename conflict
test_expect_success 'setup rename/rename(1to2)/add-source conflict' '
test_setup_rename_rename_1to2_add_source_1 () {
test_create_repo rename-rename-1to2-add-source-1 &&
(
cd rename-rename-1to2-add-source-1 &&
@ -687,9 +700,10 @@ test_expect_success 'setup rename/rename(1to2)/add-source conflict' '
git add a &&
git commit -m C
)
'
}
test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge' '
test_setup_rename_rename_1to2_add_source_1 &&
(
cd rename-rename-1to2-add-source-1 &&
@ -714,7 +728,7 @@ test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge'
)
'
test_expect_success 'setup rename/rename(1to2)/add-source resolvable conflict' '
test_setup_rename_rename_1to2_add_source_2 () {
test_create_repo rename-rename-1to2-add-source-2 &&
(
cd rename-rename-1to2-add-source-2 &&
@ -737,9 +751,10 @@ test_expect_success 'setup rename/rename(1to2)/add-source resolvable conflict' '
test_tick &&
git commit -m two
)
'
}
test_expect_failure 'rename/rename/add-source still tracks new a file' '
test_setup_rename_rename_1to2_add_source_2 &&
(
cd rename-rename-1to2-add-source-2 &&
@ -759,7 +774,7 @@ test_expect_failure 'rename/rename/add-source still tracks new a file' '
)
'
test_expect_success 'setup rename/rename(1to2)/add-dest conflict' '
test_setup_rename_rename_1to2_add_dest () {
test_create_repo rename-rename-1to2-add-dest &&
(
cd rename-rename-1to2-add-dest &&
@ -784,9 +799,10 @@ test_expect_success 'setup rename/rename(1to2)/add-dest conflict' '
test_tick &&
git commit -m two
)
'
}
test_expect_success 'rename/rename/add-dest merge still knows about conflicting file versions' '
test_setup_rename_rename_1to2_add_dest &&
(
cd rename-rename-1to2-add-dest &&
@ -838,7 +854,7 @@ test_expect_success 'rename/rename/add-dest merge still knows about conflicting
# Commit B: rename foo->bar
# Expected: CONFLICT (rename/add/delete), two-way merged bar
test_expect_success 'rad-setup: rename/add/delete conflict' '
test_setup_rad () {
test_create_repo rad &&
(
cd rad &&
@ -860,9 +876,10 @@ test_expect_success 'rad-setup: rename/add/delete conflict' '
git mv foo bar &&
git commit -m "rename foo to bar"
)
'
}
test_expect_failure 'rad-check: rename/add/delete conflict' '
test_setup_rad &&
(
cd rad &&
@ -904,7 +921,7 @@ test_expect_failure 'rad-check: rename/add/delete conflict' '
# Commit B: rename bar->baz, rm foo
# Expected: CONFLICT (rename/rename/delete/delete), two-way merged baz
test_expect_success 'rrdd-setup: rename/rename(2to1)/delete/delete conflict' '
test_setup_rrdd () {
test_create_repo rrdd &&
(
cd rrdd &&
@ -927,9 +944,10 @@ test_expect_success 'rrdd-setup: rename/rename(2to1)/delete/delete conflict' '
git rm foo &&
git commit -m "Rename bar, remove foo"
)
'
}
test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
test_setup_rrdd &&
(
cd rrdd &&
@ -973,7 +991,7 @@ test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
# Expected: six CONFLICT(rename/rename) messages, each path in two of the
# multi-way merged contents found in two, four, six
test_expect_success 'mod6-setup: chains of rename/rename(1to2) and rename/rename(2to1)' '
test_setup_mod6 () {
test_create_repo mod6 &&
(
cd mod6 &&
@ -1009,9 +1027,10 @@ test_expect_success 'mod6-setup: chains of rename/rename(1to2) and rename/rename
test_tick &&
git commit -m "B"
)
'
}
test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename(2to1)' '
test_setup_mod6 &&
(
cd mod6 &&
@ -1108,7 +1127,8 @@ test_conflicts_with_adds_and_renames() {
# files. Is it present?
# 4) There should not be any three~* files in the working
# tree
test_expect_success "setup simple $sideL/$sideR conflict" '
test_setup_collision_conflict () {
#test_expect_success "setup simple $sideL/$sideR conflict" '
test_create_repo simple_${sideL}_${sideR} &&
(
cd simple_${sideL}_${sideR} &&
@ -1185,9 +1205,11 @@ test_conflicts_with_adds_and_renames() {
fi &&
test_tick && git commit -m R
)
'
#'
}
test_expect_success "check simple $sideL/$sideR conflict" '
test_setup_collision_conflict &&
(
cd simple_${sideL}_${sideR} &&
@ -1254,7 +1276,7 @@ test_conflicts_with_adds_and_renames add add
#
# So, we have four different conflicting files that all end up at path
# 'three'.
test_expect_success 'setup nested conflicts from rename/rename(2to1)' '
test_setup_nested_conflicts_from_rename_rename () {
test_create_repo nested_conflicts_from_rename_rename &&
(
cd nested_conflicts_from_rename_rename &&
@ -1305,9 +1327,10 @@ test_expect_success 'setup nested conflicts from rename/rename(2to1)' '
git add one three &&
test_tick && git commit -m german
)
'
}
test_expect_success 'check nested conflicts from rename/rename(2to1)' '
test_setup_nested_conflicts_from_rename_rename &&
(
cd nested_conflicts_from_rename_rename &&

File diff suppressed because it is too large Load Diff

View File

@ -36,10 +36,10 @@ test_description="merge cases"
# Commit B: b_3
# Expected: b_2
test_expect_success '1a-setup: Modify(A)/Modify(B), change on B subset of A' '
test_create_repo 1a &&
test_setup_1a () {
test_create_repo 1a_$1 &&
(
cd 1a &&
cd 1a_$1 &&
test_write_lines 1 2 3 4 5 6 7 8 9 10 >b &&
git add b &&
@ -62,13 +62,12 @@ test_expect_success '1a-setup: Modify(A)/Modify(B), change on B subset of A' '
test_tick &&
git commit -m "B"
)
'
}
test_expect_success '1a-check-L: Modify(A)/Modify(B), change on B subset of A' '
test_when_finished "git -C 1a reset --hard" &&
test_when_finished "git -C 1a clean -fd" &&
test_expect_success '1a-L: Modify(A)/Modify(B), change on B subset of A' '
test_setup_1a L &&
(
cd 1a &&
cd 1a_L &&
git checkout A^0 &&
@ -96,11 +95,10 @@ test_expect_success '1a-check-L: Modify(A)/Modify(B), change on B subset of A' '
)
'
test_expect_success '1a-check-R: Modify(A)/Modify(B), change on B subset of A' '
test_when_finished "git -C 1a reset --hard" &&
test_when_finished "git -C 1a clean -fd" &&
test_expect_success '1a-R: Modify(A)/Modify(B), change on B subset of A' '
test_setup_1a R &&
(
cd 1a &&
cd 1a_R &&
git checkout B^0 &&
@ -133,10 +131,10 @@ test_expect_success '1a-check-R: Modify(A)/Modify(B), change on B subset of A' '
# Commit B: c_1
# Expected: c_2
test_expect_success '2a-setup: Modify(A)/rename(B)' '
test_create_repo 2a &&
test_setup_2a () {
test_create_repo 2a_$1 &&
(
cd 2a &&
cd 2a_$1 &&
test_seq 1 10 >b &&
git add b &&
@ -158,13 +156,12 @@ test_expect_success '2a-setup: Modify(A)/rename(B)' '
test_tick &&
git commit -m "B"
)
'
}
test_expect_success '2a-check-L: Modify/rename, merge into modify side' '
test_when_finished "git -C 2a reset --hard" &&
test_when_finished "git -C 2a clean -fd" &&
test_expect_success '2a-L: Modify/rename, merge into modify side' '
test_setup_2a L &&
(
cd 2a &&
cd 2a_L &&
git checkout A^0 &&
@ -189,11 +186,10 @@ test_expect_success '2a-check-L: Modify/rename, merge into modify side' '
)
'
test_expect_success '2a-check-R: Modify/rename, merge into rename side' '
test_when_finished "git -C 2a reset --hard" &&
test_when_finished "git -C 2a clean -fd" &&
test_expect_success '2a-R: Modify/rename, merge into rename side' '
test_setup_2a R &&
(
cd 2a &&
cd 2a_R &&
git checkout B^0 &&
@ -224,10 +220,10 @@ test_expect_success '2a-check-R: Modify/rename, merge into rename side' '
# Commit B: b_3
# Expected: c_2
test_expect_success '2b-setup: Rename+Mod(A)/Mod(B), B mods subset of A' '
test_create_repo 2b &&
test_setup_2b () {
test_create_repo 2b_$1 &&
(
cd 2b &&
cd 2b_$1 &&
test_write_lines 1 2 3 4 5 6 7 8 9 10 >b &&
git add b &&
@ -251,13 +247,12 @@ test_expect_success '2b-setup: Rename+Mod(A)/Mod(B), B mods subset of A' '
test_tick &&
git commit -m "B"
)
'
}
test_expect_success '2b-check-L: Rename+Mod(A)/Mod(B), B mods subset of A' '
test_when_finished "git -C 2b reset --hard" &&
test_when_finished "git -C 2b clean -fd" &&
test_expect_success '2b-L: Rename+Mod(A)/Mod(B), B mods subset of A' '
test_setup_2b L &&
(
cd 2b &&
cd 2b_L &&
git checkout A^0 &&
@ -288,11 +283,10 @@ test_expect_success '2b-check-L: Rename+Mod(A)/Mod(B), B mods subset of A' '
)
'
test_expect_success '2b-check-R: Rename+Mod(A)/Mod(B), B mods subset of A' '
test_when_finished "git -C 2b reset --hard" &&
test_when_finished "git -C 2b clean -fd" &&
test_expect_success '2b-R: Rename+Mod(A)/Mod(B), B mods subset of A' '
test_setup_2b R &&
(
cd 2b &&
cd 2b_R &&
git checkout B^0 &&
@ -332,7 +326,7 @@ test_expect_success '2b-check-R: Rename+Mod(A)/Mod(B), B mods subset of A' '
# skip the update, then we're in trouble. This test verifies we do
# not make that particular mistake.
test_expect_success '2c-setup: Modify b & add c VS rename b->c' '
test_setup_2c () {
test_create_repo 2c &&
(
cd 2c &&
@ -358,9 +352,10 @@ test_expect_success '2c-setup: Modify b & add c VS rename b->c' '
test_tick &&
git commit -m "B"
)
'
}
test_expect_success '2c-check: Modify b & add c VS rename b->c' '
test_expect_success '2c: Modify b & add c VS rename b->c' '
test_setup_2c &&
(
cd 2c &&
@ -428,10 +423,10 @@ test_expect_success '2c-check: Modify b & add c VS rename b->c' '
# Commit B: bq_1, bar/whatever
# Expected: bar/{bq_2, whatever}
test_expect_success '3a-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_create_repo 3a &&
test_setup_3a () {
test_create_repo 3a_$1 &&
(
cd 3a &&
cd 3a_$1 &&
mkdir foo &&
test_seq 1 10 >bq &&
@ -456,13 +451,12 @@ test_expect_success '3a-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_tick &&
git commit -m "B"
)
'
}
test_expect_success '3a-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_when_finished "git -C 3a reset --hard" &&
test_when_finished "git -C 3a clean -fd" &&
test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_setup_3a L &&
(
cd 3a &&
cd 3a_L &&
git checkout A^0 &&
@ -487,11 +481,10 @@ test_expect_success '3a-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
)
'
test_expect_success '3a-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_when_finished "git -C 3a reset --hard" &&
test_when_finished "git -C 3a clean -fd" &&
test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_setup_3a R &&
(
cd 3a &&
cd 3a_R &&
git checkout B^0 &&
@ -522,10 +515,10 @@ test_expect_success '3a-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
# Commit B: bq_2, bar/whatever
# Expected: bar/{bq_2, whatever}
test_expect_success '3b-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_create_repo 3b &&
test_setup_3b () {
test_create_repo 3b_$1 &&
(
cd 3b &&
cd 3b_$1 &&
mkdir foo &&
test_seq 1 10 >bq &&
@ -550,13 +543,12 @@ test_expect_success '3b-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_tick &&
git commit -m "B"
)
'
}
test_expect_success '3b-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_when_finished "git -C 3b reset --hard" &&
test_when_finished "git -C 3b clean -fd" &&
test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_setup_3b L &&
(
cd 3b &&
cd 3b_L &&
git checkout A^0 &&
@ -581,11 +573,10 @@ test_expect_success '3b-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
)
'
test_expect_success '3b-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_when_finished "git -C 3b reset --hard" &&
test_when_finished "git -C 3b clean -fd" &&
test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
test_setup_3b R &&
(
cd 3b &&
cd 3b_R &&
git checkout B^0 &&
@ -621,7 +612,7 @@ test_expect_success '3b-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
# Working copy: b_4
# Expected: b_2 for merge, b_4 in working copy
test_expect_success '4a-setup: Change on A, change on B subset of A, dirty mods present' '
test_setup_4a () {
test_create_repo 4a &&
(
cd 4a &&
@ -647,7 +638,7 @@ test_expect_success '4a-setup: Change on A, change on B subset of A, dirty mods
test_tick &&
git commit -m "B"
)
'
}
# NOTE: For as long as we continue using unpack_trees() without index_only
# set to true, it will error out on a case like this claiming the the locally
@ -655,9 +646,8 @@ test_expect_success '4a-setup: Change on A, change on B subset of A, dirty mods
# correct requires doing the merge in-memory first, then realizing that no
# updates to the file are necessary, and thus that we can just leave the path
# alone.
test_expect_failure '4a-check: Change on A, change on B subset of A, dirty mods present' '
test_when_finished "git -C 4a reset --hard" &&
test_when_finished "git -C 4a clean -fd" &&
test_expect_failure '4a: Change on A, change on B subset of A, dirty mods present' '
test_setup_4a &&
(
cd 4a &&
@ -695,7 +685,7 @@ test_expect_failure '4a-check: Change on A, change on B subset of A, dirty mods
# Working copy: c_4
# Expected: c_2
test_expect_success '4b-setup: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' '
test_setup_4b () {
test_create_repo 4b &&
(
cd 4b &&
@ -722,11 +712,10 @@ test_expect_success '4b-setup: Rename+Mod(A)/Mod(B), change on B subset of A, di
test_tick &&
git commit -m "B"
)
'
}
test_expect_success '4b-check: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' '
test_when_finished "git -C 4b reset --hard" &&
test_when_finished "git -C 4b clean -fd" &&
test_expect_success '4b: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' '
test_setup_4b &&
(
cd 4b &&