Skip to content

Commit 69b301b

Browse files
committed
git-extra: wrap 'notepad' so it can serve as Git's editor
Windows' notepad.exe handles only DOS line endings and it cannot wrap any lines. That makes it less useful as a commit message editor. So let's wrap it in a shell script that adds DOS line endings before, and strips them after running notepad.exe. Also, to make it appropriate as commit message editor, interpret a new config variable "format.commitMessageColumns" and line-wrap the commit message accordingly. This very commit message, in fact, was written using that notepad wrapper with "format.commitMessageColumns" set to 72. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 01503bf commit 69b301b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

git-extra/PKGBUILD

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ package() {
4141
install -m644 $startdir/inputrc $pkgdir/etc
4242
install -m644 $startdir/vimrc $pkgdir/etc
4343
install -m755 $startdir/vi $pkgdir/usr/bin
44+
install -m755 $startdir/notepad $pkgdir/usr/bin
4445
install -m755 $startdir/wordpad $pkgdir/usr/bin
4546
install -m755 create-shortcut.exe $pkgdir/$mingwdir/bin
4647
install -m755 $startdir/git-prompt.sh $pkgdir/etc/profile.d

git-extra/notepad

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
die () {
4+
echo "$*" >&2
5+
exit 1
6+
}
7+
8+
test $# = 1 ||
9+
die "Usage: $0 <file>"
10+
11+
if test -f "$1"
12+
then
13+
unix2dos.exe "$1"
14+
fi &&
15+
notepad.exe "$1" &&
16+
dos2unix.exe "$1" &&
17+
case "$1" in
18+
*/COMMIT_EDITMSG|*\\COMMIT_EDITMSG)
19+
columns="$(git config format.commitmessagecolumns)" &&
20+
test -z "$columns" || {
21+
msg="$(fmt.exe -s -w "$columns" "$1")" &&
22+
printf "%s" "$msg" >"$1"
23+
}
24+
;;
25+
esac

0 commit comments

Comments
 (0)