git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-project-version
@ 2006-08-04 21:48 Santi Béjar
  2006-09-23 23:51 ` Petr Baudis
  0 siblings, 1 reply; 3+ messages in thread
From: Santi Béjar @ 2006-08-04 21:48 UTC (permalink / raw)
  To: Git Mailing List

Introduce an easy way for projects to get its git version. This is
something that other projects using git would like to do, and we don't
want them all reinventing the wheel.

Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
Hi *,

I would prefer an output with an explicit git string as:

v1.4.2-rc3-git46faaaf

Also I would prefer the dirty state with an ending M as in:

v1.4.2-rc3-git46faaaf-M

to use the same letter of the diff family.

   Santi

 Makefile               |    3 ++-
 git-project-version.sh |    9 +++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index d662bd6..7c4e360 100644
--- a/Makefile
+++ b/Makefile
@@ -169,7 +169,8 @@ SCRIPT_SH = \
 	git-applymbox.sh git-applypatch.sh git-am.sh \
 	git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
 	git-merge-resolve.sh git-merge-ours.sh \
-	git-lost-found.sh git-quiltimport.sh
+	git-lost-found.sh git-quiltimport.sh \
+	git-project-version.sh
 
 SCRIPT_PERL = \
 	git-archimport.perl git-cvsimport.perl git-relink.perl \
diff --git a/git-project-version.sh b/git-project-version.sh
new file mode 100755
index 0000000..88b21fa
--- /dev/null
+++ b/git-project-version.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# First try git-describe.
+VN=$(git describe --abbrev=4 HEAD 2>/dev/null) ||
+VN=$(git rev-parse --short HEAD | sed -e 's/^/g/')
+
+dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
+[ "$dirty" ] && VN="$VN-dirty"
+
+echo $VN
-- 
1.4.2.rc3.g3f0a-dirty

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

* Re: [PATCH] git-project-version
  2006-08-04 21:48 [PATCH] git-project-version Santi Béjar
@ 2006-09-23 23:51 ` Petr Baudis
  2006-09-24 11:37   ` Santi
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Baudis @ 2006-09-23 23:51 UTC (permalink / raw)
  To: Santi Béjar; +Cc: Git Mailing List

Dear diary, on Fri, Aug 04, 2006 at 11:48:25PM CEST, I got a letter
where Santi Béjar <sbejar@gmail.com> said that...
> Introduce an easy way for projects to get its git version. This is
> something that other projects using git would like to do, and we don't
> want them all reinventing the wheel.
> 
> Signed-off-by: Santi Béjar <sbejar@gmail.com>

Perhaps it would be more useful to have a flag for git-describe to
describe not the (HEAD) commit but your working copy (thus HEAD + check
for the dirtyness).

-- 
				Petr "Pasky the Hater of Too Many
					Commands" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)

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

* Re: [PATCH] git-project-version
  2006-09-23 23:51 ` Petr Baudis
@ 2006-09-24 11:37   ` Santi
  0 siblings, 0 replies; 3+ messages in thread
From: Santi @ 2006-09-24 11:37 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Git Mailing List

2006/9/24, Petr Baudis <pasky@suse.cz>:
> Dear diary, on Fri, Aug 04, 2006 at 11:48:25PM CEST, I got a letter
> where Santi Béjar <sbejar@gmail.com> said that...
> > Introduce an easy way for projects to get its git version. This is
> > something that other projects using git would like to do, and we don't
> > want them all reinventing the wheel.
> >
> > Signed-off-by: Santi Béjar <sbejar@gmail.com>
>
> Perhaps it would be more useful to have a flag for git-describe to
> describe not the (HEAD) commit but your working copy (thus HEAD + check
> for the dirtyness).
>

Sure.

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

end of thread, other threads:[~2006-09-24 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-04 21:48 [PATCH] git-project-version Santi Béjar
2006-09-23 23:51 ` Petr Baudis
2006-09-24 11:37   ` Santi

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