* git-svn: simple user-level versions question, plus help request
From: Richard Holmes @ 2012-02-16 20:57 UTC (permalink / raw)
To: git
Hi all,
I've enjoyed using git-svn in the past, and it's been great until I
had to update my local svn executable to support the server's adoption
of sslv3. I updated and configured my svn client with ra_serf and
then I could use svn standalone again.
When I went back to a git-svn project, I found that I could no longer
interact with the svn server via git-svn. I tried recreate the
git-svn tree by blowing away my working copy and starting over:
git svn init --stdlayout https://<redacted>/svn/path/to/repo
and got the familiar ssl error:
Initialized empty Git repository in /Volumes/foo/bar/.git/
RA layer request failed: OPTIONS of
'https://<redacted>/svn/path/to/repo': SSL handshake failed: SSL
error: bad decompression (https://<redacted>) at
/usr/local/Cellar/git/1.7.8.2/libexec/git-core/git-svn line 2299
(Yes, I'm using MacOS Lion and Homebrew to install git). So, it
appears that the svn with the ra_serf is not being used by git-svn.
Obvious questions:
1) Can I force git to use "my" version of svn for git-svn?
2) If so, how / where is this configured?
3) If not, what else can I do to get git-svn to talk to my svn server?
After looking at the respective versions, it appears that git svn
shows svn version 1.6.16 and my svn (standalone) client shows svn
version 1.6.17 (and its associated RA modules):
$ git svn --version
git-svn version 1.7.8.2 (svn 1.6.16)
$ svn --version
svn, version 1.6.17 (r1128011)
compiled Aug 26 2011, 09:41:54
Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository access (RA) modules are available:
* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
- handles 'http' scheme
- handles 'https' scheme
$ which git
/usr/local/bin/git
$ which svn
/opt/subversion/bin/svn
Sorry for the long post, but any help would be appreciated. Doesn't
seem to be a common problem (judging from lack of discussion on
google), so I'd appreciate any pointers, either to documentation about
git's svn path / configuration, problem tickets, or ways to determine
if I've done something wonky to my environment to seriously confuse
git / svn.
Thanks!
-Richard.
^ permalink raw reply
* Re: [PATCHv2 0/8] gitweb: Faster and improved project search
From: Junio C Hamano @ 2012-02-16 20:40 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
In-Reply-To: <1329338332-30358-1-git-send-email-jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> [Cc-ing Junio because of his involvement in discussion about first
> patch in previous version of this series.]
>
> First three patches in this series are mainly about speeding up
> project search (and perhaps in the future also project pagination).
> Well, first one is unification, refactoring and future-proofing.
> The second and third patch could be squashed together; second adds
> @fill_only, but third actually uses it.
>
> Next set of patches is about highlighting matched part, making it
> easier to recognize why project was selected, what we were searching
> for (though better page title would also help second issue).
>
> Well, fourth patch (first in set mentioned above) is here for the
> commit message, otherwise it could have been squashed with next one.
>
> Last patch in this series is beginning of using esc_html_match_hl()
> for other searches in gitweb -- the easiest part.
Notice that you never said anything about what you wanted to achieve with
this entire series? " -- the easiest part." does not mean anything.
The easiest part of what?
Where in the series do the "faster" and "improved" come from? What do you
exactly mean by "faster" and "improved"? In which commit would we find
the answers to the questions like:
- What operation was slow and how you tackled that slowness?
- What are the benchmark results?
In general, "improve" is such a loaded word (after all, patches sent to
the list are almost always meant to "improve" things) that it almost does
not convey a single bit of information. Are you fixing bugs? Are you
tidying up an unreadable piece of code? Are you fixing styles? Are you
producing prettier output? Are you refactoring cut-and-pasted repetition
into a common helper function? Are you adding a new feature?
^ permalink raw reply
* Re: [PATCHv2 1/3] gitweb: Deal with HEAD pointing to unborn branch in "heads" view
From: Junio C Hamano @ 2012-02-16 20:29 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git, rajesh boyapati
In-Reply-To: <1329320203-20272-2-git-send-email-jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> Gitweb has problems if HEAD points to an unborn branch, with no
> commits on it yet, but there are other branches present (so it is not
> newly initialized repository).
It would be more readable if you rephrase the vague "has problems" with a
concrete description of what the problem is.
Also, drop the " (so it is ...)" part, which does not add much useful
information. Your next paragraph describes how a repository can come to
this state anyway.
> This can happen if non-bare repository (with default 'master' branch)
> is updated not via committing but by other means like push to it, or
> Gerrit. It can happen also just after running "git checkout --orphan
> <new branch>" but before creating any new commit on this branch.
>
> This commit adds test and fixes the issue of being on unborn branch
> (of HEAD not pointing to a commit) in "heads" view, and also in
> "summary" view -- which includes "heads" excerpt as subview.
The reader has not seen anything more than "has problems" at this point,
so "fixes the issue of ..." is not very helpful. You could have just said
"adds tests and fixes it", if you said that the unspecified "problems"
apear in "heads" and "summary" view at the beginning of the log message.
Thanks.
^ permalink raw reply
* Re: git status: small difference between stating whole repository and small subdirectory
From: Junio C Hamano @ 2012-02-16 20:15 UTC (permalink / raw)
To: Thomas Rast
Cc: Piotr Krukowiecki, Jeff King, Git Mailing List,
Nguyen Thai Ngoc Duy
In-Reply-To: <87d39eswkx.fsf@thomas.inf.ethz.ch>
Thomas Rast <trast@inf.ethz.ch> writes:
> ... If my memory of pack organization serves
> right, the commit objects involved would essentially be spread across
> the whole pack
No they are crumped together in a contiguous section in a packfile, so
that "git log" without any pathspec can go faster without consulting tree
objects.
^ permalink raw reply
* Re: [PATCH 0/8] config-include fixes
From: Junio C Hamano @ 2012-02-16 20:11 UTC (permalink / raw)
To: Jeff King; +Cc: git
In-Reply-To: <20120216080102.GA11793@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I prepared this on top of what you have queued in jk/config-include.
> However, all of the cleanup is semantically independent of the topic
> (though there are a few minor textual conflicts). If I were re-rolling,
> I would put it all at the front, then squash patch 8 into my prior
> "implement config includes" patch.
Sorry for being late in answering the "revert or build on top" question; I
was mostly offline yesterday afternoon.
> [7/8]: config: eliminate config_exclusive_filename
>
> This is all cleanup which makes config_exclusive_filename go away. It's
> not strictly necessary for this series, but it's something I've been
> wanting to clean up for a while. And it does fix a few minor bugs (see
> patch 6/8). And the refactoring in 5/8 lays the groundwork for 8/8.
>
> [8/8]: config: do not respect includes for single-file --list
>
> The actual fix for the regression in my config-include patch.
Thanks.
Looking at the rebased result, it strikes me that with_options version
Furthermore, by providing a more "advanced" interface, we
now have a a natural place to add new options for callers
like git-config, which care about tweaking the specifics of
config lookup, without disturbing the large number of
"simple" users (i.e., every other part of git).
perhaps wants to get a pointer to struct config_lookup_options, instead of
us having to add a new parameter to all callsites every time a new need
is discovered.
^ permalink raw reply
* Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Junio C Hamano @ 2012-02-16 20:10 UTC (permalink / raw)
To: Matthieu Moy; +Cc: Tim Haga, git
In-Reply-To: <vpq39abrxav.fsf@bauges.imag.fr>
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
> Tim Haga <timhaga@ebene6.org> writes:
>
>> While testing your script on my office machine i discovered that the
>> following might be a problem:
>>
>>> +if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
>>> + xpdf "$pdffile"
>>> +fi
>>
>> Xpdf is not installed on all machines (e.g. it's not installed on my
>> office machine), so maybe it would be a good idea to use a environment
>> variable instead?
Honestly speaking, this is looking more like an "useful application for
latex users who happen to use git to store their document source", and not
a "useful addition for all git users", to me.
These two viewpoint suggests completely different evolution path for this
program. Imagining what the first major new enhancement intended for
people outside the original audience <git,latex> will be, I have this
suspicion that "this new version will help people who have their documents
stored in Mercurial" would be much more realistic (and the end result
being useful) than "this new version will help git users who do not write
their documents in latex but in asciidoc".
For that reason, I suspect that in the longer term, the tool will benefit
more if I do not take this patch and the tool lives standalone.
^ permalink raw reply
* Re: [PATCH 1/3 v5] diff --stat: tests for long filenames and big change counts
From: Junio C Hamano @ 2012-02-16 20:01 UTC (permalink / raw)
To: Zbigniew Jędrzejewski-Szmek; +Cc: git, Michael J Gruber, pclouds
In-Reply-To: <4F3CD318.1040600@in.waw.pl>
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
> On 02/15/2012 06:12 PM, Junio C Hamano wrote:
>> Zbigniew Jędrzejewski-Szmek<zbyszek@in.waw.pl> writes:
>>
>>> Eleven tests for various combinations of a long filename and/or big
>>> change count and ways to specify widths for diff --stat.
>>> ---
>>
>> Sign-off?
>
>> Hrm, this does not seem to pass, making the result of applying [1/3] fail;
>> I see that the elided name is shown much shorter than the above expects.
>
> Hi,
>
> I'm sorry for not properly testing the patch with tests. I somehow
> convinced myself that the tests pass. This whole series needs more
> work, even after squashing in your two patches.
It is nothing to be sorry about if a series needs more polishing; that is
what the review discussions are for.
I've queued the series after restructuring it, and merged except for [3/3]
to 'pu', which conflicts too heavily with the nd/diffstat-gramnum topic
that is already in 'master'. I'd say we should concentrate on your first
two patches without the "num-width" stuff and get them in first, and then
later consider if rerolling the [3/3] patch is worth it after the dust
settles.
Thanks.
^ permalink raw reply
* Re: [PATCH v2] git-latexdiff: new command in contrib, to use latexdiff and Git
From: David Aguilar @ 2012-02-16 19:24 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git, gitster
In-Reply-To: <1329381560-15853-1-git-send-email-Matthieu.Moy@imag.fr>
On Thu, Feb 16, 2012 at 12:39 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
> +
> +verbose () {
> + if [ "$verbose" = 1 ]; then
> + printf "%s ..." "$@"
> + fi
> +}
In addition to preferring "test" over "[", we also prefer to write
these on several lines. It's probably time to update the CodingStyle
document with these notes.
e.g.
if test "$verbose" = 1
then
.... do stuff
fi
(with hard-tabs, not spaces (unlike my example))
--
David
^ permalink raw reply
* Re: git status: small difference between stating whole repository and small subdirectory
From: Jeff King @ 2012-02-16 19:20 UTC (permalink / raw)
To: Piotr Krukowiecki; +Cc: Thomas Rast, Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <CAA01Cso5y23UMguEe0vwOc6kR3-DjuC8-LTMDsMeeOKU4rVGvg@mail.gmail.com>
On Thu, Feb 16, 2012 at 02:37:47PM +0100, Piotr Krukowiecki wrote:
> >> $ time git status -- .
> >> real 0m2.503s
> >> user 0m0.160s
> >> sys 0m0.096s
> >>
> >> $ time git status
> >> real 0m9.663s
> >> user 0m0.232s
> >> sys 0m0.556s
> >
> > Did you drop caches here, too?
>
> Yes I did - with cache the status takes something like 0.1-0.3s on whole repo.
OK, then that makes sense. It's pretty much just I/O on the filesystem
and on the object db.
You can break status down a little more to see which is which. Try "git
update-index --refresh" to see just how expensive the lstat and index
handling is.
And then try "git diff-index HEAD" for an idea of how expensive it is to
just read the objects and compare to the index.
> > Not really. You're showing an I/O problem, and repacking is git's way of
> > reducing I/O.
>
> So if I understand correctly, the reason is because git must compare
> workspace files with packed objects - and the problem is
> reading/seeking/searching in the packs?
Mostly reading (we keep a sorted index and access the packfiles via
mmap, so we only touch the pages we need). But you're also paying to
lstat() the directory tree, too. And you're paying to load (probably)
the whole index into memory, although it's relatively compact compared
to the actual file data.
> Is there a way to make packs better? I think most operations are on
> workdir files - so maybe it'd be possible to tell gc/repack/whatever
> to optimize access to files which I currently have in workdir?
It already does optimize for that case. If you can make it even better,
I'm sure people would be happy to see the numbers.
Mostly I think it is just the case that disk I/O is slow, and the
operation you're asking for has to do a certain amount of it. What kind
of disk/filesystem are you pulling off of?
It's not a fuse filesystem by any chance, is it? I have a repo on an
encfs-mounted filesystem, and the lstat times are absolutely horrific.
-Peff
^ permalink raw reply
* Re: [PATCH] completion: --list option for git-branch
From: Junio C Hamano @ 2012-02-16 18:07 UTC (permalink / raw)
To: Zbigniew Jędrzejewski-Szmek; +Cc: Ralf Thielow, spearce, git
In-Reply-To: <4F3CCC4A.5010100@in.waw.pl>
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
> Normally one would use just a bare 'git branch' to list branches.
> Why would you want to use --list in an interactive environment (as
> opposed to a script)? Isn't it better not to clutter the completion
> options with something that the user actually has not need for?
$ git branch jc/\*
fatal: 'jc/*' is not a valid branch name.
$ git branch --list jc/\*
jc/advise-i18n
jc/advise-push-default
...
^ permalink raw reply
* Re: [PATCH v3] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Matthieu Moy @ 2012-02-16 14:15 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git, gitster
In-Reply-To: <m3d39esxrg.fsf@localhost.localdomain>
Jakub Narebski <jnareb@gmail.com> writes:
> Nb. I think it would be good to put detecting PDF viewer in its own
> function, don't you?
I normally like functions, but for such a linear and small piece of
code, I think it adds more confusion that clarity to write
do_fo () {
actual stuff
}
do_foo
than the actual stuff alone.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply
* [PATCH v4] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Matthieu Moy @ 2012-02-16 14:08 UTC (permalink / raw)
To: git, gitster; +Cc: Matthieu Moy
In-Reply-To: <m3d39esxrg.fsf@localhost.localdomain>
git-latexdiff is a wrapper around latexdiff
(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two
revisions of a LaTeX file.
git-latexdiff is made to work on documents split accross multiple .tex
files (plus possibly figures and other non-diffable files), hence could
not be implemented as a per-file diff driver.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Sorry, I forgot to commit before sending v3, so it was obviously wrong.
This one should contain what I promised in v2, i.e:
- Try 'open' on MacOS to view PDF file.
- Shell style issues (thanks to Jakub)
Jakub, I also forgot to send this before the patch (I got interrupted,
and it seems my mental context-switch implementation loses data ;-) ):
> Why we autodetect PDF viewer unconditionally?
We don't really do that: the test is inside a test on $PDFVIEWER, so
it's essentially the same. I just wrote it this way because I thought
"break" wasn't POSIX, but it is actually, so I'm taking your version.
contrib/latex/Makefile | 22 ++++
contrib/latex/README | 12 ++
contrib/latex/git-latexdiff | 256 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 290 insertions(+), 0 deletions(-)
create mode 100644 contrib/latex/Makefile
create mode 100644 contrib/latex/README
create mode 100755 contrib/latex/git-latexdiff
diff --git a/contrib/latex/Makefile b/contrib/latex/Makefile
new file mode 100644
index 0000000..4617906
--- /dev/null
+++ b/contrib/latex/Makefile
@@ -0,0 +1,22 @@
+-include ../../config.mak
+-include ../../config.mak.autogen
+
+ifndef SHELL_PATH
+ SHELL_PATH = /bin/sh
+endif
+
+SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
+
+SCRIPT=git-latexdiff
+
+.PHONY: install help
+help:
+ @echo 'This is the help target of the Makefile. Current configuration:'
+ @echo ' gitexecdir = $(gitexecdir_SQ)'
+ @echo ' SHELL_PATH = $(SHELL_PATH_SQ)'
+ @echo 'Run "$(MAKE) install" to install $(SCRIPT) in gitexecdir.'
+
+install:
+ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' $(SCRIPT) > '$(gitexecdir_SQ)/$(SCRIPT)'
+ chmod 755 '$(gitexecdir)/$(SCRIPT)'
diff --git a/contrib/latex/README b/contrib/latex/README
new file mode 100644
index 0000000..2d7fdd6
--- /dev/null
+++ b/contrib/latex/README
@@ -0,0 +1,12 @@
+git-latexdiff is a wrapper around latexdiff
+(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two
+revisions of a LaTeX file.
+
+The script internally checks out the full tree for the specified
+revisions, and calls latexdiff with the --flatten option, hence this
+works if the document is split into multiple .tex files.
+
+Try "git latexdiff -h" for more information.
+
+To install, either drop git-latexdiff in your $PATH, or run "make
+install".
diff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff
new file mode 100755
index 0000000..19b9783
--- /dev/null
+++ b/contrib/latex/git-latexdiff
@@ -0,0 +1,256 @@
+#! /bin/sh
+
+# Author: Matthieu Moy <Matthieu.Moy@imag.fr> (2012)
+
+# Missing features (patches welcome ;-) :
+# - diff the index or the current worktree
+# - checkout only a subdirectory of the repo
+# - hardlink temporary checkouts as much as possible
+
+usage () {
+ cat << EOF
+Usage: $(basename $0) [options] OLD [NEW]
+Call latexdiff on two Git revisions of a file.
+
+OLD and NEW are Git revision identifiers. NEW defaults to HEAD.
+
+Options:
+ --help this help message
+ --main <file.tex> name of the main LaTeX file
+ --no-view don't display the resulting PDF file
+ --view view the resulting PDF file
+ (default if -o is not used)
+ --pdf-viewer <cmd> use <cmd> to view the PDF file (default: \$PDFVIEWER)
+ --no-cleanup don't cleanup temp dir after running
+ -o <file>, --output <file>
+ copy resulting PDF into <file>
+ (usually ending with .pdf)
+EOF
+}
+
+die () {
+ echo "fatal: $@"
+ exit 1
+}
+
+verbose () {
+ if test "$verbose" = 1 ; then
+ printf "%s ..." "$@"
+ fi
+}
+
+verbose_progress () {
+ if test "$verbose" = 1 ; then
+ printf "." "$@"
+ fi
+}
+
+verbose_done () {
+ if test "$verbose" = 1 ; then
+ echo " ${1:-done}."
+ fi
+}
+
+old=
+new=
+main=
+view=maybe
+cleanup=1
+verbose=0
+output=
+initial_dir=$PWD
+
+while test $# -ne 0; do
+ case "$1" in
+ "--help"|"-h")
+ usage
+ exit 0
+ ;;
+ "--main")
+ test $# -gt 1 && shift || die "missing argument for $1"
+ main=$1
+ ;;
+ "--no-view")
+ view=0
+ ;;
+ "--view")
+ view=1
+ ;;
+ "--pdf-viewer")
+ test $# -gt 1 && shift || die "missing argument for $1"
+ PDFVIEWER="$1"
+ ;;
+ "--no-cleanup")
+ cleanup=0
+ ;;
+ "-o"|"--output")
+ test $# -gt 1 && shift || die "missing argument for $1"
+ output=$1
+ ;;
+ "--verbose"|"-v")
+ verbose=1
+ ;;
+ *)
+ if test -z "$1" ; then
+ echo "Empty string not allowed as argument"
+ usage
+ exit 1
+ elif test -z "$old" ; then
+ old=$1
+ elif test -z "$new" ; then
+ new=$1
+ else
+ echo "Bad argument $1"
+ usage
+ exit 1
+ fi
+ ;;
+ esac
+ shift
+done
+
+if test -z "$new" ; then
+ new=HEAD
+fi
+
+if test -z "$old" ; then
+ echo "fatal: Please, provide at least one revision to diff with."
+ usage
+ exit 1
+fi
+
+if test -z "$PDFVIEWER" ; then
+ verbose "Auto-detecting PDF viewer"
+ candidates="xdg-open evince okular xpdf acroread"
+ if test "$(uname)" = Darwin ; then
+ # open exists on GNU/Linux, but does not open PDFs
+ candidates="open $candidates"
+ fi
+
+ for command in $candidates; do
+ if command -v "$command" >/dev/null 2>&1; then
+ PDFVIEWER="$command"
+ break
+ else
+ verbose_progress
+ fi
+ done
+ verbose_done "$PDFVIEWER"
+fi
+
+case "$view" in
+ maybe|1)
+ if test -z "$PDFVIEWER" ; then
+ echo "warning: could not find a PDF viewer on your system."
+ echo "warning: Please set \$PDFVIEWER or use --pdf-viewer CMD."
+ PDFVIEWER=false
+ fi
+ ;;
+esac
+
+if test -z "$main" ; then
+ printf "%s" "No --main provided, trying to guess ... "
+ main=$(git grep -l '^[ \t]*\\documentclass')
+ # May return multiple results, but if so the result won't be a file.
+ if test -r "$main" ; then
+ echo "Using $main as the main file."
+ else
+ if test -z "$main" ; then
+ echo "No candidate for main file."
+ else
+ echo "Multiple candidates for main file:"
+ printf "%s\n" "$main" | sed 's/^/\t/'
+ fi
+ die "Please, provide a main file with --main FILE.tex."
+ fi
+fi
+
+if test ! -r "$main" ; then
+ die "Cannot read $main."
+fi
+
+verbose "Creating temporary directories"
+
+git_prefix=$(git rev-parse --show-prefix)
+cd "$(git rev-parse --show-cdup)" || die "Can't cd back to repository root"
+git_dir="$(git rev-parse --git-dir)" || die "Not a git repository?"
+git_dir=$(cd "$git_dir"; pwd)
+
+main=$git_prefix/$main
+
+tmpdir=$initial_dir/git-latexdiff.$$
+mkdir "$tmpdir" || die "Cannot create temporary directory."
+
+cd "$tmpdir" || die "Cannot cd to $tmpdir"
+
+mkdir old new diff || die "Cannot create old, new and diff directories."
+
+verbose_done
+verbose "Checking out old and new version"
+
+cd old || die "Cannot cd to old/"
+git --git-dir="$git_dir" --work-tree=. checkout "$old" -- . || die "checkout failed for old/"
+verbose_progress
+cd ../new || die "Cannot cd to new/"
+git --git-dir="$git_dir" --work-tree=. checkout "$new" -- . || die "checkout failed for new/"
+verbose_progress
+cd ..
+
+verbose_done
+verbose "Running latexdiff --flatten old/$main new/$main > $main"
+
+latexdiff --flatten old/"$main" new/"$main" > diff.tex || die "latexdiff failed"
+
+mv -f diff.tex new/"$main"
+
+verbose_done
+
+mainbase=$(basename "$main" .tex)
+maindir=$(dirname "$main")
+
+verbose "Compiling result"
+
+compile_error=0
+cd new/"$maindir" || die "Can't cd to new/$maindir"
+if test -f Makefile ; then
+ make || compile_error=1
+else
+ pdflatex --interaction errorstopmode "$mainbase" || compile_error=1
+fi
+
+verbose_done
+
+pdffile="$mainbase".pdf
+if test ! -r "$pdffile" ; then
+ echo "No PDF file generated."
+ compile_error=1
+fi
+
+if test ! -s "$pdffile" ; then
+ echo "PDF file generated is empty."
+ compile_error=1
+fi
+
+if test "$compile_error" = "1" ; then
+ echo "Error during compilation. Please examine and cleanup if needed:"
+ echo "Directory: $tmpdir/new/$maindir/"
+ echo " File: $mainbase.tex"
+ # Don't clean up to let the user diagnose.
+ exit 1
+fi
+
+if test -n "$output" ; then
+ abs_pdffile="$PWD/$pdffile"
+ (cd "$initial_dir" && cp "$abs_pdffile" "$output")
+ echo "Output written on $output"
+fi
+
+if test "$view" = 1 || test "$view" = maybe && test -z "$output" ; then
+ "$PDFVIEWER" "$pdffile"
+fi
+
+if test "$cleanup" = 1 ; then
+ verbose "Cleaning-up result"
+ rm -fr "$tmpdir"
+ verbose_done
+fi
--
1.7.9.111.gf3fb0.dirty
^ permalink raw reply related
* Re: git status: small difference between stating whole repository and small subdirectory
From: Thomas Rast @ 2012-02-16 14:05 UTC (permalink / raw)
To: Piotr Krukowiecki; +Cc: Jeff King, Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <CAA01Cso5y23UMguEe0vwOc6kR3-DjuC8-LTMDsMeeOKU4rVGvg@mail.gmail.com>
Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:
> On Wed, Feb 15, 2012 at 8:03 PM, Jeff King <peff@peff.net> wrote:
>> On Wed, Feb 15, 2012 at 09:57:29AM +0100, Piotr Krukowiecki wrote:
>>>
>> I notice that you're still I/O bound even after the repack:
>>
>>> $ time git status -- .
>>> real 0m2.503s
>>> user 0m0.160s
>>> sys 0m0.096s
>>>
>>> $ time git status
>>> real 0m9.663s
>>> user 0m0.232s
>>> sys 0m0.556s
>>
>> Did you drop caches here, too?
>
> Yes I did - with cache the status takes something like 0.1-0.3s on whole repo.
So umm, I'm not sure that leaves anything to be improved.
I looked at some strace dumps, and limiting the status to a subdirectory
(in my case, '-- t' in git.git) does omit the lstat()s on uninteresting
parts of the index-listed files, as well as the getdents() (i.e.,
readdir()) for parts of the tree that are not interesting.
BTW, some other parts of git-status's display may be responsible for the
amount of data it pulls from disk. In particular, the "Your branch is
ahead" display requires computing the merge-base between HEAD and
@{upstream}. If your @{upstream} is way ahead/behind, or points at a
disjoint chunk of history, this may mean essentially pulling all of the
involved history from disk. If my memory of pack organization serves
right, the commit objects involved would essentially be spread across
the whole pack (corresponding to "time") and thus this operation would
more or less load the entire pack from disk.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: [PATCH v3] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Jakub Narebski @ 2012-02-16 13:40 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git, gitster
In-Reply-To: <1329395775-18294-1-git-send-email-Matthieu.Moy@imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
> Changes since v2:
>
[...]
> - Shell style issues (thanks to Jakub)
[...]
> +verbose "Auto-detecting PDF viewer"
> +candidates="xdg-open evince okular xpdf acroread"
> +if [ "$(uname)" = Darwin ]; then
> + # open exists on GNU/Linux, but does not open PDFs
> + candidates="open $candidates"
> +fi
> +
> +for command in $candidates; do
> + if [ "$PDFVIEWER" = "" ]; then
> + if command -v "$command" >/dev/null 2>&1; then
> + PDFVIEWER="$command"
> + else
> + verbose_progress
> + fi
> + fi
> +done
> +verbose_done "$PDFVIEWER"
Eh? I don't see shell style issues fixed (loop inside conditional
instead of vice-versa, "test ..." instead of "[ ... ]").
Nb. I think it would be good to put detecting PDF viewer in its own
function, don't you?
--
Jakub Narebski
^ permalink raw reply
* Re: git status: small difference between stating whole repository and small subdirectory
From: Piotr Krukowiecki @ 2012-02-16 13:37 UTC (permalink / raw)
To: Jeff King; +Cc: Thomas Rast, Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20120215190318.GA5992@sigill.intra.peff.net>
On Wed, Feb 15, 2012 at 8:03 PM, Jeff King <peff@peff.net> wrote:
> On Wed, Feb 15, 2012 at 09:57:29AM +0100, Piotr Krukowiecki wrote:
>>
> I notice that you're still I/O bound even after the repack:
>
>> $ time git status -- .
>> real 0m2.503s
>> user 0m0.160s
>> sys 0m0.096s
>>
>> $ time git status
>> real 0m9.663s
>> user 0m0.232s
>> sys 0m0.556s
>
> Did you drop caches here, too?
Yes I did - with cache the status takes something like 0.1-0.3s on whole repo.
> Usually that would not be the case on a
> warm cache. If it is, then it sounds like you are short on memory to
> actually hold the directory tree and object db in cache. If not, what do
> the warm cache numbers look like?
I've got 4GB of ram and I did not hit the swap when doing last
performance tests AFAIK.
Please see my previous posts for performance results with warm cache
and profile results:
http://article.gmane.org/gmane.comp.version-control.git/190397
http://article.gmane.org/gmane.comp.version-control.git/190638
>> - can it be faster without repacking?
>
> Not really. You're showing an I/O problem, and repacking is git's way of
> reducing I/O.
So if I understand correctly, the reason is because git must compare
workspace files with packed objects - and the problem is
reading/seeking/searching in the packs?
Is there a way to make packs better? I think most operations are on
workdir files - so maybe it'd be possible to tell gc/repack/whatever
to optimize access to files which I currently have in workdir?
>> - even with packed repo, the time on small subdirectory is much higher
>> than I'd expect given time on whole repo and subdirectory size - why?
>
> Hard to say without profiling. It may be that we reduced the object db
> lookups, saving some time, but still end up stat()ing the whole tree.
> The optimization to stat only the directories of interest was in 688cd6d
> (status: only touch path we may need to check, 2010-01-14), which went
> into v1.7.0. What version of git are you using?
For latest tests I've used 1.7.9.rc0.10.gbeecc, for profiling - 1.7.9.188.g12766
Is there anything else I could do?
--
Piotr Krukowiecki
^ permalink raw reply
* Re: git status: small difference between stating whole repository and small subdirectory
From: Piotr Krukowiecki @ 2012-02-16 13:22 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: Thomas Rast, Git Mailing List, Jeff King
In-Reply-To: <CAA01CsoW-32kOtD2g==2FDcYaxfSVD4Xdy1bYG_wJBWDNept4A@mail.gmail.com>
On Wed, Feb 15, 2012 at 4:14 PM, Piotr Krukowiecki
<piotr.krukowiecki@gmail.com> wrote:
> On Wed, Feb 15, 2012 at 12:01 PM, Nguyen Thai Ngoc Duy
> <pclouds@gmail.com> wrote:
>> On Wed, Feb 15, 2012 at 3:57 PM, Piotr Krukowiecki
>> <piotr.krukowiecki@gmail.com> wrote:
>>> Indeed, after gc the times went down:
>>> 10s -> 2.3s (subdirectory)
>>> 17s -> 9.5s (whole repo)
>>>
>>> 2 seconds is much better and I'd say acceptable for me. But my questions are:
>>> - why is it so slow with not packed repo?
>>> - can it be faster without repacking?
>>
>> gc does more than just repacking. If you still have the un-gc'd repo,
>> Try these commands one by one, and time "git status" after each:
>>
>> - git pack-refs --all --prune
>> - git reflog expire --all
>> - git repack -d -l
>> - git prune --expire
>> - git rerere gc
>
> It will take some time but hopefully I'll have the stats for tomorrow.
Here they are. I did 'status' three times to get reliable results and
before each run have dropped caches. Backed up repository was copied
before each 'status'. Full log is at http://pastebin.com/VmB7J9CJ
git version 1.7.9.rc0.10.gbeecc
Results after each command:
status on whole repo:
18.5s - after git count-objects -v
16.0s - after git pack-refs --all --prune
20.2s - after git reflog expire --all
13.0s - after git repack -d -l
16.8s - after git prune --expire now
19.7s - after git rerere gc
status on subdir:
9.7s - after git count-objects -v
9.2s - after git pack-refs --all --prune
9.3s - after git reflog expire --all
4.4s - after git repack -d -l
9.2s - after git prune --expire now
9.0s - after git rerere gc
--
Piotr Krukowiecki
^ permalink raw reply
* [PATCH v3] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Matthieu Moy @ 2012-02-16 12:36 UTC (permalink / raw)
To: git, gitster; +Cc: Matthieu Moy
In-Reply-To: <vpq39abrxav.fsf@bauges.imag.fr>
git-latexdiff is a wrapper around latexdiff
(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two
revisions of a LaTeX file.
git-latexdiff is made to work on documents split accross multiple .tex
files (plus possibly figures and other non-diffable files), hence could
not be implemented as a per-file diff driver.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Changes since v2:
- Try 'open' on MacOS to view PDF file.
- Shell style issues (thanks to Jakub)
contrib/latex/Makefile | 22 ++++
contrib/latex/README | 12 ++
contrib/latex/git-latexdiff | 255 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 289 insertions(+), 0 deletions(-)
create mode 100644 contrib/latex/Makefile
create mode 100644 contrib/latex/README
create mode 100755 contrib/latex/git-latexdiff
diff --git a/contrib/latex/Makefile b/contrib/latex/Makefile
new file mode 100644
index 0000000..4617906
--- /dev/null
+++ b/contrib/latex/Makefile
@@ -0,0 +1,22 @@
+-include ../../config.mak
+-include ../../config.mak.autogen
+
+ifndef SHELL_PATH
+ SHELL_PATH = /bin/sh
+endif
+
+SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
+
+SCRIPT=git-latexdiff
+
+.PHONY: install help
+help:
+ @echo 'This is the help target of the Makefile. Current configuration:'
+ @echo ' gitexecdir = $(gitexecdir_SQ)'
+ @echo ' SHELL_PATH = $(SHELL_PATH_SQ)'
+ @echo 'Run "$(MAKE) install" to install $(SCRIPT) in gitexecdir.'
+
+install:
+ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' $(SCRIPT) > '$(gitexecdir_SQ)/$(SCRIPT)'
+ chmod 755 '$(gitexecdir)/$(SCRIPT)'
diff --git a/contrib/latex/README b/contrib/latex/README
new file mode 100644
index 0000000..2d7fdd6
--- /dev/null
+++ b/contrib/latex/README
@@ -0,0 +1,12 @@
+git-latexdiff is a wrapper around latexdiff
+(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two
+revisions of a LaTeX file.
+
+The script internally checks out the full tree for the specified
+revisions, and calls latexdiff with the --flatten option, hence this
+works if the document is split into multiple .tex files.
+
+Try "git latexdiff -h" for more information.
+
+To install, either drop git-latexdiff in your $PATH, or run "make
+install".
diff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff
new file mode 100755
index 0000000..8466f52
--- /dev/null
+++ b/contrib/latex/git-latexdiff
@@ -0,0 +1,255 @@
+#! /bin/sh
+
+# Author: Matthieu Moy <Matthieu.Moy@imag.fr> (2012)
+
+# Missing features (patches welcome ;-) :
+# - diff the index or the current worktree
+# - checkout only a subdirectory of the repo
+# - hardlink temporary checkouts as much as possible
+
+usage () {
+ cat << EOF
+Usage: $(basename $0) [options] OLD [NEW]
+Call latexdiff on two Git revisions of a file.
+
+OLD and NEW are Git revision identifiers. NEW defaults to HEAD.
+
+Options:
+ --help this help message
+ --main <file.tex> name of the main LaTeX file
+ --no-view don't display the resulting PDF file
+ --view view the resulting PDF file
+ (default if -o is not used)
+ --pdf-viewer <cmd> use <cmd> to view the PDF file (default: \$PDFVIEWER)
+ --no-cleanup don't cleanup temp dir after running
+ -o <file>, --output <file>
+ copy resulting PDF into <file>
+ (usually ending with .pdf)
+EOF
+}
+
+die () {
+ echo "fatal: $@"
+ exit 1
+}
+
+verbose () {
+ if [ "$verbose" = 1 ]; then
+ printf "%s ..." "$@"
+ fi
+}
+
+verbose_progress () {
+ if [ "$verbose" = 1 ]; then
+ printf "." "$@"
+ fi
+}
+
+verbose_done () {
+ if [ "$verbose" = 1 ]; then
+ echo " ${1:-done}."
+ fi
+}
+
+old=
+new=
+main=
+view=maybe
+cleanup=1
+verbose=0
+output=
+initial_dir=$PWD
+
+while test $# -ne 0; do
+ case "$1" in
+ "--help"|"-h")
+ usage
+ exit 0
+ ;;
+ "--main")
+ shift
+ main=$1
+ ;;
+ "--no-view")
+ view=0
+ ;;
+ "--view")
+ view=1
+ ;;
+ "--pdf-viewer")
+ shift
+ PDFVIEWER="$1"
+ ;;
+ "--no-cleanup")
+ cleanup=0
+ ;;
+ "-o"|"--output")
+ shift
+ output=$1
+ ;;
+ "--verbose"|"-v")
+ verbose=1
+ ;;
+ *)
+ if [ "$1" = "" ]; then
+ echo "Empty string not allowed as argument"
+ usage
+ exit 1
+ elif [ "$old" = "" ]; then
+ old=$1
+ elif [ "$new" = "" ]; then
+ new=$1
+ else
+ echo "Bad argument $1"
+ usage
+ exit 1
+ fi
+ ;;
+ esac
+ shift
+done
+
+if [ "$new" = "" ]; then
+ new=HEAD
+fi
+
+if [ "$old" = "" ]; then
+ echo "fatal: Please, provide at least one revision to diff with."
+ usage
+ exit 1
+fi
+
+verbose "Auto-detecting PDF viewer"
+candidates="xdg-open evince okular xpdf acroread"
+if [ "$(uname)" = Darwin ]; then
+ # open exists on GNU/Linux, but does not open PDFs
+ candidates="open $candidates"
+fi
+
+for command in $candidates; do
+ if [ "$PDFVIEWER" = "" ]; then
+ if command -v "$command" >/dev/null 2>&1; then
+ PDFVIEWER="$command"
+ else
+ verbose_progress
+ fi
+ fi
+done
+verbose_done "$PDFVIEWER"
+
+case "$view" in
+ maybe|1)
+ if [ "$PDFVIEWER" = "" ]; then
+ echo "warning: could not find a PDF viewer on your system."
+ echo "warning: Please set \$PDFVIEWER or use --pdf-viewer CMD."
+ PDFVIEWER=false
+ fi
+ ;;
+esac
+
+if [ "$main" = "" ]; then
+ printf "%s" "No --main provided, trying to guess ... "
+ main=$(git grep -l '^[ \t]*\\documentclass')
+ # May return multiple results, but if so the result won't be a file.
+ if [ -r "$main" ]; then
+ echo "Using $main as the main file."
+ else
+ if [ "$main" = "" ]; then
+ echo "No candidate for main file."
+ else
+ echo "Multiple candidates for main file:"
+ printf "%s\n" "$main" | sed 's/^/\t/'
+ fi
+ die "Please, provide a main file with --main FILE.tex."
+ fi
+fi
+
+if [ ! -r "$main" ]; then
+ die "Cannot read $main."
+fi
+
+verbose "Creating temporary directories"
+
+git_prefix=$(git rev-parse --show-prefix)
+cd "$(git rev-parse --show-cdup)" || die "Can't cd back to repository root"
+git_dir="$(git rev-parse --git-dir)" || die "Not a git repository?"
+git_dir=$(cd "$git_dir"; pwd)
+
+main=$git_prefix/$main
+
+tmpdir=$initial_dir/git-latexdiff.$$
+mkdir "$tmpdir" || die "Cannot create temporary directory."
+
+cd "$tmpdir" || die "Cannot cd to $tmpdir"
+
+mkdir old new diff || die "Cannot create old, new and diff directories."
+
+verbose_done
+verbose "Checking out old and new version"
+
+cd old || die "Cannot cd to old/"
+git --git-dir="$git_dir" --work-tree=. checkout "$old" -- . || die "checkout failed for old/"
+verbose_progress
+cd ../new || die "Cannot cd to new/"
+git --git-dir="$git_dir" --work-tree=. checkout "$new" -- . || die "checkout failed for new/"
+verbose_progress
+cd ..
+
+verbose_done
+verbose "Running latexdiff --flatten old/$main new/$main > $main"
+
+latexdiff --flatten old/"$main" new/"$main" > diff.tex || die "latexdiff failed"
+
+mv -f diff.tex new/"$main"
+
+verbose_done
+
+mainbase=$(basename "$main" .tex)
+maindir=$(dirname "$main")
+
+verbose "Compiling result"
+
+compile_error=0
+cd new/"$maindir" || die "Can't cd to new/$maindir"
+if [ -f Makefile ]; then
+ make || compile_error=1
+else
+ pdflatex --interaction errorstopmode "$mainbase" || compile_error=1
+fi
+
+verbose_done
+
+pdffile="$mainbase".pdf
+if [ ! -r "$pdffile" ]; then
+ echo "No PDF file generated."
+ compile_error=1
+fi
+
+if [ ! -s "$pdffile" ]; then
+ echo "PDF file generated is empty."
+ compile_error=1
+fi
+
+if [ "$compile_error" = "1" ]; then
+ echo "Error during compilation. Please examine and cleanup if needed:"
+ echo "Directory: $tmpdir/new/$maindir/"
+ echo " File: $mainbase.tex"
+ # Don't clean up to let the user diagnose.
+ exit 1
+fi
+
+if [ "$output" != "" ]; then
+ abs_pdffile="$PWD/$pdffile"
+ (cd "$initial_dir" && cp "$abs_pdffile" "$output")
+ echo "Output written on $output"
+fi
+
+if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
+ "$PDFVIEWER" "$pdffile"
+fi
+
+if [ "$cleanup" = 1 ]; then
+ verbose "Cleaning-up result"
+ rm -fr "$tmpdir"
+ verbose_done
+fi
--
1.7.9.111.gf3fb0.dirty
^ permalink raw reply related
* Re: [PATCH 1/3 v5] diff --stat: tests for long filenames and big change counts
From: Zbigniew Jędrzejewski-Szmek @ 2012-02-16 9:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Michael J Gruber, pclouds
In-Reply-To: <7vvcn810ml.fsf@alter.siamese.dyndns.org>
On 02/15/2012 06:12 PM, Junio C Hamano wrote:
> Zbigniew Jędrzejewski-Szmek<zbyszek@in.waw.pl> writes:
>
>> Eleven tests for various combinations of a long filename and/or big
>> change count and ways to specify widths for diff --stat.
>> ---
>
> Sign-off?
> Hrm, this does not seem to pass, making the result of applying [1/3] fail;
> I see that the elided name is shown much shorter than the above expects.
Hi,
I'm sorry for not properly testing the patch with tests. I somehow
convinced myself that the tests pass. This whole series needs more work,
even after squashing in your two patches. I'll send a new series, but
probably not today. (I'll try to remember the sign-off too, next time).
--
Zbyszek
^ permalink raw reply
* Re: [PATCH] completion: --list option for git-branch
From: Zbigniew Jędrzejewski-Szmek @ 2012-02-16 9:28 UTC (permalink / raw)
To: Ralf Thielow; +Cc: spearce, git, gitster
In-Reply-To: <1329338218-9822-1-git-send-email-ralf.thielow@googlemail.com>
On 02/15/2012 09:36 PM, Ralf Thielow wrote:
> Signed-off-by: Ralf Thielow<ralf.thielow@googlemail.com>
> ---
> contrib/completion/git-completion.bash | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index d7367e9..1505cff 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1137,7 +1137,7 @@ _git_branch ()
> __gitcomp "
> --color --no-color --verbose --abbrev= --no-abbrev
> --track --no-track --contains --merged --no-merged
> - --set-upstream --edit-description
> + --set-upstream --edit-description --list
> "
> ;;
> *)
Normally one would use just a bare 'git branch' to list branches.
Why would you want to use --list in an interactive environment (as
opposed to a script)? Isn't it better not to clutter the completion
options with something that the user actually has not need for?
Zbyszek
^ permalink raw reply
* Re: [PATCH v2] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Jakub Narebski @ 2012-02-16 9:15 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git, gitster
In-Reply-To: <1329381560-15853-1-git-send-email-Matthieu.Moy@imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
> +verbose "Auto-detecting PDF viewer"
> +for command in xdg-open evince okular xpdf acroread; do
> + if [ "$PDFVIEWER" = "" ]; then
> + if command -v "$command" >/dev/null 2>&1; then
> + PDFVIEWER="$command"
> + else
> + verbose_progress
> + fi
> + fi
> +done
> +verbose_done "$PDFVIEWER"
Why we autodetect PDF viewer unconditionally? Why we do not stop on
first detected viewer rather than last? Why not
+if [ "$PDFVIEWER" = "" ]; then
+ verbose "Auto-detecting PDF viewer"
+ for command in xdg-open evince okular xpdf acroread; do
+ if command -v "$command" >/dev/null 2>&1; then
+ PDFVIEWER=$command
+ break
+ else
+ verbose_progress
+ fi
+ done
+ verbose_done "$PDFVIEWER"
+fi
Nb. Documentation/CodingGuidelines says:
For shell scripts specifically (not exhaustive):
[...]
- We prefer "test" over "[ ... ]".
I know that 'contrib/' is more relaxed...
--
Jakub Narebski
^ permalink raw reply
* Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Matthieu Moy @ 2012-02-16 8:59 UTC (permalink / raw)
To: Steven Michalske; +Cc: Tim Haga, git, gitster
In-Reply-To: <94614DF7-9EE3-47CB-BC6E-97069597557E@gmail.com>
Steven Michalske <smichalske@gmail.com> writes:
> On Mac OS X use the open command and the OS will use the correct viewer chosen by the user
>
> open "$pdffile"
Unfortunately, open also exists on my system, but does not do that at
all. I'm squashing this into the next version:
--- a/contrib/latex/git-latexdiff
+++ b/contrib/latex/git-latexdiff
@@ -120,7 +120,13 @@ if [ "$old" = "" ]; then
fi
verbose "Auto-detecting PDF viewer"
-for command in xdg-open evince okular xpdf acroread; do
+candidates="xdg-open evince okular xpdf acroread"
+if [ "$(uname)" = Darwin ]; then
+ # open exists on GNU/Linux, but does not open PDFs
+ candidates="open $candidates"
+fi
+
+for command in $candidates; do
if [ "$PDFVIEWER" = "" ]; then
if command -v "$command" >/dev/null 2>&1; then
PDFVIEWER="$command"
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply
* Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Steven Michalske @ 2012-02-16 8:47 UTC (permalink / raw)
To: Matthieu Moy; +Cc: Tim Haga, git, gitster
In-Reply-To: <vpq39abrxav.fsf@bauges.imag.fr>
On Mac OS X use the open command and the OS will use the correct viewer chosen by the user
open "$pdffile"
On Feb 16, 2012, at 12:34 AM, Matthieu Moy wrote:
> Tim Haga <timhaga@ebene6.org> writes:
>
>> While testing your script on my office machine i discovered that the
>> following might be a problem:
>>
>>> +if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
>>> + xpdf "$pdffile"
>>> +fi
>>
>> Xpdf is not installed on all machines (e.g. it's not installed on my
>> office machine), so maybe it would be a good idea to use a environment
>> variable instead?
>
> Right. I'm squashing this into the next version to allow configuration
> (environment variable or --pdf-viewer) and sensible auto-detection:
>
> diff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff
> index 13aeb9a..85aafda 100755
> --- a/contrib/latex/git-latexdiff
> +++ b/contrib/latex/git-latexdiff
> @@ -20,6 +20,8 @@ Options:
> --no-view Don't display the resulting PDF file
> --view View the resulting PDF file
> (default if -o is not used)
> + --pdf-viewer CMD
> + Use CMD to view the PDF file (default: \$PDFVIEWER)
> --no-cleanup Don't cleanup temp dir after running
> -o FILE, --output FILE
> Copy resulting PDF into FILE
> @@ -46,7 +48,7 @@ verbose_progress () {
>
> verbose_done () {
> if [ "$verbose" = 1 ]; then
> - echo " done."
> + echo " ${1:-done}."
> fi
> }
>
> @@ -75,6 +77,10 @@ while test $# -ne 0; do
> "--view")
> view=1
> ;;
> + "--pdf-viewer")
> + shift
> + PDFVIEWER="$1"
> + ;;
> "--no-cleanup")
> cleanup=0
> ;;
> @@ -114,6 +120,28 @@ if [ "$old" = "" ]; then
> exit 1
> fi
>
> +verbose "Auto-detecting PDF viewer"
> +for command in xdg-open evince okular xpdf acroread; do
> + if [ "$PDFVIEWER" = "" ]; then
> + if command -v "$command" >/dev/null 2>&1; then
> + PDFVIEWER="$command"
> + else
> + verbose_progress
> + fi
> + fi
> +done
> +verbose_done "$PDFVIEWER"
> +
> +case "$view" in
> + maybe|1)
> + if [ "$PDFVIEWER" = "" ]; then
> + echo "warning: could not find a PDF viewer on your system."
> + echo "warning: Please set \$PDFVIEWER or use --pdf-viewer CMD."
> + PDFVIEWER=false
> + fi
> + ;;
> +esac
> +
> if [ "$main" = "" ]; then
> printf "%s" "No --main provided, trying to guess ... "
> main=$(git grep -l '^[ \t]*\\documentclass')
> @@ -212,7 +240,7 @@ if [ "$output" != "" ]; then
> fi
>
> if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
> - xpdf "$pdffile"
> + "$PDFVIEWER" "$pdffile"
> fi
>
> if [ "$cleanup" = 1 ]; then
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH v2] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Matthieu Moy @ 2012-02-16 8:39 UTC (permalink / raw)
To: git, gitster; +Cc: Matthieu Moy
In-Reply-To: <vpq39abrxav.fsf@bauges.imag.fr>
git-latexdiff is a wrapper around latexdiff
(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two
revisions of a LaTeX file.
git-latexdiff is made to work on documents split accross multiple .tex
files (plus possibly figures and other non-diffable files), hence could
not be implemented as a per-file diff driver.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Changes since v1:
- Configuration/autodetection of PDF viewer
- Reformat output of -h to match what PARSE_OPTION does for other commands
contrib/latex/Makefile | 22 ++++
contrib/latex/README | 12 ++
contrib/latex/git-latexdiff | 249 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 283 insertions(+), 0 deletions(-)
create mode 100644 contrib/latex/Makefile
create mode 100644 contrib/latex/README
create mode 100755 contrib/latex/git-latexdiff
diff --git a/contrib/latex/Makefile b/contrib/latex/Makefile
new file mode 100644
index 0000000..4617906
--- /dev/null
+++ b/contrib/latex/Makefile
@@ -0,0 +1,22 @@
+-include ../../config.mak
+-include ../../config.mak.autogen
+
+ifndef SHELL_PATH
+ SHELL_PATH = /bin/sh
+endif
+
+SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
+
+SCRIPT=git-latexdiff
+
+.PHONY: install help
+help:
+ @echo 'This is the help target of the Makefile. Current configuration:'
+ @echo ' gitexecdir = $(gitexecdir_SQ)'
+ @echo ' SHELL_PATH = $(SHELL_PATH_SQ)'
+ @echo 'Run "$(MAKE) install" to install $(SCRIPT) in gitexecdir.'
+
+install:
+ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' $(SCRIPT) > '$(gitexecdir_SQ)/$(SCRIPT)'
+ chmod 755 '$(gitexecdir)/$(SCRIPT)'
diff --git a/contrib/latex/README b/contrib/latex/README
new file mode 100644
index 0000000..2d7fdd6
--- /dev/null
+++ b/contrib/latex/README
@@ -0,0 +1,12 @@
+git-latexdiff is a wrapper around latexdiff
+(http://www.ctan.org/pkg/latexdiff) that allows using it to diff two
+revisions of a LaTeX file.
+
+The script internally checks out the full tree for the specified
+revisions, and calls latexdiff with the --flatten option, hence this
+works if the document is split into multiple .tex files.
+
+Try "git latexdiff -h" for more information.
+
+To install, either drop git-latexdiff in your $PATH, or run "make
+install".
diff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff
new file mode 100755
index 0000000..57c2237
--- /dev/null
+++ b/contrib/latex/git-latexdiff
@@ -0,0 +1,249 @@
+#! /bin/sh
+
+# Author: Matthieu Moy <Matthieu.Moy@imag.fr> (2012)
+
+# Missing features (patches welcome ;-) :
+# - diff the index or the current worktree
+# - checkout only a subdirectory of the repo
+# - hardlink temporary checkouts as much as possible
+
+usage () {
+ cat << EOF
+Usage: $(basename $0) [options] OLD [NEW]
+Call latexdiff on two Git revisions of a file.
+
+OLD and NEW are Git revision identifiers. NEW defaults to HEAD.
+
+Options:
+ --help this help message
+ --main <file.tex> name of the main LaTeX file
+ --no-view don't display the resulting PDF file
+ --view view the resulting PDF file
+ (default if -o is not used)
+ --pdf-viewer <cmd> use <cmd> to view the PDF file (default: \$PDFVIEWER)
+ --no-cleanup don't cleanup temp dir after running
+ -o <file>, --output <file>
+ copy resulting PDF into <file>
+ (usually ending with .pdf)
+EOF
+}
+
+die () {
+ echo "fatal: $@"
+ exit 1
+}
+
+verbose () {
+ if [ "$verbose" = 1 ]; then
+ printf "%s ..." "$@"
+ fi
+}
+
+verbose_progress () {
+ if [ "$verbose" = 1 ]; then
+ printf "." "$@"
+ fi
+}
+
+verbose_done () {
+ if [ "$verbose" = 1 ]; then
+ echo " ${1:-done}."
+ fi
+}
+
+old=
+new=
+main=
+view=maybe
+cleanup=1
+verbose=0
+output=
+initial_dir=$PWD
+
+while test $# -ne 0; do
+ case "$1" in
+ "--help"|"-h")
+ usage
+ exit 0
+ ;;
+ "--main")
+ shift
+ main=$1
+ ;;
+ "--no-view")
+ view=0
+ ;;
+ "--view")
+ view=1
+ ;;
+ "--pdf-viewer")
+ shift
+ PDFVIEWER="$1"
+ ;;
+ "--no-cleanup")
+ cleanup=0
+ ;;
+ "-o"|"--output")
+ shift
+ output=$1
+ ;;
+ "--verbose"|"-v")
+ verbose=1
+ ;;
+ *)
+ if [ "$1" = "" ]; then
+ echo "Empty string not allowed as argument"
+ usage
+ exit 1
+ elif [ "$old" = "" ]; then
+ old=$1
+ elif [ "$new" = "" ]; then
+ new=$1
+ else
+ echo "Bad argument $1"
+ usage
+ exit 1
+ fi
+ ;;
+ esac
+ shift
+done
+
+if [ "$new" = "" ]; then
+ new=HEAD
+fi
+
+if [ "$old" = "" ]; then
+ echo "fatal: Please, provide at least one revision to diff with."
+ usage
+ exit 1
+fi
+
+verbose "Auto-detecting PDF viewer"
+for command in xdg-open evince okular xpdf acroread; do
+ if [ "$PDFVIEWER" = "" ]; then
+ if command -v "$command" >/dev/null 2>&1; then
+ PDFVIEWER="$command"
+ else
+ verbose_progress
+ fi
+ fi
+done
+verbose_done "$PDFVIEWER"
+
+case "$view" in
+ maybe|1)
+ if [ "$PDFVIEWER" = "" ]; then
+ echo "warning: could not find a PDF viewer on your system."
+ echo "warning: Please set \$PDFVIEWER or use --pdf-viewer CMD."
+ PDFVIEWER=false
+ fi
+ ;;
+esac
+
+if [ "$main" = "" ]; then
+ printf "%s" "No --main provided, trying to guess ... "
+ main=$(git grep -l '^[ \t]*\\documentclass')
+ # May return multiple results, but if so the result won't be a file.
+ if [ -r "$main" ]; then
+ echo "Using $main as the main file."
+ else
+ if [ "$main" = "" ]; then
+ echo "No candidate for main file."
+ else
+ echo "Multiple candidates for main file:"
+ printf "%s\n" "$main" | sed 's/^/\t/'
+ fi
+ die "Please, provide a main file with --main FILE.tex."
+ fi
+fi
+
+if [ ! -r "$main" ]; then
+ die "Cannot read $main."
+fi
+
+verbose "Creating temporary directories"
+
+git_prefix=$(git rev-parse --show-prefix)
+cd "$(git rev-parse --show-cdup)" || die "Can't cd back to repository root"
+git_dir="$(git rev-parse --git-dir)" || die "Not a git repository?"
+git_dir=$(cd "$git_dir"; pwd)
+
+main=$git_prefix/$main
+
+tmpdir=$initial_dir/git-latexdiff.$$
+mkdir "$tmpdir" || die "Cannot create temporary directory."
+
+cd "$tmpdir" || die "Cannot cd to $tmpdir"
+
+mkdir old new diff || die "Cannot create old, new and diff directories."
+
+verbose_done
+verbose "Checking out old and new version"
+
+cd old || die "Cannot cd to old/"
+git --git-dir="$git_dir" --work-tree=. checkout "$old" -- . || die "checkout failed for old/"
+verbose_progress
+cd ../new || die "Cannot cd to new/"
+git --git-dir="$git_dir" --work-tree=. checkout "$new" -- . || die "checkout failed for new/"
+verbose_progress
+cd ..
+
+verbose_done
+verbose "Running latexdiff --flatten old/$main new/$main > $main"
+
+latexdiff --flatten old/"$main" new/"$main" > diff.tex || die "latexdiff failed"
+
+mv -f diff.tex new/"$main"
+
+verbose_done
+
+mainbase=$(basename "$main" .tex)
+maindir=$(dirname "$main")
+
+verbose "Compiling result"
+
+compile_error=0
+cd new/"$maindir" || die "Can't cd to new/$maindir"
+if [ -f Makefile ]; then
+ make || compile_error=1
+else
+ pdflatex --interaction errorstopmode "$mainbase" || compile_error=1
+fi
+
+verbose_done
+
+pdffile="$mainbase".pdf
+if [ ! -r "$pdffile" ]; then
+ echo "No PDF file generated."
+ compile_error=1
+fi
+
+if [ ! -s "$pdffile" ]; then
+ echo "PDF file generated is empty."
+ compile_error=1
+fi
+
+if [ "$compile_error" = "1" ]; then
+ echo "Error during compilation. Please examine and cleanup if needed:"
+ echo "Directory: $tmpdir/new/$maindir/"
+ echo " File: $mainbase.tex"
+ # Don't clean up to let the user diagnose.
+ exit 1
+fi
+
+if [ "$output" != "" ]; then
+ abs_pdffile="$PWD/$pdffile"
+ (cd "$initial_dir" && cp "$abs_pdffile" "$output")
+ echo "Output written on $output"
+fi
+
+if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
+ "$PDFVIEWER" "$pdffile"
+fi
+
+if [ "$cleanup" = 1 ]; then
+ verbose "Cleaning-up result"
+ rm -fr "$tmpdir"
+ verbose_done
+fi
--
1.7.9.111.gf3fb0.dirty
^ permalink raw reply related
* Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git
From: Matthieu Moy @ 2012-02-16 8:34 UTC (permalink / raw)
To: Tim Haga; +Cc: git, gitster
In-Reply-To: <20120216003300.17228570@sirion>
Tim Haga <timhaga@ebene6.org> writes:
> While testing your script on my office machine i discovered that the
> following might be a problem:
>
>> +if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
>> + xpdf "$pdffile"
>> +fi
>
> Xpdf is not installed on all machines (e.g. it's not installed on my
> office machine), so maybe it would be a good idea to use a environment
> variable instead?
Right. I'm squashing this into the next version to allow configuration
(environment variable or --pdf-viewer) and sensible auto-detection:
diff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff
index 13aeb9a..85aafda 100755
--- a/contrib/latex/git-latexdiff
+++ b/contrib/latex/git-latexdiff
@@ -20,6 +20,8 @@ Options:
--no-view Don't display the resulting PDF file
--view View the resulting PDF file
(default if -o is not used)
+ --pdf-viewer CMD
+ Use CMD to view the PDF file (default: \$PDFVIEWER)
--no-cleanup Don't cleanup temp dir after running
-o FILE, --output FILE
Copy resulting PDF into FILE
@@ -46,7 +48,7 @@ verbose_progress () {
verbose_done () {
if [ "$verbose" = 1 ]; then
- echo " done."
+ echo " ${1:-done}."
fi
}
@@ -75,6 +77,10 @@ while test $# -ne 0; do
"--view")
view=1
;;
+ "--pdf-viewer")
+ shift
+ PDFVIEWER="$1"
+ ;;
"--no-cleanup")
cleanup=0
;;
@@ -114,6 +120,28 @@ if [ "$old" = "" ]; then
exit 1
fi
+verbose "Auto-detecting PDF viewer"
+for command in xdg-open evince okular xpdf acroread; do
+ if [ "$PDFVIEWER" = "" ]; then
+ if command -v "$command" >/dev/null 2>&1; then
+ PDFVIEWER="$command"
+ else
+ verbose_progress
+ fi
+ fi
+done
+verbose_done "$PDFVIEWER"
+
+case "$view" in
+ maybe|1)
+ if [ "$PDFVIEWER" = "" ]; then
+ echo "warning: could not find a PDF viewer on your system."
+ echo "warning: Please set \$PDFVIEWER or use --pdf-viewer CMD."
+ PDFVIEWER=false
+ fi
+ ;;
+esac
+
if [ "$main" = "" ]; then
printf "%s" "No --main provided, trying to guess ... "
main=$(git grep -l '^[ \t]*\\documentclass')
@@ -212,7 +240,7 @@ if [ "$output" != "" ]; then
fi
if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
- xpdf "$pdffile"
+ "$PDFVIEWER" "$pdffile"
fi
if [ "$cleanup" = 1 ]; then
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply related
* [PATCH 8/8] config: do not respect includes for single-file --list
From: Jeff King @ 2012-02-16 8:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20120216080102.GA11793@sigill.intra.peff.net>
The original include implementation tried not to impact
calls to "git config" that look at a single file. However,
since we called into git_config in a few places (e.g.,
--list), our respect_includes flag was not supported.
This patch teaches git_config_with_options a flag to
respect includes (instead of doing so by default), and
teaches git-config to use it.
Signed-off-by: Jeff King <peff@peff.net>
---
builtin/config.c | 7 ++++---
cache.h | 3 ++-
config.c | 14 ++++++++------
t/t1305-config-include.sh | 8 ++++++++
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index 8901dd9..d41a9bf 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -316,7 +316,7 @@ static void get_color(const char *def_color)
get_color_found = 0;
parsed_color[0] = '\0';
git_config_with_options(git_get_color_config, NULL,
- given_config_file);
+ given_config_file, respect_includes);
if (!get_color_found && def_color)
color_parse(def_color, "command line", parsed_color);
@@ -344,7 +344,7 @@ static int get_colorbool(int print)
get_colorbool_found = -1;
get_diff_color_found = -1;
git_config_with_options(git_get_colorbool_config, NULL,
- given_config_file);
+ given_config_file, respect_includes);
if (get_colorbool_found < 0) {
if (!strcmp(get_colorbool_slot, "color.diff"))
@@ -441,7 +441,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
if (actions == ACTION_LIST) {
check_argc(argc, 0, 0);
if (git_config_with_options(show_all_config, NULL,
- given_config_file) < 0) {
+ given_config_file,
+ respect_includes) < 0) {
if (given_config_file)
die_errno("unable to read config file '%s'",
given_config_file);
diff --git a/cache.h b/cache.h
index 411c60d..ff54d6f 100644
--- a/cache.h
+++ b/cache.h
@@ -1115,7 +1115,8 @@ extern int git_config_from_file(config_fn_t fn, const char *, void *);
extern void git_config_push_parameter(const char *text);
extern int git_config_from_parameters(config_fn_t fn, void *data);
extern int git_config(config_fn_t fn, void *);
-extern int git_config_with_options(config_fn_t fn, void *, const char *filename);
+extern int git_config_with_options(config_fn_t fn, void *,
+ const char *filename, int respect_includes);
extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
extern int git_parse_ulong(const char *, unsigned long *);
extern int git_config_int(const char *, const char *);
diff --git a/config.c b/config.c
index e1d6857..ad03908 100644
--- a/config.c
+++ b/config.c
@@ -976,16 +976,18 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
}
int git_config_with_options(config_fn_t fn, void *data,
- const char *filename)
+ const char *filename, int respect_includes)
{
char *repo_config = NULL;
int ret;
struct config_include_data inc = CONFIG_INCLUDE_INIT;
- inc.fn = fn;
- inc.data = data;
- fn = git_config_include;
- data = &inc;
+ if (respect_includes) {
+ inc.fn = fn;
+ inc.data = data;
+ fn = git_config_include;
+ data = &inc;
+ }
/*
* If we have a specific filename, use it. Otherwise, follow the
@@ -1003,7 +1005,7 @@ int git_config_with_options(config_fn_t fn, void *data,
int git_config(config_fn_t fn, void *data)
{
- return git_config_with_options(fn, data, NULL);
+ return git_config_with_options(fn, data, NULL, 1);
}
/*
diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index 0a27ec4..f3e03a0 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -59,6 +59,14 @@ test_expect_success 'single file lookup does not expand includes by default' '
test_cmp expect actual
'
+test_expect_success 'single file list does not expand includes by default' '
+ echo "[test]one = 1" >one &&
+ echo "[include]path = one" >.gitconfig &&
+ echo "include.path=one" >expect &&
+ git config -f .gitconfig --list >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'writing config file does not expand includes' '
echo "[test]one = 1" >one &&
echo "[include]path = one" >.gitconfig &&
--
1.7.9.1.4.g8ffed
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox