Skip to content

Commit 00624d6

Browse files
committed
Merge branch 'sb/object-store-grafts'
The conversion to pass "the_repository" and then "a_repository" throughout the object access API continues. * sb/object-store-grafts: commit: allow lookup_commit_graft to handle arbitrary repositories commit: allow prepare_commit_graft to handle arbitrary repositories shallow: migrate shallow information into the object parser path.c: migrate global git_path_* to take a repository argument cache: convert get_graft_file to handle arbitrary repositories commit: convert read_graft_file to handle arbitrary repositories commit: convert register_commit_graft to handle arbitrary repositories commit: convert commit_graft_pos() to handle arbitrary repositories shallow: add repository argument to is_repository_shallow shallow: add repository argument to check_shallow_file_for_update shallow: add repository argument to register_shallow shallow: add repository argument to set_alternate_shallow_file commit: add repository argument to lookup_commit_graft commit: add repository argument to prepare_commit_graft commit: add repository argument to read_graft_file commit: add repository argument to register_commit_graft commit: add repository argument to commit_graft_pos object: move grafts to object parser object-store: move object access functions to object-store.h
2 parents 473b8bb + b9dbddf commit 00624d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+463
-328
lines changed

apply.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "cache.h"
1111
#include "config.h"
12+
#include "object-store.h"
1213
#include "blob.h"
1314
#include "delta.h"
1415
#include "diff.h"

archive-tar.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "config.h"
66
#include "tar.h"
77
#include "archive.h"
8+
#include "object-store.h"
89
#include "streaming.h"
910
#include "run-command.h"
1011

archive-zip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "archive.h"
77
#include "streaming.h"
88
#include "utf8.h"
9+
#include "object-store.h"
910
#include "userdiff.h"
1011
#include "xdiff-interface.h"
1112

archive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "cache.h"
22
#include "config.h"
33
#include "refs.h"
4+
#include "object-store.h"
45
#include "commit.h"
56
#include "tree-walk.h"
67
#include "attr.h"

blame.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "cache.h"
22
#include "refs.h"
3+
#include "object-store.h"
34
#include "cache-tree.h"
45
#include "mergesort.h"
56
#include "diff.h"
@@ -129,17 +130,19 @@ static void append_merge_parents(struct commit_list **tail)
129130
int merge_head;
130131
struct strbuf line = STRBUF_INIT;
131132

132-
merge_head = open(git_path_merge_head(), O_RDONLY);
133+
merge_head = open(git_path_merge_head(the_repository), O_RDONLY);
133134
if (merge_head < 0) {
134135
if (errno == ENOENT)
135136
return;
136-
die("cannot open '%s' for reading", git_path_merge_head());
137+
die("cannot open '%s' for reading",
138+
git_path_merge_head(the_repository));
137139
}
138140

139141
while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) {
140142
struct object_id oid;
141143
if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))
142-
die("unknown line in '%s': %s", git_path_merge_head(), line.buf);
144+
die("unknown line in '%s': %s",
145+
git_path_merge_head(the_repository), line.buf);
143146
tail = append_parent(tail, &oid);
144147
}
145148
close(merge_head);

branch.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,13 @@ void create_branch(const char *name, const char *start_name,
340340

341341
void remove_branch_state(void)
342342
{
343-
unlink(git_path_cherry_pick_head());
344-
unlink(git_path_revert_head());
345-
unlink(git_path_merge_head());
346-
unlink(git_path_merge_rr());
347-
unlink(git_path_merge_msg());
348-
unlink(git_path_merge_mode());
349-
unlink(git_path_squash_msg());
343+
unlink(git_path_cherry_pick_head(the_repository));
344+
unlink(git_path_revert_head(the_repository));
345+
unlink(git_path_merge_head(the_repository));
346+
unlink(git_path_merge_rr(the_repository));
347+
unlink(git_path_merge_msg(the_repository));
348+
unlink(git_path_merge_mode(the_repository));
349+
unlink(git_path_squash_msg(the_repository));
350350
}
351351

352352
void die_if_checked_out(const char *branch, int ignore_current_worktree)

builtin/blame.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "config.h"
1010
#include "color.h"
1111
#include "builtin.h"
12+
#include "repository.h"
1213
#include "commit.h"
1314
#include "diff.h"
1415
#include "revision.h"
@@ -23,6 +24,7 @@
2324
#include "line-log.h"
2425
#include "dir.h"
2526
#include "progress.h"
27+
#include "object-store.h"
2628
#include "blame.h"
2729
#include "string-list.h"
2830

@@ -576,7 +578,7 @@ static int read_ancestry(const char *graft_file)
576578
/* The format is just "Commit Parent1 Parent2 ...\n" */
577579
struct commit_graft *graft = read_graft_line(&buf);
578580
if (graft)
579-
register_commit_graft(graft, 0);
581+
register_commit_graft(the_repository, graft, 0);
580582
}
581583
fclose(fp);
582584
strbuf_release(&buf);

