git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Swap file trouble with gvimdiff
@ 2011-02-24 19:34 Marco
  2011-02-25  9:36 ` [PATCH] mergetool-lib: call vim in readonly mode for diffs Michael J Gruber
  0 siblings, 1 reply; 4+ messages in thread
From: Marco @ 2011-02-24 19:34 UTC (permalink / raw)
  To: git

Hi,

I use gvimdiff as difftool. The relevant .gitconfig entries look as follows:

[diff]
	tool = gvimdiff
[difftool]
	prompt = false

But when one diffs a file alredy opened in another window it clashes because
gvimdiff recognises the swap file and throws a message.

It would make sense to pass the option »-n« to gvimdiff to avoid creating a
swap file, since it is not needed here.

I haven't found the place where the command line and arguments for the
supported difftools are placed, so I created a new entry in the .gitconfig

[diff]
	tool = bettergvimdiff
[difftool "bettergvimdiff"]
	cmd = "gvimdiff -f -n \"$LOCAL\" \"$REMOTE\""

I want to know if this is a »correct« solution and — if not — how you solve
the problem.


Marco

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] mergetool-lib: call vim in readonly mode for diffs
  2011-02-24 19:34 Swap file trouble with gvimdiff Marco
@ 2011-02-25  9:36 ` Michael J Gruber
  2011-02-25 20:01   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Michael J Gruber @ 2011-02-25  9:36 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, netuse

When [g]vimdiff is called for files which are opened already, the editor
complains about the existing swap file. But we do not want to write
anything when called from difftool. So, make difftool use "-R" for the
vim family. This

- prevents the use of a swap file and
- marks the buffers readonly.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
Notes:
    It would be nice to mark all buffers but one with -R in mergemode
    but that seems to require some vim-scripting. There are no per-file command
    line options that I know of.

 git-mergetool--lib.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 77d4aee..78ce49e 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -182,7 +182,7 @@ run_merge_tool () {
 			fi
 			check_unchanged
 		else
-			"$merge_tool_path" -f -d -c "wincmd l" \
+			"$merge_tool_path" -R -f -d -c "wincmd l" \
 				"$LOCAL" "$REMOTE"
 		fi
 		;;
@@ -193,7 +193,7 @@ run_merge_tool () {
 				"$LOCAL" "$MERGED" "$REMOTE"
 			check_unchanged
 		else
-			"$merge_tool_path" -f -d -c "wincmd l" \
+			"$merge_tool_path" -R -f -d -c "wincmd l" \
 				"$LOCAL" "$REMOTE"
 		fi
 		;;
-- 
1.7.4.1.224.gefc87

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mergetool-lib: call vim in readonly mode for diffs
  2011-02-25  9:36 ` [PATCH] mergetool-lib: call vim in readonly mode for diffs Michael J Gruber
@ 2011-02-25 20:01   ` Junio C Hamano
  2011-02-27 22:33     ` David Aguilar
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2011-02-25 20:01 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git, netuse

Michael J Gruber <git@drmicha.warpmail.net> writes:

> When [g]vimdiff is called for files which are opened already, the editor
> complains about the existing swap file. But we do not want to write
> anything when called from difftool. So, make difftool use "-R" for the
> vim family.

Makes sense.  Maint-worthy?

Will queue, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mergetool-lib: call vim in readonly mode for diffs
  2011-02-25 20:01   ` Junio C Hamano
@ 2011-02-27 22:33     ` David Aguilar
  0 siblings, 0 replies; 4+ messages in thread
From: David Aguilar @ 2011-02-27 22:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Michael J Gruber, git, netuse

On Fri, Feb 25, 2011 at 12:01:15PM -0800, Junio C Hamano wrote:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> 
> > When [g]vimdiff is called for files which are opened already, the editor
> > complains about the existing swap file. But we do not want to write
> > anything when called from difftool. So, make difftool use "-R" for the
> > vim family.
> 
> Makes sense.  Maint-worthy?

I think this would be good in maint.
thanks,
-- 
		David

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-27 22:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-24 19:34 Swap file trouble with gvimdiff Marco
2011-02-25  9:36 ` [PATCH] mergetool-lib: call vim in readonly mode for diffs Michael J Gruber
2011-02-25 20:01   ` Junio C Hamano
2011-02-27 22:33     ` 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).