git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: David Aguilar <davvid@gmail.com>,
	Christophe Macabiau <christophemacabiau@gmail.com>,
	Git ML <git@vger.kernel.org>
Subject: Re: [PATCH] difftool: handle changing symlinks in dir-diff mode
Date: Mon, 13 Mar 2017 22:27:30 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1703132204410.3767@virtualbox> (raw)
In-Reply-To: <xmqqlgs9rprt.fsf@gitster.mtv.corp.google.com>

Hi Junio,

On Mon, 13 Mar 2017, Junio C Hamano wrote:

> David Aguilar <davvid@gmail.com> writes:
> 
> > +static int create_symlink_file(struct cache_entry* ce, struct checkout* state)
> 
> Asterisk sticks to variable, not type.

If only we had tools to format the code so that authors as well as
reviewers could concentrate on essential parts of the patches :-)

> > +	 * into the checkout state's path.
> > +	 */
> > +	struct strbuf path = STRBUF_INIT;
> > +	struct strbuf link = STRBUF_INIT;
> > +
> > +	int ok = 0;
> > +
> > +	if (strbuf_readlink(&link, ce->name, ce_namelen(ce)) == 0) {
> > +		strbuf_add(&path, state->base_dir, state->base_dir_len);
> > +		strbuf_add(&path, ce->name, ce_namelen(ce));
> > +
> > +		write_file_buf(path.buf, link.buf, link.len);
> 
> This does "write content into symlink stand-in file", but why?

From the commit message:

	> Detect the null object ID for symlinks in dir-diff so that
	> difftool can prepare temporary files that matches how git
	> handles symlinks.

The obvious connection: when core.symlinks = false, Git already falls back
to writing plain files with the link target as contents. This function
does the same, for the same motivation: it is the best we can do in this
case.

> Also, I am not sure if strbuf_readlink() can unconditionally used
> here.  On a filesystem without symbolic link, the working tree
> entity that corresponds to the ce that represents a symlink is a
> stand-in regular file, so shouldn't we be opening it as a regular
> file and reading its contents in that case?

I think you are right, we cannot simply call strbuf_readlink(), we would
have to check the core_symlinks variable to maybe read the file contents
instead.

But then, it may not be appropriate to read the worktree to begin with...
see my reply to the patch that I will send out in a couple of minutes.

Ciao,
Johannes

  parent reply	other threads:[~2017-03-13 21:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-24 11:47 fatal error when diffing changed symlinks Christophe Macabiau
2017-02-24 17:53 ` Junio C Hamano
2017-02-24 19:51   ` Junio C Hamano
2017-02-24 20:35     ` Jeff King
2017-02-25 12:36       ` Johannes Schindelin
2017-03-07 18:16         ` Junio C Hamano
2017-03-07 22:34           ` Johannes Schindelin
2017-03-13 17:56             ` [PATCH] difftool: handle changing symlinks in dir-diff mode David Aguilar
2017-03-13 18:32               ` Junio C Hamano
2017-03-13 21:04                 ` Johannes Schindelin
2017-03-13 21:27                 ` Johannes Schindelin [this message]
2017-03-13 21:33                   ` Junio C Hamano
2017-03-14  2:20                     ` David Aguilar
2017-03-14  5:52                       ` Junio C Hamano
2017-03-14  4:13                 ` Junio C Hamano
2017-03-13 19:02               ` Junio C Hamano
2017-03-13 21:36               ` Johannes Schindelin

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1703132204410.3767@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=christophemacabiau@gmail.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
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).