builtin/cat-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "tree-walk.h"
1414
#include "sha1-array.h"
1515
#include "packfile.h"
16+
#include "object-store.h"
1617

1718
struct batch_options {
1819
int enabled;

builtin/checkout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "lockfile.h"
55
#include "parse-options.h"
66
#include "refs.h"
7+
#include "object-store.h"
78
#include "commit.h"
89
#include "tree.h"
910
#include "tree-walk.h"

builtin/clone.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "fetch-pack.h"
1616
#include "refs.h"
1717
#include "refspec.h"
18+
#include "object-store.h"
1819
#include "tree.h"
1920
#include "tree-walk.h"
2021
#include "unpack-trees.h"

builtin/commit-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include "cache.h"
77
#include "config.h"
8+
#include "object-store.h"
89
#include "commit.h"
910
#include "tree.h"
1011
#include "builtin.h"

builtin/commit.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ static int opt_parse_rename_score(const struct option *opt, const char *arg, int
168168

169169
static void determine_whence(struct wt_status *s)
170170
{
171-
if (file_exists(git_path_merge_head()))
171+
if (file_exists(git_path_merge_head(the_repository)))
172172
whence = FROM_MERGE;
173-
else if (file_exists(git_path_cherry_pick_head())) {
173+
else if (file_exists(git_path_cherry_pick_head(the_repository))) {
174174
whence = FROM_CHERRY_PICK;
175175
if (file_exists(git_path_seq_dir()))
176176
sequencer_in_use = 1;
@@ -718,21 +718,21 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
718718
if (have_option_m)
719719
strbuf_addbuf(&sb, &message);
720720
hook_arg1 = "message";
721-
} else if (!stat(git_path_merge_msg(), &statbuf)) {
721+
} else if (!stat(git_path_merge_msg(the_repository), &statbuf)) {
722722
/*
723723
* prepend SQUASH_MSG here if it exists and a
724724
* "merge --squash" was originally performed
725725
*/
726-
if (!stat(git_path_squash_msg(), &statbuf)) {
727-
if (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)
726+
if (!stat(git_path_squash_msg(the_repository), &statbuf)) {
727+
if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)
728728
die_errno(_("could not read SQUASH_MSG"));
729729
hook_arg1 = "squash";
730730
} else
731731
hook_arg1 = "merge";
732-
if (strbuf_read_file(&sb, git_path_merge_msg(), 0) < 0)
732+
if (strbuf_read_file(&sb, git_path_merge_msg(the_repository), 0) < 0)
733733
die_errno(_("could not read MERGE_MSG"));
734-
} else if (!stat(git_path_squash_msg(), &statbuf)) {
735-
if (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)
734+
} else if (!stat(git_path_squash_msg(the_repository), &statbuf)) {
735+
if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)
736736
die_errno(_("could not read SQUASH_MSG"));
737737
hook_arg1 = "squash";
738738
} else if (template_file) {
@@ -813,8 +813,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
813813
" %s\n"
814814
"and try again.\n"),
815815
whence == FROM_MERGE ?
816-
git_path_merge_head() :
817-
git_path_cherry_pick_head());
816+
git_path_merge_head(the_repository) :
817+
git_path_cherry_pick_head(the_repository));
818818
}
819819

