Kristoffer Haugsbakk says commands in the git-rev-list family can NUL-delimit commits, but that support is fragile, inconsistent and awkward to use. The topic, kh/revision-nul-termination, introduces -Z, which NUL-terminates commits independently of the NUL handling inside diffs.

He says it began when he tried to replace git-format-rev(1) with git-diff-tree(1) and ran into problems he describes in a linked message. Today log-tree.c uses diff_options.line_termination for the commit record terminator, so -z and -Z both give NUL commit records and NUL in non-patch diff formats. The existing -z behavior must stay for backwards compatibility. With the new option, -Z means only commit-record termination, and users who want NUL-terminated diffs as well can pass both -Z and -z. To do that, the series stores a delimiter in struct rev_info and teaches handle_revision_opt() about -z.

Terminators are the default only for user-defined pretty formats, so built-in formats could not get terminator behavior before. Haugsbakk says terminators let a program read and act on each record immediately without risking deadlocks. A related patch makes git log -z --patch or --stat terminate the whole record, commit and diff, with NUL, and fixes the "NUL termination with --stat" test in t4205.

One patch makes the diff case in git diff-tree --stdin call the IO flush function, as the commit case already does through maybe_flush_or_die(). That guarantees a diff is readable right after each input. Other patches add tests for diff output on merge commits and expand the git-diff-tree documentation, including a note that diff-tree does not output merge commits without a diff.

The posted messages are all from Haugsbakk, and no reviews are visible yet.