[tor-commits] [tor-design-2012/master] Add a Git revision header and update .gitignore

sjm217 at torproject.org sjm217 at torproject.org
Tue Dec 17 16:36:18 UTC 2013


commit 2ea9fe0a0e6133e52ac19a86c4304b6a97b5890c
Author: Steven Murdoch <Steven.Murdoch at cl.cam.ac.uk>
Date:   Mon Dec 16 18:29:24 2013 +0000

    Add a Git revision header and update .gitignore
---
 .gitignore          |    3 +-
 Makefile            |    7 ++--
 tor-design-2012.tex |   12 +++++++
 vc                  |   24 ++++++++++++++
 vc-git.awk          |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 132 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index f1ba132..2047e1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,9 @@
 *~
+*.swp
 
 /tor-design-2012.aux
 /tor-design-2012.bbl
 /tor-design-2012.blg
 /tor-design-2012.log
 /tor-design-2012.pdf
-
+/vc._include_.tex
diff --git a/Makefile b/Makefile
index efbc840..c484403 100644
--- a/Makefile
+++ b/Makefile
@@ -9,14 +9,17 @@ cell-struct.pdf: cell-struct.fig
 interaction.pdf: interaction.fig
 	fig2dev -L pdf $< $@
 
-tor-design-2012.ps: cell-struct.eps interaction.eps tor-design-2012.bib tor-design-2012.tex usenix.sty latex8.bst
+vc._include_.tex: vc tor-design-2012.bib tor-design-2012.tex
+	./vc -m && mv vc.tex $@
+
+tor-design-2012.ps: cell-struct.eps interaction.eps tor-design-2012.bib tor-design-2012.tex usenix.sty latex8.bst vc._include_.tex
 	latex tor-design-2012.tex
 	bibtex tor-design-2012
 	latex tor-design-2012.tex
 	latex tor-design-2012.tex
 	dvips -o $@ tor-design-2012.dvi
 
-tor-design-2012.pdf: cell-struct.pdf interaction.pdf tor-design-2012.bib tor-design-2012.tex usenix.sty latex8.bst
+tor-design-2012.pdf: cell-struct.pdf interaction.pdf tor-design-2012.bib tor-design-2012.tex usenix.sty latex8.bst vc._include_.tex
 	pdflatex tor-design-2012.tex
 	bibtex tor-design-2012
 	pdflatex tor-design-2012.tex
diff --git a/tor-design-2012.tex b/tor-design-2012.tex
index 1766883..1efb544 100644
--- a/tor-design-2012.tex
+++ b/tor-design-2012.tex
@@ -8,7 +8,10 @@
 \usepackage{graphics}
 \usepackage{prettyref}
 \usepackage{amsmath}
+\usepackage{fancyhdr}
+\usepackage{color}
 \usepackage{epsfig}
+\input{vc._include_.tex}
 
 \pagestyle{empty}
 
@@ -44,6 +47,15 @@
 % Cut down on whitespace above and below figures displayed in middle of page
 \setlength{\intextsep}{3mm}
 
+\pagestyle{fancy}
+\fancyhf{}
+\setlength{\headheight}{12pt}
+\setlength{\voffset}{-0.2in}
+\setlength{\headsep}{25pt}
+
+\fancyhead[C]{\sc revision \VCRevisionMod~(\VCDateISO~\VCTime)}
+\fancyfoot[C]{\thepage}
+
 \begin{document}
 
 %% Use dvipdfm instead. --DH
