]> git.ipfire.org Git - thirdparty/git.git/commitdiff
last-modified: add option '-z' to help output
authorToon Claes <toon@iotcl.com>
Fri, 16 Jan 2026 13:22:50 +0000 (14:22 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Jan 2026 18:27:20 +0000 (10:27 -0800)
The parsing of option '-z' is done by diff_opt_parse(), which is called
by setup_revisions(), and ends up filling in
`struct diff_options::line_termination`. But that field isn't used by
the diff machinery itself, only by builtin/last-modified.c to format
the output.

To have '-z' also appear in the help output of `git last-modified -h`,
move the handling of '-z' to parse_options() in builtin/last-modified.c
itself.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/last-modified.c

index 80b805a589c860c9eb794bb0d64632ff77bea5f1..bc51d16b92f6f22cf33aebee75cfcde58065803f 100644 (file)
@@ -55,6 +55,7 @@ struct last_modified {
        struct rev_info rev;
        bool recursive;
        bool show_trees;
+       bool null_termination;
 
        const char **all_paths;
        size_t all_paths_nr;
@@ -165,10 +166,10 @@ static void last_modified_emit(struct last_modified *lm,
                putchar('^');
        printf("%s\t", oid_to_hex(&commit->object.oid));
 
-       if (lm->rev.diffopt.line_termination)
-               write_name_quoted(path, stdout, '\n');
-       else
+       if (lm->null_termination)
                printf("%s%c", path, '\0');
+       else
+               write_name_quoted(path, stdout, '\n');
 }
 
 static void mark_path(const char *path, const struct object_id *oid,
@@ -520,6 +521,8 @@ int cmd_last_modified(int argc, const char **argv, const char *prefix,
                         N_("recurse into subtrees")),
                OPT_BOOL('t', "show-trees", &lm.show_trees,
                         N_("show tree entries when recursing into subtrees")),
+               OPT_BOOL('z', NULL, &lm.null_termination,
+                       N_("lines are separated with NUL character")),
                OPT_END()
        };