diff mbox

[ndctl] build: quiet warnings about missing git repository

Message ID 146740856798.33306.12339801003788127221.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams July 1, 2016, 9:29 p.m. UTC
The git-version script auto-appends the commit id, but complains if the
repository is missing.  The complaint is benign, but we should also tag
builds outside of git with a '+' because who knows what changes were
made locally.

Link: https://github.com/pmem/ndctl/issues/5
Reported-by: Yi Zhang <yi.a.zhang@hotmail.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 git-version |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Johannes Thumshirn July 4, 2016, 7:29 a.m. UTC | #1
On Fri, Jul 01, 2016 at 02:29:28PM -0700, Dan Williams wrote:
> The git-version script auto-appends the commit id, but complains if the
> repository is missing.  The complaint is benign, but we should also tag
> builds outside of git with a '+' because who knows what changes were
> made locally.
> 
> Link: https://github.com/pmem/ndctl/issues/5
> Reported-by: Yi Zhang <yi.a.zhang@hotmail.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
diff mbox

Patch

diff --git a/git-version b/git-version
index 3823ee29afaf..9eb8fd654e38 100755
--- a/git-version
+++ b/git-version
@@ -38,9 +38,13 @@  elif test -d ${GIT_DIR:-.git} -o -f .git &&
 	VN=$(echo "$VN" | sed -e 's/-/./g');
 else
 	read COMMIT COMMIT_SUBJECT <<EOF
-	$(git log --oneline --abbrev=8 -n1 HEAD)
+	$(git log --oneline --abbrev=8 -n1 HEAD 2>/dev/null)
 EOF
-	VN="$(dirty ${DEF_VER}.git$COMMIT)"
+	if [ -z $COMMIT ]; then
+		VN="${DEF_VER}+"
+	else
+		VN="$(dirty ${DEF_VER}.git$COMMIT)"
+	fi
 fi
 
 echo $VN