git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Beyn <malex-git@fatelectrons.org>
To: git@vger.kernel.org
Subject: [PATCH] have commit-id dereference git tags
Date: Thu, 5 May 2005 00:48:23 -0700	[thread overview]
Message-ID: <20050505074823.GA9075@fatelectrons.org> (raw)

With this patch, if commit-id is passed a git tag, it will check to see
if the tag points to a commit. If it does, commit-id will return that
commit's id.

I'm not sure if this is the proper place to handle git tags, but it does
make things like "cg-diff -r v2.6.12-rc2:v2.6.12-rc3" work in the Linus
kernel tree. I've not noticed any problems this introduces, but I didn't 
do a thorough check.

Signed-Off-By: Alexander Beyn <malex-git@fatelectrons.org>


Index: commit-id
===================================================================
--- 6a20fd05c468097d5a5a47cd37b41581c963cf63/commit-id  (mode:100755 sha1:daf0ea1e35f1bee22eb4c4771495b2212d15f4e7)
+++ 66fded2e9d931ecc8b03aa282a7eb9559955c172/commit-id  (mode:100755 sha1:978c3ffeb072422436af7af1ad4a8de0e91c9632)
@@ -32,7 +32,15 @@
 	exit 1
 fi
 
-if [ "$(git-cat-file -t "$id")" != "commit" ]; then
+type="$(git-cat-file -t "$id")"
+
+if [ "$type" = "tag" ]; then
+	id=$(git-cat-file tag "$id" | egrep -m 1 "^object $SHA1")
+	id="${id#object }"
+	type="$(git-cat-file -t "$id")"
+fi
+
+if [ "$type" != "commit" ]; then
 	echo "Invalid id: $id" >&2
 	exit 1
 fi

             reply	other threads:[~2005-05-05  7:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-05  7:48 Alexander Beyn [this message]
2005-05-05 21:14 ` [PATCH] have commit-id dereference git tags Matt Porter

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=20050505074823.GA9075@fatelectrons.org \
    --to=malex-git@fatelectrons.org \
    --cc=git@vger.kernel.org \
    /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 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).