{"thread":{"id":"10044","subject":"[PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents","startedAt":"2007-09-27T11:45:58Z","lastAt":"2007-09-27T12:04:34Z","messageCount":3,"participants":["Johannes Sixt","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"54158","messageId":"11908935593618-git-send-email-johannes.sixt@telecom.at","threadId":"10044","inReplyTo":null,"subject":"[PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-09-27T11:45:58Z","receivedAt":"2007-09-27T11:45:58Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"A shell script opens WinWord with the documents and a document template.\nThe document template contains a VBA macro that is run automatically.\nIt looks up the two documents and performs the comparison.\n\nUnfortunately, the user's help is needed to construct the document template\nwith the macro from a plain text file, so we print the instructions from\nthe Makefile.\n\nThe README file contains instructions how to use this feature.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n\tOk, here's something that shows how git helps solve REAL PROBLEMS.\n\n\tI've been using this for a day or two now with the MinGW port.\n\tOther Windows prisoners might be interested, too.\n\tBe sure to read the README and take a deap breath of the\n\tfresh air.\n\n\t;)\n\n\tThis was only tested with a localized version Microsoft Office 2000,\n\tso your milage may vary.\n\n\t-- Hannes\n\n contrib/winword/diff/.gitignore      |    2 +\n contrib/winword/diff/Makefile        |   39 ++++++++++++++++++++++++++++++++++\n contrib/winword/diff/README          |   34 +++++++++++++++++++++++++++++\n contrib/winword/diff/winworddiff.bas |   13 +++++++++++\n contrib/winword/diff/winworddiff.sh  |   15 +++++++++++++\n 5 files changed, 103 insertions(+), 0 deletions(-)\n create mode 100644 contrib/winword/diff/.gitignore\n create mode 100644 contrib/winword/diff/Makefile\n create mode 100644 contrib/winword/diff/README\n create mode 100644 contrib/winword/diff/winworddiff.bas\n create mode 100755 contrib/winword/diff/winworddiff.sh\n\ndiff --git a/contrib/winword/diff/.gitignore b/contrib/winword/diff/.gitignore\nnew file mode 100644\nindex 0000000..f37a3c4\n--- /dev/null\n+++ b/contrib/winword/diff/.gitignore\n@@ -0,0 +1,2 @@\n+winworddiff\n+winworddiff.dot\ndiff --git a/contrib/winword/diff/Makefile b/contrib/winword/diff/Makefile\nnew file mode 100644\nindex 0000000..61de940\n--- /dev/null\n+++ b/contrib/winword/diff/Makefile\n@@ -0,0 +1,39 @@\n+prefix = $(HOME)\n+bindir = $(prefix)/bin\n+datadir = $(prefix)/share/winworddiff\n+\n+WINWORDEXE = C:/Program Files/Microsoft Office/Office/WINWORD.EXE\n+INSTALL = install\n+\n+all: winworddiff winworddiff.dot\n+\n+winworddiff: winworddiff.sh\n+\tsed\t-e 's|@@WINWORDEXE@@|$(WINWORDEXE)|' \\\n+\t\t-e 's|@@PREFIX@@|$(prefix)|' \\\n+\t\t< $@.sh > $@\n+\n+winworddiff.dot: winworddiff.bas\n+\t@echo\n+\t@echo '****  ATTENTION  ***'\n+\t@echo '* $@ must be created from $<'\n+\t@echo '* This cannot be done automatically, so your help is needed:'\n+\t@echo '* 1. Start Microsoft Word; create a new document *template*'\n+\t@echo '* 2. Open the Tools->Macro->Visual Basic Editor'\n+\t@echo '* 3. In the Project browser, locate and open:'\n+\t@echo '*        TemplateProject (Template1)'\n+\t@echo '*           Microsoft Word Objects'\n+\t@echo '*              ThisDocument'\n+\t@echo '* 4. Double-click \"ThisDocument\"'\n+\t@echo '* 5. Choose Insert->File... and select this file:'\n+\t@echo; echo \"`pwd`/$<\"; echo\n+\t@echo '* 6. Close the Visual Basic Editor'\n+\t@echo '* 7. Save the template as this file (overwrite if necessary):'\n+\t@echo; echo \"`pwd`/$@\"; echo\n+\t@echo '* 8. Run make again'\n+\t@exit 1\n+\n+-include ../../../config.mak\n+\n+install: all\n+\t$(INSTALL) winworddiff $(bindir)\n+\t$(INSTALL) winworddiff.dot $(datadir)\ndiff --git a/contrib/winword/diff/README b/contrib/winword/diff/README\nnew file mode 100644\nindex 0000000..dfbcdc3\n--- /dev/null\n+++ b/contrib/winword/diff/README\n@@ -0,0 +1,34 @@\n+This directory contains facilities that allow to highlight changes\n+between two revisions of WinWord documents.\n+\n+1.\tInstallation:\n+\ta.\tSet the variable WINWORDEXE in ../../../config.mak to point\n+\t\tto your installed WinWord.exe\n+\tb.\tRun 'make'. This will fail with instructions to\n+\t\tcreate a document template. (It boils down to import\n+\t\ta macro file into the template.) Once you have completed\n+\t\tthe instructions, 'make' will no longer fail.\n+\tc.\tRun 'make install'\n+\n+2.\tActivate diff in your repository\n+\ta.\tDefine a custom diff driver:\n+\n+\t\t\t$ git config diff.docdiff.command winworddiff\n+\n+\tb.\tUse the custom driver for your Word documents, i.e. put\n+\t\ta line like this in your .git/info/attributes:\n+\n+\t\t\t*.doc\tdiff=docdiff\n+\n+3.\tEnjoy the diffs:\n+\n+\t\t$ git diff HEAD~1.. -- UserManual.doc\n+\n+4.\tCaveats:\n+\n+\t-\tMacros must be enabled.\n+\n+\t-\tA new WinWord instance is started *for*each*document* that\n+\t\tis covered by the 'git diff' invocation; therefore, to be\n+\t\ton the safe side, always specify a path limiter. Use git-gui\n+\t\tand gitk to inspect diffs without path limiters.\ndiff --git a/contrib/winword/diff/winworddiff.bas b/contrib/winword/diff/winworddiff.bas\nnew file mode 100644\nindex 0000000..c7c7630\n--- /dev/null\n+++ b/contrib/winword/diff/winworddiff.bas\n@@ -0,0 +1,13 @@\n+Sub Document_Open()\n+    ' pick the last 2 documents, present changes from second-last to last\n+    ' (the third document is this one)\n+    Dim olddoc As Document, newdoc As Document\n+    With Application.Documents\n+        If .Count < 3 Then Exit Sub\n+        Set newdoc = .Item(.Count)\n+        Set olddoc = .Item(.Count - 1)\n+    End With\n+    newdoc.Activate\n+    newdoc.Compare Name:=olddoc.FullName\n+    newdoc.ShowRevisions = True\n+End Sub\ndiff --git a/contrib/winword/diff/winworddiff.sh b/contrib/winword/diff/winworddiff.sh\nnew file mode 100755\nindex 0000000..5adb97d\n--- /dev/null\n+++ b/contrib/winword/diff/winworddiff.sh\n@@ -0,0 +1,15 @@\n+#!/bin/sh\n+\n+word=\"@@WINWORDEXE@@\"\n+difftempl=\"@@PREFIX@@/share/winworddiff/winworddiff.dot\"\n+\n+test $# = 7 || {\n+\techo >&2 \"$0: expected 7 arguments:\"\n+\techo >&2 \"\tpath old oldsha1 oldmode new newsha1 newmode\"\n+\texit 1;\n+}\n+\n+of=\"$2\"\n+nf=\"$5\"\n+\n+\"$word\" -w \"$nf\" \"$of\" \"$difftempl\"\n-- \n1.5.3.3.gcc9e\n"},{"id":"54159","messageId":"11908935604108-git-send-email-johannes.sixt@telecom.at","threadId":"10044","inReplyTo":"11908935593618-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 2/2] winworddiff: Check the path to winword.exe during the installation.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-09-27T11:45:59Z","receivedAt":"2007-09-27T11:45:59Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Since we do not find the path to winword.exe automatically, but rely on\nwhat the user has told us, we better check the path for plausibility.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n contrib/winword/diff/Makefile |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/winword/diff/Makefile b/contrib/winword/diff/Makefile\nindex 61de940..91b9328 100644\n--- a/contrib/winword/diff/Makefile\n+++ b/contrib/winword/diff/Makefile\n@@ -1,3 +1,4 @@\n+# You can override any of these from ../../../config.mak\n prefix = $(HOME)\n bindir = $(prefix)/bin\n datadir = $(prefix)/share/winworddiff\n@@ -8,6 +9,9 @@ INSTALL = install\n all: winworddiff winworddiff.dot\n \n winworddiff: winworddiff.sh\n+ifndef FORCE\n+\texec < \"$(WINWORDEXE)\"\t# check existence; override with 'make FORCE=1'\n+endif\n \tsed\t-e 's|@@WINWORDEXE@@|$(WINWORDEXE)|' \\\n \t\t-e 's|@@PREFIX@@|$(prefix)|' \\\n \t\t< $@.sh > $@\n-- \n1.5.3.3.gcc9e\n"},{"id":"54162","messageId":"Pine.LNX.4.64.0709271258140.28395@racer.site","threadId":"10044","inReplyTo":"11908935593618-git-send-email-johannes.sixt@telecom.at","subject":"Re: [msysGit] [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-27T12:04:34Z","receivedAt":"2007-09-27T12:04:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 27 Sep 2007, Johannes Sixt wrote:\n\n> \tOk, here's something that shows how git helps solve REAL PROBLEMS.\n\nHehe.\n\n> +WINWORDEXE = C:/Program Files/Microsoft Office/Office/WINWORD.EXE\n\nAFAICT this would be better written as $(PROGRAMFILES) (but you have to \nadd proper quoting, I guess).\n\nOr, alternatively, you can get it with a simple Tcl script\n\n\tpackage require registry 1.0\n\tputs [regsub \"\\\\\" [registry get \\\n\t\t\"HKEY_CURRENT_USER\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Extensions\" \\\n\t\t \"doc\"] \"/\"]\n\nOr something like that.\n\nCiao,\nDscho\n"}]}