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

[PATCH v3 16/18] rerere: call conflict-ids IDs

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 17, 2015, 22:24 UTC
Message-ID
<1437171880-21590-17-git-send-email-gitster@pobox.com>
In-Reply-To
<1437171880-21590-1-git-send-email-gitster@pobox.com>

Most places we call conflict IDs "name" and some others we call them "hex"; update all of them to "id".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/rerere.c |  4 +--
 rerere.c         | 76 ++++++++++++++++++++++++++++----------------------------
 rerere.h         |  2 +-
 3 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 98eb8c5..81730bb 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -103,8 +103,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
 	} else if (!strcmp(argv[0], "diff"))
 		for (i = 0; i < merge_rr.nr; i++) {
 			const char *path = merge_rr.items[i].string;
-			const char *name = (const char *)merge_rr.items[i].util;
-			diff_two(rerere_path(name, "preimage"), path, path, path);
+			const char *id = (const char *)merge_rr.items[i].util;
+			diff_two(rerere_path(id, "preimage"), path, path, path);
 		}
 	else
 		usage_with_options(rerere_usage, options);
diff --git a/rerere.c b/rerere.c
index 30bdfeb..e68469a 100644
--- a/rerere.c
+++ b/rerere.c
@@ -22,15 +22,15 @@ static int rerere_autoupdate;
 
 static char *merge_rr_path;
 
-const char *rerere_path(const char *hex, const char *file)
+const char *rerere_path(const char *id, const char *file)
 {
-	return git_path("rr-cache/%s/%s", hex, file);
+	return git_path("rr-cache/%s/%s", id, file);
 }
 
-static int has_rerere_resolution(const char *hex)
+static int has_rerere_resolution(const char *id)
 {
 	struct stat st;
-	return !stat(rerere_path(hex, "postimage"), &st);
+	return !stat(rerere_path(id, "postimage"), &st);
 }
 
 /*
@@ -530,7 +530,7 @@ int rerere_remaining(struct string_list *merge_rr)
 }
 
 /*
- * Find the conflict identified by "name"; the change between its
+ * Find the conflict identified by "id"; the change between its
  * "preimage" (i.e. a previous contents with conflict markers) and its
  * "postimage" (i.e. the corresponding contents with conflicts
  * resolved) may apply cleanly to the contents stored in "path", i.e.
@@ -539,7 +539,7 @@ int rerere_remaining(struct string_list *merge_rr)
  * Returns 0 for successful replay of recorded resolution, or non-zero
  * for failure.
  */
-static int merge(const char *name, const char *path)
+static int merge(const char *id, const char *path)
 {
 	int ret;
 	mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0};
@@ -549,12 +549,12 @@ static int merge(const char *name, const char *path)
 	 * Normalize the conflicts in path and write it out to
 	 * "thisimage" temporary file.
 	 */
-	if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
+	if (handle_file(path, NULL, rerere_path(id, "thisimage")) < 0)
 		return 1;
 
