git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Add merge-subtree back
@ 2008-02-23 19:16 Junio C Hamano
  2008-02-24  6:19 ` Daniel Barkalow
  2008-02-28  1:51 ` [PATCH] New test to check the real "subtree" case Miklos Vajna
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2008-02-23 19:16 UTC (permalink / raw)
  To: git; +Cc: Daniel Barkalow

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>
---
 Makefile                 |    8 +++-----
 git.c                    |    1 +
 t/t6029-merge-subtree.sh |   32 ++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 5 deletions(-)
 create mode 100755 t/t6029-merge-subtree.sh

diff --git a/Makefile b/Makefile
index 90c0dd8..40fa41b 100644
--- a/Makefile
+++ b/Makefile
@@ -261,17 +261,18 @@ PROGRAMS = \
 # Empty...
 EXTRA_PROGRAMS =
 
+# List built-in command $C whose implementation cmd_$C() is not in
+# builtin-$C.o but is linked in as part of some other command.
 BUILT_INS = \
 	git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
 	git-get-tar-commit-id$X git-init$X git-repo-config$X \
 	git-fsck-objects$X git-cherry-pick$X git-peek-remote$X git-status$X \
+	git-merge-subtree$X \
 	$(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
 
 # what 'all' will build and 'install' will install, in gitexecdir
 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 
-ALL_PROGRAMS += git-merge-subtree$X
-
 # what 'all' will build but not install in gitexecdir
 OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
 
@@ -807,9 +808,6 @@ help.o: help.c common-cmds.h GIT-CFLAGS
 		'-DGIT_MAN_PATH="$(mandir_SQ)"' \
 		'-DGIT_INFO_PATH="$(infodir_SQ)"' $<
 
-git-merge-subtree$X: git-merge-recursive$X
-	$(QUIET_BUILT_IN)$(RM) $@ && ln git-merge-recursive$X $@
-
 $(BUILT_INS): git$X
 	$(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@
 
diff --git a/git.c b/git.c
index fc15686..bd424ea 100644
--- a/git.c
+++ b/git.c
@@ -332,6 +332,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "merge-file", cmd_merge_file },
 		{ "merge-ours", cmd_merge_ours, RUN_SETUP },
 		{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
+		{ "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
 		{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
 		{ "name-rev", cmd_name_rev, RUN_SETUP },
 		{ "pack-objects", cmd_pack_objects, RUN_SETUP },
diff --git a/t/t6029-merge-subtree.sh b/t/t6029-merge-subtree.sh
new file mode 100755
index 0000000..3900a05
--- /dev/null
+++ b/t/t6029-merge-subtree.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+test_description='subtree merge strategy'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+	s="1 2 3 4 5 6 7 8"
+	for i in $s; do echo $i; done >hello &&
+	git add hello &&
+	git commit -m initial &&
+	git checkout -b side &&
+	echo >>hello world &&
+	git add hello &&
+	git commit -m second &&
+	git checkout master &&
+	for i in mundo $s; do echo $i; done >hello &&
+	git add hello &&
+	git commit -m master
+
+'
+
+test_expect_success 'subtree available and works like recursive' '
+
+	git merge -s subtree side &&
+	for i in mundo $s world; do echo $i; done >expect &&
+	diff -u expect hello
+
+'
+
+test_done
-- 
1.5.4.2.300.g8d945

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add merge-subtree back
  2008-02-23 19:16 [PATCH] Add merge-subtree back Junio C Hamano
@ 2008-02-24  6:19 ` Daniel Barkalow
  2008-02-28  1:51 ` [PATCH] New test to check the real "subtree" case Miklos Vajna
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Barkalow @ 2008-02-24  6:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Sat, 23 Feb 2008, Junio C Hamano wrote:

> An earlier commit e1b3a2c (Build-in merge-recursive) made the
> subtree merge strategy backend unavailable.  This resurrects
> it.

That's really quite subtle. I think there should probably be a 
cmd_merge_subtree that shares almost everything with cmd_merge_recursive, 
but is a different function.

Or maybe there should be a "--subtree" option to merge that has that 
effect with arbitrary stratgeies by changing what gets sent to the 
strategy.

But restoring access to the strategy for now is obviously fine.

	-Daniel
*This .sig left intentionally blank*

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] New test to check the real "subtree" case
  2008-02-23 19:16 [PATCH] Add merge-subtree back Junio C Hamano
  2008-02-24  6:19 ` Daniel Barkalow
@ 2008-02-28  1:51 ` Miklos Vajna
  2008-02-28  9:45   ` Johannes Schindelin
  1 sibling, 1 reply; 6+ messages in thread
From: Miklos Vajna @ 2008-02-28  1:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Daniel Barkalow

t6029 already checks if subtree available and works like recursive, but
this new one actually tests the extra functionality the subtree merge
strategy provides.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---

On Sat, Feb 23, 2008 at 11:16:21AM -0800, Junio C Hamano <gitster@pobox.com> wrote:
> A new test t6029 currently only tests the strategy is available,
> but it should be enhanced to check the real "subtree" case.

i think something like this should do it.

 t/t3035-merge-subtree.sh |   54 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100755 t/t3035-merge-subtree.sh

diff --git a/t/t3035-merge-subtree.sh b/t/t3035-merge-subtree.sh
new file mode 100755
index 0000000..e400dce
--- /dev/null
+++ b/t/t3035-merge-subtree.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+test_description='merge-subtree backend test'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	mkdir git-gui &&
+	cd git-gui &&
+	git init &&
+	echo git-gui > git-gui.sh &&
+	o1=$(git hash-object git-gui.sh) &&
+	git add git-gui.sh &&
+	git commit -m "initial git-gui" &&
+	cd .. &&
+	mkdir git &&
+	cd git &&
+	git init &&
+	echo git >git.c &&
+	o2=$(git hash-object git.c) &&
+	git add git.c &&
+	git commit -m "initial git"
+'
+
+test_expect_success 'initial merge' '
+	git remote add -f gui ../git-gui &&
+	git merge -s ours --no-commit gui/master &&
+	git read-tree --prefix=git-gui/ -u gui/master &&
+	git commit -m "Merge git-gui as our subdirectory" &&
+	git ls-files -s >actual &&
+	(
+		echo "100644 $o1 0	git-gui/git-gui.sh"
+		echo "100644 $o2 0	git.c"
+	) >expected &&
+	git diff -u expected actual
+'
+
+test_expect_success 'merge update' '
+	cd ../git-gui &&
+	echo git-gui2 > git-gui.sh &&
+	o3=$(git hash-object git-gui.sh) &&
+	git add git-gui.sh &&
+	git commit -m "update git-gui" &&
+	cd ../git &&
+	git pull -s subtree gui master &&
+	git ls-files -s >actual &&
+	(
+		echo "100644 $o3 0	git-gui/git-gui.sh"
+		echo "100644 $o2 0	git.c"
+	) >expected &&
+	git diff -u expected actual
+'
+
+test_done
-- 
1.5.4.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] New test to check the real "subtree" case
  2008-02-28  1:51 ` [PATCH] New test to check the real "subtree" case Miklos Vajna
@ 2008-02-28  9:45   ` Johannes Schindelin
  2008-02-28 12:36     ` [PATCH] Improve t6029 " Miklos Vajna
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2008-02-28  9:45 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Junio C Hamano, git, Daniel Barkalow

Hi,

On Thu, 28 Feb 2008, Miklos Vajna wrote:

> On Sat, Feb 23, 2008 at 11:16:21AM -0800, Junio C Hamano <gitster@pobox.com> wrote:
> > A new test t6029 currently only tests the strategy is available,
> > but it should be enhanced to check the real "subtree" case.
> 
> i think something like this should do it.
> 
>  t/t3035-merge-subtree.sh |   54 ++++++++++++++++++++++++++++++++++++++++++++++

Why yet another file?  Why not enhance t6029, as suggested?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Improve t6029 to check the real "subtree" case
  2008-02-28  9:45   ` Johannes Schindelin
@ 2008-02-28 12:36     ` Miklos Vajna
  2008-02-28 14:57       ` Johannes Schindelin
  0 siblings, 1 reply; 6+ messages in thread
From: Miklos Vajna @ 2008-02-28 12:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git, Daniel Barkalow

t6029 already checks if subtree available and works like recursive. This
patch adds code to test test the extra functionality the subtree merge
strategy provides.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---

On Thu, Feb 28, 2008 at 09:45:03AM +0000, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Why yet another file?  Why not enhance t6029, as suggested?

here it is.

 t/t6029-merge-subtree.sh |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/t/t6029-merge-subtree.sh b/t/t6029-merge-subtree.sh
index 3900a05..35d66e8 100755
--- a/t/t6029-merge-subtree.sh
+++ b/t/t6029-merge-subtree.sh
@@ -29,4 +29,51 @@ test_expect_success 'subtree available and works like recursive' '
 
 '
 
+test_expect_success 'setup' '
+	mkdir git-gui &&
+	cd git-gui &&
+	git init &&
+	echo git-gui > git-gui.sh &&
+	o1=$(git hash-object git-gui.sh) &&
+	git add git-gui.sh &&
+	git commit -m "initial git-gui" &&
+	cd .. &&
+	mkdir git &&
+	cd git &&
+	git init &&
+	echo git >git.c &&
+	o2=$(git hash-object git.c) &&
+	git add git.c &&
+	git commit -m "initial git"
+'
+
+test_expect_success 'initial merge' '
+	git remote add -f gui ../git-gui &&
+	git merge -s ours --no-commit gui/master &&
+	git read-tree --prefix=git-gui/ -u gui/master &&
+	git commit -m "Merge git-gui as our subdirectory" &&
+	git ls-files -s >actual &&
+	(
+		echo "100644 $o1 0	git-gui/git-gui.sh"
+		echo "100644 $o2 0	git.c"
+	) >expected &&
+	git diff -u expected actual
+'
+
+test_expect_success 'merge update' '
+	cd ../git-gui &&
+	echo git-gui2 > git-gui.sh &&
+	o3=$(git hash-object git-gui.sh) &&
+	git add git-gui.sh &&
+	git commit -m "update git-gui" &&
+	cd ../git &&
+	git pull -s subtree gui master &&
+	git ls-files -s >actual &&
+	(
+		echo "100644 $o3 0	git-gui/git-gui.sh"
+		echo "100644 $o2 0	git.c"
+	) >expected &&
+	git diff -u expected actual
+'
+
 test_done
-- 
1.5.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Improve t6029 to check the real "subtree" case
  2008-02-28 12:36     ` [PATCH] Improve t6029 " Miklos Vajna
@ 2008-02-28 14:57       ` Johannes Schindelin
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2008-02-28 14:57 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Junio C Hamano, git, Daniel Barkalow

Hi,

On Thu, 28 Feb 2008, Miklos Vajna wrote:

> On Thu, Feb 28, 2008 at 09:45:03AM +0000, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > Why yet another file?  Why not enhance t6029, as suggested?
> 
> here it is.

Thanks.

> diff --git a/t/t6029-merge-subtree.sh b/t/t6029-merge-subtree.sh
> index 3900a05..35d66e8 100755
> --- a/t/t6029-merge-subtree.sh
> +++ b/t/t6029-merge-subtree.sh
> @@ -29,4 +29,51 @@ test_expect_success 'subtree available and works like recursive' '
>  
>  '
>  
> +test_expect_success 'setup' '

I'd call this 'setup subproject', but that's just nitpicking.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-28 14:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-23 19:16 [PATCH] Add merge-subtree back Junio C Hamano
2008-02-24  6:19 ` Daniel Barkalow
2008-02-28  1:51 ` [PATCH] New test to check the real "subtree" case Miklos Vajna
2008-02-28  9:45   ` Johannes Schindelin
2008-02-28 12:36     ` [PATCH] Improve t6029 " Miklos Vajna
2008-02-28 14:57       ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).