* Diftool problems
@ 2009-04-29 16:15 Marcin Zalewski
2009-04-29 19:42 ` Markus Heidelberg
0 siblings, 1 reply; 6+ messages in thread
From: Marcin Zalewski @ 2009-04-29 16:15 UTC (permalink / raw)
To: git
Hi,
When git-difftool calls a diff tool, it uses file names given to it by
git-diff. This is a problem because often one of the files to be
compared is the same as the file to be merged into. What I mean is
that, in the following fragment of the git-difftool--helper file, $1
and $2 (I think) may end up being the same:
launch_merge_tool () {
# Merged is the filename as it appears in the work tree
# Local is the contents of a/filename
# Remote is the contents of b/filename
# Custom merge tool commands might use $BASE so we provide it
MERGED="$1"
LOCAL="$2"
REMOTE="$3"
BASE="$1"
Git-mergetool creates a temporary file for merging, but git-difftool
does not. Since git-diff tools is not meant for merging anything, it
may seem that there is no problem. However, some merge tools (such as
ediff) do not like when the merge target is the same as one of the
files to be compared. I use the following emacs snippet by Theodore
Tso:
http://kerneltrap.org/mailarchive/git/2007/7/2/250505
With that emacs code, ediff refuses to do a diff with the way that
difftool is done now. I do not have a patch, but it seems that a
simple fix would be to copy the code that creates temporary files from
mergetool.
Cheers,
Marcin Zalewski
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Diftool problems 2009-04-29 16:15 Diftool problems Marcin Zalewski @ 2009-04-29 19:42 ` Markus Heidelberg 2009-04-29 19:55 ` Marcin Zalewski 0 siblings, 1 reply; 6+ messages in thread From: Markus Heidelberg @ 2009-04-29 19:42 UTC (permalink / raw) To: Marcin Zalewski; +Cc: git Marcin Zalewski, 29.04.2009: > Hi, > > When git-difftool calls a diff tool, it uses file names given to it by > git-diff. This is a problem because often one of the files to be > compared is the same as the file to be merged into. What I mean is > that, in the following fragment of the git-difftool--helper file, $1 > and $2 (I think) may end up being the same: > > launch_merge_tool () { > # Merged is the filename as it appears in the work tree > # Local is the contents of a/filename > # Remote is the contents of b/filename > # Custom merge tool commands might use $BASE so we provide it > MERGED="$1" > LOCAL="$2" > REMOTE="$3" > BASE="$1" > > Git-mergetool creates a temporary file for merging, but git-difftool > does not. Since git-diff tools is not meant for merging anything, it > may seem that there is no problem. However, some merge tools (such as > ediff) do not like when the merge target is the same as one of the > files to be compared. I use the following emacs snippet by Theodore > Tso: > > http://kerneltrap.org/mailarchive/git/2007/7/2/250505 > > With that emacs code, ediff refuses to do a diff with the way that > difftool is done now. I do not have a patch, but it seems that a > simple fix would be to copy the code that creates temporary files from > mergetool. The real fix would be to adjust the ediff snippet for difftool support. As you said yourself, git-difftool is not meant for merging files, so there is no reason to open more than 2 files at all. The built-in difftools 'emerge' and 'ecmerge' still seem to open LOCAL, REMOTE and MERGED. This should be fixed, so that they don't open MERGED any more, but I don't have emacs installed, so I shouldn't try it myself. Oh, and LOCAL shouldn't be copied to a temporary file in the first place, because people don't use git-difftool in read-only mode only. Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Diftool problems 2009-04-29 19:42 ` Markus Heidelberg @ 2009-04-29 19:55 ` Marcin Zalewski 2009-04-29 20:48 ` Markus Heidelberg 2009-05-02 9:05 ` David Aguilar 0 siblings, 2 replies; 6+ messages in thread From: Marcin Zalewski @ 2009-04-29 19:55 UTC (permalink / raw) To: markus.heidelberg; +Cc: git > The real fix would be to adjust the ediff snippet for difftool support. The emas snippet was meant to work with mergetool and it does (I think). Changing the emacs code could indeed help with difftool but it would break mergetool. > As you said yourself, git-difftool is not meant for merging files, so > there is no reason to open more than 2 files at all. I agree, but the current implementation of difftool uses mergetool library. That may be the reason why difftool is trying to come up with the third file. Here is the snippet of code from mergetool library that executes emerge in case of non-merge-mode: "$merge_tool_path" -f emerge-files-command \ "$LOCAL" "$REMOTE" "$(basename "$MERGED")" > The built-in difftools 'emerge' and 'ecmerge' still seem to open LOCAL, > REMOTE and MERGED. This should be fixed, so that they don't open MERGED > any more, but I don't have emacs installed, so I shouldn't try it > myself. Again, I agree. This could be one of the possible solutions, but it would require that mergetool library is changed or rewriting pieces of mergetool in difftool. Correct me if I am wrong. > Oh, and LOCAL shouldn't be copied to a temporary file in the first > place, because people don't use git-difftool in read-only mode only. I think that merge result could be a temporary file, like in mergetool. In a situation where I use git to track an SVN repository, difftool can be actually used to merge my uncommitted changes with a commit from someone else after doing svn rebase. On the other hand, I am no git expert so there may be a better way to handle this case. -m ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Diftool problems 2009-04-29 19:55 ` Marcin Zalewski @ 2009-04-29 20:48 ` Markus Heidelberg 2009-04-29 21:37 ` Marcin Zalewski 2009-05-02 9:05 ` David Aguilar 1 sibling, 1 reply; 6+ messages in thread From: Markus Heidelberg @ 2009-04-29 20:48 UTC (permalink / raw) To: Marcin Zalewski; +Cc: git Marcin Zalewski, 29.04.2009: > > The real fix would be to adjust the ediff snippet for difftool support. > > The emas snippet was meant to work with mergetool and it does (I > think). Changing the emacs code could indeed help with difftool but it > would break mergetool. I'm sure the emacs snippet can be adjusted to work with both. If it is called with 2 files, then it's for difftool, else for mergetool. > > As you said yourself, git-difftool is not meant for merging files, so > > there is no reason to open more than 2 files at all. > > I agree, but the current implementation of difftool uses mergetool > library. The file is called git-mergetool--lib, but more exactly it should be called git-mergetool-difftool--lib, but who wants this? Difftool was originally based on mergetool, but the recent refactoring introduced the lib, which is shared by both, without belonging to one of them more than to the other. > That may be the reason why difftool is trying to come up with > the third file. Difftool isn't forcing a third file on you. > Here is the snippet of code from mergetool library > that executes emerge in case of non-merge-mode: > > "$merge_tool_path" -f emerge-files-command \ > "$LOCAL" "$REMOTE" "$(basename "$MERGED")" As said, this command shouldn't open the 3rd MERGED file, this should be fixed. This part of the lib is not responsible for difftool. > > The built-in difftools 'emerge' and 'ecmerge' still seem to open LOCAL, > > REMOTE and MERGED. This should be fixed, so that they don't open MERGED > > any more, but I don't have emacs installed, so I shouldn't try it > > myself. > > Again, I agree. This could be one of the possible solutions, No, that doesn't solve your problem with ediff. Or do you set merge.tool=emerge and ediff is called due to the snippet in your ~/.emacs? If yes, then I got it now... Sure, I just read the post from Ted Tso again, use-ediff-instead.el, aha. I guess it would be cleaner to do this in ~/.gitconfig: [diff] tool = ediff [difftool "ediff"] cmd = emacs --options "$LOCAL" "$REMOTE" Which is annoying, of course. But now that I got it (see above) I think you should leave merge.tool=emerge, since the snippet somehow seems to rely on it. > but it > would require that mergetool library is changed What's wrong with that? If this solves the 'ediff' problem and also makes 'emerge' to work right as difftool, then everyone would benefit from. > or rewriting pieces of > mergetool in difftool. Correct me if I am wrong. > > > Oh, and LOCAL shouldn't be copied to a temporary file in the first > > place, because people don't use git-difftool in read-only mode only. > > I think that merge result could be a temporary file, like in > mergetool. In a situation where I use git to track an SVN repository, > difftool can be actually used to merge my uncommitted changes with a > commit from someone else after doing svn rebase. Above you want your ediff mergetool snippet to work with difftool. And here you want to use difftool as a mergetool. I'm confused :) BTW, difftool doesn't work with files in unmerged state. Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Diftool problems 2009-04-29 20:48 ` Markus Heidelberg @ 2009-04-29 21:37 ` Marcin Zalewski 0 siblings, 0 replies; 6+ messages in thread From: Marcin Zalewski @ 2009-04-29 21:37 UTC (permalink / raw) To: markus.heidelberg; +Cc: git Markus, I think I mostly agree with everything that you have written. I hope that someone will fix something now. :) Cheers, -m ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Diftool problems 2009-04-29 19:55 ` Marcin Zalewski 2009-04-29 20:48 ` Markus Heidelberg @ 2009-05-02 9:05 ` David Aguilar 1 sibling, 0 replies; 6+ messages in thread From: David Aguilar @ 2009-05-02 9:05 UTC (permalink / raw) To: Marcin Zalewski; +Cc: markus.heidelberg, git On 0, Marcin Zalewski <marcin.zalewski@gmail.com> wrote: > > The real fix would be to adjust the ediff snippet for difftool support. > > "$merge_tool_path" -f emerge-files-command \ > "$LOCAL" "$REMOTE" "$(basename "$MERGED")" Hi Would the right command be: "$merge_tool_path" -f emerge-files-command \ "$LOCAL" "$REMOTE" (without $MERGED) ? > I think that merge result could be a temporary file, like in > mergetool. In a situation where I use git to track an SVN repository, > difftool can be actually used to merge my uncommitted changes with a > commit from someone else after doing svn rebase. On the other hand, I > am no git expert so there may be a better way to handle this case. > > -m Are you able to save the result to a file with the above snippet? I'd prefer to not touch the way difftool deals with files this late in the RC cycle, and if just saving within emacs works without changing difftool to use temporary files then that's even better. I tried it and didn't notice any difference w/ or w/out the patch, but if not specifying $MERGED is more correct then we should do that. You should have just seen a patch from me. Let me know if you have any other suggestions. -- David ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-05-02 9:05 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-04-29 16:15 Diftool problems Marcin Zalewski 2009-04-29 19:42 ` Markus Heidelberg 2009-04-29 19:55 ` Marcin Zalewski 2009-04-29 20:48 ` Markus Heidelberg 2009-04-29 21:37 ` Marcin Zalewski 2009-05-02 9:05 ` David Aguilar
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).