{"thread":{"id":"8629","subject":"[PATCH] mergetool: make Apple's FileMerge available as a merge_tool","startedAt":"2007-06-17T15:59:01Z","lastAt":"2007-06-18T13:18:00Z","messageCount":6,"participants":["Steffen Prohaska","Theodore Tso","Scott Lamb"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"45228","messageId":"11820959413590-git-send-email-prohaska@zib.de","threadId":"8629","inReplyTo":null,"subject":"[PATCH] mergetool: make Apple's FileMerge available as a merge_tool","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-06-17T15:59:01Z","receivedAt":"2007-06-17T15:59:01Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"Apple's developer tools include the application FileMerge,\nwhich supports graphical three way merges with ancestor.\nThis patch makes the tool available through git-mergetool.\n\nFileMerge is assumed to be installed at its default location.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n Documentation/git-mergetool.txt |    3 ++-\n git-mergetool.sh                |   20 ++++++++++++++++++++\n 2 files changed, 22 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex 6c32c6d..ff4cdf2 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -25,7 +25,8 @@ OPTIONS\n -t or --tool=<tool>::\n \tUse the merge resolution program specified by <tool>.\n \tValid merge tools are:\n-\tkdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, and opendiff\n+\tkdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, opendiff,\n+\tand FileMerge\n +\n If a merge resolution program is not specified, 'git mergetool'\n will use the configuration variable merge.tool.  If the\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 7b66309..abe2a97 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -258,6 +258,16 @@ merge_file () {\n \t    status=$?\n \t    save_backup\n \t    ;;\n+\t*FileMerge)\n+\t    touch \"$BACKUP\"\n+\t    if base_present; then\n+\t\t$merge_tool -left \"$LOCAL\" -right \"$REMOTE\" -ancestor \"$BASE\" -merge \"$path\" | cat\n+\t    else\n+\t\t$merge_tool -left \"$LOCAL\" -right \"$REMOTE\" -merge \"$path\" | cat\n+\t    fi\n+\t    check_unchanged\n+\t    save_backup\n+\t    ;;\n     esac\n     if test \"$status\" -ne 0; then\n \techo \"merge of $path failed\" 1>&2\n@@ -326,6 +336,9 @@ if test -z \"$merge_tool\" ; then\n         merge_tool_candidates=\"$merge_tool_candidates vimdiff\"\n     fi\n     merge_tool_candidates=\"$merge_tool_candidates opendiff emerge vimdiff\"\n+    if test $(uname) = \"Darwin\" ; then\n+    \tmerge_tool_candidates=\"/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge $merge_tool_candidates\"\n+    fi\n     echo \"merge tool candidates: $merge_tool_candidates\"\n     for i in $merge_tool_candidates; do\n         if test $i = emerge ; then\n@@ -357,6 +370,13 @@ case \"$merge_tool\" in\n \t    exit 1\n \tfi\n \t;;\n+    *FileMerge)\n+\tmerge_tool=/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge\n+\tif ! test -x $merge_tool ; then\n+\t    echo \"FileMerge is not available\"\n+\t    exit 1\n+\tfi\n+\t;;\n     *)\n \techo \"Unknown merge tool: $merge_tool\"\n \texit 1\n-- \n1.5.2.2.252.gbc777-dirty\n"},{"id":"45230","messageId":"B12626B9-766E-4EA4-888F-B3E2DA889D15@zib.de","threadId":"8629","inReplyTo":"11820959413590-git-send-email-prohaska@zib.de","subject":"Re: [PATCH] mergetool: make Apple's FileMerge available as a merge_tool","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-06-17T16:13:11Z","receivedAt":"2007-06-17T16:13:11Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jun 17, 2007, at 5:59 PM, Steffen Prohaska wrote:\n\n> Apple's developer tools include the application FileMerge,\n> which supports graphical three way merges with ancestor.\n> This patch makes the tool available through git-mergetool.\n>\n> FileMerge is assumed to be installed at its default location.\n\nHmm, now I found out that opendiff, which was already available\nas an option, actually launches FileMerge.\n\nI wasn't aware of this fact. git-mergetool proposed to use vimdiff\nalthough I had preferred the graphical application FileMerge, which\nwould have been launched by opendiff.\n\nDon't know if my patch makes any sense. Probably a note in the\ndocumentation that opendiff launches the GUI would be nice.\n\n\tSteffen\n"},{"id":"45234","messageId":"20070617181200.GA15218@thunk.org","threadId":"8629","inReplyTo":"B12626B9-766E-4EA4-888F-B3E2DA889D15@zib.de","subject":"Re: [PATCH] mergetool: make Apple's FileMerge available as a merge_tool","fromName":"Theodore Tso","fromEmail":"tytso@mit.edu","sentAt":"2007-06-17T18:12:00Z","receivedAt":"2007-06-17T18:12:00Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"On Sun, Jun 17, 2007 at 06:13:11PM +0200, Steffen Prohaska wrote:\n> \n> Hmm, now I found out that opendiff, which was already available\n> as an option, actually launches FileMerge.\n\nYep.\n\n> I wasn't aware of this fact. git-mergetool proposed to use vimdiff\n> although I had preferred the graphical application FileMerge, which\n> would have been launched by opendiff.\n\nDo you know of a way of determining whether or not under MacOS X, a\nprogram can easily determine whether or not the user is sitting in\nfront of the graphical display, as opposed to coming in via an SSH\nconnection?\n\nIf so, we could use that under MacOS to make the defaults be to use\nopendiff under those circumstances.\n\nRealistically, though, past a certain point we can only be so smart\nwith the hueristics.  If you know what you want, you should really set\nthe merge.tool config option in your ~/.gitconfig file, and be done\nwith it.\n\n> Don't know if my patch makes any sense. Probably a note in the\n> documentation that opendiff launches the GUI would be nice.\n\nMaybe a change so that opendiff is listed as \"opendiff (aka\nFileMerge)\", perhaps?\n\n\t\t\t\t\t\t- Ted\n"},{"id":"45238","messageId":"42FEB11E-426D-4B44-9E7E-0E35032CB1B0@zib.de","threadId":"8629","inReplyTo":"20070617181200.GA15218@thunk.org","subject":"Re: [PATCH] mergetool: make Apple's FileMerge available as a merge_tool","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-06-17T19:20:54Z","receivedAt":"2007-06-17T19:20:54Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jun 17, 2007, at 8:12 PM, Theodore Tso wrote:\n\n> On Sun, Jun 17, 2007 at 06:13:11PM +0200, Steffen Prohaska wrote:\n>\n>> I wasn't aware of this fact. git-mergetool proposed to use vimdiff\n>> although I had preferred the graphical application FileMerge, which\n>> would have been launched by opendiff.\n>\n> Do you know of a way of determining whether or not under MacOS X, a\n> program can easily determine whether or not the user is sitting in\n> front of the graphical display, as opposed to coming in via an SSH\n> connection?\n\nthis might do the job:\n\n--- SNIP ---\n#! /bin/sh\n\npid=$$\n\nwhile [ $pid -ne 1 ] ; do\n     command=$(ps -p $pid | tail -n 1 | cut -b 27-)\n     echo $command | grep -q sshd && { echo \"ssh\" ; exit ; }\n     echo $command | grep -q Terminal && { echo \"local\" ; exit ; }\n     pid=$(ps -O ppid -p $pid | tail -n 1 | cut -b 6-11)\ndone\n\necho \"unknown\"\n--- SNIP ---\n\n\n> If so, we could use that under MacOS to make the defaults be to use\n> opendiff under those circumstances.\n>\n> Realistically, though, past a certain point we can only be so smart\n> with the heuristics.  If you know what you want, you should really set\n> the merge.tool config option in your ~/.gitconfig file, and be done\n> with it.\n\nWell, I'm done with it. I learned that opendiff and FileMerge are the\nsame, which I wasn't aware of before.\n\n\n>> Don't know if my patch makes any sense. Probably a note in the\n>> documentation that opendiff launches the GUI would be nice.\n>\n> Maybe a change so that opendiff is listed as \"opendiff (aka\n> FileMerge)\", perhaps?\n\nperhaps. It wouldn't make things worse.\n\n\tSteffen\n"},{"id":"45260","messageId":"467652BC.4050900@slamb.org","threadId":"8629","inReplyTo":"42FEB11E-426D-4B44-9E7E-0E35032CB1B0@zib.de","subject":"Re: [PATCH] mergetool: make Apple's FileMerge available as a merge_tool","fromName":"Scott Lamb","fromEmail":"slamb@slamb.org","sentAt":"2007-06-18T09:39:08Z","receivedAt":"2007-06-18T09:39:08Z","isPatch":true,"sender":{"key":"slamb@slamb.org","avatar":null},"body":"Steffen Prohaska wrote:\n> \n> On Jun 17, 2007, at 8:12 PM, Theodore Tso wrote:\n>> Do you know of a way of determining whether or not under MacOS X, a\n>> program can easily determine whether or not the user is sitting in\n>> front of the graphical display, as opposed to coming in via an SSH\n>> connection?\n> \n> this might do the job:\n> \n> --- SNIP ---\n> #! /bin/sh\n> \n> pid=$$\n> \n> while [ $pid -ne 1 ] ; do\n>     command=$(ps -p $pid | tail -n 1 | cut -b 27-)\n>     echo $command | grep -q sshd && { echo \"ssh\" ; exit ; }\n>     echo $command | grep -q Terminal && { echo \"local\" ; exit ; }\n>     pid=$(ps -O ppid -p $pid | tail -n 1 | cut -b 6-11)\n> done\n> \n> echo \"unknown\"\n> --- SNIP ---\n\nI propose a simpler test:\n\n    if [ -n \"$TERM_PROGRAM\" ]; then\n        echo local\n    else\n        echo remote\n    fi\n\nThis environment variable seems to be set by Terminal.app and even two\nalternatives I just tried (iTerm.app and GLterm.app). It's not\ntransmitted across ssh unless you stick an AcceptEnv in sshd_config.\n\nAbout the only time it would fail is logging in via local xterm. I'd\nguess few people do that, and determining if xterm is local or not seems\ninfeasible - the best I've got is examining DISPLAY, but where do you\ndraw the line between :0.0 or localhost:0 (probably local), foobar:0\n(probably remote), and :10 (probably remote via ssh forwarding)? I'd\nrather not try.\n\n-- \nScott Lamb <http://www.slamb.org/>\n"},{"id":"45267","messageId":"20070618131800.GA30244@thunk.org","threadId":"8629","inReplyTo":"467652BC.4050900@slamb.org","subject":"Re: [PATCH] mergetool: make Apple's FileMerge available as a merge_tool","fromName":"Theodore Tso","fromEmail":"tytso@mit.edu","sentAt":"2007-06-18T13:18:00Z","receivedAt":"2007-06-18T13:18:00Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"On Mon, Jun 18, 2007 at 02:39:08AM -0700, Scott Lamb wrote:\n> I propose a simpler test:\n> \n>     if [ -n \"$TERM_PROGRAM\" ]; then\n>         echo local\n>     else\n>         echo remote\n>     fi\n> \n> This environment variable seems to be set by Terminal.app and even two\n> alternatives I just tried (iTerm.app and GLterm.app). It's not\n> transmitted across ssh unless you stick an AcceptEnv in sshd_config.\n\nThanks, that's just what I was looking for!\n\n\t\t\t\t\t\t- Ted\n"}]}