summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2013-08-14 16:38:14 +0200
committerFlorian Bruhin <git@the-compiler.org>2013-08-14 16:38:14 +0200
commit9f6bcae7bdae12433c6520f9ad74ff4659301946 (patch)
tree02ccafcf1145ae5d47c1fbc559d161e59074d9ba
parent7b71c6c21b24f987ed89476cb0ea898d23c3f9a0 (diff)
downloadgit2latex-master.tar.gz
git2latex-master.zip
New versionHEADmaster
-rw-r--r--git2latex.sh57
1 files changed, 42 insertions, 15 deletions
diff --git a/git2latex.sh b/git2latex.sh
index ae40c8d..8e3939a 100644
--- a/git2latex.sh
+++ b/git2latex.sh
@@ -1,6 +1,5 @@
#!/bin/bash
-bulletwidth=1
idwidth=8
datewidth=11
@@ -18,27 +17,55 @@ if [[ $1 == --full ]]; then
echo '\begin{document}'
fi
-echo '\newlength\gittextlength'
-echo '\setlength\gittextlength{\linewidth}'
-echo '\addtolength\gittextlength{-'"$((bulletwidth + idwidth + datewidth))"'ex}'
-echo '\newenvironment{gitcommits}%'
-echo ' {\begin{longtable}{'"p{${bulletwidth}ex}p{${idwidth}ex}p{${datewidth}ex}"'p{\the\gittextlength}}}%'
-echo ' {\end{longtable}}'
-echo '\newcommand{\gitcommit}[3]{\textbullet & \textbf{#1} & \emph{#2} & #3 \\}'
-echo
-echo '\begin{gitcommits}'
-
-{ git log --date=short --format='format:%h %ad %s'; echo; } | \
-while read -r id date msg; do
+cat << 'EOF'
+\begin{landscape}
+\newlength\gittextlength
+\newlength\gitidlength
+\newlength\gitdatelength
+\newlength\gitdecolength
+
+\setlength\gittextlength{\linewidth}
+\setlength\gitidlength{9ex}
+\setlength\gitdatelength{11ex}
+\setlength\gitdecolength{30ex}
+
+\addtolength\gittextlength{-\gitidlength}
+\addtolength\gittextlength{-\gitdatelength}
+\addtolength\gittextlength{-\gitidlength}
+\addtolength\gittextlength{-\gitdecolength}
+
+\newenvironment{gitcommits}%
+ {\begin{longtable}{p{\gitidlength}p{\gitdatelength}p{\gitdecolength}p{\gittextlength}}%
+ \textbf{ID} & \textbf{Datum} & \textbf{Tag/Branch} & \textbf{Commitmessage} \\ \hline }%
+ {\end{longtable}}
+\newcommand{\gitcommit}[4]{\textbf{#1} & #2 & #3 & #4 \\}
+
+\begin{gitcommits}
+EOF
+
+{ git log --date=short --format='format:%h%x1f%ad%x1f%d%x1f%s%x1f'; echo; } | \
+while read -r line; do
+ IFS=$'\x1f' read -r id date msg deco <<< "$line"
msg=$(sed -e 's/\\/\\textbackslash/g' \
-e 's/~/\\textasciitilde/g' \
-e 's/\^/\\textasciicircum/g' \
-e 's/[%$_#{}&]/\\&/g' \
-e 's/[^\]\\text\(asciitilde\|asciicircum\|backslash\)/&{}/g' \
<<< "$msg")
- echo " \\gitcommit{$id}{$date}{$msg}"
+ deco=${deco# *}
+ deco=$(sed -e 's/\\/\\textbackslash/g' \
+ -e 's/~/\\textasciitilde/g' \
+ -e 's/\^/\\textasciicircum/g' \
+ -e 's/[%$_#{}&]/\\&/g' \
+ -e 's/[^\]\\text\(asciitilde\|asciicircum\|backslash\)/&{}/g' \
+ <<< "$deco")
+ echo " \\gitcommit{$id}{$date}{$msg}{$deco}"
done
-echo '\end{gitcommits}'
+cat << 'EOF'
+\end{gitcommits}
+\end{landscape}
+EOF
[[ $1 == --full ]] && echo '\end{document}'
+exit 0