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: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 09/10] read-cache.c: remove the_* from index_has_changes()
Date: Sat,  5 Jan 2019 12:51:52 +0700	[thread overview]
Message-ID: <20190105055153.3256-10-pclouds@gmail.com> (raw)
In-Reply-To: <20190105055153.3256-1-pclouds@gmail.com>

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/am.c      |  6 +++---
 cache.h           |  6 +++---
 merge-recursive.c |  2 +-
 read-cache.c      | 12 +++++-------
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index 611712dc95..a9ffc92eaa 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1719,7 +1719,7 @@ static void am_run(struct am_state *state, int resume)
 
 	refresh_and_write_cache();
 
-	if (index_has_changes(&the_index, NULL, &sb)) {
+	if (repo_index_has_changes(the_repository, NULL, &sb)) {
 		write_state_bool(state, "dirtyindex", 1);
 		die(_("Dirty index: cannot apply patches (dirty: %s)"), sb.buf);
 	}
@@ -1777,7 +1777,7 @@ static void am_run(struct am_state *state, int resume)
 			 * the result may have produced the same tree as ours.
 			 */
 			if (!apply_status &&
-			    !index_has_changes(&the_index, NULL, NULL)) {
+			    !repo_index_has_changes(the_repository, NULL, NULL)) {
 				say(state, stdout, _("No changes -- Patch already applied."));
 				goto next;
 			}
@@ -1831,7 +1831,7 @@ static void am_resolve(struct am_state *state)
 
 	say(state, stdout, _("Applying: %.*s"), linelen(state->msg), state->msg);
 
-	if (!index_has_changes(&the_index, NULL, NULL)) {
+	if (!repo_index_has_changes(the_repository, NULL, NULL)) {
 		printf_ln(_("No changes - did you forget to use 'git add'?\n"
 			"If there is nothing left to stage, chances are that something else\n"
 			"already introduced the same changes; you might want to skip this patch."));
diff --git a/cache.h b/cache.h
index fdcd69bfb0..326e73f391 100644
--- a/cache.h
+++ b/cache.h
@@ -706,9 +706,9 @@ extern int unmerged_index(const struct index_state *);
  * provided, the space-separated list of files that differ will be appended
  * to it.
  */
-extern int index_has_changes(struct index_state *istate,
-			     struct tree *tree,
-			     struct strbuf *sb);
+extern int repo_index_has_changes(struct repository *repo,
+				  struct tree *tree,
+				  struct strbuf *sb);
 
 extern int verify_path(const char *path, unsigned mode);
 extern int strcmp_offset(const char *s1, const char *s2, size_t *first_change);
diff --git a/merge-recursive.c b/merge-recursive.c
index a596d95739..df00896b25 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3412,7 +3412,7 @@ int merge_trees(struct merge_options *o,
 	int code, clean;
 	struct strbuf sb = STRBUF_INIT;
 
-	if (!o->call_depth && index_has_changes(istate, head, &sb)) {
+	if (!o->call_depth && repo_index_has_changes(o->repo, head, &sb)) {
 		err(o, _("Your local changes to the following files would be overwritten by merge:\n  %s"),
 		    sb.buf);
 		return -1;
diff --git a/read-cache.c b/read-cache.c
index 61cc0571da..2549477ed2 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2365,22 +2365,20 @@ int unmerged_index(const struct index_state *istate)
 	return 0;
 }
 
-int index_has_changes(struct index_state *istate,
-		      struct tree *tree,
-		      struct strbuf *sb)
+int repo_index_has_changes(struct repository *repo,
+			   struct tree *tree,
+			   struct strbuf *sb)
 {
+	struct index_state *istate = repo->index;
 	struct object_id cmp;
 	int i;
 
-	if (istate != &the_index) {
-		BUG("index_has_changes cannot yet accept istate != &the_index; do_diff_cache needs updating first.");
-	}
 	if (tree)
 		cmp = tree->object.oid;
 	if (tree || !get_oid_tree("HEAD", &cmp)) {
 		struct diff_options opt;
 
-		repo_diff_setup(the_repository, &opt);
+		repo_diff_setup(repo, &opt);
 		opt.flags.exit_with_status = 1;
 		if (!sb)
 			opt.flags.quick = 1;
-- 
2.20.0.482.g66447595a7


  parent reply	other threads:[~2019-01-05  5:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-05  5:51 [PATCH 00/10] Remove the_index, the final part Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 01/10] notes-utils.c: remove the_repository references Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 02/10] repository.c: replace hold_locked_index() with repo_hold_locked_index() Nguyễn Thái Ngọc Duy
2019-01-05 14:33   ` Martin Ågren
2019-01-07 12:55     ` Duy Nguyen
2019-01-05  5:51 ` [PATCH 03/10] checkout: avoid the_index when possible Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 04/10] read-cache.c: kill read_index() Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 05/10] read-cache.c: replace update_index_if_able with repo_& Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 06/10] sha1-name.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 07/10] merge-recursive.c: " Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 08/10] merge-recursive.c: remove implicit dependency on the_repository Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` Nguyễn Thái Ngọc Duy [this message]
2019-01-05  5:51 ` [PATCH 10/10] cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch Nguyễn Thái Ngọc Duy
2019-01-12  2:13 ` [PATCH v2 00/11] Remove the_index, the final part Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 01/11] grep: use grep_opt->repo instead of explict repo argument Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 02/11] notes-utils.c: remove the_repository references Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 03/11] repository.c: replace hold_locked_index() with repo_hold_locked_index() Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 04/11] checkout: avoid the_index when possible Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 05/11] read-cache.c: kill read_index() Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 06/11] read-cache.c: replace update_index_if_able with repo_& Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 07/11] sha1-name.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 08/11] merge-recursive.c: " Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 09/11] merge-recursive.c: remove implicit dependency on the_repository Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 10/11] read-cache.c: remove the_* from index_has_changes() Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 11/11] cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch Nguyễn Thái Ngọc Duy

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=20190105055153.3256-10-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.