threads / discuss / 21947

How can I get full filenames from Git difftool (for Microsoft Word “Compare Documents” feature)?

Subject: How can I get full filenames from Git difftool (for Microsoft Word “Compare Documents” feature)?

## tl;dr

3 messages between Dec 14, 2009 and Dec 14, 2009.

replies: 2people: 3as markdown or json

Doug Ireton· Dec 14, 2009, 06:25 UTC · lore

I am using the latest version of Git (1.6.6) on a Mac. My wife wants to use Git to manage her fiction writing as long as she can still use Microsoft Word 2008 (Mac). Instead of pushing her into saving everything as plain text, I would like to use Git Difftool to pass the files to Word and use Word's Compare Documents feature. She wouldn't be able to use Git Diff since Word docs are binary files but she could still use Git Difftool.

I have written an Applescript which takes two filenames in this format: /Users/foo/Documents/my_novel.docx and opens Word to do the file comparison. However, Git Difftool seems to only pass the bare filenames (e.g. my_novel.docx) as parameters.

Is there anyway to get the full filenames from Git Difftool?
Thanks,
Doug Ireton
Matthieu Moy· Dec 14, 2009, 07:55 UTC · re: Doug Ireton · lore

Re: How can I get full filenames from Git difftool (for Microsoft Word “Compare Documents” feature)?

Doug Ireton <dougireton@gmail.com> writes:
Show 7 quoted lines
> I am using the latest version of Git (1.6.6) on a Mac. My wife wants
> to use Git to manage her fiction writing as long as she can still use
> Microsoft Word 2008 (Mac). Instead of pushing her into saving
> everything as plain text, I would like to use Git Difftool to pass the
> files to Word and use Word's Compare Documents feature. She wouldn't
> be able to use Git Diff since Word docs are binary files but she could
> still use Git Difftool.

If you're interested in diff-ing the _text_ itself, you can use the textconv filter of Git, together with antiword (or catdoc, which does the same thing, but I think antiword works better).

See this:
http://git.or.cz/gitwiki/GitTips#HowtousegittotrackOpenDocument.28OpenOffice.2CKoffice.29files.3F

and adapt by replacing "OpenOffice" with MS Word, and odt2txt with antiword.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Jeff Epler· Dec 14, 2009, 13:11 UTC · re: Doug Ireton · lore

Re: How can I get full filenames from Git difftool (for Microsoft Word “Compare Documents” feature)?

In the bash shell, you can convert a relative path to absolute by prepending
the directory name:
    mkabs () {
        case "$1" in
        /*) echo "$1" ;;
        *)  echo "$(pwd)/$1" ;;
        esac
    }
Using it at the shell prompt:
    $ mkabs example
    /home/jepler/example
    $ ls -l $(mkabs example)
    -rw-r--r-- 1 jepler jepler 0 2009-12-14 07:08 /home/jepler/example
If mac has a gnu-like readlink(1), then use 'readlink -f' instead of the
mkabs shell function:
    $ readlink -f example
    /home/jepler/example

You should be able to write a shell script which does the conversion from relative to absolute using one of these patterns, and then invokes the applescript.

It may turn out that there's a way to convert a path from relative to absolute in applescript as well, but I wouldn't know it.

Jeff

← back to recent threads