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

[PATCH 1/3] hooks/post-receive-email: use plumbing instead of git log/show

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 2, 2013, 23:22 UTC
Message-ID
<20130802232208.GC2963@elie.Belkin>
In-Reply-To
<20130802232118.GB2963@elie.Belkin>

This way the hook doesn't have to keep being tweaked as porcelain learns new features like color and pagination.

While at it, replace the "git rev-list | git shortlog" idiom with plain "git shortlog" for simplicity.

Except for depending less on the value of settings like '[log] abbrevCommit', no change in output intended.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 contrib/hooks/post-receive-email | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 15311502..72084511 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -471,7 +471,7 @@ generate_delete_branch_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git show -s --pretty=oneline $oldrev
+	git diff-tree -s --always --pretty=oneline $oldrev
 	echo $LOGEND
 }
 
@@ -547,11 +547,11 @@ generate_atag_email()
 		# performed on them
 		if [ -n "$prevtag" ]; then
 			# Show changes since the previous release
-			git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
+			git shortlog "$prevtag..$newrev"
 		else
 			# No previous tag, show all the changes since time
 			# began
-			git rev-list --pretty=short $newrev | git shortlog
+			git shortlog $newrev
 		fi
 		;;
 	*)
@@ -571,7 +571,7 @@ generate_delete_atag_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git show -s --pretty=oneline $oldrev
+	git diff-tree -s --always --pretty=oneline $oldrev
 	echo $LOGEND
 }
 
@@ -617,7 +617,7 @@ generate_general_email()
 	echo ""
 	if [ "$newrev_type" = "commit" ]; then
 		echo $LOGBEGIN
-		git show --no-color --root -s --pretty=medium $newrev
+		git diff-tree -s --always --pretty=medium $newrev
 		echo $LOGEND
 	else
 		# What can we do here?  The tag marks an object that is not
@@ -636,7 +636,7 @@ generate_delete_general_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git show -s --pretty=oneline $oldrev
+	git diff-tree -s --always --pretty=oneline $oldrev
 	echo $LOGEND
 }
 
-- 
1.8.4.rc1
Previous: Jonathan NiederNext: Jonathan Nieder
Message 2 of 7 in “post-receive-email: explicitly set Content-Type header”
  1. 0/3 post-receive-email: explicitly set Content-Type headerJonathan Nieder, Aug 2, 2013
  2. 1/3 hooks/post-receive-email: use plumbing instead of git log/showJonathan Nieder, Aug 2, 2013
  3. 2/3 hooks/post-receive-email: force log messages in UTF-8Jonathan Nieder, Aug 2, 2013
  4. Alexey ShumkinAug 4, 2013
  5. Jonathan NiederAug 4, 2013
  6. Alexey ShumkinAug 5, 2013
  7. 3/3 hooks/post-receive-email: set declared encoding to utf-8Jonathan Nieder, Aug 2, 2013

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.