All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org, newren@gmail.com, szeder.dev@gmail.com
Subject: Re: [PATCH v2] merge-recursive: symlink's descendants not in way
Date: Fri, 20 Sep 2019 10:15:25 -0700	[thread overview]
Message-ID: <xmqqzhiyvqhe.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190918202738.57273-1-jonathantanmy@google.com> (Jonathan Tan's message of "Wed, 18 Sep 2019 13:27:38 -0700")

Jonathan Tan <jonathantanmy@google.com> writes:

> When the working tree has:
>  - bar (directory)
>  - bar/file (file)
>  - foo (symlink to .)
>
> (note that lstat() for "foo/bar" would tell us that it is a directory)
>
> and the user merges a commit that deletes the foo symlink and instead
> contains:
>  - bar (directory, as above)
>  - bar/file (file, as above)
>  - foo (directory)
>  - foo/bar (file)
>
> the merge should happen without requiring user intervention.

Thanks.  That clears my previous confusion.  It is clear that the
desired outcome is that bar/file will be merged with itself, foo
itself will resolve to "deleted", and foo/bar will be created.

> However, this does not happen.

OK.  We notice that we need to newly create foo/bar but we
incorrectly find that there is "foo/bar" already because of the
careless use of bare lstat(2) makes "bar" visible as if it were also
"foo/bar".  I wonder if the current code would be confused the same
way if the side branch added "foo/bar/file", or the confusion would
be even worse---it is not dir_in_way() and a different codepath
would be affected, no?

> diff --git a/merge-recursive.c b/merge-recursive.c
> index 6b812d67e3..22a12cfeba 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -764,7 +764,8 @@ static int dir_in_way(struct index_state *istate, const char *path,
>  
>  	strbuf_release(&dirpath);
>  	return check_working_copy && !lstat(path, &st) && S_ISDIR(st.st_mode) &&
> -		!(empty_ok && is_empty_dir(path));
> +		!(empty_ok && is_empty_dir(path)) &&
> +		!has_symlink_leading_path(path, strlen(path));

As the new call is fairly heavyweight compared to everything else we
are doing, I think it is very sensible to have this at the end, like
this patch does.

Nicely done.  Thanks, will queue.

  parent reply	other threads:[~2019-09-20 17:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <https://public-inbox.org/git/20190917215040.132503-1-jonathantanmy@google.com/>
2019-09-18 20:27 ` [PATCH v2] merge-recursive: symlink's descendants not in way Jonathan Tan
2019-09-18 21:54   ` Elijah Newren
2019-09-20 17:15   ` Junio C Hamano [this message]
2019-09-20 20:25     ` Jonathan Tan
2019-09-20 20:38       ` Junio C Hamano
2019-09-20 20:50         ` Jonathan Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqzhiyvqhe.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.com \
    --cc=newren@gmail.com \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.