git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Keeping <john@keeping.me.uk>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: David Aguilar <davvid@gmail.com>,
	Sitaram Chamarty <sitaramc@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, Jonathan Nieder <jrnieder@gmail.com>
Subject: Re: [PATCH v3 3/4] t7800: modernize tests
Date: Fri, 22 Mar 2013 11:53:52 +0000	[thread overview]
Message-ID: <20130322115352.GI2283@serenity.lan> (raw)
In-Reply-To: <514C3D13.5010301@viscovery.net>

On Fri, Mar 22, 2013 at 12:14:27PM +0100, Johannes Sixt wrote:
> 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)?

> 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

  reply	other threads:[~2013-03-22 11:54 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-21  4:03 [PATCH v3 1/4] difftool: silence uninitialized variable warning David Aguilar
2013-02-21  4:03 ` [PATCH 2/4] t7800: update copyright notice David Aguilar
2013-02-21  4:03   ` [PATCH v3 3/4] t7800: modernize tests David Aguilar
2013-02-21  4:03     ` [PATCH v3 4/4] t7800: "defaults" is no longer a builtin tool name David Aguilar
2013-02-21  4:55       ` Junio C Hamano
2013-02-21  5:00       ` Junio C Hamano
2013-02-21 23:31         ` David Aguilar
2013-03-20  9:48     ` [PATCH v3 3/4] t7800: modernize tests Johannes Sixt
2013-03-20 22:59       ` David Aguilar
2013-03-21  7:41         ` Johannes Sixt
2013-03-22  7:13           ` Johannes Sixt
2013-03-22 10:00             ` John Keeping
2013-03-22 11:14               ` Johannes Sixt
2013-03-22 11:53                 ` John Keeping [this message]
2013-03-22 19:36                   ` [PATCH 0/3] Improve difftool --dir-diff tests John Keeping
2013-03-22 19:36                     ` [PATCH 1/3] t7800: don't hide grep output John Keeping
2013-03-22 22:32                       ` Johannes Sixt
2013-03-22 22:45                       ` Junio C Hamano
2013-03-22 19:36                     ` [PATCH 2/3] t7800: fix tests when difftool uses --no-symlinks John Keeping
2013-03-22 22:27                       ` Johannes Sixt
2013-03-22 22:53                       ` Junio C Hamano
2013-03-22 23:05                         ` John Keeping
2013-03-23  3:24                           ` David Aguilar
2013-03-22 19:36                     ` [PATCH 3/3] t7800: run --dir-diff tests with and without symlinks John Keeping
2013-03-22 21:05                       ` [PATCH 3/3 v2] " John Keeping
2013-03-23 13:31                     ` [PATCH v2 0/3] difftool --dir-diff test improvements John Keeping
2013-03-23 13:31                       ` [PATCH v2 1/3] t7800: don't hide grep output John Keeping
2013-03-23 13:31                       ` [PATCH v2 2/3] t7800: fix tests when difftool uses --no-symlinks John Keeping
2013-03-24  5:19                         ` Junio C Hamano
2013-03-24 12:36                           ` John Keeping
2013-03-24 13:31                             ` Matt McClure
2013-03-24 15:15                               ` John Keeping
2013-03-25  7:41                                 ` Johannes Sixt
2013-03-25 10:42                                   ` John Keeping
2013-03-25 21:44                                     ` [PATCH v2] difftool: don't overwrite modified files John Keeping
2013-03-26  8:38                                       ` Johannes Sixt
2013-03-26  8:47                                         ` Johannes Sixt
2013-03-26  9:31                                         ` John Keeping
2013-03-26  9:53                                           ` Johannes Sixt
2013-03-26 19:34                                             ` John Keeping
2013-03-26 20:52                                       ` Matt McClure
2013-03-26 21:01                                         ` John Keeping
2013-03-25 16:15                                   ` [PATCH v2 2/3] t7800: fix tests when difftool uses --no-symlinks Junio C Hamano
2013-03-24 21:29                             ` David Aguilar
2013-03-25 10:57                               ` John Keeping
2013-03-25 14:54                               ` Junio C Hamano
2013-03-24 13:24                           ` Matt McClure
2013-03-24  6:20                         ` Eric Sunshine
2013-03-23 13:31                       ` [PATCH v2 3/3] t7800: run --dir-diff tests with and without symlinks John Keeping
2013-03-25  7:26                         ` Johannes Sixt
2013-03-25 10:35                           ` John Keeping
2013-03-25 10:59                             ` Johannes Sixt
2013-03-25 11:02                               ` John Keeping
2013-03-25 21:50                               ` Junio C Hamano
2013-03-26  9:22                                 ` John Keeping

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=20130322115352.GI2283@serenity.lan \
    --to=john@keeping.me.uk \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=jrnieder@gmail.com \
    --cc=sitaramc@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 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 NNTP newsgroup(s).