summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2012-09-04 17:31:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-09-04 20:34:46 (GMT)
commit4e2d094dde4f078245d057dd6111ab9d013ae6d0 (patch)
tree208226504d771a78580d6f8a78277134c3b3ecc1 /builtin
parentd292bfaf356338b41e14e40ce4dbd6b9c8d600ec (diff)
downloadgit-4e2d094dde4f078245d057dd6111ab9d013ae6d0.zip
git-4e2d094dde4f078245d057dd6111ab9d013ae6d0.tar.gz
git-4e2d094dde4f078245d057dd6111ab9d013ae6d0.tar.bz2
Call mkpathdup() rather than xstrdup(mkpath(...))
In addition to updating the xstrdup(mkpath(...)) call sites with mkpathdup(), we also fix a memory leak (in merge_3way()) caused by neglecting to free the memory allocated to the 'base_name' variable. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/branch.c2
-rw-r--r--builtin/clone.c4
-rw-r--r--builtin/prune.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index 0e060f2..bdf8495 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -196,7 +196,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
free(name);
- name = xstrdup(mkpath(fmt, bname.buf));
+ name = mkpathdup(fmt, bname.buf);
if (read_ref(name, sha1)) {
error(remote_branch
? _("remote branch '%s' not found.")
diff --git a/builtin/clone.c b/builtin/clone.c
index e314b0b..c819757 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -236,7 +236,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)
/* Beware: real_path() and mkpath() return static buffer */
ref_git = xstrdup(real_path(item->string));
if (is_directory(mkpath("%s/.git/objects", ref_git))) {
- char *ref_git_git = xstrdup(mkpath("%s/.git", ref_git));
+ char *ref_git_git = mkpathdup("%s/.git", ref_git);
free(ref_git);
ref_git = ref_git_git;
} else if (!is_directory(mkpath("%s/objects", ref_git)))
@@ -700,7 +700,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
git_dir = xstrdup(dir);
else {
work_tree = dir;
- git_dir = xstrdup(mkpath("%s/.git", dir));
+ git_dir = mkpathdup("%s/.git", dir);
}
if (!option_bare) {
diff --git a/builtin/prune.c b/builtin/prune.c
index b99b635..f66ff67 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -168,7 +168,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
prune_packed_objects(show_only);
remove_temporary_files(get_object_directory());
- s = xstrdup(mkpath("%s/pack", get_object_directory()));
+ s = mkpathdup("%s/pack", get_object_directory());
remove_temporary_files(s);
free(s);
return 0;