Skip to contentSkip to conversation

commit-id, tree-id fail on tags

PATCH New Pavel Roskin 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 commit-id, tree-id fail on tags

Hello!

Tag names don't work with current cogito because commit-id and tree-id don't parse the cg-Xnormid output properly.

Namely, if $type is empty (which is the case for tags), $normid is used before the trailing space is stripped from it.

commit-id +2 -1
@@ -9,8 +9,9 @@
 
 id="$1"
 normid=$(. ${COGITO_LIB}cg-Xnormid "$id") || exit 1
-type=${normid#* }; [ "$type" ] || type=$(git-cat-file -t "$normid")
+type=${normid#* }
 normid=${normid% *}
+[ "$type" ] || type=$(git-cat-file -t "$normid")
 
 if [ "$type" != "commit" ]; then
 	echo "Invalid commit id: $normid" >&2
tree-id +2 -1
@@ -7,8 +7,9 @@
 
 id="$1"
 normid=$(. ${COGITO_LIB}cg-Xnormid "$id") || exit 1
-type=${normid#* }; [ "$type" ] || type=$(git-cat-file -t "$normid")
+type=${normid#* }
 normid=${normid% *}
+[ "$type" ] || type=$(git-cat-file -t "$normid")
 
 if [ "$type" = "commit" ]; then
 	normid=$(git-cat-file commit "$normid" | sed -e 's/tree //;q')
Signature · 2 lines
Regards,
Pavel Roskin