path.c: migrate global git_path_* to take a repository argument
Migrate all git_path_* functions that are defined in path.c to take a repository argument. Unlike other patches in this series, do not use the #define trick, as we rewrite the whole function, which is rather small. This doesn't migrate all the functions, as other builtins have their own local path functions defined using GIT_PATH_FUNC. So keep that macro around to serve the other locations. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
May 17, 2018 at 15:51 UTC
102de880d24fe66a8916e7c984e5bf8db6be047c
15 files changed
+135
-101
blame.c
+5
-3
@@ -112,17 +112,19 @@ static void append_merge_parents(struct commit_list **tail)
112
int merge_head;
113
struct strbuf line = STRBUF_INIT;
114
115
- merge_head = open(git_path_merge_head(), O_RDONLY);
115
+ merge_head = open(git_path_merge_head(the_repository), O_RDONLY);
116
if (merge_head < 0) {
117
if (errno == ENOENT)
118
return;
119
- die("cannot open '%s' for reading", git_path_merge_head());
119
+ die("cannot open '%s' for reading",
120
+ git_path_merge_head(the_repository));
121
}
122
123
while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) {
124
struct object_id oid;
125
if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))
125
- die("unknown line in '%s': %s", git_path_merge_head(), line.buf);
126
+ die("unknown line in '%s': %s",
127
+ git_path_merge_head(the_repository), line.buf);
128
tail = append_parent(tail, &oid);
129
}
130
close(merge_head);
branch.c
+7
-7
@@ -339,13 +339,13 @@ void create_branch(const char *name, const char *start_name,
339
340
void remove_branch_state(void)
341
{
342
- unlink(git_path_cherry_pick_head());
343
- unlink(git_path_revert_head());
344
- unlink(git_path_merge_head());
345
- unlink(git_path_merge_rr());
346
- unlink(git_path_merge_msg());
347
- unlink(git_path_merge_mode());
348
- unlink(git_path_squash_msg());
342
+ unlink(git_path_cherry_pick_head(the_repository));
343
+ unlink(git_path_revert_head(the_repository));
344
+ unlink(git_path_merge_head(the_repository));
345
+ unlink(git_path_merge_rr(the_repository));
346
+ unlink(git_path_merge_msg(the_repository));
347
+ unlink(git_path_merge_mode(the_repository));
348
+ unlink(git_path_squash_msg(the_repository));
349
}
350
351
void die_if_checked_out(const char *branch, int ignore_current_worktree)
builtin/commit.c
+19
-19
@@ -145,9 +145,9 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)
145
146
static void determine_whence(struct wt_status *s)
147
{
148
- if (file_exists(git_path_merge_head()))
148
+ if (file_exists(git_path_merge_head(the_repository)))
149
whence = FROM_MERGE;
150
- else if (file_exists(git_path_cherry_pick_head())) {
150
+ else if (file_exists(git_path_cherry_pick_head(the_repository))) {
151
whence = FROM_CHERRY_PICK;
152
if (file_exists(git_path_seq_dir()))
153
sequencer_in_use = 1;
@@ -696,21 +696,21 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
696
if (have_option_m)
697
strbuf_addbuf(&sb, &message);
698
hook_arg1 = "message";
699
- } else if (!stat(git_path_merge_msg(), &statbuf)) {
699
+ } else if (!stat(git_path_merge_msg(the_repository), &statbuf)) {
700
/*
701
* prepend SQUASH_MSG here if it exists and a
702
* "merge --squash" was originally performed
703
*/
704
- if (!stat(git_path_squash_msg(), &statbuf)) {
705
- if (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)
704
+ if (!stat(git_path_squash_msg(the_repository), &statbuf)) {
705
+ if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)
706
die_errno(_("could not read SQUASH_MSG"));
707
hook_arg1 = "squash";
708
} else
709
hook_arg1 = "merge";
710
- if (strbuf_read_file(&sb, git_path_merge_msg(), 0) < 0)
710
+ if (strbuf_read_file(&sb, git_path_merge_msg(the_repository), 0) < 0)
711
die_errno(_("could not read MERGE_MSG"));
712
- } else if (!stat(git_path_squash_msg(), &statbuf)) {
713
- if (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)
712
+ } else if (!stat(git_path_squash_msg(the_repository), &statbuf)) {
713
+ if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)
714
die_errno(_("could not read SQUASH_MSG"));
715
hook_arg1 = "squash";
716
} else if (template_file) {
@@ -791,8 +791,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
791
" %s\n"
792
"and try again.\n"),
793
whence == FROM_MERGE ?
794
- git_path_merge_head() :
795
- git_path_cherry_pick_head());
794
+ git_path_merge_head(the_repository) :
795
+ git_path_cherry_pick_head(the_repository));
796
}
797
798
fprintf(s->fp, "\n");
@@ -1523,7 +1523,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1523
if (!reflog_msg)
1524
reflog_msg = "commit (merge)";
1525
pptr = commit_list_append(current_head, pptr);
1526
- fp = xfopen(git_path_merge_head(), "r");
1526
+ fp = xfopen(git_path_merge_head(the_repository), "r");
1527
while (strbuf_getline_lf(&m, fp) != EOF) {
1528
struct commit *parent;
1529
@@ -1534,8 +1534,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1534
}
1535
fclose(fp);
1536
strbuf_release(&m);
1537
- if (!stat(git_path_merge_mode(), &statbuf)) {
1538
- if (strbuf_read_file(&sb, git_path_merge_mode(), 0) < 0)
1537
+ if (!stat(git_path_merge_mode(the_repository), &statbuf)) {
1538
+ if (strbuf_read_file(&sb, git_path_merge_mode(the_repository), 0) < 0)
1539
die_errno(_("could not read MERGE_MODE"));
1540
if (!strcmp(sb.buf, "no-ff"))
1541
allow_fast_forward = 0;
@@ -1598,12 +1598,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1598
die("%s", err.buf);
1599
}
1600
1601
- unlink(git_path_cherry_pick_head());
1602
- unlink(git_path_revert_head());
1603
- unlink(git_path_merge_head());
1604
- unlink(git_path_merge_msg());
1605
- unlink(git_path_merge_mode());
1606
- unlink(git_path_squash_msg());
1601
+ unlink(git_path_cherry_pick_head(the_repository));
1602
+ unlink(git_path_revert_head(the_repository));
1603
+ unlink(git_path_merge_head(the_repository));
1604
+ unlink(git_path_merge_msg(the_repository));
1605
+ unlink(git_path_merge_mode(the_repository));
1606
+ unlink(git_path_squash_msg(the_repository));
1607
1608
if (commit_index_files())
1609
die (_("Repository has been updated, but unable to write\n"
builtin/fetch.c
+2
-2
@@ -767,7 +767,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
767
const char *what, *kind;
768
struct ref *rm;
769
char *url;
770
- const char *filename = dry_run ? "/dev/null" : git_path_fetch_head();
770
+ const char *filename = dry_run ? "/dev/null" : git_path_fetch_head(the_repository);
771
int want_status;
772
int summary_width = transport_summary_width(ref_map);
773
@@ -1019,7 +1019,7 @@ static void check_not_current_branch(struct ref *ref_map)
1019
1020
static int truncate_fetch_head(void)
1021
{
1022
- const char *filename = git_path_fetch_head();
1022
+ const char *filename = git_path_fetch_head(the_repository);
1023
FILE *fp = fopen_for_writing(filename);
1024
1025
if (!fp)
builtin/merge.c
+19
-18
@@ -245,9 +245,9 @@ static struct option builtin_merge_options[] = {
245
/* Cleans up metadata that is uninteresting after a succeeded merge. */
246
static void drop_save(void)
247
{
248
- unlink(git_path_merge_head());
249
- unlink(git_path_merge_msg());
250
- unlink(git_path_merge_mode());
248
+ unlink(git_path_merge_head(the_repository));
249
+ unlink(git_path_merge_msg(the_repository));
250
+ unlink(git_path_merge_mode(the_repository));
251
}
252
253
static int save_state(struct object_id *stash)
@@ -380,7 +380,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
380
oid_to_hex(&commit->object.oid));
381
pretty_print_commit(&ctx, commit, &out);
382
}
383
- write_file_buf(git_path_squash_msg(), out.buf, out.len);
383
+ write_file_buf(git_path_squash_msg(the_repository), out.buf, out.len);
384
strbuf_release(&out);
385
}
386
@@ -741,7 +741,7 @@ static void add_strategies(const char *string, unsigned attr)
741
742
static void read_merge_msg(struct strbuf *msg)
743
{
744
- const char *filename = git_path_merge_msg();
744
+ const char *filename = git_path_merge_msg(the_repository);
745
strbuf_reset(msg);
746
if (strbuf_read_file(msg, filename, 0) < 0)
747
die_errno(_("Could not read from '%s'"), filename);
@@ -778,18 +778,18 @@ static void prepare_to_commit(struct commit_list *remoteheads)
778
if (signoff)
779
append_signoff(&msg, ignore_non_trailer(msg.buf, msg.len), 0);
780
write_merge_heads(remoteheads);
781
- write_file_buf(git_path_merge_msg(), msg.buf, msg.len);
781
+ write_file_buf(git_path_merge_msg(the_repository), msg.buf, msg.len);
782
if (run_commit_hook(0 < option_edit, get_index_file(), "prepare-commit-msg",
783
- git_path_merge_msg(), "merge", NULL))
783
+ git_path_merge_msg(the_repository), "merge", NULL))
784
abort_commit(remoteheads, NULL);
785
if (0 < option_edit) {
786
- if (launch_editor(git_path_merge_msg(), NULL, NULL))
786
+ if (launch_editor(git_path_merge_msg(the_repository), NULL, NULL))
787
abort_commit(remoteheads, NULL);
788
}
789
790
if (verify_msg && run_commit_hook(0 < option_edit, get_index_file(),
791
"commit-msg",
792
- git_path_merge_msg(), NULL))
792
+ git_path_merge_msg(the_repository), NULL))
793
abort_commit(remoteheads, NULL);
794
795
read_merge_msg(&msg);
@@ -859,7 +859,7 @@ static int suggest_conflicts(void)
859
FILE *fp;
860
struct strbuf msgbuf = STRBUF_INIT;
861
862
- filename = git_path_merge_msg();
862
+ filename = git_path_merge_msg(the_repository);
863
fp = xfopen(filename, "a");
864
865
append_conflicts_hint(&msgbuf);
@@ -939,12 +939,12 @@ static void write_merge_heads(struct commit_list *remoteheads)
939
}
940
strbuf_addf(&buf, "%s\n", oid_to_hex(oid));
941
}
942
- write_file_buf(git_path_merge_head(), buf.buf, buf.len);
942
+ write_file_buf(git_path_merge_head(the_repository), buf.buf, buf.len);
943
944
strbuf_reset(&buf);
945
if (fast_forward == FF_NO)
946
strbuf_addstr(&buf, "no-ff");
947
- write_file_buf(git_path_merge_mode(), buf.buf, buf.len);
947
+ write_file_buf(git_path_merge_mode(the_repository), buf.buf, buf.len);
948
strbuf_release(&buf);
949
}
950
@@ -952,7 +952,8 @@ static void write_merge_state(struct commit_list *remoteheads)
952
{
953
write_merge_heads(remoteheads);
954
strbuf_addch(&merge_msg, '\n');
955
- write_file_buf(git_path_merge_msg(), merge_msg.buf, merge_msg.len);
955
+ write_file_buf(git_path_merge_msg(the_repository), merge_msg.buf,
956
+ merge_msg.len);
957
}
958
959
static int default_edit_option(void)
@@ -1035,7 +1036,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge
1036
if (!merge_names)
1037
merge_names = &fetch_head_file;
1038
1038
- filename = git_path_fetch_head();
1039
+ filename = git_path_fetch_head(the_repository);
1040
fd = open(filename, O_RDONLY);
1041
if (fd < 0)
1042
die_errno(_("could not open '%s' for reading"), filename);
@@ -1209,7 +1210,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1210
usage_msg_opt(_("--abort expects no arguments"),
1211
builtin_merge_usage, builtin_merge_options);
1212
1212
- if (!file_exists(git_path_merge_head()))
1213
+ if (!file_exists(git_path_merge_head(the_repository)))
1214
die(_("There is no merge to abort (MERGE_HEAD missing)."));
1215
1216
/* Invoke 'git reset --merge' */
@@ -1225,7 +1226,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1226
usage_msg_opt(_("--continue expects no arguments"),
1227
builtin_merge_usage, builtin_merge_options);
1228
1228
- if (!file_exists(git_path_merge_head()))
1229
+ if (!file_exists(git_path_merge_head(the_repository)))
1230
die(_("There is no merge in progress (MERGE_HEAD missing)."));
1231
1232
/* Invoke 'git commit' */
@@ -1236,7 +1237,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1237
if (read_cache_unmerged())
1238
die_resolve_conflict("merge");
1239
1239
- if (file_exists(git_path_merge_head())) {
1240
+ if (file_exists(git_path_merge_head(the_repository))) {
1241
/*
1242
* There is no unmerged entry, don't advise 'git
1243
* add/rm <file>', just 'git commit'.
@@ -1247,7 +1248,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1248
else
1249
die(_("You have not concluded your merge (MERGE_HEAD exists)."));
1250
}
1250
- if (file_exists(git_path_cherry_pick_head())) {
1251
+ if (file_exists(git_path_cherry_pick_head(the_repository))) {
1252
if (advice_resolve_conflict)
1253
die(_("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
1254
"Please, commit your changes before you merge."));
builtin/pull.c
+2
-2
@@ -351,7 +351,7 @@ static int git_pull_config(const char *var, const char *value, void *cb)
351
*/
352
static void get_merge_heads(struct oid_array *merge_heads)
353
{
354
- const char *filename = git_path_fetch_head();
354
+ const char *filename = git_path_fetch_head(the_repository);
355
FILE *fp;
356
struct strbuf sb = STRBUF_INIT;
357
struct object_id oid;
@@ -857,7 +857,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
857
if (read_cache_unmerged())
858
die_resolve_conflict("pull");
859
860
- if (file_exists(git_path_merge_head()))
860
+ if (file_exists(git_path_merge_head(the_repository)))
861
die_conclude_merge();
862
863
if (get_oid("HEAD", &orig_head))
builtin/reset.c
+1
-1
@@ -39,7 +39,7 @@ static const char *reset_type_names[] = {
39
40
static inline int is_merge(void)
41
{
42
- return !access(git_path_merge_head(), F_OK);
42
+ return !access(git_path_merge_head(the_repository), F_OK);
43
}
44
45
static int reset_index(const struct object_id *oid, int reset_type, int quiet)
fetch-pack.c
+1
-1
@@ -1136,7 +1136,7 @@ static void update_shallow(struct fetch_pack_args *args,
1136
1137
if (args->deepen && alternate_shallow_file) {
1138
if (*alternate_shallow_file == '\0') { /* --unshallow */
1139
- unlink_or_warn(git_path_shallow());
1139
+ unlink_or_warn(git_path_shallow(the_repository));
1140
rollback_lock_file(&shallow_lock);
1141
} else
1142
commit_lock_file(&shallow_lock);
path.c
+9
-9
@@ -1358,12 +1358,12 @@ char *xdg_cache_home(const char *filename)
1358
return NULL;
1359
}
1360
1361
-GIT_PATH_FUNC(git_path_cherry_pick_head, "CHERRY_PICK_HEAD")
1362
-GIT_PATH_FUNC(git_path_revert_head, "REVERT_HEAD")
1363
-GIT_PATH_FUNC(git_path_squash_msg, "SQUASH_MSG")
1364
-GIT_PATH_FUNC(git_path_merge_msg, "MERGE_MSG")
1365
-GIT_PATH_FUNC(git_path_merge_rr, "MERGE_RR")
1366
-GIT_PATH_FUNC(git_path_merge_mode, "MERGE_MODE")
1367
-GIT_PATH_FUNC(git_path_merge_head, "MERGE_HEAD")
1368
-GIT_PATH_FUNC(git_path_fetch_head, "FETCH_HEAD")
1369
-GIT_PATH_FUNC(git_path_shallow, "shallow")
1361
+REPO_GIT_PATH_FUNC(cherry_pick_head, "CHERRY_PICK_HEAD")
1362
+REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD")
1363
+REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG")
1364
+REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")
1365
+REPO_GIT_PATH_FUNC(merge_rr, "MERGE_RR")
1366
+REPO_GIT_PATH_FUNC(merge_mode, "MERGE_MODE")
1367
+REPO_GIT_PATH_FUNC(merge_head, "MERGE_HEAD")
1368
+REPO_GIT_PATH_FUNC(fetch_head, "FETCH_HEAD")
1369
+REPO_GIT_PATH_FUNC(shallow, "shallow")
path.h
+31
-9
@@ -160,14 +160,36 @@ extern void report_linked_checkout_garbage(void);
160
return ret; \
161
}
162
163
-const char *git_path_cherry_pick_head(void);
164
-const char *git_path_revert_head(void);
165
-const char *git_path_squash_msg(void);
166
-const char *git_path_merge_msg(void);
167
-const char *git_path_merge_rr(void);
168
-const char *git_path_merge_mode(void);
169
-const char *git_path_merge_head(void);
170
-const char *git_path_fetch_head(void);
171
-const char *git_path_shallow(void);
163
+#define REPO_GIT_PATH_FUNC(var, filename) \
164
+ const char *git_path_##var(struct repository *r) \
165
+ { \
166
+ if (!r->cached_paths.var) \
167
+ r->cached_paths.var = git_pathdup(filename); \
168
+ return r->cached_paths.var; \
169
+ }
170
+
171
+struct path_cache {
172
+ const char *cherry_pick_head;
173
+ const char *revert_head;
174
+ const char *squash_msg;
175
+ const char *merge_msg;
176
+ const char *merge_rr;
177
+ const char *merge_mode;
178
+ const char *merge_head;
179
+ const char *fetch_head;
180
+ const char *shallow;
181
+};
182
+
183
+#define PATH_CACHE_INIT { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
184
+
185
+const char *git_path_cherry_pick_head(struct repository *r);
186
+const char *git_path_revert_head(struct repository *r);
187
+const char *git_path_squash_msg(struct repository *r);
188
+const char *git_path_merge_msg(struct repository *r);
189
+const char *git_path_merge_rr(struct repository *r);
190
+const char *git_path_merge_mode(struct repository *r);
191
+const char *git_path_merge_head(struct repository *r);
192
+const char *git_path_fetch_head(struct repository *r);
193
+const char *git_path_shallow(struct repository *r);
194
195
#endif /* PATH_H */
repository.h
+5
@@ -38,6 +38,11 @@ struct repository {
38
/* The store in which the refs are held. */
39
struct ref_store *refs;
40
41
+ /*
42
+ * Contains path to often used file names.
43
+ */
44
+ struct path_cache cached_paths;
45
+
46
/*
47
* Path to the repository's graft file.
48
* Cannot be NULL after initialization.
rerere.c
+4
-3
@@ -201,7 +201,7 @@ static struct rerere_id *new_rerere_id(unsigned char *sha1)
201
static void read_rr(struct string_list *rr)
202
{
203
struct strbuf buf = STRBUF_INIT;
204
- FILE *in = fopen_or_warn(git_path_merge_rr(), "r");
204
+ FILE *in = fopen_or_warn(git_path_merge_rr(the_repository), "r");
205
206
if (!in)
207
return;
@@ -897,7 +897,8 @@ int setup_rerere(struct string_list *merge_rr, int flags)
897
if (flags & RERERE_READONLY)
898
fd = 0;
899
else
900
- fd = hold_lock_file_for_update(&write_lock, git_path_merge_rr(),
900
+ fd = hold_lock_file_for_update(&write_lock,
901
+ git_path_merge_rr(the_repository),
902
LOCK_DIE_ON_ERROR);
903
read_rr(merge_rr);
904
return fd;
@@ -1247,6 +1248,6 @@ void rerere_clear(struct string_list *merge_rr)
1248
rmdir(rerere_path(id, NULL));
1249
}
1250
}
1250
- unlink_or_warn(git_path_merge_rr());
1251
+ unlink_or_warn(git_path_merge_rr(the_repository));
1252
rollback_lock_file(&write_lock);
1253
}
sequencer.c
+19
-18
@@ -322,7 +322,7 @@ static void print_advice(int show_hint, struct replay_opts *opts)
322
* (typically rebase --interactive) wants to take care
323
* of the commit itself so remove CHERRY_PICK_HEAD
324
*/
325
- unlink(git_path_cherry_pick_head());
325
+ unlink(git_path_cherry_pick_head(the_repository));
326
return;
327
}
328
@@ -1191,8 +1191,8 @@ static int do_commit(const char *msg_file, const char *author,
1191
&oid);
1192
strbuf_release(&sb);
1193
if (!res) {
1194
- unlink(git_path_cherry_pick_head());
1195
- unlink(git_path_merge_msg());
1194
+ unlink(git_path_cherry_pick_head(the_repository));
1195
+ unlink(git_path_merge_msg(the_repository));
1196
if (!is_rebase_i(opts))
1197
print_commit_summary(NULL, &oid,
1198
SUMMARY_SHOW_AUTHOR_DATE);
@@ -1459,7 +1459,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
1459
struct replay_opts *opts, int final_fixup)
1460
{
1461
unsigned int flags = opts->edit ? EDIT_MSG : 0;
1462
- const char *msg_file = opts->edit ? NULL : git_path_merge_msg();
1462
+ const char *msg_file = opts->edit ? NULL : git_path_merge_msg(the_repository);
1463
struct object_id head;
1464
struct commit *base, *next, *parent;
1465
const char *base_label, *next_label;
@@ -1594,12 +1594,12 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
1594
flags |= CLEANUP_MSG;
1595
msg_file = rebase_path_fixup_msg();
1596
} else {
1597
- const char *dest = git_path_squash_msg();
1597
+ const char *dest = git_path_squash_msg(the_repository);
1598
unlink(dest);
1599
if (copy_file(dest, rebase_path_squash_msg(), 0666))
1600
return error(_("could not rename '%s' to '%s'"),
1601
rebase_path_squash_msg(), dest);
1602
- unlink(git_path_merge_msg());
1602
+ unlink(git_path_merge_msg(the_repository));
1603
msg_file = dest;
1604
flags |= EDIT_MSG;
1605
}
@@ -1616,13 +1616,13 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
1616
if (res < 0)
1617
return res;
1618
res |= write_message(msgbuf.buf, msgbuf.len,
1619
- git_path_merge_msg(), 0);
1619
+ git_path_merge_msg(the_repository), 0);
1620
} else {
1621
struct commit_list *common = NULL;
1622
struct commit_list *remotes = NULL;
1623
1624
res = write_message(msgbuf.buf, msgbuf.len,
1625
- git_path_merge_msg(), 0);
1625
+ git_path_merge_msg(the_repository), 0);
1626
1627
commit_list_insert(base, &common);
1628
commit_list_insert(next, &remotes);
@@ -2168,8 +2168,8 @@ static int rollback_single_pick(void)
2168
{
2169
struct object_id head_oid;
2170
2171
- if (!file_exists(git_path_cherry_pick_head()) &&
2172
- !file_exists(git_path_revert_head()))
2171
+ if (!file_exists(git_path_cherry_pick_head(the_repository)) &&
2172
+ !file_exists(git_path_revert_head(the_repository)))
2173
return error(_("no cherry-pick or revert in progress"));
2174
if (read_ref_full("HEAD", 0, &head_oid, NULL))
2175
return error(_("cannot resolve HEAD"));
@@ -2397,10 +2397,11 @@ static int error_failed_squash(struct commit *commit,
2397
return error(_("could not rename '%s' to '%s'"),
2398
rebase_path_squash_msg(), rebase_path_message());
2399
unlink(rebase_path_fixup_msg());
2400
- unlink(git_path_merge_msg());
2401
- if (copy_file(git_path_merge_msg(), rebase_path_message(), 0666))
2400
+ unlink(git_path_merge_msg(the_repository));
2401
+ if (copy_file(git_path_merge_msg(the_repository), rebase_path_message(), 0666))
2402
return error(_("could not copy '%s' to '%s'"),
2403
- rebase_path_message(), git_path_merge_msg());
2403
+ rebase_path_message(),
2404
+ git_path_merge_msg(the_repository));
2405
return error_with_patch(commit, subject, subject_len, opts, 1, 0);
2406
}
2407
@@ -2756,8 +2757,8 @@ static int continue_single_pick(void)
2757
{
2758
const char *argv[] = { "commit", NULL };
2759
2759
- if (!file_exists(git_path_cherry_pick_head()) &&
2760
- !file_exists(git_path_revert_head()))
2760
+ if (!file_exists(git_path_cherry_pick_head(the_repository)) &&
2761
+ !file_exists(git_path_revert_head(the_repository)))
2762
return error(_("no cherry-pick or revert in progress"));
2763
return run_command_v_opt(argv, RUN_GIT_CMD);
2764
}
@@ -2769,7 +2770,7 @@ static int commit_staged_changes(struct replay_opts *opts)
2770
if (has_unstaged_changes(1))
2771
return error(_("cannot rebase: You have unstaged changes."));
2772
if (!has_uncommitted_changes(0)) {
2772
- const char *cherry_pick_head = git_path_cherry_pick_head();
2773
+ const char *cherry_pick_head = git_path_cherry_pick_head(the_repository);
2774
2775
if (file_exists(cherry_pick_head) && unlink(cherry_pick_head))
2776
return error(_("could not remove CHERRY_PICK_HEAD"));
@@ -2823,8 +2824,8 @@ int sequencer_continue(struct replay_opts *opts)
2824
2825
if (!is_rebase_i(opts)) {
2826
/* Verify that the conflict has been resolved */
2826
- if (file_exists(git_path_cherry_pick_head()) ||
2827
- file_exists(git_path_revert_head())) {
2827
+ if (file_exists(git_path_cherry_pick_head(the_repository)) ||
2828
+ file_exists(git_path_revert_head(the_repository))) {
2829
res = continue_single_pick();
2830
if (res)
2831
goto release_todo_list;
shallow.c
+7
-5
@@ -52,7 +52,7 @@ int is_repository_shallow_the_repository(void)
52
return is_shallow;
53
54
if (!path)
55
- path = git_path_shallow();
55
+ path = git_path_shallow(the_repository);
56
/*
57
* fetch-pack sets '--shallow-file ""' as an indicator that no
58
* shallow file should be used. We could just open it and it
@@ -223,7 +223,7 @@ static void check_shallow_file_for_update_the_repository(void)
223
if (is_shallow == -1)
224
die("BUG: shallow must be initialized by now");
225
226
- if (!stat_validity_check(&shallow_stat, git_path_shallow()))
226
+ if (!stat_validity_check(&shallow_stat, git_path_shallow(the_repository)))
227
die("shallow file has changed since we read it");
228
}
229
@@ -318,7 +318,8 @@ void setup_alternate_shallow(struct lock_file *shallow_lock,
318
struct strbuf sb = STRBUF_INIT;
319
int fd;
320
321
- fd = hold_lock_file_for_update(shallow_lock, git_path_shallow(),
321
+ fd = hold_lock_file_for_update(shallow_lock,
322
+ git_path_shallow(the_repository),
323
LOCK_DIE_ON_ERROR);
324
check_shallow_file_for_update(the_repository);
325
if (write_shallow_commits(&sb, 0, extra)) {
@@ -365,7 +366,8 @@ void prune_shallow(int show_only)
366
strbuf_release(&sb);
367
return;
368
}
368
- fd = hold_lock_file_for_update(&shallow_lock, git_path_shallow(),
369
+ fd = hold_lock_file_for_update(&shallow_lock,
370
+ git_path_shallow(the_repository),
371
LOCK_DIE_ON_ERROR);
372
check_shallow_file_for_update(the_repository);
373
if (write_shallow_commits_1(&sb, 0, NULL, SEEN_ONLY)) {
@@ -374,7 +376,7 @@ void prune_shallow(int show_only)
376
get_lock_file_path(&shallow_lock));
377
commit_lock_file(&shallow_lock);
378
} else {
377
- unlink(git_path_shallow());
379
+ unlink(git_path_shallow(the_repository));
380
rollback_lock_file(&shallow_lock);
381
}
382
strbuf_release(&sb);
wt-status.c
+4
-4
@@ -1309,7 +1309,7 @@ static void show_rebase_in_progress(struct wt_status *s,
1309
status_printf_ln(s, color,
1310
_(" (use \"git rebase --abort\" to check out the original branch)"));
1311
}
1312
- } else if (state->rebase_in_progress || !stat(git_path_merge_msg(), &st)) {
1312
+ } else if (state->rebase_in_progress || !stat(git_path_merge_msg(the_repository), &st)) {
1313
print_rebase_state(s, state, color);
1314
if (s->hints)
1315
status_printf_ln(s, color,
@@ -1544,17 +1544,17 @@ void wt_status_get_state(struct wt_status_state *state,
1544
struct stat st;
1545
struct object_id oid;
1546
1547
- if (!stat(git_path_merge_head(), &st)) {
1547
+ if (!stat(git_path_merge_head(the_repository), &st)) {
1548
state->merge_in_progress = 1;
1549
} else if (wt_status_check_rebase(NULL, state)) {
1550
; /* all set */
1551
- } else if (!stat(git_path_cherry_pick_head(), &st) &&
1551
+ } else if (!stat(git_path_cherry_pick_head(the_repository), &st) &&
1552
!get_oid("CHERRY_PICK_HEAD", &oid)) {
1553
state->cherry_pick_in_progress = 1;
1554
oidcpy(&state->cherry_pick_head_oid, &oid);
1555
}
1556
wt_status_check_bisect(NULL, state);
1557
- if (!stat(git_path_revert_head(), &st) &&
1557
+ if (!stat(git_path_revert_head(the_repository), &st) &&
1558
!get_oid("REVERT_HEAD", &oid)) {
1559
state->revert_in_progress = 1;
1560
oidcpy(&state->revert_head_oid, &oid);