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

[PATCH] make commit message a little more consistent and conforting

From
Nicolas Pitre <nico@cam.org>
Date
Dec 15, 2006, 04:15 UTC
Message-ID
<Pine.LNX.4.64.0612142307160.18171@xanadu.home>
In-Reply-To
<Pine.LNX.4.64.0612141343200.18171@xanadu.home>

It is nicer to let the user know when a commit succeeded all the time, not only the first time. Also the commit sha1 is much more useful than the tree sha1 in this case.

This patch also introduces a -q switch to supress this message as well as the summary of created/deleted files.

Signed-off-by: Nicolas Pitre <nico@cam.org>
---
diff --git a/Documentation/core-tutorial.txt b/Documentation/core-tutorial.txt
index 47505aa..1c31159 100644
--- a/Documentation/core-tutorial.txt
+++ b/Documentation/core-tutorial.txt
@@ -336,17 +336,9 @@ $ commit=$(echo 'Initial commit' | git-commit-tree $tree)
 $ git-update-ref HEAD $commit
 ------------------------------------------------
 
-which will say:
-
-----------------
-Committing initial tree 8988da15d077d4829fc51d8544c097def6644dbb
-----------------
-
-just to warn you about the fact that it created a totally new commit
-that is not related to anything else. Normally you do this only *once*
-for a project ever, and all later commits will be parented on top of an
-earlier commit, and you'll never see this "Committing initial tree"
-message ever again.
+In this case this creates a totally new commit that is not related to
+anything else. Normally you do this only *once* for a project ever, and
+all later commits will be parented on top of an earlier commit.
 
 Again, normally you'd never actually do this by hand. There is a
 helpful script called `git commit` that will do all of this for you. So
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 97d66ef..0b74cd7 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -113,6 +113,9 @@ but can be used to amend a merge commit.
 	as well.  This is usually not what you want unless you
 	are concluding a conflicted merge.
 
+-q|--quiet::
+	Supress commit summary message.
+
 \--::
 	Do not interpret any more arguments as options.
 
diff --git a/Documentation/tutorial-2.txt b/Documentation/tutorial-2.txt
index 6389de5..8606381 100644
--- a/Documentation/tutorial-2.txt
+++ b/Documentation/tutorial-2.txt
@@ -22,14 +22,14 @@ defaulting to local storage area
 $ echo 'hello world' > file.txt
 $ git add .
 $ git commit -a -m "initial commit"
-Committing initial tree 92b8b694ffb1675e5975148e1121810081dbdffe
+Created initial commit 54196cc2703dc165cbd373a65a4dcf22d50ae7f7
  create mode 100644 file.txt
 $ echo 'hello world!' >file.txt
 $ git commit -a -m "add emphasis"
+Created commit c4d59f390b9cfd4318117afde11d601c1085f241
 ------------------------------------------------
 
-What are the 40 digits of hex that git responded to the first commit
-with?
+What are the 40 digits of hex that git responded to the commit with?
 
 We saw in part one of the tutorial that commits have names like this.
 It turns out that every object in the git history is stored under
@@ -39,13 +39,25 @@ the same data twice (since identical data is given an identical SHA1
 name), and that the contents of a git object will never change (since
 that would change the object's name as well).
 
+It is expected that the content of the commit object you created while
+following the example above generates a different SHA1 hash than
+the one shown above because the commit object records the time when
+it was created and the name of the person performing the commit.
+
 We can ask git about this particular object with the cat-file
-command--just cut-and-paste from the reply to the initial commit, to
-save yourself typing all 40 hex digits:
+command. Don't copy the 40 hex digits from this example but use those
+from your own version. Note that you can shorten it to only a few
+characters to save yourself typing all 40 hex digits:
 
 ------------------------------------------------
-$ git cat-file -t 92b8b694ffb1675e5975148e1121810081dbdffe
-tree
+$ git-cat-file -t 54196cc2
+commit
+$ git-cat-file commit 54196cc2
+tree 92b8b694ffb1675e5975148e1121810081dbdffe
+author J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500
+committer J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500
+
+initial commit
 ------------------------------------------------
 
 A tree can refer to one or more "blob" objects, each corresponding to
@@ -102,8 +114,7 @@ $ find .git/objects/
 
 and the contents of these files is just the compressed data plus a
 header identifying their length and their type.  The type is either a
-blob, a tree, a commit, or a tag.  We've seen a blob and a tree now,
-so next we should look at a commit.
+blob, a tree, a commit, or a tag.
 
 The simplest commit to find is the HEAD commit, which we can find
 from .git/HEAD:
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index e2e690a..856f3cd 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -107,8 +107,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 		if (new_parent(parents))
 			parents++;
 	}
