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

Re: [PATCH] difftool: handle changing symlinks in dir-diff mode

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 13, 2017, 18:32 UTC
Message-ID
<xmqqlgs9rprt.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170313175640.14106-1-davvid@gmail.com>
David Aguilar <davvid@gmail.com> writes:
Show 10 quoted lines
> Detect the null object ID for symlinks in dir-diff so that difftool can
> prepare temporary files that matches how git handles symlinks.
>
> Previously, a null object ID would crash difftool.  We now detect null
> object IDs and write the symlink's content into the temporary symlink
> stand-in file.
>
> Original-patch-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---

I would have appreciated (and I suspect other reviewers would, too) a bit of back-story wrt how "Original-patch-by" resulted in this patch after the three-dashes line. It is perfectly fine if you two coordinated privately; I mostly wanted to hear something like "Dscho has been working on this and I asked him if it is OK to take over his WIP to produce a quick-fix we can ship on the maint branch, here is the result of that collaboration." IOW, the person who is named as the original author is fine to be named like so (I care only because I do not think we saw the "original" here on the list).

> +static int create_symlink_file(struct cache_entry* ce, struct checkout* state)
Asterisk sticks to variable, not type.
> +{
> +	/*
> +	 * Dereference a worktree symlink and writes its contents
s/writes/write/
Show 12 quoted lines
> +	 * 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? A symbolic link that is not changed on the right-hand side of the comparison (i.e. S_ISLNK(rmode) && !is_null_oid(&roid)) would go to checkout_entry() which

 - creates a symbolic link, on a filesystem that supports symlink; or
 - writes the stand-in file on a filesystem that does not.

which is the right thing. It seems that the other side of "if (!use_wt_file())" if/elseif/... cascade also does the right thing manually.

Shouldn't this helper also do the same (i.e. create symlink and fall back to stand-in)?

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?

Previous: David AguilarNext: Johannes Schindelin
Message 9 of 17 in “fatal error when diffing changed symlinks”
  1. Christophe MacabiauFeb 24, 2017
  2. Junio C HamanoFeb 24, 2017
  3. Junio C HamanoFeb 24, 2017
  4. Jeff KingFeb 24, 2017
  5. Johannes SchindelinFeb 25, 2017
  6. Junio C HamanoMar 7, 2017
  7. Johannes SchindelinMar 7, 2017
  8. difftool: handle changing symlinks in dir-diff modeDavid Aguilar, Mar 13, 2017
  9. Junio C HamanoMar 13, 2017
  10. Johannes SchindelinMar 13, 2017
  11. Johannes SchindelinMar 13, 2017
  12. Junio C HamanoMar 13, 2017
  13. David AguilarMar 14, 2017
  14. Junio C HamanoMar 14, 2017
  15. Junio C HamanoMar 14, 2017
  16. Junio C HamanoMar 13, 2017
  17. Johannes SchindelinMar 13, 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.