* [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents
@ 2007-09-27 11:45 Johannes Sixt
2007-09-27 11:45 ` [PATCH 2/2] winworddiff: Check the path to winword.exe during the installation Johannes Sixt
2007-09-27 12:04 ` [msysGit] [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents Johannes Schindelin
0 siblings, 2 replies; 3+ messages in thread
From: Johannes Sixt @ 2007-09-27 11:45 UTC (permalink / raw)
To: git, msysgit; +Cc: Johannes Sixt
A shell script opens WinWord with the documents and a document template.
The document template contains a VBA macro that is run automatically.
It looks up the two documents and performs the comparison.
Unfortunately, the user's help is needed to construct the document template
with the macro from a plain text file, so we print the instructions from
the Makefile.
The README file contains instructions how to use this feature.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
Ok, here's something that shows how git helps solve REAL PROBLEMS.
I've been using this for a day or two now with the MinGW port.
Other Windows prisoners might be interested, too.
Be sure to read the README and take a deap breath of the
fresh air.
;)
This was only tested with a localized version Microsoft Office 2000,
so your milage may vary.
-- Hannes
contrib/winword/diff/.gitignore | 2 +
contrib/winword/diff/Makefile | 39 ++++++++++++++++++++++++++++++++++
contrib/winword/diff/README | 34 +++++++++++++++++++++++++++++
contrib/winword/diff/winworddiff.bas | 13 +++++++++++
contrib/winword/diff/winworddiff.sh | 15 +++++++++++++
5 files changed, 103 insertions(+), 0 deletions(-)
create mode 100644 contrib/winword/diff/.gitignore
create mode 100644 contrib/winword/diff/Makefile
create mode 100644 contrib/winword/diff/README
create mode 100644 contrib/winword/diff/winworddiff.bas
create mode 100755 contrib/winword/diff/winworddiff.sh
diff --git a/contrib/winword/diff/.gitignore b/contrib/winword/diff/.gitignore
new file mode 100644
index 0000000..f37a3c4
--- /dev/null
+++ b/contrib/winword/diff/.gitignore
@@ -0,0 +1,2 @@
+winworddiff
+winworddiff.dot
diff --git a/contrib/winword/diff/Makefile b/contrib/winword/diff/Makefile
new file mode 100644
index 0000000..61de940
--- /dev/null
+++ b/contrib/winword/diff/Makefile
@@ -0,0 +1,39 @@
+prefix = $(HOME)
+bindir = $(prefix)/bin
+datadir = $(prefix)/share/winworddiff
+
+WINWORDEXE = C:/Program Files/Microsoft Office/Office/WINWORD.EXE
+INSTALL = install
+
+all: winworddiff winworddiff.dot
+
+winworddiff: winworddiff.sh
+ sed -e 's|@@WINWORDEXE@@|$(WINWORDEXE)|' \
+ -e 's|@@PREFIX@@|$(prefix)|' \
+ < $@.sh > $@
+
+winworddiff.dot: winworddiff.bas
+ @echo
+ @echo '**** ATTENTION ***'
+ @echo '* $@ must be created from $<'
+ @echo '* This cannot be done automatically, so your help is needed:'
+ @echo '* 1. Start Microsoft Word; create a new document *template*'
+ @echo '* 2. Open the Tools->Macro->Visual Basic Editor'
+ @echo '* 3. In the Project browser, locate and open:'
+ @echo '* TemplateProject (Template1)'
+ @echo '* Microsoft Word Objects'
+ @echo '* ThisDocument'
+ @echo '* 4. Double-click "ThisDocument"'
+ @echo '* 5. Choose Insert->File... and select this file:'
+ @echo; echo "`pwd`/$<"; echo
+ @echo '* 6. Close the Visual Basic Editor'
+ @echo '* 7. Save the template as this file (overwrite if necessary):'
+ @echo; echo "`pwd`/$@"; echo
+ @echo '* 8. Run make again'
+ @exit 1
+
+-include ../../../config.mak
+
+install: all
+ $(INSTALL) winworddiff $(bindir)
+ $(INSTALL) winworddiff.dot $(datadir)
diff --git a/contrib/winword/diff/README b/contrib/winword/diff/README
new file mode 100644
index 0000000..dfbcdc3
--- /dev/null
+++ b/contrib/winword/diff/README
@@ -0,0 +1,34 @@
+This directory contains facilities that allow to highlight changes
+between two revisions of WinWord documents.
+
+1. Installation:
+ a. Set the variable WINWORDEXE in ../../../config.mak to point
+ to your installed WinWord.exe
+ b. Run 'make'. This will fail with instructions to
+ create a document template. (It boils down to import
+ a macro file into the template.) Once you have completed
+ the instructions, 'make' will no longer fail.
+ c. Run 'make install'
+
+2. Activate diff in your repository
+ a. Define a custom diff driver:
+
+ $ git config diff.docdiff.command winworddiff
+
+ b. Use the custom driver for your Word documents, i.e. put
+ a line like this in your .git/info/attributes:
+
+ *.doc diff=docdiff
+
+3. Enjoy the diffs:
+
+ $ git diff HEAD~1.. -- UserManual.doc
+
+4. Caveats:
+
+ - Macros must be enabled.
+
+ - A new WinWord instance is started *for*each*document* that
+ is covered by the 'git diff' invocation; therefore, to be
+ on the safe side, always specify a path limiter. Use git-gui
+ and gitk to inspect diffs without path limiters.
diff --git a/contrib/winword/diff/winworddiff.bas b/contrib/winword/diff/winworddiff.bas
new file mode 100644
index 0000000..c7c7630
--- /dev/null
+++ b/contrib/winword/diff/winworddiff.bas
@@ -0,0 +1,13 @@
+Sub Document_Open()
+ ' pick the last 2 documents, present changes from second-last to last
+ ' (the third document is this one)
+ Dim olddoc As Document, newdoc As Document
+ With Application.Documents
+ If .Count < 3 Then Exit Sub
+ Set newdoc = .Item(.Count)
+ Set olddoc = .Item(.Count - 1)
+ End With
+ newdoc.Activate
+ newdoc.Compare Name:=olddoc.FullName
+ newdoc.ShowRevisions = True
+End Sub
diff --git a/contrib/winword/diff/winworddiff.sh b/contrib/winword/diff/winworddiff.sh
new file mode 100755
index 0000000..5adb97d
--- /dev/null
+++ b/contrib/winword/diff/winworddiff.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+word="@@WINWORDEXE@@"
+difftempl="@@PREFIX@@/share/winworddiff/winworddiff.dot"
+
+test $# = 7 || {
+ echo >&2 "$0: expected 7 arguments:"
+ echo >&2 " path old oldsha1 oldmode new newsha1 newmode"
+ exit 1;
+}
+
+of="$2"
+nf="$5"
+
+"$word" -w "$nf" "$of" "$difftempl"
--
1.5.3.3.gcc9e
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] winworddiff: Check the path to winword.exe during the installation.
2007-09-27 11:45 [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents Johannes Sixt
@ 2007-09-27 11:45 ` Johannes Sixt
2007-09-27 12:04 ` [msysGit] [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents Johannes Schindelin
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Sixt @ 2007-09-27 11:45 UTC (permalink / raw)
To: git, msysgit; +Cc: Johannes Sixt
Since we do not find the path to winword.exe automatically, but rely on
what the user has told us, we better check the path for plausibility.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
contrib/winword/diff/Makefile | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/contrib/winword/diff/Makefile b/contrib/winword/diff/Makefile
index 61de940..91b9328 100644
--- a/contrib/winword/diff/Makefile
+++ b/contrib/winword/diff/Makefile
@@ -1,3 +1,4 @@
+# You can override any of these from ../../../config.mak
prefix = $(HOME)
bindir = $(prefix)/bin
datadir = $(prefix)/share/winworddiff
@@ -8,6 +9,9 @@ INSTALL = install
all: winworddiff winworddiff.dot
winworddiff: winworddiff.sh
+ifndef FORCE
+ exec < "$(WINWORDEXE)" # check existence; override with 'make FORCE=1'
+endif
sed -e 's|@@WINWORDEXE@@|$(WINWORDEXE)|' \
-e 's|@@PREFIX@@|$(prefix)|' \
< $@.sh > $@
--
1.5.3.3.gcc9e
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [msysGit] [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents
2007-09-27 11:45 [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents Johannes Sixt
2007-09-27 11:45 ` [PATCH 2/2] winworddiff: Check the path to winword.exe during the installation Johannes Sixt
@ 2007-09-27 12:04 ` Johannes Schindelin
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2007-09-27 12:04 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, msysgit
Hi,
On Thu, 27 Sep 2007, Johannes Sixt wrote:
> Ok, here's something that shows how git helps solve REAL PROBLEMS.
Hehe.
> +WINWORDEXE = C:/Program Files/Microsoft Office/Office/WINWORD.EXE
AFAICT this would be better written as $(PROGRAMFILES) (but you have to
add proper quoting, I guess).
Or, alternatively, you can get it with a simple Tcl script
package require registry 1.0
puts [regsub "\\" [registry get \
"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Extensions" \
"doc"] "/"]
Or something like that.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-27 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-27 11:45 [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents Johannes Sixt
2007-09-27 11:45 ` [PATCH 2/2] winworddiff: Check the path to winword.exe during the installation Johannes Sixt
2007-09-27 12:04 ` [msysGit] [PATCH 1/2] contrib: Add diff viewing capability for Microsoft Word documents Johannes Schindelin
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).