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

[PATCH v3 0/6] merge-recursive code cleanups

From
Elijah Newren <newren@gmail.com>
Date
Jun 10, 2018, 04:16 UTC
Message-ID
<20180610041616.4448-1-newren@gmail.com>
In-Reply-To
<20180522004327.13085-1-newren@gmail.com>

This patch series contains several small code cleanups for merge-recursive.

Changes since v2:
  * Now built on master (the topics this depended on have graduated);
    merges cleanly with next and pu.
  * Patch #2 has a few additional argument alignment fixes; some in
    code added by topics that have since graduated, and a couple that
    were overlooked previously.
  * Patch #3 is entirely new.
  * Re-wrapped the commit message of the final patch.
  (range-diff below)
Elijah Newren (6):
  merge-recursive: fix miscellaneous grammar error in comment
  merge-recursive: fix numerous argument alignment issues
  merge-recursive: align labels with their respective code blocks
  merge-recursive: clarify the rename_dir/RENAME_DIR meaning
  merge-recursive: rename conflict_rename_*() family of functions
  merge-recursive: add pointer about unduly complex looking code
 merge-recursive.c | 186 ++++++++++++++++++++++++++--------------------
 1 file changed, 104 insertions(+), 82 deletions(-)
range-diff against v2:
 1: 4222f174de =  1: 4222f174de merge-recursive: fix miscellaneous grammar error in comment
 2: 4ebf93822d !  2: 284a5fee3d merge-recursive: fix numerous argument alignment issues
    @@ -33,6 +33,76 @@
      {
      	struct path_hashmap_entry *entry;
      	int baselen = base->len;
    +@@
    + 	 */
    + 	if (would_lose_untracked(path))
    + 		return err(o, _("refusing to lose untracked file at '%s'"),
    +-			     path);
    ++			   path);
    + 
    + 	/* Successful unlink is good.. */
    + 	if (!unlink(path))
    +@@
    + 			unlink(path);
    + 			if (symlink(lnk, path))
    + 				ret = err(o, _("failed to symlink '%s': %s"),
    +-					path, strerror(errno));
    ++					  path, strerror(errno));
    + 			free(lnk);
    + 		} else
    + 			ret = err(o,
    +@@
    + }
    + 
    + static int find_first_merges(struct object_array *result, const char *path,
    +-		struct commit *a, struct commit *b)
    ++			     struct commit *a, struct commit *b)
    + {
    + 	int i, j;
    + 	struct object_array merges = OBJECT_ARRAY_INIT;
    +@@
    + 
    + 	/* get all revisions that merge commit a */
    + 	xsnprintf(merged_revision, sizeof(merged_revision), "^%s",
    +-			oid_to_hex(&a->object.oid));
    ++		  oid_to_hex(&a->object.oid));
    + 	init_revisions(&revs, NULL);
    + 	rev_opts.submodule = path;
    + 	/* FIXME: can't handle linked worktrees in submodules yet */
    +@@
    + 		output(o, 2, _("Found a possible merge resolution for the submodule:\n"));
    + 		print_commit((struct commit *) merges.objects[0].item);
    + 		output(o, 2, _(
    +-			"If this is correct simply add it to the index "
    +-			"for example\n"
    +-			"by using:\n\n"
    +-			"  git update-index --cacheinfo 160000 %s \"%s\"\n\n"
    +-			"which will accept this suggestion.\n"),
    +-			oid_to_hex(&merges.objects[0].item->oid), path);
    ++		       "If this is correct simply add it to the index "
    ++		       "for example\n"
    ++		       "by using:\n\n"
    ++		       "  git update-index --cacheinfo 160000 %s \"%s\"\n\n"
    ++		       "which will accept this suggestion.\n"),
    ++		       oid_to_hex(&merges.objects[0].item->oid), path);
    + 		break;
    + 
    + 	default:
    +@@
    + 			result->clean = (merge_status == 0);
    + 		} else if (S_ISGITLINK(a->mode)) {
    + 			result->clean = merge_submodule(o, &result->oid,
    +-						       one->path,
    +-						       &one->oid,
    +-						       &a->oid,
    +-						       &b->oid);
    ++							one->path,
    ++							&one->oid,
    ++							&a->oid,
    ++							&b->oid);
    + 		} else if (S_ISLNK(a->mode)) {
    + 			switch (o->recursive_variant) {
    + 			case MERGE_RECURSIVE_NORMAL:
     @@
      }
      
--: ---------- >  3: 6bae2a267f merge-recursive: align labels with their respective code blocks
 3: 585759f07a =  4: aecf1267d8 merge-recursive: clarify the rename_dir/RENAME_DIR meaning
 4: 3cfb8b01b8 =  5: f7637bef12 merge-recursive: rename conflict_rename_*() family of functions
 5: d2a24f5b38 !  6: ffeb3ef585 merge-recursive: add pointer about unduly complex looking code
    @@ -3,10 +3,11 @@
         merge-recursive: add pointer about unduly complex looking code
     
         handle_change_delete() has a block of code displaying one of four nearly
    -    identical messages.  Each contains about half a dozen variable interpolations,
    -    which use nearly identical variables as well.  Someone trying to parse this
    -    may be slowed down trying to parse the differences and why they are here; help
    -    them out by adding a comment explaining the differences.
    +    identical messages.  Each contains about half a dozen variable
    +    interpolations, which use nearly identical variables as well.  Someone
    +    trying to parse this may be slowed down trying to parse the differences
    +    and why they are here; help them out by adding a comment explaining the
    +    differences.
     
         Further, point out that this code structure isn't collapsed into something
         more concise and readable for the programmer, because we want to keep full
-- 
2.18.0.rc1.6.gffeb3ef585
Previous: Elijah NewrenNext: Elijah Newren
Message 21 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.