Skip to content

Commit 2bf8f36

Browse files
pks-tgitster
authored andcommitted
csum-file: drop hashfd_throughput()
The `hashfd_throughput()` function is used by a single callsite in git-pack-objects(1). In contrast to `hashfd()`, this function uses a progress meter to measure throughput and a smaller buffer length so that the progress meter can provide more granular metrics. We're going to change that caller in the next commit to be a bit more specific to packing objects. As such, `hashfd_throughput()` will be a somewhat unfitting mechanism for any potential new callers. Drop the function and replace it with a call to `hashfd_ext()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a1118c0 commit 2bf8f36

3 files changed

Lines changed: 15 additions & 22 deletions

File tree

builtin/pack-objects.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,11 +1331,22 @@ static void write_pack_file(void)
13311331
unsigned char hash[GIT_MAX_RAWSZ];
13321332
char *pack_tmp_name = NULL;
13331333

1334-
if (pack_to_stdout)
1335-
f = hashfd_throughput(the_repository->hash_algo, 1,
1336-
"<stdout>", progress_state);
1337-
else
1334+
if (pack_to_stdout) {
1335+
/*
1336+
* Since we are expecting to report progress of the
1337+
* write into this hashfile, use a smaller buffer
1338+
* size so the progress indicators arrive at a more
1339+
* frequent rate.
1340+
*/
1341+
struct hashfd_options opts = {
1342+
.progress = progress_state,
1343+
.buffer_len = 8 * 1024,
1344+
};
1345+
f = hashfd_ext(the_repository->hash_algo, 1,
1346+
"<stdout>", &opts);
1347+
} else {
13381348
f = create_tmp_packfile(the_repository, &pack_tmp_name);
1349+
}
13391350

13401351
offset = write_pack_header(f, nr_remaining);
13411352

csum-file.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,6 @@ struct hashfile *hashfd(const struct git_hash_algo *algop,
197197
return hashfd_ext(algop, fd, name, &opts);
198198
}
199199

200-
struct hashfile *hashfd_throughput(const struct git_hash_algo *algop,
201-
int fd, const char *name, struct progress *tp)
202-
{
203-
/*
204-
* Since we are expecting to report progress of the
205-
* write into this hashfile, use a smaller buffer
206-
* size so the progress indicators arrive at a more
207-
* frequent rate.
208-
*/
209-
struct hashfd_options opts = {
210-
.progress = tp,
211-
.buffer_len = 8 * 1024,
212-
};
213-
return hashfd_ext(algop, fd, name, &opts);
214-
}
215-
216200
void hashfile_checkpoint_init(struct hashfile *f,
217201
struct hashfile_checkpoint *checkpoint)
218202
{

csum-file.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ struct hashfile *hashfd(const struct git_hash_algo *algop,
6363
int fd, const char *name);
6464
struct hashfile *hashfd_check(const struct git_hash_algo *algop,
6565
const char *name);
66-
struct hashfile *hashfd_throughput(const struct git_hash_algo *algop,
67-
int fd, const char *name, struct progress *tp);
6866

6967
/*
7068
* Free the hashfile without flushing its contents to disk. This only

0 commit comments

Comments
 (0)