Merge を使用して「git diff HEAD」コマンドを処理できるように、Araxis が提供する AppleScript を使用しています。
ただし、Mountain Lion にアップグレードして以来、コマンドを実行するたびに次の警告が表示されます。
CFURLGetFSRef was passed this URL which has no scheme
(the URL may not work with other CFURL routines): .
スクリプトでは、問題を引き起こしていると思われるのは
set _file2 to (POSIX path of (POSIX file "." as alias)) & _file2
を使用する代わりにパスをハードコーディングする"."
と、警告が消えます。私は pre-pending を試しましfile:///
たPOSIX path of
が、スラッシュの 1 つをエスケープ文字と見なしているため、パスがfile:/Users/...
になり、スキーマが不明であるというエラーが生成されます (2 番目のスラッシュが削除されたため)。POSIX file
それで、私の質問は、現在の場所を取得する適切な方法は何ですか (現在、Mountain Lion で) ?
完全なスクリプトを追加する
#!/usr/bin/osascript
# This script is required to reorder the parameters sent by Git, so that they may be passed into the Merge Applescript API
on run args
tell application "Araxis Merge"
set _file1 to item 2 of args as text
set _file2 to item 5 of args as text
if not _file1 starts with "/"
set _file1 to (POSIX path of (POSIX file "." as alias)) & _file1
end if
if not _file2 starts with "/"
set _file2 to (POSIX path of (POSIX file "." as alias)) & _file2
end if
set _document to compare {_file1, _file2}
tell _document
activate
end tell
repeat while exists _document
delay 1
end repeat
end tell
end run
実用的なソリューション(@adayzdoneに感謝)
#!/usr/bin/osascript
# This script is required to reorder the parameters sent by Git, so that they may be passed into the Merge Applescript API
on run args
tell application "Araxis Merge"
set _file1 to item 2 of args as text
set _file2 to item 5 of args as text
if not _file1 starts with "/"
set _file1 to (POSIX path of (POSIX file (do shell script "pwd") as alias)) & _file1
end if
if not _file2 starts with "/"
set _file2 to (POSIX path of (POSIX file (do shell script "pwd") as alias)) & _file2
end if
set _document to compare {_file1, _file2}
tell _document
activate
end tell
repeat while exists _document
delay 1
end repeat
end tell
end run