Skip to content

Commit fb998ea

Browse files
pcloudsgitster
authored andcommitted
blame.c: remove implicit dependency the_repository
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 005af33 commit fb998ea

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

blame.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,35 +116,38 @@ static void verify_working_tree_path(struct repository *r,
116116
die("no such path '%s' in HEAD", path);
117117
}
118118

119-
static struct commit_list **append_parent(struct commit_list **tail, const struct object_id *oid)
119+
static struct commit_list **append_parent(struct repository *r,
120+
struct commit_list **tail,
121+
const struct object_id *oid)
120122
{
121123
struct commit *parent;
122124

123-
parent = lookup_commit_reference(the_repository, oid);
125+
parent = lookup_commit_reference(r, oid);
124126
if (!parent)
125127
die("no such commit %s", oid_to_hex(oid));
126128
return &commit_list_insert(parent, tail)->next;
127129
}
128130

129-
static void append_merge_parents(struct commit_list **tail)
131+
static void append_merge_parents(struct repository *r,
132+
struct commit_list **tail)
130133
{
131134
int merge_head;
132135
struct strbuf line = STRBUF_INIT;
133136

134-
merge_head = open(git_path_merge_head(the_repository), O_RDONLY);
137+
merge_head = open(git_path_merge_head(r), O_RDONLY);
135138
if (merge_head < 0) {
136139
if (errno == ENOENT)
137140
return;
138141
die("cannot open '%s' for reading",
139-
git_path_merge_head(the_repository));
142+
git_path_merge_head(r));
140143
}
141144

142145
while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) {
143146
struct object_id oid;
144147
if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))
145148
die("unknown line in '%s': %s",
146-
git_path_merge_head(the_repository), line.buf);
147-
tail = append_parent(tail, &oid);
149+
git_path_merge_head(r), line.buf);
150+
tail = append_parent(r, tail, &oid);
148151
}
149152
close(merge_head);
150153
strbuf_release(&line);
@@ -155,11 +158,13 @@ static void append_merge_parents(struct commit_list **tail)
155158
* want to transfer ownership of the buffer to the commit (so we
156159
* must use detach).
157160
*/
158-
static void set_commit_buffer_from_strbuf(struct commit *c, struct strbuf *sb)
161+
static void set_commit_buffer_from_strbuf(struct repository *r,
162+
struct commit *c,
163+
struct strbuf *sb)
159164
{
160165
size_t len;
161166
void *buf = strbuf_detach(sb, &len);
162-
set_commit_buffer(the_repository, c, buf, len);
167+
set_commit_buffer(r, c, buf, len);
163168
}
164169

165170
/*
@@ -185,16 +190,16 @@ static struct commit *fake_working_tree_commit(struct repository *r,
185190

186191
read_index(r->index);
187192
time(&now);
188-
commit = alloc_commit_node(the_repository);
193+
commit = alloc_commit_node(r);
189194
commit->object.parsed = 1;
190195
commit->date = now;
191196
parent_tail = &commit->parents;
192197

193198
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
194199
die("no such ref: HEAD");
195200

196-
parent_tail = append_parent(parent_tail, &head_oid);
197-
append_merge_parents(parent_tail);
201+
parent_tail = append_parent(r, parent_tail, &head_oid);
202+
append_merge_parents(r, parent_tail);
198203
verify_working_tree_path(r, commit, path);
199204

200205
origin = make_origin(commit, path);
@@ -211,7 +216,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
211216
ident, ident, path,
212217
(!contents_from ? path :
213218
(!strcmp(contents_from, "-") ? "standard input" : contents_from)));
214-
set_commit_buffer_from_strbuf(commit, &msg);
219+
set_commit_buffer_from_strbuf(r, commit, &msg);
215220

216221
if (!contents_from || strcmp("-", contents_from)) {
217222
struct stat st;
@@ -1678,7 +1683,7 @@ static struct commit *find_single_final(struct rev_info *revs,
16781683
struct object *obj = revs->pending.objects[i].item;
16791684
if (obj->flags & UNINTERESTING)
16801685
continue;
1681-
obj = deref_tag(the_repository, obj, NULL, 0);
1686+
obj = deref_tag(revs->repo, obj, NULL, 0);
16821687
if (obj->type != OBJ_COMMIT)
16831688
die("Non commit %s?", revs->pending.objects[i].name);
16841689
if (found)
@@ -1709,14 +1714,14 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
17091714

17101715
/* Is that sole rev a committish? */
17111716
obj = revs->pending.objects[0].item;
1712-
obj = deref_tag(the_repository, obj, NULL, 0);
1717+
obj = deref_tag(revs->repo, obj, NULL, 0);
17131718
if (obj->type != OBJ_COMMIT)
17141719
return NULL;
17151720

17161721
/* Do we have HEAD? */
17171722
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
17181723
return NULL;
1719-
head_commit = lookup_commit_reference_gently(the_repository,
1724+
head_commit = lookup_commit_reference_gently(revs->repo,
17201725
&head_oid, 1);
17211726
if (!head_commit)
17221727
return NULL;
@@ -1745,7 +1750,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
17451750
struct object *obj = revs->pending.objects[i].item;
17461751
if (!(obj->flags & UNINTERESTING))
17471752
continue;
1748-
obj = deref_tag(the_repository, obj, NULL, 0);
1753+
obj = deref_tag(revs->repo, obj, NULL, 0);
17491754
if (obj->type != OBJ_COMMIT)
17501755
die("Non commit %s?", revs->pending.objects[i].name);
17511756
if (found)

0 commit comments

Comments
 (0)