summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-07-09 09:42:02 -0700
committerJunio C Hamano <gitster@pobox.com>2017-07-09 09:42:02 -0700
commit7db02b3bef2459b60e021369360f7a2f9e7f0c25 (patch)
tree4dae9327b9a3dec260312ba4d965c3657c50c6ca
parentfe8b77b7083253e55138a2aa09b60e7f7918a081 (diff)
downloadgit-rs/sha1-file-micro-optim.tar.gz
-rw-r--r--sha1_file.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 6a9deb9e68..d277b32bf1 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -3749,7 +3749,7 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
each_loose_subdir_fn subdir_cb,
void *data)
{
- size_t origlen, dirlen, baselen;
+ size_t origlen, baselen;
DIR *dir;
struct dirent *de;
int r = 0;
@@ -3760,7 +3760,6 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
origlen = path->len;
strbuf_complete(path, '/');
strbuf_addf(path, "%02x", subdir_nr);
- dirlen = path->len;
dir = opendir(path->buf);
if (!dir) {
@@ -3804,7 +3803,7 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
}
closedir(dir);
- strbuf_setlen(path, dirlen);
+ strbuf_setlen(path, baselen - 1); /* chomp the '/' that we added */
if (!r && subdir_cb)
r = subdir_cb(subdir_nr, path->buf, data);