From 1d18d7581cf1ce45314b7ed58e52d5cc73b2e7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 12 Jan 2019 09:13:23 +0700 Subject: notes-utils.c: remove the_repository references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- sequencer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index b68bca0bef..1a92a5d678 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1115,7 +1115,8 @@ static int run_rewrite_hook(const struct object_id *oldoid, return finish_command(&proc); } -void commit_post_rewrite(const struct commit *old_head, +void commit_post_rewrite(struct repository *r, + const struct commit *old_head, const struct object_id *new_head) { struct notes_rewrite_cfg *cfg; @@ -1124,7 +1125,7 @@ void commit_post_rewrite(const struct commit *old_head, if (cfg) { /* we are amending, so old_head is not NULL */ copy_note_for_rewrite(cfg, &old_head->object.oid, new_head); - finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'"); + finish_copy_notes_for_rewrite(r, cfg, "Notes added by 'git commit --amend'"); } run_rewrite_hook(&old_head->object.oid, new_head); } @@ -1405,7 +1406,7 @@ static int try_to_commit(struct repository *r, } if (flags & AMEND_MSG) - commit_post_rewrite(current_head, oid); + commit_post_rewrite(r, current_head, oid); out: free_commit_extra_headers(extra); -- cgit v1.2.1 From 3a95f31d1cdc93fa4f926c6537f84186edd85ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 12 Jan 2019 09:13:24 +0700 Subject: repository.c: replace hold_locked_index() with repo_hold_locked_index() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hold_locked_index() assumes the index path at $GIT_DIR/index. This is not good for places that take an arbitrary index_state instead of the_index, which is basically everywhere except builtin/. Replace it with repo_hold_locked_index(). hold_locked_index() remains as a wrapper around repo_hold_locked_index() to reduce changes in builtin/ Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- sequencer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index 1a92a5d678..668c232b05 100644 --- a/sequencer.c +++ b/sequencer.c @@ -540,7 +540,7 @@ static int do_recursive_merge(struct repository *r, char **xopt; struct lock_file index_lock = LOCK_INIT; - if (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR) < 0) + if (repo_hold_locked_index(r, &index_lock, LOCK_REPORT_ON_ERROR) < 0) return -1; read_index(r->index); @@ -1992,8 +1992,8 @@ static int read_and_refresh_cache(struct repository *r, struct replay_opts *opts) { struct lock_file index_lock = LOCK_INIT; - int index_fd = hold_locked_index(&index_lock, 0); - if (read_index(r->index) < 0) { + int index_fd = repo_hold_locked_index(r, &index_lock, 0); + if (repo_read_index(r) < 0) { rollback_lock_file(&index_lock); return error(_("git %s: failed to read the index"), _(action_name(opts))); @@ -2978,7 +2978,7 @@ static int do_reset(struct repository *r, struct unpack_trees_options unpack_tree_opts; int ret = 0; - if (hold_locked_index(&lock, LOCK_REPORT_ON_ERROR) < 0) + if (repo_hold_locked_index(r, &lock, LOCK_REPORT_ON_ERROR) < 0) return -1; if (len == 10 && !strncmp("[new root]", name, len)) { @@ -3096,7 +3096,7 @@ static int do_merge(struct repository *r, static struct lock_file lock; const char *p; - if (hold_locked_index(&lock, LOCK_REPORT_ON_ERROR) < 0) { + if (repo_hold_locked_index(r, &lock, LOCK_REPORT_ON_ERROR) < 0) { ret = -1; goto leave_merge; } -- cgit v1.2.1 From e1ff0a32e48eb0f3e53970df3f941d183093ff5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 12 Jan 2019 09:13:26 +0700 Subject: read-cache.c: kill read_index() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit read_index() shares the same problem as hold_locked_index(): it assumes $GIT_DIR/index. Move all call sites to repo_read_index() instead. read_index_preload() and read_index_unmerged() are also killed as a consequence. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- sequencer.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index 668c232b05..c2c9cc7e2b 100644 --- a/sequencer.c +++ b/sequencer.c @@ -446,9 +446,9 @@ static struct tree *empty_tree(struct repository *r) return lookup_tree(r, the_hash_algo->empty_tree); } -static int error_dirty_index(struct index_state *istate, struct replay_opts *opts) +static int error_dirty_index(struct repository *repo, struct replay_opts *opts) { - if (read_index_unmerged(istate)) + if (repo_read_index_unmerged(repo)) return error_resolve_conflict(_(action_name(opts))); error(_("your local changes would be overwritten by %s."), @@ -483,7 +483,7 @@ static int fast_forward_to(struct repository *r, struct strbuf sb = STRBUF_INIT; struct strbuf err = STRBUF_INIT; - read_index(r->index); + repo_read_index(r); if (checkout_fast_forward(r, from, to, 1)) return -1; /* the callee should have complained already */ @@ -543,7 +543,7 @@ static int do_recursive_merge(struct repository *r, if (repo_hold_locked_index(r, &index_lock, LOCK_REPORT_ON_ERROR) < 0) return -1; - read_index(r->index); + repo_read_index(r); init_merge_options(&o); o.ancestor = base ? base_label : "(empty tree)"; @@ -1766,7 +1766,7 @@ static int do_pick_commit(struct repository *r, oidcpy(&head, the_hash_algo->empty_tree); if (index_differs_from(r, unborn ? empty_tree_oid_hex() : "HEAD", NULL, 0)) - return error_dirty_index(r->index, opts); + return error_dirty_index(r, opts); } discard_index(r->index); @@ -2854,7 +2854,7 @@ static int do_exec(struct repository *r, const char *command_line) child_env.argv); /* force re-reading of the cache */ - if (discard_index(r->index) < 0 || read_index(r->index) < 0) + if (discard_index(r->index) < 0 || repo_read_index(r) < 0) return error(_("could not read index")); dirty = require_clean_work_tree(r, "rebase", NULL, 1, 1); @@ -3023,7 +3023,7 @@ static int do_reset(struct repository *r, unpack_tree_opts.merge = 1; unpack_tree_opts.update = 1; - if (read_index_unmerged(r->index)) { + if (repo_read_index_unmerged(r)) { rollback_lock_file(&lock); strbuf_release(&ref_name); return error_resolve_conflict(_(action_name(opts))); @@ -3277,7 +3277,7 @@ static int do_merge(struct repository *r, /* force re-reading of the cache */ if (!ret && (discard_index(r->index) < 0 || - read_index(r->index) < 0)) + repo_read_index(r) < 0)) ret = error(_("could not read index")); goto leave_merge; } @@ -3299,7 +3299,7 @@ static int do_merge(struct repository *r, commit_list_insert(j->item, &reversed); free_commit_list(bases); - read_index(r->index); + repo_read_index(r); init_merge_options(&o); o.branch1 = "HEAD"; o.branch2 = ref_name.buf; @@ -3972,7 +3972,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) goto release_todo_list; } if (index_differs_from(r, "HEAD", NULL, 0)) { - res = error_dirty_index(r->index, opts); + res = error_dirty_index(r, opts); goto release_todo_list; } todo_list.current++; -- cgit v1.2.1 From 0d6caa2d08e39bf97e0cffb8ba2b4d39a73bf763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 12 Jan 2019 09:13:29 +0700 Subject: merge-recursive.c: remove implicit dependency on the_index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- sequencer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index c2c9cc7e2b..cede6ea095 100644 --- a/sequencer.c +++ b/sequencer.c @@ -545,7 +545,7 @@ static int do_recursive_merge(struct repository *r, repo_read_index(r); - init_merge_options(&o); + init_merge_options(&o, r); o.ancestor = base ? base_label : "(empty tree)"; o.branch1 = "HEAD"; o.branch2 = next ? next_label : "(empty tree)"; @@ -3300,7 +3300,7 @@ static int do_merge(struct repository *r, free_commit_list(bases); repo_read_index(r); - init_merge_options(&o); + init_merge_options(&o, r); o.branch1 = "HEAD"; o.branch2 = ref_name.buf; o.buffer_output = 2; -- cgit v1.2.1