diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-03-02 11:03:46 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-03-02 11:12:16 -0800 |
| commit | fa6c383309557b9d2942c47b75a895ca960ad9f5 (patch) | |
| tree | 534c6d89339dcf0228d7fdb90db9cd51591a5692 /builtin/unpack-objects.c | |
| parent | b387623c12f3f4a376e4d35a610fd3e55d7ea907 (diff) | |
| download | git-fa6c383309557b9d2942c47b75a895ca960ad9f5.tar.gz | |
unpack: replace xwrite() loop with write_in_full()
We have two packfile stream consumers, index-pack and
unpack-objects, that allow excess payload after the packfile stream
data. Their code to relay excess data hasn't changed significantly
since their original implementation that appeared in 67e5a5ec
(git-unpack-objects: re-write to read from stdin, 2005-06-28) and
9bee2478 (mimic unpack-objects when --stdin is used with index-pack,
2006-10-25).
These code blocks contain hand-rolled loops using xwrite(), written
before our write_in_full() helper existed. This helper now provides
the same functionality.
Replace these loops with write_in_full() for shorter, clearer
code. Update related variables accordingly.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/unpack-objects.c')
| -rw-r--r-- | builtin/unpack-objects.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index e0a701f2b3..f1c85a00ae 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -679,13 +679,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED) use(the_hash_algo->rawsz); /* Write the last part of the buffer to stdout */ - while (len) { - int ret = xwrite(1, buffer + offset, len); - if (ret <= 0) - break; - len -= ret; - offset += ret; - } + write_in_full(1, buffer + offset, len); /* All done */ return has_errors; |
