{"thread":{"id":"29635","subject":"[PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","startedAt":"2012-02-15T15:49:47Z","lastAt":"2012-02-20T12:00:26Z","messageCount":22,"participants":["Matthieu Moy","Tim Haga","Steven Michalske","Jakub Narebski","David Aguilar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"184768","messageId":"1329320987-15203-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"29635","inReplyTo":null,"subject":"[PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-02-15T15:49:47Z","receivedAt":"2012-02-15T15:49:47Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"git-latexdiff is a wrapper around latexdiff\n(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two\nrevisions of a LaTeX file.\n\ngit-latexdiff is made to work on documents split accross multiple .tex\nfiles (plus possibly figures and other non-diffable files), hence could\nnot be implemented as a per-file diff driver.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n\nIt seems at least one person is interested in my script, so it\nprobably deserves to be in contrib/ ;-).\n\n contrib/latex/Makefile      |   22 ++++\n contrib/latex/README        |   12 +++\n contrib/latex/git-latexdiff |  222 +++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 256 insertions(+), 0 deletions(-)\n create mode 100644 contrib/latex/Makefile\n create mode 100644 contrib/latex/README\n create mode 100755 contrib/latex/git-latexdiff\n\ndiff --git a/contrib/latex/Makefile b/contrib/latex/Makefile\nnew file mode 100644\nindex 0000000..4617906\n--- /dev/null\n+++ b/contrib/latex/Makefile\n@@ -0,0 +1,22 @@\n+-include ../../config.mak\n+-include ../../config.mak.autogen\n+\n+ifndef SHELL_PATH\n+\tSHELL_PATH = /bin/sh\n+endif\n+\n+SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n+gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+\n+SCRIPT=git-latexdiff\n+\n+.PHONY: install help\n+help:\n+\t@echo 'This is the help target of the Makefile. Current configuration:'\n+\t@echo '  gitexecdir = $(gitexecdir_SQ)'\n+\t@echo '  SHELL_PATH = $(SHELL_PATH_SQ)'\n+\t@echo 'Run \"$(MAKE) install\" to install $(SCRIPT) in gitexecdir.'\n+\n+install:\n+\tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' $(SCRIPT) > '$(gitexecdir_SQ)/$(SCRIPT)'\n+\tchmod 755 '$(gitexecdir)/$(SCRIPT)'\ndiff --git a/contrib/latex/README b/contrib/latex/README\nnew file mode 100644\nindex 0000000..2d7fdd6\n--- /dev/null\n+++ b/contrib/latex/README\n@@ -0,0 +1,12 @@\n+git-latexdiff is a wrapper around latexdiff\n+(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two\n+revisions of a LaTeX file.\n+\n+The script internally checks out the full tree for the specified\n+revisions, and calls latexdiff with the --flatten option, hence this\n+works if the document is split into multiple .tex files.\n+\n+Try \"git latexdiff -h\" for more information.\n+\n+To install, either drop git-latexdiff in your $PATH, or run \"make\n+install\".\ndiff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff\nnew file mode 100755\nindex 0000000..13aeb9a\n--- /dev/null\n+++ b/contrib/latex/git-latexdiff\n@@ -0,0 +1,222 @@\n+#! /bin/sh\n+\n+# Author: Matthieu Moy <Matthieu.Moy@imag.fr> (2012)\n+\n+# Missing features (patches welcome ;-) :\n+# - diff the index or the current worktree \n+# - checkout only a subdirectory of the repo\n+# - hardlink temporary checkouts as much as possible\n+\n+usage () {\n+            cat << EOF\n+Usage: $(basename $0) [options] OLD [NEW]\n+Call latexdiff on two Git revisions of a file.\n+\n+OLD and NEW are Git revision identifiers. NEW defaults to HEAD.\n+\n+Options:\n+\t--help\t\tThis help message\n+\t--main FILE.tex\tName of the main LaTeX file\n+\t--no-view\tDon't display the resulting PDF file\n+\t--view\t\tView the resulting PDF file\n+\t\t\t(default if -o is not used)\n+\t--no-cleanup\tDon't cleanup temp dir after running\n+\t-o FILE, --output FILE\n+\t\t\tCopy resulting PDF into FILE\n+\t\t\t(usually ending with .pdf)\n+EOF\n+}\n+\n+die () {\n+    echo \"fatal: $@\"\n+    exit 1\n+}\n+\n+verbose () {\n+    if [ \"$verbose\" = 1 ]; then\n+\tprintf \"%s ...\" \"$@\"\n+    fi\n+}\n+\n+verbose_progress () {\n+    if [ \"$verbose\" = 1 ]; then\n+\tprintf \".\" \"$@\"\n+    fi\n+}\n+\n+verbose_done () {\n+    if [ \"$verbose\" = 1 ]; then\n+\techo \" done.\"\n+    fi\n+}\n+\n+old=\n+new=\n+main=\n+view=maybe\n+cleanup=1\n+verbose=0\n+output=\n+initial_dir=$PWD\n+\n+while test $# -ne 0; do\n+    case \"$1\" in\n+        \"--help\"|\"-h\")\n+            usage\n+            exit 0\n+            ;;\n+\t\"--main\")\n+\t    shift\n+\t    main=$1\n+\t    ;;\n+\t\"--no-view\")\n+\t    view=0\n+\t    ;;\n+\t\"--view\")\n+\t    view=1\n+\t    ;;\n+\t\"--no-cleanup\")\n+\t    cleanup=0\n+\t    ;;\n+\t\"-o\"|\"--output\")\n+\t    shift\n+\t    output=$1\n+\t    ;;\n+\t\"--verbose\"|\"-v\")\n+\t    verbose=1\n+\t    ;;\n+        *)\n+\t    if [ \"$1\" = \"\" ]; then\n+\t\techo \"Empty string not allowed as argument\"\n+\t\tusage\n+\t\texit 1\n+\t    elif [ \"$old\" = \"\" ]; then\n+\t\told=$1\n+\t    elif [ \"$new\" = \"\" ]; then\n+\t\tnew=$1\n+\t    else\n+\t\techo \"Bad argument $1\"\n+\t\tusage\n+\t\texit 1\n+\t    fi\n+            ;;\n+    esac\n+    shift\n+done\n+\n+if [ \"$new\" = \"\" ]; then\n+    new=HEAD\n+fi\n+\n+if [ \"$old\" = \"\" ]; then\n+    echo \"fatal: Please, provide at least one revision to diff with.\"\n+    usage\n+    exit 1\n+fi\n+\n+if [ \"$main\" = \"\" ]; then\n+    printf \"%s\" \"No --main provided, trying to guess ... \"\n+    main=$(git grep -l '^[ \\t]*\\\\documentclass')\n+    # May return multiple results, but if so the result won't be a file.\n+    if [ -r \"$main\" ]; then\n+\techo \"Using $main as the main file.\"\n+    else\n+\tif [ \"$main\" = \"\" ]; then\n+\t    echo \"No candidate for main file.\"\n+\telse\n+\t    echo \"Multiple candidates for main file:\"\n+\t    printf \"%s\\n\" \"$main\" | sed 's/^/\\t/'\n+\tfi\n+\tdie \"Please, provide a main file with --main FILE.tex.\"\n+    fi\n+fi\n+\n+if [ ! -r \"$main\" ]; then\n+    die \"Cannot read $main.\"\n+fi\n+\n+verbose \"Creating temporary directories\"\n+\n+git_prefix=$(git rev-parse --show-prefix)\n+cd \"$(git rev-parse --show-cdup)\" || die \"Can't cd back to repository root\"\n+git_dir=\"$(git rev-parse --git-dir)\" || die \"Not a git repository?\"\n+git_dir=$(cd \"$git_dir\"; pwd)\n+\n+main=$git_prefix/$main\n+\n+tmpdir=$initial_dir/git-latexdiff.$$\n+mkdir \"$tmpdir\" || die \"Cannot create temporary directory.\"\n+\n+cd \"$tmpdir\" || die \"Cannot cd to $tmpdir\"\n+\n+mkdir old new diff || die \"Cannot create old, new and diff directories.\"\n+\n+verbose_done\n+verbose \"Checking out old and new version\"\n+\n+cd old || die \"Cannot cd to old/\"\n+git --git-dir=\"$git_dir\" --work-tree=. checkout \"$old\" -- . || die \"checkout failed for old/\"\n+verbose_progress\n+cd ../new || die \"Cannot cd to new/\"\n+git --git-dir=\"$git_dir\" --work-tree=. checkout \"$new\" -- . || die \"checkout failed for new/\"\n+verbose_progress\n+cd ..\n+\n+verbose_done\n+verbose \"Running latexdiff --flatten old/$main new/$main > $main\"\n+\n+latexdiff --flatten old/\"$main\" new/\"$main\" > diff.tex || die \"latexdiff failed\"\n+\n+mv -f diff.tex new/\"$main\"\n+\n+verbose_done\n+\n+mainbase=$(basename \"$main\" .tex)\n+maindir=$(dirname \"$main\")\n+\n+verbose \"Compiling result\"\n+\n+compile_error=0\n+cd new/\"$maindir\" || die \"Can't cd to new/$maindir\"\n+if [ -f Makefile ]; then\n+    make || compile_error=1\n+else\n+    pdflatex --interaction errorstopmode \"$mainbase\" || compile_error=1\n+fi\n+\n+verbose_done\n+\n+pdffile=\"$mainbase\".pdf\n+if [ ! -r \"$pdffile\" ]; then\n+    echo \"No PDF file generated.\"\n+    compile_error=1\n+fi\n+\n+if [ ! -s \"$pdffile\" ]; then\n+    echo \"PDF file generated is empty.\"\n+    compile_error=1\n+fi\n+\n+if [ \"$compile_error\" = \"1\" ]; then\n+    echo \"Error during compilation. Please examine and cleanup if needed:\"\n+    echo \"Directory: $tmpdir/new/$maindir/\"\n+    echo \"     File: $mainbase.tex\"\n+    # Don't clean up to let the user diagnose.\n+    exit 1\n+fi\n+\n+if [ \"$output\" != \"\" ]; then\n+    abs_pdffile=\"$PWD/$pdffile\"\n+    (cd \"$initial_dir\" && cp \"$abs_pdffile\" \"$output\")\n+    echo \"Output written on $output\"\n+fi\n+\n+if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n+    xpdf \"$pdffile\"\n+fi\n+\n+if [ \"$cleanup\" = 1 ]; then\n+    verbose \"Cleaning-up result\"\n+    rm -fr \"$tmpdir\"\n+    verbose_done\n+fi\n-- \n1.7.9.111.gf3fb0.dirty\n"},{"id":"184796","messageId":"20120216003300.17228570@sirion","threadId":"29635","inReplyTo":"1329320987-15203-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Tim Haga","fromEmail":"timhaga@ebene6.org","sentAt":"2012-02-15T23:33:00Z","receivedAt":"2012-02-15T23:33:00Z","isPatch":true,"sender":{"key":"timhaga@ebene6.org","avatar":null},"body":"While testing your script on my office machine i discovered that the\nfollowing might be a problem:\n\n> +if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n> +    xpdf \"$pdffile\"\n> +fi\n\nXpdf is not installed on all machines (e.g. it's not installed on my\noffice machine), so maybe it would be a good idea to use a environment\nvariable instead?\n\n\nTim\n"},{"id":"184815","messageId":"vpq39abrxav.fsf@bauges.imag.fr","threadId":"29635","inReplyTo":"20120216003300.17228570@sirion","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-16T08:34:48Z","receivedAt":"2012-02-16T08:34:48Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Tim Haga <timhaga@ebene6.org> writes:\n\n> While testing your script on my office machine i discovered that the\n> following might be a problem:\n>\n>> +if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n>> +    xpdf \"$pdffile\"\n>> +fi\n>\n> Xpdf is not installed on all machines (e.g. it's not installed on my\n> office machine), so maybe it would be a good idea to use a environment\n> variable instead?\n\nRight. I'm squashing this into the next version to allow configuration\n(environment variable or --pdf-viewer) and sensible auto-detection:\n\ndiff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff\nindex 13aeb9a..85aafda 100755\n--- a/contrib/latex/git-latexdiff\n+++ b/contrib/latex/git-latexdiff\n@@ -20,6 +20,8 @@ Options:\n \t--no-view\tDon't display the resulting PDF file\n \t--view\t\tView the resulting PDF file\n \t\t\t(default if -o is not used)\n+\t--pdf-viewer CMD\n+\t\t\tUse CMD to view the PDF file (default: \\$PDFVIEWER)\n \t--no-cleanup\tDon't cleanup temp dir after running\n \t-o FILE, --output FILE\n \t\t\tCopy resulting PDF into FILE\n@@ -46,7 +48,7 @@ verbose_progress () {\n \n verbose_done () {\n     if [ \"$verbose\" = 1 ]; then\n-\techo \" done.\"\n+\techo \" ${1:-done}.\"\n     fi\n }\n \n@@ -75,6 +77,10 @@ while test $# -ne 0; do\n \t\"--view\")\n \t    view=1\n \t    ;;\n+\t\"--pdf-viewer\")\n+\t    shift\n+\t    PDFVIEWER=\"$1\"\n+\t    ;;\n \t\"--no-cleanup\")\n \t    cleanup=0\n \t    ;;\n@@ -114,6 +120,28 @@ if [ \"$old\" = \"\" ]; then\n     exit 1\n fi\n \n+verbose \"Auto-detecting PDF viewer\"\n+for command in xdg-open evince okular xpdf acroread; do\n+    if [ \"$PDFVIEWER\" = \"\" ]; then\n+\tif command -v \"$command\" >/dev/null 2>&1; then\n+\t    PDFVIEWER=\"$command\"\n+\telse\n+\t    verbose_progress\n+\tfi\n+    fi\n+done\n+verbose_done \"$PDFVIEWER\"\n+\n+case \"$view\" in\n+    maybe|1)\n+\tif [ \"$PDFVIEWER\" = \"\" ]; then\n+\t    echo \"warning: could not find a PDF viewer on your system.\"\n+\t    echo \"warning: Please set \\$PDFVIEWER or use --pdf-viewer CMD.\"\n+\t    PDFVIEWER=false\n+\tfi\n+\t;;\n+esac\n+\n if [ \"$main\" = \"\" ]; then\n     printf \"%s\" \"No --main provided, trying to guess ... \"\n     main=$(git grep -l '^[ \\t]*\\\\documentclass')\n@@ -212,7 +240,7 @@ if [ \"$output\" != \"\" ]; then\n fi\n \n if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n-    xpdf \"$pdffile\"\n+    \"$PDFVIEWER\" \"$pdffile\"\n fi\n \n if [ \"$cleanup\" = 1 ]; then\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"184816","messageId":"1329381560-15853-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"29635","inReplyTo":"vpq39abrxav.fsf@bauges.imag.fr","subject":"[PATCH v2] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-02-16T08:39:20Z","receivedAt":"2012-02-16T08:39:20Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"git-latexdiff is a wrapper around latexdiff\n(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two\nrevisions of a LaTeX file.\n\ngit-latexdiff is made to work on documents split accross multiple .tex\nfiles (plus possibly figures and other non-diffable files), hence could\nnot be implemented as a per-file diff driver.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\nChanges since v1:\n\n- Configuration/autodetection of PDF viewer\n- Reformat output of -h to match what PARSE_OPTION does for other commands\n\n contrib/latex/Makefile      |   22 ++++\n contrib/latex/README        |   12 ++\n contrib/latex/git-latexdiff |  249 +++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 283 insertions(+), 0 deletions(-)\n create mode 100644 contrib/latex/Makefile\n create mode 100644 contrib/latex/README\n create mode 100755 contrib/latex/git-latexdiff\n\ndiff --git a/contrib/latex/Makefile b/contrib/latex/Makefile\nnew file mode 100644\nindex 0000000..4617906\n--- /dev/null\n+++ b/contrib/latex/Makefile\n@@ -0,0 +1,22 @@\n+-include ../../config.mak\n+-include ../../config.mak.autogen\n+\n+ifndef SHELL_PATH\n+\tSHELL_PATH = /bin/sh\n+endif\n+\n+SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n+gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+\n+SCRIPT=git-latexdiff\n+\n+.PHONY: install help\n+help:\n+\t@echo 'This is the help target of the Makefile. Current configuration:'\n+\t@echo '  gitexecdir = $(gitexecdir_SQ)'\n+\t@echo '  SHELL_PATH = $(SHELL_PATH_SQ)'\n+\t@echo 'Run \"$(MAKE) install\" to install $(SCRIPT) in gitexecdir.'\n+\n+install:\n+\tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' $(SCRIPT) > '$(gitexecdir_SQ)/$(SCRIPT)'\n+\tchmod 755 '$(gitexecdir)/$(SCRIPT)'\ndiff --git a/contrib/latex/README b/contrib/latex/README\nnew file mode 100644\nindex 0000000..2d7fdd6\n--- /dev/null\n+++ b/contrib/latex/README\n@@ -0,0 +1,12 @@\n+git-latexdiff is a wrapper around latexdiff\n+(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two\n+revisions of a LaTeX file.\n+\n+The script internally checks out the full tree for the specified\n+revisions, and calls latexdiff with the --flatten option, hence this\n+works if the document is split into multiple .tex files.\n+\n+Try \"git latexdiff -h\" for more information.\n+\n+To install, either drop git-latexdiff in your $PATH, or run \"make\n+install\".\ndiff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff\nnew file mode 100755\nindex 0000000..57c2237\n--- /dev/null\n+++ b/contrib/latex/git-latexdiff\n@@ -0,0 +1,249 @@\n+#! /bin/sh\n+\n+# Author: Matthieu Moy <Matthieu.Moy@imag.fr> (2012)\n+\n+# Missing features (patches welcome ;-) :\n+# - diff the index or the current worktree \n+# - checkout only a subdirectory of the repo\n+# - hardlink temporary checkouts as much as possible\n+\n+usage () {\n+            cat << EOF\n+Usage: $(basename $0) [options] OLD [NEW]\n+Call latexdiff on two Git revisions of a file.\n+\n+OLD and NEW are Git revision identifiers. NEW defaults to HEAD.\n+\n+Options:\n+    --help                this help message\n+    --main <file.tex>     name of the main LaTeX file\n+    --no-view             don't display the resulting PDF file\n+    --view                view the resulting PDF file\n+                            (default if -o is not used)\n+    --pdf-viewer <cmd>    use <cmd> to view the PDF file (default: \\$PDFVIEWER)\n+    --no-cleanup          don't cleanup temp dir after running\n+    -o <file>, --output <file>\n+                          copy resulting PDF into <file>\n+                             (usually ending with .pdf)\n+EOF\n+}\n+\n+die () {\n+    echo \"fatal: $@\"\n+    exit 1\n+}\n+\n+verbose () {\n+    if [ \"$verbose\" = 1 ]; then\n+\tprintf \"%s ...\" \"$@\"\n+    fi\n+}\n+\n+verbose_progress () {\n+    if [ \"$verbose\" = 1 ]; then\n+\tprintf \".\" \"$@\"\n+    fi\n+}\n+\n+verbose_done () {\n+    if [ \"$verbose\" = 1 ]; then\n+\techo \" ${1:-done}.\"\n+    fi\n+}\n+\n+old=\n+new=\n+main=\n+view=maybe\n+cleanup=1\n+verbose=0\n+output=\n+initial_dir=$PWD\n+\n+while test $# -ne 0; do\n+    case \"$1\" in\n+        \"--help\"|\"-h\")\n+            usage\n+            exit 0\n+            ;;\n+\t\"--main\")\n+\t    shift\n+\t    main=$1\n+\t    ;;\n+\t\"--no-view\")\n+\t    view=0\n+\t    ;;\n+\t\"--view\")\n+\t    view=1\n+\t    ;;\n+\t\"--pdf-viewer\")\n+\t    shift\n+\t    PDFVIEWER=\"$1\"\n+\t    ;;\n+\t\"--no-cleanup\")\n+\t    cleanup=0\n+\t    ;;\n+\t\"-o\"|\"--output\")\n+\t    shift\n+\t    output=$1\n+\t    ;;\n+\t\"--verbose\"|\"-v\")\n+\t    verbose=1\n+\t    ;;\n+        *)\n+\t    if [ \"$1\" = \"\" ]; then\n+\t\techo \"Empty string not allowed as argument\"\n+\t\tusage\n+\t\texit 1\n+\t    elif [ \"$old\" = \"\" ]; then\n+\t\told=$1\n+\t    elif [ \"$new\" = \"\" ]; then\n+\t\tnew=$1\n+\t    else\n+\t\techo \"Bad argument $1\"\n+\t\tusage\n+\t\texit 1\n+\t    fi\n+            ;;\n+    esac\n+    shift\n+done\n+\n+if [ \"$new\" = \"\" ]; then\n+    new=HEAD\n+fi\n+\n+if [ \"$old\" = \"\" ]; then\n+    echo \"fatal: Please, provide at least one revision to diff with.\"\n+    usage\n+    exit 1\n+fi\n+\n+verbose \"Auto-detecting PDF viewer\"\n+for command in xdg-open evince okular xpdf acroread; do\n+    if [ \"$PDFVIEWER\" = \"\" ]; then\n+\tif command -v \"$command\" >/dev/null 2>&1; then\n+\t    PDFVIEWER=\"$command\"\n+\telse\n+\t    verbose_progress\n+\tfi\n+    fi\n+done\n+verbose_done \"$PDFVIEWER\"\n+\n+case \"$view\" in\n+    maybe|1)\n+\tif [ \"$PDFVIEWER\" = \"\" ]; then\n+\t    echo \"warning: could not find a PDF viewer on your system.\"\n+\t    echo \"warning: Please set \\$PDFVIEWER or use --pdf-viewer CMD.\"\n+\t    PDFVIEWER=false\n+\tfi\n+\t;;\n+esac\n+\n+if [ \"$main\" = \"\" ]; then\n+    printf \"%s\" \"No --main provided, trying to guess ... \"\n+    main=$(git grep -l '^[ \\t]*\\\\documentclass')\n+    # May return multiple results, but if so the result won't be a file.\n+    if [ -r \"$main\" ]; then\n+\techo \"Using $main as the main file.\"\n+    else\n+\tif [ \"$main\" = \"\" ]; then\n+\t    echo \"No candidate for main file.\"\n+\telse\n+\t    echo \"Multiple candidates for main file:\"\n+\t    printf \"%s\\n\" \"$main\" | sed 's/^/\\t/'\n+\tfi\n+\tdie \"Please, provide a main file with --main FILE.tex.\"\n+    fi\n+fi\n+\n+if [ ! -r \"$main\" ]; then\n+    die \"Cannot read $main.\"\n+fi\n+\n+verbose \"Creating temporary directories\"\n+\n+git_prefix=$(git rev-parse --show-prefix)\n+cd \"$(git rev-parse --show-cdup)\" || die \"Can't cd back to repository root\"\n+git_dir=\"$(git rev-parse --git-dir)\" || die \"Not a git repository?\"\n+git_dir=$(cd \"$git_dir\"; pwd)\n+\n+main=$git_prefix/$main\n+\n+tmpdir=$initial_dir/git-latexdiff.$$\n+mkdir \"$tmpdir\" || die \"Cannot create temporary directory.\"\n+\n+cd \"$tmpdir\" || die \"Cannot cd to $tmpdir\"\n+\n+mkdir old new diff || die \"Cannot create old, new and diff directories.\"\n+\n+verbose_done\n+verbose \"Checking out old and new version\"\n+\n+cd old || die \"Cannot cd to old/\"\n+git --git-dir=\"$git_dir\" --work-tree=. checkout \"$old\" -- . || die \"checkout failed for old/\"\n+verbose_progress\n+cd ../new || die \"Cannot cd to new/\"\n+git --git-dir=\"$git_dir\" --work-tree=. checkout \"$new\" -- . || die \"checkout failed for new/\"\n+verbose_progress\n+cd ..\n+\n+verbose_done\n+verbose \"Running latexdiff --flatten old/$main new/$main > $main\"\n+\n+latexdiff --flatten old/\"$main\" new/\"$main\" > diff.tex || die \"latexdiff failed\"\n+\n+mv -f diff.tex new/\"$main\"\n+\n+verbose_done\n+\n+mainbase=$(basename \"$main\" .tex)\n+maindir=$(dirname \"$main\")\n+\n+verbose \"Compiling result\"\n+\n+compile_error=0\n+cd new/\"$maindir\" || die \"Can't cd to new/$maindir\"\n+if [ -f Makefile ]; then\n+    make || compile_error=1\n+else\n+    pdflatex --interaction errorstopmode \"$mainbase\" || compile_error=1\n+fi\n+\n+verbose_done\n+\n+pdffile=\"$mainbase\".pdf\n+if [ ! -r \"$pdffile\" ]; then\n+    echo \"No PDF file generated.\"\n+    compile_error=1\n+fi\n+\n+if [ ! -s \"$pdffile\" ]; then\n+    echo \"PDF file generated is empty.\"\n+    compile_error=1\n+fi\n+\n+if [ \"$compile_error\" = \"1\" ]; then\n+    echo \"Error during compilation. Please examine and cleanup if needed:\"\n+    echo \"Directory: $tmpdir/new/$maindir/\"\n+    echo \"     File: $mainbase.tex\"\n+    # Don't clean up to let the user diagnose.\n+    exit 1\n+fi\n+\n+if [ \"$output\" != \"\" ]; then\n+    abs_pdffile=\"$PWD/$pdffile\"\n+    (cd \"$initial_dir\" && cp \"$abs_pdffile\" \"$output\")\n+    echo \"Output written on $output\"\n+fi\n+\n+if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n+    \"$PDFVIEWER\" \"$pdffile\"\n+fi\n+\n+if [ \"$cleanup\" = 1 ]; then\n+    verbose \"Cleaning-up result\"\n+    rm -fr \"$tmpdir\"\n+    verbose_done\n+fi\n-- \n1.7.9.111.gf3fb0.dirty\n"},{"id":"184817","messageId":"94614DF7-9EE3-47CB-BC6E-97069597557E@gmail.com","threadId":"29635","inReplyTo":"vpq39abrxav.fsf@bauges.imag.fr","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Steven Michalske","fromEmail":"smichalske@gmail.com","sentAt":"2012-02-16T08:47:06Z","receivedAt":"2012-02-16T08:47:06Z","isPatch":true,"sender":{"key":"smichalske@gmail.com","avatar":"https://gravatar.com/avatar/721f27456adc9ac84f3bb235f021a70015abb9e09222ae8622fc5579c6a203c1?d=mp&s=160"},"body":"On Mac OS X use the open command and the OS will use the correct viewer chosen by the user\n\nopen \"$pdffile\"\n\n\nOn Feb 16, 2012, at 12:34 AM, Matthieu Moy wrote:\n\n> Tim Haga <timhaga@ebene6.org> writes:\n> \n>> While testing your script on my office machine i discovered that the\n>> following might be a problem:\n>> \n>>> +if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n>>> +    xpdf \"$pdffile\"\n>>> +fi\n>> \n>> Xpdf is not installed on all machines (e.g. it's not installed on my\n>> office machine), so maybe it would be a good idea to use a environment\n>> variable instead?\n> \n> Right. I'm squashing this into the next version to allow configuration\n> (environment variable or --pdf-viewer) and sensible auto-detection:\n> \n> diff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff\n> index 13aeb9a..85aafda 100755\n> --- a/contrib/latex/git-latexdiff\n> +++ b/contrib/latex/git-latexdiff\n> @@ -20,6 +20,8 @@ Options:\n> \t--no-view\tDon't display the resulting PDF file\n> \t--view\t\tView the resulting PDF file\n> \t\t\t(default if -o is not used)\n> +\t--pdf-viewer CMD\n> +\t\t\tUse CMD to view the PDF file (default: \\$PDFVIEWER)\n> \t--no-cleanup\tDon't cleanup temp dir after running\n> \t-o FILE, --output FILE\n> \t\t\tCopy resulting PDF into FILE\n> @@ -46,7 +48,7 @@ verbose_progress () {\n> \n> verbose_done () {\n>     if [ \"$verbose\" = 1 ]; then\n> -\techo \" done.\"\n> +\techo \" ${1:-done}.\"\n>     fi\n> }\n> \n> @@ -75,6 +77,10 @@ while test $# -ne 0; do\n> \t\"--view\")\n> \t    view=1\n> \t    ;;\n> +\t\"--pdf-viewer\")\n> +\t    shift\n> +\t    PDFVIEWER=\"$1\"\n> +\t    ;;\n> \t\"--no-cleanup\")\n> \t    cleanup=0\n> \t    ;;\n> @@ -114,6 +120,28 @@ if [ \"$old\" = \"\" ]; then\n>     exit 1\n> fi\n> \n> +verbose \"Auto-detecting PDF viewer\"\n> +for command in xdg-open evince okular xpdf acroread; do\n> +    if [ \"$PDFVIEWER\" = \"\" ]; then\n> +\tif command -v \"$command\" >/dev/null 2>&1; then\n> +\t    PDFVIEWER=\"$command\"\n> +\telse\n> +\t    verbose_progress\n> +\tfi\n> +    fi\n> +done\n> +verbose_done \"$PDFVIEWER\"\n> +\n> +case \"$view\" in\n> +    maybe|1)\n> +\tif [ \"$PDFVIEWER\" = \"\" ]; then\n> +\t    echo \"warning: could not find a PDF viewer on your system.\"\n> +\t    echo \"warning: Please set \\$PDFVIEWER or use --pdf-viewer CMD.\"\n> +\t    PDFVIEWER=false\n> +\tfi\n> +\t;;\n> +esac\n> +\n> if [ \"$main\" = \"\" ]; then\n>     printf \"%s\" \"No --main provided, trying to guess ... \"\n>     main=$(git grep -l '^[ \\t]*\\\\documentclass')\n> @@ -212,7 +240,7 @@ if [ \"$output\" != \"\" ]; then\n> fi\n> \n> if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n> -    xpdf \"$pdffile\"\n> +    \"$PDFVIEWER\" \"$pdffile\"\n> fi\n> \n> if [ \"$cleanup\" = 1 ]; then\n> \n> -- \n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"184818","messageId":"vpqy5s3i26m.fsf@bauges.imag.fr","threadId":"29635","inReplyTo":"94614DF7-9EE3-47CB-BC6E-97069597557E@gmail.com","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-16T08:59:29Z","receivedAt":"2012-02-16T08:59:29Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Steven Michalske <smichalske@gmail.com> writes:\n\n> On Mac OS X use the open command and the OS will use the correct viewer chosen by the user\n>\n> open \"$pdffile\"\n\nUnfortunately, open also exists on my system, but does not do that at\nall. I'm squashing this into the next version:\n\n--- a/contrib/latex/git-latexdiff\n+++ b/contrib/latex/git-latexdiff\n@@ -120,7 +120,13 @@ if [ \"$old\" = \"\" ]; then\n fi\n \n verbose \"Auto-detecting PDF viewer\"\n-for command in xdg-open evince okular xpdf acroread; do\n+candidates=\"xdg-open evince okular xpdf acroread\"\n+if [ \"$(uname)\" = Darwin ]; then\n+    # open exists on GNU/Linux, but does not open PDFs\n+    candidates=\"open $candidates\"\n+fi\n+\n+for command in $candidates; do\n     if [ \"$PDFVIEWER\" = \"\" ]; then\n        if command -v \"$command\" >/dev/null 2>&1; then\n            PDFVIEWER=\"$command\"\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"184819","messageId":"m3hayrrvf9.fsf@localhost.localdomain","threadId":"29635","inReplyTo":"1329381560-15853-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH v2] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-02-16T09:15:27Z","receivedAt":"2012-02-16T09:15:27Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> +verbose \"Auto-detecting PDF viewer\"\n> +for command in xdg-open evince okular xpdf acroread; do\n> +    if [ \"$PDFVIEWER\" = \"\" ]; then\n> +\tif command -v \"$command\" >/dev/null 2>&1; then\n> +\t    PDFVIEWER=\"$command\"\n> +\telse\n> +\t    verbose_progress\n> +\tfi\n> +    fi\n> +done\n> +verbose_done \"$PDFVIEWER\"\n\nWhy we autodetect PDF viewer unconditionally?  Why we do not stop on\nfirst detected viewer rather than last?  Why not\n\n  +if [ \"$PDFVIEWER\" = \"\" ]; then\n  +\tverbose \"Auto-detecting PDF viewer\"\n  +\tfor command in xdg-open evince okular xpdf acroread; do\n  +\t\tif command -v \"$command\" >/dev/null 2>&1; then\n  +\t\t\tPDFVIEWER=$command\n  +\t\t\tbreak\n  +\t\telse\n  +\t\t\tverbose_progress\n  +\t\tfi\n  +\tdone\n  +\tverbose_done \"$PDFVIEWER\"\n  +fi\n\nNb. Documentation/CodingGuidelines says:\n\n  For shell scripts specifically (not exhaustive):\n  \n  [...]\n  \n   - We prefer \"test\" over \"[ ... ]\".\n\nI know that 'contrib/' is more relaxed...\n-- \nJakub Narebski\n"},{"id":"184822","messageId":"1329395775-18294-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"29635","inReplyTo":"vpq39abrxav.fsf@bauges.imag.fr","subject":"[PATCH v3] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-02-16T12:36:15Z","receivedAt":"2012-02-16T12:36:15Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"git-latexdiff is a wrapper around latexdiff\n(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two\nrevisions of a LaTeX file.\n\ngit-latexdiff is made to work on documents split accross multiple .tex\nfiles (plus possibly figures and other non-diffable files), hence could\nnot be implemented as a per-file diff driver.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\nChanges since v2:\n\n- Try 'open' on MacOS to view PDF file.\n- Shell style issues (thanks to Jakub)\n\n contrib/latex/Makefile      |   22 ++++\n contrib/latex/README        |   12 ++\n contrib/latex/git-latexdiff |  255 +++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 289 insertions(+), 0 deletions(-)\n create mode 100644 contrib/latex/Makefile\n create mode 100644 contrib/latex/README\n create mode 100755 contrib/latex/git-latexdiff\n\ndiff --git a/contrib/latex/Makefile b/contrib/latex/Makefile\nnew file mode 100644\nindex 0000000..4617906\n--- /dev/null\n+++ b/contrib/latex/Makefile\n@@ -0,0 +1,22 @@\n+-include ../../config.mak\n+-include ../../config.mak.autogen\n+\n+ifndef SHELL_PATH\n+\tSHELL_PATH = /bin/sh\n+endif\n+\n+SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n+gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+\n+SCRIPT=git-latexdiff\n+\n+.PHONY: install help\n+help:\n+\t@echo 'This is the help target of the Makefile. Current configuration:'\n+\t@echo '  gitexecdir = $(gitexecdir_SQ)'\n+\t@echo '  SHELL_PATH = $(SHELL_PATH_SQ)'\n+\t@echo 'Run \"$(MAKE) install\" to install $(SCRIPT) in gitexecdir.'\n+\n+install:\n+\tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' $(SCRIPT) > '$(gitexecdir_SQ)/$(SCRIPT)'\n+\tchmod 755 '$(gitexecdir)/$(SCRIPT)'\ndiff --git a/contrib/latex/README b/contrib/latex/README\nnew file mode 100644\nindex 0000000..2d7fdd6\n--- /dev/null\n+++ b/contrib/latex/README\n@@ -0,0 +1,12 @@\n+git-latexdiff is a wrapper around latexdiff\n+(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two\n+revisions of a LaTeX file.\n+\n+The script internally checks out the full tree for the specified\n+revisions, and calls latexdiff with the --flatten option, hence this\n+works if the document is split into multiple .tex files.\n+\n+Try \"git latexdiff -h\" for more information.\n+\n+To install, either drop git-latexdiff in your $PATH, or run \"make\n+install\".\ndiff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff\nnew file mode 100755\nindex 0000000..8466f52\n--- /dev/null\n+++ b/contrib/latex/git-latexdiff\n@@ -0,0 +1,255 @@\n+#! /bin/sh\n+\n+# Author: Matthieu Moy <Matthieu.Moy@imag.fr> (2012)\n+\n+# Missing features (patches welcome ;-) :\n+# - diff the index or the current worktree \n+# - checkout only a subdirectory of the repo\n+# - hardlink temporary checkouts as much as possible\n+\n+usage () {\n+            cat << EOF\n+Usage: $(basename $0) [options] OLD [NEW]\n+Call latexdiff on two Git revisions of a file.\n+\n+OLD and NEW are Git revision identifiers. NEW defaults to HEAD.\n+\n+Options:\n+    --help                this help message\n+    --main <file.tex>     name of the main LaTeX file\n+    --no-view             don't display the resulting PDF file\n+    --view                view the resulting PDF file\n+                            (default if -o is not used)\n+    --pdf-viewer <cmd>    use <cmd> to view the PDF file (default: \\$PDFVIEWER)\n+    --no-cleanup          don't cleanup temp dir after running\n+    -o <file>, --output <file>\n+                          copy resulting PDF into <file>\n+                             (usually ending with .pdf)\n+EOF\n+}\n+\n+die () {\n+    echo \"fatal: $@\"\n+    exit 1\n+}\n+\n+verbose () {\n+    if [ \"$verbose\" = 1 ]; then\n+\tprintf \"%s ...\" \"$@\"\n+    fi\n+}\n+\n+verbose_progress () {\n+    if [ \"$verbose\" = 1 ]; then\n+\tprintf \".\" \"$@\"\n+    fi\n+}\n+\n+verbose_done () {\n+    if [ \"$verbose\" = 1 ]; then\n+\techo \" ${1:-done}.\"\n+    fi\n+}\n+\n+old=\n+new=\n+main=\n+view=maybe\n+cleanup=1\n+verbose=0\n+output=\n+initial_dir=$PWD\n+\n+while test $# -ne 0; do\n+    case \"$1\" in\n+        \"--help\"|\"-h\")\n+            usage\n+            exit 0\n+            ;;\n+\t\"--main\")\n+\t    shift\n+\t    main=$1\n+\t    ;;\n+\t\"--no-view\")\n+\t    view=0\n+\t    ;;\n+\t\"--view\")\n+\t    view=1\n+\t    ;;\n+\t\"--pdf-viewer\")\n+\t    shift\n+\t    PDFVIEWER=\"$1\"\n+\t    ;;\n+\t\"--no-cleanup\")\n+\t    cleanup=0\n+\t    ;;\n+\t\"-o\"|\"--output\")\n+\t    shift\n+\t    output=$1\n+\t    ;;\n+\t\"--verbose\"|\"-v\")\n+\t    verbose=1\n+\t    ;;\n+        *)\n+\t    if [ \"$1\" = \"\" ]; then\n+\t\techo \"Empty string not allowed as argument\"\n+\t\tusage\n+\t\texit 1\n+\t    elif [ \"$old\" = \"\" ]; then\n+\t\told=$1\n+\t    elif [ \"$new\" = \"\" ]; then\n+\t\tnew=$1\n+\t    else\n+\t\techo \"Bad argument $1\"\n+\t\tusage\n+\t\texit 1\n+\t    fi\n+            ;;\n+    esac\n+    shift\n+done\n+\n+if [ \"$new\" = \"\" ]; then\n+    new=HEAD\n+fi\n+\n+if [ \"$old\" = \"\" ]; then\n+    echo \"fatal: Please, provide at least one revision to diff with.\"\n+    usage\n+    exit 1\n+fi\n+\n+verbose \"Auto-detecting PDF viewer\"\n+candidates=\"xdg-open evince okular xpdf acroread\"\n+if [ \"$(uname)\" = Darwin ]; then\n+    # open exists on GNU/Linux, but does not open PDFs\n+    candidates=\"open $candidates\"\n+fi\n+\n+for command in $candidates; do\n+    if [ \"$PDFVIEWER\" = \"\" ]; then\n+\tif command -v \"$command\" >/dev/null 2>&1; then\n+\t    PDFVIEWER=\"$command\"\n+\telse\n+\t    verbose_progress\n+\tfi\n+    fi\n+done\n+verbose_done \"$PDFVIEWER\"\n+\n+case \"$view\" in\n+    maybe|1)\n+\tif [ \"$PDFVIEWER\" = \"\" ]; then\n+\t    echo \"warning: could not find a PDF viewer on your system.\"\n+\t    echo \"warning: Please set \\$PDFVIEWER or use --pdf-viewer CMD.\"\n+\t    PDFVIEWER=false\n+\tfi\n+\t;;\n+esac\n+\n+if [ \"$main\" = \"\" ]; then\n+    printf \"%s\" \"No --main provided, trying to guess ... \"\n+    main=$(git grep -l '^[ \\t]*\\\\documentclass')\n+    # May return multiple results, but if so the result won't be a file.\n+    if [ -r \"$main\" ]; then\n+\techo \"Using $main as the main file.\"\n+    else\n+\tif [ \"$main\" = \"\" ]; then\n+\t    echo \"No candidate for main file.\"\n+\telse\n+\t    echo \"Multiple candidates for main file:\"\n+\t    printf \"%s\\n\" \"$main\" | sed 's/^/\\t/'\n+\tfi\n+\tdie \"Please, provide a main file with --main FILE.tex.\"\n+    fi\n+fi\n+\n+if [ ! -r \"$main\" ]; then\n+    die \"Cannot read $main.\"\n+fi\n+\n+verbose \"Creating temporary directories\"\n+\n+git_prefix=$(git rev-parse --show-prefix)\n+cd \"$(git rev-parse --show-cdup)\" || die \"Can't cd back to repository root\"\n+git_dir=\"$(git rev-parse --git-dir)\" || die \"Not a git repository?\"\n+git_dir=$(cd \"$git_dir\"; pwd)\n+\n+main=$git_prefix/$main\n+\n+tmpdir=$initial_dir/git-latexdiff.$$\n+mkdir \"$tmpdir\" || die \"Cannot create temporary directory.\"\n+\n+cd \"$tmpdir\" || die \"Cannot cd to $tmpdir\"\n+\n+mkdir old new diff || die \"Cannot create old, new and diff directories.\"\n+\n+verbose_done\n+verbose \"Checking out old and new version\"\n+\n+cd old || die \"Cannot cd to old/\"\n+git --git-dir=\"$git_dir\" --work-tree=. checkout \"$old\" -- . || die \"checkout failed for old/\"\n+verbose_progress\n+cd ../new || die \"Cannot cd to new/\"\n+git --git-dir=\"$git_dir\" --work-tree=. checkout \"$new\" -- . || die \"checkout failed for new/\"\n+verbose_progress\n+cd ..\n+\n+verbose_done\n+verbose \"Running latexdiff --flatten old/$main new/$main > $main\"\n+\n+latexdiff --flatten old/\"$main\" new/\"$main\" > diff.tex || die \"latexdiff failed\"\n+\n+mv -f diff.tex new/\"$main\"\n+\n+verbose_done\n+\n+mainbase=$(basename \"$main\" .tex)\n+maindir=$(dirname \"$main\")\n+\n+verbose \"Compiling result\"\n+\n+compile_error=0\n+cd new/\"$maindir\" || die \"Can't cd to new/$maindir\"\n+if [ -f Makefile ]; then\n+    make || compile_error=1\n+else\n+    pdflatex --interaction errorstopmode \"$mainbase\" || compile_error=1\n+fi\n+\n+verbose_done\n+\n+pdffile=\"$mainbase\".pdf\n+if [ ! -r \"$pdffile\" ]; then\n+    echo \"No PDF file generated.\"\n+    compile_error=1\n+fi\n+\n+if [ ! -s \"$pdffile\" ]; then\n+    echo \"PDF file generated is empty.\"\n+    compile_error=1\n+fi\n+\n+if [ \"$compile_error\" = \"1\" ]; then\n+    echo \"Error during compilation. Please examine and cleanup if needed:\"\n+    echo \"Directory: $tmpdir/new/$maindir/\"\n+    echo \"     File: $mainbase.tex\"\n+    # Don't clean up to let the user diagnose.\n+    exit 1\n+fi\n+\n+if [ \"$output\" != \"\" ]; then\n+    abs_pdffile=\"$PWD/$pdffile\"\n+    (cd \"$initial_dir\" && cp \"$abs_pdffile\" \"$output\")\n+    echo \"Output written on $output\"\n+fi\n+\n+if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n+    \"$PDFVIEWER\" \"$pdffile\"\n+fi\n+\n+if [ \"$cleanup\" = 1 ]; then\n+    verbose \"Cleaning-up result\"\n+    rm -fr \"$tmpdir\"\n+    verbose_done\n+fi\n-- \n1.7.9.111.gf3fb0.dirty\n"},{"id":"184825","messageId":"m3d39esxrg.fsf@localhost.localdomain","threadId":"29635","inReplyTo":"1329395775-18294-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH v3] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-02-16T13:40:26Z","receivedAt":"2012-02-16T13:40:26Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> Changes since v2:\n> \n[...]\n> - Shell style issues (thanks to Jakub)\n[...]\n\n> +verbose \"Auto-detecting PDF viewer\"\n> +candidates=\"xdg-open evince okular xpdf acroread\"\n> +if [ \"$(uname)\" = Darwin ]; then\n> +    # open exists on GNU/Linux, but does not open PDFs\n> +    candidates=\"open $candidates\"\n> +fi\n> +\n> +for command in $candidates; do\n> +    if [ \"$PDFVIEWER\" = \"\" ]; then\n> +\tif command -v \"$command\" >/dev/null 2>&1; then\n> +\t    PDFVIEWER=\"$command\"\n> +\telse\n> +\t    verbose_progress\n> +\tfi\n> +    fi\n> +done\n> +verbose_done \"$PDFVIEWER\"\n\nEh?  I don't see shell style issues fixed (loop inside conditional\ninstead of vice-versa, \"test ...\" instead of \"[ ... ]\").\n\nNb. I think it would be good to put detecting PDF viewer in its own\nfunction, don't you?\n\n-- \nJakub Narebski\n"},{"id":"184827","messageId":"1329401300-28166-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"29635","inReplyTo":"m3d39esxrg.fsf@localhost.localdomain","subject":"[PATCH v4] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-02-16T14:08:20Z","receivedAt":"2012-02-16T14:08:20Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"git-latexdiff is a wrapper around latexdiff\n(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two\nrevisions of a LaTeX file.\n\ngit-latexdiff is made to work on documents split accross multiple .tex\nfiles (plus possibly figures and other non-diffable files), hence could\nnot be implemented as a per-file diff driver.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\nSorry, I forgot to commit before sending v3, so it was obviously wrong.\n\nThis one should contain what I promised in v2, i.e:\n\n- Try 'open' on MacOS to view PDF file.\n- Shell style issues (thanks to Jakub)\n\nJakub, I also forgot to send this before the patch (I got interrupted,\nand it seems my mental context-switch implementation loses data ;-) ):\n\n> Why we autodetect PDF viewer unconditionally?\n\nWe don't really do that: the test is inside a test on $PDFVIEWER, so\nit's essentially the same. I just wrote it this way because I thought\n\"break\" wasn't POSIX, but it is actually, so I'm taking your version.\n\n contrib/latex/Makefile      |   22 ++++\n contrib/latex/README        |   12 ++\n contrib/latex/git-latexdiff |  256 +++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 290 insertions(+), 0 deletions(-)\n create mode 100644 contrib/latex/Makefile\n create mode 100644 contrib/latex/README\n create mode 100755 contrib/latex/git-latexdiff\n\ndiff --git a/contrib/latex/Makefile b/contrib/latex/Makefile\nnew file mode 100644\nindex 0000000..4617906\n--- /dev/null\n+++ b/contrib/latex/Makefile\n@@ -0,0 +1,22 @@\n+-include ../../config.mak\n+-include ../../config.mak.autogen\n+\n+ifndef SHELL_PATH\n+\tSHELL_PATH = /bin/sh\n+endif\n+\n+SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n+gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+\n+SCRIPT=git-latexdiff\n+\n+.PHONY: install help\n+help:\n+\t@echo 'This is the help target of the Makefile. Current configuration:'\n+\t@echo '  gitexecdir = $(gitexecdir_SQ)'\n+\t@echo '  SHELL_PATH = $(SHELL_PATH_SQ)'\n+\t@echo 'Run \"$(MAKE) install\" to install $(SCRIPT) in gitexecdir.'\n+\n+install:\n+\tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' $(SCRIPT) > '$(gitexecdir_SQ)/$(SCRIPT)'\n+\tchmod 755 '$(gitexecdir)/$(SCRIPT)'\ndiff --git a/contrib/latex/README b/contrib/latex/README\nnew file mode 100644\nindex 0000000..2d7fdd6\n--- /dev/null\n+++ b/contrib/latex/README\n@@ -0,0 +1,12 @@\n+git-latexdiff is a wrapper around latexdiff\n+(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two\n+revisions of a LaTeX file.\n+\n+The script internally checks out the full tree for the specified\n+revisions, and calls latexdiff with the --flatten option, hence this\n+works if the document is split into multiple .tex files.\n+\n+Try \"git latexdiff -h\" for more information.\n+\n+To install, either drop git-latexdiff in your $PATH, or run \"make\n+install\".\ndiff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff\nnew file mode 100755\nindex 0000000..19b9783\n--- /dev/null\n+++ b/contrib/latex/git-latexdiff\n@@ -0,0 +1,256 @@\n+#! /bin/sh\n+\n+# Author: Matthieu Moy <Matthieu.Moy@imag.fr> (2012)\n+\n+# Missing features (patches welcome ;-) :\n+# - diff the index or the current worktree \n+# - checkout only a subdirectory of the repo\n+# - hardlink temporary checkouts as much as possible\n+\n+usage () {\n+            cat << EOF\n+Usage: $(basename $0) [options] OLD [NEW]\n+Call latexdiff on two Git revisions of a file.\n+\n+OLD and NEW are Git revision identifiers. NEW defaults to HEAD.\n+\n+Options:\n+    --help                this help message\n+    --main <file.tex>     name of the main LaTeX file\n+    --no-view             don't display the resulting PDF file\n+    --view                view the resulting PDF file\n+                            (default if -o is not used)\n+    --pdf-viewer <cmd>    use <cmd> to view the PDF file (default: \\$PDFVIEWER)\n+    --no-cleanup          don't cleanup temp dir after running\n+    -o <file>, --output <file>\n+                          copy resulting PDF into <file>\n+                             (usually ending with .pdf)\n+EOF\n+}\n+\n+die () {\n+    echo \"fatal: $@\"\n+    exit 1\n+}\n+\n+verbose () {\n+    if test \"$verbose\" = 1 ; then\n+\tprintf \"%s ...\" \"$@\"\n+    fi\n+}\n+\n+verbose_progress () {\n+    if test \"$verbose\" = 1 ; then\n+\tprintf \".\" \"$@\"\n+    fi\n+}\n+\n+verbose_done () {\n+    if test \"$verbose\" = 1 ; then\n+\techo \" ${1:-done}.\"\n+    fi\n+}\n+\n+old=\n+new=\n+main=\n+view=maybe\n+cleanup=1\n+verbose=0\n+output=\n+initial_dir=$PWD\n+\n+while test $# -ne 0; do\n+    case \"$1\" in\n+        \"--help\"|\"-h\")\n+            usage\n+            exit 0\n+            ;;\n+\t\"--main\")\n+\t    test $# -gt 1 && shift || die \"missing argument for $1\"\n+\t    main=$1\n+\t    ;;\n+\t\"--no-view\")\n+\t    view=0\n+\t    ;;\n+\t\"--view\")\n+\t    view=1\n+\t    ;;\n+\t\"--pdf-viewer\")\n+\t    test $# -gt 1 && shift || die \"missing argument for $1\"\n+\t    PDFVIEWER=\"$1\"\n+\t    ;;\n+\t\"--no-cleanup\")\n+\t    cleanup=0\n+\t    ;;\n+\t\"-o\"|\"--output\")\n+\t    test $# -gt 1 && shift || die \"missing argument for $1\"\n+\t    output=$1\n+\t    ;;\n+\t\"--verbose\"|\"-v\")\n+\t    verbose=1\n+\t    ;;\n+        *)\n+\t    if test -z \"$1\" ; then\n+\t\techo \"Empty string not allowed as argument\"\n+\t\tusage\n+\t\texit 1\n+\t    elif test -z \"$old\" ; then\n+\t\told=$1\n+\t    elif test -z \"$new\" ; then\n+\t\tnew=$1\n+\t    else\n+\t\techo \"Bad argument $1\"\n+\t\tusage\n+\t\texit 1\n+\t    fi\n+            ;;\n+    esac\n+    shift\n+done\n+\n+if test -z \"$new\" ; then\n+    new=HEAD\n+fi\n+\n+if test -z \"$old\" ; then\n+    echo \"fatal: Please, provide at least one revision to diff with.\"\n+    usage\n+    exit 1\n+fi\n+\n+if test -z \"$PDFVIEWER\" ; then\n+    verbose \"Auto-detecting PDF viewer\"\n+    candidates=\"xdg-open evince okular xpdf acroread\"\n+    if test \"$(uname)\" = Darwin ; then\n+        # open exists on GNU/Linux, but does not open PDFs\n+\tcandidates=\"open $candidates\"\n+    fi\n+    \n+    for command in $candidates; do\n+\tif command -v \"$command\" >/dev/null 2>&1; then\n+\t    PDFVIEWER=\"$command\"\n+\t    break\n+\telse\n+\t    verbose_progress\n+\tfi\n+    done\n+    verbose_done \"$PDFVIEWER\"\n+fi\n+\n+case \"$view\" in\n+    maybe|1)\n+\tif test -z \"$PDFVIEWER\" ; then\n+\t    echo \"warning: could not find a PDF viewer on your system.\"\n+\t    echo \"warning: Please set \\$PDFVIEWER or use --pdf-viewer CMD.\"\n+\t    PDFVIEWER=false\n+\tfi\n+\t;;\n+esac\n+\n+if test -z \"$main\" ; then\n+    printf \"%s\" \"No --main provided, trying to guess ... \"\n+    main=$(git grep -l '^[ \\t]*\\\\documentclass')\n+    # May return multiple results, but if so the result won't be a file.\n+    if test -r \"$main\" ; then\n+\techo \"Using $main as the main file.\"\n+    else\n+\tif test -z \"$main\" ; then\n+\t    echo \"No candidate for main file.\"\n+\telse\n+\t    echo \"Multiple candidates for main file:\"\n+\t    printf \"%s\\n\" \"$main\" | sed 's/^/\\t/'\n+\tfi\n+\tdie \"Please, provide a main file with --main FILE.tex.\"\n+    fi\n+fi\n+\n+if test ! -r \"$main\" ; then\n+    die \"Cannot read $main.\"\n+fi\n+\n+verbose \"Creating temporary directories\"\n+\n+git_prefix=$(git rev-parse --show-prefix)\n+cd \"$(git rev-parse --show-cdup)\" || die \"Can't cd back to repository root\"\n+git_dir=\"$(git rev-parse --git-dir)\" || die \"Not a git repository?\"\n+git_dir=$(cd \"$git_dir\"; pwd)\n+\n+main=$git_prefix/$main\n+\n+tmpdir=$initial_dir/git-latexdiff.$$\n+mkdir \"$tmpdir\" || die \"Cannot create temporary directory.\"\n+\n+cd \"$tmpdir\" || die \"Cannot cd to $tmpdir\"\n+\n+mkdir old new diff || die \"Cannot create old, new and diff directories.\"\n+\n+verbose_done\n+verbose \"Checking out old and new version\"\n+\n+cd old || die \"Cannot cd to old/\"\n+git --git-dir=\"$git_dir\" --work-tree=. checkout \"$old\" -- . || die \"checkout failed for old/\"\n+verbose_progress\n+cd ../new || die \"Cannot cd to new/\"\n+git --git-dir=\"$git_dir\" --work-tree=. checkout \"$new\" -- . || die \"checkout failed for new/\"\n+verbose_progress\n+cd ..\n+\n+verbose_done\n+verbose \"Running latexdiff --flatten old/$main new/$main > $main\"\n+\n+latexdiff --flatten old/\"$main\" new/\"$main\" > diff.tex || die \"latexdiff failed\"\n+\n+mv -f diff.tex new/\"$main\"\n+\n+verbose_done\n+\n+mainbase=$(basename \"$main\" .tex)\n+maindir=$(dirname \"$main\")\n+\n+verbose \"Compiling result\"\n+\n+compile_error=0\n+cd new/\"$maindir\" || die \"Can't cd to new/$maindir\"\n+if test -f Makefile ; then\n+    make || compile_error=1\n+else\n+    pdflatex --interaction errorstopmode \"$mainbase\" || compile_error=1\n+fi\n+\n+verbose_done\n+\n+pdffile=\"$mainbase\".pdf\n+if test ! -r \"$pdffile\" ; then\n+    echo \"No PDF file generated.\"\n+    compile_error=1\n+fi\n+\n+if test ! -s \"$pdffile\" ; then\n+    echo \"PDF file generated is empty.\"\n+    compile_error=1\n+fi\n+\n+if test \"$compile_error\" = \"1\" ; then\n+    echo \"Error during compilation. Please examine and cleanup if needed:\"\n+    echo \"Directory: $tmpdir/new/$maindir/\"\n+    echo \"     File: $mainbase.tex\"\n+    # Don't clean up to let the user diagnose.\n+    exit 1\n+fi\n+\n+if test -n \"$output\" ; then\n+    abs_pdffile=\"$PWD/$pdffile\"\n+    (cd \"$initial_dir\" && cp \"$abs_pdffile\" \"$output\")\n+    echo \"Output written on $output\"\n+fi\n+\n+if test \"$view\" = 1  || test \"$view\" = maybe  && test -z \"$output\" ; then\n+    \"$PDFVIEWER\" \"$pdffile\"\n+fi\n+\n+if test \"$cleanup\" = 1 ; then\n+    verbose \"Cleaning-up result\"\n+    rm -fr \"$tmpdir\"\n+    verbose_done\n+fi\n-- \n1.7.9.111.gf3fb0.dirty\n"},{"id":"184828","messageId":"vpq62f627b4.fsf@bauges.imag.fr","threadId":"29635","inReplyTo":"m3d39esxrg.fsf@localhost.localdomain","subject":"Re: [PATCH v3] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-16T14:15:27Z","receivedAt":"2012-02-16T14:15:27Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Nb. I think it would be good to put detecting PDF viewer in its own\n> function, don't you?\n\nI normally like functions, but for such a linear and small piece of\ncode, I think it adds more confusion that clarity to write\n\ndo_fo () {\n   actual stuff\n}\n\ndo_foo\n\nthan the actual stuff alone.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"184831","messageId":"CAJDDKr5SrDoVyd8s7pE3WMQ_c_DiSiiwHTz0O0t2TM24fCb-Aw@mail.gmail.com","threadId":"29635","inReplyTo":"1329381560-15853-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH v2] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-02-16T19:24:51Z","receivedAt":"2012-02-16T19:24:51Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Thu, Feb 16, 2012 at 12:39 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n> +\n> +verbose () {\n> +    if [ \"$verbose\" = 1 ]; then\n> +       printf \"%s ...\" \"$@\"\n> +    fi\n> +}\n\nIn addition to preferring \"test\" over \"[\", we also prefer to write\nthese on several lines.  It's probably time to update the CodingStyle\ndocument with these notes.\n\ne.g.\n\nif test \"$verbose\" = 1\nthen\n    .... do stuff\nfi\n\n(with hard-tabs, not spaces (unlike my example))\n-- \nDavid\n"},{"id":"184833","messageId":"7v8vk2zghl.fsf@alter.siamese.dyndns.org","threadId":"29635","inReplyTo":"vpq39abrxav.fsf@bauges.imag.fr","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-16T20:10:46Z","receivedAt":"2012-02-16T20:10:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Tim Haga <timhaga@ebene6.org> writes:\n>\n>> While testing your script on my office machine i discovered that the\n>> following might be a problem:\n>>\n>>> +if [ \"$view\" = 1 ] || [ \"$view\" = maybe ] && [ \"$output\" = \"\" ]; then\n>>> +    xpdf \"$pdffile\"\n>>> +fi\n>>\n>> Xpdf is not installed on all machines (e.g. it's not installed on my\n>> office machine), so maybe it would be a good idea to use a environment\n>> variable instead?\n\nHonestly speaking, this is looking more like an \"useful application for\nlatex users who happen to use git to store their document source\", and not\na \"useful addition for all git users\", to me.\n\nThese two viewpoint suggests completely different evolution path for this\nprogram.  Imagining what the first major new enhancement intended for\npeople outside the original audience <git,latex> will be, I have this\nsuspicion that \"this new version will help people who have their documents\nstored in Mercurial\" would be much more realistic (and the end result\nbeing useful) than \"this new version will help git users who do not write\ntheir documents in latex but in asciidoc\".\n\nFor that reason, I suspect that in the longer term, the tool will benefit\nmore if I do not take this patch and the tool lives standalone.\n"},{"id":"184839","messageId":"7vfweaxzfq.fsf@alter.siamese.dyndns.org","threadId":"29635","inReplyTo":"7v8vk2zghl.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-16T21:04:25Z","receivedAt":"2012-02-16T21:04:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Honestly speaking, this is looking more like an \"useful application for\n> latex users who happen to use git to store their document source\", and not\n> a \"useful addition for all git users\", to me.\n\nSorry, un-proofread draft escaped.\n\nPlease replace \"for all git users\" with \"to git to help users who happen\nto have latex documents in their repositories.\"\n"},{"id":"184865","messageId":"vpqty2px4l5.fsf@bauges.imag.fr","threadId":"29635","inReplyTo":"7v8vk2zghl.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-17T08:10:46Z","receivedAt":"2012-02-17T08:10:46Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Honestly speaking, this is looking more like an \"useful application for\n> latex users who happen to use git to store their document source\", and not\n> a \"useful addition for all git users\", to me.\n>\n> These two viewpoint suggests completely different evolution path for this\n> program.  Imagining what the first major new enhancement intended for\n> people outside the original audience <git,latex> will be, I have this\n> suspicion that \"this new version will help people who have their documents\n> stored in Mercurial\" would be much more realistic (and the end result\n> being useful) than \"this new version will help git users who do not write\n> their documents in latex but in asciidoc\".\n\nI agree that the next step may be to allow users of <whatever SCM\noutside Git>, but I don't think the way to do that would be to make the\nscript generic. The script is a quick hack, and all the \"clever\" parts\nof it are calls to Git. If someone were to adapt this for Mercurial or\nBzr, writting a python plugin would be a much better way to go\n(Mercurial already has \"hg extdiff\" doing the hardlinked checkouts for\nexample, and both would allow better command-line option parsing than\nmy \"case $1 in ... esac\").\n\nI normally like code reuse very much, but trying to make a 250 lines\nlong script generic enough to accept multiple SCMs would be more work\nthan a rewrite.\n\nOTOH, having this script in contrib/ has several advantages over\nmaintaining it as a separate one-file project:\n\n- \"make install\" uses Git's Makefile configuration, so it's easy to\n  install.\n\n- It makes it natural to use this mailing list for discussion. The\n  script has already improved a lot since I posted it as a patch here.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"184881","messageId":"7vmx8hvb69.fsf@alter.siamese.dyndns.org","threadId":"29635","inReplyTo":"vpqty2px4l5.fsf@bauges.imag.fr","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-17T13:31:26Z","receivedAt":"2012-02-17T13:31:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> I agree that the next step may be to allow users of <whatever SCM\n> outside Git>, but I don't think the way to do that would be to make the\n> script generic. The script is a quick hack, and all the \"clever\" parts\n> of it are calls to Git.\n\nYou are not suggesting me to take and carry any future request that wants\nto add any quick hack that is heavily specific to Git and not portable to\nother SCMs to the contrib/ area only because they depend on Git, are you?\n\nThat would bloat the contrib/ area with stuff that do not belong there and\nwe need to draw a line somewhere.  The criteria I use to draw it is by\nanswering \"is this an application that merely happens to use git, or is it\na way to help people who use Git?\" question.\n\nLook at what we have in the contrib/ area.  I think what is common among\nthem is that their primary benefit is to enrich user's Git experience.\nBash completion for example is dependent on bash and it may be useless for\nCsh users, but if you are a bash user, your Git experience will be\ninfinitely better with it regardless of what kind of payload you are\ntracking in your Git repository.  And in my mind, \"regardless of what you\nare tracking\" is the key part that defines \"the enhancement is about\nuser's Git experience\".\n"},{"id":"184883","messageId":"vpqobsx7d9s.fsf@bauges.imag.fr","threadId":"29635","inReplyTo":"7vmx8hvb69.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-17T14:19:59Z","receivedAt":"2012-02-17T14:19:59Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> I agree that the next step may be to allow users of <whatever SCM\n>> outside Git>, but I don't think the way to do that would be to make the\n>> script generic. The script is a quick hack, and all the \"clever\" parts\n>> of it are calls to Git.\n>\n> You are not suggesting me to take and carry any future request that wants\n> to add any quick hack that is heavily specific to Git and not portable to\n> other SCMs to the contrib/ area only because they depend on Git, are\n> you?\n\nI'm answering the remark you made:\n\n| I have this suspicion that \"this new version will help people who have\n| their documents stored in Mercurial\" would be much more realistic (and\n| the end result being useful) than \"this new version will help git users\n| who do not write their documents in latex but in asciidoc\".\n\nI think the probability that a next version of git-latexdiff is to\nsupport another SCM is 0, and I tried to explain that.\n\nDo you think I failed to address this remark?\n\n> Look at what we have in the contrib/ area.  I think what is common among\n> them is that their primary benefit is to enrich user's Git experience.\n\n... and many of them is to enrich the user experience using Git with\nanother tool (shell, text editor, foreign VCS).\n\nWithout git-latexdiff, you can run \"git diff\" on LaTeX documents, while\nwith it, you can get a better view of the diff. To me, this is \"enrich\nuser's experience\" of users running \"git diff\".\n\nGit's _core_ already has some code to show diff hunks for various\nlanguages, and I don't think anyone would want to move these out because\nthey only benefit people tracking files in these languages.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"184892","messageId":"7vwr7ltlrj.fsf@alter.siamese.dyndns.org","threadId":"29635","inReplyTo":"vpqobsx7d9s.fsf@bauges.imag.fr","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-17T17:25:36Z","receivedAt":"2012-02-17T17:25:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n>> Look at what we have in the contrib/ area.  I think what is common among\n>> them is that their primary benefit is to enrich user's Git experience.\n>\n> ... and many of them is to enrich the user experience using Git with\n> another tool (shell, text editor, foreign VCS).\n\n... where the amount of the benefit they get does not change regardless of\nthe payload.  That is what makes them tool in Git users' toolbox, not\nshell scripters' or p4 users' toolbox.\n\n> Git's _core_ already has some code to show diff hunks for various\n> languages,...\n\nI would have to say that it is an oranges vs squirrels comparison.  I do\nnot see a justification to reject an addition of an entry to an array that\nadds a few strings of regexp to drive the mechanism that is already in\ncore, when it gets compiled in, and it is useless by itself outside Git.\nUnless the language is something obscure, that is.\n\nRead git-latexdiff that is a free-standing 200+ line script again\nyourself. The use of Git in the script is not more than how you would\nemulate what you would use \"cp -r\" in order to populate the old/ and new/\ndirectories if the two versions were stored in the file system outside\nGit. If you rip the part that deals with \"the two versions happen to be\nstored in Git\" out, the remainder deals with parsing the command line,\ninterfacing with latex and reporting the result, none of which is in any\nway Git specific.  That is much larger part of the script, which I view as\na clear sign that it is an application to serve the need for LaTeX users\nbetter, which happens to be written for the subset of LaTeX users who have\ntheir contents in Git.\n\nAren't there LaTeX tools archives that would be a much better home for\nthis tool?\n"},{"id":"184894","messageId":"m34nups3q2.fsf@localhost.localdomain","threadId":"29635","inReplyTo":"7vwr7ltlrj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-02-17T18:40:26Z","receivedAt":"2012-02-17T18:40:26Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Aren't there LaTeX tools archives that would be a much better home for\n> this tool?\n\nThere is CTAN: Comprehensive TeX Archive Network (http://ctan.org),\nwhich hosts tools such like latexmk (cousin of the general make\nutility), autolatex (generates Makefile), chktex, ite (interactive TeX\neditor),... latexdiff itself is also there.\n\n-- \nJakub Narebski\n"},{"id":"184977","messageId":"vpqy5rxsxb3.fsf@bauges.imag.fr","threadId":"29635","inReplyTo":"m34nups3q2.fsf@localhost.localdomain","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-20T08:50:40Z","receivedAt":"2012-02-20T08:50:40Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Aren't there LaTeX tools archives that would be a much better home for\n>> this tool?\n>\n> There is CTAN: Comprehensive TeX Archive Network (http://ctan.org),\n> which hosts tools such like latexmk (cousin of the general make\n> utility), autolatex (generates Makefile), chktex, ite (interactive TeX\n> editor),... latexdiff itself is also there.\n\nIt's not really the same thing: AFAIK, ctan is a good place to\ndistribute things, but not to develop them (i.e. I don't see revision\ncontrol or developpers mailing-lists there, which were the two\nmotivations for pushing git-latexdiff in git.git).\n\nAnyway, since no one spoke up to defend my position, I'll have to find\nanother place to host it.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"184979","messageId":"7v4nulnac8.fsf@alter.siamese.dyndns.org","threadId":"29635","inReplyTo":"vpqy5rxsxb3.fsf@bauges.imag.fr","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-20T09:05:43Z","receivedAt":"2012-02-20T09:05:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Jakub Narebski <jnareb@gmail.com> writes:\n>\n>> There is CTAN: Comprehensive TeX Archive Network (http://ctan.org),\n>> which hosts tools such like latexmk (cousin of the general make\n>> utility), autolatex (generates Makefile), chktex, ite (interactive TeX\n>> editor),... latexdiff itself is also there.\n>\n> It's not really the same thing: AFAIK, ctan is a good place to\n> distribute things, but not to develop them (i.e. I don't see revision\n> control or developpers mailing-lists there, which were the two\n> motivations for pushing git-latexdiff in git.git).\n\nOh, don't get me wrong.\n\nIt's just that I agree with Jakub that a better final destination for it\nis CTAN next to latexdiff, not in git.git/contrib/, and when we last did\nsomething similar for emacs vc mode support, the copy I carried ended up\nbecoming way stale than its final destination, and we had to remove our\ncopy in order to reduce confusion. I just do not want to make the same\nmistake here.\n\nI didn't intend to discourage discusson of your application here.\n\nCarry on the discussion in a forum where you think the most people with\nappropriate skills and interests hang out, and if that forum is this list,\nthat is perfectly fine. Host a development repository at GitHub, Gitorious\nor somesuch, if it would help people stay in sync with the current status\nto have a public repository.\n\nI just do not think my tree is a good place to use as a \"while we are\ndeveloping\" staging area.\n"},{"id":"184984","messageId":"vpqmx8dg1et.fsf@bauges.imag.fr","threadId":"29635","inReplyTo":"7v4nulnac8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-20T12:00:26Z","receivedAt":"2012-02-20T12:00:26Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Carry on the discussion in a forum where you think the most people with\n> appropriate skills and interests hang out, and if that forum is this list,\n> that is perfectly fine. Host a development repository at GitHub, Gitorious\n> or somesuch, if it would help people stay in sync with the current status\n> to have a public repository.\n\nThe script is now available here:\n\n  https://gitorious.org/git-latexdiff/git-latexdiff/trees/master\n\nIn the meantime, I discovered another script doing essentially the\nsame : latexdiff-git\n\n  https://github.com/cawka/latexdiff/blob/master/latexdiff-git\n\nMy feeling is that the development of latexdiff is stalled (the\nauthor's email included in the script bounces ...), and there are a few\nunofficial forks, more or less stalled too.\n\nWhen I have time, I may try to add the features of my script to\nlatexdiff-git (written in perl, while latexdiff is already in perl, so\nthe choice of language is probably better). But that's most likely not\ngoing to happen soon.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}