* [PATCH Cogito] Make cg-Xnormid use $_git and $_git_objects
@ 2005-05-29 1:00 Jonas Fonseca
0 siblings, 0 replies; only message in thread
From: Jonas Fonseca @ 2005-05-29 1:00 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
The recently introduced cg-Xnormid accesses .git and .git/objects
directly which is not consistent with the current behavior so source
cg-Xlib to get access to the $_git and $_git_objects variables.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
BTW, both commit-id and tree-id needs to be patched to find the
installed cg-Xnormid.
-normid=$(cg-Xnormid "$id") || exit 1
+normid=$(${COGITO_LIB}cg-Xnormid "$id") || exit 1
--- c8e987e5e4608c1144293cd3f852210d70b572cb/cg-Xnormid (mode:100755)
+++ uncommitted/cg-Xnormid (mode:100755)
@@ -13,16 +13,18 @@
#
# Takes the ID to normalize and returns the normalized ID.
+. ${COGITO_LIB}cg-Xlib
+
id="$1"
if [ ! "$id" ] || [ "$id" = "this" ] || [ "$id" = "HEAD" ]; then
- read id < .git/HEAD
+ read id < "$_git/HEAD"
-elif [ -r ".git/refs/tags/$id" ]; then
- read id < ".git/refs/tags/$id"
+elif [ -r "$_git/refs/tags/$id" ]; then
+ read id < "$_git/refs/tags/$id"
-elif [ -r ".git/refs/heads/$id" ]; then
- read id < ".git/refs/heads/$id"
+elif [ -r "$_git/refs/heads/$id" ]; then
+ read id < "$_git/refs/heads/$id"
# Short id's must be lower case and at least 4 digits.
elif [[ "$id" == [0-9a-z][0-9a-z][0-9a-z][0-9a-z]* ]]; then
@@ -30,10 +32,10 @@
idpost=${id:2}
# Assign array elements to matching names
- idmatch=(.git/objects/$idpref/$idpost*)
+ idmatch=($_git_objects/$idpref/$idpost*)
if [ ${#idmatch[*]} -eq 1 ] && [ -r "$idmatch" ]; then
- id=$idpref${idmatch#.git/objects/$idpref/}
+ id=$idpref${idmatch#$_git_objects/$idpref/}
elif [ ${#idmatch[*]} -gt 1 ]; then
echo "Ambiguous id: $id" >&2
exit 1
@@ -41,7 +43,7 @@
fi
# If we don't have a 40-char ID by now, it's an error
-if [ ${#id} -ne 40 ] || [ ! -f .git/objects/${id:0:2}/${id:2} ]; then
+if [ ${#id} -ne 40 ] || [ ! -f $_git_objects/${id:0:2}/${id:2} ]; then
echo "Invalid id: $id" >&2
exit 1
fi
--
Jonas Fonseca
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-05-29 0:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-29 1:00 [PATCH Cogito] Make cg-Xnormid use $_git and $_git_objects Jonas Fonseca
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).