-	if (!parents)
-		fprintf(stderr, "Committing initial tree %s\n", argv[1]);
 
 	init_buffer(&buffer, &size);
 	add_buffer(&buffer, &size, "tree %s\n", sha1_to_hex(tree_sha1));
diff --git a/git-commit.sh b/git-commit.sh
index 05828bb..395bcd2 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -80,6 +80,7 @@ no_edit=
 log_given=
 log_message=
 verify=t
+quiet=
 verbose=
 signoff=
 force_author=
@@ -241,6 +242,10 @@ $1"
 		signoff=t
 		shift
 		;;
+	-q|--q|--qu|--qui|--quie|--quiet)
+		quiet=t
+		shift
+		;;
 	-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
 		verbose=t
 		shift
@@ -615,11 +620,17 @@ then
 	git-rerere
 fi
 
-if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0
+if test "$ret" = 0
 then
-	"$GIT_DIR"/hooks/post-commit
+	if test -x "$GIT_DIR"/hooks/post-commit 
+	then
+		"$GIT_DIR"/hooks/post-commit
+	fi
+	if test -z "$quiet"
+	then
+		echo "Created${initial_commit:+ initial} commit $commit"
+		git-diff-tree --summary --root --no-commit-id HEAD
+	fi
 fi
 
-test "$ret" = 0 && git-diff-tree --summary --root --no-commit-id HEAD
-
Previous: Nicolas PitreNext: Shawn Pearce
Message 48 of 102 in “What's in git.git (stable)”
  1. Junio C HamanoDec 13, 2006
  2. Andy ParkinsDec 13, 2006
  3. Jakub NarebskiDec 13, 2006
  4. Andy ParkinsDec 14, 2006
  5. Shawn PearceDec 14, 2006
  6. Andy ParkinsDec 14, 2006
  7. Nicolas PitreDec 14, 2006
  8. Jakub NarebskiDec 15, 2006
  9. Junio C HamanoDec 13, 2006
  10. Peter BaumannDec 13, 2006
  11. Johannes SchindelinDec 14, 2006
  12. Nicolas PitreDec 14, 2006
  13. Junio C HamanoDec 14, 2006
  14. git-show, was Re: What's in git.git (stable)Johannes Schindelin, Dec 14, 2006
  15. Junio C HamanoDec 14, 2006
  16. Johannes SchindelinDec 14, 2006
  17. Andreas EricssonDec 14, 2006
  18. Jakub NarebskiDec 15, 2006
  19. Andy ParkinsDec 14, 2006
  20. Junio C HamanoDec 14, 2006
  21. Andy ParkinsDec 14, 2006
  22. Shawn PearceDec 14, 2006
  23. Carl WorthDec 14, 2006
  24. Shawn PearceDec 14, 2006
  25. reflog by default?, was Re: What's in git.git (stable)Johannes Schindelin, Dec 14, 2006
  26. Nicolas PitreDec 14, 2006
  27. Junio C HamanoDec 14, 2006
  28. Shawn PearceDec 14, 2006
  29. Nicolas PitreDec 14, 2006
  30. Andreas EricssonDec 14, 2006
  31. Junio C HamanoDec 15, 2006
  32. Shawn PearceDec 16, 2006
  33. Nicolas PitreDec 14, 2006
  34. Junio C HamanoDec 14, 2006
  35. Enable reflogs by default in all repositories.Shawn O. Pearce, Dec 14, 2006
  36. Nicolas PitreDec 14, 2006
  37. Junio C HamanoDec 14, 2006
  38. Andy ParkinsDec 14, 2006
  39. Jakub NarebskiDec 15, 2006
  40. Jakub NarebskiDec 15, 2006
  41. Nicolas PitreDec 15, 2006
  42. Andreas EricssonDec 15, 2006
  43. Nicolas PitreDec 15, 2006
  44. Shawn PearceDec 15, 2006
  45. Andreas EricssonDec 15, 2006
  46. Johannes SchindelinDec 15, 2006
  47. Nicolas PitreDec 15, 2006
  48. make commit message a little more consistent and confortingNicolas Pitre, Dec 15, 2006
  49. Shawn PearceDec 15, 2006
  50. Andreas EricssonDec 15, 2006
  51. Shawn PearceDec 15, 2006
  52. Andreas EricssonDec 15, 2006
  53. Shawn PearceDec 15, 2006
  54. Andreas EricssonDec 15, 2006
  55. Nicolas PitreDec 15, 2006
  56. Junio C HamanoDec 15, 2006
  57. Nicolas PitreDec 15, 2006
  58. Shawn PearceDec 15, 2006
  59. Junio C HamanoDec 15, 2006
  60. Nicolas PitreDec 15, 2006
  61. Junio C HamanoDec 16, 2006
  62. Junio C HamanoDec 14, 2006
  63. Andy ParkinsDec 14, 2006
  64. Junio C HamanoDec 14, 2006
  65. Andy ParkinsDec 15, 2006
  66. Raimund BauerDec 15, 2006
  67. Junio C HamanoDec 15, 2006
  68. Carl WorthDec 15, 2006
  69. Johannes SchindelinDec 14, 2006
  70. Johannes SchindelinDec 14, 2006
  71. Andy ParkinsDec 14, 2006
  72. Johannes SchindelinDec 14, 2006
  73. Andy ParkinsDec 14, 2006
  74. Johannes SchindelinDec 14, 2006
  75. Andy ParkinsDec 14, 2006
  76. Shawn PearceDec 14, 2006
  77. Andy ParkinsDec 14, 2006
  78. Nicolas PitreDec 14, 2006
  79. Andy ParkinsDec 14, 2006
  80. Shawn PearceDec 14, 2006
  81. Jakub NarebskiDec 15, 2006
  82. Junio C HamanoDec 15, 2006
  83. Jakub NarebskiDec 15, 2006
  84. Johannes SchindelinDec 15, 2006
  85. Junio C HamanoDec 15, 2006
  86. Johannes SchindelinDec 16, 2006
  87. Junio C HamanoDec 16, 2006
  88. Steven GrimmDec 16, 2006
  89. Junio C HamanoDec 16, 2006
  90. Junio C HamanoDec 15, 2006
  91. git-clone: use wildcard specification for tracking branchesJunio C Hamano, Dec 16, 2006
  92. git-pull: refuse default merge without branch.*.mergeJunio C Hamano, Dec 16, 2006
  93. git-clone: lose the artificial "first" fetch refspecJunio C Hamano, Dec 16, 2006
  94. git-clone: lose the traditional 'no-separate-remote' layoutJunio C Hamano, Dec 16, 2006
  95. Linus TorvaldsDec 16, 2006
  96. Johannes SchindelinDec 16, 2006
  97. Linus TorvaldsDec 16, 2006
  98. Jakub NarebskiDec 16, 2006
  99. Junio C HamanoDec 16, 2006
  100. Document git-merge-fileJohannes Schindelin, Dec 16, 2006
  101. Jakub NarebskiDec 16, 2006
  102. Junio C HamanoDec 16, 2006

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.