linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mmc-utils: Improve version reporting
@ 2025-06-30  7:24 Avri Altman
  2025-06-30  7:24 ` [PATCH v2 1/3] mmc-utils: Add option to print version Avri Altman
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Avri Altman @ 2025-06-30  7:24 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.

---
Changes since v1:
 - Add a 3rd patch to print the version at program start

Avri Altman (3):
  mmc-utils: Add option to print version
  mmc-utils: Makefile: Make version string to show commit date
  mmc-utils: mmc.c: Print version at program start

 Makefile |  4 +++-
 mmc.c    | 12 +++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] mmc-utils: Add option to print version
  2025-06-30  7:24 [PATCH v2 0/3] mmc-utils: Improve version reporting Avri Altman
@ 2025-06-30  7:24 ` Avri Altman
  2025-06-30  7:24 ` [PATCH v2 2/3] mmc-utils: Makefile: Make version string to show commit date Avri Altman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2025-06-30  7:24 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] 5+ messages in thread

* [PATCH v2 2/3] mmc-utils: Makefile: Make version string to show commit date
  2025-06-30  7:24 [PATCH v2 0/3] mmc-utils: Improve version reporting Avri Altman
  2025-06-30  7:24 ` [PATCH v2 1/3] mmc-utils: Add option to print version Avri Altman
@ 2025-06-30  7:24 ` Avri Altman
  2025-06-30  7:24 ` [PATCH v2 3/3] mmc-utils: mmc.c: Print version at program start Avri Altman
  2025-07-03 14:17 ` [PATCH v2 0/3] mmc-utils: Improve version reporting Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2025-06-30  7:24 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] 5+ messages in thread

* [PATCH v2 3/3] mmc-utils: mmc.c: Print version at program start
  2025-06-30  7:24 [PATCH v2 0/3] mmc-utils: Improve version reporting Avri Altman
  2025-06-30  7:24 ` [PATCH v2 1/3] mmc-utils: Add option to print version Avri Altman
  2025-06-30  7:24 ` [PATCH v2 2/3] mmc-utils: Makefile: Make version string to show commit date Avri Altman
@ 2025-06-30  7:24 ` Avri Altman
  2025-07-03 14:17 ` [PATCH v2 0/3] mmc-utils: Improve version reporting Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2025-06-30  7:24 UTC (permalink / raw)
  To: Ulf Hansson, linux-mmc; +Cc: Avri Altman

Enhance the visibility of the mmc-utils version string by printing it at
the beginning of each run. This makes it easier for users and support
personnel to quickly identify the tool version in logs and outputs.

Signed-off-by: Avri Altman <avri.altman@sandisk.com>
---
 mmc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mmc.c b/mmc.c
index e941aa2..6770a45 100644
--- a/mmc.c
+++ b/mmc.c
@@ -573,6 +573,10 @@ int main(int ac, char **av )
 	int nargs = 0, r;
 	CommandFunction func = NULL;
 
+	printf("\n┌───────────────────────────────────────────────┐\n");
+	printf("│  mmc-utils version: %-24s  │\n", VERSION);
+	printf("└───────────────────────────────────────────────┘\n\n");
+
 	r = parse_args(ac, av, &func, &nargs, &cmd, &args);
 	if( r <= 0 ){
 		/* error or no command to parse*/
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/3] mmc-utils: Improve version reporting
  2025-06-30  7:24 [PATCH v2 0/3] mmc-utils: Improve version reporting Avri Altman
                   ` (2 preceding siblings ...)
  2025-06-30  7:24 ` [PATCH v2 3/3] mmc-utils: mmc.c: Print version at program start Avri Altman
@ 2025-07-03 14:17 ` Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2025-07-03 14:17 UTC (permalink / raw)
  To: Avri Altman; +Cc: linux-mmc

On Mon, 30 Jun 2025 at 09:24, Avri Altman <avri.altman@sandisk.com> wrote:
>
> 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.
>
> ---
> Changes since v1:
>  - Add a 3rd patch to print the version at program start
>
> Avri Altman (3):
>   mmc-utils: Add option to print version
>   mmc-utils: Makefile: Make version string to show commit date
>   mmc-utils: mmc.c: Print version at program start
>
>  Makefile |  4 +++-
>  mmc.c    | 12 +++++++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
>

Applied for mmc-utils master, thanks!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-03 14:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30  7:24 [PATCH v2 0/3] mmc-utils: Improve version reporting Avri Altman
2025-06-30  7:24 ` [PATCH v2 1/3] mmc-utils: Add option to print version Avri Altman
2025-06-30  7:24 ` [PATCH v2 2/3] mmc-utils: Makefile: Make version string to show commit date Avri Altman
2025-06-30  7:24 ` [PATCH v2 3/3] mmc-utils: mmc.c: Print version at program start Avri Altman
2025-07-03 14:17 ` [PATCH v2 0/3] mmc-utils: Improve version reporting Ulf Hansson

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).