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

[PATCH 1/5] Add test case for basic commit functionality.

From
Kristian Høgsberg <krh@redhat.com>
Date
Jul 30, 2007, 21:28 UTC
Message-ID
<11858309261111-git-send-email-krh@redhat.com>
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
---
 t/t7501-commit.sh |  126 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 126 insertions(+), 0 deletions(-)
 create mode 100644 t/t7501-commit.sh
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
new file mode 100644
index 0000000..eba19da
--- /dev/null
+++ b/t/t7501-commit.sh
@@ -0,0 +1,126 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
+#
+
+# FIXME: Test the various index usages, -i and -o, test reflog,
+# signoff, hooks
+
+test_description='git-commit'
+. ./test-lib.sh
+
+# Pick a date so we get consistent commits. 7/7/07 means good luck!
+export GIT_AUTHOR_DATE="July 7, 2007"
+export GIT_COMMITTER_DATE="July 7, 2007"
+
+echo "bongo bongo" >file
+test_expect_success \
+	"initial status" \
+	"git-add file && \
+	 git-status | grep 'Initial commit'"
+
+test_expect_failure \
+	"fail initial amend" \
+	"git-commit -m initial --amend"
+
+test_expect_success \
+	"initial commit" \
+	"git-commit -m initial"
+
+test_expect_failure \
+	"testing nothing to commit" \
+	"git-commit -m initial"
+
+echo "bongo bongo bongo" >file
+
+test_expect_success \
+	"next commit" \
+	"git-commit -m next -a"
+
+echo "more bongo: bongo bongo bongo bongo" >file
+
+test_expect_failure \
+	"commit message from non-existing file" \
+	"git-commit -F gah -a"
+
+cat >msg <<EOF
+		
+
+  
+Signed-off-by: hula
+EOF
+test_expect_failure \
+	"empty commit message" \
+	"git-commit -F msg -a"
+
+echo "this is the commit message, coming from a file" >msg
+test_expect_success \
+	"commit message from file" \
+	"git-commit -F msg -a"
+
+cat >editor <<\EOF
+#!/bin/sh
+sed -i -e "s/a file/an amend commit/g" $1
+EOF
+chmod 755 editor
+
+test_expect_success \
+	"amend commit" \
+	"VISUAL=./editor git-commit --amend"
+
+echo "enough with the bongos" >file
+test_expect_failure \
+	"passing --amend and -F" \
+	"git-commit -F msg --amend ."
+
+test_expect_success \
+	"using message from other commit" \
+	"git-commit -C HEAD^ ."
+
+cat >editor <<\EOF
+#!/bin/sh
+sed -i -e "s/amend/older/g" $1
+EOF
+chmod 755 editor
+
+echo "hula hula" >file
+test_expect_success \
+	"editing message from other commit" \
+	"VISUAL=./editor git-commit -c HEAD^ -a"
+
+echo "silly new contents" >file
+test_expect_success \
+	"message from stdin" \
+	"echo commit message from stdin | git-commit -F - -a"
+
+echo "gak" >file
+test_expect_success \
+	"overriding author from command line" \
+	"git-commit -m 'author' --author 'Rubber Duck <rduck@convoy.org>' -a"
+
+test_expect_success \
+	"interactive add" \
+	"echo 7 | git-commit --interactive | grep 'What now'"
+
+test_expect_success \
+	"showing committed revisions" \
+	"git-rev-list HEAD >current"
+
+# We could just check the head sha1, but checking each commit makes it
+# easier to isolate bugs.
+
+cat >expected <<\EOF
+b19013342b676054179a1685d62b07f56b354331
+763fd16cd476920986129b09672915be44847d90
+b97ce6debb52cbb541d798ce4c2cefa3c9f20332
+720cebf2e443885c6325a0a602ddb9922376452c
+19db513255cc049feee9c107e60297a48c6b0df4
+4cd324560cd9dcac18f17bac227b17238ad458f9
+821776fc6a0699927268feb5e157d245cdcd102a
+EOF
+
+test_expect_success \
+    'validate git-rev-list output.' \
+    'diff current expected'
+
+test_done
-- 
1.5.2.GIT
Next: Kristian Høgsberg
Message 1 of 19 in “Add test case for basic commit functionality.”
  1. 1/5 Add test case for basic commit functionality.Kristian Høgsberg, Jul 30, 2007
  2. 2/5 Enable wt-status output to a given FILE pointer.Kristian Høgsberg, Jul 30, 2007
  3. 3/5 Add strbuf_printf() to do formatted printing to a strbuf.Kristian Høgsberg, Jul 30, 2007
  4. 4/5 Make builtin-commit-tree use a strbuf instead of hand-rolled realloc buffer.Kristian Høgsberg, Jul 30, 2007
  5. 5/5 Split out the actual commit creation from the option parsing etc.Kristian Høgsberg, Jul 30, 2007
  6. Junio C HamanoJul 31, 2007
  7. Kristian HøgsbergJul 31, 2007
  8. Junio C HamanoJul 31, 2007
  9. Junio C HamanoJul 31, 2007
  10. Kristian HøgsbergJul 31, 2007
  11. Johannes SchindelinJul 31, 2007
  12. Kristian HøgsbergJul 31, 2007
  13. Johannes SchindelinJul 31, 2007
  14. Kristian HøgsbergJul 31, 2007
  15. Add strbuf_printf() to do formatted printing to a strbuf.Kristian Høgsberg, Jul 31, 2007
  16. Junio C HamanoJul 31, 2007
  17. Junio C HamanoJul 31, 2007
  18. Kristian HøgsbergJul 31, 2007
  19. Add test case for basic commit functionality.Kristian Høgsberg, Jul 31, 2007

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.