Use git_pathdup instead of xstrdup(git_path(...))
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alex Riesen committed
Oct 27, 2008 at 11:22 UTC
a4f34cbb4cea1f0b0e625b528f269f4b517c64f8
9 files changed
+12
-12
builtin-config.c
+1
-1
@@ -84,7 +84,7 @@ static int get_value(const char* key_, const char* regex_)
84
local = config_exclusive_filename;
85
if (!local) {
86
const char *home = getenv("HOME");
87
- local = repo_config = xstrdup(git_path("config"));
87
+ local = repo_config = git_pathdup("config");
88
if (git_config_global() && home)
89
global = xstrdup(mkpath("%s/.gitconfig", home));
90
if (git_config_system())
builtin-reflog.c
+2
-2
@@ -277,11 +277,11 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
277
lock = lock_any_ref_for_update(ref, sha1, 0);
278
if (!lock)
279
return error("cannot lock ref '%s'", ref);
280
- log_file = xstrdup(git_path("logs/%s", ref));
280
+ log_file = git_pathdup("logs/%s", ref);
281
if (!file_exists(log_file))
282
goto finish;
283
if (!cmd->dry_run) {
284
- newlog_path = xstrdup(git_path("logs/%s.lock", ref));
284
+ newlog_path = git_pathdup("logs/%s.lock", ref);
285
cb.newlog = fopen(newlog_path, "w");
286
}
287
builtin-revert.c
+1
-1
@@ -269,7 +269,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
269
int i;
270
char *oneline, *reencoded_message = NULL;
271
const char *message, *encoding;
272
- const char *defmsg = xstrdup(git_path("MERGE_MSG"));
272
+ const char *defmsg = git_pathdup("MERGE_MSG");
273
274
git_config(git_default_config, NULL);
275
me = action == REVERT ? "revert" : "cherry-pick";
builtin-tag.c
+1
-1
@@ -283,7 +283,7 @@ static void create_tag(const unsigned char *object, const char *tag,
283
int fd;
284
285
/* write the template message before editing: */
286
- path = xstrdup(git_path("TAG_EDITMSG"));
286
+ path = git_pathdup("TAG_EDITMSG");
287
fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
288
if (fd < 0)
289
die("could not create file '%s': %s",
config.c
+3
-3
@@ -630,7 +630,7 @@ int git_config(config_fn_t fn, void *data)
630
free(user_config);
631
}
632
633
- repo_config = xstrdup(git_path("config"));
633
+ repo_config = git_pathdup("config");
634
ret += git_config_from_file(fn, repo_config, data);
635
free(repo_config);
636
return ret;
@@ -872,7 +872,7 @@ int git_config_set_multivar(const char* key, const char* value,
872
if (config_exclusive_filename)
873
config_filename = xstrdup(config_exclusive_filename);
874
else
875
- config_filename = xstrdup(git_path("config"));
875
+ config_filename = git_pathdup("config");
876
877
/*
878
* Since "key" actually contains the section name and the real
@@ -1132,7 +1132,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
1132
if (config_exclusive_filename)
1133
config_filename = xstrdup(config_exclusive_filename);
1134
else
1135
- config_filename = xstrdup(git_path("config"));
1135
+ config_filename = git_pathdup("config");
1136
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
1137
if (out_fd < 0) {
1138
ret = error("could not lock config file %s", config_filename);
environment.c
+1
-1
@@ -71,7 +71,7 @@ static void setup_git_env(void)
71
}
72
git_graft_file = getenv(GRAFT_ENVIRONMENT);
73
if (!git_graft_file)
74
- git_graft_file = xstrdup(git_path("info/grafts"));
74
+ git_graft_file = git_pathdup("info/grafts");
75
}
76
77
int is_bare_repository(void)
refs.c
+1
-1
@@ -1258,7 +1258,7 @@ int create_symref(const char *ref_target, const char *refs_heads_master,
1258
const char *lockpath;
1259
char ref[1000];
1260
int fd, len, written;
1261
- char *git_HEAD = xstrdup(git_path("%s", ref_target));
1261
+ char *git_HEAD = git_pathdup("%s", ref_target);
1262
unsigned char old_sha1[20], new_sha1[20];
1263
1264
if (logmsg && read_ref(ref_target, old_sha1))
rerere.c
+1
-1
@@ -345,7 +345,7 @@ int setup_rerere(struct string_list *merge_rr)
345
if (!is_rerere_enabled())
346
return -1;
347
348
- merge_rr_path = xstrdup(git_path("MERGE_RR"));
348
+ merge_rr_path = git_pathdup("MERGE_RR");
349
fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
350
read_rr(merge_rr);
351
return fd;
server-info.c
+1
-1
@@ -25,7 +25,7 @@ static int add_info_ref(const char *path, const unsigned char *sha1, int flag, v
25
26
static int update_info_refs(int force)
27
{
28
- char *path0 = xstrdup(git_path("info/refs"));
28
+ char *path0 = git_pathdup("info/refs");
29
int len = strlen(path0);
30
char *path1 = xmalloc(len + 2);
31