diff --git a/vc b/vc
new file mode 100755
index 0000000..807689d
--- /dev/null
+++ b/vc
@@ -0,0 +1,24 @@
+#!/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
+# English locale.
+LC_ALL=C
+git --no-pager log -1 HEAD --pretty=format:"Hash: %H%nAbr. Hash: %h%nParent Hashes: %P%nAbr. Parent Hashes: %p%nAuthor Name: %an%nAuthor Email: %ae%nAuthor Date: %ai%nCommitter Name: %cn%nCommitter Email: %ce%nCommitter Date: %ci%n" |gawk -v script=log -v full=$full -f vc-git.awk > vc.tex
+if [ "$mod" = 1 ]
+then
+  git -c color.ui=never status |gawk -v script=status -f vc-git.awk >> vc.tex
+fi
diff --git a/vc-git.awk b/vc-git.awk
new file mode 100644
index 0000000..a79977a
--- /dev/null
+++ b/vc-git.awk
@@ -0,0 +1,89 @@
+# This is file 'vc-git.awk' from the vc bundle for TeX.
+# The original file can be found at CTAN:support/vc.
+# This file is Public Domain.
+BEGIN {
+		
+### Process output of "git status".
+		if (script=="status") {
+				modified = 0
+		}
+
+}
+
+
+
+### Process output of "git log".
+script=="log" && /^Hash:/ { Hash = substr($0, 2+match($0, ":")) }
+script=="log" && /^Abr. Hash:/ { AbrHash = substr($0, 2+match($0, ":")) }
+script=="log" && /^Parent Hashes:/ { ParentHashes = substr($0, 2+match($0, ":")) }
+script=="log" && /^Abr. Parent Hashes:/ { AbrParentHashes = substr($0, 2+match($0, ":")) }
+script=="log" && /^Author Name:/ { AuthorName = substr($0, 2+match($0, ":")) }
+script=="log" && /^Author Email:/ { AuthorEmail = substr($0, 2+match($0, ":")) }
+script=="log" && /^Author Date:/ { AuthorDate = substr($0, 2+match($0, ":")) }
+script=="log" && /^Committer Name:/ { CommitterName = substr($0, 2+match($0, ":")) }
+script=="log" && /^Committer Email:/ { CommitterEmail = substr($0, 2+match($0, ":")) }
+script=="log" && /^Committer Date:/ { CommitterDate = substr($0, 2+match($0, ":")) }
+
+### Process output of "git status".
+### Changed index?
+script=="status" && /^Changes to be committed:/ { modified = 1 }
+### Unstaged modifications?
+script=="status" && /^Changes not staged for commit:/ { modified = 2 }
+
+
+
+END {
+		
+### Process output of "git log".
+		if (script=="log") {
+### Standard encoding is UTF-8.
+				if (Encoding == "") Encoding = "UTF-8"
+### Extract relevant information from variables.
+				LongDate = substr(AuthorDate, 1, 25)
+        DateRAW = substr(LongDate, 1, 10)
+        DateISO = DateRAW
+        DateTEX = DateISO
+        gsub("-", "/", DateTEX)
+				Time = substr(LongDate, 12, 14)
+### Write file identification to vc.tex.
+				print "%%% This file has been generated by the vc bundle for TeX."
+				print "%%% Do not edit this file!"
+				print "%%%"
+### Write Git specific macros.
+				print "%%% Define Git specific macros."
+				print "\\gdef\\GITHash{" Hash "}%"
+				print "\\gdef\\GITAbrHash{" AbrHash "}%"
+				print "\\gdef\\GITParentHashes{" ParentHashes "}%"
+				print "\\gdef\\GITAbrParentHashes{" AbrParentHashes "}%"
+				print "\\gdef\\GITAuthorName{" AuthorName "}%"
+				print "\\gdef\\GITAuthorEmail{" AuthorEmail "}%"
+				print "\\gdef\\GITAuthorDate{" AuthorDate "}%"
+				print "\\gdef\\GITCommitterName{" CommitterName "}%"
+				print "\\gdef\\GITCommitterEmail{" CommitterEmail "}%"
+				print "\\gdef\\GITCommitterDate{" CommitterDate "}%"
+### Write generic version control macros.
+				print "%%% Define generic version control macros."
+				print "\\gdef\\VCRevision{\\GITAbrHash}%"
+				print "\\gdef\\VCAuthor{\\GITAuthorName}%"
+        print "\\gdef\\VCDateRAW{" DateRAW "}%"
+        print "\\gdef\\VCDateISO{" DateISO "}%"
+        print "\\gdef\\VCDateTEX{" DateTEX "}%"
+				print "\\gdef\\VCTime{" Time "}%"
+				print "\\gdef\\VCModifiedText{\\textcolor{red}{with local modifications!}}%"
+				print "%%% Assume clean working copy."
+				print "\\gdef\\VCModified{0}%"
+				print "\\gdef\\VCRevisionMod{\\VCRevision}%"
+		}
+		
+### Process output of "git status".
+		if (script=="status") {
+				print "%%% Is working copy modified?"
+				print "\\gdef\\VCModified{" modified "}%"
+				if (modified==0) {
+						print "\\gdef\\VCRevisionMod{\\VCRevision}%"
+				} else {
+						print "\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%"
+				}
+		}
+		
+}



More information about the tor-commits mailing list