Page 1 of 3

Git integration question

Posted: Fri Feb 11, 2022 4:52 pm
by Alexo
Why does https://www.prestosoft.com/edp_versioncontrol.asp recommend setting merge.trustExitCode to false?

Re: Git integration question

Posted: Sat Feb 12, 2022 11:53 am
by psguru
We don't use git so this was based on recommendations from multiple users.

Re: Git integration question

Posted: Sat Feb 12, 2022 8:55 pm
by Alexo
From the documentation of git's diff tool integration:
difftool.trustExitCode
Exit difftool if the invoked diff tool returns a non-zero exit status.
See the --trust-exit-code option above for more details.

--[no-]trust-exit-code
git-difftool invokes a diff tool individually on each file. Errors reported by the diff tool are ignored by default. Use --trust-exit-code to make git-difftool exit when an invoked diff tool returns a non-zero exit code.
git-difftool will forward the exit code of the invoked tool when --trust-exit-code is used.
And the merge tool integration:
If the custom merge tool correctly indicates the success of a merge resolution with its exit code, then the configuration variable mergetool.<tool>.trustExitCode can be set to true. Otherwise, git mergetool will prompt the user to indicate the success of the resolution after the custom tool has exited.

mergetool.<tool>.trustExitCode
For a custom merge command, specify whether the exit code of the merge command can be used to determine whether the merge was successful. If this is not set to true then the merge target file timestamp is checked and the merge assumed to have been successful if the file has been updated, otherwise the user is prompted to indicate the success of the merge.
So it basically depends on when EDP returns an error code.

Re: Git integration question

Posted: Sun Feb 13, 2022 1:45 pm
by psguru
Well, since EDP does return exit code, we'll change the page to have "trustExitCode true".

Re: Git integration question

Posted: Sun Feb 13, 2022 5:34 pm
by Alexo
Actually, from reading the help page, it appears that the original suggestion was correct.
Comparison Exit Codes
0 identical files or directories
1 different files or directories
2 an error occurred

Merging Exit Codes
0 no conflicts
1 some conflicts were found
2 an error occurred
EDP returns a non-zero exit code in cases where no error occurred.

Re: Git integration question

Posted: Sun Feb 13, 2022 10:47 pm
by Alexo
Unfortunately, I am having another issue.

Running the following

Code: Select all

git difftool --dir-diff <some branch> <some other branch>
Displays a directory comparison as expected, but then I start getting incessant pop-ups that files got changed prompting to re-compare the directories. Indeed, many of the displayed files start changing to italics as if they are getting changed, but not all of them.

Interestingly, when I clicked on a line to open a file comparison, and waited, I got a notification for that file in directory comparison window, but did not get any notification in the file comparison window, suggesting that the file did not actually change.

Is it possible to disable the external change monitoring via a command-line switch?

Re: Git integration question

Posted: Mon Feb 14, 2022 9:35 am
by psguru
Actually, from reading the help page, it appears that the original suggestion was correct.
Well then we'll reverse the recommendation back to what it was.
Is it possible to disable the external change monitoring via a command-line switch?
Not directly but you can always export your options to a file and use the /g option to use the saved options files.

Re: Git integration question

Posted: Mon Feb 14, 2022 10:13 am
by MSpagni
Alexo wrote: Sun Feb 13, 2022 5:34 pm EDP returns a non-zero exit code in cases where no error occurred.
It seems to me exactly the opposite, as is customary.
Zero usually means ok.

Re: Git integration question

Posted: Mon Feb 14, 2022 10:24 am
by psguru
Zero does usually means OK but EDP has to also tell whether differences/conflicts were found. Compare with GNU diff https://man7.org/linux/man-pages/man1/diff.1.html:
Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.

Re: Git integration question

Posted: Mon Feb 14, 2022 12:45 pm
by Alexo
Not directly but you can always export your options to a file and use the /g option to use the saved options files.
The behaviour is still problematic, and disabling the notifications is a workaround at best (not an optimal one, since any changes need to be exported again).

