git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* merge-recursive thinks symlink's child dirs are "real"
@ 2019-09-16 21:47 Jonathan Tan
  2019-09-16 22:15 ` SZEDER Gábor
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Jonathan Tan @ 2019-09-16 21:47 UTC (permalink / raw)
  To: git; +Cc: Jonathan Tan

This was raised by a coworker at $DAYJOB. I run the following script:

  $GIT init test && cd test
  ln -s . foo
  mkdir bar && touch bar/file
  $GIT add foo bar/file
  $GIT commit -m "foo symlink"
  
  $GIT checkout -b branch1
  $GIT commit --allow-empty -m "empty commit"
  
  $GIT checkout master
  $GIT rm foo
  mkdir foo
  (cd foo; ln -s ../bar bar)
  $GIT add foo/bar
  $GIT commit -m "replace foo symlink with real foo dir and foo/bar symlink"
  
  $GIT checkout branch1
  $GIT cherry-pick master

The cherry-pick must be manually resolved, when I would expect it to
happen without needing user intervention.

You can see that at the point of the cherry-pick, in the working
directory, ./foo is a symlink and ./foo/bar is a directory. I traced the
code that ran during the cherry-pick to process_entry() in
merge-recursive.c. When processing "foo/bar", control flow correctly
reaches "Case B: Added in one", but the dir_in_way() invocation returns
true, since lstat() indeed reveals that "foo/bar" is a directory. If I
hardcode dir_in_way() to return false, then the cherry-pick happens
without needing user intervention. I checked with "ls-tree -r" and the
resulting tree is as I expect (foo is a real dir, foo/bar is a symlink).

Is this use case something that Git should be able to handle, and if
yes, is the correct solution to teach dir_in_way() that dirs reachable
from symlinks are not really in the way (presumably the implementation
would climb directories until we reach the root or we reach a filesystem
boundary, similar to what we do when we search for the .git directory)?
Also, my proposed solution would work in the specific use case outlined
in the script above, but can anyone think offhand of a case that it
would make worse?

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-09-18  0:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-16 21:47 merge-recursive thinks symlink's child dirs are "real" Jonathan Tan
2019-09-16 22:15 ` SZEDER Gábor
2019-09-17 15:54   ` Elijah Newren
2019-09-17  0:09 ` Jonathan Nieder
2019-09-17 16:02   ` Elijah Newren
2019-09-17 15:48 ` Elijah Newren
2019-09-17 21:50   ` [RFC PATCH] merge-recursive: symlink's descendants not in way Jonathan Tan
2019-09-17 22:23     ` Junio C Hamano
2019-09-17 22:32       ` Jonathan Tan
2019-09-17 22:37         ` Junio C Hamano
2019-09-17 22:49           ` Jonathan Tan
2019-09-17 23:02     ` SZEDER Gábor
2019-09-18  0:35     ` Elijah Newren

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).