mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][RFC] Kconfig: show git branch name in LOCALVERSION_AUTO
@ 2008-01-21 12:02 Richard Kennedy
  2008-01-24 21:23 ` Sam Ravnborg
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Kennedy @ 2008-01-21 12:02 UTC (permalink / raw)
  To: sam; +Cc: linux-kbuild, lkml

config option to add the git branch name to the automatically generated
version string.

If the current git branch name is not "master" then add the name to the
LOCALVERSION_AUTO version string.
The format will then be -<name>-gxxxxxxxx

Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
---
 Makefile                |    3 ++-
 init/Kconfig            |   10 ++++++++++
 scripts/setlocalversion |    9 ++++++++-
 3 files changed, 20 insertions(+), 2 deletions(-)

I added this to automatically track which git branch I was on, because I
kept forgetting to change the version string manually. Maybe it will be 
helpful to other people too.

Patch is against v2.6.24-rc8.

comments /suggestions ?

Thanks
Richard


diff --git a/Makefile b/Makefile
index 713f685..ea01118 100644
--- a/Makefile
+++ b/Makefile
@@ -867,7 +867,8 @@ localver = $(subst $(space),, $(string) \
 # checks as needed.
 ifdef CONFIG_LOCALVERSION_AUTO
 	_localver-auto = $(shell $(CONFIG_SHELL) \
-	                  $(srctree)/scripts/setlocalversion $(srctree))
+	                  $(srctree)/scripts/setlocalversion $(srctree) \
+			  $(CONFIG_LOCALVERSION_BRANCH) )
 	localver-auto  = $(LOCALVERSION)$(_localver-auto)
 endif
 
diff --git a/init/Kconfig b/init/Kconfig
index b9d11a8..fafb7e5 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -92,6 +92,16 @@ config LOCALVERSION_AUTO
 
 	  which is done within the script "scripts/setlocalversion".)
 
+config LOCALVERSION_BRANCH
+	bool "Automatically add branch name to the version string"
+	default n
+	depends on LOCALVERSION_AUTO
+	help
+	  If the current git branch name is not "master" then add the name to
+	  the LOCALVERSION_AUTO version string.
+	  The format will then be -<name>-gxxxxxxxx
+	  see the help for LOCALVERSION_AUTO for more details
+
 config SWAP
 	bool "Support for paging of anonymous memory (swap)"
 	depends on MMU && BLOCK
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 82e4993..1fffa2d 100644
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -2,7 +2,7 @@
 # Print additional version information for non-release trees.
 
 usage() {
-	echo "Usage: $0 [srctree]" >&2
+	echo "Usage: $0 [srctree] [show_branch]" >&2
 	exit 1
 }
 
@@ -10,6 +10,13 @@ cd "${1:-.}" || usage
 
 # Check for git and a git repo.
 if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+
+	if [[ $2 == "y" ]]; then
+		name=`git branch | grep -E "^[*]" | cut -d " " -sf 2`
+		if [[ $name != "master" ]]; then
+			printf '%s' "-$name"
+		fi
+	fi
 	# Do we have an untagged version?
 	if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
 		printf '%s%s' -g `echo "$head" | cut -c1-8`
-- 
1.5.3.7




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][RFC] Kconfig: show git branch name in LOCALVERSION_AUTO
  2008-01-21 12:02 [PATCH][RFC] Kconfig: show git branch name in LOCALVERSION_AUTO Richard Kennedy
@ 2008-01-24 21:23 ` Sam Ravnborg
  2008-01-27 17:38   ` Richard Kennedy
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2008-01-24 21:23 UTC (permalink / raw)
  To: Richard Kennedy; +Cc: linux-kbuild, lkml

On Mon, Jan 21, 2008 at 12:02:13PM +0000, Richard Kennedy wrote:
> config option to add the git branch name to the automatically generated
> version string.
> 
> If the current git branch name is not "master" then add the name to the
> LOCALVERSION_AUTO version string.
> The format will then be -<name>-gxxxxxxxx

PAtch does no longer apply to kbuild.git.
Please update either on top of kbuild.git or
when kbuild.git is merged and then resubmit.

Thanks,
	Sam

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][RFC] Kconfig: show git branch name in LOCALVERSION_AUTO
  2008-01-24 21:23 ` Sam Ravnborg
