public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] kconfig: place git SHA1 in .config output if in git tree
@ 2010-03-01  4:22 Paul E. McKenney
  2010-03-01  8:34 ` Ingo Molnar
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Paul E. McKenney @ 2010-03-01  4:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: zippel, mingo, akpm, torvalds

This patch appends the SHA1 hash of the current git tree to the
kernel version line, or "[Not git tree]" if run from a non-git tree.
Uses "git log" to print the hash.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---

 confdata.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c4dec80..4bd7842 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -399,10 +399,11 @@ int conf_read(const char *name)
 int conf_write(const char *name)
 {
 	FILE *out;
+	FILE *git;
 	struct symbol *sym;
 	struct menu *menu;
 	const char *basename;
-	char dirname[128], tmpname[128], newname[128];
+	char dirname[128], tmpname[128], newname[128], gitsha[128];
 	int type, l;
 	const char *str;
 	time_t now;
@@ -450,12 +451,20 @@ int conf_write(const char *name)
 	if (env && *env)
 		use_timestamp = 0;
 
+	gitsha[0] = '\0';
+	git = popen("git log --pretty=format:%h -1 2> /dev/null", "r");
+	if (git != NULL) {
+		fscanf(git, " %127s ", gitsha);
+		pclose(git);
+	}
+
 	fprintf(out, _("#\n"
 		       "# Automatically generated make config: don't edit\n"
-		       "# Linux kernel version: %s\n"
+		       "# Linux kernel version: %s %s\n"
 		       "%s%s"
 		       "#\n"),
 		     sym_get_string_value(sym),
+		     gitsha[0] == '\0' ? "[Not git tree]" : gitsha,
 		     use_timestamp ? "# " : "",
 		     use_timestamp ? ctime(&now) : "");
 

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

end of thread, other threads:[~2010-03-03  2:19 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-01  4:22 [PATCH RFC] kconfig: place git SHA1 in .config output if in git tree Paul E. McKenney
2010-03-01  8:34 ` Ingo Molnar
2010-03-01  9:42 ` Frans Pop
2010-03-01 10:10   ` Geert Uytterhoeven
2010-03-01 16:27     ` Paul E. McKenney
2010-03-01 16:53       ` Frans Pop
2010-03-01 18:16         ` Paul E. McKenney
2010-03-01 20:29           ` Frans Pop
2010-03-02  1:16             ` Paul E. McKenney
2010-03-02 15:19               ` Frans Pop
2010-03-03  0:01                 ` Paul E. McKenney
2010-03-03  0:42                   ` Frans Pop
2010-03-03  2:19                     ` Paul E. McKenney
2010-03-01 16:22 ` Linus Torvalds
2010-03-01 16:48   ` Paul E. McKenney
2010-03-01 20:46     ` James Cloos
2010-03-02  1:20       ` Paul E. McKenney
2010-03-02  1:53         ` James Cloos
2010-03-02  5:21           ` Paul E. McKenney

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