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

[PATCH v3 2/7] merge-ort: drop unnecessary temporary in check_for_directory_rename()

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 6, 2025, 23:15 UTC
Message-ID
<58df0710efc042b014a0c8282ce1d7fa62fbb760.1754522123.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1943.v3.git.1754522122.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

check_for_directory_rename() had a weirdly coded check for whether a strmap contained a certain key. Replace the temporary variable and call to strmap_get_entry() with the more natural strmap_contains() call.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/merge-ort.c b/merge-ort.c
index d87ba6dd42bf..9b9d82ed10f7 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -2580,7 +2580,6 @@ static char *check_for_directory_rename(struct merge_options *opt,
 {
 	char *new_path;
 	struct strmap_entry *rename_info;
-	struct strmap_entry *otherinfo;
 	const char *new_dir;
 	int other_side = 3 - side_index;
 
@@ -2615,14 +2614,13 @@ static char *check_for_directory_rename(struct merge_options *opt,
 	 * to not let Side1 do the rename to dumbdir, since we know that is
 	 * the source of one of our directory renames.
 	 *
-	 * That's why otherinfo and dir_rename_exclusions is here.
+	 * That's why dir_rename_exclusions is here.
 	 *
 	 * As it turns out, this also prevents N-way transient rename
 	 * confusion; See testcases 9c and 9d of t6423.
 	 */
 	new_dir = rename_info->value; /* old_dir = rename_info->key; */
-	otherinfo = strmap_get_entry(dir_rename_exclusions, new_dir);
-	if (otherinfo) {
+	if (strmap_contains(dir_rename_exclusions, new_dir)) {
 		path_msg(opt, INFO_DIR_RENAME_SKIPPED_DUE_TO_RERENAME, 1,
 			 rename_info->key, path, new_dir, NULL,
 			 _("WARNING: Avoiding applying %s -> %s rename "
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 34 of 39 in “Fix various rename corner cases”
  1. 0/6 Fix various rename corner casesElijah Newren via GitGitGadget, Jul 22, 2025
  2. 1/6 merge-ort: update comments to modern testfile locationElijah Newren via GitGitGadget, Jul 22, 2025
  3. 2/6 merge-ort: drop unnecessary temporary in check_for_directory_rename()Elijah Newren via GitGitGadget, Jul 22, 2025
  4. 3/6 t6423: document two bugs with rename-to-self testcasesElijah Newren via GitGitGadget, Jul 22, 2025
  5. Patrick SteinhardtAug 1, 2025
  6. Elijah NewrenAug 4, 2025
  7. Patrick SteinhardtAug 5, 2025
  8. Elijah NewrenAug 5, 2025
  9. 4/6 t6423: fix missed staging of file in testcases 12i,12j,12kElijah Newren via GitGitGadget, Jul 22, 2025
  10. Patrick SteinhardtAug 1, 2025
  11. Elijah NewrenAug 4, 2025
  12. Patrick SteinhardtAug 5, 2025
  13. Elijah NewrenAug 5, 2025
  14. 5/6 merge-ort: fix incorrect file handlingElijah Newren via GitGitGadget, Jul 22, 2025
  15. Patrick SteinhardtAug 1, 2025
  16. Elijah NewrenAug 4, 2025
  17. Patrick SteinhardtAug 5, 2025
  18. Elijah NewrenAug 5, 2025
  19. 6/6 merge-ort: fix directory rename on top of source of other rename/deleteElijah Newren via GitGitGadget, Jul 22, 2025
  20. Patrick SteinhardtAug 1, 2025
  21. Elijah NewrenAug 4, 2025
  22. Patrick SteinhardtAug 1, 2025
  23. 0/6 Fix various rename corner casesElijah Newren via GitGitGadget, Aug 5, 2025
  24. 1/6 merge-ort: update comments to modern testfile locationElijah Newren via GitGitGadget, Aug 5, 2025
  25. 2/6 merge-ort: drop unnecessary temporary in check_for_directory_rename()Elijah Newren via GitGitGadget, Aug 5, 2025
  26. 3/6 t6423: document two bugs with rename-to-self testcasesElijah Newren via GitGitGadget, Aug 5, 2025
  27. 4/6 t6423: fix missed staging of file in testcases 12i,12j,12kElijah Newren via GitGitGadget, Aug 5, 2025
  28. 5/6 merge-ort: fix incorrect file handlingElijah Newren via GitGitGadget, Aug 5, 2025
  29. 6/6 merge-ort: fix directory rename on top of source of other rename/deleteElijah Newren via GitGitGadget, Aug 5, 2025
  30. Junio C HamanoAug 5, 2025
  31. Elijah NewrenAug 5, 2025
  32. 0/7 Fix various rename corner casesElijah Newren via GitGitGadget, Aug 6, 2025
  33. 1/7 merge-ort: update comments to modern testfile locationElijah Newren via GitGitGadget, Aug 6, 2025
  34. 2/7 merge-ort: drop unnecessary temporary in check_for_directory_rename()Elijah Newren via GitGitGadget, Aug 6, 2025
  35. 3/7 t6423: document two bugs with rename-to-self testcasesElijah Newren via GitGitGadget, Aug 6, 2025
  36. 4/7 t6423: fix missed staging of file in testcases 12i,12j,12kElijah Newren via GitGitGadget, Aug 6, 2025
  37. 5/7 merge-ort: clarify the interning of strings in opt->priv->pathElijah Newren via GitGitGadget, Aug 6, 2025
  38. 6/7 merge-ort: fix incorrect file handlingElijah Newren via GitGitGadget, Aug 6, 2025
  39. 7/7 merge-ort: fix directory rename on top of source of other rename/deleteElijah Newren via GitGitGadget, Aug 6, 2025

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.