Changed the display format of the Git commit hash in the version display

This commit is contained in:
Takeshi Nakatani 2024-06-23 05:43:07 +00:00 committed by Andrew Gaul
parent fa807a56fb
commit a3a0ae523f
4 changed files with 25 additions and 10 deletions

View File

@ -21,11 +21,15 @@
echo "--- Make commit hash file -------" echo "--- Make commit hash file -------"
SHORTHASH="unknown" SHORTHASH=""
if command -v git > /dev/null 2>&1 && test -d .git; then if command -v git > /dev/null 2>&1 && test -d .git; then
if RESULT=$(git rev-parse --short HEAD); then if SHORTHASH=$(git rev-parse --short HEAD); then
SHORTHASH="${RESULT}" echo " -> Git commit hash : ${SHORTHASH}"
else
echo " -> Not get git commit hash"
fi fi
else
echo " -> Not found git command or .git directory"
fi fi
echo "${SHORTHASH}" > default_commit_hash echo "${SHORTHASH}" > default_commit_hash

View File

@ -367,11 +367,22 @@ AS_IF([test -d .git], [DOTGITDIR=yes], [DOTGITDIR=no])
AC_MSG_CHECKING([github short commit hash]) AC_MSG_CHECKING([github short commit hash])
if test "x${GITCMD}" = "xyes" -a "x${DOTGITDIR}" = "xyes"; then if test "x${GITCMD}" = "xyes" -a "x${DOTGITDIR}" = "xyes"; then
GITCOMMITHASH=`git rev-parse --short HEAD` TMP_GITCOMMITHASH=`git rev-parse --short HEAD`
elif test -f default_commit_hash; then UNTRACKED_FILES=`git status -s --untracked-files=no`
GITCOMMITHASH=`cat default_commit_hash` if test -n "${UNTRACKED_FILES}"; then
GITCOMMITHASH="(commit:${TMP_GITCOMMITHASH} +untracked files)"
else else
GITCOMMITHASH="unknown" GITCOMMITHASH="(commit:${TMP_GITCOMMITHASH})"
fi
elif test -f default_commit_hash; then
TMP_GITCOMMITHASH=`cat default_commit_hash`
if test -n "${TMP_GITCOMMITHASH}"; then
GITCOMMITHASH="(base commit:${TMP_GITCOMMITHASH})"
else
GITCOMMITHASH=""
fi
else
GITCOMMITHASH=""
fi fi
AC_MSG_RESULT([${GITCOMMITHASH}]) AC_MSG_RESULT([${GITCOMMITHASH}])

View File

@ -4270,7 +4270,7 @@ static void s3fs_exit_fuseloop(int exit_status)
static void* s3fs_init(struct fuse_conn_info* conn) 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) // cache(remove cache dirs at first)
if(is_remove_cache && (!CacheFileStat::DeleteCacheFileStatDirectory() || !FdManager::DeleteCacheDirectory())){ if(is_remove_cache && (!CacheFileStat::DeleteCacheFileStatDirectory() || !FdManager::DeleteCacheDirectory())){

View File

@ -653,7 +653,7 @@ void show_help()
void show_version() void show_version()
{ {
printf( 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 <rrizun@gmail.com>\n" "Copyright (C) 2010 Randy Rizun <rrizun@gmail.com>\n"
"License GPL2: GNU GPL version 2 <https://gnu.org/licenses/gpl.html>\n" "License GPL2: GNU GPL version 2 <https://gnu.org/licenses/gpl.html>\n"
"This is free software: you are free to change and redistribute it.\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() 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; return short_ver;
} }