summaryrefslogtreecommitdiff
path: root/t/t5316-pack-delta-depth.sh
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2022-07-22 23:29:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-07-23 04:42:06 (GMT)
commitdb9d67f2e9c9ea389f5558d6a168460d51631769 (patch)
tree480ef901948f38b409cc9148bca64c5f1a04d97a /t/t5316-pack-delta-depth.sh
parent3639fefe7d1d7bf881ea6128cedc4fc503164edc (diff)
downloadgit-db9d67f2e9c9ea389f5558d6a168460d51631769.zip
git-db9d67f2e9c9ea389f5558d6a168460d51631769.tar.gz
git-db9d67f2e9c9ea389f5558d6a168460d51631769.tar.bz2
builtin/cat-file.c: support NUL-delimited input with `-z`
When callers are using `cat-file` via one of the stdin-driven `--batch` modes, all input is newline-delimited. This presents a problem when callers wish to ask about, e.g. tree-entries that have a newline character present in their filename. To support this niche scenario, introduce a new `-z` mode to the `--batch`, `--batch-check`, and `--batch-command` suite of options that instructs `cat-file` to treat its input as NUL-delimited, allowing the individual commands themselves to have newlines present. The refactoring here is slightly unfortunate, since we turn loops like: while (strbuf_getline(&buf, stdin) != EOF) into: while (1) { int ret; if (opt->nul_terminated) ret = strbuf_getline_nul(&input, stdin); else ret = strbuf_getline(&input, stdin); if (ret == EOF) break; } It's tempting to think that we could use `strbuf_getwholeline()` and specify either `\n` or `\0` as the terminating character. But for input on platforms that include a CR character preceeding the LF, this wouldn't quite be the same, since `strbuf_getline(...)` will trim any trailing CR, while `strbuf_getwholeline(&buf, stdin, '\n')` will not. In the future, we could clean this up further by introducing a variant of `strbuf_getwholeline()` that addresses the aforementioned gap, but that approach felt too heavy-handed for this pair of uses. Some tests are added in t1006 to ensure that `cat-file` produces the same output in `--batch`, `--batch-check`, and `--batch-command` modes with and without the new `-z` option. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5316-pack-delta-depth.sh')
0 files changed, 0 insertions, 0 deletions