From 1093fd992cee39b0c4c8c72f09dffa1a8442941c Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Date: Thu, 24 Jun 2021 10:21:23 +0200
Subject: [PATCH] add configure option to omit git sha1 from version
when working with git, in particular when using git-rebase extensively,
the full rebuild caused by every modification of HEAD quickly becomes a
significant time-sink without adding any tangible value. consequently,
add an option to suppress this behavior.
---
Makefile.am | 2 +-
autogen.sh | 2 +-
m4.include/mc-version.m4 | 6 ++++++
version.sh | 16 +++++++++++++---
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index caadeed10..55801e8e8 100644
a
|
b
|
CONFIG_STATUS_DEPENDENCIES = $(top_srcdir)/mc-version.h |
32 | 32 | |
33 | 33 | update-version: |
34 | 34 | @if test -x $(top_srcdir)/version.sh; then \ |
35 | | $(top_srcdir)/version.sh "$(top_srcdir)" 2>&1 >/dev/null; \ |
| 35 | $(top_srcdir)/version.sh "$(top_srcdir)" $(USE_GIT_SHA1) 2>&1 >/dev/null; \ |
36 | 36 | else \ |
37 | 37 | if test ! -e $(top_srcdir)/mc-version.h; then \ |
38 | 38 | echo "File not found: $(top_srcdir)/version.sh"; \ |
diff --git a/autogen.sh b/autogen.sh
index e462872fa..582c737b6 100755
a
|
b
|
${XGETTEXT:-xgettext} --keyword=_ --keyword=N_ --keyword=Q_ --output=- \ |
20 | 20 | cd src/vfs/smbfs/helpers |
21 | 21 | date -u >include/stamp-h.in |
22 | 22 | |
23 | | $srcdir/version.sh "$srcdir" |
| 23 | $srcdir/version.sh "$srcdir" $USE_GIT_SHA1 |
24 | 24 | |
25 | 25 | if test -x $srcdir/configure.mc; then |
26 | 26 | $srcdir/configure.mc "$@" |
diff --git a/m4.include/mc-version.m4 b/m4.include/mc-version.m4
index 51b6b77c4..0c04798cd 100644
a
|
b
|
dnl @copyright Free Software Foundation, Inc. |
9 | 9 | dnl @modified Andrew Borodin <aborodin@vmail.ru> |
10 | 10 | |
11 | 11 | AC_DEFUN([mc_VERSION],[ |
| 12 | AC_ARG_ENABLE([git-sha1], |
| 13 | [AS_HELP_STRING([--disable-git-sha1], [Do not include git SHA1 in version string])], |
| 14 | [USE_GIT_SHA1=$enableval], |
| 15 | [USE_GIT_SHA1=yes]) |
| 16 | AC_SUBST(USE_GIT_SHA1) |
| 17 | |
12 | 18 | if test -f ${srcdir}/mc-version.h; then |
13 | 19 | VERSION=$(grep '^#define MC_CURRENT_VERSION' ${srcdir}/mc-version.h | sed 's/.*"\(.*\)"$/\1/') |
14 | 20 | else |
diff --git a/version.sh b/version.sh
index 5d7aa1615..b4638b19e 100755
a
|
b
|
EOF |
50 | 50 | |
51 | 51 | if [ -z "$1" ] |
52 | 52 | then |
53 | | echo "usage: $0 <toplevel-source-dir>" |
| 53 | echo "usage: $0 <toplevel-source-dir> [<use-git-sha1>]" |
54 | 54 | exit 1 |
55 | 55 | fi |
56 | 56 | |
57 | 57 | src_top_dir="$1" |
| 58 | use_git_sha1="$2" |
58 | 59 | |
59 | 60 | VERSION_FILE="${src_top_dir}/mc-version.h" |
60 | 61 | PREV_MC_VERSION="unknown" |
… |
… |
git_head=`git --git-dir "${src_top_dir}/.git" rev-parse --verify HEAD 2>/dev/nul |
72 | 73 | # try to store sha1 |
73 | 74 | CURR_MC_VERSION="${git_head}" |
74 | 75 | |
75 | | new_version=`git --git-dir "${src_top_dir}/.git" describe --always 2>/dev/null` |
| 76 | if [ "x$use_git_sha1" = xno ] |
| 77 | then |
| 78 | arg=--abbrev=0 |
| 79 | sfx=-dirty |
| 80 | else |
| 81 | arg= |
| 82 | sfx= |
| 83 | fi |
| 84 | |
| 85 | new_version=`git --git-dir "${src_top_dir}/.git" describe --always $arg 2>/dev/null` |
76 | 86 | [ -z "${new_version}" ] && mc_print_version |
77 | 87 | |
78 | 88 | # store pretty tagged version |
79 | | CURR_MC_VERSION="${new_version}" |
| 89 | CURR_MC_VERSION="${new_version}${sfx}" |
80 | 90 | mc_print_version |