Skip to content

Commit 366d2d5

Browse files
committed
Merge branch 'da/subtree-2.9-regression' into maint
"git merge" in Git v2.9 was taught to forbid merging an unrelated lines of history by default, but that is exactly the kind of thing the "--rejoin" mode of "git subtree" (in contrib/) wants to do. "git subtree" has been taught to use the "--allow-unrelated-histories" option to override the default. * da/subtree-2.9-regression: subtree: fix "git subtree split --rejoin" t7900-subtree.sh: fix quoting and broken && chains
2 parents d9d7ab3 + 0f12c7d commit 366d2d5

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ cmd_split()
662662
debug "Merging split branch into HEAD..."
663663
latest_old=$(cache_get latest_old)
664664
git merge -s ours \
665+
--allow-unrelated-histories \
665666
-m "$(rejoin_msg "$dir" $latest_old $latest_new)" \
666667
$latest_new >&2 || exit $?
667668
fi

contrib/subtree/t/t7900-subtree.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ export TEST_DIRECTORY
1616

1717
subtree_test_create_repo()
1818
{
19-
test_create_repo "$1"
19+
test_create_repo "$1" &&
2020
(
21-
cd $1
21+
cd "$1" &&
2222
git config log.date relative
2323
)
2424
}
2525

2626
create()
2727
{
28-
echo "$1" >"$1"
28+
echo "$1" >"$1" &&
2929
git add "$1"
3030
}
3131

@@ -71,12 +71,12 @@ join_commits()
7171
}
7272

7373
test_create_commit() (
74-
repo=$1
75-
commit=$2
76-
cd "$repo"
77-
mkdir -p $(dirname "$commit") \
74+
repo=$1 &&
75+
commit=$2 &&
76+
cd "$repo" &&
77+
mkdir -p "$(dirname "$commit")" \
7878
|| error "Could not create directory for commit"
79-
echo "$commit" >"$commit"
79+
echo "$commit" >"$commit" &&
8080
git add "$commit" || error "Could not add commit"
8181
git commit -m "$commit" || error "Could not commit"
8282
)
@@ -346,6 +346,22 @@ test_expect_success 'split sub dir/ with --rejoin' '
346346
)
347347
'
348348

349+
next_test
350+
test_expect_success 'split sub dir/ with --rejoin from scratch' '
351+
subtree_test_create_repo "$subtree_test_count" &&
352+
test_create_commit "$subtree_test_count" main1 &&
353+
(
354+
cd "$subtree_test_count" &&
355+
mkdir "sub dir" &&
356+
echo file >"sub dir"/file &&
357+
git add "sub dir/file" &&
358+
git commit -m"sub dir file" &&
359+
split_hash=$(git subtree split --prefix="sub dir" --rejoin) &&
360+
git subtree split --prefix="sub dir" --rejoin &&
361+
check_equal "$(last_commit_message)" "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
362+
)
363+
'
364+
349365
next_test
350366
test_expect_success 'split sub dir/ with --rejoin and --message' '
351367
subtree_test_create_repo "$subtree_test_count" &&

0 commit comments

Comments
 (0)