Skip to content

Commit c32af21

Browse files
committed
Convert doc and docx files to text by default
Converting Word files to text before diffing them allows an easier comparison between changed files. This reintroduces some functionality of Git for Windows 1.7.x+. It was requested by a user to reintroduce this feature in git-for-windows/git#355 . Signed-off-by: Matthias Aßhauer <[email protected]>
1 parent d930be0 commit c32af21

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

git-extra/PKGBUILD

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pkgname=('git-extra')
44
_ver_base=1.1
5-
pkgver=1.1.71.b45c943
5+
pkgver=1.1.73.6e1b584
66
pkgrel=1
77
pkgdesc="Git for Windows extra files"
88
arch=('i686' 'x86_64')
@@ -38,6 +38,7 @@ package() {
3838
install -d -m755 $pkgdir/usr/bin
3939
install -d -m755 $pkgdir/usr/share/git
4040
install -d -m755 $pkgdir/$mingwdir/bin
41+
install -d -m755 $pkgdir/$mingwdir/etc
4142
install -m644 $startdir/inputrc $pkgdir/etc
4243
install -m644 $startdir/vimrc $pkgdir/etc
4344
install -m755 $startdir/vi $pkgdir/usr/bin
@@ -50,4 +51,7 @@ package() {
5051
install -m755 $startdir/bash_profile.sh $pkgdir/etc/profile.d
5152
install -m644 $startdir/msys2-32.ico $pkgdir/usr/share/git
5253
install -m644 $startdir/99-post-install-cleanup.post $pkgdir/etc/post-install
54+
install -m755 $startdir/astextplain $pkgdir/$mingwdir/bin
55+
install -m755 $startdir/gitconfig $pkgdir/$mingwdir/etc
56+
install -m755 $startdir/gitattributes $pkgdir/$mingwdir/etc
5357
}

git-extra/astextplain

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh -e
2+
# minimalistic replacement for `run-mailcap --action=cat <file>`
3+
4+
if test "$#" != 1 ; then
5+
echo "Usage: astextplain <file>" 1>&2
6+
exit 1
7+
fi
8+
9+
# XXX output encoding (UTF-8) hardcoded
10+
case "$1" in
11+
*.doc | *.DOC | *.dot | *.DOT)
12+
antiword -m UTF-8 "$1" || cat "$1"
13+
;;
14+
*.docx | *.DOCX)
15+
docx2txt.pl "$1" -
16+
;;
17+
*.pdf | *.PDF)
18+
pdftotext -layout "$1" -enc UTF-8 -
19+
;;
20+
# TODO add rtf support
21+
*.rtf | *.RTF)
22+
cat "$1"
23+
;;
24+
*)
25+
echo "E: unsupported filetype $1" 1>&2
26+
exit 1
27+
;;
28+
esac
29+
30+
exit 0

git-extra/gitattributes

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.doc diff=astextplain
2+
*.DOC diff=astextplain
3+
*.docx diff=astextplain
4+
*.DOCX diff=astextplain
5+
*.dot diff=astextplain
6+
*.DOT diff=astextplain
7+
*.pdf diff=astextplain
8+
*.PDF diff=astextplain
9+
*.rtf diff=astextplain
10+
*.RTF diff=astextplain

make-file-list.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ pacman_list () {
2828
}
2929

3030
# Packages that have been added after Git SDK 1.0.0 was released...
31-
pacman -S --needed --noconfirm mingw-w64-$ARCH-connect git-flow >&2 ||
31+
pacman -S --needed --noconfirm mingw-w64-$ARCH-connect git-flow unzip docx2txt mingw-w64-$ARCH-antiword >&2 ||
3232
die "Could not install required packages"
3333

3434
pacman_list mingw-w64-$ARCH-git mingw-w64-$ARCH-git-doc-html \
3535
git-extra ncurses mintty vim openssh winpty \
3636
sed awk less grep gnupg tar findutils coreutils diffutils patch \
3737
dos2unix which subversion mingw-w64-$ARCH-tk \
38-
mingw-w64-$ARCH-connect git-flow "$@" |
38+
mingw-w64-$ARCH-connect git-flow docx2txt mingw-w64-$ARCH-antiword "$@" |
3939
grep -v -e '\.[acho]$' -e '\.l[ao]$' -e '/aclocal/' \
4040
-e '/man/' -e '/pkgconfig/' -e '/emacs/' \
4141
-e '^/usr/lib/python' -e '^/usr/lib/ruby' \
@@ -71,7 +71,7 @@ grep --perl-regexp -v -e '^/usr/(lib|share)/terminfo/(?!.*/(cygwin|dumb|xterm.*)
7171
sed 's/^\///'
7272

7373
test -z "$PACKAGE_VERSIONS_FILE" ||
74-
pacman -Q filesystem dash rebase util-linux >>"$PACKAGE_VERSIONS_FILE"
74+
pacman -Q filesystem dash rebase util-linux unzip >>"$PACKAGE_VERSIONS_FILE"
7575

7676
cat <<EOF
7777
etc/profile
@@ -89,4 +89,8 @@ usr/bin/dash.exe
8989
usr/bin/rebase.exe
9090
usr/bin/rebaseall
9191
usr/bin/getopt.exe
92+
mingw$BITNESS/bin/astextplain
93+
mingw$BITNESS/etc/gitattributes
94+
mingw$BITNESS/etc/gitconfig
95+
usr/bin/unzip.exe
9296
EOF

0 commit comments

Comments
 (0)