All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] tools/setlocalversion test for git and .git directory before running commands
@ 2007-02-12 18:59 Andrew Dyer
  0 siblings, 0 replies; only message in thread
From: Andrew Dyer @ 2007-02-12 18:59 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-02-12 18:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-12 18:59 [U-Boot-Users] [PATCH] tools/setlocalversion test for git and .git directory before running commands Andrew Dyer

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.