diff options
| author | Jeff King <peff@peff.net> | 2023-01-18 20:57:56 -0500 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-01-19 08:24:21 -0800 |
| commit | 590b63673747597ab458cb4414e68bb7c4a66aea (patch) | |
| tree | 774b124d8d0226d5eb84c9b2aad2023ff2b39f96 /builtin/commit-tree.c | |
| parent | Git 2.38.3 (diff) | |
| download | git-590b63673747597ab458cb4414e68bb7c4a66aea.tar.gz git-590b63673747597ab458cb4414e68bb7c4a66aea.zip | |
hash-object: fix descriptor leak with --literally
In hash_object(), we open a descriptor for each file to hash (whether we
got the filename from the command line or --stdin-paths), but never
close it. For the traditional code path, which feeds the result to
index_fd(), this is OK; it closes the descriptor for us.
But 5ba9a93b39 (hash-object: add --literally option, 2014-09-11) added a
second code path, which does not close the descriptor. There we need to
do so ourselves.
You can see the problem in a clone of git.git like this:
$ git ls-files -s | grep ^100644 | cut -f2 |
git hash-object --stdin-paths --literally >/dev/null
fatal: could not open 'builtin/var.c' for reading: Too many open files
After this patch, it completes successfully. I didn't bother with a
test, as it's a pain to deal with descriptor limits portably, and the
fix is so trivial.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit-tree.c')
0 files changed, 0 insertions, 0 deletions
