From a3a0ae523fed8aeb3758f9ab2ab3fcd5e90c1312 Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Sun, 23 Jun 2024 05:43:07 +0000 Subject: [PATCH] Changed the display format of the Git commit hash in the version display --- autogen.sh | 12 ++++++++---- configure.ac | 17 ++++++++++++++--- src/s3fs.cpp | 2 +- src/s3fs_help.cpp | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/autogen.sh b/autogen.sh index e9bab02..a86c3a8 100755 --- a/autogen.sh +++ b/autogen.sh @@ -21,11 +21,15 @@ echo "--- Make commit hash file -------" -SHORTHASH="unknown" +SHORTHASH="" if command -v git > /dev/null 2>&1 && test -d .git; then - if RESULT=$(git rev-parse --short HEAD); then - SHORTHASH="${RESULT}" - fi + if SHORTHASH=$(git rev-parse --short HEAD); then + echo " -> Git commit hash : ${SHORTHASH}" + else + echo " -> Not get git commit hash" + fi +else + echo " -> Not found git command or .git directory" fi echo "${SHORTHASH}" > default_commit_hash diff --git a/configure.ac b/configure.ac index 6bc7bfd..cc50bee 100644 --- a/configure.ac +++ b/configure.ac @@ -367,11 +367,22 @@ AS_IF([test -d .git], [DOTGITDIR=yes], [DOTGITDIR=no]) AC_MSG_CHECKING([github short commit hash]) if test "x${GITCMD}" = "xyes" -a "x${DOTGITDIR}" = "xyes"; then - GITCOMMITHASH=`git rev-parse --short HEAD` + TMP_GITCOMMITHASH=`git rev-parse --short HEAD` + UNTRACKED_FILES=`git status -s --untracked-files=no` + if test -n "${UNTRACKED_FILES}"; then + GITCOMMITHASH="(commit:${TMP_GITCOMMITHASH} +untracked files)" + else + GITCOMMITHASH="(commit:${TMP_GITCOMMITHASH})" + fi elif test -f default_commit_hash; then - GITCOMMITHASH=`cat default_commit_hash` + TMP_GITCOMMITHASH=`cat default_commit_hash` + if test -n "${TMP_GITCOMMITHASH}"; then + GITCOMMITHASH="(base commit:${TMP_GITCOMMITHASH})" + else + GITCOMMITHASH="" + fi else - GITCOMMITHASH="unknown" + GITCOMMITHASH="" fi AC_MSG_RESULT([${GITCOMMITHASH}]) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 20d8305..959690e 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -4270,7 +4270,7 @@ static void s3fs_exit_fuseloop(int exit_status) static void* s3fs_init(struct fuse_conn_info* conn) { - S3FS_PRN_INIT_INFO("init v%s(commit:%s) with %s, credential-library(%s)", VERSION, COMMIT_HASH_VAL, s3fs_crypt_lib_name(), ps3fscred->GetCredFuncVersion(false)); + S3FS_PRN_INIT_INFO("init v%s%s with %s, credential-library(%s)", VERSION, COMMIT_HASH_VAL, s3fs_crypt_lib_name(), ps3fscred->GetCredFuncVersion(false)); // cache(remove cache dirs at first) if(is_remove_cache && (!CacheFileStat::DeleteCacheFileStatDirectory() || !FdManager::DeleteCacheDirectory())){ diff --git a/src/s3fs_help.cpp b/src/s3fs_help.cpp index 880e299..27510df 100644 --- a/src/s3fs_help.cpp +++ b/src/s3fs_help.cpp @@ -653,7 +653,7 @@ void show_help() void show_version() { printf( - "Amazon Simple Storage Service File System V%s (commit:%s) with %s\n" + "Amazon Simple Storage Service File System V%s%s with %s\n" "Copyright (C) 2010 Randy Rizun \n" "License GPL2: GNU GPL version 2 \n" "This is free software: you are free to change and redistribute it.\n" @@ -663,7 +663,7 @@ void show_version() const char* short_version() { - static constexpr char short_ver[] = "s3fs version " VERSION "(" COMMIT_HASH_VAL ")"; + static constexpr char short_ver[] = "s3fs version " VERSION "" COMMIT_HASH_VAL; return short_ver; }