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

[PATCH 3/5] merge-recursive: clarify the rename_dir/RENAME_DIR meaning

From
Elijah Newren <newren@gmail.com>
Date
May 19, 2018, 02:06 UTC
Message-ID
<20180519020700.2241-4-newren@gmail.com>
In-Reply-To
<20180519020700.2241-1-newren@gmail.com>

We had an enum of rename types which included RENAME_DIR; this name felt misleading since it was not about an entire directory but was a status for each individual file add that occurred within a renamed directory. Since this type is for signifying that the files in question were being renamed due to directory rename detection, rename this enum value to RENAME_VIA_DIR. Make a similar change to the conflict_rename_dir() function, and add a comment to the top of that function explaining its purpose (it may not be quite as obvious as for the other conflict_rename_*() functions).

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-recursive.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 01306c87eb..d30085d9c7 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -180,7 +180,7 @@ static int oid_eq(const struct object_id *a, const struct object_id *b)
 
 enum rename_type {
 	RENAME_NORMAL = 0,
-	RENAME_DIR,
+	RENAME_VIA_DIR,
 	RENAME_DELETE,
 	RENAME_ONE_FILE_TO_ONE,
 	RENAME_ONE_FILE_TO_TWO,
@@ -1224,11 +1224,17 @@ static int merge_file_one(struct merge_options *o,
 	return merge_file_1(o, &one, &a, &b, path, branch1, branch2, mfi);
 }
 
-static int conflict_rename_dir(struct merge_options *o,
-			       struct diff_filepair *pair,
-			       const char *rename_branch,
-			       const char *other_branch)
+static int conflict_rename_via_dir(struct merge_options *o,
+				   struct diff_filepair *pair,
+				   const char *rename_branch,
+				   const char *other_branch)
 {
+	/*
+	 * Handle file adds that need to be renamed due to directory rename
+	 * detection.  This differs from handle_rename_normal, because
+	 * there is no content merge to do; just move the path into the
+	 * desired final location.
+	 */
 	const struct diff_filespec *dest = pair->two;
 
 	if (!o->call_depth && would_lose_untracked(dest->path)) {
@@ -2498,7 +2504,7 @@ static int process_renames(struct merge_options *o,
 
 			if (oid_eq(&src_other.oid, &null_oid) &&
 			    ren1->add_turned_into_rename) {
-				setup_rename_conflict_info(RENAME_DIR,
+				setup_rename_conflict_info(RENAME_VIA_DIR,
 							   ren1->pair,
 							   NULL,
 							   branch1,
@@ -2944,12 +2950,12 @@ static int process_entry(struct merge_options *o,
 							     b_oid, b_mode,
 							     conflict_info);
 			break;
-		case RENAME_DIR:
+		case RENAME_VIA_DIR:
 			clean_merge = 1;
-			if (conflict_rename_dir(o,
-						conflict_info->pair1,
-						conflict_info->branch1,
-						conflict_info->branch2))
+			if (conflict_rename_via_dir(o,
+						    conflict_info->pair1,
+						    conflict_info->branch1,
+						    conflict_info->branch2))
 				clean_merge = -1;
 			break;
 		case RENAME_DELETE:
-- 
2.17.0.847.g20b8963732
Previous: Elijah NewrenNext: Johannes Schindelin
Message 11 of 27 in “merge-recursive code cleanups”
  1. 0/5 merge-recursive code cleanupsElijah Newren, May 19, 2018
  2. 1/5 merge-recursive: fix miscellaneous grammar error in commentElijah Newren, May 19, 2018
  3. 5/5 merge-recursive: simplify handle_change_deleteElijah Newren, May 19, 2018
  4. Johannes SixtMay 19, 2018
  5. Elijah NewrenMay 19, 2018
  6. Johannes SchindelinMay 21, 2018
  7. Elijah NewrenMay 21, 2018
  8. 2/5 merge-recursive: fix numerous argument alignment issuesElijah Newren, May 19, 2018
  9. Johannes SchindelinMay 21, 2018
  10. Elijah NewrenMay 21, 2018
  11. 3/5 merge-recursive: clarify the rename_dir/RENAME_DIR meaningElijah Newren, May 19, 2018
  12. Johannes SchindelinMay 21, 2018
  13. 4/5 merge-recursive: rename conflict_rename_*() family of functionsElijah Newren, May 19, 2018
  14. Johannes SchindelinMay 21, 2018
  15. 0/5 merge-recursive code cleanupsElijah Newren, May 22, 2018
  16. 4/5 merge-recursive: rename conflict_rename_*() family of functionsElijah Newren, May 22, 2018
  17. 5/5 merge-recursive: add pointer about unduly complex looking codeElijah Newren, May 22, 2018
  18. 1/5 merge-recursive: fix miscellaneous grammar error in commentElijah Newren, May 22, 2018
  19. 2/5 merge-recursive: fix numerous argument alignment issuesElijah Newren, May 22, 2018
  20. 3/5 merge-recursive: clarify the rename_dir/RENAME_DIR meaningElijah Newren, May 22, 2018
  21. 0/6 merge-recursive code cleanupsElijah Newren, Jun 10, 2018
  22. 1/6 merge-recursive: fix miscellaneous grammar error in commentElijah Newren, Jun 10, 2018
  23. 2/6 merge-recursive: fix numerous argument alignment issuesElijah Newren, Jun 10, 2018
  24. 4/6 merge-recursive: clarify the rename_dir/RENAME_DIR meaningElijah Newren, Jun 10, 2018
  25. 3/6 merge-recursive: align labels with their respective code blocksElijah Newren, Jun 10, 2018
  26. 6/6 merge-recursive: add pointer about unduly complex looking codeElijah Newren, Jun 10, 2018
  27. 5/6 merge-recursive: rename conflict_rename_*() family of functionsElijah Newren, Jun 10, 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.