All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Dyer <amdyer@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] tools/setlocalversion test for git and .git directory before running commands
Date: Mon, 12 Feb 2007 12:59:37 -0600	[thread overview]
Message-ID: <c166aa9f0702121059m5432481fye1e852daf83151c6@mail.gmail.com> (raw)

This patch adds commands to tools/setlocalversion to test for a git
executable and for a .git directory before running 'git name-rev'.  If
it finds this condition it will return the string '-unknown' to the
calling program.

Running git without a .git directory causes a the build to hang in the
make version step with the git program stopped like so
$ ps -x | grep git
13750 pts/1    S      0:00 /bin/sh /usr/bin/git rev-parse --verify HEAD

Our particular reason for not having a .git directory is that we use
CVS as our standard internal source control.  (Machine gets admin'd by
someone and backed up nightly), so we have a git pull that we
periodically import into CVS as a vendor branch.  I think this patch
would still be useful for vendors who distribute their source tree to
end users who may or may not have git (and those who make tar files
and forget hidden directories ;-)

Signed-off-by: Andrew Dyer <amdyer@gmail.com>
-- 
Hardware, n.:
        The parts of a computer system that can be kicked.
-------------- next part --------------
diff --git a/tools/setlocalversion b/tools/setlocalversion
index 9a23825..f6503fa 100755
--- a/tools/setlocalversion
+++ b/tools/setlocalversion
@@ -9,14 +9,18 @@ usage() {
 cd "${1:-.}" || usage
 
 # Check for git and a git repo.
-if head=`git rev-parse --verify HEAD 2>/dev/null`; then
-	# Do we have an untagged version?
-	if  [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then
-		printf '%s%s' -g `echo "$head" | cut -c1-8`
-	fi
+if ( which git >& /dev/null ) && [ -d .git ]; then
+	if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+		# Do we have an untagged version?
+		if  [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then
+			printf '%s%s' -g `echo "$head" | cut -c1-8`
+		fi
 
-	# Are there uncommitted changes?
-	if git diff-files | read dummy; then
-		printf '%s' -dirty
+		# Are there uncommitted changes?
+		if git diff-files | read dummy; then
+			printf '%s' -dirty
+		fi
 	fi
+else
+	echo -n "-unknown"
 fi

                 reply	other threads:[~2007-02-12 18:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=c166aa9f0702121059m5432481fye1e852daf83151c6@mail.gmail.com \
    --to=amdyer@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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.