git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] have commit-id dereference git tags
@ 2005-05-05  7:48 Alexander Beyn
  2005-05-05 21:14 ` Matt Porter
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Beyn @ 2005-05-05  7:48 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] have commit-id dereference git tags
  2005-05-05  7:48 [PATCH] have commit-id dereference git tags Alexander Beyn
@ 2005-05-05 21:14 ` Matt Porter
  0 siblings, 0 replies; 2+ messages in thread
From: Matt Porter @ 2005-05-05 21:14 UTC (permalink / raw)
  To: Alexander Beyn; +Cc: git

On Thu, May 05, 2005 at 12:48:23AM -0700, Alexander Beyn wrote:
> 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.

I like this feature and it works on the Linus tree for me as well.
However, it fails on the cogito tree as follows:

mporter@beef:~/src/cogito$ cg-diff -r git-pasky-0.7:cogito-0.8
.git/objects/c8/3b95297c2a6336c2007548f909769e0862b509: No such file or directory
fatal: git-cat-file c83b95297c2a6336c2007548f909769e0862b509: bad file
Invalid id: c83b95297c2a6336c2007548f909769e0862b509
usage: git-cat-file [-t | tagname] <sha1>
usage: git-cat-file [-t | tagname] <sha1>
Invalid id:

I haven't looked any further at it yet though.

-Matt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-05 21:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-05  7:48 [PATCH] have commit-id dereference git tags Alexander Beyn
2005-05-05 21:14 ` Matt Porter

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).