summaryrefslogtreecommitdiff
path: root/builtin/fsck.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2015-08-24 15:30:43 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-08-24 15:30:43 -0700
commit7b8419f0940dcb9c017fc66390dc6a6471ce5373 (patch)
tree88c8f8c4ae2a7c3441578757ed6adba68691b303 /builtin/fsck.c
parentMerge 'kn/for-each-tag-branch' into kn/for-each-tag (diff)
parentmemoize common git-path "constant" files (diff)
downloadtgif-7b8419f0940dcb9c017fc66390dc6a6471ce5373.tar.xz
Merge 'jk/git-path' into kn/for-each-tag
* jk/git-path: memoize common git-path "constant" files get_repo_path: refactor path-allocation find_hook: keep our own static buffer refs.c: remove_empty_directories can take a strbuf refs.c: avoid git_path assignment in lock_ref_sha1_basic refs.c: avoid repeated git_path calls in rename_tmp_log refs.c: simplify strbufs in reflog setup and writing path.c: drop git_path_submodule refs.c: remove extra git_path calls from read_loose_refs remote.c: drop extraneous local variable from migrate_file prefer mkpathdup to mkpath in assignments prefer git_pathdup to git_path in some possibly-dangerous cases add_to_alternates_file: don't add duplicate entries t5700: modernize style cache.h: complete set of git_path_submodule helpers cache.h: clarify documentation for git_path, et al
Diffstat (limited to 'builtin/fsck.c')
-rw-r--r--builtin/fsck.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index f4b87e9b33..079470342f 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -243,13 +243,14 @@ static void check_unreachable_object(struct object *obj)
printf("dangling %s %s\n", typename(obj->type),
sha1_to_hex(obj->sha1));
if (write_lost_and_found) {
- const char *filename = git_path("lost-found/%s/%s",
+ char *filename = git_pathdup("lost-found/%s/%s",
obj->type == OBJ_COMMIT ? "commit" : "other",
sha1_to_hex(obj->sha1));
FILE *f;
if (safe_create_leading_directories_const(filename)) {
error("Could not create lost-found");
+ free(filename);
return;
}
if (!(f = fopen(filename, "w")))
@@ -262,6 +263,7 @@ static void check_unreachable_object(struct object *obj)
if (fclose(f))
die_errno("Could not finish '%s'",
filename);
+ free(filename);
}
return;
}