commit ec295f5e68d2ced6c0e2639c69166c0387d04443
parent 4b5b66a806d196a291231ed3dbf6bd94e8861d70
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Fri, 8 Apr 2016 10:22:09 +0200
build-sys: detect a build from git and show its short commit hash
Diffstat:
4 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
# USA.
-AC_INIT([GNU nano], [2.5.3-git], [nano-devel@gnu.org], [nano])
+AC_INIT([GNU nano], [2.5.3], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE
@@ -692,6 +692,16 @@ AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)
AC_CHECK_PROG(haveit, makeinfo, yes, no)
AM_CONDITIONAL(HAVE_MAKEINFO, test x$haveit = xyes)
+AC_MSG_CHECKING([whether building from git])
+if test -d .git ; then
+ AC_MSG_RESULT([yes])
+ AC_PATH_PROG([GIT], [git])
+ REVISION=`($GIT rev-parse --is-inside-work-tree >/dev/null 2>&1) && ($GIT rev-parse --short HEAD)`
+ AC_SUBST(REVISION)
+ AC_DEFINE_UNQUOTED([REVISION],"${REVISION}","Setting REVISION in config.h.")
+else
+ AC_MSG_RESULT([no])
+fi
AC_CONFIG_FILES([
Makefile
diff --git a/src/nano.c b/src/nano.c
@@ -933,7 +933,11 @@ void usage(void)
* it was compiled with. */
void version(void)
{
+#ifdef REVISION
+ printf(" GNU nano from git, commit %s (after %s)\n", REVISION, VERSION);
+#else
printf(_(" GNU nano, version %s\n"), VERSION);
+#endif
printf(" (C) 1999..2016 Free Software Foundation, Inc.\n");
printf(
_(" Email: nano@nano-editor.org Web: http://www.nano-editor.org/"));
diff --git a/src/nano.h b/src/nano.h
@@ -581,4 +581,10 @@ enum
/* The maximum number of bytes buffered at one time. */
#define MAX_BUF_SIZE 128
+#ifdef REVISION
+#define BRANDING PACKAGE_VERSION"-git "REVISION
+#else
+#define BRANDING PACKAGE_STRING
+#endif
+
#endif /* !NANO_H */
diff --git a/src/winio.c b/src/winio.c
@@ -1952,9 +1952,8 @@ void titlebar(const char *path)
{
int space = COLS;
/* The space we have available for display. */
- size_t verlen = strlenpt(PACKAGE_STRING) + 1;
- /* The length of the version message in columns, plus one for
- * padding. */
+ size_t verlen = strlenpt(BRANDING);
+ /* The length of the version message in columns. */
const char *prefix;
/* "DIR:", "File:", or "New Buffer". Goes before filename. */
size_t prefixlen;
@@ -1996,8 +1995,7 @@ void titlebar(const char *path)
if (space >= 4) {
/* Add a space after the version message, and account for both
* it and the two spaces before it. */
- mvwaddnstr(topwin, 0, 2, PACKAGE_STRING,
- actual_x(PACKAGE_STRING, verlen));
+ mvwaddnstr(topwin, 0, 2, BRANDING, actual_x(BRANDING, verlen));
verlen += 3;
/* Account for the full length of the version message. */