aboutsummaryrefslogtreecommitdiff
path: root/builtin/pack-objects.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/pack-objects.c')
-rw-r--r--builtin/pack-objects.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index cd013c0b68..da1087930c 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -41,6 +41,7 @@
#include "promisor-remote.h"
#include "pack-mtimes.h"
#include "parse-options.h"
+#include "pkt-line.h"
#include "blob.h"
#include "tree.h"
#include "path-walk.h"
@@ -1330,11 +1331,25 @@ static void write_pack_file(void)
unsigned char hash[GIT_MAX_RAWSZ];
char *pack_tmp_name = NULL;
- if (pack_to_stdout)
- f = hashfd_throughput(the_repository->hash_algo, 1,
- "<stdout>", progress_state);
- else
+ if (pack_to_stdout) {
+ /*
+ * This command is most often invoked via
+ * git-upload-pack(1), which will typically chunk data
+ * into pktlines. As such, we use the maximum data
+ * length of them as buffer length.
+ *
+ * Note that we need to subtract one though to
+ * accomodate for the sideband byte.
+ */
+ struct hashfd_options opts = {
+ .progress = progress_state,
+ .buffer_len = LARGE_PACKET_DATA_MAX - 1,
+ };
+ f = hashfd_ext(the_repository->hash_algo, 1,
+ "<stdout>", &opts);
+ } else {
f = create_tmp_packfile(the_repository, &pack_tmp_name);
+ }
offset = write_pack_header(f, nr_remaining);