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 in67e5a5ec
(git-unpack-objects: re-write to read from stdin, 2005-06-28) and9bee2478
(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>
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user