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

[PATCH 10/15] rerere.c: stop using index compat macros

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jun 16, 2018, 05:41 UTC
Message-ID
<20180616054157.32433-11-pclouds@gmail.com>
In-Reply-To
<20180616054157.32433-1-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 rerere.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/rerere.c b/rerere.c
index e0862e2778..810e86d246 100644
--- a/rerere.c
+++ b/rerere.c
@@ -524,7 +524,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
  */
 static int check_one_conflict(int i, int *type)
 {
-	const struct cache_entry *e = active_cache[i];
+	const struct cache_entry *e = the_index.cache[i];
 
 	if (!ce_stage(e)) {
 		*type = RESOLVED;
@@ -532,13 +532,13 @@ static int check_one_conflict(int i, int *type)
 	}
 
 	*type = PUNTED;
-	while (ce_stage(active_cache[i]) == 1)
+	while (ce_stage(the_index.cache[i]) == 1)
 		i++;
 
 	/* Only handle regular files with both stages #2 and #3 */
-	if (i + 1 < active_nr) {
-		const struct cache_entry *e2 = active_cache[i];
-		const struct cache_entry *e3 = active_cache[i + 1];
+	if (i + 1 < the_index.cache_nr) {
+		const struct cache_entry *e2 = the_index.cache[i];
+		const struct cache_entry *e3 = the_index.cache[i + 1];
 		if (ce_stage(e2) == 2 &&
 		    ce_stage(e3) == 3 &&
 		    ce_same_name(e, e3) &&
@@ -548,7 +548,7 @@ static int check_one_conflict(int i, int *type)
 	}
 
 	/* Skip the entries with the same name */
-	while (i < active_nr && ce_same_name(e, active_cache[i]))
+	while (i < the_index.cache_nr && ce_same_name(e, the_index.cache[i]))
 		i++;
 	return i;
 }
@@ -567,12 +567,12 @@ static int check_one_conflict(int i, int *type)
 static int find_conflict(struct string_list *conflict)
 {
 	int i;
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		return error("Could not read index");
 
-	for (i = 0; i < active_nr;) {
+	for (i = 0; i < the_index.cache_nr;) {
 		int conflict_type;
-		const struct cache_entry *e = active_cache[i];
+		const struct cache_entry *e = the_index.cache[i];
 		i = check_one_conflict(i, &conflict_type);
 		if (conflict_type == THREE_STAGED)
 			string_list_insert(conflict, (const char *)e->name);
@@ -600,12 +600,12 @@ int rerere_remaining(struct string_list *merge_rr)
 	int i;
 	if (setup_rerere(merge_rr, RERERE_READONLY))
 		return 0;
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		return error("Could not read index");
 
-	for (i = 0; i < active_nr;) {
+	for (i = 0; i < the_index.cache_nr;) {
 		int conflict_type;
-		const struct cache_entry *e = active_cache[i];
+		const struct cache_entry *e = the_index.cache[i];
 		i = check_one_conflict(i, &conflict_type);
 		if (conflict_type == PUNTED)
 			string_list_insert(merge_rr, (const char *)e->name);
@@ -712,7 +712,7 @@ static void update_paths(struct string_list *update)
 
 	for (i = 0; i < update->nr; i++) {
 		struct string_list_item *item = &update->items[i];
-		if (add_file_to_cache(item->string, 0))
+		if (add_file_to_index(&the_index, item->string, 0))
 			exit(128);
 		fprintf(stderr, "Staged '%s' using previous resolution.\n",
 			item->string);
@@ -964,16 +964,16 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
 	 * Reproduce the conflicted merge in-core
 	 */
 	len = strlen(path);
-	pos = cache_name_pos(path, len);
+	pos = index_name_pos(&the_index, path, len);
 	if (0 <= pos)
 		return -1;
 	pos = -pos - 1;
 
-	while (pos < active_nr) {
+	while (pos < the_index.cache_nr) {
 		enum object_type type;
 		unsigned long size;
 
-		ce = active_cache[pos++];
+		ce = the_index.cache[pos++];
 		if (ce_namelen(ce) != len || memcmp(ce->name, path, len))
 			break;
 		i = ce_stage(ce) - 1;
@@ -1102,7 +1102,7 @@ int rerere_forget(struct pathspec *pathspec)
 	struct string_list conflict = STRING_LIST_INIT_DUP;
 	struct string_list merge_rr = STRING_LIST_INIT_DUP;
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		return error("Could not read index");
 
 	fd = setup_rerere(&merge_rr, RERERE_NOAUTOUPDATE);
@@ -1114,7 +1114,7 @@ int rerere_forget(struct pathspec *pathspec)
 	 * recover the original conflicted state and then
 	 * find the conflicted paths.
 	 */
-	unmerge_cache(pathspec);
+	unmerge_index(&the_index, pathspec);
 	find_conflict(&conflict);
 	for (i = 0; i < conflict.nr; i++) {
 		struct string_list_item *it = &conflict.items[i];
-- 
2.18.0.rc0.333.g22e6ee6cdf
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 12 of 32 in “Kill the_index part 1, expose it”
  1. 00/15 Kill the_index part 1, expose itNguyễn Thái Ngọc Duy, Jun 16, 2018
  2. 01/15 contrib: add cocci script to replace index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  3. Derrick StoleeJun 19, 2018
  4. Derrick StoleeJun 19, 2018
  5. Duy NguyenJun 19, 2018
  6. Derrick StoleeJun 19, 2018
  7. SZEDER GáborJul 23, 2018
  8. 05/15 diff-lib.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  9. 11/15 revision.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  10. 04/15 check-racy.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  11. 14/15 wt-status.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  12. 10/15 rerere.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  13. 12/15 sequencer.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  14. 13/15 sha1-name.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  15. 03/15 blame.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  16. 08/15 merge-recursive.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  17. 09/15 merge.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  18. 15/15 cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switchNguyễn Thái Ngọc Duy, Jun 16, 2018
  19. Brandon WilliamsJun 18, 2018
  20. 02/15 apply.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  21. Junio C HamanoJun 25, 2018
  22. Duy NguyenJun 30, 2018
  23. Junio C HamanoJul 3, 2018
  24. Duy NguyenJul 9, 2018
  25. 07/15 entry.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  26. 06/15 diff.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  27. Elijah NewrenJun 17, 2018
  28. Duy NguyenJun 17, 2018
  29. Brandon WilliamsJun 18, 2018
  30. Ben PeartJun 19, 2018
  31. Derrick StoleeJun 19, 2018
  32. Duy NguyenJun 19, 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.