From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 10/22] blame.c: remove implicit dependency the_repository
Date: Sat, 10 Nov 2018 06:48:58 +0100 [thread overview]
Message-ID: <20181110054910.10568-11-pclouds@gmail.com> (raw)
In-Reply-To: <20181110054910.10568-1-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
blame.c | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/blame.c b/blame.c
index d84c937780..43861437f7 100644
--- a/blame.c
+++ b/blame.c
@@ -116,35 +116,38 @@ static void verify_working_tree_path(struct repository *r,
die("no such path '%s' in HEAD", path);
}
-static struct commit_list **append_parent(struct commit_list **tail, const struct object_id *oid)
+static struct commit_list **append_parent(struct repository *r,
+ struct commit_list **tail,
+ const struct object_id *oid)
{
struct commit *parent;
- parent = lookup_commit_reference(the_repository, oid);
+ parent = lookup_commit_reference(r, oid);
if (!parent)
die("no such commit %s", oid_to_hex(oid));
return &commit_list_insert(parent, tail)->next;
}
-static void append_merge_parents(struct commit_list **tail)
+static void append_merge_parents(struct repository *r,
+ struct commit_list **tail)
{
int merge_head;
struct strbuf line = STRBUF_INIT;
- merge_head = open(git_path_merge_head(the_repository), O_RDONLY);
+ merge_head = open(git_path_merge_head(r), O_RDONLY);
if (merge_head < 0) {
if (errno == ENOENT)
return;
die("cannot open '%s' for reading",
- git_path_merge_head(the_repository));
+ git_path_merge_head(r));
}
while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) {
struct object_id oid;
if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))
die("unknown line in '%s': %s",
- git_path_merge_head(the_repository), line.buf);
- tail = append_parent(tail, &oid);
+ git_path_merge_head(r), line.buf);
+ tail = append_parent(r, tail, &oid);
}
close(merge_head);
strbuf_release(&line);
@@ -155,11 +158,13 @@ static void append_merge_parents(struct commit_list **tail)
* want to transfer ownership of the buffer to the commit (so we
* must use detach).
*/
-static void set_commit_buffer_from_strbuf(struct commit *c, struct strbuf *sb)
+static void set_commit_buffer_from_strbuf(struct repository *r,
+ struct commit *c,
+ struct strbuf *sb)
{
size_t len;
void *buf = strbuf_detach(sb, &len);
- set_commit_buffer(the_repository, c, buf, len);
+ set_commit_buffer(r, c, buf, len);
}
/*
@@ -185,7 +190,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
read_index(r->index);
time(&now);
- commit = alloc_commit_node(the_repository);
+ commit = alloc_commit_node(r);
commit->object.parsed = 1;
commit->date = now;
parent_tail = &commit->parents;
@@ -193,8 +198,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
die("no such ref: HEAD");
- parent_tail = append_parent(parent_tail, &head_oid);
- append_merge_parents(parent_tail);
+ parent_tail = append_parent(r, parent_tail, &head_oid);
+ append_merge_parents(r, parent_tail);
verify_working_tree_path(r, commit, path);
origin = make_origin(commit, path);
@@ -211,7 +216,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
ident, ident, path,
(!contents_from ? path :
(!strcmp(contents_from, "-") ? "standard input" : contents_from)));
- set_commit_buffer_from_strbuf(commit, &msg);
+ set_commit_buffer_from_strbuf(r, commit, &msg);
if (!contents_from || strcmp("-", contents_from)) {
struct stat st;
@@ -1678,7 +1683,7 @@ static struct commit *find_single_final(struct rev_info *revs,
struct object *obj = revs->pending.objects[i].item;
if (obj->flags & UNINTERESTING)
continue;
- obj = deref_tag(the_repository, obj, NULL, 0);
+ obj = deref_tag(revs->repo, obj, NULL, 0);
if (obj->type != OBJ_COMMIT)
die("Non commit %s?", revs->pending.objects[i].name);
if (found)
@@ -1709,14 +1714,14 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
/* Is that sole rev a committish? */
obj = revs->pending.objects[0].item;
- obj = deref_tag(the_repository, obj, NULL, 0);
+ obj = deref_tag(revs->repo, obj, NULL, 0);
if (obj->type != OBJ_COMMIT)
return NULL;
/* Do we have HEAD? */
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
return NULL;
- head_commit = lookup_commit_reference_gently(the_repository,
+ head_commit = lookup_commit_reference_gently(revs->repo,
&head_oid, 1);
if (!head_commit)
return NULL;
@@ -1745,7 +1750,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
struct object *obj = revs->pending.objects[i].item;
if (!(obj->flags & UNINTERESTING))
continue;
- obj = deref_tag(the_repository, obj, NULL, 0);
+ obj = deref_tag(revs->repo, obj, NULL, 0);
if (obj->type != OBJ_COMMIT)
die("Non commit %s?", revs->pending.objects[i].name);
if (found)
--
2.19.1.1231.g84aef82467
next prev parent reply other threads:[~2018-11-10 5:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-10 5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 01/22] wt-status.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 02/22] wt-status.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 03/22] list-objects-filter.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 04/22] list-objects.c: reduce the_repository references Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 05/22] notes-merge.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 06/22] notes-merge.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 07/22] transport.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 08/22] sequencer.c: " Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` [PATCH v2 09/22] sequencer.c: remove implicit dependency on the_repository Nguyễn Thái Ngọc Duy
2018-11-10 5:48 ` Nguyễn Thái Ngọc Duy [this message]
2018-11-10 5:48 ` [PATCH v2 11/22] bisect.c: remove the_repository reference Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 12/22] branch.c: " Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 13/22] bundle.c: remove the_repository references Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 14/22] cache-tree.c: " Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 15/22] delta-islands.c: " Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 16/22] diff-lib.c: " Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 17/22] line-log.c: remove the_repository reference Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 18/22] notes-cache.c: remove the_repository references Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 19/22] pack-check.c: " Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 20/22] pack-*.c: " Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 21/22] rerere.c: " Nguyễn Thái Ngọc Duy
2018-11-10 5:49 ` [PATCH v2 22/22] rebase-interactive.c: " Nguyễn Thái Ngọc Duy
2018-11-12 5:53 ` [PATCH v2 00/22] Kill the_index part 5 Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181110054910.10568-11-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).