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

[PATCH] git-mergetool: properly handle "git mergetool -- filename"

From
David Aguilar <davvid@gmail.com>
Date
Oct 15, 2008, 07:39 UTC
Message-ID
<36715524a8e3a4688024cc1e23dd1518c4df71a0.1224056291.git.davvid@gmail.com>

git-mergetool has an entry for "--" in its command-line parsing code to designate the end of option processing. It was not calling shift, though, which caused git-mergetool to incorrectly use "--" as the merge filename.

This patch fixes this bug and updates the usage and documentation to include [--] in the options spec.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 Documentation/git-mergetool.txt |    2 +-
 git-mergetool.sh                |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e0b2703..475db72 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -7,7 +7,7 @@ git-mergetool - Run merge conflict resolution tools to resolve merge conflicts
 
 SYNOPSIS
 --------
-'git mergetool' [--tool=<tool>] [<file>]...
+'git mergetool' [--tool=<tool>] [--] [<file>]...
 
 DESCRIPTION
 -----------
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 94187c3..1b0dfec 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -8,7 +8,7 @@
 # at the discretion of Junio C Hamano.
 #
 
-USAGE='[--tool=tool] [file to merge] ...'
+USAGE='[--tool=tool] [--] [file to merge] ...'
 SUBDIRECTORY_OK=Yes
 OPTIONS_SPEC=
 . git-sh-setup
@@ -296,6 +296,7 @@ do
 	    esac
 	    ;;
 	--)
+	    shift
 	    break
 	    ;;
 	-*)
-- 
1.6.0.2.532.g84ed4c
Message 1 of 1 in “git-mergetool: properly handle "git mergetool -- filename"”
  1. git-mergetool: properly handle "git mergetool -- filename"David Aguilar, Oct 15, 2008

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.