* [PATCH 0/2] mmc-utils: Improve version reporting
@ 2025-06-29 11:06 Avri Altman
2025-06-29 11:06 ` [PATCH 1/2] mmc-utils: Add option to print version Avri Altman
2025-06-29 11:06 ` [PATCH 2/2] mmc-utils: Makefile: Make version string to show commit date Avri Altman
0 siblings, 2 replies; 3+ messages in thread
From: Avri Altman @ 2025-06-29 11:06 UTC (permalink / raw)
To: Ulf Hansson, linux-mmc; +Cc: Avri Altman
This series improves version reporting in mmc-utils to make it easier
for users and developers to identify the exact build in use, which is
especially helpful for debugging and support—particularly since many
users run pre-built binaries.
These changes should make it easier to track and support mmc-utils
deployments in the field.
Avri Altman (2):
mmc-utils: Add option to print version
mmc-utils: Makefile: Make version string to show commit date
Makefile | 4 +++-
mmc.c | 8 +++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] mmc-utils: Add option to print version
2025-06-29 11:06 [PATCH 0/2] mmc-utils: Improve version reporting Avri Altman
@ 2025-06-29 11:06 ` Avri Altman
2025-06-29 11:06 ` [PATCH 2/2] mmc-utils: Makefile: Make version string to show commit date Avri Altman
1 sibling, 0 replies; 3+ messages in thread
From: Avri Altman @ 2025-06-29 11:06 UTC (permalink / raw)
To: Ulf Hansson, linux-mmc; +Cc: Avri Altman
This change adds support for printing the version as a command-line
argument. When any of 'ver', '-ver', '--ver', etc. are specified as the
first argument, mmc-utils will print its version string and exit.
This makes it easier for users and support personnel to quickly
determine the exact version of mmc-utils in use, which is especially
helpful for debugging and when users are running pre-built binaries.
Signed-off-by: Avri Altman <avri.altman@sandisk.com>
---
mmc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/mmc.c b/mmc.c
index 315fa70..e941aa2 100644
--- a/mmc.c
+++ b/mmc.c
@@ -460,12 +460,18 @@ static int parse_args(int argc, char **argv,
char *prgname = get_prgname(argv[0]);
int i=0, helprequested=0;
- if( argc < 2 || !strcmp(argv[1], "help") ||
+ if(argc < 2 || !strcmp(argv[1], "help") ||
!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){
help(prgname);
return 0;
}
+ if(!strcmp(argv[1], "ver") || !strcmp(argv[1], "-ver") || !strcmp(argv[1], "--ver") ||
+ !strcmp(argv[1], "version") || !strcmp(argv[1], "-version") || !strcmp(argv[1], "--version")){
+ printf("%s\n", VERSION);
+ return 0;
+ }
+
for( cp = commands; cp->verb; cp++ )
if( !cp->ncmds)
cp->ncmds = split_command(cp->verb, &(cp->cmds));
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] mmc-utils: Makefile: Make version string to show commit date
2025-06-29 11:06 [PATCH 0/2] mmc-utils: Improve version reporting Avri Altman
2025-06-29 11:06 ` [PATCH 1/2] mmc-utils: Add option to print version Avri Altman
@ 2025-06-29 11:06 ` Avri Altman
1 sibling, 0 replies; 3+ messages in thread
From: Avri Altman @ 2025-06-29 11:06 UTC (permalink / raw)
To: Ulf Hansson, linux-mmc; +Cc: Avri Altman
Previously, the version string included the abbreviated SHA1 of the
latest commit (e.g., "v1.0-1-g5e67f7"), which was not very informative.
This change updates the version string to includes the date of the
latest commit instead (e.g., "v1.0-1-2024-06-29"). This makes it easier
to identify the build date at a glance.
Many mmc-utils users do not build the tool themselves, so having a clear
version string with the commit date helps greatly when debugging issues
or providing support.
Signed-off-by: Avri Altman <avri.altman@sandisk.com>
---
Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index c0284bb..7631524 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
CC ?= gcc
-GIT_VERSION := "$(shell git describe --abbrev=6 --always --tags)"
+# GIT_VERSION is set to the latest tag, number of commits since that tag, and the date of the last commit
+# e.g., v1.0-5-2023-10-01
+GIT_VERSION := "$(shell git describe --abbrev=0 --tags)-$$(git rev-list --count $$(git describe --abbrev=0 --tags)..HEAD)-$$(git log -1 --format=%cd --date=short)"
AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \
-DVERSION=\"$(GIT_VERSION)\"
CFLAGS ?= -g -O2
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-29 11:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-29 11:06 [PATCH 0/2] mmc-utils: Improve version reporting Avri Altman
2025-06-29 11:06 ` [PATCH 1/2] mmc-utils: Add option to print version Avri Altman
2025-06-29 11:06 ` [PATCH 2/2] mmc-utils: Makefile: Make version string to show commit date Avri Altman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).