-	if (read_mmfile(&cur, rerere_path(name, "thisimage")) ||
-	    read_mmfile(&base, rerere_path(name, "preimage")) ||
-	    read_mmfile(&other, rerere_path(name, "postimage"))) {
+	if (read_mmfile(&cur, rerere_path(id, "thisimage")) ||
+	    read_mmfile(&base, rerere_path(id, "preimage")) ||
+	    read_mmfile(&other, rerere_path(id, "postimage"))) {
 		ret = 1;
 		goto out;
 	}
@@ -571,9 +571,9 @@ static int merge(const char *name, const char *path)
 		 * A successful replay of recorded resolution.
 		 * Mark that "postimage" was used to help gc.
 		 */
-		if (utime(rerere_path(name, "postimage"), NULL) < 0)
+		if (utime(rerere_path(id, "postimage"), NULL) < 0)
 			warning("failed utime() on %s: %s",
-					rerere_path(name, "postimage"),
+					rerere_path(id, "postimage"),
 					strerror(errno));
 
 		/* Update "path" with the resolution */
@@ -631,11 +631,11 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
 			       struct string_list *update)
 {
 	const char *path = rr_item->string;
-	const char *name = (const char *)rr_item->util;
+	const char *id = (const char *)rr_item->util;
 
 	/* Is there a recorded resolution we could attempt to apply? */
-	if (has_rerere_resolution(name)) {
-		if (merge(name, path))
+	if (has_rerere_resolution(id)) {
+		if (merge(id, path))
 			return; /* failed to replay */
 
 		if (rerere_autoupdate)
@@ -646,7 +646,7 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
 				path);
 	} else if (!handle_file(path, NULL, NULL)) {
 		/* The user has resolved it. */
-		copy_file(rerere_path(name, "postimage"), path, 0666);
+		copy_file(rerere_path(id, "postimage"), path, 0666);
 		fprintf(stderr, "Recorded resolution for '%s'.\n", path);
 	} else {
 		return;
@@ -671,7 +671,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
 	 */
 	for (i = 0; i < conflict.nr; i++) {
 		unsigned char sha1[20];
-		char *hex;
+		char *id;
 		int ret;
 		const char *path = conflict.items[i].string;
 
@@ -686,8 +686,8 @@ static int do_plain_rerere(struct string_list *rr, int fd)
 		ret = handle_file(path, sha1, NULL);
 		if (ret < 1)
 			continue;
-		hex = xstrdup(sha1_to_hex(sha1));
-		string_list_insert(rr, path)->util = hex;
+		id = xstrdup(sha1_to_hex(sha1));
+		string_list_insert(rr, path)->util = id;
 
 		/*
 		 * If the directory does not exist, create
@@ -697,7 +697,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
 		 * NEEDSWORK: make sure "gc" does not remove
 		 * preimage without removing the directory.
 		 */
-		if (mkdir_in_gitdir(git_path("rr-cache/%s", hex)))
+		if (mkdir_in_gitdir(git_path("rr-cache/%s", id)))
 			continue;
 
 		/*
@@ -705,7 +705,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
 		 * conflict.  Ask handle_file() to write the
 		 * normalized contents to the "preimage" file.
 		 */
-		handle_file(path, NULL, rerere_path(hex, "preimage"));
+		handle_file(path, NULL, rerere_path(id, "preimage"));
 		fprintf(stderr, "Recorded preimage for '%s'\n", path);
 	}
 
@@ -779,7 +779,7 @@ int rerere(int flags)
 static int rerere_forget_one_path(const char *path, struct string_list *rr)
 {
 	const char *filename;
-	char *hex;
+	char *id;
 	unsigned char sha1[20];
 	int ret;
 	struct string_list_item *item;
@@ -793,8 +793,8 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
 		return error("Could not parse conflict hunks in '%s'", path);
 
 	/* Nuke the recorded resolution for the conflict */
-	hex = xstrdup(sha1_to_hex(sha1));
-	filename = rerere_path(hex, "postimage");
+	id = xstrdup(sha1_to_hex(sha1));
+	filename = rerere_path(id, "postimage");
 	if (unlink(filename))
 		return (errno == ENOENT
 			? error("no remembered resolution for %s", path)
@@ -805,7 +805,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
 	 * conflict in the working tree, run us again to record
 	 * the postimage.
 	 */
-	handle_cache(path, sha1, rerere_path(hex, "preimage"));
+	handle_cache(path, sha1, rerere_path(id, "preimage"));
 	fprintf(stderr, "Updated preimage for '%s'\n", path);
 
 	/*
@@ -814,7 +814,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
 	 */
 	item = string_list_insert(rr, path);
 	free(item->util);
-	item->util = hex;
+	item->util = id;
 	fprintf(stderr, "Forgot resolution for %s\n", path);
 	return 0;
 }
@@ -850,32 +850,32 @@ int rerere_forget(struct pathspec *pathspec)
 /*
  * Garbage collection support
  */
-static time_t rerere_created_at(const char *name)
+static time_t rerere_created_at(const char *id)
 {
 	struct stat st;
-	return stat(rerere_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
+	return stat(rerere_path(id, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
 }
 
-static time_t rerere_last_used_at(const char *name)
+static time_t rerere_last_used_at(const char *id)
 {
 	struct stat st;
-	return stat(rerere_path(name, "postimage"), &st) ? (time_t) 0 : st.st_mtime;
+	return stat(rerere_path(id, "postimage"), &st) ? (time_t) 0 : st.st_mtime;
 }
 
 /*
  * Remove the recorded resolution for a given conflict ID
  */
-static void unlink_rr_item(const char *name)
+static void unlink_rr_item(const char *id)
 {
-	unlink(rerere_path(name, "thisimage"));
-	unlink(rerere_path(name, "preimage"));
-	unlink(rerere_path(name, "postimage"));
+	unlink(rerere_path(id, "thisimage"));
+	unlink(rerere_path(id, "preimage"));
+	unlink(rerere_path(id, "postimage"));
 	/*
 	 * NEEDSWORK: what if this rmdir() fails?  Wouldn't we then
 	 * assume that we already have preimage recorded in
 	 * do_plain_rerere()?
 	 */
-	rmdir(git_path("rr-cache/%s", name));
+	rmdir(git_path("rr-cache/%s", id));
 }
 
 void rerere_gc(struct string_list *rr)
@@ -930,9 +930,9 @@ void rerere_clear(struct string_list *merge_rr)
 	int i;
 
 	for (i = 0; i < merge_rr->nr; i++) {
-		const char *name = (const char *)merge_rr->items[i].util;
-		if (!has_rerere_resolution(name))
-			unlink_rr_item(name);
+		const char *id = (const char *)merge_rr->items[i].util;
+		if (!has_rerere_resolution(id))
+			unlink_rr_item(id);
 	}
 	unlink_or_warn(git_path("MERGE_RR"));
 }
diff --git a/rerere.h b/rerere.h
index 2956c2e..f998eba 100644
--- a/rerere.h
+++ b/rerere.h
@@ -17,7 +17,7 @@ extern void *RERERE_RESOLVED;
 
 extern int setup_rerere(struct string_list *, int);
 extern int rerere(int);
-extern const char *rerere_path(const char *hex, const char *file);
+extern const char *rerere_path(const char *id, const char *file);
 extern int rerere_forget(struct pathspec *);
 extern int rerere_remaining(struct string_list *);
 extern void rerere_clear(struct string_list *);
-- 
2.5.0-rc2-340-g0cccc16
Previous: Junio C HamanoNext: Junio C Hamano
Message 36 of 39 in “"rerere" minor clean-up”
  1. 00/13 "rerere" minor clean-upJunio C Hamano, Jul 1, 2015
  2. 01/13 rerere: fix an off-by-one non-bugJunio C Hamano, Jul 1, 2015
  3. 02/13 rerere: plug conflict ID leaksJunio C Hamano, Jul 1, 2015
  4. 03/13 rerere: lift PATH_MAX limitationJunio C Hamano, Jul 1, 2015
  5. 04/13 rerere: write out each record of MERGE_RR in one goJunio C Hamano, Jul 1, 2015
  6. 05/13 rerere: report autoupdated paths only after actually updating themJunio C Hamano, Jul 1, 2015
  7. 06/13 rerere: drop want_sp parameter from is_cmarker()Junio C Hamano, Jul 1, 2015
  8. 07/13 rerere: stop looping unnecessarilyJunio C Hamano, Jul 1, 2015
  9. 08/13 rerere: explain the rerere I/O abstractionJunio C Hamano, Jul 1, 2015
  10. 09/13 rerere: explain MERGE_RR management helpersJunio C Hamano, Jul 1, 2015
  11. 10/13 rerere: explain the primary codepathJunio C Hamano, Jul 1, 2015
  12. 11/13 rerere: explain "rerere forget" codepathJunio C Hamano, Jul 1, 2015
  13. 12/13 rerere: explain the remainderJunio C Hamano, Jul 1, 2015
  14. 13/13 rerere: refactor "replay" part of do_plain_rerere()Junio C Hamano, Jul 1, 2015
  15. 00/18 "rerere" preparatory clean-upJunio C Hamano, Jul 17, 2015
  16. 01/18 rerere: fix an off-by-one non-bugJunio C Hamano, Jul 17, 2015
  17. Junio C HamanoJul 24, 2015
  18. 02/18 rerere: plug conflict ID leaksJunio C Hamano, Jul 17, 2015
  19. 03/18 rerere: lift PATH_MAX limitationJunio C Hamano, Jul 17, 2015
  20. 04/18 rerere: write out each record of MERGE_RR in one goJunio C Hamano, Jul 17, 2015
  21. 05/18 rerere: report autoupdated paths only after actually updating themJunio C Hamano, Jul 17, 2015
  22. 06/18 rerere: drop want_sp parameter from is_cmarker()Junio C Hamano, Jul 17, 2015
  23. Philip OakleyJul 18, 2015
  24. Eric SunshineJul 18, 2015
  25. 07/18 rerere: stop looping unnecessarilyJunio C Hamano, Jul 17, 2015
  26. Junio C HamanoJul 24, 2015
  27. 08/18 rerere: explain the rerere I/O abstractionJunio C Hamano, Jul 17, 2015
  28. Junio C HamanoJul 24, 2015
  29. 09/18 rerere: explain MERGE_RR management helpersJunio C Hamano, Jul 17, 2015
  30. 10/18 rerere: explain the primary codepathJunio C Hamano, Jul 17, 2015
  31. 11/18 rerere: explain "rerere forget" codepathJunio C Hamano, Jul 17, 2015
  32. 12/18 rerere: explain the remainderJunio C Hamano, Jul 17, 2015
  33. 13/18 rerere: refactor "replay" part of do_plain_rerere()Junio C Hamano, Jul 17, 2015
  34. 14/18 rerere: further de-dent do_plain_rerere()Junio C Hamano, Jul 17, 2015
  35. 15/18 rerere: further clarify do_rerere_one_path()Junio C Hamano, Jul 17, 2015
  36. 16/18 rerere: call conflict-ids IDsJunio C Hamano, Jul 17, 2015
  37. 17/18 rerere: use "struct rerere_id" instead of "char *" for conflict IDJunio C Hamano, Jul 17, 2015
  38. Eric SunshineJul 18, 2015
  39. 18/18 rerere: un-nest merge() furtherJunio C Hamano, Jul 17, 2015

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.