324
)
325
'
326
327
+test_expect_success 'split "sub dir"/ with --rejoin and --squash' '
328
+ subtree_test_create_repo "$test_count" &&
329
+ subtree_test_create_repo "$test_count/sub proj" &&
330
+ test_create_commit "$test_count" main1 &&
331
+ test_create_commit "$test_count/sub proj" sub1 &&
332
+ (
333
+ cd "$test_count" &&
334
+ git fetch ./"sub proj" HEAD &&
335
+ git subtree add --prefix="sub dir" --squash FETCH_HEAD
336
+ ) &&
337
+ test_create_commit "$test_count" "sub dir"/main-sub1 &&
338
+ test_create_commit "$test_count" main2 &&
339
+ test_create_commit "$test_count/sub proj" sub2 &&
340
+ test_create_commit "$test_count" "sub dir"/main-sub2 &&
341
+ (
342
+ cd "$test_count" &&
343
+ git subtree pull --prefix="sub dir" --squash ./"sub proj" HEAD &&
344
+ MAIN=$(git rev-parse --verify HEAD) &&
345
+ SUB=$(git -C "sub proj" rev-parse --verify HEAD) &&
346
+
347
+ SPLIT=$(git subtree split --prefix="sub dir" --annotate="*" --rejoin --squash) &&
348
+
349
+ test_must_fail git merge-base --is-ancestor $SUB HEAD &&
350
+ test_must_fail git merge-base --is-ancestor $SPLIT HEAD &&
351
+ git rev-list HEAD ^$MAIN >commit-list &&
352
+ test_line_count = 2 commit-list &&
353
+ test "$(git rev-parse --verify HEAD:)" = "$(git rev-parse --verify $MAIN:)" &&
354
+ test "$(git rev-parse --verify HEAD:"sub dir")" = "$(git rev-parse --verify $SPLIT:)" &&
355
+ test "$(git rev-parse --verify HEAD^1)" = $MAIN &&
356
+ test "$(git rev-parse --verify HEAD^2)" != $SPLIT &&
357
+ test "$(git rev-parse --verify HEAD^2:)" = "$(git rev-parse --verify $SPLIT:)" &&
358
+ test "$(last_commit_subject)" = "Split '\''sub dir/'\'' into commit '\''$SPLIT'\''"
359
+ )
360
+'
361
+
362
+test_expect_success 'split then pull "sub dir"/ with --rejoin and --squash' '
363
+ # 1. "add"
364
+ subtree_test_create_repo "$test_count" &&
365
+ subtree_test_create_repo "$test_count/sub proj" &&
366
+ test_create_commit "$test_count" main1 &&
367
+ test_create_commit "$test_count/sub proj" sub1 &&
368
+ git -C "$test_count" subtree --prefix="sub dir" add --squash ./"sub proj" HEAD &&
369
+
370
+ # 2. commit from parent
371
+ test_create_commit "$test_count" "sub dir"/main-sub1 &&
372
+
373
+ # 3. "split --rejoin --squash"
374
+ git -C "$test_count" subtree --prefix="sub dir" split --rejoin --squash &&
375
+
376
+ # 4. "pull --squash"
377
+ test_create_commit "$test_count/sub proj" sub2 &&
378
+ git -C "$test_count" subtree -d --prefix="sub dir" pull --squash ./"sub proj" HEAD &&
379
+
380
+ test_must_fail git merge-base HEAD FETCH_HEAD
381
+'
382
+
383
test_expect_success 'split "sub dir"/ with --branch' '
384
subtree_test_create_repo "$test_count" &&
385
subtree_test_create_repo "$test_count/sub proj" &&