git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2 00/22] Kill the_index part 5
@ 2018-11-10  5:48 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
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

(Please ignore v1 which contains unrelated patches)

I lied about part 5 being final. This series contains most of my WIP
series [2] except sha1-name.c, read-cache.c and merge-recursive.c
because there will be conflicts on 'pu' so they will be in part 6. At
least this only results in two small conflicts in sequencer.c.

I did start pushing the_repository out of library code [1] in the bottom
half of this series. There aren't big surprises except that cache-tree
API now take _both_ struct repository and struct index_state. The
reason is cache-tree can work on temporary indexes and repo->index is
about $GIT_DIR/index.

[1] Stefan and I make a good team. He keeps adding the_repository. I
keep removing. We both hold hands leading commit counts (with Brian
just a bit behind frantically replacing sha1 with oid to keep up).
Meanwhile Junio is crying in the corner because of too many conflicts.
:-D

[2] https://public-inbox.org/git/20181019145237.16079-1-pclouds@gmail.com/

Nguyễn Thái Ngọc Duy (22):
  wt-status.c: remove implicit dependency on the_index
  wt-status.c: remove implicit dependency the_repository
  list-objects-filter.c: remove implicit dependency on the_index
  list-objects.c: reduce the_repository references
  notes-merge.c: remove implicit dependency on the_index
  notes-merge.c: remove implicit dependency the_repository
  transport.c: remove implicit dependency on the_index
  sequencer.c: remove implicit dependency on the_index
  sequencer.c: remove implicit dependency on the_repository
  blame.c: remove implicit dependency the_repository
  bisect.c: remove the_repository reference
  branch.c: remove the_repository reference
  bundle.c: remove the_repository references
  cache-tree.c: remove the_repository references
  delta-islands.c: remove the_repository references
  diff-lib.c: remove the_repository references
  line-log.c: remove the_repository reference
  notes-cache.c: remove the_repository references
  pack-check.c: remove the_repository references
  pack-*.c: remove the_repository references
  rerere.c: remove the_repository references
  rebase-interactive.c: remove the_repository references

 bisect.c                      |  48 ++--
 bisect.h                      |   5 +-
 blame.c                       |  39 +--
 branch.c                      |  21 +-
 branch.h                      |   8 +-
 builtin/am.c                  |   4 +-
 builtin/bisect--helper.c      |   2 +-
 builtin/branch.c              |   6 +-
 builtin/bundle.c              |   7 +-
 builtin/checkout.c            |   5 +-
 builtin/commit.c              |   8 +-
 builtin/fsck.c                |   3 +-
 builtin/merge-ours.c          |   2 +-
 builtin/merge.c               |   2 +-
 builtin/notes.c               |   2 +-
 builtin/pack-objects.c        |   6 +-
 builtin/pull.c                |   3 +-
 builtin/push.c                |   3 +-
 builtin/read-tree.c           |   4 +-
 builtin/rebase--interactive.c |  19 +-
 builtin/rebase.c              |  13 +-
 builtin/rerere.c              |  10 +-
 builtin/reset.c               |   4 +-
 builtin/revert.c              |   8 +-
 bundle.c                      |  26 +-
 bundle.h                      |   9 +-
 cache-tree.c                  |  26 +-
 cache-tree.h                  |   4 +-
 combine-diff.c                |   2 +-
 delta-islands.c               |  24 +-
 delta-islands.h               |   9 +-
 diff-lib.c                    |   7 +-
 diff.c                        |  12 +-
 diff.h                        |   5 +-
 diffcore-pickaxe.c            |   4 +-
 grep.c                        |   2 +-
 line-log.c                    |   2 +-
 list-objects-filter.c         |  10 +-
 list-objects-filter.h         |   2 +
 list-objects.c                |  13 +-
 notes-cache.c                 |  12 +-
 notes-cache.h                 |   6 +-
 notes-merge.c                 |  16 +-
 notes-merge.h                 |   5 +-
 pack-bitmap-write.c           |   6 +-
 pack-bitmap.c                 |  13 +-
 pack-bitmap.h                 |   3 +-
 pack-check.c                  |   9 +-
 pack-objects.c                |   6 +-
 pack-objects.h                |   5 +-
 pack.h                        |   4 +-
 read-cache.c                  |   2 +-
 rebase-interactive.c          |   6 +-
 rebase-interactive.h          |   5 +-
 ref-filter.c                  |   2 +-
 rerere.c                      |  26 +-
 rerere.h                      |   6 +-
 sequencer.c                   | 453 +++++++++++++++++++---------------
 sequencer.h                   |  27 +-
 transport.c                   |   9 +-
 transport.h                   |   3 +-
 unpack-trees.c                |   2 +-
 userdiff.c                    |   5 +-
 userdiff.h                    |   4 +-
 wt-status.c                   |  94 ++++---
 wt-status.h                   |  21 +-
 66 files changed, 650 insertions(+), 489 deletions(-)

-- 
2.19.1.1231.g84aef82467


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 01/22] wt-status.c: remove implicit dependency on the_index
  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 ` 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
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/commit.c |  2 +-
 builtin/pull.c   |  3 +-
 builtin/rebase.c |  7 +++--
 sequencer.c      |  8 ++---
 wt-status.c      | 76 +++++++++++++++++++++++++++---------------------
 wt-status.h      | 17 +++++++----
 6 files changed, 66 insertions(+), 47 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 074bd9a551..6637a928a7 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -185,7 +185,7 @@ static void determine_whence(struct wt_status *s)
 
 static void status_init_config(struct wt_status *s, config_fn_t fn)
 {
-	wt_status_prepare(s);
+	wt_status_prepare(the_repository, s);
 	init_diff_ui_defaults();
 	git_config(fn, s);
 	determine_whence(s);
diff --git a/builtin/pull.c b/builtin/pull.c
index c21aa276f1..6026ce1a69 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -888,7 +888,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
 			die(_("Updating an unborn branch with changes added to the index."));
 
 		if (!autostash)
-			require_clean_work_tree(N_("pull with rebase"),
+			require_clean_work_tree(the_repository,
+				N_("pull with rebase"),
 				_("please commit or stash them."), 1, 0);
 
 		if (get_rebase_fork_point(&rebase_fork_point, repo, *refspecs))
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 0ee06aa363..b9eb958454 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -983,7 +983,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 					     &lock_file);
 		rollback_lock_file(&lock_file);
 
-		if (has_unstaged_changes(1)) {
+		if (has_unstaged_changes(the_repository, 1)) {
 			puts(_("You must edit all merge conflicts and then\n"
 			       "mark them as resolved using git add"));
 			exit(1);
@@ -1351,7 +1351,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			update_index_if_able(&the_index, &lock_file);
 		rollback_lock_file(&lock_file);
 
-		if (has_unstaged_changes(1) || has_uncommitted_changes(1)) {
+		if (has_unstaged_changes(the_repository, 1) ||
+		    has_uncommitted_changes(the_repository, 1)) {
 			const char *autostash =
 				state_dir_path("autostash", &options);
 			struct child_process stash = CHILD_PROCESS_INIT;
@@ -1397,7 +1398,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	if (require_clean_work_tree("rebase",
+	if (require_clean_work_tree(the_repository, "rebase",
 				    _("Please commit or stash them."), 1, 1)) {
 		ret = 1;
 		goto cleanup;
diff --git a/sequencer.c b/sequencer.c
index 9e1ab3a2a7..0b8f18fd36 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2773,7 +2773,7 @@ static int do_exec(const char *command_line)
 	if (discard_cache() < 0 || read_cache() < 0)
 		return error(_("could not read index"));
 
-	dirty = require_clean_work_tree("rebase", NULL, 1, 1);
+	dirty = require_clean_work_tree(the_repository, "rebase", NULL, 1, 1);
 
 	if (status) {
 		warning(_("execution failed: %s\n%s"
@@ -3714,10 +3714,10 @@ static int commit_staged_changes(struct replay_opts *opts,
 	unsigned int flags = ALLOW_EMPTY | EDIT_MSG;
 	unsigned int final_fixup = 0, is_clean;
 
-	if (has_unstaged_changes(1))
+	if (has_unstaged_changes(the_repository, 1))
 		return error(_("cannot rebase: You have unstaged changes."));
 
-	is_clean = !has_uncommitted_changes(0);
+	is_clean = !has_uncommitted_changes(the_repository, 0);
 
 	if (file_exists(rebase_path_amend())) {
 		struct strbuf rev = STRBUF_INIT;
@@ -4847,7 +4847,7 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 	if (checkout_onto(opts, onto_name, oid_to_hex(&oid), orig_head))
 		return -1;
 ;
-	if (require_clean_work_tree("rebase", "", 1, 1))
+	if (require_clean_work_tree(the_repository, "rebase", "", 1, 1))
 		return -1;
 
 	return sequencer_continue(opts);
diff --git a/wt-status.c b/wt-status.c
index 187568a112..6d401b2c24 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -119,9 +119,10 @@ static void status_printf_more(struct wt_status *s, const char *color,
 	va_end(ap);
 }
 
-void wt_status_prepare(struct wt_status *s)
+void wt_status_prepare(struct repository *r, struct wt_status *s)
 {
 	memset(s, 0, sizeof(*s));
+	s->repo = r;
 	memcpy(s->color_palette, default_wt_status_colors,
 	       sizeof(default_wt_status_colors));
 	s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
@@ -494,19 +495,19 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
 	}
 }
 
-static int unmerged_mask(const char *path)
+static int unmerged_mask(struct index_state *istate, const char *path)
 {
 	int pos, mask;
 	const struct cache_entry *ce;
 
-	pos = cache_name_pos(path, strlen(path));
+	pos = index_name_pos(istate, path, strlen(path));
 	if (0 <= pos)
 		return 0;
 
 	mask = 0;
 	pos = -pos-1;
-	while (pos < active_nr) {
-		ce = active_cache[pos++];
+	while (pos < istate->cache_nr) {
+		ce = istate->cache[pos++];
 		if (strcmp(ce->name, path) || !ce_stage(ce))
 			break;
 		mask |= (1 << (ce_stage(ce) - 1));
@@ -566,7 +567,8 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
 			s->committable = 1;
 			break;
 		case DIFF_STATUS_UNMERGED:
-			d->stagemask = unmerged_mask(p->two->path);
+			d->stagemask = unmerged_mask(s->repo->index,
+						     p->two->path);
 			/*
 			 * Don't bother setting {mode,oid}_{head,index} since the print
 			 * code will output the stage values directly and not use the
@@ -585,7 +587,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
 {
 	struct rev_info rev;
 
-	repo_init_revisions(the_repository, &rev, NULL);
+	repo_init_revisions(s->repo, &rev, NULL);
 	setup_revisions(0, NULL, &rev, NULL);
 	rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 	rev.diffopt.flags.dirty_submodules = 1;
@@ -610,7 +612,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)
 	struct rev_info rev;
 	struct setup_revision_opt opt;
 
-	repo_init_revisions(the_repository, &rev, NULL);
+	repo_init_revisions(s->repo, &rev, NULL);
 	memset(&opt, 0, sizeof(opt));
 	opt.def = s->is_initial ? empty_tree_oid_hex() : s->reference;
 	setup_revisions(0, NULL, &rev, &opt);
@@ -643,14 +645,15 @@ static void wt_status_collect_changes_index(struct wt_status *s)
 
 static void wt_status_collect_changes_initial(struct wt_status *s)
 {
+	struct index_state *istate = s->repo->index;
 	int i;
 
-	for (i = 0; i < active_nr; i++) {
+	for (i = 0; i < istate->cache_nr; i++) {
 		struct string_list_item *it;
 		struct wt_status_change_data *d;
-		const struct cache_entry *ce = active_cache[i];
+		const struct cache_entry *ce = istate->cache[i];
 
-		if (!ce_path_match(&the_index, ce, &s->pathspec, NULL))
+		if (!ce_path_match(istate, ce, &s->pathspec, NULL))
 			continue;
 		if (ce_intent_to_add(ce))
 			continue;
@@ -684,6 +687,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
 	int i;
 	struct dir_struct dir;
 	uint64_t t_begin = getnanotime();
+	struct index_state *istate = s->repo->index;
 
 	if (!s->show_untracked_files)
 		return;
@@ -698,25 +702,25 @@ static void wt_status_collect_untracked(struct wt_status *s)
 		if (s->show_ignored_mode == SHOW_MATCHING_IGNORED)
 			dir.flags |= DIR_SHOW_IGNORED_TOO_MODE_MATCHING;
 	} else {
-		dir.untracked = the_index.untracked;
+		dir.untracked = istate->untracked;
 	}
 
 	setup_standard_excludes(&dir);
 
-	fill_directory(&dir, &the_index, &s->pathspec);
+	fill_directory(&dir, istate, &s->pathspec);
 
 	for (i = 0; i < dir.nr; i++) {
 		struct dir_entry *ent = dir.entries[i];
-		if (cache_name_is_other(ent->name, ent->len) &&
-		    dir_path_match(&the_index, ent, &s->pathspec, 0, NULL))
+		if (index_name_is_other(istate, ent->name, ent->len) &&
+		    dir_path_match(istate, ent, &s->pathspec, 0, NULL))
 			string_list_insert(&s->untracked, ent->name);
 		free(ent);
 	}
 
 	for (i = 0; i < dir.ignored_nr; i++) {
 		struct dir_entry *ent = dir.ignored[i];
-		if (cache_name_is_other(ent->name, ent->len) &&
-		    dir_path_match(&the_index, ent, &s->pathspec, 0, NULL))
+		if (index_name_is_other(istate, ent->name, ent->len) &&
+		    dir_path_match(istate, ent, &s->pathspec, 0, NULL))
 			string_list_insert(&s->ignored, ent->name);
 		free(ent);
 	}
@@ -1009,7 +1013,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)
 	int dirty_submodules;
 	const char *c = color(WT_STATUS_HEADER, s);
 
-	repo_init_revisions(the_repository, &rev, NULL);
+	repo_init_revisions(s->repo, &rev, NULL);
 	rev.diffopt.flags.allow_textconv = 1;
 	rev.diffopt.ita_invisible_in_index = 1;
 
@@ -1326,7 +1330,7 @@ static void show_rebase_in_progress(struct wt_status *s,
 				_("  (use \"git rebase --abort\" to check out the original branch)"));
 		}
 	} else if (s->state.rebase_in_progress ||
-		   !stat(git_path_merge_msg(the_repository), &st)) {
+		   !stat(git_path_merge_msg(s->repo), &st)) {
 		print_rebase_state(s, color);
 		if (s->hints)
 			status_printf_ln(s, color,
@@ -2135,6 +2139,7 @@ static void wt_porcelain_v2_print_unmerged_entry(
 	struct wt_status *s)
 {
 	struct wt_status_change_data *d = it->util;
+	struct index_state *istate = s->repo->index;
 	const struct cache_entry *ce;
 	struct strbuf buf_index = STRBUF_INIT;
 	const char *path_index = NULL;
@@ -2173,11 +2178,11 @@ static void wt_porcelain_v2_print_unmerged_entry(
 	 */
 	memset(stages, 0, sizeof(stages));
 	sum = 0;
-	pos = cache_name_pos(it->string, strlen(it->string));
+	pos = index_name_pos(istate, it->string, strlen(it->string));
 	assert(pos < 0);
 	pos = -pos-1;
-	while (pos < active_nr) {
-		ce = active_cache[pos++];
+	while (pos < istate->cache_nr) {
+		ce = istate->cache[pos++];
 		stage = ce_stage(ce);
 		if (strcmp(ce->name, it->string) || !stage)
 			break;
@@ -2302,12 +2307,12 @@ void wt_status_print(struct wt_status *s)
 /**
  * Returns 1 if there are unstaged changes, 0 otherwise.
  */
-int has_unstaged_changes(int ignore_submodules)
+int has_unstaged_changes(struct repository *r, int ignore_submodules)
 {
 	struct rev_info rev_info;
 	int result;
 
-	repo_init_revisions(the_repository, &rev_info, NULL);
+	repo_init_revisions(r, &rev_info, NULL);
 	if (ignore_submodules) {
 		rev_info.diffopt.flags.ignore_submodules = 1;
 		rev_info.diffopt.flags.override_submodule_config = 1;
@@ -2321,15 +2326,16 @@ int has_unstaged_changes(int ignore_submodules)
 /**
  * Returns 1 if there are uncommitted changes, 0 otherwise.
  */
-int has_uncommitted_changes(int ignore_submodules)
+int has_uncommitted_changes(struct repository *r,
+			    int ignore_submodules)
 {
 	struct rev_info rev_info;
 	int result;
 
-	if (is_cache_unborn())
+	if (is_index_unborn(r->index))
 		return 0;
 
-	repo_init_revisions(the_repository, &rev_info, NULL);
+	repo_init_revisions(r, &rev_info, NULL);
 	if (ignore_submodules)
 		rev_info.diffopt.flags.ignore_submodules = 1;
 	rev_info.diffopt.flags.quick = 1;
@@ -2340,7 +2346,7 @@ int has_uncommitted_changes(int ignore_submodules)
 		 * We have no head (or it's corrupt); use the empty tree,
 		 * which will complain if the index is non-empty.
 		 */
-		struct tree *tree = lookup_tree(the_repository, the_hash_algo->empty_tree);
+		struct tree *tree = lookup_tree(r, the_hash_algo->empty_tree);
 		add_pending_object(&rev_info, &tree->object, "");
 	}
 
@@ -2353,24 +2359,28 @@ int has_uncommitted_changes(int ignore_submodules)
  * If the work tree has unstaged or uncommitted changes, dies with the
  * appropriate message.
  */
-int require_clean_work_tree(const char *action, const char *hint, int ignore_submodules, int gently)
+int require_clean_work_tree(struct repository *r,
+			    const char *action,
+			    const char *hint,
+			    int ignore_submodules,
+			    int gently)
 {
 	struct lock_file lock_file = LOCK_INIT;
 	int err = 0, fd;
 
 	fd = hold_locked_index(&lock_file, 0);
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(r->index, REFRESH_QUIET, NULL, NULL, NULL);
 	if (0 <= fd)
-		update_index_if_able(&the_index, &lock_file);
+		update_index_if_able(r->index, &lock_file);
 	rollback_lock_file(&lock_file);
 
-	if (has_unstaged_changes(ignore_submodules)) {
+	if (has_unstaged_changes(r, ignore_submodules)) {
 		/* TRANSLATORS: the action is e.g. "pull with rebase" */
 		error(_("cannot %s: You have unstaged changes."), _(action));
 		err = 1;
 	}
 
-	if (has_uncommitted_changes(ignore_submodules)) {
+	if (has_uncommitted_changes(r, ignore_submodules)) {
 		if (err)
 			error(_("additionally, your index contains uncommitted changes."));
 		else
diff --git a/wt-status.h b/wt-status.h
index 1fcf93afbf..8375e816fb 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -7,6 +7,7 @@
 #include "pathspec.h"
 #include "remote.h"
 
+struct repository;
 struct worktree;
 
 enum color_wt_status {
@@ -83,6 +84,7 @@ struct wt_status_state {
 };
 
 struct wt_status {
+	struct repository *repo;
 	int is_initial;
 	char *branch;
 	const char *reference;
@@ -128,7 +130,7 @@ struct wt_status {
 
 size_t wt_status_locate_end(const char *s, size_t len);
 void wt_status_add_cut_line(FILE *fp);
-void wt_status_prepare(struct wt_status *s);
+void wt_status_prepare(struct repository *r, struct wt_status *s);
 void wt_status_print(struct wt_status *s);
 void wt_status_collect(struct wt_status *s);
 void wt_status_collect_free_buffers(struct wt_status *s);
@@ -144,9 +146,14 @@ __attribute__((format (printf, 3, 4)))
 void status_printf(struct wt_status *s, const char *color, const char *fmt, ...);
 
 /* The following functions expect that the caller took care of reading the index. */
-int has_unstaged_changes(int ignore_submodules);
-int has_uncommitted_changes(int ignore_submodules);
-int require_clean_work_tree(const char *action, const char *hint,
-	int ignore_submodules, int gently);
+int has_unstaged_changes(struct repository *repo,
+			 int ignore_submodules);
+int has_uncommitted_changes(struct repository *repo,
+			    int ignore_submodules);
+int require_clean_work_tree(struct repository *repo,
+			    const char *action,
+			    const char *hint,
+			    int ignore_submodules,
+			    int gently);
 
 #endif /* STATUS_H */
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 02/22] wt-status.c: remove implicit dependency the_repository
  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 ` 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
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 ref-filter.c |  2 +-
 wt-status.c  | 18 ++++++++++--------
 wt-status.h  |  4 +++-
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/ref-filter.c b/ref-filter.c
index 0c45ed9d94..c4eaf30313 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1413,7 +1413,7 @@ char *get_head_description(void)
 	struct strbuf desc = STRBUF_INIT;
 	struct wt_status_state state;
 	memset(&state, 0, sizeof(state));
-	wt_status_get_state(&state, 1);
+	wt_status_get_state(the_repository, &state, 1);
 	if (state.rebase_in_progress ||
 	    state.rebase_interactive_in_progress) {
 		if (state.branch)
diff --git a/wt-status.c b/wt-status.c
index 6d401b2c24..e582c54238 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -755,7 +755,7 @@ void wt_status_collect(struct wt_status *s)
 		wt_status_collect_changes_index(s);
 	wt_status_collect_untracked(s);
 
-	wt_status_get_state(&s->state, s->branch && !strcmp(s->branch, "HEAD"));
+	wt_status_get_state(s->repo, &s->state, s->branch && !strcmp(s->branch, "HEAD"));
 	if (s->state.merge_in_progress && !has_unmerged(s))
 		s->committable = 1;
 }
