{"thread":{"id":"13989","subject":"[PATCH v3/RFC] Remove the use of '--' in merge program invocation","startedAt":"2008-06-16T23:33:41Z","lastAt":"2008-06-17T16:52:21Z","messageCount":3,"participants":["Patrick Higgins","Junio C Hamano","patrick.higgins@cexp.com"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"80087","messageId":"1213659221-27519-1-git-send-email-patrick.higgins@cexp.com","threadId":"13989","inReplyTo":null,"subject":"[PATCH v3/RFC] Remove the use of '--' in merge program invocation","fromName":"Patrick Higgins","fromEmail":"patrick.higgins@cexp.com","sentAt":"2008-06-16T23:33:41Z","receivedAt":"2008-06-16T23:33:41Z","isPatch":true,"sender":{"key":"patrick.higgins@cexp.com","avatar":null},"body":"Put a \"./\" at the beginning of all paths given to the merge program so\nthat filenames beginning with a '-' character don't get interpreted as\noptions.\n\nThis deals with a problem where kdiff3 can be compiled with or without\nsupport for the '--' separator between options and filenames.\n\nSigned-off-by: Patrick Higgins <patrick.higgins@cexp.com>\n---\n\nThis is applying Junio's idea because my earlier attempts would fail on files\nthat started with a dash. This should work for those files with kdiff3\ncompiled with or without '--' support, does not require any additional\noverhead to determine if kdiff3 has that support, and the technique should\nwork for all merge programs in case any others have the problem kdiff3 has.\n\nMy only concern is if 'git ls-files -u' ever returns absolute paths, then this\nwill not work.\n\n git-mergetool.sh |   24 ++++++++++++------------\n 1 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex fcdec4a..94187c3 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -141,10 +141,10 @@ merge_file () {\n     fi\n \n     ext=\"$$$(expr \"$MERGED\" : '.*\\(\\.[^/]*\\)$')\"\n-    BACKUP=\"$MERGED.BACKUP.$ext\"\n-    LOCAL=\"$MERGED.LOCAL.$ext\"\n-    REMOTE=\"$MERGED.REMOTE.$ext\"\n-    BASE=\"$MERGED.BASE.$ext\"\n+    BACKUP=\"./$MERGED.BACKUP.$ext\"\n+    LOCAL=\"./$MERGED.LOCAL.$ext\"\n+    REMOTE=\"./$MERGED.REMOTE.$ext\"\n+    BASE=\"./$MERGED.BASE.$ext\"\n \n     mv -- \"$MERGED\" \"$BACKUP\"\n     cp -- \"$BACKUP\" \"$MERGED\"\n@@ -183,29 +183,29 @@ merge_file () {\n \tkdiff3)\n \t    if base_present ; then\n \t\t(\"$merge_tool_path\" --auto --L1 \"$MERGED (Base)\" --L2 \"$MERGED (Local)\" --L3 \"$MERGED (Remote)\" \\\n-\t\t    -o \"$MERGED\" -- \"$BASE\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n+\t\t    -o \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n \t    else\n \t\t(\"$merge_tool_path\" --auto --L1 \"$MERGED (Local)\" --L2 \"$MERGED (Remote)\" \\\n-\t\t    -o \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n+\t\t    -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n \t    fi\n \t    status=$?\n \t    ;;\n \ttkdiff)\n \t    if base_present ; then\n-\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n \t    else\n-\t\t\"$merge_tool_path\" -o \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n \t    fi\n \t    status=$?\n \t    ;;\n \tmeld|vimdiff)\n \t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" -- \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t    \"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \t    check_unchanged\n \t    ;;\n \tgvimdiff)\n \t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" -f -- \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t    \"$merge_tool_path\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \t    check_unchanged\n \t    ;;\n \txxdiff)\n@@ -215,13 +215,13 @@ merge_file () {\n \t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t    --merged-file \"$MERGED\" -- \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n+\t\t    --merged-file \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \t    else\n \t\t\"$merge_tool_path\" -X --show-merged-pane \\\n \t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t    --merged-file \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t    --merged-file \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n \t    fi\n \t    check_unchanged\n \t    ;;\n-- \n1.5.6.rc2\n"},{"id":"80089","messageId":"7vlk157woq.fsf@gitster.siamese.dyndns.org","threadId":"13989","inReplyTo":"1213659221-27519-1-git-send-email-patrick.higgins@cexp.com","subject":"Re: [PATCH v3/RFC] Remove the use of '--' in merge program invocation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-17T00:05:25Z","receivedAt":"2008-06-17T00:05:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Higgins <patrick.higgins@cexp.com> writes:\n\n> Put a \"./\" at the beginning of all paths given to the merge program so\n> that filenames beginning with a '-' character don't get interpreted as\n> options.\n>\n> This deals with a problem where kdiff3 can be compiled with or without\n> support for the '--' separator between options and filenames.\n>\n> Signed-off-by: Patrick Higgins <patrick.higgins@cexp.com>\n> ---\n>\n> This is applying Junio's idea because my earlier attempts would fail on files\n> that started with a dash. This should work for those files with kdiff3\n> compiled with or without '--' support, does not require any additional\n> overhead to determine if kdiff3 has that support, and the technique should\n> work for all merge programs in case any others have the problem kdiff3 has.\n>\n> My only concern is if 'git ls-files -u' ever returns absolute paths,\n> then this will not work.\n\nWhat do you mean by \"absolute paths\"?  The path git proper deals with is\nalways relative to the root of the repository's work tree, so you won't be\nseeing \"/home/patrick/src/Makefile\" from ls-files if that is what you are\nworried about.\n\nThis change applies to all the backends not just kdiff3; people who use\ndifferent merge backends please give success (or breakage) reports.\n\nThanks.\n"},{"id":"80154","messageId":"911589C97062424796D53B625CEC0025E46165@USCOBRMFA-SE-70.northamerica.cexp.com","threadId":"13989","inReplyTo":"7vlk157woq.fsf@gitster.siamese.dyndns.org","subject":"RE: [PATCH v3/RFC] Remove the use of '--' in merge program invocation","fromName":"","fromEmail":"patrick.higgins@cexp.com","sentAt":"2008-06-17T16:52:21Z","receivedAt":"2008-06-17T16:52:21Z","isPatch":true,"sender":{"key":"patrick.higgins@cexp.com","avatar":null},"body":"\n\nFrom: Junio C Hamano [mailto:gitster@pobox.com]\n> \n> Patrick Higgins <patrick.higgins@cexp.com> writes:\n> \n> > My only concern is if 'git ls-files -u' ever returns absolute paths,\n> > then this will not work.\n> \n> What do you mean by \"absolute paths\"?  The path git proper \n> deals with is\n> always relative to the root of the repository's work tree, so \n> you won't be\n> seeing \"/home/patrick/src/Makefile\" from ls-files if that is \n> what you are\n> worried about.\n\nYes, that's what I was worried about. Glad to hear that won't ever happen.\n"}]}