All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Stefan Beller" <sbeller@google.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 07/19] notes-merge.c: remove implicit dependency on the_index
Date: Fri, 19 Oct 2018 16:52:25 +0200	[thread overview]
Message-ID: <20181019145237.16079-8-pclouds@gmail.com> (raw)
In-Reply-To: <20181019145237.16079-1-pclouds@gmail.com>

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

diff --git a/builtin/notes.c b/builtin/notes.c
index c05cd004ab..d8bd01656a 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(&o, the_repository);
 	o.verbosity = verbosity + NOTES_MERGE_VERBOSITY_DEFAULT;
 
 	if (do_abort)
diff --git a/notes-merge.c b/notes-merge.c
index bd05d50b05..c3bee1a87d 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 notes_merge_options *o,
+			      struct repository *repo)
 {
 	memset(o, 0, sizeof(struct notes_merge_options));
 	strbuf_init(&(o->commit_msg), 0);
 	o->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;
+	o->repo = repo;
 }
 
 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..fe70cbd5e8 100644
--- a/notes-merge.h
+++ b/notes-merge.h
@@ -7,6 +7,8 @@
 struct commit;
 struct object_id;
 
+struct repository;
+
 #define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
 
 enum notes_merge_verbosity {
@@ -15,6 +17,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 +26,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 notes_merge_options *o,
+			      struct repository *repo);
 
 /*
  * Merge notes from o->remote_ref into o->local_ref
-- 
2.19.1.647.g708186aaf9


  parent reply	other threads:[~2018-10-19 14:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-19 14:52 [PATCH/WIP 00/19] Kill the_index, final part Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 01/19] wt-status.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 02/19] wt-status.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 03/19] list-objects-filter.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 04/19] list-objects.c: " Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 05/19] sequencer.c: " Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 06/19] sequencer.c: remove implicit dependency on the_repository Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` Nguyễn Thái Ngọc Duy [this message]
2018-10-19 14:52 ` [PATCH 08/19] notes-merge.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 09/19] repository.c: replace hold_locked_index() with repo_hold_locked_index() Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 10/19] checkout: avoid the_index when possible Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 11/19] read-cache.c: kill read_index() Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 12/19] read-cache.c: replace update_index_if_able with repo_& Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 13/19] transport.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 14/19] sha1-name.c: " Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 15/19] merge-recursive.c: " Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 16/19] merge-recursive.c: remove implicit dependency on the_repository Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 17/19] read-cache.c: remove the_* from index_has_changes() Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 18/19] cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch Nguyễn Thái Ngọc Duy
2018-10-19 14:52 ` [PATCH 19/19] Flip NO_THE_REPOSITORY_COMPATIBILITY_MACROS Nguyễn Thái Ngọc Duy
2018-10-19 17:38 ` [PATCH/WIP 00/19] Kill the_index, final part Stefan Beller
2018-10-29 16:42   ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181019145237.16079-8-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.