@ 2008-01-27 17:38   ` Richard Kennedy
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Kennedy @ 2008-01-27 17:38 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kbuild, lkml

On Thu, 2008-01-24 at 22:23 +0100, Sam Ravnborg wrote:
> On Mon, Jan 21, 2008 at 12:02:13PM +0000, Richard Kennedy wrote:
> > config option to add the git branch name to the automatically generated
> > version string.
> > 
> > If the current git branch name is not "master" then add the name to the
> > LOCALVERSION_AUTO version string.
> > The format will then be -<name>-gxxxxxxxx
> 
> PAtch does no longer apply to kbuild.git.
> Please update either on top of kbuild.git or
> when kbuild.git is merged and then resubmit.
> 
> Thanks,
> 	Sam
config option to add the git branch name to the automatically generated
version string.

If the current git branch name is not "master" then add the name to the
LOCALVERSION_AUTO version string.
The format will then be -<name>-gxxxxxxxx

Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
---
Sam,
here's a patch against the latest kbuild.git.
[ if I got the git remote thing right ;) ]

Richard


diff --git a/Makefile b/Makefile
index ae80713..84eddba 100644
--- a/Makefile
+++ b/Makefile
@@ -874,7 +874,8 @@ localver = $(subst $(space),, $(string) \
 # checks as needed.
 ifdef CONFIG_LOCALVERSION_AUTO
 	_localver-auto = $(shell $(CONFIG_SHELL) \
-	                  $(srctree)/scripts/setlocalversion $(srctree))
+	                  $(srctree)/scripts/setlocalversion $(srctree) \
+				$(CONFIG_LOCALVERSION_BRANCH))
 	localver-auto  = $(LOCALVERSION)$(_localver-auto)
 endif
 
diff --git a/init/Kconfig b/init/Kconfig
index e7f2f41..bfaadc7 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -100,6 +100,16 @@ config LOCALVERSION_AUTO
 
 	  which is done within the script "scripts/setlocalversion".)
 
+config LOCALVERSION_BRANCH
+	bool "Automatically add branch name to the version string"
+	default n
+	depends on LOCALVERSION_AUTO
+	help
+	  If the current git branch name is not "master" then add the name to
+	  the LOCALVERSION_AUTO version string.
+	  The format will then be -<name>-gxxxxxxxx
+	  see the help for LOCALVERSION_AUTO for more details
+
 config SWAP
 	bool "Support for paging of anonymous memory (swap)"
 	depends on MMU && BLOCK
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 52f032e..f38e3c4 100644
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -2,7 +2,7 @@
 # Print additional version information for non-release trees.
 
 usage() {
-	echo "Usage: $0 [srctree]" >&2
+	echo "Usage: $0 [srctree] [show-branch]" >&2
 	exit 1
 }
 
@@ -10,6 +10,13 @@ cd "${1:-.}" || usage
 
 # Check for git and a git repo.
 if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+	# show the branch name?
+    	if [[ $2 == "y" ]]; then
+		name=`git branch | grep -E "^[*]" | cut -d " " -sf 2`
+		if [[ $name != "master" ]]; then
+			printf '%s' "-$name"
+		fi
+	fi
 	# Do we have an untagged version?
 	if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
 	        git describe | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
-- 
1.5.3.7




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-27 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-21 12:02 [PATCH][RFC] Kconfig: show git branch name in LOCALVERSION_AUTO Richard Kennedy
2008-01-24 21:23 ` Sam Ravnborg
2008-01-27 17:38   ` Richard Kennedy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome