summaryrefslogtreecommitdiff
path: root/support/vc/git-unix/vc
blob: 63c737e4e3f4cced83dcbfd52b8a697565dcbf32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
# This is file 'vc' from the vc bundle for TeX.
# The original file can be found at CTAN:support/vc.
# This file is Public Domain.

# Parse command line options
full=0
mod=0
while [ -n "$(echo $1 | grep '-')" ]; do
	case $1 in
		-f)	full=1 ;;
		-m)	mod=1 ;;
		* )
			echo 'usage: vc [-f] [-m]'
			exit 1
			;;
	esac
	shift
done

# Query all info from git log
logformat=""
logformat="${logformat}Hash: %H%n"
logformat="${logformat}AbrHash: %h%n"
logformat="${logformat}ParentHashes: %P%n"
logformat="${logformat}AbrParentHashes: %p%n"
logformat="${logformat}AuthorName: %an%n"
logformat="${logformat}AuthorEmail: %ae%n"
logformat="${logformat}AuthorDate: %ai%n"
logformat="${logformat}CommitterName: %cn%n"
logformat="${logformat}CommitterEmail: %ce%n"
logformat="${logformat}CommitterDate: %ci%n"
LC_ALL=C
git --no-pager log -1 HEAD --pretty=format:"$logformat" \
	| gawk -v script=log -v full=$full -f vc-git.awk \
	> vc.tex

# Query modification status of the working copy
if [ "$mod" = 1 ]; then
	git status --porcelain=v1 \
		| gawk -v script=status -f vc-git.awk \
		>> vc.tex
fi