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

[PATCH 3/8] cogito: "cg-object-id -p" should separate its output by newlines

From
PRPavel Roskin <proski@gnu.org>
Date
Sep 20, 2005, 02:14 UTC
Message-ID
<1127182496.31115.21.camel@dv>
"cg-object-id -p" should separate its output by newlines.

If there are several parents, they should be separated by newlines, not by spaces. That's what cg-diff expects.

diff --git a/cg-Xnormid b/cg-Xnormid
--- a/cg-Xnormid
+++ b/cg-Xnormid
@@ -17,11 +17,11 @@
 id="$1"
 
 if [ "${id:(-1):1}" = "^" ]; then
 	# find parent
 	id=$(cg-object-id "${id%^}") || exit 1
-	git-cat-file commit "$id" | awk '/^parent/{print $2," "};/^$/{exit}' || exit 1
+	git-cat-file commit "$id" | awk '/^parent/{print $2};/^$/{exit}' || exit 1
 	exit
 fi
 
 if [ ! "$id" ] || [ "$id" = "this" ] || [ "$id" = "HEAD" ]; then
 	read id < "$_git/HEAD"
diff --git a/cg-object-id b/cg-object-id
--- a/cg-object-id
+++ b/cg-object-id
@@ -9,12 +9,12 @@
 #
 # OPTIONS
 # -------
 # -p::
 #	Get ID of parent commit(s) to a given revision or HEAD.
-#	NOTE: Multiple SHA1s will be returned for commits with multiple
-#	parents.
+#	NOTE: Multiple SHA1s separated by newlines will be returned for
+#	commits with multiple parents.
 #
 # -t::
 #	Get ID of tree associated with given commit or HEAD.
 #
 # OBJECT_ID::
@@ -53,11 +53,11 @@ if [ "$show_parent" ]; then
 fi
 
 normid=$(. ${COGITO_LIB}cg-Xnormid "$id") || exit 1
 
 if [ "$show_parent" ]; then
-	echo ${normid% *}
+	echo "${normid% *}"
 	exit 0
 fi
 
 type=${normid#* }
 normid=${normid% *}
-- 
Regards,
Pavel Roskin
Message 1 of 1 in “cogito: "cg-object-id -p" should separate its output by newlines”
  1. 3/8 cogito: "cg-object-id -p" should separate its output by newlinesPavel Roskin, Sep 20, 2005

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.