Today's seen branch fails to build (with DEVELOPER=1), like so:
CC builtin/name-rev.o
builtin/name-rev.c: In function ‘cmd_format_rev’:
builtin/name-rev.c:885:28: error: ‘commit’ may be used uninitialized [-Werror=maybe-uninitialized]
885 | if (!commit) {
| ^
builtin/name-rev.c:867:40: note: ‘commit’ was declared here
867 | struct commit *commit;
| ^~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:2932: builtin/name-rev.o] Error 1This can be fixed in several ways; initialise the 'commit' variable to NULL (on line 867), initialise 'commit' to NULL on the line before the conditional on line 883, or (as I chose here) initialise the 'commit' variable in an else arm of the conditional.
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> ---
Hi Kristoffer,
I wrote this patch yesterday, just before I had to go out, and didn't get around to sending it to the list. Today, the problem has gone away ... (along with the 'kh/name-rev-custom-format' branch)!
Assuming you will be sending a new version soon, ... could you please squash this (or similar) into the patch corresponding to commit 5903855b1c ("format-rev: introduce builtin for on-demand pretty formatting", 2026-04-29).
Note that I don't think this particular fix is better than any other, it was just that my cursor was on that line in vim ... :)
ATB, Ramsay Jones
builtin/name-rev.c | 2 ++ 1 file changed, 2 insertions(+)
Show changes to builtin/name-rev.c +2 −0
diff --git a/builtin/name-rev.c b/builtin/name-rev.c index b941e93834..5b7f7a00e5 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -882,6 +882,8 @@ int cmd_format_rev(int argc, peeled = deref_tag(the_repository, object, scratch_buf.buf, 0); if (peeled && peeled->type == OBJ_COMMIT) commit = (struct commit *)peeled; + else + commit = NULL; if (!commit) { fprintf(stderr, "Could not get commit for %s. Skipping.\n", *argv);
-- 2.54.0