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

Re: [PATCH v3 3/4] t7800: modernize tests

From
John Keeping <john@keeping.me.uk>
Date
Mar 22, 2013, 11:53 UTC
Message-ID
<20130322115352.GI2283@serenity.lan>
In-Reply-To
<514C3D13.5010301@viscovery.net>
On Fri, Mar 22, 2013 at 12:14:27PM +0100, Johannes Sixt wrote:
Show 61 quoted lines
> Am 3/22/2013 11:00, schrieb John Keeping:
> > On Fri, Mar 22, 2013 at 08:13:46AM +0100, Johannes Sixt wrote:
> >> Am 3/21/2013 8:41, schrieb Johannes Sixt:
> >>> Am 3/20/2013 23:59, schrieb David Aguilar:
> >>>> I started digging in and the @worktree_files (aka @worktree above)
> >>>> is populated from the output of "git diff --raw ...".
> >>>>
> >>>> Seeing the "output" filename in "diff --raw" implies that one of the
> >>>> tests added "output" to the index somehow.  I do not see that
> >>>> happening anywhere, though, so I do not know how it would end up in
> >>>> the @worktree array if it is not reported by "diff --raw".
> >>>>
> >>>>
> >>>> My current understanding of how it could possibly be open twice:
> >>>>
> >>>> 1. via the >output redirect
> >>>> 2. via the copy() perl code which is fed by @worktree
> >>>>
> >>>> So I'm confused.  Why would we get different results on Windows?
> >>>
> >>> I tracked down the difference between Windows and Linux, and it is...
> >>>
> >>> 	for my $file (@worktree) {
> >>> 		next if $symlinks && -l "$b/$file";
> >>>
> >>> ... this line in sub dir_diff. On Linux, we take the short-cut, but on
> >>> Windows we proceed through the rest of the loop,
> >>
> >> And that is likely by design. From the docs:
> >>
> >> --symlinks
> >> --no-symlinks
> >>
> >>     git difftool's default behavior is create symlinks to the working
> >>     tree when run in --dir-diff mode.
> >>
> >>     Specifying `--no-symlinks` instructs 'git difftool' to create
> >>     copies instead.  `--no-symlinks` is the default on Windows.
> >>
> >> And indeed, we have this initialization:
> >>
> >> 	my %opts = (
> >> 		...
> >> 		symlinks => $^O ne 'cygwin' &&
> >> 				$^O ne 'MSWin32' && $^O ne 'msys',
> >> 		...
> >> 	);
> >>
> >> Can the --dir-diff tests case pass on Cygwin when neither --symlinks nor
> >> --no-symlinks is passed?
> >>
> >> Perhaps the right solution is this:
> > 
> > We already have tests that explicitly pass '--symlinks'.  I wonder if it
> > would be better to change "output" to ".git/output", which should avoid
> > the problem by moving the output file out of the working tree.
> 
> The point of using --symlinks is not to test the effect of the option, but
> to test the same thing on Unix and on Cygwin, because the latter uses
> --no-symlinks by default. Therefore, I think that this sketch is the right
> thing to do.

So shouldn't we be running all of the tests with both --symlinks and --no-symlinks (except those which explicitly check that these options do the right thing)?

Show 5 quoted lines
> But the real problem seems to be that "output" should not be among the
> files treated in the cited pieces of code (unless I'm wrong, of course; I
> know next to nothing about git-difftool). It should not matter where the
> file lives. Just add --no-symlinks to the difftool invocation of test
> "difftool -d" and watch it fail on Linux, too.

I fired up strace and it looks like difftool sees it as a working tree file (i.e. the working tree content matches the RHS of the diff) in the output of "git diff --raw --no-abbrev -z branch" and copies it over to the temporary directories. Then when difftool completes it copies back the working tree files from there.

When the file is copied to the temporary directory, the diff command hasn't yet run so "output" is empty. When it's copied back it is after the "ls" has run and so we overwrite the output of the command with the original empty file.

So sticking the output file under .git does solve this issue since it then is not treated as a working tree file.

Whether the current behaviour of difftool is entirely sensible is a different question. I think we should at the very least by refusing to overwrite working tree files that have been modified since they were copied to the temporary directory

If I ever end up on a system using --no-symlinks I can see myself being bitten by this by editing the original working tree file while inspecting the diff in a separate window. I suspect this is just as common a workflow as people editing the file in their diff tool and wanting the changes copied back to the working tree.

John
Previous: Johannes SixtNext: John Keeping
Message 14 of 55 in “difftool: silence uninitialized variable warning”
  1. 1/4 difftool: silence uninitialized variable warningDavid Aguilar, Feb 21, 2013
  2. 2/4 t7800: update copyright noticeDavid Aguilar, Feb 21, 2013
  3. 3/4 t7800: modernize testsDavid Aguilar, Feb 21, 2013
  4. 4/4 t7800: "defaults" is no longer a builtin tool nameDavid Aguilar, Feb 21, 2013
  5. Junio C HamanoFeb 21, 2013
  6. Junio C HamanoFeb 21, 2013
  7. David AguilarFeb 21, 2013
  8. Johannes SixtMar 20, 2013
  9. David AguilarMar 20, 2013
  10. Johannes SixtMar 21, 2013
  11. Johannes SixtMar 22, 2013
  12. John KeepingMar 22, 2013
  13. Johannes SixtMar 22, 2013
  14. John KeepingMar 22, 2013
  15. 0/3 Improve difftool --dir-diff testsJohn Keeping, Mar 22, 2013
  16. 1/3 t7800: don't hide grep outputJohn Keeping, Mar 22, 2013
  17. Johannes SixtMar 22, 2013
  18. Junio C HamanoMar 22, 2013
  19. 2/3 t7800: fix tests when difftool uses --no-symlinksJohn Keeping, Mar 22, 2013
  20. Johannes SixtMar 22, 2013
  21. Junio C HamanoMar 22, 2013
  22. John KeepingMar 22, 2013
  23. David AguilarMar 23, 2013
  24. 3/3 t7800: run --dir-diff tests with and without symlinksJohn Keeping, Mar 22, 2013
  25. 3/3 t7800: run --dir-diff tests with and without symlinksJohn Keeping, Mar 22, 2013
  26. 0/3 difftool --dir-diff test improvementsJohn Keeping, Mar 23, 2013
  27. 1/3 t7800: don't hide grep outputJohn Keeping, Mar 23, 2013
  28. 2/3 t7800: fix tests when difftool uses --no-symlinksJohn Keeping, Mar 23, 2013
  29. Junio C HamanoMar 24, 2013
  30. John KeepingMar 24, 2013
  31. Matt McClureMar 24, 2013
  32. John KeepingMar 24, 2013
  33. Johannes SixtMar 25, 2013
  34. John KeepingMar 25, 2013
  35. difftool: don't overwrite modified filesJohn Keeping, Mar 25, 2013
  36. Johannes SixtMar 26, 2013
  37. Johannes SixtMar 26, 2013
  38. John KeepingMar 26, 2013
  39. Johannes SixtMar 26, 2013
  40. John KeepingMar 26, 2013
  41. Matt McClureMar 26, 2013
  42. John KeepingMar 26, 2013
  43. Junio C HamanoMar 25, 2013
  44. David AguilarMar 24, 2013
  45. John KeepingMar 25, 2013
  46. Junio C HamanoMar 25, 2013
  47. Matt McClureMar 24, 2013
  48. Eric SunshineMar 24, 2013
  49. 3/3 t7800: run --dir-diff tests with and without symlinksJohn Keeping, Mar 23, 2013
  50. Johannes SixtMar 25, 2013
  51. John KeepingMar 25, 2013
  52. Johannes SixtMar 25, 2013
  53. John KeepingMar 25, 2013
  54. Junio C HamanoMar 25, 2013
  55. John KeepingMar 26, 2013

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.