From: Philip Pokorny <ppokorny@mindspring.com>
To: Petr Baudis <pasky@ucw.cz>
Cc: git@vger.kernel.org
Subject: Re: PATCH[1/4]: Allow tree-id to return the ID of a tree object
Date: Thu, 28 Apr 2005 00:14:13 -0700 [thread overview]
Message-ID: <42708D45.8070303@mindspring.com> (raw)
In-Reply-To: <20050427232223.GM22956@pasky.ji.cz>
[-- Attachment #1: Type: text/plain, Size: 119 bytes --]
Patch to re-introduce cg-Xnormid for common ID normalizing.
Signed-off-by: Philip Pokorny <ppokorny@mindspring.com>
[-- Attachment #2: cogito-0.8-cg-Xnormid.patch --]
[-- Type: text/plain, Size: 1962 bytes --]
Index: cg-Xnormid
===================================================================
--- /dev/null (tree:6ad600e20c89323c1d3049f75b8ca9b0a2d72167)
+++ uncommitted/cg-Xnormid (mode:100755 sha1:6dc089c8d571f330e2e01d96f79616d6146840ee)
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+#
+# Normalize an ID to an SHA1 hash value
+# Strings resolve in order:
+# NULL, this, HEAD => .git/HEAD
+# <tags>
+# <heads>
+# short SHA1 (4 or more hex digits)
+#
+# Copyright (c) Philip Pokorny, 2005
+
+id="$1"
+
+if [ ! "$id" ] || [ "$id" = "this" ] || [ "$id" = "HEAD" ]; then
+ read id < .git/HEAD
+
+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"
+
+# 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
+ idpost=${id#??}
+ idpref=${id%$idpost}
+
+ # Assign array elements to matching names
+ idmatch=(.git/objects/$idpref/$idpost*)
+
+ if [ ${#idmatch[*]} -eq 1 ] && [ -r "$idmatch" ]; then
+ id=$idpref${idmatch#.git/objects/$idpref/}
+ elif [ ${#idmatch[*]} -gt 1 ]; then
+ echo "Ambiguous id: $id" >&2
+ exit 1
+ fi
+fi
+
+# FIXME? Should we verify the existance of the ID in the object cache?
+
+# If we don't have a 40-char ID by now, it's an error
+if [ ${#id} -ne 40 ]; then
+ echo "Invalid id: $id" >&2
+ exit 1
+fi
+
+echo $id
Index: Makefile
===================================================================
--- 6ad600e20c89323c1d3049f75b8ca9b0a2d72167/Makefile (mode:100644 sha1:d73bea1cbb9451a89b03d6066bf2ed7fec32fd31)
+++ uncommitted/Makefile (mode:100664)
@@ -44,7 +44,7 @@
cg-add cg-admin-lsobj cg-cancel cg-clone cg-commit cg-diff \
cg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch \
cg-patch cg-pull cg-branch-add cg-branch-ls cg-rm cg-seek cg-status \
- cg-tag cg-update cg-Xlib
+ cg-tag cg-update cg-Xlib cg-Xnormid
COMMON= read-cache.o
next prev parent reply other threads:[~2005-04-28 7:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-27 16:20 PATCH: Allow tree-id to return the ID of a tree object Philip Pokorny
2005-04-27 23:22 ` Petr Baudis
2005-04-28 7:11 ` PATCH[0/4]: " Philip Pokorny
2005-04-28 7:14 ` Philip Pokorny [this message]
2005-04-28 7:15 ` PATCH[2/4]: " Philip Pokorny
2005-05-02 5:46 ` Philip Pokorny
2005-04-28 7:16 ` PATCH[3/4]: " Philip Pokorny
2005-04-28 7:17 ` PATCH[4/4]: " Philip Pokorny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42708D45.8070303@mindspring.com \
--to=ppokorny@mindspring.com \
--cc=git@vger.kernel.org \
--cc=pasky@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.