Skip to contentSkip to conversation

Change version.sh from last tag and hash to output last commit date and hash

PATCH Superseded Mike Fedyk 1 participant 3 messages May 4, 2010 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Mike Fedyk

author
#0 lore raw

PATCH 1/2 Change version.sh from last tag and hash to output last commit date and hash

The btrfs git repo doesn't have all of the tags from the base 2.6.32 kernel it's currently based upon and the btrfs module is regularly compiled against other kernels so this changes the version to be based upon the date and hash of the latest commit instead which is more relevant to most people testing.

An example version string with this change:
Btrfs 2010-04-06_09:37:47_-0400_9f680ce
---

 fs/btrfs/version.sh |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 fs/btrfs/version.sh
fs/btrfs/version.sh +1 -5
old mode 100644
new mode 100755
index 1ca1952..a4576f2
@@ -12,10 +12,7 @@ which git &> /dev/null
 if [ $? == 0 ]; then
     git branch >& /dev/null
     if [ $? == 0 ]; then
-	    if head=`git rev-parse --verify HEAD 2>/dev/null`; then
-		if tag=`git describe --tags 2>/dev/null`; then
-		    v="$tag"
-		fi
+		v="`git show --format='%ci_%h'|head -n 1|sed 's/[^a-z0-9_-:]/_/ig'`"
 
 		# Are there uncommitted changes?
 		git update-index --refresh --unmerged > /dev/null
@@ -24,7 +21,6 @@ if [ $? == 0 ]; then
 		    | read dummy; then
 		    v="$v"-dirty
 		fi
-	    fi
     fi
 fi
  
author
#1 lore raw

PATCH 2/2 Fix version.sh to work with dash

---

 fs/btrfs/version.h  |    6 +++---
 fs/btrfs/version.sh |   16 ++++++++--------
 2 files changed, 11 insertions(+), 11 deletions(-)
fs/btrfs/version.h +3 -3
index 9bf3946..12f7e5c 100644
@@ -1,4 +1,4 @@
-#ifndef __BTRFS_VERSION_H
-#define __BTRFS_VERSION_H
-#define BTRFS_BUILD_VERSION "Btrfs"
+#ifndef __BUILD_VERSION
+#define __BUILD_VERSION
+#define BTRFS_BUILD_VERSION "Btrfs 2010-05-04_08:46:49_-0700_ea1dcb3-dirty"
 #endif
fs/btrfs/version.sh +8 -8
index a4576f2..0733eef 100755
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/dash
 #
 # determine-version -- report a useful version for releases
 #
@@ -8,10 +8,10 @@
  
 v="v0.16"
 
-which git &> /dev/null
-if [ $? == 0 ]; then
-    git branch >& /dev/null
-    if [ $? == 0 ]; then
+which git 2>&1 > /dev/null
+if [ $? -eq 0 ]; then
+    git branch 2>&1 > /dev/null
+    if [ $? -eq 0 ]; then
 		v="`git show --format='%ci_%h'|head -n 1|sed 's/[^a-z0-9_-:]/_/ig'`"
 
 		# Are there uncommitted changes?
@@ -19,7 +19,7 @@ if [ $? == 0 ]; then
 		if git diff-index --name-only HEAD | \
 		    grep -v "^scripts/package" \
 		    | read dummy; then
-		    v="$v"-dirty
+		    v="${v}-dirty"
 		fi
     fi
 fi
@@ -29,9 +29,9 @@ echo "#define __BUILD_VERSION" >> .build-version.h
 echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-version.h
 echo "#endif" >> .build-version.h
 
-diff -q version.h .build-version.h >& /dev/null
+diff -q version.h .build-version.h 2>&1 > /dev/null
 
-if [ $? == 0 ]; then
+if [ $? -eq 0 ]; then
     rm .build-version.h
     exit 0
 fi
author
#2 lore raw

Re: [PATCH 2/2] Fix version.sh to work with dash

Please ignore this patch, I will resend a fixed one.

On Tue, May 4, 2010 at 9:12 AM, Mike Fedyk <[email protected]> wrote= :

Quoted 12 lines

---

=C2=A0fs/btrfs/version.h =C2=A0| =C2=A0 =C2=A06 +++--- =C2=A0fs/btrfs/version.sh | =C2=A0 16 ++++++++-------- =C2=A02 files changed, 11 insertions(+), 11 deletions(-)

fs/btrfs/version.h +0 -0
index 9bf3946..12f7e5c 100644

fs/btrfs/version.h line 3

Quoted 6 lines
fs/btrfs/version.h +3 -3
@@ -1,4 +1,4 @@
-#ifndef __BTRFS_VERSION_H
-#define __BTRFS_VERSION_H
-#define BTRFS_BUILD_VERSION "Btrfs"
+#ifndef __BUILD_VERSION
+#define __BUILD_VERSION
+#define BTRFS_BUILD_VERSION "Btrfs 2010-05-04_08:46:49_-0700_ea1dcb3=

-dirty"

Quoted 23 lines

=C2=A0#endif

fs/btrfs/version.sh +1 -1
index a4576f2..0733eef 100755
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/dash

=C2=A0#
=C2=A0# determine-version -- report a useful version for releases =C2=A0#

fs/btrfs/version.sh +0 -0
@@ -8,10 +8,10 @@
 

=C2=A0v=3D"v0.16"

fs/btrfs/version.sh +4 -4
-which git &> /dev/null
-if [ $? =3D=3D 0 ]; then
- =C2=A0 =C2=A0git branch >& /dev/null
- =C2=A0 =C2=A0if [ $? =3D=3D 0 ]; then
+which git 2>&1 > /dev/null
+if [ $? -eq 0 ]; then
+ =C2=A0 =C2=A0git branch 2>&1 > /dev/null
+ =C2=A0 =C2=A0if [ $? -eq 0 ]; then
Quoted 1 line

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0v=3D"`git show=

--format=3D'%ci_%h'|head -n 1|sed 's/[^a-z0-9_-:]/_/ig'`"

Quoted 2 lines

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Are there un=

committed changes?

Quoted 2 lines
fs/btrfs/version.sh +0 -0
@@ -19,7 +19,7 @@ if [ $? =3D=3D 0 ]; then

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if git diff-in=

dex --name-only HEAD | \

Quoted 1 line

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=

grep -v "^scripts/package" \

Quoted 1 line

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=

| read dummy; then

Quoted 1 line

- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 v=3D=

"$v"-dirty

Quoted 1 line

+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 v=3D=

"${v}-dirty"

Quoted 5 lines

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fi =C2=A0 =C2=A0 fi
=C2=A0fi

fs/btrfs/version.sh +0 -0
@@ -29,9 +29,9 @@ echo "#define __BUILD_VERSION" >> .build-version.h

=C2=A0echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-versi=

on.h

Quoted 11 lines

=C2=A0echo "#endif" >> .build-version.h

fs/btrfs/version.sh +2 -2
-diff -q version.h .build-version.h >& /dev/null
+diff -q version.h .build-version.h 2>&1 > /dev/null
 
-if [ $? =3D=3D 0 ]; then
+if [ $? -eq 0 ]; then

=C2=A0 =C2=A0 rm .build-version.h
=C2=A0 =C2=A0 exit 0
=C2=A0fi

Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs=

" in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.ht=

ml

Quoted 1 line

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html