Skip to content

Commit a4f34cb

Browse files
raalkmlgitster
authored andcommitted
Use git_pathdup instead of xstrdup(git_path(...))
Signed-off-by: Junio C Hamano <[email protected]>
1 parent aba13e7 commit a4f34cb

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

builtin-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static int get_value(const char* key_, const char* regex_)
8484
local = config_exclusive_filename;
8585
if (!local) {
8686
const char *home = getenv("HOME");
87-
local = repo_config = xstrdup(git_path("config"));
87+
local = repo_config = git_pathdup("config");
8888
if (git_config_global() && home)
8989
global = xstrdup(mkpath("%s/.gitconfig", home));
9090
if (git_config_system())

builtin-reflog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
277277
lock = lock_any_ref_for_update(ref, sha1, 0);
278278
if (!lock)
279279
return error("cannot lock ref '%s'", ref);
280-
log_file = xstrdup(git_path("logs/%s", ref));
280+
log_file = git_pathdup("logs/%s", ref);
281281
if (!file_exists(log_file))
282282
goto finish;
283283
if (!cmd->dry_run) {
284-
newlog_path = xstrdup(git_path("logs/%s.lock", ref));
284+
newlog_path = git_pathdup("logs/%s.lock", ref);
285285
cb.newlog = fopen(newlog_path, "w");
286286
}
287287

builtin-revert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
269269
int i;
270270
char *oneline, *reencoded_message = NULL;
271271
const char *message, *encoding;
272-
const char *defmsg = xstrdup(git_path("MERGE_MSG"));
272+
const char *defmsg = git_pathdup("MERGE_MSG");
273273

274274
git_config(git_default_config, NULL);
275275
me = action == REVERT ? "revert" : "cherry-pick";

builtin-tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static void create_tag(const unsigned char *object, const char *tag,
283283
int fd;
284284

285285
/* write the template message before editing: */
286-
path = xstrdup(git_path("TAG_EDITMSG"));
286+
path = git_pathdup("TAG_EDITMSG");
287287
fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
288288
if (fd < 0)
289289
die("could not create file '%s': %s",

config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ int git_config(config_fn_t fn, void *data)
630630
free(user_config);
631631
}
632632

633-
repo_config = xstrdup(git_path("config"));
633+
repo_config = git_pathdup("config");
634634
ret += git_config_from_file(fn, repo_config, data);
635635
free(repo_config);
636636
return ret;
@@ -872,7 +872,7 @@ int git_config_set_multivar(const char* key, const char* value,
872872
if (config_exclusive_filename)
873873
config_filename = xstrdup(config_exclusive_filename);
874874
else
875-
config_filename = xstrdup(git_path("config"));
875+
config_filename = git_pathdup("config");
876876

877877
/*
878878
* 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)
11321132
if (config_exclusive_filename)
11331133
config_filename = xstrdup(config_exclusive_filename);
11341134
else
1135-
config_filename = xstrdup(git_path("config"));
1135+
config_filename = git_pathdup("config");
11361136
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
11371137
if (out_fd < 0) {
11381138
ret = error("could not lock config file %s", config_filename);

environment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void setup_git_env(void)
7171
}
7272
git_graft_file = getenv(GRAFT_ENVIRONMENT);
7373
if (!git_graft_file)
74-
git_graft_file = xstrdup(git_path("info/grafts"));
74+
git_graft_file = git_pathdup("info/grafts");
7575
}
7676

7777
int is_bare_repository(void)

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ int create_symref(const char *ref_target, const char *refs_heads_master,
12581258
const char *lockpath;
12591259
char ref[1000];
12601260
int fd, len, written;
1261-
char *git_HEAD = xstrdup(git_path("%s", ref_target));
1261+
char *git_HEAD = git_pathdup("%s", ref_target);
12621262
unsigned char old_sha1[20], new_sha1[20];
12631263

12641264
if (logmsg && read_ref(ref_target, old_sha1))

rerere.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ int setup_rerere(struct string_list *merge_rr)
345345
if (!is_rerere_enabled())
346346
return -1;
347347

348-
merge_rr_path = xstrdup(git_path("MERGE_RR"));
348+
merge_rr_path = git_pathdup("MERGE_RR");
349349
fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
350350
read_rr(merge_rr);
351351
return fd;

server-info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static int add_info_ref(const char *path, const unsigned char *sha1, int flag, v
2525

2626
static int update_info_refs(int force)
2727
{
28-
char *path0 = xstrdup(git_path("info/refs"));
28+
char *path0 = git_pathdup("info/refs");
2929
int len = strlen(path0);
3030
char *path1 = xmalloc(len + 2);
3131

0 commit comments

Comments
 (0)