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

[PATCH 1/3] add tests for merge message headings

From
Jeff King <peff@peff.net>
Date
Aug 9, 2009, 10:01 UTC
Message-ID
<20090809100148.GA25231@coredump.intra.peff.net>
In-Reply-To
<20090809100045.GA25197@coredump.intra.peff.net>

When calling "git merge $X", we automatically generate a commit message containing something like "Merge branch '$X'". This test script checks that those messages say what they should, and exposes a failure when merging a refname that is ambiguous between a tag and a branch.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t7608-merge-messages.sh |   50 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100755 t/t7608-merge-messages.sh
diff --git a/t/t7608-merge-messages.sh b/t/t7608-merge-messages.sh
new file mode 100755
index 0000000..9d10583
--- /dev/null
+++ b/t/t7608-merge-messages.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+test_description='test auto-generated merge messages'
+. ./test-lib.sh
+
+check_oneline() {
+	echo "$1" | sed "s/Q/'/g" >expect &&
+	git log -1 --pretty=tformat:%s >actual &&
+	test_cmp expect actual
+}
+
+test_expect_success 'merge local branch' '
+	test_commit master-1 &&
+	git checkout -b local-branch &&
+	test_commit branch-1 &&
+	git checkout master &&
+	test_commit master-2 &&
+	git merge local-branch &&
+	check_oneline "Merge branch Qlocal-branchQ"
+'
+
+test_expect_success 'merge octopus branches' '
+	git checkout -b octopus-a master &&
+	test_commit octopus-1 &&
+	git checkout -b octopus-b master &&
+	test_commit octopus-2 &&
+	git checkout master &&
+	git merge octopus-a octopus-b &&
+	check_oneline "Merge branches Qoctopus-aQ and Qoctopus-bQ"
+'
+
+test_expect_success 'merge tag' '
+	git checkout -b tag-branch master &&
+	test_commit tag-1 &&
+	git checkout master &&
+	test_commit master-3 &&
+	git merge tag-1 &&
+	check_oneline "Merge commit Qtag-1Q"
+'
+
+test_expect_failure 'ambiguous tag' '
+	git checkout -b ambiguous master &&
+	test_commit ambiguous &&
+	git checkout master &&
+	test_commit master-4 &&
+	git merge ambiguous &&
+	check_oneline "Merge commit QambiguousQ"
+'
+
+test_done
-- 
1.6.4.178.g7a987
Previous: Jeff KingNext: Jeff King
Message 7 of 12 in “merge: indicate remote tracking branches in merge message”
  1. merge: indicate remote tracking branches in merge messageJeff King, Aug 9, 2009
  2. Jeff KingAug 9, 2009
  3. Junio C HamanoAug 9, 2009
  4. Jeff KingAug 9, 2009
  5. Jeff KingAug 9, 2009
  6. Jeff KingAug 9, 2009
  7. 1/3 add tests for merge message headingsJeff King, Aug 9, 2009
  8. 2/3 merge: fix incorrect merge message for ambiguous tag/branchJeff King, Aug 9, 2009
  9. 3/3 merge: indicate remote tracking branches in merge messageJeff King, Aug 9, 2009
  10. Jeff KingAug 9, 2009
  11. Junio C HamanoAug 9, 2009
  12. Jeff KingAug 9, 2009

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.