aboutsummaryrefslogtreecommitdiffstats
path: root/t/t4301-merge-tree-write-tree.sh
diff options
context:
space:
mode:
authorKyle Zhao <kylezhao@tencent.com>2022-11-11 23:45:13 +0000
committerTaylor Blau <me@ttaylorr.com>2022-11-12 23:53:04 -0500
commit66265a693e8deb3ab86577eb7f69940410044081 (patch)
treed2efd3dba5320d5efb55dade00c4ea9161e748bc /t/t4301-merge-tree-write-tree.sh
parentmerge-tree: support multiple batched merges with --stdin (diff)
downloadgit-66265a693e8deb3ab86577eb7f69940410044081.tar.gz
git-66265a693e8deb3ab86577eb7f69940410044081.zip
merge-tree.c: add --merge-base=<commit> option
This patch will give our callers more flexibility to use `git merge-tree`, such as: git merge-tree --write-tree --merge-base=branch^ HEAD branch This does a merge of HEAD and branch, but uses branch^ as the merge-base. And the reason why using an option flag instead of a positional argument is to allow additional commits passed to merge-tree to be handled via an octopus merge in the future. Signed-off-by: Kyle Zhao <kylezhao@tencent.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 't/t4301-merge-tree-write-tree.sh')
-rwxr-xr-xt/t4301-merge-tree-write-tree.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh
index cac85591b5..6db96ccbaa 100755
--- a/t/t4301-merge-tree-write-tree.sh
+++ b/t/t4301-merge-tree-write-tree.sh
@@ -860,4 +860,31 @@ test_expect_success '--stdin with both a successful and a conflicted merge' '
test_cmp expect actual
'
+# specify merge-base as parent of branch2
+# git merge-tree --write-tree --merge-base=c2 c1 c3
+# Commit c1: add file1
+# Commit c2: add file2 after c1
+# Commit c3: add file3 after c2
+# Expected: add file3, and file2 does NOT appear
+
+test_expect_success 'specify merge-base as parent of branch2' '
+ # Setup
+ test_when_finished "rm -rf base-b2-p" &&
+ git init base-b2-p &&
+ test_commit -C base-b2-p c1 file1 &&
+ test_commit -C base-b2-p c2 file2 &&
+ test_commit -C base-b2-p c3 file3 &&
+
+ # Testing
+ TREE_OID=$(git -C base-b2-p merge-tree --write-tree --merge-base=c2 c1 c3) &&
+
+ q_to_tab <<-EOF >expect &&
+ 100644 blob $(git -C base-b2-p rev-parse c1:file1)Qfile1
+ 100644 blob $(git -C base-b2-p rev-parse c3:file3)Qfile3
+ EOF
+
+ git -C base-b2-p ls-tree $TREE_OID >actual &&
+ test_cmp expect actual
+'
+
test_done