git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 16/22] diff-lib.c: remove the_repository references

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Nov 10, 2018, 05:49 UTC
Message-ID
<20181110054910.10568-17-pclouds@gmail.com>
In-Reply-To
<20181110054910.10568-1-pclouds@gmail.com>
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
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 20 of 24 in “Kill the_index part 5”
  1. 00/22 Kill the_index part 5Nguyễn Thái Ngọc Duy, Nov 10, 2018
  2. 01/22 wt-status.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Nov 10, 2018
  3. 03/22 list-objects-filter.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Nov 10, 2018
  4. 04/22 list-objects.c: reduce the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  5. 05/22 notes-merge.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Nov 10, 2018
  6. 06/22 notes-merge.c: remove implicit dependency the_repositoryNguyễn Thái Ngọc Duy, Nov 10, 2018
  7. 07/22 transport.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Nov 10, 2018
  8. 08/22 sequencer.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Nov 10, 2018
  9. 09/22 sequencer.c: remove implicit dependency on the_repositoryNguyễn Thái Ngọc Duy, Nov 10, 2018
  10. 11/22 bisect.c: remove the_repository referenceNguyễn Thái Ngọc Duy, Nov 10, 2018
  11. 12/22 branch.c: remove the_repository referenceNguyễn Thái Ngọc Duy, Nov 10, 2018
  12. 14/22 cache-tree.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  13. 15/22 delta-islands.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  14. 17/22 line-log.c: remove the_repository referenceNguyễn Thái Ngọc Duy, Nov 10, 2018
  15. 18/22 notes-cache.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  16. 19/22 pack-check.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  17. 20/22 pack-*.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  18. 21/22 rerere.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  19. 22/22 rebase-interactive.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  20. 16/22 diff-lib.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  21. 13/22 bundle.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Nov 10, 2018
  22. 10/22 blame.c: remove implicit dependency the_repositoryNguyễn Thái Ngọc Duy, Nov 10, 2018
  23. 02/22 wt-status.c: remove implicit dependency the_repositoryNguyễn Thái Ngọc Duy, Nov 10, 2018
  24. Junio C HamanoNov 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.