Ticket #4125: 0001-add-configure-option-to-omit-git-sha1-from-version.patch

File 0001-add-configure-option-to-omit-git-sha1-from-version.patch, 3.2 KB (added by ossi, 3 years ago)
  • Makefile.am

    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 
    3232 
    3333update-version: 
    3434        @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; \ 
    3636        else \ 
    3737            if test ! -e $(top_srcdir)/mc-version.h; then \ 
    3838                echo "File not found: $(top_srcdir)/version.sh"; \ 
  • autogen.sh

    diff --git a/autogen.sh b/autogen.sh
    index e462872fa..582c737b6 100755
    a b ${XGETTEXT:-xgettext} --keyword=_ --keyword=N_ --keyword=Q_ --output=- \ 
    2020cd src/vfs/smbfs/helpers 
    2121date -u >include/stamp-h.in 
    2222 
    23 $srcdir/version.sh "$srcdir" 
     23$srcdir/version.sh "$srcdir" $USE_GIT_SHA1 
    2424 
    2525if test -x $srcdir/configure.mc; then 
    2626  $srcdir/configure.mc "$@" 
  • m4.include/mc-version.m4

    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. 
    99dnl @modified Andrew Borodin <aborodin@vmail.ru> 
    1010 
    1111AC_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 
    1218    if test -f ${srcdir}/mc-version.h; then 
    1319        VERSION=$(grep '^#define MC_CURRENT_VERSION' ${srcdir}/mc-version.h | sed 's/.*"\(.*\)"$/\1/') 
    1420    else 
  • version.sh

    diff --git a/version.sh b/version.sh
    index 5d7aa1615..b4638b19e 100755
    a b EOF 
    5050 
    5151if [ -z "$1" ] 
    5252  then 
    53       echo "usage: $0 <toplevel-source-dir>" 
     53      echo "usage: $0 <toplevel-source-dir> [<use-git-sha1>]" 
    5454      exit 1 
    5555fi 
    5656 
    5757src_top_dir="$1" 
     58use_git_sha1="$2" 
    5859 
    5960VERSION_FILE="${src_top_dir}/mc-version.h" 
    6061PREV_MC_VERSION="unknown" 
    git_head=`git --git-dir "${src_top_dir}/.git" rev-parse --verify HEAD 2>/dev/nul 
    7273# try to store sha1 
    7374CURR_MC_VERSION="${git_head}" 
    7475 
    75 new_version=`git --git-dir "${src_top_dir}/.git" describe --always 2>/dev/null` 
     76if [ "x$use_git_sha1" = xno ] 
     77  then 
     78    arg=--abbrev=0 
     79    sfx=-dirty 
     80  else 
     81    arg= 
     82    sfx= 
     83fi 
     84 
     85new_version=`git --git-dir "${src_top_dir}/.git" describe --always $arg 2>/dev/null` 
    7686[ -z "${new_version}" ] && mc_print_version 
    7787 
    7888# store pretty tagged version 
    79 CURR_MC_VERSION="${new_version}" 
     89CURR_MC_VERSION="${new_version}${sfx}" 
    8090mc_print_version