820820
fprintf(s->fp, "\n");
@@ -1564,7 +1564,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
15641564
if (!reflog_msg)
15651565
reflog_msg = "commit (merge)";
15661566
pptr = commit_list_append(current_head, pptr);
1567-
fp = xfopen(git_path_merge_head(), "r");
1567+
fp = xfopen(git_path_merge_head(the_repository), "r");
15681568
while (strbuf_getline_lf(&m, fp) != EOF) {
15691569
struct commit *parent;
15701570

@@ -1575,8 +1575,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
15751575
}
15761576
fclose(fp);
15771577
strbuf_release(&m);
1578-
if (!stat(git_path_merge_mode(), &statbuf)) {
1579-
if (strbuf_read_file(&sb, git_path_merge_mode(), 0) < 0)
1578+
if (!stat(git_path_merge_mode(the_repository), &statbuf)) {
1579+
if (strbuf_read_file(&sb, git_path_merge_mode(the_repository), 0) < 0)
15801580
die_errno(_("could not read MERGE_MODE"));
15811581
if (!strcmp(sb.buf, "no-ff"))
15821582
allow_fast_forward = 0;
@@ -1639,12 +1639,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16391639
die("%s", err.buf);
16401640
}
16411641

1642-
unlink(git_path_cherry_pick_head());
1643-
unlink(git_path_revert_head());
1644-
unlink(git_path_merge_head());
1645-
unlink(git_path_merge_msg());
1646-
unlink(git_path_merge_mode());
1647-
unlink(git_path_squash_msg());
1642+
unlink(git_path_cherry_pick_head(the_repository));
1643+
unlink(git_path_revert_head(the_repository));
1644+
unlink(git_path_merge_head(the_repository));
1645+
unlink(git_path_merge_msg(the_repository));
1646+
unlink(git_path_merge_mode(the_repository));
1647+
unlink(git_path_squash_msg(the_repository));
16481648

16491649
if (commit_index_files())
16501650
die (_("Repository has been updated, but unable to write\n"

builtin/describe.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "hashmap.h"
1414
#include "argv-array.h"
1515
#include "run-command.h"
16+
#include "object-store.h"
1617
#include "revision.h"
1718
#include "list-objects.h"
1819
#include "commit-slab.h"

builtin/difftool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "argv-array.h"
2121
#include "strbuf.h"
2222
#include "lockfile.h"
23+
#include "object-store.h"
2324
#include "dir.h"
2425

2526
static char *diff_gui_tool;

builtin/fast-export.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "config.h"
99
#include "refs.h"
1010
#include "refspec.h"
11+
#include "object-store.h"
1112
#include "commit.h"
1213
#include "object.h"
1314
#include "tag.h"

builtin/fetch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "repository.h"
77
#include "refs.h"
88
#include "refspec.h"
9+
#include "object-store.h"
910
#include "commit.h"
1011
#include "builtin.h"
1112
#include "string-list.h"
@@ -777,7 +778,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
777778
const char *what, *kind;
778779
struct ref *rm;
779780
char *url;
780-
const char *filename = dry_run ? "/dev/null" : git_path_fetch_head();
781+
const char *filename = dry_run ? "/dev/null" : git_path_fetch_head(the_repository);
781782
int want_status;
782783
int summary_width = transport_summary_width(ref_map);
783784

@@ -1029,7 +1030,7 @@ static void check_not_current_branch(struct ref *ref_map)
10291030

10301031
static int truncate_fetch_head(void)
10311032
{
1032-
const char *filename = git_path_fetch_head();
1033+
const char *filename = git_path_fetch_head(the_repository);
10331034
FILE *fp = fopen_for_writing(filename);
10341035

10351036
if (!fp)
@@ -1449,7 +1450,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
14491450
if (unshallow) {
14501451
if (depth)
14511452
die(_("--depth and --unshallow cannot be used together"));
1452-
else if (!is_repository_shallow())
1453+
else if (!is_repository_shallow(the_repository))
14531454
die(_("--unshallow on a complete repository does not make sense"));
14541455
else
14551456
depth = xstrfmt("%d", INFINITE_DEPTH);

builtin/fmt-merge-msg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "cache.h"
33
#include "config.h"
44
#include "refs.h"
5+
#include "object-store.h"
56
#include "commit.h"
67
#include "diff.h"
78
#include "revision.h"

builtin/hash-object.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
#include "builtin.h"
88
#include "config.h"
9+
#include "object-store.h"
910
#include "blob.h"
1011
#include "quote.h"
1112
#include "parse-options.h"

builtin/log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "cache.h"
88
#include "config.h"
99
#include "refs.h"
10+
#include "object-store.h"
1011
#include "color.h"
1112
#include "commit.h"
1213
#include "diff.h"

builtin/ls-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include "cache.h"
77
#include "config.h"
8+
#include "object-store.h"
89
#include "blob.h"
910
#include "tree.h"
1011
#include "commit.h"

builtin/merge-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "builtin.h"
22
#include "tree-walk.h"
33
#include "xdiff-interface.h"
4+
#include "object-store.h"
45
#include "blob.h"
56
#include "exec-cmd.h"
67
#include "merge-blobs.h"

0 commit comments

Comments
 (0)