From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Dyer Date: Mon, 12 Feb 2007 12:59:37 -0600 Subject: [U-Boot-Users] [PATCH] tools/setlocalversion test for git and .git directory before running commands Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 -- 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