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

[PATCH 3/6] lib-rebase.sh: introduce test_commit() and test_merge() helpers

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 27, 2009, 17:47 UTC
Message-ID
<alpine.DEB.1.00.0901271847070.3586@pacific.mpi-cbg.de>
In-Reply-To
<alpine.DEB.1.00.0901271844340.3586@pacific.mpi-cbg.de>

Often we just need to add a commit with a given (short) name, that will be tagged with the same name. Now, relatively complicated graphs can be constructed easily and in a clear fashion:

	test_commit A &&
	test_commit B &&
	git checkout A &&
	test_commit C &&
	test_merge D B
will construct this graph:
	A - B
	  \   \
	    C - D

For simplicity, files of the same name (but in lower case, to avoid a warning about ambiguous names) will be committed, with the commit message as contents.

If you need to provide a different file/different contents, you can use the more explicit form

	test_commit $MESSAGE $FILENAME $CONTENTS
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	This may want to live in test-lib.sh instead.
 t/lib-rebase.sh |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index cda7778..37430f3 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -46,3 +46,29 @@ EOF
 	test_set_editor "$(pwd)/fake-editor.sh"
 	chmod a+x fake-editor.sh
 }
+
+# Call test_commit with the arguments "<message> [<file> [<contents>]]"
+#
+# This will commit a file with the given contents and the given commit
+# message.  It will also add a tag with <message> as name.
+#
+# Both <file> and <contents> default to <message>.
+
+test_commit () {
+	file=$2
+	test -z "$2" && file=$(echo "$1" | tr 'A-Z' 'a-z')
+	echo ${3-$1} > $file &&
+	git add $file &&
+	test_tick &&
+	git commit -m $1 &&
+	git tag $1
+}
+
+# Call test_merge with the arguments "<message> <commit>", where <commit>
+# can be a tag pointing to the commit-to-merge.
+
+test_merge () {
+	test_tick &&
+	git merge -m $1 $2 &&
+	git tag $1
+}
-- 
1.6.1.482.g7d54be
Previous: Johannes SchindelinNext: Junio C Hamano
Message 21 of 30 in “Heads up: rebase -i -p will be made sane again”
  1. Johannes SchindelinJan 27, 2009
  2. Stephen HabermanJan 27, 2009
  3. 0/6 Simplifications of some 'rebase' testsJohannes Schindelin, Jan 27, 2009
  4. 1/6 t3404 & t3411: undo copy&pasteJohannes Schindelin, Jan 27, 2009
  5. Junio C HamanoJan 27, 2009
  6. Johannes SchindelinJan 27, 2009
  7. Junio C HamanoJan 27, 2009
  8. Johannes SchindelinJan 27, 2009
  9. 0/6 rebase simplificationsJohannes Schindelin, Jan 27, 2009
  10. Junio C HamanoJan 27, 2009
  11. Johannes SchindelinJan 27, 2009
  12. 1/6 t3404 & t3411: undo copy&pasteJohannes Schindelin, Jan 27, 2009
  13. 2/6 lib-rebase.sh: Document what set_fake_editor() doesJohannes Schindelin, Jan 27, 2009
  14. 3/6 test-lib.sh: introduce test_commit() and test_merge() helpersJohannes Schindelin, Jan 27, 2009
  15. 4/6 Simplify t3410Johannes Schindelin, Jan 27, 2009
  16. 5/6 Simplify t3411Johannes Schindelin, Jan 27, 2009
  17. 6/6 Simplify t3412Johannes Schindelin, Jan 27, 2009
  18. 2/6 lib-rebase.sh: Document what set_fake_editor() doesJohannes Schindelin, Jan 27, 2009
  19. Junio C HamanoJan 27, 2009
  20. Johannes SchindelinJan 27, 2009
  21. 3/6 lib-rebase.sh: introduce test_commit() and test_merge() helpersJohannes Schindelin, Jan 27, 2009
  22. Junio C HamanoJan 27, 2009
  23. 4/6 Simplify t3410Johannes Schindelin, Jan 27, 2009
  24. 5/6 Simplify t3411Johannes Schindelin, Jan 27, 2009
  25. 6/6 Simplify t3412Johannes Schindelin, Jan 27, 2009
  26. Johannes SchindelinJan 27, 2009
  27. Johannes SchindelinJan 28, 2009
  28. Stephen HabermanJan 28, 2009
  29. Johannes SchindelinJan 28, 2009
  30. Stephen HabermanJan 28, 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.