Skip to content

Commit 1736855

Browse files
committed
Add merge-subtree back
An earlier commit e1b3a2c (Build-in merge-recursive) made the subtree merge strategy backend unavailable. This resurrects it. A new test t6029 currently only tests the strategy is available, but it should be enhanced to check the real "subtree" case. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b56fca0 commit 1736855

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,18 @@ PROGRAMS = \
261261
# Empty...
262262
EXTRA_PROGRAMS =
263263

264+
# List built-in command $C whose implementation cmd_$C() is not in
265+
# builtin-$C.o but is linked in as part of some other command.
264266
BUILT_INS = \
265267
git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
266268
git-get-tar-commit-id$X git-init$X git-repo-config$X \
267269
git-fsck-objects$X git-cherry-pick$X git-peek-remote$X git-status$X \
270+
git-merge-subtree$X \
268271
$(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
269272

270273
# what 'all' will build and 'install' will install, in gitexecdir
271274
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
272275

273-
ALL_PROGRAMS += git-merge-subtree$X
274-
275276
# what 'all' will build but not install in gitexecdir
276277
OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
277278

@@ -807,9 +808,6 @@ help.o: help.c common-cmds.h GIT-CFLAGS
807808
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
808809
'-DGIT_INFO_PATH="$(infodir_SQ)"' $<
809810

810-
git-merge-subtree$X: git-merge-recursive$X
811-
$(QUIET_BUILT_IN)$(RM) $@ && ln git-merge-recursive$X $@
812-
813811
$(BUILT_INS): git$X
814812
$(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@
815813

git.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ static void handle_internal_command(int argc, const char **argv)
332332
{ "merge-file", cmd_merge_file },
333333
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
334334
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
335+
{ "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
335336
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
336337
{ "name-rev", cmd_name_rev, RUN_SETUP },
337338
{ "pack-objects", cmd_pack_objects, RUN_SETUP },

t/t6029-merge-subtree.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
test_description='subtree merge strategy'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
9+
s="1 2 3 4 5 6 7 8"
10+
for i in $s; do echo $i; done >hello &&
11+
git add hello &&
12+
git commit -m initial &&
13+
git checkout -b side &&
14+
echo >>hello world &&
15+
git add hello &&
16+
git commit -m second &&
17+
git checkout master &&
18+
for i in mundo $s; do echo $i; done >hello &&
19+
git add hello &&
20+
git commit -m master
21+
22+
'
23+
24+
test_expect_success 'subtree available and works like recursive' '
25+
26+
git merge -s subtree side &&
27+
for i in mundo $s world; do echo $i; done >expect &&
28+
diff -u expect hello
29+
30+
'
31+
32+
test_done

0 commit comments

Comments
 (0)