All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Santi Béjar" <sbejar@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] git-project-version
Date: Fri, 04 Aug 2006 23:48:25 +0200	[thread overview]
Message-ID: <87bqr0tbo6.fsf@gmail.com> (raw)

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

             reply	other threads:[~2006-08-04 21:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-04 21:48 Santi Béjar [this message]
2006-09-23 23:51 ` [PATCH] git-project-version Petr Baudis
2006-09-24 11:37   ` Santi

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=87bqr0tbo6.fsf@gmail.com \
    --to=sbejar@gmail.com \
    --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 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.