Skip to content

Commit bba59f5

Browse files
pks-tgitster
authored andcommitted
path: drop git_pathdup() in favor of repo_git_path()
Remove `git_pathdup()` in favor of `repo_git_path()`. The latter does essentially the same, with the only exception that it does not rely on `the_repository` but takes the repo as separate parameter. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7f17900 commit bba59f5

File tree

16 files changed

+22
-36
lines changed

16 files changed

+22
-36
lines changed

bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r,
930930
if (!current_bad_oid)
931931
return error(_("a %s revision is needed"), term_bad);
932932

933-
filename = git_pathdup("BISECT_ANCESTORS_OK");
933+
filename = repo_git_path(the_repository, "BISECT_ANCESTORS_OK");
934934

935935
/* Check if file BISECT_ANCESTORS_OK exists. */
936936
if (!stat(filename, &st) && S_ISREG(st.st_mode))

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static void am_state_init(struct am_state *state)
158158

159159
memset(state, 0, sizeof(*state));
160160

161-
state->dir = git_pathdup("rebase-apply");
161+
state->dir = repo_git_path(the_repository, "rebase-apply");
162162

163163
state->prec = 4;
164164

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ static void write_refspec_config(const char *src_ref_prefix,
938938

939939
static void dissociate_from_references(void)
940940
{
941-
char *alternates = git_pathdup("objects/info/alternates");
941+
char *alternates = repo_git_path(the_repository, "objects/info/alternates");
942942

943943
if (!access(alternates, F_OK)) {
944944
struct child_process cmd = CHILD_PROCESS_INIT;

builtin/config.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,13 +775,13 @@ static void location_options_init(struct config_location_options *opts,
775775
opts->source.file = opts->file_to_free = git_system_config();
776776
opts->source.scope = CONFIG_SCOPE_SYSTEM;
777777
} else if (opts->use_local_config) {
778-
opts->source.file = opts->file_to_free = git_pathdup("config");
778+
opts->source.file = opts->file_to_free = repo_git_path(the_repository, "config");
779779
opts->source.scope = CONFIG_SCOPE_LOCAL;
780780
} else if (opts->use_worktree_config) {
781781
struct worktree **worktrees = get_worktrees();
782782
if (the_repository->repository_format_worktree_config)
783783
opts->source.file = opts->file_to_free =
784-
git_pathdup("config.worktree");
784+
repo_git_path(the_repository, "config.worktree");
785785
else if (worktrees[0] && worktrees[1])
786786
die(_("--worktree cannot be used with multiple "
787787
"working trees unless the config\n"
@@ -790,7 +790,7 @@ static void location_options_init(struct config_location_options *opts,
790790
"section in \"git help worktree\" for details"));
791791
else
792792
opts->source.file = opts->file_to_free =
793-
git_pathdup("config");
793+
repo_git_path(the_repository, "config");
794794
opts->source.scope = CONFIG_SCOPE_LOCAL;
795795
free_worktrees(worktrees);
796796
} else if (opts->source.file) {
@@ -1087,7 +1087,7 @@ static int show_editor(struct config_location_options *opts)
10871087
git_config(git_default_config, NULL);
10881088
config_file = opts->source.file ?
10891089
xstrdup(opts->source.file) :
1090-
git_pathdup("config");
1090+
repo_git_path(the_repository, "config");
10911091
if (opts->use_global_config) {
10921092
int fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);
10931093
if (fd >= 0) {

builtin/fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static void write_branch_report(FILE *rpt, struct branch *b)
328328

329329
static void write_crash_report(const char *err)
330330
{
331-
char *loc = git_pathdup("fast_import_crash_%"PRIuMAX, (uintmax_t) getpid());
331+
char *loc = repo_git_path(the_repository, "fast_import_crash_%"PRIuMAX, (uintmax_t) getpid());
332332
FILE *rpt = fopen(loc, "w");
333333
struct branch *b;
334334
unsigned long lu;
@@ -3280,7 +3280,7 @@ static char* make_fast_import_path(const char *path)
32803280
{
32813281
if (!relative_marks_paths || is_absolute_path(path))
32823282
return prefix_filename(global_prefix, path);
3283-
return git_pathdup("info/fast-import/%s", path);
3283+
return repo_git_path(the_repository, "info/fast-import/%s", path);
32843284
}
32853285

32863286
static void option_import_marks(const char *marks,

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static void check_unreachable_object(struct object *obj)
326326
printable_type(&obj->oid, obj->type),
327327
describe_object(&obj->oid));
328328
if (write_lost_and_found) {
329-
char *filename = git_pathdup("lost-found/%s/%s",
329+
char *filename = repo_git_path(the_repository, "lost-found/%s/%s",
330330
obj->type == OBJ_COMMIT ? "commit" : "other",
331331
describe_object(&obj->oid));
332332
FILE *f;

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
546546
if (xgethostname(my_host, sizeof(my_host)))
547547
xsnprintf(my_host, sizeof(my_host), "unknown");
548548

549-
pidfile_path = git_pathdup("gc.pid");
549+
pidfile_path = repo_git_path(the_repository, "gc.pid");
550550
fd = hold_lock_file_for_update(&lock, pidfile_path,
551551
LOCK_DIE_ON_ERROR);
552552
if (!force) {
@@ -607,7 +607,7 @@ static int report_last_gc_error(void)
607607
int ret = 0;
608608
ssize_t len;
609609
struct stat st;
610-
char *gc_log_path = git_pathdup("gc.log");
610+
char *gc_log_path = repo_git_path(the_repository, "gc.log");
611611

612612
if (stat(gc_log_path, &st)) {
613613
if (errno == ENOENT)

builtin/notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static void prepare_note_data(const struct object_id *object, struct note_data *
197197
struct strbuf buf = STRBUF_INIT;
198198

199199
/* write the template message before editing: */
200-
d->edit_path = git_pathdup("NOTES_EDITMSG");
200+
d->edit_path = repo_git_path(the_repository, "NOTES_EDITMSG");
201201
fd = xopen(d->edit_path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
202202

203203
if (d->msg_nr)

builtin/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
345345
}
346346
strbuf_release(&ref);
347347

348-
tmpfile = git_pathdup("REPLACE_EDITOBJ");
348+
tmpfile = repo_git_path(the_repository, "REPLACE_EDITOBJ");
349349
if (export_object(&old_oid, type, raw, tmpfile)) {
350350
free(tmpfile);
351351
return -1;

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ int cmd_tag(int argc,
667667
if (create_tag_object) {
668668
if (force_sign_annotate && !annotate)
669669
opt.sign = 1;
670-
path = git_pathdup("TAG_EDITMSG");
670+
path = repo_git_path(the_repository, "TAG_EDITMSG");
671671
create_tag(&object, object_ref, tag, &buf, &opt, &prev, &object,
672672
&trailer_args, path);
673673
}

0 commit comments

Comments
 (0)