git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/6] Add a new test for using a custom merge strategy

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Jul 28, 2008, 23:39 UTC
Message-ID
<f3af7df2dda2dcb7801314cc993470264259f970.1217288180.git.vmiklos@frugalware.org>
In-Reply-To
<alpine.DEB.1.00.0807281506510.2725@eeepc-johanness>

Testing is done by creating a simple git-merge-theirs strategy which just picks the upstream tree. (In other words, this is not the opposite of -s ours.)

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
On Mon, Jul 28, 2008 at 03:12:59PM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 5 quoted lines
> Note that what was asked for, and what Junio implemented before
> deciding
> that it would do more harm than good in git.git, is not the same as
> what
> you provide.

Thanks, now I see the difference. The updated commit message is hopefully better.

Also I added a check to make sure the upstream and the result tree is the same as well.

 t/t7606-merge-custom.sh |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100755 t/t7606-merge-custom.sh
diff --git a/t/t7606-merge-custom.sh b/t/t7606-merge-custom.sh
new file mode 100755
index 0000000..13e8ff5
--- /dev/null
+++ b/t/t7606-merge-custom.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+test_description='git-merge
+
+Testing a custom strategy.'
+
+. ./test-lib.sh
+
+cat > git-merge-theirs << EOF
+#!/bin/sh
+eval git read-tree --reset -u \\\$\$#
+EOF
+chmod +x git-merge-theirs
+PATH=.:$PATH
+export PATH
+
+test_expect_success 'setup' '
+	echo c0 > c0.c &&
+	git add c0.c &&
+	git commit -m c0 &&
+	git tag c0 &&
+	echo c1 > c1.c &&
+	git add c1.c &&
+	git commit -m c1 &&
+	git tag c1 &&
+	git reset --hard c0 &&
+	echo c2 > c2.c &&
+	git add c2.c &&
+	git commit -m c2 &&
+	git tag c2
+'
+
+test_expect_success 'merge c2 with a custom strategy' '
+	git reset --hard c1 &&
+	git merge -s theirs c2 &&
+	test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
+	test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
+	test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
+	test "$(git rev-parse c2^{tree})" = "$(git rev-parse HEAD^{tree})" &&
+	git diff --exit-code &&
+	test -f c0.c &&
+	test ! -f c1.c &&
+	test -f c2.c
+'
+
+test_done
-- 
1.6.0.rc0.14.g95f8.dirty
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 34 of 46 in “Allow custom merge strategies”
  1. 0/7 Allow custom merge strategiesMiklos Vajna, Jul 26, 2008
  2. 1/7 Make is_git_command() usable outside builtin-helpMiklos Vajna, Jul 26, 2008
  3. t7601: extend the 'merge picks up the best result' testMiklos Vajna, Jul 26, 2008
  4. 2/7 builtin-help: change the current directory back in list_commands_in_dir()Miklos Vajna, Jul 26, 2008
  5. 3/7 builtin-help: make list_commands() a bit more genericMiklos Vajna, Jul 26, 2008
  6. 4/7 builtin-merge: allow using a custom strategyMiklos Vajna, Jul 26, 2008
  7. 5/7 Add a new test for using a custom merge strategyMiklos Vajna, Jul 26, 2008
  8. 6/7 builtin-help: make it possible to exclude some commands in list_commands()Miklos Vajna, Jul 26, 2008
  9. 7/7 builtin-merge: avoid non-strategy git-merge commands in error messageMiklos Vajna, Jul 26, 2008
  10. Johannes SchindelinJul 26, 2008
  11. Miklos VajnaJul 26, 2008
  12. 7/7 builtin-merge: avoid non-strategy git-merge commands in error messageMiklos Vajna, Jul 26, 2008
  13. Johannes SchindelinJul 26, 2008
  14. Miklos VajnaJul 26, 2008
  15. Johannes SchindelinJul 26, 2008
  16. builtin-merge: avoid non-strategy git-merge commands in error messageMiklos Vajna, Jul 26, 2008
  17. Jonathan NiederJul 26, 2008
  18. 3/7 builtin-help: make list_commands() a bit more genericMiklos Vajna, Jul 26, 2008
  19. Johannes SchindelinJul 26, 2008
  20. Junio C HamanoJul 27, 2008
  21. Johannes SchindelinJul 27, 2008
  22. Avoid chdir() in list_commands_in_dir()Johannes Schindelin, Jul 27, 2008
  23. Miklos VajnaJul 26, 2008
  24. Jonathan NiederJul 26, 2008
  25. Miklos VajnaJul 28, 2008
  26. 0/6 Allow custom merge strategies, take 2Miklos Vajna, Jul 28, 2008
  27. 1/6 builtin-help: make is_git_command() usable outside builtin-helpMiklos Vajna, Jul 28, 2008
  28. 2/6 builtin-help: make list_commands() a bit more genericMiklos Vajna, Jul 28, 2008
  29. 3/6 builtin-help: make it possible to exclude some commands in list_commands()Miklos Vajna, Jul 28, 2008
  30. 4/6 builtin-merge: allow using a custom strategyMiklos Vajna, Jul 28, 2008
  31. 5/6 builtin-merge: avoid non-strategy git-merge commands in error messageMiklos Vajna, Jul 28, 2008
  32. 6/6 Add a new test for using a custom merge strategyMiklos Vajna, Jul 28, 2008
  33. Johannes SchindelinJul 28, 2008
  34. 6/6 Add a new test for using a custom merge strategyMiklos Vajna, Jul 28, 2008
  35. Johannes SchindelinJul 28, 2008
  36. Miklos VajnaJul 28, 2008
  37. Miklos VajnaJul 29, 2008
  38. Johannes SchindelinJul 28, 2008
  39. builtin-merge: allow using a custom strategyMiklos Vajna, Jul 28, 2008
  40. Johannes SchindelinJul 28, 2008
  41. Junio C HamanoJul 28, 2008
  42. Johannes SchindelinJul 28, 2008
  43. Junio C HamanoJul 28, 2008
  44. Junio C HamanoJul 28, 2008
  45. Johannes SchindelinJul 28, 2008
  46. 3/6 builtin-help: make it possible to exclude some commands in list_commands()Miklos Vajna, Jul 28, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.