@@ -1482,7 +1482,8 @@ static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,
 	return 1;
 }
 
-static void wt_status_get_detached_from(struct wt_status_state *state)
+static void wt_status_get_detached_from(struct repository *r,
+					struct wt_status_state *state)
 {
 	struct grab_1st_switch_cbdata cb;
 	struct commit *commit;
@@ -1499,7 +1500,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
 	    /* sha1 is a commit? match without further lookup */
 	    (oideq(&cb.noid, &oid) ||
 	     /* perhaps sha1 is a tag, try to dereference to a commit */
-	     ((commit = lookup_commit_reference_gently(the_repository, &oid, 1)) != NULL &&
+	     ((commit = lookup_commit_reference_gently(r, &oid, 1)) != NULL &&
 	      oideq(&cb.noid, &commit->object.oid)))) {
 		const char *from = ref;
 		if (!skip_prefix(from, "refs/tags/", &from))
@@ -1556,30 +1557,31 @@ int wt_status_check_bisect(const struct worktree *wt,
 	return 0;
 }
 
-void wt_status_get_state(struct wt_status_state *state,
+void wt_status_get_state(struct repository *r,
+			 struct wt_status_state *state,
 			 int get_detached_from)
 {
 	struct stat st;
 	struct object_id oid;
 
-	if (!stat(git_path_merge_head(the_repository), &st)) {
+	if (!stat(git_path_merge_head(r), &st)) {
 		state->merge_in_progress = 1;
 	} else if (wt_status_check_rebase(NULL, state)) {
 		;		/* all set */
-	} else if (!stat(git_path_cherry_pick_head(the_repository), &st) &&
+	} else if (!stat(git_path_cherry_pick_head(r), &st) &&
 			!get_oid("CHERRY_PICK_HEAD", &oid)) {
 		state->cherry_pick_in_progress = 1;
 		oidcpy(&state->cherry_pick_head_oid, &oid);
 	}
 	wt_status_check_bisect(NULL, state);
-	if (!stat(git_path_revert_head(the_repository), &st) &&
+	if (!stat(git_path_revert_head(r), &st) &&
 	    !get_oid("REVERT_HEAD", &oid)) {
 		state->revert_in_progress = 1;
 		oidcpy(&state->revert_head_oid, &oid);
 	}
 
 	if (get_detached_from)
-		wt_status_get_detached_from(state);
+		wt_status_get_detached_from(r, state);
 }
 
 static void wt_longstatus_print_state(struct wt_status *s)
diff --git a/wt-status.h b/wt-status.h
index 8375e816fb..3a95975032 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -134,7 +134,9 @@ void wt_status_prepare(struct repository *r, struct wt_status *s);
 void wt_status_print(struct wt_status *s);
 void wt_status_collect(struct wt_status *s);
 void wt_status_collect_free_buffers(struct wt_status *s);
-void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
+void wt_status_get_state(struct repository *repo,
+			 struct wt_status_state *state,
+			 int get_detached_from);
 int wt_status_check_rebase(const struct worktree *wt,
 			   struct wt_status_state *state);
 int wt_status_check_bisect(const struct worktree *wt,
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 03/22] list-objects-filter.c: remove implicit dependency on the_index
  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 ` 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
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

While at there, since we have access to struct repository now,
eliminate the only the_repository reference in this file.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 list-objects-filter.c | 10 +++++++---
 list-objects-filter.h |  2 ++
 list-objects.c        |  9 ++++++---
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/list-objects-filter.c b/list-objects-filter.c
index 765f3df3b0..a62624a1ce 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -34,6 +34,7 @@ struct filter_blobs_none_data {
 };
 
 static enum list_objects_filter_result filter_blobs_none(
+	struct repository *r,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
 	const char *pathname,
@@ -88,6 +89,7 @@ struct filter_trees_none_data {
 };
 
 static enum list_objects_filter_result filter_trees_none(
+	struct repository *r,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
 	const char *pathname,
@@ -144,6 +146,7 @@ struct filter_blobs_limit_data {
 };
 
 static enum list_objects_filter_result filter_blobs_limit(
+	struct repository *r,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
 	const char *pathname,
@@ -171,7 +174,7 @@ static enum list_objects_filter_result filter_blobs_limit(
 		assert(obj->type == OBJ_BLOB);
 		assert((obj->flags & SEEN) == 0);
 
-		t = oid_object_info(the_repository, &obj->oid, &object_length);
+		t = oid_object_info(r, &obj->oid, &object_length);
 		if (t != OBJ_BLOB) { /* probably OBJ_NONE */
 			/*
 			 * We DO NOT have the blob locally, so we cannot
@@ -249,6 +252,7 @@ struct filter_sparse_data {
 };
 
 static enum list_objects_filter_result filter_sparse(
+	struct repository *r,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
 	const char *pathname,
@@ -268,7 +272,7 @@ static enum list_objects_filter_result filter_sparse(
 		dtype = DT_DIR;
 		val = is_excluded_from_list(pathname, strlen(pathname),
 					    filename, &dtype, &filter_data->el,
-					    &the_index);
+					    r->index);
 		if (val < 0)
 			val = filter_data->array_frame[filter_data->nr].defval;
 
@@ -331,7 +335,7 @@ static enum list_objects_filter_result filter_sparse(
 		dtype = DT_REG;
 		val = is_excluded_from_list(pathname, strlen(pathname),
 					    filename, &dtype, &filter_data->el,
-					    &the_index);
+					    r->index);
 		if (val < 0)
 			val = frame->defval;
 		if (val > 0) {
diff --git a/list-objects-filter.h b/list-objects-filter.h
index 52b4a84da9..1d45a4ad57 100644
--- a/list-objects-filter.h
+++ b/list-objects-filter.h
@@ -4,6 +4,7 @@
 struct list_objects_filter_options;
 struct object;
 struct oidset;
+struct repository;
 
 /*
  * During list-object traversal we allow certain objects to be
@@ -60,6 +61,7 @@ enum list_objects_filter_situation {
 };
 
 typedef enum list_objects_filter_result (*filter_object_fn)(
+	struct repository *r,
 	enum list_objects_filter_situation filter_situation,
 	struct object *obj,
 	const char *pathname,
diff --git a/list-objects.c b/list-objects.c
index c41cc80db5..0cfd646026 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -55,7 +55,8 @@ static void process_blob(struct traversal_context *ctx,
 	pathlen = path->len;
 	strbuf_addstr(path, name);
 	if ((obj->flags & NOT_USER_GIVEN) && ctx->filter_fn)
-		r = ctx->filter_fn(LOFS_BLOB, obj,
+		r = ctx->filter_fn(ctx->revs->repo,
+				   LOFS_BLOB, obj,
 				   path->buf, &path->buf[pathlen],
 				   ctx->filter_data);
 	if (r & LOFR_MARK_SEEN)
@@ -175,7 +176,8 @@ static void process_tree(struct traversal_context *ctx,
 
 	strbuf_addstr(base, name);
 	if ((obj->flags & NOT_USER_GIVEN) && ctx->filter_fn)
-		r = ctx->filter_fn(LOFS_BEGIN_TREE, obj,
+		r = ctx->filter_fn(ctx->revs->repo,
+				   LOFS_BEGIN_TREE, obj,
 				   base->buf, &base->buf[baselen],
 				   ctx->filter_data);
 	if (r & LOFR_MARK_SEEN)
@@ -191,7 +193,8 @@ static void process_tree(struct traversal_context *ctx,
 		process_tree_contents(ctx, tree, base);
 
 	if ((obj->flags & NOT_USER_GIVEN) && ctx->filter_fn) {
-		r = ctx->filter_fn(LOFS_END_TREE, obj,
+		r = ctx->filter_fn(ctx->revs->repo,
+				   LOFS_END_TREE, obj,
 				   base->buf, &base->buf[baselen],
 				   ctx->filter_data);
 		if (r & LOFR_MARK_SEEN)
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 04/22] list-objects.c: reduce the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (2 preceding siblings ...)
  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 ` 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
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 list-objects.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/list-objects.c b/list-objects.c
index 0cfd646026..cf7f25bed3 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -123,7 +123,7 @@ static void process_tree_contents(struct traversal_context *ctx,
 		}
 
 		if (S_ISDIR(entry.mode)) {
-			struct tree *t = lookup_tree(the_repository, entry.oid);
+			struct tree *t = lookup_tree(ctx->revs->repo, entry.oid);
 			t->object.flags |= NOT_USER_GIVEN;
 			process_tree(ctx, t, base, entry.path);
 		}
@@ -131,7 +131,7 @@ static void process_tree_contents(struct traversal_context *ctx,
 			process_gitlink(ctx, entry.oid->hash,
 					base, entry.path);
 		else {
-			struct blob *b = lookup_blob(the_repository, entry.oid);
+			struct blob *b = lookup_blob(ctx->revs->repo, entry.oid);
 			b->object.flags |= NOT_USER_GIVEN;
 			process_blob(ctx, b, base, entry.path);
 		}
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 05/22] notes-merge.c: remove implicit dependency on the_index
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (3 preceding siblings ...)
  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 ` 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
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/notes.c |  2 +-
 notes-merge.c   | 12 +++++++-----
 notes-merge.h   |  5 ++++-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/builtin/notes.c b/builtin/notes.c
index c05cd004ab..15a6c78855 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -808,7 +808,7 @@ static int merge(int argc, const char **argv, const char *prefix)
 		usage_with_options(git_notes_merge_usage, options);
 	}
 
-	init_notes_merge_options(&o);
+	init_notes_merge_options(the_repository, &o);
 	o.verbosity = verbosity + NOTES_MERGE_VERBOSITY_DEFAULT;
 
 	if (do_abort)
diff --git a/notes-merge.c b/notes-merge.c
index bd05d50b05..0c22f09b28 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -18,11 +18,13 @@ struct notes_merge_pair {
 	struct object_id obj, base, local, remote;
 };
 
-void init_notes_merge_options(struct notes_merge_options *o)
+void init_notes_merge_options(struct repository *r,
+			      struct notes_merge_options *o)
 {
 	memset(o, 0, sizeof(struct notes_merge_options));
 	strbuf_init(&(o->commit_msg), 0);
 	o->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;
+	o->repo = r;
 }
 
 static int path_to_oid(const char *path, struct object_id *oid)
@@ -127,7 +129,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
 	trace_printf("\tdiff_tree_remote(base = %.7s, remote = %.7s)\n",
 	       oid_to_hex(base), oid_to_hex(remote));
 
-	repo_diff_setup(the_repository, &opt);
+	repo_diff_setup(o->repo, &opt);
 	opt.flags.recursive = 1;
 	opt.output_format = DIFF_FORMAT_NO_OUTPUT;
 	diff_setup_done(&opt);
@@ -190,7 +192,7 @@ static void diff_tree_local(struct notes_merge_options *o,
 	trace_printf("\tdiff_tree_local(len = %i, base = %.7s, local = %.7s)\n",
 	       len, oid_to_hex(base), oid_to_hex(local));
 
-	repo_diff_setup(the_repository, &opt);
+	repo_diff_setup(o->repo, &opt);
 	opt.flags.recursive = 1;
 	opt.output_format = DIFF_FORMAT_NO_OUTPUT;
 	diff_setup_done(&opt);
@@ -350,7 +352,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
 
 	status = ll_merge(&result_buf, oid_to_hex(&p->obj), &base, NULL,
 			  &local, o->local_ref, &remote, o->remote_ref,
-			  &the_index, NULL);
+			  o->repo->index, NULL);
 
 	free(base.ptr);
 	free(local.ptr);
@@ -711,7 +713,7 @@ int notes_merge_commit(struct notes_merge_options *o,
 		/* write file as blob, and add to partial_tree */
 		if (stat(path.buf, &st))
 			die_errno("Failed to stat '%s'", path.buf);
-		if (index_path(&the_index, &blob_oid, path.buf, &st, HASH_WRITE_OBJECT))
+		if (index_path(o->repo->index, &blob_oid, path.buf, &st, HASH_WRITE_OBJECT))
 			die("Failed to write blob object from '%s'", path.buf);
 		if (add_note(partial_tree, &obj_oid, &blob_oid, NULL))
 			die("Failed to add resolved note '%s' to notes tree",
diff --git a/notes-merge.h b/notes-merge.h
index 6c74e9385b..99f9c709c5 100644
--- a/notes-merge.h
+++ b/notes-merge.h
@@ -6,6 +6,7 @@
 
 struct commit;
 struct object_id;
+struct repository;
 
 #define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
 
@@ -15,6 +16,7 @@ enum notes_merge_verbosity {
 };
 
 struct notes_merge_options {
+	struct repository *repo;
 	const char *local_ref;
 	const char *remote_ref;
 	struct strbuf commit_msg;
@@ -23,7 +25,8 @@ struct notes_merge_options {
 	unsigned has_worktree:1;
 };
 
-void init_notes_merge_options(struct notes_merge_options *o);
+void init_notes_merge_options(struct repository *r,
+			      struct notes_merge_options *o);
 
 /*
  * Merge notes from o->remote_ref into o->local_ref
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 06/22] notes-merge.c: remove implicit dependency the_repository
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (4 preceding siblings ...)
  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 ` 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
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 notes-merge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/notes-merge.c b/notes-merge.c
index 0c22f09b28..72688d301b 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -558,7 +558,7 @@ int notes_merge(struct notes_merge_options *o,
 	else if (!check_refname_format(o->local_ref, 0) &&
 		is_null_oid(&local_oid))
 		local = NULL; /* local_oid == null_oid indicates unborn ref */
-	else if (!(local = lookup_commit_reference(the_repository, &local_oid)))
+	else if (!(local = lookup_commit_reference(o->repo, &local_oid)))
 		die("Could not parse local commit %s (%s)",
 		    oid_to_hex(&local_oid), o->local_ref);
 	trace_printf("\tlocal commit: %.7s\n", oid_to_hex(&local_oid));
@@ -576,7 +576,7 @@ int notes_merge(struct notes_merge_options *o,
 			die("Failed to resolve remote notes ref '%s'",
 			    o->remote_ref);
 		}
-	} else if (!(remote = lookup_commit_reference(the_repository, &remote_oid))) {
+	} else if (!(remote = lookup_commit_reference(o->repo, &remote_oid))) {
 		die("Could not parse remote commit %s (%s)",
 		    oid_to_hex(&remote_oid), o->remote_ref);
 	}
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 07/22] transport.c: remove implicit dependency on the_index
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (5 preceding siblings ...)
  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 ` 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
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

note, there's still another hidden dependency related to this: even
though we pass a repo to transport_push() we still use
is_bare_repository() which pretty much assumes the_repository (and
some other global state).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/push.c | 3 ++-
 transport.c    | 7 ++++---
 transport.h    | 3 ++-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/builtin/push.c b/builtin/push.c
index d09a42062c..efb3e38a8d 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -355,7 +355,8 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
 
 	if (verbosity > 0)
 		fprintf(stderr, _("Pushing to %s\n"), transport->url);
-	err = transport_push(transport, rs, flags, &reject_reasons);
+	err = transport_push(the_repository, transport,
+			     rs, flags, &reject_reasons);
 	if (err != 0) {
 		fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
 		error(_("failed to push some refs to '%s'"), transport->url);
diff --git a/transport.c b/transport.c
index 5a74b609ff..71f663743f 100644
--- a/transport.c
+++ b/transport.c
@@ -1105,7 +1105,8 @@ static int run_pre_push_hook(struct transport *transport,
 	return ret;
 }
 
-int transport_push(struct transport *transport,
+int transport_push(struct repository *r,
+		   struct transport *transport,
 		   struct refspec *rs, int flags,
 		   unsigned int *reject_reasons)
 {
@@ -1172,7 +1173,7 @@ int transport_push(struct transport *transport,
 					oid_array_append(&commits,
 							  &ref->new_oid);
 
-			if (!push_unpushed_submodules(the_repository,
+			if (!push_unpushed_submodules(r,
 						      &commits,
 						      transport->remote,
 						      rs,
@@ -1197,7 +1198,7 @@ int transport_push(struct transport *transport,
 					oid_array_append(&commits,
 							  &ref->new_oid);
 
-			if (find_unpushed_submodules(the_repository,
+			if (find_unpushed_submodules(r,
 						     &commits,
 						     transport->remote->name,
 						     &needs_pushing)) {
diff --git a/transport.h b/transport.h
index 9baeca2d7a..f2ee7c4f49 100644
--- a/transport.h
+++ b/transport.h
@@ -223,7 +223,8 @@ void transport_set_verbosity(struct transport *transport, int verbosity,
 #define REJECT_FETCH_FIRST     0x08
 #define REJECT_NEEDS_FORCE     0x10
 
-int transport_push(struct transport *connection,
+int transport_push(struct repository *repo,
+		   struct transport *connection,
 		   struct refspec *rs, int flags,
 		   unsigned int * reject_reasons);
 
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 08/22] sequencer.c: remove implicit dependency on the_index
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (6 preceding siblings ...)
  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 ` 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
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Since we're going to pass 'struct repository *' around most of the
time instead of 'struct index_state *' because most sequencer.c
operations need more than just the index, the_repository is replaced
as well in the functions that now take 'struct repository
*'. the_repository is still present in this file, but total clean up
will be done later. It's not the main focus of this patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/commit.c              |   3 +-
 builtin/merge.c               |   2 +-
 builtin/rebase--interactive.c |   4 +-
 builtin/revert.c              |   4 +-
 sequencer.c                   | 321 +++++++++++++++++++---------------
 sequencer.h                   |  15 +-
 6 files changed, 197 insertions(+), 152 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 6637a928a7..e89bf35634 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1679,7 +1679,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 			flags |= SUMMARY_INITIAL_COMMIT;
 		if (author_date_is_interesting())
 			flags |= SUMMARY_SHOW_AUTHOR_DATE;
-		print_commit_summary(prefix, &oid, flags);
+		print_commit_summary(the_repository, prefix,
+				     &oid, flags);
 	}
 
 	UNLEAK(err);
diff --git a/builtin/merge.c b/builtin/merge.c
index 4aa6071598..db22119c93 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -896,7 +896,7 @@ static int suggest_conflicts(void)
 	filename = git_path_merge_msg(the_repository);
 	fp = xfopen(filename, "a");
 
-	append_conflicts_hint(&msgbuf);
+	append_conflicts_hint(&the_index, &msgbuf);
 	fputs(msgbuf.buf, fp);
 	strbuf_release(&msgbuf);
 	fclose(fp);
diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c
index a2ab68ed06..b7ce48a1ec 100644
--- a/builtin/rebase--interactive.c
+++ b/builtin/rebase--interactive.c
@@ -105,7 +105,7 @@ static int do_interactive_rebase(struct replay_opts *opts, unsigned flags,
 	if (restrict_revision)
 		argv_array_push(&make_script_args, restrict_revision);
 
-	ret = sequencer_make_script(todo_list,
+	ret = sequencer_make_script(the_repository, todo_list,
 				    make_script_args.argc, make_script_args.argv,
 				    flags);
 	fclose(todo_list);
@@ -235,7 +235,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
 		rerere_clear(&merge_rr);
 		/* fallthrough */
 	case CONTINUE:
-		ret = sequencer_continue(&opts);
+		ret = sequencer_continue(the_repository, &opts);
 		break;
 	}
 	case EDIT_TODO:
diff --git a/builtin/revert.c b/builtin/revert.c
index c93393c89b..cd9f068195 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -199,10 +199,10 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
 		return ret;
 	}
 	if (cmd == 'c')
-		return sequencer_continue(opts);
+		return sequencer_continue(the_repository, opts);
 	if (cmd == 'a')
 		return sequencer_rollback(opts);
-	return sequencer_pick_revisions(opts);
+	return sequencer_pick_revisions(the_repository, opts);
 }
 
 int cmd_revert(int argc, const char **argv, const char *prefix)
diff --git a/sequencer.c b/sequencer.c
index 0b8f18fd36..6cf3f65b0c 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -445,9 +445,9 @@ static struct tree *empty_tree(void)
 	return lookup_tree(the_repository, the_repository->hash_algo->empty_tree);
 }
 
-static int error_dirty_index(struct replay_opts *opts)
+static int error_dirty_index(struct index_state *istate, struct replay_opts *opts)
 {
-	if (read_cache_unmerged())
+	if (read_index_unmerged(istate))
 		return error_resolve_conflict(_(action_name(opts)));
 
 	error(_("your local changes would be overwritten by %s."),
@@ -472,15 +472,18 @@ static void update_abort_safety_file(void)
 		write_file(git_path_abort_safety_file(), "%s", "");
 }
 
-static int fast_forward_to(const struct object_id *to, const struct object_id *from,
-			int unborn, struct replay_opts *opts)
+static int fast_forward_to(struct repository *r,
+			   const struct object_id *to,
+			   const struct object_id *from,
+			   int unborn,
+			   struct replay_opts *opts)
 {
 	struct ref_transaction *transaction;
 	struct strbuf sb = STRBUF_INIT;
 	struct strbuf err = STRBUF_INIT;
 
-	read_index(&the_index);
-	if (checkout_fast_forward(the_repository, from, to, 1))
+	read_index(r->index);
+	if (checkout_fast_forward(r, from, to, 1))
 		return -1; /* the callee should have complained already */
 
 	strbuf_addf(&sb, _("%s: fast-forward"), _(action_name(opts)));
@@ -506,24 +509,26 @@ static int fast_forward_to(const struct object_id *to, const struct object_id *f
 	return 0;
 }
 
-void append_conflicts_hint(struct strbuf *msgbuf)
+void append_conflicts_hint(struct index_state *istate,
+			   struct strbuf *msgbuf)
 {
 	int i;
 
 	strbuf_addch(msgbuf, '\n');
 	strbuf_commented_addf(msgbuf, "Conflicts:\n");
-	for (i = 0; i < active_nr;) {
-		const struct cache_entry *ce = active_cache[i++];
+	for (i = 0; i < istate->cache_nr;) {
+		const struct cache_entry *ce = istate->cache[i++];
 		if (ce_stage(ce)) {
 			strbuf_commented_addf(msgbuf, "\t%s\n", ce->name);
-			while (i < active_nr && !strcmp(ce->name,
-							active_cache[i]->name))
+			while (i < istate->cache_nr &&
+			       !strcmp(ce->name, istate->cache[i]->name))
 				i++;
 		}
 	}
 }
 
-static int do_recursive_merge(struct commit *base, struct commit *next,
+static int do_recursive_merge(struct repository *r,
+			      struct commit *base, struct commit *next,
 			      const char *base_label, const char *next_label,
 			      struct object_id *head, struct strbuf *msgbuf,
 			      struct replay_opts *opts)
@@ -537,7 +542,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
 	if (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR) < 0)
 		return -1;
 
-	read_cache();
+	read_index(r->index);
 
 	init_merge_options(&o);
 	o.ancestor = base ? base_label : "(empty tree)";
@@ -566,7 +571,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
 		return clean;
 	}
 
-	if (write_locked_index(&the_index, &index_lock,
+	if (write_locked_index(r->index, &index_lock,
 			       COMMIT_LOCK | SKIP_IF_UNCHANGED))
 		/*
 		 * TRANSLATORS: %s will be "revert", "cherry-pick" or
@@ -576,26 +581,26 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
 			_(action_name(opts)));
 
 	if (!clean)
-		append_conflicts_hint(msgbuf);
+		append_conflicts_hint(r->index, msgbuf);
 
 	return !clean;
 }
 
-static struct object_id *get_cache_tree_oid(void)
+static struct object_id *get_cache_tree_oid(struct index_state *istate)
 {
-	if (!active_cache_tree)
-		active_cache_tree = cache_tree();
+	if (!istate->cache_tree)
+		istate->cache_tree = cache_tree();
 
-	if (!cache_tree_fully_valid(active_cache_tree))
-		if (cache_tree_update(&the_index, 0)) {
+	if (!cache_tree_fully_valid(istate->cache_tree))
+		if (cache_tree_update(istate, 0)) {
 			error(_("unable to update cache tree"));
 			return NULL;
 		}
 
-	return &active_cache_tree->oid;
+	return &istate->cache_tree->oid;
 }
 
-static int is_index_unchanged(void)
+static int is_index_unchanged(struct index_state *istate)
 {
 	struct object_id head_oid, *cache_tree_oid;
 	struct commit *head_commit;
@@ -616,7 +621,7 @@ static int is_index_unchanged(void)
 	if (parse_commit(head_commit))
 		return -1;
 
-	if (!(cache_tree_oid = get_cache_tree_oid()))
+	if (!(cache_tree_oid = get_cache_tree_oid(istate)))
 		return -1;
 
 	return oideq(cache_tree_oid, get_commit_tree_oid(head_commit));
@@ -838,7 +843,9 @@ static int run_command_silent_on_success(struct child_process *cmd)
  * interactive rebase: in that case, we will want to retain the
  * author metadata.
  */
-static int run_git_commit(const char *defmsg, struct replay_opts *opts,
+static int run_git_commit(struct repository *r,
+			  const char *defmsg,
+			  struct replay_opts *opts,
 			  unsigned int flags)
 {
 	struct child_process cmd = CHILD_PROCESS_INIT;
@@ -861,7 +868,7 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
 		if (!defmsg)
 			BUG("root commit without message");
 
-		if (!(cache_tree_oid = get_cache_tree_oid()))
+		if (!(cache_tree_oid = get_cache_tree_oid(r->index)))
 			res = -1;
 
 		if (!res)
@@ -1070,7 +1077,9 @@ void commit_post_rewrite(const struct commit *old_head,
 	run_rewrite_hook(&old_head->object.oid, new_head);
 }
 
-static int run_prepare_commit_msg_hook(struct strbuf *msg, const char *commit)
+static int run_prepare_commit_msg_hook(struct repository *r,
+				       struct strbuf *msg,
+				       const char *commit)
 {
 	struct argv_array hook_env = ARGV_ARRAY_INIT;
 	int ret;
@@ -1080,7 +1089,7 @@ static int run_prepare_commit_msg_hook(struct strbuf *msg, const char *commit)
 	if (write_message(msg->buf, msg->len, name, 0))
 		return -1;
 
-	argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", get_index_file());
+	argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", r->index_file);
 	argv_array_push(&hook_env, "GIT_EDITOR=:");
 	if (commit)
 		ret = run_hook_le(hook_env.argv, "prepare-commit-msg", name,
@@ -1136,7 +1145,9 @@ static const char *implicit_ident_advice(void)
 
 }
 
-void print_commit_summary(const char *prefix, const struct object_id *oid,
+void print_commit_summary(struct repository *r,
+			  const char *prefix,
+			  const struct object_id *oid,
 			  unsigned int flags)
 {
 	struct rev_info rev;
@@ -1147,7 +1158,7 @@ void print_commit_summary(const char *prefix, const struct object_id *oid,
 	struct strbuf author_ident = STRBUF_INIT;
 	struct strbuf committer_ident = STRBUF_INIT;
 
-	commit = lookup_commit(the_repository, oid);
+	commit = lookup_commit(r, oid);
 	if (!commit)
 		die(_("couldn't look up newly created commit"));
 	if (parse_commit(commit))
@@ -1180,7 +1191,7 @@ void print_commit_summary(const char *prefix, const struct object_id *oid,
 	strbuf_release(&author_ident);
 	strbuf_release(&committer_ident);
 
-	repo_init_revisions(the_repository, &rev, prefix);
+	repo_init_revisions(r, &rev, prefix);
 	setup_revisions(0, NULL, &rev, NULL);
 
 	rev.diff = 1;
@@ -1246,7 +1257,8 @@ static int parse_head(struct commit **head)
  *   0 - success
  *   1 - run 'git commit'
  */
-static int try_to_commit(struct strbuf *msg, const char *author,
+static int try_to_commit(struct repository *r,
+			 struct strbuf *msg, const char *author,
 			 struct replay_opts *opts, unsigned int flags,
 			 struct object_id *oid)
 {
@@ -1290,7 +1302,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,
 		commit_list_insert(current_head, &parents);
 	}
 
-	if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL)) {
+	if (write_index_as_tree(&tree, r->index, r->index_file, 0, NULL)) {
 		res = error(_("git write-tree failed to write a tree"));
 		goto out;
 	}
@@ -1303,7 +1315,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,
 	}
 
 	if (find_hook("prepare-commit-msg")) {
-		res = run_prepare_commit_msg_hook(msg, hook_commit);
+		res = run_prepare_commit_msg_hook(r, msg, hook_commit);
 		if (res)
 			goto out;
 		if (strbuf_read_file(&commit_msg, git_path_commit_editmsg(),
@@ -1352,7 +1364,8 @@ static int try_to_commit(struct strbuf *msg, const char *author,
 	return res;
 }
 
-static int do_commit(const char *msg_file, const char *author,
+static int do_commit(struct repository *r,
+		     const char *msg_file, const char *author,
 		     struct replay_opts *opts, unsigned int flags)
 {
 	int res = 1;
@@ -1367,20 +1380,20 @@ static int do_commit(const char *msg_file, const char *author,
 					     "from '%s'"),
 					   msg_file);
 
-		res = try_to_commit(msg_file ? &sb : NULL, author, opts, flags,
-				    &oid);
+		res = try_to_commit(r, msg_file ? &sb : NULL,
+				    author, opts, flags, &oid);
 		strbuf_release(&sb);
 		if (!res) {
-			unlink(git_path_cherry_pick_head(the_repository));
-			unlink(git_path_merge_msg(the_repository));
+			unlink(git_path_cherry_pick_head(r));
+			unlink(git_path_merge_msg(r));
 			if (!is_rebase_i(opts))
-				print_commit_summary(NULL, &oid,
+				print_commit_summary(r, NULL, &oid,
 						SUMMARY_SHOW_AUTHOR_DATE);
 			return res;
 		}
 	}
 	if (res == 1)
-		return run_git_commit(msg_file, opts, flags);
+		return run_git_commit(r, msg_file, opts, flags);
 
 	return res;
 }
@@ -1408,7 +1421,9 @@ static int is_original_commit_empty(struct commit *commit)
 /*
  * Do we run "git commit" with "--allow-empty"?
  */
-static int allow_empty(struct replay_opts *opts, struct commit *commit)
+static int allow_empty(struct repository *r,
+		       struct replay_opts *opts,
+		       struct commit *commit)
 {
 	int index_unchanged, empty_commit;
 
@@ -1425,7 +1440,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
 	if (!opts->allow_empty)
 		return 0; /* let "git commit" barf as necessary */
 
-	index_unchanged = is_index_unchanged();
+	index_unchanged = is_index_unchanged(r->index);
 	if (index_unchanged < 0)
 		return index_unchanged;
 	if (!index_unchanged)
@@ -1658,11 +1673,14 @@ static void record_in_rewritten(struct object_id *oid,
 		flush_rewritten_pending();
 }
 
-static int do_pick_commit(enum todo_command command, struct commit *commit,
-		struct replay_opts *opts, int final_fixup)
+static int do_pick_commit(struct repository *r,
+			  enum todo_command command,
+			  struct commit *commit,
+			  struct replay_opts *opts,
+			  int final_fixup)
 {
 	unsigned int flags = opts->edit ? EDIT_MSG : 0;
-	const char *msg_file = opts->edit ? NULL : git_path_merge_msg(the_repository);
+	const char *msg_file = opts->edit ? NULL : git_path_merge_msg(r);
 	struct object_id head;
 	struct commit *base, *next, *parent;
 	const char *base_label, *next_label;
@@ -1678,7 +1696,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 		 * that represents the "current" state for merge-recursive
 		 * to work on.
 		 */
-		if (write_index_as_tree(&head, &the_index, get_index_file(), 0, NULL))
+		if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
 			return error(_("your index file is unmerged."));
 	} else {
 		unborn = get_oid("HEAD", &head);
@@ -1693,9 +1711,9 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 			oidcpy(&head, the_hash_algo->empty_tree);
 		if (index_differs_from(unborn ? empty_tree_oid_hex() : "HEAD",
 				       NULL, 0))
-			return error_dirty_index(opts);
+			return error_dirty_index(r->index, opts);
 	}
-	discard_cache();
+	discard_index(r->index);
 
 	if (!commit->parents)
 		parent = NULL;
@@ -1731,7 +1749,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 	     (!parent && unborn))) {
 		if (is_rebase_i(opts))
 			write_author_script(msg.message);
-		res = fast_forward_to(&commit->object.oid, &head, unborn,
+		res = fast_forward_to(r, &commit->object.oid, &head, unborn,
 			opts);
 		if (res || command != TODO_REWORD)
 			goto leave;
@@ -1804,12 +1822,12 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 			flags |= CLEANUP_MSG;
 			msg_file = rebase_path_fixup_msg();
 		} else {
-			const char *dest = git_path_squash_msg(the_repository);
+			const char *dest = git_path_squash_msg(r);
 			unlink(dest);
 			if (copy_file(dest, rebase_path_squash_msg(), 0666))
 				return error(_("could not rename '%s' to '%s'"),
 					     rebase_path_squash_msg(), dest);
-			unlink(git_path_merge_msg(the_repository));
+			unlink(git_path_merge_msg(r));
 			msg_file = dest;
 			flags |= EDIT_MSG;
 		}
@@ -1821,23 +1839,23 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 	if (is_rebase_i(opts) && write_author_script(msg.message) < 0)
 		res = -1;
 	else if (!opts->strategy || !strcmp(opts->strategy, "recursive") || command == TODO_REVERT) {
-		res = do_recursive_merge(base, next, base_label, next_label,
+		res = do_recursive_merge(r, base, next, base_label, next_label,
 					 &head, &msgbuf, opts);
 		if (res < 0)
 			goto leave;
 
 		res |= write_message(msgbuf.buf, msgbuf.len,
-				     git_path_merge_msg(the_repository), 0);
+				     git_path_merge_msg(r), 0);
 	} else {
 		struct commit_list *common = NULL;
 		struct commit_list *remotes = NULL;
 
 		res = write_message(msgbuf.buf, msgbuf.len,
-				    git_path_merge_msg(the_repository), 0);
+				    git_path_merge_msg(r), 0);
 
 		commit_list_insert(base, &common);
 		commit_list_insert(next, &remotes);
-		res |= try_merge_command(the_repository, opts->strategy,
+		res |= try_merge_command(r, opts->strategy,
 					 opts->xopts_nr, (const char **)opts->xopts,
 					common, oid_to_hex(&head), remotes);
 		free_commit_list(common);
@@ -1866,11 +1884,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 		      : _("could not apply %s... %s"),
 		      short_commit_name(commit), msg.subject);
 		print_advice(res == 1, opts);
-		repo_rerere(the_repository, opts->allow_rerere_auto);
+		repo_rerere(r, opts->allow_rerere_auto);
 		goto leave;
 	}
 
-	allow = allow_empty(opts, commit);
+	allow = allow_empty(r, opts, commit);
 	if (allow < 0) {
 		res = allow;
 		goto leave;
@@ -1879,7 +1897,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 	if (!opts->no_commit) {
 fast_forward_edit:
 		if (author || command == TODO_REVERT || (flags & AMEND_MSG))
-			res = do_commit(msg_file, author, opts, flags);
+			res = do_commit(r, msg_file, author, opts, flags);
 		else
 			res = error(_("unable to parse commit author"));
 	}
@@ -1915,18 +1933,19 @@ static int prepare_revs(struct replay_opts *opts)
 	return 0;
 }
 
-static int read_and_refresh_cache(struct replay_opts *opts)
+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_preload(&the_index, NULL, 0) < 0) {
+	if (read_index_preload(r->index, NULL, 0) < 0) {
 		rollback_lock_file(&index_lock);
 		return error(_("git %s: failed to read the index"),
 			_(action_name(opts)));
 	}
-	refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
+	refresh_index(r->index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
 	if (index_fd >= 0) {
-		if (write_locked_index(&the_index, &index_lock,
+		if (write_locked_index(r->index, &index_lock,
 				       COMMIT_LOCK | SKIP_IF_UNCHANGED)) {
 			return error(_("git %s: failed to refresh the index"),
 				_(action_name(opts)));
@@ -2644,7 +2663,9 @@ static int save_opts(struct replay_opts *opts)
 	return res;
 }
 
-static int make_patch(struct commit *commit, struct replay_opts *opts)
+static int make_patch(struct repository *r,
+		      struct commit *commit,
+		      struct replay_opts *opts)
 {
 	struct strbuf buf = STRBUF_INIT;
 	struct rev_info log_tree_opt;
@@ -2660,7 +2681,7 @@ static int make_patch(struct commit *commit, struct replay_opts *opts)
 
 	strbuf_addf(&buf, "%s/patch", get_dir(opts));
 	memset(&log_tree_opt, 0, sizeof(log_tree_opt));
-	repo_init_revisions(the_repository, &log_tree_opt, NULL);
+	repo_init_revisions(r, &log_tree_opt, NULL);
 	log_tree_opt.abbrev = 0;
 	log_tree_opt.diff = 1;
 	log_tree_opt.diffopt.output_format = DIFF_FORMAT_PATCH;
@@ -2700,17 +2721,19 @@ static int intend_to_amend(void)
 	return write_message(p, strlen(p), rebase_path_amend(), 1);
 }
 
-static int error_with_patch(struct commit *commit,
-	const char *subject, int subject_len,
-	struct replay_opts *opts, int exit_code, int to_amend)
+static int error_with_patch(struct repository *r,
+			    struct commit *commit,
+			    const char *subject, int subject_len,
+			    struct replay_opts *opts,
+			    int exit_code, int to_amend)
 {
 	if (commit) {
-		if (make_patch(commit, opts))
+		if (make_patch(r, commit, opts))
 			return -1;
 	} else if (copy_file(rebase_path_message(),
-			     git_path_merge_msg(the_repository), 0666))
+			     git_path_merge_msg(r), 0666))
 		return error(_("unable to copy '%s' to '%s'"),
-			     git_path_merge_msg(the_repository), rebase_path_message());
+			     git_path_merge_msg(r), rebase_path_message());
 
 	if (to_amend) {
 		if (intend_to_amend())
@@ -2741,21 +2764,24 @@ static int error_with_patch(struct commit *commit,
 	return exit_code;
 }
 
-static int error_failed_squash(struct commit *commit,
-	struct replay_opts *opts, int subject_len, const char *subject)
+static int error_failed_squash(struct repository *r,
+			       struct commit *commit,
+			       struct replay_opts *opts,
+			       int subject_len,
+			       const char *subject)
 {
 	if (copy_file(rebase_path_message(), rebase_path_squash_msg(), 0666))
 		return error(_("could not copy '%s' to '%s'"),
 			rebase_path_squash_msg(), rebase_path_message());
-	unlink(git_path_merge_msg(the_repository));
-	if (copy_file(git_path_merge_msg(the_repository), rebase_path_message(), 0666))
+	unlink(git_path_merge_msg(r));
+	if (copy_file(git_path_merge_msg(r), rebase_path_message(), 0666))
 		return error(_("could not copy '%s' to '%s'"),
 			     rebase_path_message(),
-			     git_path_merge_msg(the_repository));
-	return error_with_patch(commit, subject, subject_len, opts, 1, 0);
+			     git_path_merge_msg(r));
+	return error_with_patch(r, commit, subject, subject_len, opts, 1, 0);
 }
 
-static int do_exec(const char *command_line)
+static int do_exec(struct repository *r, const char *command_line)
 {
 	struct argv_array child_env = ARGV_ARRAY_INIT;
 	const char *child_argv[] = { NULL, NULL };
@@ -2770,10 +2796,10 @@ static int do_exec(const char *command_line)
 					  child_env.argv);
 
 	/* force re-reading of the cache */
-	if (discard_cache() < 0 || read_cache() < 0)
+	if (discard_index(r->index) < 0 || read_index(r->index) < 0)
 		return error(_("could not read index"));
 
-	dirty = require_clean_work_tree(the_repository, "rebase", NULL, 1, 1);
+	dirty = require_clean_work_tree(r, "rebase", NULL, 1, 1);
 
 	if (status) {
 		warning(_("execution failed: %s\n%s"
@@ -2839,9 +2865,9 @@ static int safe_append(const char *filename, const char *fmt, ...)
 	return 0;
 }
 
-static int do_label(const char *name, int len)
+static int do_label(struct repository *r, const char *name, int len)
 {
-	struct ref_store *refs = get_main_ref_store(the_repository);
+	struct ref_store *refs = get_main_ref_store(r);
 	struct ref_transaction *transaction;
 	struct strbuf ref_name = STRBUF_INIT, err = STRBUF_INIT;
 	struct strbuf msg = STRBUF_INIT;
@@ -2882,7 +2908,9 @@ static int do_label(const char *name, int len)
 static const char *reflog_message(struct replay_opts *opts,
 	const char *sub_action, const char *fmt, ...);
 
-static int do_reset(const char *name, int len, struct replay_opts *opts)
+static int do_reset(struct repository *r,
+		    const char *name, int len,
+		    struct replay_opts *opts)
 {
 	struct strbuf ref_name = STRBUF_INIT;
 	struct object_id oid;
@@ -2928,13 +2956,13 @@ static int do_reset(const char *name, int len, struct replay_opts *opts)
 	memset(&unpack_tree_opts, 0, sizeof(unpack_tree_opts));
 	setup_unpack_trees_porcelain(&unpack_tree_opts, "reset");
 	unpack_tree_opts.head_idx = 1;
-	unpack_tree_opts.src_index = &the_index;
-	unpack_tree_opts.dst_index = &the_index;
+	unpack_tree_opts.src_index = r->index;
+	unpack_tree_opts.dst_index = r->index;
 	unpack_tree_opts.fn = oneway_merge;
 	unpack_tree_opts.merge = 1;
 	unpack_tree_opts.update = 1;
 
-	if (read_cache_unmerged()) {
+	if (read_index_unmerged(r->index)) {
 		rollback_lock_file(&lock);
 		strbuf_release(&ref_name);
 		return error_resolve_conflict(_(action_name(opts)));
@@ -2956,9 +2984,9 @@ static int do_reset(const char *name, int len, struct replay_opts *opts)
 	}
 
 	tree = parse_tree_indirect(&oid);
-	prime_cache_tree(&the_index, tree);
+	prime_cache_tree(r->index, tree);
 
-	if (write_locked_index(&the_index, &lock, COMMIT_LOCK) < 0)
+	if (write_locked_index(r->index, &lock, COMMIT_LOCK) < 0)
 		ret = error(_("could not write index"));
 	free((void *)desc.buffer);
 
@@ -2991,7 +3019,9 @@ static struct commit *lookup_label(const char *label, int len,
 	return commit;
 }
 
-static int do_merge(struct commit *commit, const char *arg, int arg_len,
+static int do_merge(struct repository *r,
+		    struct commit *commit,
+		    const char *arg, int arg_len,
 		    int flags, struct replay_opts *opts)
 {
 	int run_commit_flags = (flags & TODO_EDIT_MERGE_MSG) ?
@@ -3058,7 +3088,7 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
 			ret = error(_("octopus merge cannot be executed on "
 				      "top of a [new root]"));
 		else
-			ret = fast_forward_to(&to_merge->item->object.oid,
+			ret = fast_forward_to(r, &to_merge->item->object.oid,
 					      &head_commit->object.oid, 0,
 					      opts);
 		goto leave_merge;
@@ -3077,11 +3107,11 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
 		write_author_script(message);
 		find_commit_subject(message, &body);
 		len = strlen(body);
-		ret = write_message(body, len, git_path_merge_msg(the_repository), 0);
+		ret = write_message(body, len, git_path_merge_msg(r), 0);
 		unuse_commit_buffer(commit, message);
 		if (ret) {
 			error_errno(_("could not write '%s'"),
-				    git_path_merge_msg(the_repository));
+				    git_path_merge_msg(r));
 			goto leave_merge;
 		}
 	} else {
@@ -3103,11 +3133,11 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
 			len = buf.len;
 		}
 
-		ret = write_message(p, len, git_path_merge_msg(the_repository), 0);
+		ret = write_message(p, len, git_path_merge_msg(r), 0);
 		strbuf_release(&buf);
 		if (ret) {
 			error_errno(_("could not write '%s'"),
-				    git_path_merge_msg(the_repository));
+				    git_path_merge_msg(r));
 			goto leave_merge;
 		}
 	}
@@ -3143,7 +3173,7 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
 
 	if (can_fast_forward) {
 		rollback_lock_file(&lock);
-		ret = fast_forward_to(&commit->object.oid,
+		ret = fast_forward_to(r, &commit->object.oid,
 				      &head_commit->object.oid, 0, opts);
 		goto leave_merge;
 	}
@@ -3168,7 +3198,7 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
 		argv_array_push(&cmd.args, "--no-log");
 		argv_array_push(&cmd.args, "--no-stat");
 		argv_array_push(&cmd.args, "-F");
-		argv_array_push(&cmd.args, git_path_merge_msg(the_repository));
+		argv_array_push(&cmd.args, git_path_merge_msg(r));
 		if (opts->gpg_sign)
 			argv_array_push(&cmd.args, opts->gpg_sign);
 
@@ -3178,22 +3208,23 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
 					oid_to_hex(&j->item->object.oid));
 
 		strbuf_release(&ref_name);
-		unlink(git_path_cherry_pick_head(the_repository));
+		unlink(git_path_cherry_pick_head(r));
 		rollback_lock_file(&lock);
 
 		rollback_lock_file(&lock);
 		ret = run_command(&cmd);
 
 		/* force re-reading of the cache */
-		if (!ret && (discard_cache() < 0 || read_cache() < 0))
+		if (!ret && (discard_index(r->index) < 0 ||
+			     read_index(r->index) < 0))
 			ret = error(_("could not read index"));
 		goto leave_merge;
 	}
 
 	merge_commit = to_merge->item;
 	write_message(oid_to_hex(&merge_commit->object.oid), GIT_SHA1_HEXSZ,
-		      git_path_merge_head(the_repository), 0);
-	write_message("no-ff", 5, git_path_merge_mode(the_repository), 0);
+		      git_path_merge_head(r), 0);
+	write_message("no-ff", 5, git_path_merge_mode(r), 0);
 
 	bases = get_merge_bases(head_commit, merge_commit);
 	if (bases && oideq(&merge_commit->object.oid,
@@ -3207,7 +3238,7 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
 		commit_list_insert(j->item, &reversed);
 	free_commit_list(bases);
 
-	read_cache();
+	read_index(r->index);
 	init_merge_options(&o);
 	o.branch1 = "HEAD";
 	o.branch2 = ref_name.buf;
@@ -3232,23 +3263,23 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
 	 */
 	ret = !ret;
 
-	if (active_cache_changed &&
-	    write_locked_index(&the_index, &lock, COMMIT_LOCK)) {
+	if (r->index->cache_changed &&
+	    write_locked_index(r->index, &lock, COMMIT_LOCK)) {
 		ret = error(_("merge: Unable to write new index file"));
 		goto leave_merge;
 	}
 
 	rollback_lock_file(&lock);
 	if (ret)
-		repo_rerere(the_repository, opts->allow_rerere_auto);
+		repo_rerere(r, opts->allow_rerere_auto);
 	else
 		/*
 		 * In case of problems, we now want to return a positive
 		 * value (a negative one would indicate that the `merge`
 		 * command needs to be rescheduled).
 		 */
-		ret = !!run_git_commit(git_path_merge_msg(the_repository), opts,
-				     run_commit_flags);
+		ret = !!run_git_commit(r, git_path_merge_msg(r), opts,
+				       run_commit_flags);
 
 leave_merge:
 	strbuf_release(&ref_name);
@@ -3425,7 +3456,9 @@ N_("Could not execute the todo command\n"
 "    git rebase --edit-todo\n"
 "    git rebase --continue\n");
 
-static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
+static int pick_commits(struct repository *r,
+			struct todo_list *todo_list,
+			struct replay_opts *opts)
 {
 	int res = 0, reschedule = 0;
 
@@ -3433,7 +3466,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 	if (opts->allow_ff)
 		assert(!(opts->signoff || opts->no_commit ||
 				opts->record_origin || opts->edit));
-	if (read_and_refresh_cache(opts))
+	if (read_and_refresh_cache(r, opts))
 		return -1;
 
 	while (todo_list->current < todo_list->nr) {
@@ -3469,7 +3502,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 				setenv("GIT_REFLOG_ACTION", reflog_message(opts,
 					command_to_string(item->command), NULL),
 					1);
-			res = do_pick_commit(item->command, item->commit,
+			res = do_pick_commit(r, item->command, item->commit,
 					opts, is_final_fixup(todo_list));
 			if (is_rebase_i(opts) && res < 0) {
 				/* Reschedule */
@@ -3489,7 +3522,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 						_("Stopped at %s...  %.*s\n"),
 						short_commit_name(commit),
 						item->arg_len, item->arg);
-				return error_with_patch(commit,
+				return error_with_patch(r, commit,
 					item->arg, item->arg_len, opts, res,
 					!res);
 			}
@@ -3499,7 +3532,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 			if (res && is_fixup(item->command)) {
 				if (res == 1)
 					intend_to_amend();
-				return error_failed_squash(item->commit, opts,
+				return error_failed_squash(r, item->commit, opts,
 					item->arg_len, item->arg);
 			} else if (res && is_rebase_i(opts) && item->commit) {
 				int to_amend = 0;
@@ -3518,7 +3551,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 				      oideq(&opts->squash_onto, &oid))))
 					to_amend = 1;
 
-				return res | error_with_patch(item->commit,
+				return res | error_with_patch(r, item->commit,
 						item->arg, item->arg_len, opts,
 						res, to_amend);
 			}
@@ -3528,7 +3561,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 			struct stat st;
 
 			*end_of_arg = '\0';
-			res = do_exec(item->arg);
+			res = do_exec(r, item->arg);
 			*end_of_arg = saved;
 
 			/* Reread the todo file if it has changed. */
@@ -3545,13 +3578,13 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 				todo_list->current = -1;
 			}
 		} else if (item->command == TODO_LABEL) {
-			if ((res = do_label(item->arg, item->arg_len)))
+			if ((res = do_label(r, item->arg, item->arg_len)))
 				reschedule = 1;
 		} else if (item->command == TODO_RESET) {
-			if ((res = do_reset(item->arg, item->arg_len, opts)))
+			if ((res = do_reset(r, item->arg, item->arg_len, opts)))
 				reschedule = 1;
 		} else if (item->command == TODO_MERGE) {
-			if ((res = do_merge(item->commit,
+			if ((res = do_merge(r, item->commit,
 					    item->arg, item->arg_len,
 					    item->flags, opts)) < 0)
 				reschedule = 1;
@@ -3560,7 +3593,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 						    peek_command(todo_list, 1));
 			if (res > 0)
 				/* failed with merge conflicts */
-				return error_with_patch(item->commit,
+				return error_with_patch(r, item->commit,
 							item->arg,
 							item->arg_len, opts,
 							res, 0);
@@ -3576,7 +3609,8 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 			if (save_todo(todo_list, opts))
 				return -1;
 			if (item->commit)
-				return error_with_patch(item->commit,
+				return error_with_patch(r,
+							item->commit,
 							item->arg,
 							item->arg_len, opts,
 							res, 0);
@@ -3641,7 +3675,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
 			struct object_id orig, head;
 
 			memset(&log_tree_opt, 0, sizeof(log_tree_opt));
-			repo_init_revisions(the_repository, &log_tree_opt, NULL);
+			repo_init_revisions(r, &log_tree_opt, NULL);
 			log_tree_opt.diff = 1;
 			log_tree_opt.diffopt.output_format =
 				DIFF_FORMAT_DIFFSTAT;
@@ -3708,16 +3742,17 @@ static int continue_single_pick(void)
 	return run_command_v_opt(argv, RUN_GIT_CMD);
 }
 
-static int commit_staged_changes(struct replay_opts *opts,
+static int commit_staged_changes(struct repository *r,
+				 struct replay_opts *opts,
 				 struct todo_list *todo_list)
 {
 	unsigned int flags = ALLOW_EMPTY | EDIT_MSG;
 	unsigned int final_fixup = 0, is_clean;
 
-	if (has_unstaged_changes(the_repository, 1))
+	if (has_unstaged_changes(r, 1))
 		return error(_("cannot rebase: You have unstaged changes."));
 
-	is_clean = !has_uncommitted_changes(the_repository, 0);
+	is_clean = !has_uncommitted_changes(r, 0);
 
 	if (file_exists(rebase_path_amend())) {
 		struct strbuf rev = STRBUF_INIT;
@@ -3817,7 +3852,7 @@ static int commit_staged_changes(struct replay_opts *opts,
 	}
 
 	if (is_clean) {
-		const char *cherry_pick_head = git_path_cherry_pick_head(the_repository);
+		const char *cherry_pick_head = git_path_cherry_pick_head(r);
 
 		if (file_exists(cherry_pick_head) && unlink(cherry_pick_head))
 			return error(_("could not remove CHERRY_PICK_HEAD"));
@@ -3825,7 +3860,7 @@ static int commit_staged_changes(struct replay_opts *opts,
 			return 0;
 	}
 
-	if (run_git_commit(final_fixup ? NULL : rebase_path_message(),
+	if (run_git_commit(r, final_fixup ? NULL : rebase_path_message(),
 			   opts, flags))
 		return error(_("could not commit staged changes."));
 	unlink(rebase_path_amend());
@@ -3845,12 +3880,12 @@ static int commit_staged_changes(struct replay_opts *opts,
 	return 0;
 }
 
-int sequencer_continue(struct replay_opts *opts)
+int sequencer_continue(struct repository *r, struct replay_opts *opts)
 {
 	struct todo_list todo_list = TODO_LIST_INIT;
 	int res;
 
-	if (read_and_refresh_cache(opts))
+	if (read_and_refresh_cache(r, opts))
 		return -1;
 
 	if (read_populate_opts(opts))
@@ -3858,7 +3893,7 @@ int sequencer_continue(struct replay_opts *opts)
 	if (is_rebase_i(opts)) {
 		if ((res = read_populate_todo(&todo_list, opts)))
 			goto release_todo_list;
-		if (commit_staged_changes(opts, &todo_list))
+		if (commit_staged_changes(r, opts, &todo_list))
 			return -1;
 	} else if (!file_exists(get_todo_path(opts)))
 		return continue_single_pick();
@@ -3867,14 +3902,14 @@ int sequencer_continue(struct replay_opts *opts)
 
 	if (!is_rebase_i(opts)) {
 		/* Verify that the conflict has been resolved */
-		if (file_exists(git_path_cherry_pick_head(the_repository)) ||
-		    file_exists(git_path_revert_head(the_repository))) {
+		if (file_exists(git_path_cherry_pick_head(r)) ||
+		    file_exists(git_path_revert_head(r))) {
 			res = continue_single_pick();
 			if (res)
 				goto release_todo_list;
 		}
 		if (index_differs_from("HEAD", NULL, 0)) {
-			res = error_dirty_index(opts);
+			res = error_dirty_index(r->index, opts);
 			goto release_todo_list;
 		}
 		todo_list.current++;
@@ -3888,27 +3923,30 @@ int sequencer_continue(struct replay_opts *opts)
 		strbuf_release(&buf);
 	}
 
-	res = pick_commits(&todo_list, opts);
+	res = pick_commits(r, &todo_list, opts);
 release_todo_list:
 	todo_list_release(&todo_list);
 	return res;
 }
 
-static int single_pick(struct commit *cmit, struct replay_opts *opts)
+static int single_pick(struct repository *r,
+		       struct commit *cmit,
+		       struct replay_opts *opts)
 {
 	setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
-	return do_pick_commit(opts->action == REPLAY_PICK ?
+	return do_pick_commit(r, opts->action == REPLAY_PICK ?
 		TODO_PICK : TODO_REVERT, cmit, opts, 0);
 }
 
-int sequencer_pick_revisions(struct replay_opts *opts)
+int sequencer_pick_revisions(struct repository *r,
+			     struct replay_opts *opts)
 {
 	struct todo_list todo_list = TODO_LIST_INIT;
 	struct object_id oid;
 	int i, res;
 
 	assert(opts->revs);
-	if (read_and_refresh_cache(opts))
+	if (read_and_refresh_cache(r, opts))
 		return -1;
 
 	for (i = 0; i < opts->revs->pending.nr; i++) {
@@ -3920,8 +3958,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
 			continue;
 
 		if (!get_oid(name, &oid)) {
-			if (!lookup_commit_reference_gently(the_repository, &oid, 1)) {
-				enum object_type type = oid_object_info(the_repository,
+			if (!lookup_commit_reference_gently(r, &oid, 1)) {
+				enum object_type type = oid_object_info(r,
 									&oid,
 									NULL);
 				return error(_("%s: can't cherry-pick a %s"),
@@ -3950,7 +3988,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
 			return error(_("empty commit set passed"));
 		if (get_revision(opts->revs))
 			BUG("unexpected extra commit from walk");
-		return single_pick(cmit, opts);
+		return single_pick(r, cmit, opts);
 	}
 
 	/*
@@ -3969,7 +4007,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
 	if (save_opts(opts))
 		return -1;
 	update_abort_safety_file();
-	res = pick_commits(&todo_list, opts);
+	res = pick_commits(r, &todo_list, opts);
 	todo_list_release(&todo_list);
 	return res;
 }
@@ -4373,7 +4411,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
 	return 0;
 }
 
-int sequencer_make_script(FILE *out, int argc, const char **argv,
+int sequencer_make_script(struct repository *r, FILE *out,
+			  int argc, const char **argv,
 			  unsigned flags)
 {
 	char *format = NULL;
@@ -4385,7 +4424,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
 	const char *insn = flags & TODO_LIST_ABBREVIATE_CMDS ? "p" : "pick";
 	int rebase_merges = flags & TODO_LIST_REBASE_MERGES;
 
-	repo_init_revisions(the_repository, &revs, NULL);
+	repo_init_revisions(r, &revs, NULL);
 	revs.verbose_header = 1;
 	if (!rebase_merges)
 		revs.max_parents = 1;
@@ -4850,7 +4889,7 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 	if (require_clean_work_tree(the_repository, "rebase", "", 1, 1))
 		return -1;
 
-	return sequencer_continue(opts);
+	return sequencer_continue(the_repository, opts);
 }
 
 struct subject2item_entry {
diff --git a/sequencer.h b/sequencer.h
index 660cff5050..ba86515ad6 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -5,6 +5,7 @@
 #include "strbuf.h"
 
 struct commit;
+struct repository;
 
 const char *git_path_commit_editmsg(void);
 const char *git_path_seq_dir(void);
@@ -74,8 +75,9 @@ int write_message(const void *buf, size_t len, const char *filename,
 
 /* Call this to setup defaults before parsing command line options */
 void sequencer_init_config(struct replay_opts *opts);
-int sequencer_pick_revisions(struct replay_opts *opts);
-int sequencer_continue(struct replay_opts *opts);
+int sequencer_pick_revisions(struct repository *repo,
+			     struct replay_opts *opts);
+int sequencer_continue(struct repository *repo, struct replay_opts *opts);
 int sequencer_rollback(struct replay_opts *opts);
 int sequencer_remove_state(struct replay_opts *opts);
 
@@ -89,7 +91,8 @@ int sequencer_remove_state(struct replay_opts *opts);
  * commits should be rebased onto the new base, this flag needs to be passed.
  */
 #define TODO_LIST_REBASE_COUSINS (1U << 4)
-int sequencer_make_script(FILE *out, int argc, const char **argv,
+int sequencer_make_script(struct repository *repo, FILE *out,
+			  int argc, const char **argv,
 			  unsigned flags);
 
 int sequencer_add_exec_commands(const char *command);
@@ -112,7 +115,7 @@ extern const char sign_off_header[];
  */
 void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag);
 
-void append_conflicts_hint(struct strbuf *msgbuf);
+void append_conflicts_hint(struct index_state *istate, struct strbuf *msgbuf);
 int message_is_empty(const struct strbuf *sb,
 		     enum commit_msg_cleanup_mode cleanup_mode);
 int template_untouched(const struct strbuf *sb, const char *template_file,
@@ -128,7 +131,9 @@ int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit);
 
 #define SUMMARY_INITIAL_COMMIT   (1 << 0)
 #define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
-void print_commit_summary(const char *prefix, const struct object_id *oid,
+void print_commit_summary(struct repository *repo,
+			  const char *prefix,
+			  const struct object_id *oid,
 			  unsigned int flags);
 #endif
 
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 09/22] sequencer.c: remove implicit dependency on the_repository
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (7 preceding siblings ...)
  2018-11-10  5:48 ` [PATCH v2 08/22] sequencer.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:48 ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:48 ` [PATCH v2 10/22] blame.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Note that the_hash_algo stays, even if we can easily replace it with
repo->hash_algo. My reason is I still believe tying hash_algo to a
struct repository is a wrong move. But if I'm wrong, we can always go
for another round of conversion.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/rebase--interactive.c |  11 +--
 builtin/revert.c              |   2 +-
 rebase-interactive.c          |   4 +-
 sequencer.c                   | 134 ++++++++++++++++++----------------
 sequencer.h                   |  12 +--
 5 files changed, 86 insertions(+), 77 deletions(-)

diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c
index b7ce48a1ec..d867050fd2 100644
--- a/builtin/rebase--interactive.c
+++ b/builtin/rebase--interactive.c
@@ -114,7 +114,8 @@ static int do_interactive_rebase(struct replay_opts *opts, unsigned flags,
 		error(_("could not generate todo list"));
 	else {
 		discard_cache();
-		ret = complete_action(opts, flags, shortrevisions, onto_name, onto,
+		ret = complete_action(the_repository, opts, flags,
+				      shortrevisions, onto_name, onto,
 				      head_hash, cmd, autosquash);
 	}
 
@@ -252,16 +253,16 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
 	}
 	case SHORTEN_OIDS:
 	case EXPAND_OIDS:
-		ret = transform_todos(flags);
+		ret = transform_todos(the_repository, flags);
 		break;
 	case CHECK_TODO_LIST:
-		ret = check_todo_list();
+		ret = check_todo_list(the_repository);
 		break;
 	case REARRANGE_SQUASH:
-		ret = rearrange_squash();
+		ret = rearrange_squash(the_repository);
 		break;
 	case ADD_EXEC:
-		ret = sequencer_add_exec_commands(cmd);
+		ret = sequencer_add_exec_commands(the_repository, cmd);
 		break;
 	default:
 		BUG("invalid command '%d'", command);
diff --git a/builtin/revert.c b/builtin/revert.c
index cd9f068195..1fa75b2773 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -201,7 +201,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
 	if (cmd == 'c')
 		return sequencer_continue(the_repository, opts);
 	if (cmd == 'a')
-		return sequencer_rollback(opts);
+		return sequencer_rollback(the_repository, opts);
 	return sequencer_pick_revisions(the_repository, opts);
 }
 
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 78f3263fc1..3cc19283ff 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -69,7 +69,7 @@ int edit_todo_list(unsigned flags)
 
 	strbuf_release(&buf);
 
-	transform_todos(flags | TODO_LIST_SHORTEN_IDS);
+	transform_todos(the_repository, flags | TODO_LIST_SHORTEN_IDS);
 
 	if (strbuf_read_file(&buf, todo_file, 0) < 0)
 		return error_errno(_("could not read '%s'."), todo_file);
@@ -85,7 +85,7 @@ int edit_todo_list(unsigned flags)
 	if (launch_sequence_editor(todo_file, NULL, NULL))
 		return -1;
 
-	transform_todos(flags & ~(TODO_LIST_SHORTEN_IDS));
+	transform_todos(the_repository, flags & ~(TODO_LIST_SHORTEN_IDS));
 
 	return 0;
 }
diff --git a/sequencer.c b/sequencer.c
index 6cf3f65b0c..111cb747d6 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -356,7 +356,8 @@ static void free_message(struct commit *commit, struct commit_message *msg)
 	unuse_commit_buffer(commit, msg->message);
 }
 
-static void print_advice(int show_hint, struct replay_opts *opts)
+static void print_advice(struct repository *r, int show_hint,
+			 struct replay_opts *opts)
 {
 	char *msg = getenv("GIT_CHERRY_PICK_HELP");
 
@@ -367,7 +368,7 @@ static void print_advice(int show_hint, struct replay_opts *opts)
 		 * (typically rebase --interactive) wants to take care
 		 * of the commit itself so remove CHERRY_PICK_HEAD
 		 */
-		unlink(git_path_cherry_pick_head(the_repository));
+		unlink(git_path_cherry_pick_head(r));
 		return;
 	}
 
@@ -440,9 +441,9 @@ static int read_oneliner(struct strbuf *buf,
 	return 1;
 }
 
-static struct tree *empty_tree(void)
+static struct tree *empty_tree(struct repository *r)
 {
-	return lookup_tree(the_repository, the_repository->hash_algo->empty_tree);
+	return lookup_tree(r, the_hash_algo->empty_tree);
 }
 
 static int error_dirty_index(struct index_state *istate, struct replay_opts *opts)
@@ -553,8 +554,8 @@ static int do_recursive_merge(struct repository *r,
 	o.show_rename_progress = 1;
 
 	head_tree = parse_tree_indirect(head);
-	next_tree = next ? get_commit_tree(next) : empty_tree();
-	base_tree = base ? get_commit_tree(base) : empty_tree();
+	next_tree = next ? get_commit_tree(next) : empty_tree(r);
+	base_tree = base ? get_commit_tree(base) : empty_tree(r);
 
 	for (xopt = opts->xopts; xopt != opts->xopts + opts->xopts_nr; xopt++)
 		parse_merge_opt(&o, *xopt);
@@ -600,15 +601,16 @@ static struct object_id *get_cache_tree_oid(struct index_state *istate)
 	return &istate->cache_tree->oid;
 }
 
-static int is_index_unchanged(struct index_state *istate)
+static int is_index_unchanged(struct repository *r)
 {
 	struct object_id head_oid, *cache_tree_oid;
 	struct commit *head_commit;
+	struct index_state *istate = r->index;
 
 	if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
 		return error(_("could not resolve HEAD commit"));
 
-	head_commit = lookup_commit(the_repository, &head_oid);
+	head_commit = lookup_commit(r, &head_oid);
 
 	/*
 	 * If head_commit is NULL, check_commit, called from
@@ -1225,7 +1227,7 @@ void print_commit_summary(struct repository *r,
 	strbuf_release(&format);
 }
 
-static int parse_head(struct commit **head)
+static int parse_head(struct repository *r, struct commit **head)
 {
 	struct commit *current_head;
 	struct object_id oid;
@@ -1233,7 +1235,7 @@ static int parse_head(struct commit **head)
 	if (get_oid("HEAD", &oid)) {
 		current_head = NULL;
 	} else {
-		current_head = lookup_commit_reference(the_repository, &oid);
+		current_head = lookup_commit_reference(r, &oid);
 		if (!current_head)
 			return error(_("could not parse HEAD"));
 		if (!oideq(&oid, &current_head->object.oid)) {
@@ -1273,7 +1275,7 @@ static int try_to_commit(struct repository *r,
 	enum commit_msg_cleanup_mode cleanup;
 	int res = 0;
 
-	if (parse_head(&current_head))
+	if (parse_head(r, &current_head))
 		return -1;
 
 	if (flags & AMEND_MSG) {
@@ -1440,7 +1442,7 @@ static int allow_empty(struct repository *r,
 	if (!opts->allow_empty)
 		return 0; /* let "git commit" barf as necessary */
 
-	index_unchanged = is_index_unchanged(r->index);
+	index_unchanged = is_index_unchanged(r);
 	if (index_unchanged < 0)
 		return index_unchanged;
 	if (!index_unchanged)
@@ -1544,8 +1546,10 @@ static int is_pick_or_similar(enum todo_command command)
 	}
 }
 
-static int update_squash_messages(enum todo_command command,
-		struct commit *commit, struct replay_opts *opts)
+static int update_squash_messages(struct repository *r,
+				  enum todo_command command,
+				  struct commit *commit,
+				  struct replay_opts *opts)
 {
 	struct strbuf buf = STRBUF_INIT;
 	int res;
@@ -1574,7 +1578,7 @@ static int update_squash_messages(enum todo_command command,
 
 		if (get_oid("HEAD", &head))
 			return error(_("need a HEAD to fixup"));
-		if (!(head_commit = lookup_commit_reference(the_repository, &head)))
+		if (!(head_commit = lookup_commit_reference(r, &head)))
 			return error(_("could not read HEAD"));
 		if (!(head_message = get_commit_buffer(head_commit, NULL)))
 			return error(_("could not read HEAD's commit message"));
@@ -1813,7 +1817,7 @@ static int do_pick_commit(struct repository *r,
 	if (command == TODO_REWORD)
 		flags |= EDIT_MSG | VERIFY_MSG;
 	else if (is_fixup(command)) {
-		if (update_squash_messages(command, commit, opts))
+		if (update_squash_messages(r, command, commit, opts))
 			return -1;
 		flags |= AMEND_MSG;
 		if (!final_fixup)
@@ -1883,7 +1887,7 @@ static int do_pick_commit(struct repository *r,
 		      ? _("could not revert %s... %s")
 		      : _("could not apply %s... %s"),
 		      short_commit_name(commit), msg.subject);
-		print_advice(res == 1, opts);
+		print_advice(r, res == 1, opts);
 		repo_rerere(r, opts->allow_rerere_auto);
 		goto leave;
 	}
@@ -1990,7 +1994,8 @@ static struct todo_item *append_new_todo(struct todo_list *todo_list)
 	return todo_list->items + todo_list->nr++;
 }
 
-static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
+static int parse_insn_line(struct repository *r, struct todo_item *item,
+			   const char *bol, char *eol)
 {
 	struct object_id commit_oid;
 	char *end_of_object_name;
@@ -2075,11 +2080,12 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
 	if (status < 0)
 		return -1;
 
-	item->commit = lookup_commit_reference(the_repository, &commit_oid);
+	item->commit = lookup_commit_reference(r, &commit_oid);
 	return !item->commit;
 }
 
-static int parse_insn_buffer(char *buf, struct todo_list *todo_list)
+static int parse_insn_buffer(struct repository *r, char *buf,
+			     struct todo_list *todo_list)
 {
 	struct todo_item *item;
 	char *p = buf, *next_p;
@@ -2095,7 +2101,7 @@ static int parse_insn_buffer(char *buf, struct todo_list *todo_list)
 
 		item = append_new_todo(todo_list);
 		item->offset_in_buf = p - todo_list->buf.buf;
-		if (parse_insn_line(item, p, eol)) {
+		if (parse_insn_line(r, item, p, eol)) {
 			res = error(_("invalid line %d: %.*s"),
 				i, (int)(eol - p), p);
 			item->command = TODO_NOOP;
@@ -2156,8 +2162,9 @@ static ssize_t strbuf_read_file_or_whine(struct strbuf *sb, const char *path)
 	return len;
 }
 
-static int read_populate_todo(struct todo_list *todo_list,
-			struct replay_opts *opts)
+static int read_populate_todo(struct repository *r,
+			      struct todo_list *todo_list,
+			      struct replay_opts *opts)
 {
 	struct stat st;
 	const char *todo_file = get_todo_path(opts);
@@ -2172,7 +2179,7 @@ static int read_populate_todo(struct todo_list *todo_list,
 		return error(_("could not stat '%s'"), todo_file);
 	fill_stat_data(&todo_list->stat, &st);
 
-	res = parse_insn_buffer(todo_list->buf.buf, todo_list);
+	res = parse_insn_buffer(r, todo_list->buf.buf, todo_list);
 	if (res) {
 		if (is_rebase_i(opts))
 			return error(_("please fix this using "
@@ -2203,7 +2210,7 @@ static int read_populate_todo(struct todo_list *todo_list,
 		FILE *f = fopen_or_warn(rebase_path_msgtotal(), "w");
 
 		if (strbuf_read_file(&done.buf, rebase_path_done(), 0) > 0 &&
-				!parse_insn_buffer(done.buf.buf, &done))
+		    !parse_insn_buffer(r, done.buf.buf, &done))
 			todo_list->done_nr = count_commands(&done);
 		else
 			todo_list->done_nr = 0;
@@ -2520,12 +2527,12 @@ static int reset_for_rollback(const struct object_id *oid)
 	return run_command_v_opt(argv, RUN_GIT_CMD);
 }
 
-static int rollback_single_pick(void)
+static int rollback_single_pick(struct repository *r)
 {
 	struct object_id head_oid;
 
-	if (!file_exists(git_path_cherry_pick_head(the_repository)) &&
-	    !file_exists(git_path_revert_head(the_repository)))
+	if (!file_exists(git_path_cherry_pick_head(r)) &&
+	    !file_exists(git_path_revert_head(r)))
 		return error(_("no cherry-pick or revert in progress"));
 	if (read_ref_full("HEAD", 0, &head_oid, NULL))
 		return error(_("cannot resolve HEAD"));
@@ -2534,7 +2541,7 @@ static int rollback_single_pick(void)
 	return reset_for_rollback(&head_oid);
 }
 
-int sequencer_rollback(struct replay_opts *opts)
+int sequencer_rollback(struct repository *r, struct replay_opts *opts)
 {
 	FILE *f;
 	struct object_id oid;
@@ -2548,7 +2555,7 @@ int sequencer_rollback(struct replay_opts *opts)
 		 * If CHERRY_PICK_HEAD or REVERT_HEAD indicates
 		 * a single-cherry-pick in progress, abort that.
 		 */
-		return rollback_single_pick();
+		return rollback_single_pick(r);
 	}
 	if (!f)
 		return error_errno(_("cannot open '%s'"), git_path_head_file());
@@ -3427,14 +3434,14 @@ static int checkout_onto(struct replay_opts *opts,
 	return update_ref(NULL, "ORIG_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR);
 }
 
-static int stopped_at_head(void)
+static int stopped_at_head(struct repository *r)
 {
 	struct object_id head;
 	struct commit *commit;
 	struct commit_message message;
 
 	if (get_oid("HEAD", &head) ||
-	    !(commit = lookup_commit(the_repository, &head)) ||
+	    !(commit = lookup_commit(r, &head)) ||
 	    parse_commit(commit) || get_message(commit, &message))
 		fprintf(stderr, _("Stopped at HEAD\n"));
 	else {
@@ -3495,7 +3502,7 @@ static int pick_commits(struct repository *r,
 			delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
 
 			if (item->command == TODO_BREAK)
-				return stopped_at_head();
+				return stopped_at_head(r);
 		}
 		if (item->command <= TODO_SQUASH) {
 			if (is_rebase_i(opts))
@@ -3572,7 +3579,7 @@ static int pick_commits(struct repository *r,
 						  get_todo_path(opts));
 			else if (match_stat_data(&todo_list->stat, &st)) {
 				todo_list_release(todo_list);
-				if (read_populate_todo(todo_list, opts))
+				if (read_populate_todo(r, todo_list, opts))
 					res = -1; /* message was printed */
 				/* `current` will be incremented below */
 				todo_list->current = -1;
@@ -3732,12 +3739,12 @@ static int pick_commits(struct repository *r,
 	return sequencer_remove_state(opts);
 }
 
-static int continue_single_pick(void)
+static int continue_single_pick(struct repository *r)
 {
 	const char *argv[] = { "commit", NULL };
 
-	if (!file_exists(git_path_cherry_pick_head(the_repository)) &&
-	    !file_exists(git_path_revert_head(the_repository)))
+	if (!file_exists(git_path_cherry_pick_head(r)) &&
+	    !file_exists(git_path_revert_head(r)))
 		return error(_("no cherry-pick or revert in progress"));
 	return run_command_v_opt(argv, RUN_GIT_CMD);
 }
@@ -3836,7 +3843,7 @@ static int commit_staged_changes(struct repository *r,
 				struct commit *commit;
 				const char *path = rebase_path_squash_msg();
 
-				if (parse_head(&commit) ||
+				if (parse_head(r, &commit) ||
 				    !(p = get_commit_buffer(commit, NULL)) ||
 				    write_message(p, strlen(p), path, 0)) {
 					unuse_commit_buffer(commit, p);
@@ -3891,20 +3898,20 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
 	if (read_populate_opts(opts))
 		return -1;
 	if (is_rebase_i(opts)) {
-		if ((res = read_populate_todo(&todo_list, opts)))
+		if ((res = read_populate_todo(r, &todo_list, opts)))
 			goto release_todo_list;
 		if (commit_staged_changes(r, opts, &todo_list))
 			return -1;
 	} else if (!file_exists(get_todo_path(opts)))
-		return continue_single_pick();
-	else if ((res = read_populate_todo(&todo_list, opts)))
+		return continue_single_pick(r);
+	else if ((res = read_populate_todo(r, &todo_list, opts)))
 		goto release_todo_list;
 
 	if (!is_rebase_i(opts)) {
 		/* Verify that the conflict has been resolved */
 		if (file_exists(git_path_cherry_pick_head(r)) ||
 		    file_exists(git_path_revert_head(r))) {
-			res = continue_single_pick();
+			res = continue_single_pick(r);
 			if (res)
 				goto release_todo_list;
 		}
@@ -4477,7 +4484,8 @@ int sequencer_make_script(struct repository *r, FILE *out,
  * Add commands after pick and (series of) squash/fixup commands
  * in the todo list.
  */
-int sequencer_add_exec_commands(const char *commands)
+int sequencer_add_exec_commands(struct repository *r,
+				const char *commands)
 {
 	const char *todo_file = rebase_path_todo();
 	struct todo_list todo_list = TODO_LIST_INIT;
@@ -4488,7 +4496,7 @@ int sequencer_add_exec_commands(const char *commands)
 	if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0)
 		return error(_("could not read '%s'."), todo_file);
 
-	if (parse_insn_buffer(todo_list.buf.buf, &todo_list)) {
+	if (parse_insn_buffer(r, todo_list.buf.buf, &todo_list)) {
 		todo_list_release(&todo_list);
 		return error(_("unusable todo list: '%s'"), todo_file);
 	}
@@ -4533,7 +4541,7 @@ int sequencer_add_exec_commands(const char *commands)
 	return i;
 }
 
-int transform_todos(unsigned flags)
+int transform_todos(struct repository *r, unsigned flags)
 {
 	const char *todo_file = rebase_path_todo();
 	struct todo_list todo_list = TODO_LIST_INIT;
@@ -4544,7 +4552,7 @@ int transform_todos(unsigned flags)
 	if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0)
 		return error(_("could not read '%s'."), todo_file);
 
-	if (parse_insn_buffer(todo_list.buf.buf, &todo_list)) {
+	if (parse_insn_buffer(r, todo_list.buf.buf, &todo_list)) {
 		todo_list_release(&todo_list);
 		return error(_("unusable todo list: '%s'"), todo_file);
 	}
@@ -4613,7 +4621,7 @@ define_commit_slab(commit_seen, unsigned char);
  * Check if there is an unrecognized command or a
  * bad SHA-1 in a command.
  */
-int check_todo_list(void)
+int check_todo_list(struct repository *r)
 {
 	enum missing_commit_check_level check_level = get_missing_commit_check_level();
 	struct strbuf todo_file = STRBUF_INIT;
@@ -4630,7 +4638,7 @@ int check_todo_list(void)
 		goto leave_check;
 	}
 	advise_to_edit_todo = res =
-		parse_insn_buffer(todo_list.buf.buf, &todo_list);
+		parse_insn_buffer(r, todo_list.buf.buf, &todo_list);
 
 	if (res || check_level == MISSING_COMMIT_CHECK_IGNORE)
 		goto leave_check;
@@ -4649,7 +4657,7 @@ int check_todo_list(void)
 		goto leave_check;
 	}
 	strbuf_release(&todo_file);
-	res = !!parse_insn_buffer(todo_list.buf.buf, &todo_list);
+	res = !!parse_insn_buffer(r, todo_list.buf.buf, &todo_list);
 
 	/* Find commits in git-rebase-todo.backup yet unseen */
 	for (i = todo_list.nr - 1; i >= 0; i--) {
@@ -4713,7 +4721,7 @@ static int rewrite_file(const char *path, const char *buf, size_t len)
 }
 
 /* skip picking commits whose parents are unchanged */
-static int skip_unnecessary_picks(struct object_id *output_oid)
+static int skip_unnecessary_picks(struct repository *r, struct object_id *output_oid)
 {
 	const char *todo_file = rebase_path_todo();
 	struct strbuf buf = STRBUF_INIT;
@@ -4731,7 +4739,7 @@ static int skip_unnecessary_picks(struct object_id *output_oid)
 
 	if (strbuf_read_file_or_whine(&todo_list.buf, todo_file) < 0)
 		return -1;
-	if (parse_insn_buffer(todo_list.buf.buf, &todo_list) < 0) {
+	if (parse_insn_buffer(r, todo_list.buf.buf, &todo_list) < 0) {
 		todo_list_release(&todo_list);
 		return -1;
 	}
@@ -4792,7 +4800,7 @@ static int skip_unnecessary_picks(struct object_id *output_oid)
 	return 0;
 }
 
-int complete_action(struct replay_opts *opts, unsigned flags,
+int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
 		    const char *shortrevisions, const char *onto_name,
 		    const char *onto, const char *orig_head, const char *cmd,
 		    unsigned autosquash)
@@ -4810,16 +4818,16 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 	    write_message("noop\n", 5, todo_file, 0))
 		return -1;
 
-	if (autosquash && rearrange_squash())
+	if (autosquash && rearrange_squash(r))
 		return -1;
 
 	if (cmd && *cmd)
-		sequencer_add_exec_commands(cmd);
+		sequencer_add_exec_commands(r, cmd);
 
 	if (strbuf_read_file(buf, todo_file, 0) < 0)
 		return error_errno(_("could not read '%s'."), todo_file);
 
-	if (parse_insn_buffer(buf->buf, &todo_list)) {
+	if (parse_insn_buffer(r, buf->buf, &todo_list)) {
 		todo_list_release(&todo_list);
 		return error(_("unusable todo list: '%s'"), todo_file);
 	}
@@ -4848,7 +4856,7 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 		return error(_("could not copy '%s' to '%s'."), todo_file,
 			     rebase_path_todo_backup());
 
-	if (transform_todos(flags | TODO_LIST_SHORTEN_IDS))
+	if (transform_todos(r, flags | TODO_LIST_SHORTEN_IDS))
 		return error(_("could not transform the todo list"));
 
 	strbuf_reset(buf);
@@ -4872,24 +4880,24 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 
 	todo_list_release(&todo_list);
 
-	if (check_todo_list()) {
+	if (check_todo_list(r)) {
 		checkout_onto(opts, onto_name, onto, orig_head);
 		return -1;
 	}
 
-	if (transform_todos(flags & ~(TODO_LIST_SHORTEN_IDS)))
+	if (transform_todos(r, flags & ~(TODO_LIST_SHORTEN_IDS)))
 		return error(_("could not transform the todo list"));
 
-	if (opts->allow_ff && skip_unnecessary_picks(&oid))
+	if (opts->allow_ff && skip_unnecessary_picks(r, &oid))
 		return error(_("could not skip unnecessary pick commands"));
 
 	if (checkout_onto(opts, onto_name, oid_to_hex(&oid), orig_head))
 		return -1;
 ;
-	if (require_clean_work_tree(the_repository, "rebase", "", 1, 1))
+	if (require_clean_work_tree(r, "rebase", "", 1, 1))
 		return -1;
 
-	return sequencer_continue(the_repository, opts);
+	return sequencer_continue(r, opts);
 }
 
 struct subject2item_entry {
@@ -4916,7 +4924,7 @@ define_commit_slab(commit_todo_item, struct todo_item *);
  * message will have to be retrieved from the commit (as the oneline in the
  * script cannot be trusted) in order to normalize the autosquash arrangement.
  */
-int rearrange_squash(void)
+int rearrange_squash(struct repository *r)
 {
 	const char *todo_file = rebase_path_todo();
 	struct todo_list todo_list = TODO_LIST_INIT;
@@ -4927,7 +4935,7 @@ int rearrange_squash(void)
 
 	if (strbuf_read_file_or_whine(&todo_list.buf, todo_file) < 0)
 		return -1;
-	if (parse_insn_buffer(todo_list.buf.buf, &todo_list) < 0) {
+	if (parse_insn_buffer(r, todo_list.buf.buf, &todo_list) < 0) {
 		todo_list_release(&todo_list);
 		return -1;
 	}
diff --git a/sequencer.h b/sequencer.h
index ba86515ad6..d2c18edd3a 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -78,7 +78,7 @@ void sequencer_init_config(struct replay_opts *opts);
 int sequencer_pick_revisions(struct repository *repo,
 			     struct replay_opts *opts);
 int sequencer_continue(struct repository *repo, struct replay_opts *opts);
-int sequencer_rollback(struct replay_opts *opts);
+int sequencer_rollback(struct repository *repo, struct replay_opts *opts);
 int sequencer_remove_state(struct replay_opts *opts);
 
 #define TODO_LIST_KEEP_EMPTY (1U << 0)
@@ -95,15 +95,15 @@ int sequencer_make_script(struct repository *repo, FILE *out,
 			  int argc, const char **argv,
 			  unsigned flags);
 
-int sequencer_add_exec_commands(const char *command);
-int transform_todos(unsigned flags);
+int sequencer_add_exec_commands(struct repository *r, const char *command);
+int transform_todos(struct repository *r, unsigned flags);
 enum missing_commit_check_level get_missing_commit_check_level(void);
-int check_todo_list(void);
-int complete_action(struct replay_opts *opts, unsigned flags,
+int check_todo_list(struct repository *r);
+int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
 		    const char *shortrevisions, const char *onto_name,
 		    const char *onto, const char *orig_head, const char *cmd,
 		    unsigned autosquash);
-int rearrange_squash(void);
+int rearrange_squash(struct repository *r);
 
 extern const char sign_off_header[];
 
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 10/22] blame.c: remove implicit dependency the_repository
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (8 preceding siblings ...)
  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
  2018-11-10  5:48 ` [PATCH v2 11/22] bisect.c: remove the_repository reference Nguyễn Thái Ngọc Duy
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

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


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 11/22] bisect.c: remove the_repository reference
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (9 preceding siblings ...)
  2018-11-10  5:48 ` [PATCH v2 10/22] blame.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:48 ` 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
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:48 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 bisect.c                 | 48 +++++++++++++++++++++++-----------------
 bisect.h                 |  5 ++++-
 builtin/bisect--helper.c |  2 +-
 3 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/bisect.c b/bisect.c
index 487675c672..4c1b80bff6 100644
--- a/bisect.c
+++ b/bisect.c
@@ -626,14 +626,15 @@ static struct commit_list *managed_skipped(struct commit_list *list,
 	return skip_away(list, count);
 }
 
-static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
+static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
+			     const char *prefix,
 			     const char *bad_format, const char *good_format,
 			     int read_paths)
 {
 	struct argv_array rev_argv = ARGV_ARRAY_INIT;
 	int i;
 
-	repo_init_revisions(the_repository, revs, prefix);
+	repo_init_revisions(r, revs, prefix);
 	revs->abbrev = 0;
 	revs->commit_format = CMIT_FMT_UNSPECIFIED;
 
@@ -723,23 +724,25 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
 	return run_command_v_opt(argv_show_branch, RUN_GIT_CMD);
 }
 
-static struct commit *get_commit_reference(const struct object_id *oid)
+static struct commit *get_commit_reference(struct repository *r,
+					   const struct object_id *oid)
 {
-	struct commit *r = lookup_commit_reference(the_repository, oid);
-	if (!r)
+	struct commit *c = lookup_commit_reference(r, oid);
+	if (!c)
 		die(_("Not a valid commit name %s"), oid_to_hex(oid));
-	return r;
+	return c;
 }
 
-static struct commit **get_bad_and_good_commits(int *rev_nr)
+static struct commit **get_bad_and_good_commits(struct repository *r,
+						int *rev_nr)
 {
 	struct commit **rev;
 	int i, n = 0;
 
 	ALLOC_ARRAY(rev, 1 + good_revs.nr);
-	rev[n++] = get_commit_reference(current_bad_oid);
+	rev[n++] = get_commit_reference(r, current_bad_oid);
 	for (i = 0; i < good_revs.nr; i++)
-		rev[n++] = get_commit_reference(good_revs.oid + i);
+		rev[n++] = get_commit_reference(r, good_revs.oid + i);
 	*rev_nr = n;
 
 	return rev;
@@ -823,12 +826,13 @@ static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout)
 	free_commit_list(result);
 }
 
-static int check_ancestors(int rev_nr, struct commit **rev, const char *prefix)
+static int check_ancestors(struct repository *r, int rev_nr,
+			   struct commit **rev, const char *prefix)
 {
 	struct rev_info revs;
 	int res;
 
-	bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
+	bisect_rev_setup(r, &revs, prefix, "^%s", "%s", 0);
 
 	bisect_common(&revs);
 	res = (revs.commits != NULL);
@@ -847,7 +851,9 @@ static int check_ancestors(int rev_nr, struct commit **rev, const char *prefix)
  * If a merge base must be tested by the user, its source code will be
  * checked out to be tested by the user and we will exit.
  */
-static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
+static void check_good_are_ancestors_of_bad(struct repository *r,
+					    const char *prefix,
+					    int no_checkout)
 {
 	char *filename = git_pathdup("BISECT_ANCESTORS_OK");
 	struct stat st;
@@ -866,8 +872,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
 		goto done;
 
 	/* Check if all good revs are ancestor of the bad rev. */
-	rev = get_bad_and_good_commits(&rev_nr);
-	if (check_ancestors(rev_nr, rev, prefix))
+	rev = get_bad_and_good_commits(r, &rev_nr);
+	if (check_ancestors(r, rev_nr, rev, prefix))
 		check_merge_bases(rev_nr, rev, no_checkout);
 	free(rev);
 
@@ -885,12 +891,14 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
 /*
  * This does "git diff-tree --pretty COMMIT" without one fork+exec.
  */
-static void show_diff_tree(const char *prefix, struct commit *commit)
+static void show_diff_tree(struct repository *r,
+			   const char *prefix,
+			   struct commit *commit)
 {
 	struct rev_info opt;
 
 	/* diff-tree init */
-	repo_init_revisions(the_repository, &opt, prefix);
+	repo_init_revisions(r, &opt, prefix);
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 	opt.abbrev = 0;
 	opt.diff = 1;
@@ -945,7 +953,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
  * If no_checkout is non-zero, the bisection process does not
  * checkout the trial commit but instead simply updates BISECT_HEAD.
  */
-int bisect_next_all(const char *prefix, int no_checkout)
+int bisect_next_all(struct repository *r, const char *prefix, int no_checkout)
 {
 	struct rev_info revs;
 	struct commit_list *tried;
@@ -957,9 +965,9 @@ int bisect_next_all(const char *prefix, int no_checkout)
 	if (read_bisect_refs())
 		die(_("reading bisect refs failed"));
 
-	check_good_are_ancestors_of_bad(prefix, no_checkout);
+	check_good_are_ancestors_of_bad(r, prefix, no_checkout);
 
-	bisect_rev_setup(&revs, prefix, "%s", "^%s", 1);
+	bisect_rev_setup(r, &revs, prefix, "%s", "^%s", 1);
 	revs.limited = 1;
 
 	bisect_common(&revs);
@@ -993,7 +1001,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
 		exit_if_skipped_commits(tried, current_bad_oid);
 		printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
 			term_bad);
-		show_diff_tree(prefix, revs.commits->item);
+		show_diff_tree(r, prefix, revs.commits->item);
 		/* This means the bisection process succeeded. */
 		exit(10);
 	}
diff --git a/bisect.h b/bisect.h
index 34df209351..821d16e4dd 100644
--- a/bisect.h
+++ b/bisect.h
@@ -2,6 +2,7 @@
 #define BISECT_H
 
 struct commit_list;
+struct repository;
 
 /*
  * Find bisection. If something is found, `reaches` will be the number of
@@ -30,7 +31,9 @@ struct rev_list_info {
 	const char *header_prefix;
 };
 
-extern int bisect_next_all(const char *prefix, int no_checkout);
+extern int bisect_next_all(struct repository *r,
+			   const char *prefix,
+			   int no_checkout);
 
 extern int estimate_bisect_steps(int all);
 
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 4b5fadcbe1..417d141c09 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -137,7 +137,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 
 	switch (cmdmode) {
 	case NEXT_ALL:
-		return bisect_next_all(prefix, no_checkout);
+		return bisect_next_all(the_repository, prefix, no_checkout);
 	case WRITE_TERMS:
 		if (argc != 2)
 			return error(_("--write-terms requires two arguments"));
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 12/22] branch.c: remove the_repository reference
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (10 preceding siblings ...)
  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 ` 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
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 branch.c           | 21 +++++++++++----------
 branch.h           |  8 ++++++--
 builtin/am.c       |  2 +-
 builtin/branch.c   |  6 ++++--
 builtin/checkout.c |  5 +++--
 builtin/reset.c    |  2 +-
 builtin/revert.c   |  2 +-
 7 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/branch.c b/branch.c
index 776f55fc66..28b81a7e02 100644
--- a/branch.c
+++ b/branch.c
@@ -242,7 +242,8 @@ N_("\n"
 "will track its remote counterpart, you may want to use\n"
 "\"git push -u\" to set the upstream config as you push.");
 
-void create_branch(const char *name, const char *start_name,
+void create_branch(struct repository *r,
+		   const char *name, const char *start_name,
 		   int force, int clobber_head_ok, int reflog,
 		   int quiet, enum branch_track track)
 {
@@ -300,7 +301,7 @@ void create_branch(const char *name, const char *start_name,
 		break;
 	}
 
-	if ((commit = lookup_commit_reference(the_repository, &oid)) == NULL)
+	if ((commit = lookup_commit_reference(r, &oid)) == NULL)
 		die(_("Not a valid branch point: '%s'."), start_name);
 	oidcpy(&oid, &commit->object.oid);
 
@@ -336,15 +337,15 @@ void create_branch(const char *name, const char *start_name,
 	free(real_ref);
 }
 
-void remove_branch_state(void)
+void remove_branch_state(struct repository *r)
 {
-	unlink(git_path_cherry_pick_head(the_repository));
-	unlink(git_path_revert_head(the_repository));
-	unlink(git_path_merge_head(the_repository));
-	unlink(git_path_merge_rr(the_repository));
-	unlink(git_path_merge_msg(the_repository));
-	unlink(git_path_merge_mode(the_repository));
-	unlink(git_path_squash_msg(the_repository));
+	unlink(git_path_cherry_pick_head(r));
+	unlink(git_path_revert_head(r));
+	unlink(git_path_merge_head(r));
+	unlink(git_path_merge_rr(r));
+	unlink(git_path_merge_msg(r));
+	unlink(git_path_merge_mode(r));
+	unlink(git_path_squash_msg(r));
 }
 
 void die_if_checked_out(const char *branch, int ignore_current_worktree)
diff --git a/branch.h b/branch.h
index 5cace4581f..29c1afa4d0 100644
--- a/branch.h
+++ b/branch.h
@@ -1,6 +1,7 @@
 #ifndef BRANCH_H
 #define BRANCH_H
 
+struct repository;
 struct strbuf;
 
 enum branch_track {
@@ -19,6 +20,8 @@ extern enum branch_track git_branch_track;
 /*
  * Creates a new branch, where:
  *
+ *   - r is the repository to add a branch to
+ *
  *   - name is the new branch name
  *
  *   - start_name is the name of the existing branch that the new branch should
@@ -37,7 +40,8 @@ extern enum branch_track git_branch_track;
  *     that start_name is a tracking branch for (if any).
  *
  */
-void create_branch(const char *name, const char *start_name,
+void create_branch(struct repository *r,
+		   const char *name, const char *start_name,
 		   int force, int clobber_head_ok,
 		   int reflog, int quiet, enum branch_track track);
 
@@ -60,7 +64,7 @@ extern int validate_new_branchname(const char *name, struct strbuf *ref, int for
  * Remove information about the state of working on the current
  * branch. (E.g., MERGE_HEAD)
  */
-void remove_branch_state(void);
+void remove_branch_state(struct repository *r);
 
 /*
  * Configure local branch "local" as downstream to branch "remote"
diff --git a/builtin/am.c b/builtin/am.c
index 3ee9a9d2a9..232f3962d7 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2022,7 +2022,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
 	if (merge_tree(remote_tree))
 		return -1;
 
-	remove_branch_state();
+	remove_branch_state(the_repository);
 
 	return 0;
 }
diff --git a/builtin/branch.c b/builtin/branch.c
index 0c55f7f065..1be727209b 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -783,7 +783,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		 * create_branch takes care of setting up the tracking
 		 * info and making sure new_upstream is correct
 		 */
-		create_branch(branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);
+		create_branch(the_repository, branch->name, new_upstream,
+			      0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);
 	} else if (unset_upstream) {
 		struct branch *branch = branch_get(argv[0]);
 		struct strbuf buf = STRBUF_INIT;
@@ -814,7 +815,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		if (track == BRANCH_TRACK_OVERRIDE)
 			die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead."));
 
-		create_branch(argv[0], (argc == 2) ? argv[1] : head,
+		create_branch(the_repository,
+			      argv[0], (argc == 2) ? argv[1] : head,
 			      force, 0, reflog, quiet, track);
 
 	} else
diff --git a/builtin/checkout.c b/builtin/checkout.c
index acdafc6e4c..169e797675 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -753,7 +753,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
 			free(refname);
 		}
 		else
-			create_branch(opts->new_branch, new_branch_info->name,
+			create_branch(the_repository,
+				      opts->new_branch, new_branch_info->name,
 				      opts->new_branch_force ? 1 : 0,
 				      opts->new_branch_force ? 1 : 0,
 				      opts->new_branch_log,
@@ -811,7 +812,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
 				delete_reflog(old_branch_info->path);
 		}
 	}
-	remove_branch_state();
+	remove_branch_state(the_repository);
 	strbuf_release(&msg);
 	if (!opts->quiet &&
 	    (new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
diff --git a/builtin/reset.c b/builtin/reset.c
index 6d37a35e2e..5b4bbb0fb5 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -400,7 +400,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 			print_new_head_line(lookup_commit_reference(the_repository, &oid));
 	}
 	if (!pathspec.nr)
-		remove_branch_state();
+		remove_branch_state(the_repository);
 
 	return update_ref_status;
 }
diff --git a/builtin/revert.c b/builtin/revert.c
index 1fa75b2773..df662d4324 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -195,7 +195,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
 	if (cmd == 'q') {
 		int ret = sequencer_remove_state(opts);
 		if (!ret)
-			remove_branch_state();
+			remove_branch_state(the_repository);
 		return ret;
 	}
 	if (cmd == 'c')
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 13/22] bundle.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (11 preceding siblings ...)
  2018-11-10  5:49 ` [PATCH v2 12/22] branch.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:49 ` 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
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/bundle.c |  7 ++++---
 bundle.c         | 26 ++++++++++++++------------
 bundle.h         |  9 +++++----
 transport.c      |  2 +-
 4 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/builtin/bundle.c b/builtin/bundle.c
index d0de59b94f..9e9c65d9c6 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -40,7 +40,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
 			usage(builtin_bundle_usage);
 			return 1;
 		}
-		if (verify_bundle(&header, 1))
+		if (verify_bundle(the_repository, &header, 1))
 			return 1;
 		fprintf(stderr, _("%s is okay\n"), bundle_file);
 		return 0;
@@ -56,11 +56,12 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
 		}
 		if (!startup_info->have_repository)
 			die(_("Need a repository to create a bundle."));
-		return !!create_bundle(&header, bundle_file, argc, argv);
+		return !!create_bundle(the_repository, &header,
+				       bundle_file, argc, argv);
 	} else if (!strcmp(cmd, "unbundle")) {
 		if (!startup_info->have_repository)
 			die(_("Need a repository to unbundle."));
-		return !!unbundle(&header, bundle_fd, 0) ||
+		return !!unbundle(the_repository, &header, bundle_fd, 0) ||
 			list_bundle_refs(&header, argc, argv);
 	} else
 		usage(builtin_bundle_usage);
diff --git a/bundle.c b/bundle.c
index 1ef584b93b..b94992675a 100644
--- a/bundle.c
+++ b/bundle.c
@@ -127,7 +127,9 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)
 /* Remember to update object flag allocation in object.h */
 #define PREREQ_MARK (1u<<16)
 
-int verify_bundle(struct bundle_header *header, int verbose)
+int verify_bundle(struct repository *r,
+		  struct bundle_header *header,
+		  int verbose)
 {
 	/*
 	 * Do fast check, then if any prereqs are missing then go line by line
@@ -140,10 +142,10 @@ int verify_bundle(struct bundle_header *header, int verbose)
 	int i, ret = 0, req_nr;
 	const char *message = _("Repository lacks these prerequisite commits:");
 
-	repo_init_revisions(the_repository, &revs, NULL);
+	repo_init_revisions(r, &revs, NULL);
 	for (i = 0; i < p->nr; i++) {
 		struct ref_list_entry *e = p->list + i;
-		struct object *o = parse_object(the_repository, &e->oid);
+		struct object *o = parse_object(r, &e->oid);
 		if (o) {
 			o->flags |= PREREQ_MARK;
 			add_pending_object(&revs, o, e->name);
@@ -168,7 +170,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
 
 	for (i = 0; i < p->nr; i++) {
 		struct ref_list_entry *e = p->list + i;
-		struct object *o = parse_object(the_repository, &e->oid);
+		struct object *o = parse_object(r, &e->oid);
 		assert(o); /* otherwise we'd have returned early */
 		if (o->flags & SHOWN)
 			continue;
@@ -180,7 +182,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
 	/* Clean up objects used, as they will be reused. */
 	for (i = 0; i < p->nr; i++) {
 		struct ref_list_entry *e = p->list + i;
-		commit = lookup_commit_reference_gently(the_repository, &e->oid, 1);
+		commit = lookup_commit_reference_gently(r, &e->oid, 1);
 		if (commit)
 			clear_commit_marks(commit, ALL_REV_FLAGS);
 	}
@@ -375,8 +377,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 			 * in terms of a tag (e.g. v2.0 from the range
 			 * "v1.0..v2.0")?
 			 */
-			struct commit *one = lookup_commit_reference(the_repository,
-								     &oid);
+			struct commit *one = lookup_commit_reference(revs->repo, &oid);
 			struct object *obj;
 
 			if (e->item == &(one->object)) {
@@ -409,8 +410,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 	return ref_count;
 }
 
-int create_bundle(struct bundle_header *header, const char *path,
-		  int argc, const char **argv)
+int create_bundle(struct repository *r, struct bundle_header *header,
+		  const char *path, int argc, const char **argv)
 {
 	struct lock_file lock = LOCK_INIT;
 	int bundle_fd = -1;
@@ -441,7 +442,7 @@ int create_bundle(struct bundle_header *header, const char *path,
 
 	/* init revs to list objects for pack-objects later */
 	save_commit_buffer = 0;
-	repo_init_revisions(the_repository, &revs, NULL);
+	repo_init_revisions(r, &revs, NULL);
 
 	/* write prerequisites */
 	if (compute_and_write_prerequisites(bundle_fd, &revs, argc, argv))
@@ -482,7 +483,8 @@ int create_bundle(struct bundle_header *header, const char *path,
 	return -1;
 }
 
-int unbundle(struct bundle_header *header, int bundle_fd, int flags)
+int unbundle(struct repository *r, struct bundle_header *header,
+	     int bundle_fd, int flags)
 {
 	const char *argv_index_pack[] = {"index-pack",
 					 "--fix-thin", "--stdin", NULL, NULL};
@@ -491,7 +493,7 @@ int unbundle(struct bundle_header *header, int bundle_fd, int flags)
 	if (flags & BUNDLE_VERBOSE)
 		argv_index_pack[3] = "-v";
 
-	if (verify_bundle(header, 0))
+	if (verify_bundle(r, header, 0))
 		return -1;
 	ip.argv = argv_index_pack;
 	ip.in = bundle_fd;
diff --git a/bundle.h b/bundle.h
index e9a4cb6a74..781e6f5c3a 100644
--- a/bundle.h
+++ b/bundle.h
@@ -18,11 +18,12 @@ struct bundle_header {
 
 int is_bundle(const char *path, int quiet);
 int read_bundle_header(const char *path, struct bundle_header *header);
-int create_bundle(struct bundle_header *header, const char *path,
-		int argc, const char **argv);
-int verify_bundle(struct bundle_header *header, int verbose);
+int create_bundle(struct repository *r, struct bundle_header *header,
+		  const char *path, int argc, const char **argv);
+int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
 #define BUNDLE_VERBOSE 1
-int unbundle(struct bundle_header *header, int bundle_fd, int flags);
+int unbundle(struct repository *r, struct bundle_header *header,
+	     int bundle_fd, int flags);
 int list_bundle_refs(struct bundle_header *header,
 		int argc, const char **argv);
 
diff --git a/transport.c b/transport.c
index 71f663743f..f6e54f6412 100644
--- a/transport.c
+++ b/transport.c
@@ -154,7 +154,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
 			       int nr_heads, struct ref **to_fetch)
 {
 	struct bundle_transport_data *data = transport->data;
-	return unbundle(&data->header, data->fd,
+	return unbundle(the_repository, &data->header, data->fd,
 			transport->progress ? BUNDLE_VERBOSE : 0);
 }
 
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 14/22] cache-tree.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (12 preceding siblings ...)
  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 ` 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
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

This case is more interesting than other boring "remove the_repo"
commits because while we need access to the object database, we cannot
simply use r->index because unpack-trees.c can operate on a temporary
index, not $GIT_DIR/index. Ideally we should be able to pass an object
database to lookup_tree() but that ship has sailed.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/read-tree.c |  4 +++-
 builtin/rebase.c    |  2 +-
 builtin/reset.c     |  2 +-
 cache-tree.c        | 26 +++++++++++++++-----------
 cache-tree.h        |  4 ++--
 read-cache.c        |  2 +-
 sequencer.c         |  2 +-
 unpack-trees.c      |  2 +-
 8 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index fbbc98e516..c05c12d034 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -255,7 +255,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 	 * what came from the tree.
 	 */
 	if (nr_trees == 1 && !opts.prefix)
-		prime_cache_tree(&the_index, trees[0]);
+		prime_cache_tree(the_repository,
+				 the_repository->index,
+				 trees[0]);
 
 	if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
 		die("unable to write new index file");
diff --git a/builtin/rebase.c b/builtin/rebase.c
index b9eb958454..d9bedecf86 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -582,7 +582,7 @@ static int reset_head(struct object_id *oid, const char *action,
 	}
 
 	tree = parse_tree_indirect(oid);
-	prime_cache_tree(the_repository->index, tree);
+	prime_cache_tree(the_repository, the_repository->index, tree);
 
 	if (write_locked_index(the_repository->index, &lock, COMMIT_LOCK) < 0)
 		ret = error(_("could not write index"));
diff --git a/builtin/reset.c b/builtin/reset.c
index 5b4bbb0fb5..161b5e0cae 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -93,7 +93,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)
 
 	if (reset_type == MIXED || reset_type == HARD) {
 		tree = parse_tree_indirect(oid);
-		prime_cache_tree(&the_index, tree);
+		prime_cache_tree(the_repository, the_repository->index, tree);
 	}
 
 	ret = 0;
diff --git a/cache-tree.c b/cache-tree.c
index 9d454d24bc..190c6e5aa6 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -659,7 +659,9 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
 	return ret;
 }
 
-static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
+static void prime_cache_tree_rec(struct repository *r,
+				 struct cache_tree *it,
+				 struct tree *tree)
 {
 	struct tree_desc desc;
 	struct name_entry entry;
@@ -673,24 +675,25 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
 			cnt++;
 		else {
 			struct cache_tree_sub *sub;
-			struct tree *subtree = lookup_tree(the_repository,
-							   entry.oid);
+			struct tree *subtree = lookup_tree(r, entry.oid);
 			if (!subtree->object.parsed)
 				parse_tree(subtree);
 			sub = cache_tree_sub(it, entry.path);
 			sub->cache_tree = cache_tree();
-			prime_cache_tree_rec(sub->cache_tree, subtree);
+			prime_cache_tree_rec(r, sub->cache_tree, subtree);
 			cnt += sub->cache_tree->entry_count;
 		}
 	}
 	it->entry_count = cnt;
 }
 
-void prime_cache_tree(struct index_state *istate, struct tree *tree)
+void prime_cache_tree(struct repository *r,
+		      struct index_state *istate,
+		      struct tree *tree)
 {
 	cache_tree_free(&istate->cache_tree);
 	istate->cache_tree = cache_tree();
-	prime_cache_tree_rec(istate->cache_tree, tree);
+	prime_cache_tree_rec(r, istate->cache_tree, tree);
 	istate->cache_changed |= CACHE_TREE_CHANGED;
 }
 
@@ -726,7 +729,8 @@ int cache_tree_matches_traversal(struct cache_tree *root,
 	return 0;
 }
 
-static void verify_one(struct index_state *istate,
+static void verify_one(struct repository *r,
+		       struct index_state *istate,
 		       struct cache_tree *it,
 		       struct strbuf *path)
 {
@@ -736,13 +740,13 @@ static void verify_one(struct index_state *istate,
 
 	for (i = 0; i < it->subtree_nr; i++) {
 		strbuf_addf(path, "%s/", it->down[i]->name);
-		verify_one(istate, it->down[i]->cache_tree, path);
+		verify_one(r, istate, it->down[i]->cache_tree, path);
 		strbuf_setlen(path, len);
 	}
 
 	if (it->entry_count < 0 ||
 	    /* no verification on tests (t7003) that replace trees */
-	    lookup_replace_object(the_repository, &it->oid) != &it->oid)
+	    lookup_replace_object(r, &it->oid) != &it->oid)
 		return;
 
 	if (path->len) {
@@ -793,12 +797,12 @@ static void verify_one(struct index_state *istate,
 	strbuf_release(&tree_buf);
 }
 
-void cache_tree_verify(struct index_state *istate)
+void cache_tree_verify(struct repository *r, struct index_state *istate)
 {
 	struct strbuf path = STRBUF_INIT;
 
 	if (!istate->cache_tree)
 		return;
-	verify_one(istate, istate->cache_tree, &path);
+	verify_one(r, istate, istate->cache_tree, &path);
 	strbuf_release(&path);
 }
diff --git a/cache-tree.h b/cache-tree.h
index 0ab6784ffe..326209198b 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -32,7 +32,7 @@ struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
 
 int cache_tree_fully_valid(struct cache_tree *);
 int cache_tree_update(struct index_state *, int);
-void cache_tree_verify(struct index_state *);
+void cache_tree_verify(struct repository *, struct index_state *);
 
 /* bitmasks to write_cache_as_tree flags */
 #define WRITE_TREE_MISSING_OK 1
@@ -47,7 +47,7 @@ void cache_tree_verify(struct index_state *);
 #define WRITE_TREE_PREFIX_ERROR (-3)
 
 int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix);
-void prime_cache_tree(struct index_state *, struct tree *);
+void prime_cache_tree(struct repository *, struct index_state *, struct tree *);
 
 int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info);
 
diff --git a/read-cache.c b/read-cache.c
index f3a848d61c..69944fc933 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3126,7 +3126,7 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
 	struct split_index *si = istate->split_index;
 
 	if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
-		cache_tree_verify(istate);
+		cache_tree_verify(the_repository, istate);
 
 	if ((flags & SKIP_IF_UNCHANGED) && !istate->cache_changed) {
 		if (flags & COMMIT_LOCK)
diff --git a/sequencer.c b/sequencer.c
index 111cb747d6..726f727644 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2991,7 +2991,7 @@ static int do_reset(struct repository *r,
 	}
 
 	tree = parse_tree_indirect(&oid);
-	prime_cache_tree(r->index, tree);
+	prime_cache_tree(r, r->index, tree);
 
 	if (write_locked_index(r->index, &lock, COMMIT_LOCK) < 0)
 		ret = error(_("could not write index"));
diff --git a/unpack-trees.c b/unpack-trees.c
index 7570df481b..6d53cbfc86 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1630,7 +1630,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
 		move_index_extensions(&o->result, o->src_index);
 		if (!ret) {
 			if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
-				cache_tree_verify(&o->result);
+				cache_tree_verify(the_repository, &o->result);
 			if (!o->result.cache_tree)
 				o->result.cache_tree = cache_tree();
 			if (!cache_tree_fully_valid(o->result.cache_tree))
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 15/22] delta-islands.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (13 preceding siblings ...)
  2018-11-10  5:49 ` [PATCH v2 14/22] cache-tree.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:49 ` 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
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/pack-objects.c |  4 ++--
 delta-islands.c        | 24 ++++++++++++++----------
 delta-islands.h        |  9 ++++++---
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index c99ee79c31..7812c2b1f3 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2628,7 +2628,7 @@ static void prepare_pack(int window, int depth)
 	unsigned n;
 
 	if (use_delta_islands)
-		resolve_tree_islands(progress, &to_pack);
+		resolve_tree_islands(the_repository, progress, &to_pack);
 
 	get_object_details();
 
@@ -3143,7 +3143,7 @@ static void get_object_list(int ac, const char **av)
 		return;
 
 	if (use_delta_islands)
-		load_delta_islands();
+		load_delta_islands(the_repository);
 
 	if (prepare_revision_walk(&revs))
 		die(_("revision walk setup failed"));
diff --git a/delta-islands.c b/delta-islands.c
index 8e5018e406..191a930705 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -190,13 +190,15 @@ static void set_island_marks(struct object *obj, struct island_bitmap *marks)
 	island_bitmap_or(b, marks);
 }
 
-static void mark_remote_island_1(struct remote_island *rl, int is_core_island)
+static void mark_remote_island_1(struct repository *r,
+				 struct remote_island *rl,
+				 int is_core_island)
 {
 	uint32_t i;
 
 	for (i = 0; i < rl->oids.nr; ++i) {
 		struct island_bitmap *marks;
-		struct object *obj = parse_object(the_repository, &rl->oids.oid[i]);
+		struct object *obj = parse_object(r, &rl->oids.oid[i]);
 
 		if (!obj)
 			continue;
@@ -211,7 +213,7 @@ static void mark_remote_island_1(struct remote_island *rl, int is_core_island)
 		while (obj && obj->type == OBJ_TAG) {
 			obj = ((struct tag *)obj)->tagged;
 			if (obj) {
-				parse_object(the_repository, &obj->oid);
+				parse_object(r, &obj->oid);
 				marks = create_or_get_island_marks(obj);
 				island_bitmap_set(marks, island_counter);
 			}
@@ -237,7 +239,9 @@ static int tree_depth_compare(const void *a, const void *b)
 	return todo_a->depth - todo_b->depth;
 }
 
-void resolve_tree_islands(int progress, struct packing_data *to_pack)
+void resolve_tree_islands(struct repository *r,
+			  int progress,
+			  struct packing_data *to_pack)
 {
 	struct progress *progress_state = NULL;
 	struct tree_islands_todo *todo;
@@ -281,7 +285,7 @@ void resolve_tree_islands(int progress, struct packing_data *to_pack)
 
 		root_marks = kh_value(island_marks, pos);
 
-		tree = lookup_tree(the_repository, &ent->idx.oid);
+		tree = lookup_tree(r, &ent->idx.oid);
 		if (!tree || parse_tree(tree) < 0)
 			die(_("bad tree object %s"), oid_to_hex(&ent->idx.oid));
 
@@ -292,7 +296,7 @@ void resolve_tree_islands(int progress, struct packing_data *to_pack)
 			if (S_ISGITLINK(entry.mode))
 				continue;
 
-			obj = lookup_object(the_repository, entry.oid->hash);
+			obj = lookup_object(r, entry.oid->hash);
 			if (!obj)
 				continue;
 
@@ -415,7 +419,7 @@ static struct remote_island *get_core_island(void)
 	return NULL;
 }
 
-static void deduplicate_islands(void)
+static void deduplicate_islands(struct repository *r)
 {
 	struct remote_island *island, *core = NULL, **list;
 	unsigned int island_count, dst, src, ref, i = 0;
@@ -444,20 +448,20 @@ static void deduplicate_islands(void)
 	core = get_core_island();
 
 	for (i = 0; i < island_count; ++i) {
-		mark_remote_island_1(list[i], core && list[i]->hash == core->hash);
+		mark_remote_island_1(r, list[i], core && list[i]->hash == core->hash);
 	}
 
 	free(list);
 }
 
-void load_delta_islands(void)
+void load_delta_islands(struct repository *r)
 {
 	island_marks = kh_init_sha1();
 	remote_islands = kh_init_str();
 
 	git_config(island_config_callback, NULL);
 	for_each_ref(find_island_for_ref, NULL);
-	deduplicate_islands();
+	deduplicate_islands(r);
 
 	fprintf(stderr, _("Marked %d islands, done.\n"), island_counter);
 }
diff --git a/delta-islands.h b/delta-islands.h
index b635cd07d8..3ac8045d8c 100644
--- a/delta-islands.h
+++ b/delta-islands.h
@@ -1,14 +1,17 @@
 #ifndef DELTA_ISLANDS_H
 #define DELTA_ISLANDS_H
 
+struct commit;
 struct object_id;
 struct packing_data;
-struct commit;
+struct repository;
 
 int island_delta_cmp(const struct object_id *a, const struct object_id *b);
 int in_same_island(const struct object_id *, const struct object_id *);
-void resolve_tree_islands(int progress, struct packing_data *to_pack);
-void load_delta_islands(void);
+void resolve_tree_islands(struct repository *r,
+			  int progress,
+			  struct packing_data *to_pack);
+void load_delta_islands(struct repository *r);
 void propagate_island_marks(struct commit *commit);
 int compute_pack_layers(struct packing_data *to_pack);
 
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 16/22] diff-lib.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (14 preceding siblings ...)
  2018-11-10  5:49 ` [PATCH v2 15/22] delta-islands.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:49 ` 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
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/commit.c     | 3 ++-
 builtin/merge-ours.c | 2 +-
 diff-lib.c           | 7 ++++---
 diff.h               | 3 ++-
 sequencer.c          | 4 ++--
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index e89bf35634..91b1920255 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -908,7 +908,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 			if (ignore_submodule_arg &&
 			    !strcmp(ignore_submodule_arg, "all"))
 				flags.ignore_submodules = 1;
-			committable = index_differs_from(parent, &flags, 1);
+			committable = index_differs_from(the_repository,
+							 parent, &flags, 1);
 		}
 	}
 	strbuf_release(&committer_ident);
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
index c84c6e05e9..0b07263415 100644
--- a/builtin/merge-ours.c
+++ b/builtin/merge-ours.c
@@ -26,7 +26,7 @@ int cmd_merge_ours(int argc, const char **argv, const char *prefix)
 	 */
 	if (read_cache() < 0)
 		die_errno("read_cache failed");
-	if (index_differs_from("HEAD", NULL, 0))
+	if (index_differs_from(the_repository, "HEAD", NULL, 0))
 		exit(2);
 	exit(0);
 }
diff --git a/diff-lib.c b/diff-lib.c
index 83fce51518..23c8d351b3 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -542,7 +542,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
 {
 	struct rev_info revs;
 
-	repo_init_revisions(the_repository, &revs, NULL);
+	repo_init_revisions(opt->repo, &revs, NULL);
 	copy_pathspec(&revs.prune_data, &opt->pathspec);
 	revs.diffopt = *opt;
 
@@ -551,13 +551,14 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
 	return 0;
 }
 
-int index_differs_from(const char *def, const struct diff_flags *flags,
+int index_differs_from(struct repository *r,
+		       const char *def, const struct diff_flags *flags,
 		       int ita_invisible_in_index)
 {
 	struct rev_info rev;
 	struct setup_revision_opt opt;
 
-	repo_init_revisions(the_repository, &rev, NULL);
+	repo_init_revisions(r, &rev, NULL);
 	memset(&opt, 0, sizeof(opt));
 	opt.def = def;
 	setup_revisions(0, NULL, &rev, &opt);
diff --git a/diff.h b/diff.h
index ce5e8a8183..3197a976a4 100644
--- a/diff.h
+++ b/diff.h
@@ -436,7 +436,8 @@ int diff_result_code(struct diff_options *, int);
 
 void diff_no_index(struct repository *, struct rev_info *, int, const char **);
 
-int index_differs_from(const char *def, const struct diff_flags *flags,
+int index_differs_from(struct repository *r, const char *def,
+		       const struct diff_flags *flags,
 		       int ita_invisible_in_index);
 
 /*
diff --git a/sequencer.c b/sequencer.c
index 726f727644..d726f77e11 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1713,7 +1713,7 @@ static int do_pick_commit(struct repository *r,
 			unborn = 1;
 		} else if (unborn)
 			oidcpy(&head, the_hash_algo->empty_tree);
-		if (index_differs_from(unborn ? empty_tree_oid_hex() : "HEAD",
+		if (index_differs_from(r, unborn ? empty_tree_oid_hex() : "HEAD",
 				       NULL, 0))
 			return error_dirty_index(r->index, opts);
 	}
@@ -3915,7 +3915,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
 			if (res)
 				goto release_todo_list;
 		}
-		if (index_differs_from("HEAD", NULL, 0)) {
+		if (index_differs_from(r, "HEAD", NULL, 0)) {
 			res = error_dirty_index(r->index, opts);
 			goto release_todo_list;
 		}
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 17/22] line-log.c: remove the_repository reference
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (15 preceding siblings ...)
  2018-11-10  5:49 ` [PATCH v2 16/22] diff-lib.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:49 ` 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
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 line-log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/line-log.c b/line-log.c
index d1d429d738..24e21731c4 100644
--- a/line-log.c
+++ b/line-log.c
@@ -479,7 +479,7 @@ static struct commit *check_single_commit(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 (commit)
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 18/22] notes-cache.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (16 preceding siblings ...)
  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 ` 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
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 combine-diff.c     |  2 +-
 diff.c             | 12 ++++++------
 diff.h             |  2 +-
 diffcore-pickaxe.c |  4 ++--
 grep.c             |  2 +-
 notes-cache.c      | 12 +++++++-----
 notes-cache.h      |  6 ++++--
 userdiff.c         |  5 +++--
 userdiff.h         |  4 +++-
 9 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/combine-diff.c b/combine-diff.c
index 10155e0ec8..3d796af3ca 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -991,7 +991,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 	if (!userdiff)
 		userdiff = userdiff_find_by_name("default");
 	if (opt->flags.allow_textconv)
-		textconv = userdiff_get_textconv(userdiff);
+		textconv = userdiff_get_textconv(opt->repo, userdiff);
 
 	/* Read the result of merge first */
 	if (!working_tree_file)
diff --git a/diff.c b/diff.c
index 8647db3d30..1135377a7f 100644
--- a/diff.c
+++ b/diff.c
@@ -3312,14 +3312,14 @@ void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const
 		options->b_prefix = b;
 }
 
-struct userdiff_driver *get_textconv(struct index_state *istate,
+struct userdiff_driver *get_textconv(struct repository *r,
 				     struct diff_filespec *one)
 {
 	if (!DIFF_FILE_VALID(one))
 		return NULL;
 
-	diff_filespec_load_driver(one, istate);
-	return userdiff_get_textconv(one->driver);
+	diff_filespec_load_driver(one, r->index);
+	return userdiff_get_textconv(r, one->driver);
 }
 
 static void builtin_diff(const char *name_a,
@@ -3368,8 +3368,8 @@ static void builtin_diff(const char *name_a,
 	}
 
 	if (o->flags.allow_textconv) {
-		textconv_one = get_textconv(o->repo->index, one);
-		textconv_two = get_textconv(o->repo->index, two);
+		textconv_one = get_textconv(o->repo, one);
+		textconv_two = get_textconv(o->repo, two);
 	}
 
 	/* Never use a non-valid filename anywhere if at all possible */
@@ -6436,7 +6436,7 @@ int textconv_object(struct repository *r,
 
 	df = alloc_filespec(path);
 	fill_filespec(df, oid, oid_valid, mode);
-	textconv = get_textconv(r->index, df);
+	textconv = get_textconv(r, df);
 	if (!textconv) {
 		free_filespec(df);
 		return 0;
diff --git a/diff.h b/diff.h
index 3197a976a4..412138ba08 100644
--- a/diff.h
+++ b/diff.h
@@ -461,7 +461,7 @@ size_t fill_textconv(struct repository *r,
  * and only if it has textconv enabled (otherwise return NULL). The result
  * can be passed to fill_textconv().
  */
-struct userdiff_driver *get_textconv(struct index_state *istate,
+struct userdiff_driver *get_textconv(struct repository *r,
 				     struct diff_filespec *one);
 
 /*
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index d2361e06a1..b815f1c449 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -139,8 +139,8 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
 		return 0;
 
 	if (o->flags.allow_textconv) {
-		textconv_one = get_textconv(o->repo->index, p->one);
-		textconv_two = get_textconv(o->repo->index, p->two);
+		textconv_one = get_textconv(o->repo, p->one);
+		textconv_two = get_textconv(o->repo, p->two);
 	}
 
 	/*
diff --git a/grep.c b/grep.c
index f6bd89e40b..b05b2e61bb 100644
--- a/grep.c
+++ b/grep.c
@@ -1811,7 +1811,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
 		 * is not thread-safe.
 		 */
 		grep_attr_lock();
-		textconv = userdiff_get_textconv(gs->driver);
+		textconv = userdiff_get_textconv(opt->repo, gs->driver);
 		grep_attr_unlock();
 	}
 
diff --git a/notes-cache.c b/notes-cache.c
index d87e7ca91c..2473314d68 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -5,7 +5,9 @@
 #include "commit.h"
 #include "refs.h"
 
-static int notes_cache_match_validity(const char *ref, const char *validity)
+static int notes_cache_match_validity(struct repository *r,
+				      const char *ref,
+				      const char *validity)
 {
 	struct object_id oid;
 	struct commit *commit;
@@ -16,7 +18,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)
 	if (read_ref(ref, &oid) < 0)
 		return 0;
 
-	commit = lookup_commit_reference_gently(the_repository, &oid, 1);
+	commit = lookup_commit_reference_gently(r, &oid, 1);
 	if (!commit)
 		return 0;
 
@@ -30,8 +32,8 @@ static int notes_cache_match_validity(const char *ref, const char *validity)
 	return ret;
 }
 
-void notes_cache_init(struct notes_cache *c, const char *name,
-		     const char *validity)
+void notes_cache_init(struct repository *r, struct notes_cache *c,
+		      const char *name, const char *validity)
 {
 	struct strbuf ref = STRBUF_INIT;
 	int flags = NOTES_INIT_WRITABLE;
@@ -40,7 +42,7 @@ void notes_cache_init(struct notes_cache *c, const char *name,
 	c->validity = xstrdup(validity);
 
 	strbuf_addf(&ref, "refs/notes/%s", name);
-	if (!notes_cache_match_validity(ref.buf, validity))
+	if (!notes_cache_match_validity(r, ref.buf, validity))
 		flags |= NOTES_INIT_EMPTY;
 	init_notes(&c->tree, ref.buf, combine_notes_overwrite, flags);
 	strbuf_release(&ref);
diff --git a/notes-cache.h b/notes-cache.h
index aeeee8409d..56f8c98e24 100644
--- a/notes-cache.h
+++ b/notes-cache.h
@@ -3,13 +3,15 @@
 
 #include "notes.h"
 
+struct repository;
+
 struct notes_cache {
 	struct notes_tree tree;
 	char *validity;
 };
 
-void notes_cache_init(struct notes_cache *c, const char *name,
-		     const char *validity);
+void notes_cache_init(struct repository *r, struct notes_cache *c,
+		      const char *name, const char *validity);
 int notes_cache_write(struct notes_cache *c);
 
 char *notes_cache_get(struct notes_cache *c, struct object_id *oid, size_t
diff --git a/userdiff.c b/userdiff.c
index 46d34cc2a4..97007abe5b 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -290,7 +290,8 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,
 	return userdiff_find_by_name(check->items[0].value);
 }
 
-struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver)
+struct userdiff_driver *userdiff_get_textconv(struct repository *r,
+					      struct userdiff_driver *driver)
 {
 	if (!driver->textconv)
 		return NULL;
@@ -300,7 +301,7 @@ struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver)
 		struct strbuf name = STRBUF_INIT;
 
 		strbuf_addf(&name, "textconv/%s", driver->name);
-		notes_cache_init(c, name.buf, driver->textconv);
+		notes_cache_init(r, c, name.buf, driver->textconv);
 		driver->textconv_cache = c;
 		strbuf_release(&name);
 	}
diff --git a/userdiff.h b/userdiff.h
index b072bfe89a..203057e13e 100644
--- a/userdiff.h
+++ b/userdiff.h
@@ -4,6 +4,7 @@
 #include "notes-cache.h"
 
 struct index_state;
+struct repository;
 
 struct userdiff_funcname {
 	const char *pattern;
@@ -30,6 +31,7 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,
  * Initialize any textconv-related fields in the driver and return it, or NULL
  * if it does not have textconv enabled at all.
  */
-struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver);
+struct userdiff_driver *userdiff_get_textconv(struct repository *r,
+					      struct userdiff_driver *driver);
 
 #endif /* USERDIFF */
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 19/22] pack-check.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (17 preceding siblings ...)
  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 ` 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
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fsck.c | 3 ++-
 pack-check.c   | 9 +++++----
 pack.h         | 4 +++-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 06eb421720..8ea2823864 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -752,7 +752,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 			for (p = get_all_packs(the_repository); p;
 			     p = p->next) {
 				/* verify gives error messages itself */
-				if (verify_pack(p, fsck_obj_buffer,
+				if (verify_pack(the_repository,
+						p, fsck_obj_buffer,
 						progress, count))
 					errors_found |= ERROR_PACK;
 				count += p->num_objects;
diff --git a/pack-check.c b/pack-check.c
index fa5f0ff8fa..2cc3603189 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -48,7 +48,8 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
 	return data_crc != ntohl(*index_crc);
 }
 
-static int verify_packfile(struct packed_git *p,
+static int verify_packfile(struct repository *r,
+			   struct packed_git *p,
 			   struct pack_window **w_curs,
 			   verify_fn fn,
 			   struct progress *progress, uint32_t base_count)
@@ -135,7 +136,7 @@ static int verify_packfile(struct packed_git *p,
 			data = NULL;
 			data_valid = 0;
 		} else {
-			data = unpack_entry(the_repository, p, entries[i].offset, &type, &size);
+			data = unpack_entry(r, p, entries[i].offset, &type, &size);
 			data_valid = 1;
 		}
 
@@ -186,7 +187,7 @@ int verify_pack_index(struct packed_git *p)
 	return err;
 }
 
-int verify_pack(struct packed_git *p, verify_fn fn,
+int verify_pack(struct repository *r, struct packed_git *p, verify_fn fn,
 		struct progress *progress, uint32_t base_count)
 {
 	int err = 0;
@@ -196,7 +197,7 @@ int verify_pack(struct packed_git *p, verify_fn fn,
 	if (!p->index_data)
 		return -1;
 
-	err |= verify_packfile(p, &w_curs, fn, progress, base_count);
+	err |= verify_packfile(r, p, &w_curs, fn, progress, base_count);
 	unuse_pack(&w_curs);
 
 	return err;
diff --git a/pack.h b/pack.h
index 34a9d458b4..da99fdd1d2 100644
--- a/pack.h
+++ b/pack.h
@@ -4,6 +4,8 @@
 #include "object.h"
 #include "csum-file.h"
 
+struct repository;
+
 /*
  * Packed object header
  */
@@ -80,7 +82,7 @@ typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned lo
 extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *, const unsigned char *sha1);
 extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);
 extern int verify_pack_index(struct packed_git *);
-extern int verify_pack(struct packed_git *, verify_fn fn, struct progress *, uint32_t);
+extern int verify_pack(struct repository *, struct packed_git *, verify_fn fn, struct progress *, uint32_t);
 extern off_t write_pack_header(struct hashfile *f, uint32_t);
 extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t);
 extern char *index_pack_lockfile(int fd);
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 20/22] pack-*.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (18 preceding siblings ...)
  2018-11-10  5:49 ` [PATCH v2 19/22] pack-check.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:49 ` 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
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/pack-objects.c |  2 +-
 pack-bitmap-write.c    |  6 +++---
 pack-bitmap.c          | 13 +++++++------
 pack-bitmap.h          |  3 ++-
 pack-objects.c         |  6 ++++--
 pack-objects.h         |  5 ++++-
 6 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 7812c2b1f3..8abfb69e2d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3481,7 +3481,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	prepare_packing_data(&to_pack);
+	prepare_packing_data(the_repository, &to_pack);
 
 	if (progress)
 		progress_state = start_progress(_("Enumerating objects"), 0);
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 9d1b951697..5566e94abe 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -77,7 +77,7 @@ void bitmap_writer_build_type_index(struct packing_data *to_pack,
 			break;
 
 		default:
-			real_type = oid_object_info(the_repository,
+			real_type = oid_object_info(to_pack->repo,
 						    &entry->idx.oid, NULL);
 			break;
 		}
@@ -262,7 +262,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
 	if (writer.show_progress)
 		writer.progress = start_progress("Building bitmaps", writer.selected_nr);
 
-	repo_init_revisions(the_repository, &revs, NULL);
+	repo_init_revisions(to_pack->repo, &revs, NULL);
 	revs.tag_objects = 1;
 	revs.tree_objects = 1;
 	revs.blob_objects = 1;
@@ -363,7 +363,7 @@ static int date_compare(const void *_a, const void *_b)
 void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack)
 {
 	struct bitmap_index *bitmap_git;
-	if (!(bitmap_git = prepare_bitmap_git()))
+	if (!(bitmap_git = prepare_bitmap_git(to_pack->repo)))
 		return;
 
 	writer.reused = kh_init_sha1();
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 5848cc93aa..4695aaf6b4 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -328,14 +328,15 @@ static int load_pack_bitmap(struct bitmap_index *bitmap_git)
 	return -1;
 }
 
-static int open_pack_bitmap(struct bitmap_index *bitmap_git)
+static int open_pack_bitmap(struct repository *r,
+			    struct bitmap_index *bitmap_git)
 {
 	struct packed_git *p;
 	int ret = -1;
 
 	assert(!bitmap_git->map);
 
-	for (p = get_all_packs(the_repository); p; p = p->next) {
+	for (p = get_all_packs(r); p; p = p->next) {
 		if (open_pack_bitmap_1(bitmap_git, p) == 0)
 			ret = 0;
 	}
@@ -343,11 +344,11 @@ static int open_pack_bitmap(struct bitmap_index *bitmap_git)
 	return ret;
 }
 
-struct bitmap_index *prepare_bitmap_git(void)
+struct bitmap_index *prepare_bitmap_git(struct repository *r)
 {
 	struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
 
-	if (!open_pack_bitmap(bitmap_git) && !load_pack_bitmap(bitmap_git))
+	if (!open_pack_bitmap(r, bitmap_git) && !load_pack_bitmap(bitmap_git))
 		return bitmap_git;
 
 	free_bitmap_index(bitmap_git);
@@ -690,7 +691,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
 	struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
 	/* try to open a bitmapped pack, but don't parse it yet
 	 * because we may not need to use it */
-	if (open_pack_bitmap(bitmap_git) < 0)
+	if (open_pack_bitmap(revs->repo, bitmap_git) < 0)
 		goto cleanup;
 
 	for (i = 0; i < revs->pending.nr; ++i) {
@@ -955,7 +956,7 @@ void test_bitmap_walk(struct rev_info *revs)
 	struct bitmap_test_data tdata;
 	struct bitmap_index *bitmap_git;
 
-	if (!(bitmap_git = prepare_bitmap_git()))
+	if (!(bitmap_git = prepare_bitmap_git(revs->repo)))
 		die("failed to load bitmap indexes");
 
 	if (revs->pending.nr != 1)
diff --git a/pack-bitmap.h b/pack-bitmap.h
index 189dd68ad3..8418ba8c79 100644
--- a/pack-bitmap.h
+++ b/pack-bitmap.h
@@ -6,6 +6,7 @@
 #include "pack-objects.h"
 
 struct commit;
+struct repository;
 struct rev_info;
 
 struct bitmap_disk_header {
@@ -39,7 +40,7 @@ typedef int (*show_reachable_fn)(
 
 struct bitmap_index;
 
-struct bitmap_index *prepare_bitmap_git(void);
+struct bitmap_index *prepare_bitmap_git(struct repository *r);
 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
 			      uint32_t *trees, uint32_t *blobs, uint32_t *tags);
 void traverse_bitmap_commit_list(struct bitmap_index *,
diff --git a/pack-objects.c b/pack-objects.c
index b6cdbb0166..9c45842df3 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -99,7 +99,7 @@ static void prepare_in_pack_by_idx(struct packing_data *pdata)
 	 * (i.e. in_pack_idx also zero) should return NULL.
 	 */
 	mapping[cnt++] = NULL;
-	for (p = get_all_packs(the_repository); p; p = p->next, cnt++) {
+	for (p = get_all_packs(pdata->repo); p; p = p->next, cnt++) {
 		if (cnt == nr) {
 			free(mapping);
 			return;
@@ -133,8 +133,10 @@ void oe_map_new_pack(struct packing_data *pack,
 }
 
 /* assume pdata is already zero'd by caller */
-void prepare_packing_data(struct packing_data *pdata)
+void prepare_packing_data(struct repository *r, struct packing_data *pdata)
 {
+	pdata->repo = r;
+
 	if (git_env_bool("GIT_TEST_FULL_IN_PACK_ARRAY", 0)) {
 		/*
 		 * do not initialize in_pack_by_idx[] to force the
diff --git a/pack-objects.h b/pack-objects.h
index 86ee93feb4..9e6af3f24f 100644
--- a/pack-objects.h
+++ b/pack-objects.h
@@ -5,6 +5,8 @@
 #include "thread-utils.h"
 #include "pack.h"
 
+struct repository;
+
 #define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)
 
 #define OE_DFS_STATE_BITS	2
@@ -127,6 +129,7 @@ struct object_entry {
 };
 
 struct packing_data {
+	struct repository *repo;
 	struct object_entry *objects;
 	uint32_t nr_objects, nr_alloc;
 
@@ -165,7 +168,7 @@ struct packing_data {
 	unsigned char *layer;
 };
 
-void prepare_packing_data(struct packing_data *pdata);
+void prepare_packing_data(struct repository *r, struct packing_data *pdata);
 
 static inline void packing_data_lock(struct packing_data *pdata)
 {
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 21/22] rerere.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (19 preceding siblings ...)
  2018-11-10  5:49 ` [PATCH v2 20/22] pack-*.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:49 ` 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
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/am.c                  |  2 +-
 builtin/rebase--interactive.c |  2 +-
 builtin/rebase.c              |  4 ++--
 builtin/rerere.c              | 10 ++++++----
 rerere.c                      | 26 +++++++++++++-------------
 rerere.h                      |  6 +++---
 6 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index 232f3962d7..f0eeec82a9 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2033,7 +2033,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
 static void am_rerere_clear(void)
 {
 	struct string_list merge_rr = STRING_LIST_INIT_DUP;
-	rerere_clear(&merge_rr);
+	rerere_clear(the_repository, &merge_rr);
 	string_list_clear(&merge_rr, 1);
 }
 
diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c
index d867050fd2..bd7d39e2af 100644
--- a/builtin/rebase--interactive.c
+++ b/builtin/rebase--interactive.c
@@ -233,7 +233,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
 	case SKIP: {
 		struct string_list merge_rr = STRING_LIST_INIT_DUP;
 
-		rerere_clear(&merge_rr);
+		rerere_clear(the_repository, &merge_rr);
 		/* fallthrough */
 	case CONTINUE:
 		ret = sequencer_continue(the_repository, &opts);
diff --git a/builtin/rebase.c b/builtin/rebase.c
index d9bedecf86..bc07d932a5 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -997,7 +997,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 
 		options.action = "skip";
 
-		rerere_clear(&merge_rr);
+		rerere_clear(the_repository, &merge_rr);
 		string_list_clear(&merge_rr, 1);
 
 		if (reset_head(NULL, "reset", NULL, 0, NULL, NULL) < 0)
@@ -1010,7 +1010,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		struct string_list merge_rr = STRING_LIST_INIT_DUP;
 		options.action = "abort";
 
-		rerere_clear(&merge_rr);
+		rerere_clear(the_repository, &merge_rr);
 		string_list_clear(&merge_rr, 1);
 
 		if (read_basic_state(&options))
diff --git a/builtin/rerere.c b/builtin/rerere.c
index e89ccbc524..6f28c19b20 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -82,11 +82,12 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
 	}
 
 	if (!strcmp(argv[0], "clear")) {
-		rerere_clear(&merge_rr);
+		rerere_clear(the_repository, &merge_rr);
 	} else if (!strcmp(argv[0], "gc"))
-		rerere_gc(&merge_rr);
+		rerere_gc(the_repository, &merge_rr);
 	else if (!strcmp(argv[0], "status")) {
-		if (setup_rerere(&merge_rr, flags | RERERE_READONLY) < 0)
+		if (setup_rerere(the_repository, &merge_rr,
+				 flags | RERERE_READONLY) < 0)
 			return 0;
 		for (i = 0; i < merge_rr.nr; i++)
 			printf("%s\n", merge_rr.items[i].string);
@@ -101,7 +102,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
 				merge_rr.items[i].util = NULL;
 		}
 	} else if (!strcmp(argv[0], "diff")) {
-		if (setup_rerere(&merge_rr, flags | RERERE_READONLY) < 0)
+		if (setup_rerere(the_repository, &merge_rr,
+				 flags | RERERE_READONLY) < 0)
 			return 0;
 		for (i = 0; i < merge_rr.nr; i++) {
 			const char *path = merge_rr.items[i].string;
diff --git a/rerere.c b/rerere.c
index b5b2357411..13624038e6 100644
--- a/rerere.c
+++ b/rerere.c
@@ -198,10 +198,10 @@ static struct rerere_id *new_rerere_id(unsigned char *sha1)
  * work on (i.e. what is left by the previous invocation of "git
  * rerere" during the current conflict resolution session).
  */
-static void read_rr(struct string_list *rr)
+static void read_rr(struct repository *r, struct string_list *rr)
 {
 	struct strbuf buf = STRBUF_INIT;
-	FILE *in = fopen_or_warn(git_path_merge_rr(the_repository), "r");
+	FILE *in = fopen_or_warn(git_path_merge_rr(r), "r");
 
 	if (!in)
 		return;
@@ -593,7 +593,7 @@ int rerere_remaining(struct repository *r, struct string_list *merge_rr)
 {
 	int i;
 
-	if (setup_rerere(merge_rr, RERERE_READONLY))
+	if (setup_rerere(r, merge_rr, RERERE_READONLY))
 		return 0;
 	if (read_index(r->index) < 0)
 		return error(_("index file corrupt"));
@@ -882,7 +882,7 @@ static int is_rerere_enabled(void)
 	return 1;
 }
 
-int setup_rerere(struct string_list *merge_rr, int flags)
+int setup_rerere(struct repository *r, struct string_list *merge_rr, int flags)
 {
 	int fd;
 
@@ -896,9 +896,9 @@ int setup_rerere(struct string_list *merge_rr, int flags)
 		fd = 0;
 	else
 		fd = hold_lock_file_for_update(&write_lock,
-					       git_path_merge_rr(the_repository),
+					       git_path_merge_rr(r),
 					       LOCK_DIE_ON_ERROR);
-	read_rr(merge_rr);
+	read_rr(r, merge_rr);
 	return fd;
 }
 
@@ -912,7 +912,7 @@ int repo_rerere(struct repository *r, int flags)
 	struct string_list merge_rr = STRING_LIST_INIT_DUP;
 	int fd, status;
 
-	fd = setup_rerere(&merge_rr, flags);
+	fd = setup_rerere(r, &merge_rr, flags);
 	if (fd < 0)
 		return 0;
 	status = do_plain_rerere(r, &merge_rr, fd);
@@ -1110,7 +1110,7 @@ int rerere_forget(struct repository *r, struct pathspec *pathspec)
 	if (read_index(r->index) < 0)
 		return error(_("index file corrupt"));
 
-	fd = setup_rerere(&merge_rr, RERERE_NOAUTOUPDATE);
+	fd = setup_rerere(r, &merge_rr, RERERE_NOAUTOUPDATE);
 	if (fd < 0)
 		return 0;
 
@@ -1178,7 +1178,7 @@ static void prune_one(struct rerere_id *id,
 		unlink_rr_item(id);
 }
 
-void rerere_gc(struct string_list *rr)
+void rerere_gc(struct repository *r, struct string_list *rr)
 {
 	struct string_list to_remove = STRING_LIST_INIT_DUP;
 	DIR *dir;
@@ -1188,7 +1188,7 @@ void rerere_gc(struct string_list *rr)
 	timestamp_t cutoff_noresolve = now - 15 * 86400;
 	timestamp_t cutoff_resolve = now - 60 * 86400;
 
-	if (setup_rerere(rr, 0) < 0)
+	if (setup_rerere(r, rr, 0) < 0)
 		return;
 
 	git_config_get_expiry_in_days("gc.rerereresolved", &cutoff_resolve, now);
@@ -1236,11 +1236,11 @@ void rerere_gc(struct string_list *rr)
  *
  * NEEDSWORK: shouldn't we be calling this from "reset --hard"?
  */
-void rerere_clear(struct string_list *merge_rr)
+void rerere_clear(struct repository *r, struct string_list *merge_rr)
 {
 	int i;
 
-	if (setup_rerere(merge_rr, 0) < 0)
+	if (setup_rerere(r, merge_rr, 0) < 0)
 		return;
 
 	for (i = 0; i < merge_rr->nr; i++) {
@@ -1250,6 +1250,6 @@ void rerere_clear(struct string_list *merge_rr)
 			rmdir(rerere_path(id, NULL));
 		}
 	}
-	unlink_or_warn(git_path_merge_rr(the_repository));
+	unlink_or_warn(git_path_merge_rr(r));
 	rollback_lock_file(&write_lock);
 }
diff --git a/rerere.h b/rerere.h
index 5ad8864b3c..c32d79c3bd 100644
--- a/rerere.h
+++ b/rerere.h
@@ -23,7 +23,7 @@ struct rerere_id {
 	int variant;
 };
 
-int setup_rerere(struct string_list *, int);
+int setup_rerere(struct repository *,struct string_list *, int);
 #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
 #define rerere(flags) repo_rerere(the_repository, flags)
 #endif
@@ -37,8 +37,8 @@ int repo_rerere(struct repository *, int);
 const char *rerere_path(const struct rerere_id *, const char *file);
 int rerere_forget(struct repository *, struct pathspec *);
 int rerere_remaining(struct repository *, struct string_list *);
-void rerere_clear(struct string_list *);
-void rerere_gc(struct string_list *);
+void rerere_clear(struct repository *, struct string_list *);
+void rerere_gc(struct repository *, struct string_list *);
 
 #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, "rerere-autoupdate", (v), \
 	N_("update the index with reused conflict resolution if possible"))
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 22/22] rebase-interactive.c: remove the_repository references
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (20 preceding siblings ...)
  2018-11-10  5:49 ` [PATCH v2 21/22] rerere.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:49 ` Nguyễn Thái Ngọc Duy
  2018-11-12  5:53 ` [PATCH v2 00/22] Kill the_index part 5 Junio C Hamano
  22 siblings, 0 replies; 24+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

While at there add a forward declaration for struct strbuf.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/rebase--interactive.c | 2 +-
 rebase-interactive.c          | 6 +++---
 rebase-interactive.h          | 5 ++++-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c
index bd7d39e2af..dd2a55ab1d 100644
--- a/builtin/rebase--interactive.c
+++ b/builtin/rebase--interactive.c
@@ -240,7 +240,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
 		break;
 	}
 	case EDIT_TODO:
-		ret = edit_todo_list(flags);
+		ret = edit_todo_list(the_repository, flags);
 		break;
 	case SHOW_CURRENT_PATCH: {
 		struct child_process cmd = CHILD_PROCESS_INIT;
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 3cc19283ff..68aff1dac2 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -53,7 +53,7 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty,
 	}
 }
 
-int edit_todo_list(unsigned flags)
+int edit_todo_list(struct repository *r, unsigned flags)
 {
 	struct strbuf buf = STRBUF_INIT;
 	const char *todo_file = rebase_path_todo();
@@ -69,7 +69,7 @@ int edit_todo_list(unsigned flags)
 
 	strbuf_release(&buf);
 
-	transform_todos(the_repository, flags | TODO_LIST_SHORTEN_IDS);
+	transform_todos(r, flags | TODO_LIST_SHORTEN_IDS);
 
 	if (strbuf_read_file(&buf, todo_file, 0) < 0)
 		return error_errno(_("could not read '%s'."), todo_file);
@@ -85,7 +85,7 @@ int edit_todo_list(unsigned flags)
 	if (launch_sequence_editor(todo_file, NULL, NULL))
 		return -1;
 
-	transform_todos(the_repository, flags & ~(TODO_LIST_SHORTEN_IDS));
+	transform_todos(r, flags & ~(TODO_LIST_SHORTEN_IDS));
 
 	return 0;
 }
diff --git a/rebase-interactive.h b/rebase-interactive.h
index 971da03776..17b6c9f6d0 100644
--- a/rebase-interactive.h
+++ b/rebase-interactive.h
@@ -1,8 +1,11 @@
 #ifndef REBASE_INTERACTIVE_H
 #define REBASE_INTERACTIVE_H
 
+struct strbuf;
+struct repository;
+
 void append_todo_help(unsigned edit_todo, unsigned keep_empty,
 		      struct strbuf *buf);
-int edit_todo_list(unsigned flags);
+int edit_todo_list(struct repository *r, unsigned flags);
 
 #endif
-- 
2.19.1.1231.g84aef82467


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 00/22] Kill the_index part 5
  2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
                   ` (21 preceding siblings ...)
  2018-11-10  5:49 ` [PATCH v2 22/22] rebase-interactive.c: " Nguyễn Thái Ngọc Duy
@ 2018-11-12  5:53 ` Junio C Hamano
  22 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2018-11-12  5:53 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> I did start pushing the_repository out of library code [1] in the bottom
> half of this series. There aren't big surprises except that cache-tree
> API now take _both_ struct repository and struct index_state. The
> reason is cache-tree can work on temporary indexes and repo->index is
> about $GIT_DIR/index.

Yes, this is very sensible, and I expect many more functions would
(and probably should) follow suit, as we'd want to be able to work
with temporary index (not in the sense that we'll write out on-disk
temporary index, but multiple in-core instances of istate that is
not necessarily tied to the current or the next state of
$GIT_DIR/index) from more places.


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2018-11-12  5:53 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 10/22] blame.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
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

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).