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

Re: PATCH[4/4]: Allow tree-id to return the ID of a tree object

From
PPPhilip Pokorny <ppokorny@mindspring.com>
Date
Apr 28, 2005, 07:17 UTC
Message-ID
<42708E26.2090803@mindspring.com>
In-Reply-To
<20050427232223.GM22956@pasky.ji.cz>

Convert parent-id to similar style and function as the new commit-id and tree-id.

NOTE: parent-id uses commit-id rather than cg-Xnormid directly
Signed-off-by: Philip Pokorny <ppokorny@mindspring.com>
Index: parent-id
===================================================================
--- 6ad600e20c89323c1d3049f75b8ca9b0a2d72167/parent-id  (mode:100755 sha1:f35877a6aa5b68d2fb4a388dcfa9b3e64262604e)
+++ uncommitted/parent-id  (mode:100775)
@@ -1,12 +1,19 @@
 #!/usr/bin/env bash
 #
 # Get ID of parent commit to a given revision or HEAD.
+# NOTE: will return multiple SHA1s if ID is a commit with multiple parents
+#
 # Copyright (c) Petr Baudis, 2005
 #
-# Takes ID of the current commit, defaults to HEAD.
 
-PARENT="^parent [A-Za-z0-9]{40}$"
+# Save for later error message
+orig="$1"
 
-id=$(commit-id $1) || exit 1
+# Normalize to SHA1 form and verify its a commit
+id=$(commit-id "$1")
+if [ ! "$id" ]; then
+	# commit-id already reported the error
+	exit 1
+fi
 
-cat-file commit $id | egrep "$PARENT" | cut -d ' ' -f 2
+cat-file commit $id | awk '/^parent/{print $2};/^$/{exit}'
Previous: Philip Pokorny
Message 8 of 8 in “PATCH: Allow tree-id to return the ID of a tree object”
  1. Philip PokornyApr 27, 2005
  2. Petr BaudisApr 27, 2005
  3. Philip PokornyApr 28, 2005
  4. Philip PokornyApr 28, 2005
  5. Philip PokornyApr 28, 2005
  6. Philip PokornyMay 2, 2005
  7. Philip PokornyApr 28, 2005
  8. Philip PokornyApr 28, 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.