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

[PATCH] mergetool-lib: call vim in readonly mode for diffs

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Feb 25, 2011, 09:36 UTC
Message-ID
<227c6e4e11ce964a6e6898afb422d424d46a7b50.1298626494.git.git@drmicha.warpmail.net>
In-Reply-To
<20110224203412.29b732b9@glyph>

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
Previous: MarcoNext: Junio C Hamano
Message 2 of 4 in “Swap file trouble with gvimdiff”
  1. MarcoFeb 24, 2011
  2. mergetool-lib: call vim in readonly mode for diffsMichael J Gruber, Feb 25, 2011
  3. Junio C HamanoFeb 25, 2011
  4. David AguilarFeb 27, 2011

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.