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, 19:02 UTC
Message-ID
<xmqqh92xrodr.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170313175640.14106-1-davvid@gmail.com>
David Aguilar <davvid@gmail.com> writes:
Show 12 quoted lines
> -		if (S_ISLNK(lmode)) {
> +		if (S_ISLNK(lmode) && !is_null_oid(&loid)) {
>  			char *content = read_sha1_file(loid.hash, &type, &size);
>  			add_left_or_right(&symlinks2, src_path, content, 0);
>  			free(content);
>  		}
>  
> -		if (S_ISLNK(rmode)) {
> +		if (S_ISLNK(rmode) && !is_null_oid(&roid)) {
>  			char *content = read_sha1_file(roid.hash, &type, &size);
>  			add_left_or_right(&symlinks2, dst_path, content, 1);
>  			free(content);

On this part I didn't comment in my previous message, but what is the implication of omitting add-left-or-right and not registering this symbolic link modified in the working tree to the symlinks2 table?

I am wondering if these should be more like
	if (S_ISLNK(lmode) {
		char *content = get_symlink(src_path, &loid);
		add_left_or_right(&symlinks2, src_path, content, 0);
                free(content);
	}                
with get_symlink() helper that does
 - if the object name is not 0{40}, read from the object store
 - if the object name is 0{40}, that means we need to read the real
   contents from the working tree file, so do the "readlink(2) if
   symbolic link is supported, otherwise open/read/close the stub
   file sitting there" thing.
Similary to the right hand side tree.

Discarding "content" after reading feels wasteful, as that is the information we would be using when populating the rstate and lstaten working trees later in the loop, but that would probably need a larger surgery to the code to optimize, I would imagine.

Previous: Junio C HamanoNext: Johannes Schindelin
Message 16 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.