This did not happen with other diff programs that are aware of file changes (BC4 and others).
Can this be investigated?

Re: Git integration question

Posted: Mon Feb 14, 2022 2:36 pm
by psguru
You can change notification settings in the Registry by using the UI, and it will affect all future sessions.
This did not happen with other diff programs that are aware of file changes (BC4 and others).
Can this be investigated?
What exactly do you want to be investigated? I'm not sure what the problem is.

Re: Git integration question

Posted: Mon Feb 14, 2022 10:47 pm
by Alexo
psguru wrote: Mon Feb 14, 2022 2:36 pm What exactly do you want to be investigated? I'm not sure what the problem is.
As I wrote above:
Alexo wrote: Sun Feb 13, 2022 10:47 pm Running the following

Code: Select all

git difftool --dir-diff <some branch> <some other branch>
Displays a directory comparison as expected, but then I start getting incessant pop-ups that files got changed prompting to re-compare the directories. Indeed, many of the displayed files start changing to italics as if they are getting changed, but not all of them.

Interestingly, when I clicked on a line to open a file comparison, and waited, I got a notification for that file in directory comparison window, but did not get any notification in the file comparison window, suggesting that the file did not actually change.
I do not know what causes the directory comparison window to decide that files are changing when the file comparison windows don't.

Thank you!

Re: Git integration question

Posted: Mon Feb 14, 2022 10:56 pm
by Alexo
I also asked the same question on SO and got the following comment:
The --dir-diff option pushes all the work off to the diff tool itself: Git just extracts the two commits to be compared into two temporary directories, and then sends the names of the two directories to the diff tool. So everything that shows up from the moment the diff tool starts, until the entire git difftool command finishes, is because of the tool.

Re: Git integration question

Posted: Tue Feb 15, 2022 9:38 am
by psguru
I do not know what causes the directory comparison window to decide that files are changing when the file comparison windows don't.
Both directory and file comparison use the same file system monitoring WIN32 API, ReadDirectoryChangesW. There is no way for me to answer your question without having a concrete reproducible scenario.
I also asked the same question on SO and got the following comment:

The --dir-diff option pushes all the work off to the diff tool itself: Git just extracts the two commits to be compared into two temporary directories, and then sends the names of the two directories to the diff tool. So everything that shows up from the moment the diff tool starts, until the entire git difftool command finishes, is because of the tool.
There must be some files that are being created/deleted/modified while the directory comparison view is on. You should be able to inspect your file system to see what they are. You can even use a tool like https://www.codeproject.com/Articles/95 ... angesW-all, or similar, to have a look at what's changing.

Re: Git integration question

Posted: Tue Feb 15, 2022 3:35 pm
by Alexo
psguru wrote: Tue Feb 15, 2022 9:38 am There must be some files that are being created/deleted/modified while the directory comparison view is on. You should be able to inspect your file system to see what they are.
Well, yes and no.

I used the SysInternals Process Monitor to see what processes access the files, trimmed the log to only include a single file name, and posted it here: https://pastebin.com/hLbQnwPs

What we can see is that the file is accessed by two processes: Windows Defender and EDP.

What happens is that once git copies the files to the temp folder, Windows Defender starts scanning them in the background.

This is a work machine, managed by the organization, so I cannot disable the antivirus, or change its parameters (like exclusions), but if we look closely at what it is doing, we see that the only write operation that it performs is setting the file's extended attributes, which should not affect the comparison in any way.

The NotifyChangeDirectory call from EDP filters on:
FILE_NOTIFY_CHANGE_FILE_NAME
FILE_NOTIFY_CHANGE_DIR_NAME
FILE_NOTIFY_CHANGE_ATTRIBUTES
FILE_NOTIFY_CHANGE_SIZE
FILE_NOTIFY_CHANGE_LAST_WRITE
FILE_NOTIFY_CHANGE_CREATION
FILE_NOTIFY_CHANGE_SECURITY

I suspect that in this case, FILE_NOTIFY_CHANGE_ATTRIBUTES causes the false positive.