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

Re: -X theirs does not resolve symlink conflict Was: BUG: merge -s theirs is not in effect

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 26, 2017, 02:39 UTC
Message-ID
<xmqqa81ichdu.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqefqucigh.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> I do not recall people talking about symbolic links but the case of
>> binary files has been on the wishlist for a long time, and I do not
>> know of anybody who is working on (or is planning to work on) it.
>
> Ah, I misremembered.
>
> We've addressed the "binary files" case back in 2012 with a944af1d
> ("merge: teach -Xours/-Xtheirs to binary ll-merge driver",
> 2012-09-08).  I do not know offhand if it is just as easy to plumb
> the MERGE_FAVOR_{OURS,THEIRS} bits thru the symbolic link codepath,
> like that patch did to the binary file codepath.

Perhaps the attached (totally untested) patch might be a good starting point. I do not know if you are interested in hacking on Git, and I do not feel offended if you are not, but perhaps somebody else might get interested in seeing if this #leftoverbits is a good direction to go in, and finishing it with docs and tests if it is ;-)

 merge-recursive.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 1d3f8f0d22..3605275ca3 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1026,10 +1026,19 @@ static int merge_file_1(struct merge_options *o,
 						       &b->oid,
 						       !o->call_depth);
 		} else if (S_ISLNK(a->mode)) {
-			oidcpy(&result->oid, &a->oid);
-
-			if (!oid_eq(&a->oid, &b->oid))
-				result->clean = 0;
+			switch (o->recursive_variant) {
+			case MERGE_RECURSIVE_NORMAL:
+				oidcpy(&result->oid, &a->oid);
+				if (!oid_eq(&a->oid, &b->oid))
+					result->clean = 0;
+				break;
+			case MERGE_RECURSIVE_OURS:
+				oidcpy(&result->oid, &a->oid);
+				break;
+			case MERGE_RECURSIVE_THEIRS:
+				oidcpy(&result->oid, &b->oid);
+				break;
+			}
 		} else
 			die("BUG: unsupported object type in the tree");
 	}
Previous: Junio C HamanoNext: Yaroslav Halchenko
Message 8 of 19 in “BUG: merge -s theirs is not in effect (does the same as -s ours)”
  1. Yaroslav HalchenkoSep 25, 2017
  2. Junio C HamanoSep 25, 2017
  3. Yaroslav HalchenkoSep 25, 2017
  4. Re* BUG: merge -s theirs is not in effect (does the same as -s ours)Junio C Hamano, Sep 25, 2017
  5. -X theirs does not resolve symlink conflict Was: BUG: merge -s theirs is not in effectYaroslav Halchenko, Sep 25, 2017
  6. Junio C HamanoSep 26, 2017
  7. Junio C HamanoSep 26, 2017
  8. Junio C HamanoSep 26, 2017
  9. Yaroslav HalchenkoSep 26, 2017
  10. merge: teach -Xours/-Xtheirs to symbolic link mergeJunio C Hamano, Oct 16, 2017
  11. Elijah NewrenDec 29, 2017
  12. Yaroslav HalchenkoDec 29, 2017
  13. external diff driver is not used for diff --stat?Yaroslav Halchenko, Jan 25, 2018
  14. -s theirs use-case(s) Was: BUG: merge -s theirs is not in effectYaroslav Halchenko, Sep 25, 2017
  15. Junio C HamanoSep 26, 2017
  16. Yaroslav HalchenkoSep 26, 2017
  17. Junio C HamanoSep 27, 2017
  18. Yaroslav HalchenkoSep 27, 2017
  19. Yaroslav HalchenkoSep 27, 2017

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.