]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
10 years agotree-diff: rework diff_tree() to generate diffs for multiparent cases as well
Kirill Smelkov [Sun, 6 Apr 2014 21:46:26 +0000 (01:46 +0400)] 
tree-diff: rework diff_tree() to generate diffs for multiparent cases as well

Previously diff_tree(), which is now named ll_diff_tree_sha1(), was
generating diff_filepair(s) for two trees t1 and t2, and that was
usually used for a commit as t1=HEAD~, and t2=HEAD - i.e. to see changes
a commit introduces.

In Git, however, we have fundamentally built flexibility in that a
commit can have many parents - 1 for a plain commit, 2 for a simple merge,
but also more than 2 for merging several heads at once.

For merges there is a so called combine-diff, which shows diff, a merge
introduces by itself, omitting changes done by any parent. That works
through first finding paths, that are different to all parents, and then
showing generalized diff, with separate columns for +/- for each parent.
The code lives in combine-diff.c .

There is an impedance mismatch, however, in that a commit could
generally have any number of parents, and that while diffing trees, we
divide cases for 2-tree diffs and more-than-2-tree diffs. I mean there
is no special casing for multiple parents commits in e.g.
revision-walker .

That impedance mismatch *hurts* *performance* *badly* for generating
combined diffs - in "combine-diff: optimize combine_diff_path
sets intersection" I've already removed some slowness from it, but from
the timings provided there, it could be seen, that combined diffs still
cost more than an order of magnitude more cpu time, compared to diff for
usual commits, and that would only be an optimistic estimate, if we take
into account that for e.g. linux.git there is only one merge for several
dozens of plain commits.

That slowness comes from the fact that currently, while generating
combined diff, a lot of time is spent computing diff(commit,commit^2)
just to only then intersect that huge diff to almost small set of files
from diff(commit,commit^1).

That's because at present, to compute combine-diff, for first finding
paths, that "every parent touches", we use the following combine-diff
property/definition:

D(A,P1...Pn) = D(A,P1) ^ ... ^ D(A,Pn)      (w.r.t. paths)

where

D(A,P1...Pn) is combined diff between commit A, and parents Pi

and

D(A,Pi) is usual two-tree diff Pi..A

So if any of that D(A,Pi) is huge, tracting 1 n-parent combine-diff as n
1-parent diffs and intersecting results will be slow.

And usually, for linux.git and other topic-based workflows, that
D(A,P2) is huge, because, if merge-base of A and P2, is several dozens
of merges (from A, via first parent) below, that D(A,P2) will be diffing
sum of merges from several subsystems to 1 subsystem.

The solution is to avoid computing n 1-parent diffs, and to find
changed-to-all-parents paths via scanning A's and all Pi's trees
simultaneously, at each step comparing their entries, and based on that
comparison, populate paths result, and deduce we could *skip*
*recursing* into subdirectories, if at least for 1 parent, sha1 of that
dir tree is the same as in A. That would save us from doing significant
amount of needless work.

Such approach is very similar to what diff_tree() does, only there we
deal with scanning only 2 trees simultaneously, and for n+1 tree, the
logic is a bit more complex:

D(T,P1...Pn) calculation scheme
-------------------------------

D(T,P1...Pn) = D(T,P1) ^ ... ^ D(T,Pn) (regarding resulting paths set)

    D(T,Pj) - diff between T..Pj
    D(T,P1...Pn) - combined diff from T to parents P1,...,Pn

We start from all trees, which are sorted, and compare their entries in
lock-step:

     T     P1       Pn
     -     -        -
    |t|   |p1|     |pn|
    |-|   |--| ... |--|      imin = argmin(p1...pn)
    | |   |  |     |  |
    |-|   |--|     |--|
    |.|   |. |     |. |
     .     .        .
     .     .        .

at any time there could be 3 cases:

    1)  t < p[imin];
    2)  t > p[imin];
    3)  t = p[imin].

Schematic deduction of what every case means, and what to do, follows:

1)  t < p[imin]  ->  ∀j t ∉ Pj  ->  "+t" ∈ D(T,Pj)  ->  D += "+t";  t↓

2)  t > p[imin]

    2.1) ∃j: pj > p[imin]  ->  "-p[imin]" ∉ D(T,Pj)  ->  D += ø;  ∀ pi=p[imin]  pi↓
    2.2) ∀i  pi = p[imin]  ->  pi ∉ T  ->  "-pi" ∈ D(T,Pi)  ->  D += "-p[imin]";  ∀i pi↓

3)  t = p[imin]

    3.1) ∃j: pj > p[imin]  ->  "+t" ∈ D(T,Pj)  ->  only pi=p[imin] remains to investigate
    3.2) pi = p[imin]  ->  investigate δ(t,pi)
     |
     |
     v

    3.1+3.2) looking at δ(t,pi) ∀i: pi=p[imin] - if all != ø  ->

                      ⎧δ(t,pi)  - if pi=p[imin]
             ->  D += ⎨
                      ⎩"+t"     - if pi>p[imin]

    in any case t↓  ∀ pi=p[imin]  pi↓

~

For comparison, here is how diff_tree() works:

D(A,B) calculation scheme
-------------------------

    A     B
    -     -
   |a|   |b|    a < b   ->  a ∉ B   ->   D(A,B) +=  +a    a↓
   |-|   |-|    a > b   ->  b ∉ A   ->   D(A,B) +=  -b    b↓
   | |   | |    a = b   ->  investigate δ(a,b)            a↓ b↓
   |-|   |-|
   |.|   |.|
    .     .
    .     .

~~~~~~~~

This patch generalizes diff tree-walker to work with arbitrary number of
parents as described above - i.e. now there is a resulting tree t, and
some parents trees tp[i] i=[0..nparent). The generalization builds on
the fact that usual diff

D(A,B)

is by definition the same as combined diff

D(A,[B]),

so if we could rework the code for common case and make it be not slower
for nparent=1 case, usual diff(t1,t2) generation will not be slower, and
multiparent diff tree-walker would greatly benefit generating
combine-diff.

What we do is as follows:

1) diff tree-walker ll_diff_tree_sha1() is internally reworked to be
   a paths generator (new name diff_tree_paths()), with each generated path
   being `struct combine_diff_path` with info for path, new sha1,mode and for
   every parent which sha1,mode it was in it.

2) From that info, we can still generate usual diff queue with
   struct diff_filepairs, via "exporting" generated
   combine_diff_path, if we know we run for nparent=1 case.
   (see emit_diff() which is now named emit_diff_first_parent_only())

3) In order for diff_can_quit_early(), which checks

       DIFF_OPT_TST(opt, HAS_CHANGES))

   to work, that exporting have to be happening not in bulk, but
   incrementally, one diff path at a time.

   For such consumers, there is a new callback in diff_options
   introduced:

       ->pathchange(opt, struct combine_diff_path *)

   which, if set to !NULL, is called for every generated path.

   (see new compat ll_diff_tree_sha1() wrapper around new paths
    generator for setup)

4) The paths generation itself, is reworked from previous
   ll_diff_tree_sha1() code according to "D(A,P1...Pn) calculation
   scheme" provided above:

   On the start we allocate [nparent] arrays in place what was
   earlier just for one parent tree.

   then we just generalize loops, and comparison according to the
   algorithm.

Some notes(*):

1) alloca(), for small arrays, is used for "runs not slower for
   nparent=1 case than before" goal - if we change it to xmalloc()/free()
   the timings get ~1% worse. For alloca() we use just-introduced
   xalloca/xalloca_free compatibility wrappers, so it should not be a
   portability problem.

2) For every parent tree, we need to keep a tag, whether entry from that
   parent equals to entry from minimal parent. For performance reasons I'm
   keeping that tag in entry's mode field in unused bit - see S_IFXMIN_NEQ.
   Not doing so, we'd need to alloca another [nparent] array, which hurts
   performance.

3) For emitted paths, memory could be reused, if we know the path was
   processed via callback and will not be needed later. We use efficient
   hand-made realloc-style path_appendnew(), that saves us from ~1-1.5%
   of potential additional slowdown.

4) goto(s) are used in several places, as the code executes a little bit
   faster with lowered register pressure.

Also

- we should now check for FIND_COPIES_HARDER not only when two entries
  names are the same, and their hashes are equal, but also for a case,
  when a path was removed from some of all parents having it.

  The reason is, if we don't, that path won't be emitted at all (see
  "a > xi" case), and we'll just skip it, and FIND_COPIES_HARDER wants
  all paths - with diff or without - to be emitted, to be later analyzed
  for being copies sources.

  The new check is only necessary for nparent >1, as for nparent=1 case
  xmin_eqtotal always =1 =nparent, and a path is always added to diff as
  removal.

~~~~~~~~

Timings for

    # without -c, i.e. testing only nparent=1 case
    `git log --raw --no-abbrev --no-renames`

before and after the patch are as follows:

                navy.git        linux.git v3.10..v3.11

    before      0.611s          1.889s
    after       0.619s          1.907s
    slowdown    1.3%            0.9%

This timings show we did no harm to usual diff(tree1,tree2) generation.
From the table we can see that we actually did ~1% slowdown, but I think
I've "earned" that 1% in the previous patch ("tree-diff: reuse base
str(buf) memory on sub-tree recursion", HEAD~~) so for nparent=1 case,
net timings stays approximately the same.

The output also stayed the same.

(*) If we revert 1)-4) to more usual techniques, for nparent=1 case,
    we'll get ~2-2.5% of additional slowdown, which I've tried to avoid, as
   "do no harm for nparent=1 case" rule.

For linux.git, combined diff will run an order of magnitude faster and
appropriate timings will be provided in the next commit, as we'll be
taking advantage of the new diff tree-walker for combined-diff
generation there.

P.S. and combined diff is not some exotic/for-play-only stuff - for
example for a program I write to represent Git archives as readonly
filesystem, there is initial scan with

    `git log --reverse --raw --no-abbrev --no-renames -c`

to extract log of what was created/changed when, as a result building a
map

    {}  sha1    ->  in which commit (and date) a content was added

that `-c` means also show combined diff for merges, and without them, if
a merge is non-trivial (merges changes from two parents with both having
separate changes to a file), or an evil one, the map will not be full,
i.e. some valid sha1 would be absent from it.

That case was my initial motivation for combined diffs speedup.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoPortable alloca for Git
Kirill Smelkov [Thu, 27 Mar 2014 14:22:50 +0000 (18:22 +0400)] 
Portable alloca for Git

In the next patch we'll have to use alloca() for performance reasons,
but since alloca is non-standardized and is not portable, let's have a
trick with compatibility wrappers:

1. at configure time, determine, do we have working alloca() through
   alloca.h, and define

    #define HAVE_ALLOCA_H

   if yes.

2. in code

    #ifdef HAVE_ALLOCA_H
    # include <alloca.h>
    # define xalloca(size)      (alloca(size))
    # define xalloca_free(p)    do {} while(0)
    #else
    # define xalloca(size)      (xmalloc(size))
    # define xalloca_free(p)    (free(p))
    #endif

   and use it like

   func() {
       p = xalloca(size);
       ...

       xalloca_free(p);
   }

This way, for systems, where alloca is available, we'll have optimal
on-stack allocations with fast executions. On the other hand, on
systems, where alloca is not available, this gracefully fallbacks to
xmalloc/free.

Both autoconf and config.mak.uname configurations were updated. For
autoconf, we are not bothering considering cases, when no alloca.h is
available, but alloca() works some other way - its simply alloca.h is
available and works or not, everything else is deep legacy.

For config.mak.uname, I've tried to make my almost-sure guess for where
alloca() is available, but since I only have access to Linux it is the
only change I can be sure about myself, with relevant to other changed
systems people Cc'ed.

NOTE

SunOS and Windows had explicit -DHAVE_ALLOCA_H in their configurations.
I've changed that to now-common HAVE_ALLOCA_H=YesPlease which should be
correct.

Cc: Brandon Casey <drafnel@gmail.com>
Cc: Marius Storm-Olsen <mstormo@gmail.com>
Cc: Johannes Sixt <j6t@kdbg.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Gerrit Pape <pape@smarden.org>
Cc: Petr Salinger <Petr.Salinger@seznam.cz>
Cc: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Thomas Schwinge <thomas@codesourcery.com> (GNU Hurd changes)
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: reuse base str(buf) memory on sub-tree recursion
Kirill Smelkov [Thu, 27 Mar 2014 14:22:07 +0000 (18:22 +0400)] 
tree-diff: reuse base str(buf) memory on sub-tree recursion

Instead of allocating it all the time for every subtree in
ll_diff_tree_sha1, let's allocate it once in diff_tree_sha1, and then
all callee just use it in stacking style, without memory allocations.

This should be faster, and for me this change gives the following
slight speedups for

    git log --raw --no-abbrev --no-renames --format='%H'

                navy.git    linux.git v3.10..v3.11

    before      0.618s      1.903s
    after       0.611s      1.889s
    speedup     1.1%        0.7%

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: no need to call "full" diff_tree_sha1 from show_path()
Kirill Smelkov [Thu, 27 Mar 2014 14:21:29 +0000 (18:21 +0400)] 
tree-diff: no need to call "full" diff_tree_sha1 from show_path()

As described in previous commit, when recursing into sub-trees, we can
use lower-level tree walker, since its interface is now sha1 based.

The change is ok, because diff_tree_sha1() only invokes
ll_diff_tree_sha1(), and also, if base is empty, try_to_follow_renames().
But base is not empty here, as we have added a path and '/' before
recursing.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: rework diff_tree interface to be sha1 based
Kirill Smelkov [Thu, 27 Mar 2014 14:24:38 +0000 (18:24 +0400)] 
tree-diff: rework diff_tree interface to be sha1 based

In the next commit this will allow to reduce intermediate calls, when
recursing into subtrees - at that stage we know only subtree sha1, and
it is natural for tree walker to start from that phase. For now we do

    diff_tree
        show_path
            diff_tree_sha1
                diff_tree
                    ...

and the change will allow to reduce it to

    diff_tree
        show_path
            diff_tree

Also, it will allow to omit allocating strbuf for each subtree, and just
reuse the common strbuf via playing with its len.

The above-mentioned improvements go in the next 2 patches.

The downside is that try_to_follow_renames(), if active, we cause
re-reading of 2 initial trees, which was negligible based on my timings,
and which is outweighed cogently by the upsides.

NOTE To keep with the current interface and semantics, I needed to
rename the function from diff_tree() to diff_tree_sha1(). As
diff_tree_sha1() was already used, and the function we are talking here
is its more low-level helper, let's use convention for prefixing
such helpers with "ll_". So the final renaming is

    diff_tree() -> ll_diff_tree_sha1()

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: diff_tree() should now be static
Kirill Smelkov [Mon, 24 Feb 2014 16:21:45 +0000 (20:21 +0400)] 
tree-diff: diff_tree() should now be static

We reworked all its users to use the functionality through
diff_tree_sha1 variant in recent patches (see "tree-diff: allow
diff_tree_sha1 to accept NULL sha1" and what comes next).

diff_tree() is now not used outside tree-diff.c - make it static.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: remove special-case diff-emitting code for empty-tree cases
Kirill Smelkov [Mon, 24 Feb 2014 16:21:44 +0000 (20:21 +0400)] 
tree-diff: remove special-case diff-emitting code for empty-tree cases

While walking trees, we iterate their entries from lowest to highest in
sort order, so empty tree means all entries were already went over.

If we artificially assign +infinity value to such tree "entry", it will
go after all usual entries, and through the usual driver loop we will be
taking the same actions, which were hand-coded for special cases, i.e.

    t1 empty, t2 non-empty
        pathcmp(+∞, t2) -> +1
        show_path(/*t1=*/NULL, t2);     /* = t1 > t2 case in main loop */

    t1 non-empty, t2-empty
        pathcmp(t1, +∞) -> -1
        show_path(t1, /*t2=*/NULL);     /* = t1 < t2 case in main loop */

In other words when we have t1 and t2, we return a sign that tells the
caller to indicate the "earlier" one to be emitted, and by returning the
sign that causes the non-empty side to be emitted, we will automatically
cause the entries from the remaining side to be emitted, without
attempting to touch the empty side at all.  We can teach
tree_entry_pathcmp() to pretend that an empty tree has an element that
sorts after anything else to achieve this.

Right now we never go to when compared tree descriptors are both
infinity, as this condition is checked in the loop beginning as
finishing criteria, but will do so in the future, when there will be
several parents iterated simultaneously, and some pair of them would run
to the end.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: simplify tree_entry_pathcmp
Kirill Smelkov [Mon, 24 Feb 2014 16:21:43 +0000 (20:21 +0400)] 
tree-diff: simplify tree_entry_pathcmp

Since an earlier "Finally switch over tree descriptors to contain a
pre-parsed entry", we can safely access all tree_desc->entry fields
directly instead of first "extracting" them through
tree_entry_extract.

Use it. The code generated stays the same - only it now visually looks
cleaner.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: show_path prototype is not needed anymore
Kirill Smelkov [Mon, 24 Feb 2014 16:21:42 +0000 (20:21 +0400)] 
tree-diff: show_path prototype is not needed anymore

We moved all action-taking code below show_path() in recent HEAD~~
(tree-diff: move all action-taking code out of compare_tree_entry).

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: rename compare_tree_entry -> tree_entry_pathcmp
Kirill Smelkov [Mon, 24 Feb 2014 16:21:41 +0000 (20:21 +0400)] 
tree-diff: rename compare_tree_entry -> tree_entry_pathcmp

Since previous commit, this function does not compare entry hashes, and
mode are compared fully outside of it. So what it does is compare entry
names and DIR bit in modes. Reflect this in its name.

Add documentation stating the semantics, and move the note about
files/dirs comparison to it.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: move all action-taking code out of compare_tree_entry()
Kirill Smelkov [Mon, 24 Feb 2014 16:21:40 +0000 (20:21 +0400)] 
tree-diff: move all action-taking code out of compare_tree_entry()

- let it do only comparison.

This way the code is cleaner and more structured - cmp function only
compares, and the driver takes action based on comparison result.

There should be no change in performance, as effectively, we just move
if series from on place into another, and merge it to was-already-there
same switch/if, so the result is maybe a little bit faster.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: don't assume compare_tree_entry() returns -1,0,1
Kirill Smelkov [Mon, 24 Feb 2014 16:21:39 +0000 (20:21 +0400)] 
tree-diff: don't assume compare_tree_entry() returns -1,0,1

It does, but we'll be reworking it in the next patch after it won't, and
besides it is better to stick to standard
strcmp/memcmp/base_name_compare/etc... convention, where comparison
function returns <0, =0, >0

Regarding performance, comparing for <0, =0, >0 should be a little bit
faster, than switch, because it is just 1 test-without-immediate
instruction and then up to 3 conditional branches, and in switch you
have up to 3 tests with immediate and up to 3 conditional branches.

No worry, that update_tree_entry(t2) is duplicated for =0 and >0 - it
will be good after we'll be adding support for multiparent walker and
will stay that way.

=0 case goes first, because it happens more often in real diffs - i.e.
paths are the same.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: consolidate code for emitting diffs and recursion in one place
Kirill Smelkov [Mon, 24 Feb 2014 16:21:38 +0000 (20:21 +0400)] 
tree-diff: consolidate code for emitting diffs and recursion in one place

Currently both compare_tree_entry() and show_entry() invoke opt diff
callbacks (opt->add_remove() and opt->change()), and also they both have
code which decides whether to recurse into sub-tree, and whether to emit
a tree as separate entry if DIFF_OPT_TREE_IN_RECURSIVE is set.

I.e. we have code duplication and logic scattered on two places.

Let's consolidate it - all diff emiting code and recurion logic moves
to show_entry, which is now named as show_path, because it shows diff
for a path, based on up to two tree entries, with actual diff emitting
code being kept in new helper emit_diff() for clarity.

What we have as the result, is that compare_tree_entry is now free from
code with logic for diff generation, and also performance is not
affected as timings for

    `git log --raw --no-abbrev --no-renames`

for navy.git and `linux.git v3.10..v3.11`, just like in previous patch,
stay the same.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: show_tree() is not needed
Kirill Smelkov [Mon, 24 Feb 2014 16:21:37 +0000 (20:21 +0400)] 
tree-diff: show_tree() is not needed

We don't need special code for showing added/removed subtree, because we
can do the same via diff_tree_sha1, just passing NULL for absent tree.

And compared to show_tree(), which was calling show_entry() for every
tree entry, that would lead to the same show_entry() callings:

    show_tree(t):
        for e in t.entries:
            show_entry(e)

    diff_tree_sha1(NULL, new):  /* the same applies to (old, NULL) */
        diff_tree(t1=NULL, t2)
            ...
            if (!t1->size)
                show_entry(t2)
            ...

and possible overhead is negligible, since after the patch, timing for

    `git log --raw --no-abbrev --no-renames`

for navy.git and `linux.git v3.10..v3.11` is practically the same.

So let's say goodbye to show_tree() - it removes some code, but also,
and what is important, consolidates more code for showing/recursing into
trees into one place.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: no need to pass match to skip_uninteresting()
Kirill Smelkov [Mon, 3 Feb 2014 12:47:18 +0000 (16:47 +0400)] 
tree-diff: no need to pass match to skip_uninteresting()

It is neither used there as input, nor the output written through it, is
used outside.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: no need to manually verify that there is no mode change for a path
Kirill Smelkov [Mon, 3 Feb 2014 12:47:17 +0000 (16:47 +0400)] 
tree-diff: no need to manually verify that there is no mode change for a path

Because if there is, such two tree entries would never be compared as
equal - the code in base_name_compare() explicitly compares modes, if
there is a change for dir bit, even for equal paths, entries would
compare as different.

The code I'm removing here is from 2005 April 262e82b4 (Fix diff-tree
recursion), which pre-dates base_name_compare() introduction in 958ba6c9
(Introduce "base_name_compare()" helper function) by a month.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocombine-diff: move changed-paths scanning logic into its own function
Kirill Smelkov [Mon, 3 Feb 2014 12:47:20 +0000 (16:47 +0400)] 
combine-diff: move changed-paths scanning logic into its own function

Move code for finding paths for which diff(commit,parent_i) is not-empty
for all parents to separate function - at present we have generic (and
slow) code for this job, which translates 1 n-parent problem to n
1-parent problems and then intersect results, and will be adding another
limited, but faster, paths scanning implementation in the next patch.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocombine-diff: move show_log_first logic/action out of paths scanning
Kirill Smelkov [Mon, 3 Feb 2014 12:47:19 +0000 (16:47 +0400)] 
combine-diff: move show_log_first logic/action out of paths scanning

Judging from sample outputs and tests nothing changes in diff -c output,
and this change will help later patches, when we'll be refactoring paths
scanning into its own function with several variants - the
show_log_first logic / code will stay common to all of them.

NOTE: only now we have to take care to explicitly not show anything if
    parents array is empty, as in fact there are some clients in Git code,
    which calls diff_tree_combined() in such a way.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotests: add checking that combine-diff emits only correct paths
Kirill Smelkov [Mon, 3 Feb 2014 09:08:49 +0000 (13:08 +0400)] 
tests: add checking that combine-diff emits only correct paths

where "correct paths" stands for paths that are different to all
parents.

Up until now, we were testing combined diff only on one file, or on
several files which were all different (t4038-diff-combined.sh).

As recent thinko in "simplify intersect_paths() further" showed, and
also, since we are going to rework code for finding paths different to
all parents, lets write at least basic tests.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocombine-diff: simplify intersect_paths() further
Junio C Hamano [Tue, 28 Jan 2014 21:55:59 +0000 (13:55 -0800)] 
combine-diff: simplify intersect_paths() further

Linus once said:

    I actually wish more people understood the really core low-level
    kind of coding. Not big, complex stuff like the lockless name
    lookup, but simply good use of pointers-to-pointers etc. For
    example, I've seen too many people who delete a singly-linked
    list entry by keeping track of the "prev" entry, and then to
    delete the entry, doing something like

if (prev)
    prev->next = entry->next;
else
    list_head = entry->next;

    and whenever I see code like that, I just go "This person
    doesn't understand pointers". And it's sadly quite common.

    People who understand pointers just use a "pointer to the entry
    pointer", and initialize that with the address of the
    list_head. And then as they traverse the list, they can remove
    the entry without using any conditionals, by just doing a "*pp =
    entry->next".

Applying that simplification lets us lose 7 lines from this function
even while adding 2 lines of comment.

I was tempted to squash this into the original commit, but because
the benchmarking described in the commit log is without this
simplification, I decided to keep it a separate follow-up patch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocombine-diff: combine_diff_path.len is not needed anymore
Kirill Smelkov [Mon, 20 Jan 2014 16:20:41 +0000 (20:20 +0400)] 
combine-diff: combine_diff_path.len is not needed anymore

The field was used in order to speed-up name comparison and also to
mark removed paths by setting it to 0.

Because the updated code does significantly less strcmp and also
just removes paths from the list and free right after we know a path
will not be needed, it is not needed anymore.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocombine-diff: optimize combine_diff_path sets intersection
Kirill Smelkov [Mon, 20 Jan 2014 16:20:40 +0000 (20:20 +0400)] 
combine-diff: optimize combine_diff_path sets intersection

When generating combined diff, for each commit, we intersect diff
paths from diff(parent_0,commit) to diff(parent_i,commit) comparing
all paths pairs, i.e. doing it the quadratic way. That is correct,
but could be optimized.

Paths come from trees in sorted (= tree) order, and so does diff_tree()
emits resulting paths in that order too. Now if we look at diffcore
transformations, all of them, except diffcore_order, preserve resulting
path ordering:

    - skip_stat_unmatch, grep, pickaxe, filter
                            -- just skip elements -> order stays preserved

    - break                 -- just breaks diff for a path, adding path
                               dup after the path -> order stays preserved

    - detect rename/copy    -- resulting paths are emitted sorted
                               (verified empirically)

So only diffcore_order changes diff paths ordering.

But diffcore_order meaning affects only presentation - i.e. only how to
show the diff, so we could do all the internal computations without
paths reordering, and order only resultant paths set. This is faster,
since, if we know two paths sets are all ordered, their intersection
could be done in linear time.

This patch does just that.

Timings for `git log --raw --no-abbrev --no-renames` without `-c` ("git log")
and with `-c` ("git log -c") before and after the patch are as follows:

                linux.git v3.10..v3.11

            log     log -c

    before  1.9s    20.4s
    after   1.9s    16.6s

                navy.git    (private repo)

            log     log -c

    before  0.83s   15.6s
    after   0.83s    2.1s

P.S.

I think linux.git case is sped up not so much as the second one, since
in navy.git, there are more exotic (subtree, etc) merges.

P.P.S.

My tracing showed that the rest of the time (16.6s vs 1.9s) is usually
spent in computing huge diffs from commit to second parent. Will try to
deal with it, if I'll have time.

P.P.P.S.

For combine_diff_path, ->len is not needed anymore - will remove it in
the next noisy cleanup path, to maintain good signal/noise ratio here.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agodiff test: add tests for combine-diff with orderfile
Kirill Smelkov [Mon, 20 Jan 2014 16:20:39 +0000 (20:20 +0400)] 
diff test: add tests for combine-diff with orderfile

In the next patch combine-diff will have special code-path for taking
orderfile into account. Prepare for making changes by introducing
coverage tests for that case.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agodiffcore-order: export generic ordering interface
Kirill Smelkov [Mon, 20 Jan 2014 16:20:38 +0000 (20:20 +0400)] 
diffcore-order: export generic ordering interface

diffcore_order() interface only accepts a queue of `struct
diff_filepair`.

In the next patches, we'll want to order `struct combine_diff_path`
by path, so let's first rework diffcore-order to also provide
generic low-level interface for ordering arbitrary objects, provided
they have path accessors.

The new interface is:

    - `struct obj_order`    for describing objects to ordering routine, and
    - order_objects()       for actually doing the ordering work.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-walk: finally switch over tree descriptors to contain a pre-parsed entry
Kirill Smelkov [Thu, 6 Feb 2014 11:36:31 +0000 (15:36 +0400)] 
tree-walk: finally switch over tree descriptors to contain a pre-parsed entry

This continues 4651ece8 (Switch over tree descriptors to contain a
pre-parsed entry) and moves the only rest computational part

    mode = canon_mode(mode)

from tree_entry_extract() to tree entry decode phase - to
decode_tree_entry().

The reason to do it, is that canon_mode() is at least 2 conditional
jumps for regular files, and that could be noticeable should canon_mode()
be invoked several times.

That does not matter for current Git codebase, where typical tree
traversal is

    while (t->size) {
        sha1 = tree_entry_extract(t, &path, &mode);
        ...
        update_tree_entry(t);
    }

i.e. we do t -> sha1,path.mode "extraction" only once per entry. In such
cases, it does not matter performance-wise, where that mode
canonicalization is done - either once in tree_entry_extract(), or once
in decode_tree_entry() called by update_tree_entry() - it is
approximately the same.

But for future code, which could need to work with several tree_desc's
in parallel, it could be handy to operate on tree_desc descriptors, and
do "extracts" only when needed, or at all, access only relevant part of
it through structure fields directly.

And for such situations, having canon_mode() be done once in decode
phase is better - we won't need to pay the performance price of 2 extra
conditional jumps on every t->mode access.

So let's move mode canonicalization to decode_tree_entry(). That was the
final bit. Now after tree entry is decoded, it is fully ready and could
be accessed either directly via field, or through tree_entry_extract()
which this time got really "totally trivial".

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorevision: convert to using diff_tree_sha1()
Kirill Smelkov [Wed, 5 Feb 2014 16:57:12 +0000 (20:57 +0400)] 
revision: convert to using diff_tree_sha1()

Since diff_tree_sha1() can now accept empty trees via NULL sha1, we
could just call it without manually reading trees into tree_desc and
duplicating code.

Besides, that

if (!tree)
return 0;

looked suspect - we were saying an invalid tree != empty tree, but maybe it is
better to just say the tree is invalid here, which is what diff_tree_sha1()
does for such case.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoline-log: convert to using diff_tree_sha1()
Kirill Smelkov [Wed, 5 Feb 2014 16:57:11 +0000 (20:57 +0400)] 
line-log: convert to using diff_tree_sha1()

Since diff_tree_sha1() can now accept empty trees via NULL sha1, we
could just call it without manually reading trees into tree_desc and
duplicating code.

Cc: Thomas Rast <tr@thomasrast.ch>
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: convert diff_root_tree_sha1() to just call diff_tree_sha1 with old=NULL
Kirill Smelkov [Wed, 5 Feb 2014 16:57:10 +0000 (20:57 +0400)] 
tree-diff: convert diff_root_tree_sha1() to just call diff_tree_sha1 with old=NULL

Now since diff_tree_sha1 understands NULL for both old and new, we could
indicate an empty tree for root commit by providing just NULL for old
sha1.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-diff: allow diff_tree_sha1 to accept NULL sha1
Kirill Smelkov [Wed, 5 Feb 2014 16:57:09 +0000 (20:57 +0400)] 
tree-diff: allow diff_tree_sha1 to accept NULL sha1

which would mean that corresponding tree - old or new - is empty.

As followup patches will show, that functionality was already needed in
several places of Git codebase, but there, we were preparing empty
tree_desc objects by hand, with some code duplication.

For handling sha1 = NULL case, let's reuse fill_tree_descriptor() which
returns just empty tree_desc in that case.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoGit 1.9-rc2 v1.9-rc2
Junio C Hamano [Fri, 31 Jan 2014 22:16:06 +0000 (14:16 -0800)] 
Git 1.9-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoMerge git://github.com/git-l10n/git-po
Junio C Hamano [Fri, 31 Jan 2014 18:52:29 +0000 (10:52 -0800)] 
Merge git://github.com/git-l10n/git-po

* 'master' of git://github.com/git-l10n/git-po:
  l10n: Bulgarian translation of git (222t21f1967u)
  po/TEAMS: Added Bulgarian team
  l10n: remove 2 blank translations on Danish, Dutch
  l10n: zh_CN.po: translate 27 messages (2210t0f0u)
  l10n: Update Swedish translation (2210t0f0u)
  [fr] update french translation 2210/2210
  l10n: vi.po (2210t): Updated git-core translation
  l10n: git.pot: v1.9 round 1 (27 new, 11 removed)

10 years agoMerge branch 'jn/pager-lv-default-env'
Junio C Hamano [Fri, 31 Jan 2014 18:51:57 +0000 (10:51 -0800)] 
Merge branch 'jn/pager-lv-default-env'

A finishing touch to its test.

* jn/pager-lv-default-env:
  pager test: make fake pager consume all its input

10 years agopager test: make fake pager consume all its input
Jonathan Nieder [Thu, 30 Jan 2014 16:42:32 +0000 (08:42 -0800)] 
pager test: make fake pager consume all its input

Otherwise there is a race: if 'git log' finishes writing before the
pager terminates and closes the pipe, all is well, and if the pager
finishes quickly enough then 'git log' terminates with SIGPIPE.

 died of signal 13 at /build/buildd/git-1.9~rc1/t/test-terminal.perl line 33.
 not ok 6 - LESS and LV envvars are set for pagination

Noticed on Ubuntu PPA builders, where the race was lost about half the
time.  Compare v1.7.0.2~6^2 (tests: Fix race condition in t7006-pager,
2010-02-22).

Reported-by: Anders Kaseorg <andersk@MIT.EDU>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agol10n: Bulgarian translation of git (222t21f1967u)
Alexander Shopov [Mon, 20 Jan 2014 19:39:30 +0000 (21:39 +0200)] 
l10n: Bulgarian translation of git (222t21f1967u)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
10 years agopo/TEAMS: Added Bulgarian team
Alexander Shopov [Tue, 28 Jan 2014 17:14:08 +0000 (19:14 +0200)] 
po/TEAMS: Added Bulgarian team

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
10 years agoGit 1.9-rc1 v1.9-rc1
Junio C Hamano [Mon, 27 Jan 2014 19:01:35 +0000 (11:01 -0800)] 
Git 1.9-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoMerge branch 'as/tree-walk-fix-aggressive-short-cut'
Junio C Hamano [Mon, 27 Jan 2014 18:48:32 +0000 (10:48 -0800)] 
Merge branch 'as/tree-walk-fix-aggressive-short-cut'

* as/tree-walk-fix-aggressive-short-cut:
  tree_entry_interesting: match against all pathspecs

10 years agoMerge branch 'ta/doc-http-protocol-in-html'
Junio C Hamano [Mon, 27 Jan 2014 18:45:59 +0000 (10:45 -0800)] 
Merge branch 'ta/doc-http-protocol-in-html'

* ta/doc-http-protocol-in-html:
  http-protocol.txt: don't use uppercase for variable names in "The Negotiation Algorithm"
  Documentation: make it easier to maintain enumerated documents
  create HTML for http-protocol.txt

10 years agoMerge branch 'mh/doc-wo-names'
Junio C Hamano [Mon, 27 Jan 2014 18:45:56 +0000 (10:45 -0800)] 
Merge branch 'mh/doc-wo-names'

* mh/doc-wo-names:
  doc: remote author/documentation sections from more pages

10 years agoMerge branch 'jk/revision-o-is-in-libgit-a'
Junio C Hamano [Mon, 27 Jan 2014 18:45:52 +0000 (10:45 -0800)] 
Merge branch 'jk/revision-o-is-in-libgit-a'

* jk/revision-o-is-in-libgit-a:
  Makefile: remove redundant object in git-http{fetch,push}

10 years agoMerge branch 'sb/repack-in-c'
Junio C Hamano [Mon, 27 Jan 2014 18:45:49 +0000 (10:45 -0800)] 
Merge branch 'sb/repack-in-c'

"git repack --max-pack-size=8g" stopped being parsed correctly when
the command was reimplemented in C.

* sb/repack-in-c:
  repack: propagate pack-objects options as strings
  repack: make parsed string options const-correct
  repack: fix typo in max-pack-size option

10 years agoMerge branch 'jk/test-fixes'
Junio C Hamano [Mon, 27 Jan 2014 18:45:46 +0000 (10:45 -0800)] 
Merge branch 'jk/test-fixes'

* jk/test-fixes:
  t7700: do not use "touch" unnecessarily
  t7501: fix "empty commit" test with NO_PERL

10 years agoMerge branch 'nd/negative-pathspec'
Junio C Hamano [Mon, 27 Jan 2014 18:45:43 +0000 (10:45 -0800)] 
Merge branch 'nd/negative-pathspec'

* nd/negative-pathspec:
  tree-walk.c: ignore trailing slash on submodule in tree_entry_interesting()

10 years agoMerge branch 'pw/git-p4'
Junio C Hamano [Mon, 27 Jan 2014 18:45:41 +0000 (10:45 -0800)] 
Merge branch 'pw/git-p4'

Various "git p4" updates.

* pw/git-p4:
  git p4 doc: use two-line style for options with multiple spellings
  git p4 test: examine behavior with locked (+l) files
  git p4: fix an error message when "p4 where" fails
  git p4: handle files with wildcards when doing RCS scrubbing
  git p4 test: do not pollute /tmp
  git p4 test: run as user "author"
  git p4 test: is_cli_file_writeable succeeds
  git p4 test: explicitly check p4 wildcard delete
  git p4: work around p4 bug that causes empty symlinks
  git p4 test: ensure p4 symlink parsing works
  git p4 test: wildcards are supported

10 years agoMerge branch 'ss/safe-create-leading-dir-with-slash'
Junio C Hamano [Mon, 27 Jan 2014 18:45:37 +0000 (10:45 -0800)] 
Merge branch 'ss/safe-create-leading-dir-with-slash'

"git clone $origin foo\bar\baz" on Windows failed to create the
leading directories (i.e. a moral-equivalent of "mkdir -p").

* ss/safe-create-leading-dir-with-slash:
  safe_create_leading_directories(): on Windows, \ can separate path components

10 years agoMerge branch 'mh/safe-create-leading-directories'
Junio C Hamano [Mon, 27 Jan 2014 18:45:33 +0000 (10:45 -0800)] 
Merge branch 'mh/safe-create-leading-directories'

Code clean-up and protection against concurrent write access to the
ref namespace.

* mh/safe-create-leading-directories:
  rename_tmp_log(): on SCLD_VANISHED, retry
  rename_tmp_log(): limit the number of remote_empty_directories() attempts
  rename_tmp_log(): handle a possible mkdir/rmdir race
  rename_ref(): extract function rename_tmp_log()
  remove_dir_recurse(): handle disappearing files and directories
  remove_dir_recurse(): tighten condition for removing unreadable dir
  lock_ref_sha1_basic(): if locking fails with ENOENT, retry
  lock_ref_sha1_basic(): on SCLD_VANISHED, retry
  safe_create_leading_directories(): add new error value SCLD_VANISHED
  cmd_init_db(): when creating directories, handle errors conservatively
  safe_create_leading_directories(): introduce enum for return values
  safe_create_leading_directories(): always restore slash at end of loop
  safe_create_leading_directories(): split on first of multiple slashes
  safe_create_leading_directories(): rename local variable
  safe_create_leading_directories(): add explicit "slash" pointer
  safe_create_leading_directories(): reduce scope of local variable
  safe_create_leading_directories(): fix format of "if" chaining

10 years agoMerge branch 'tr/nth-previous-is-a-commit'
Junio C Hamano [Mon, 27 Jan 2014 18:45:30 +0000 (10:45 -0800)] 
Merge branch 'tr/nth-previous-is-a-commit'

* tr/nth-previous-is-a-commit:
  Documentation: @{-N} can refer to a commit

10 years agoMerge branch 'tr/gitk-doc-range-trace'
Junio C Hamano [Mon, 27 Jan 2014 18:45:23 +0000 (10:45 -0800)] 
Merge branch 'tr/gitk-doc-range-trace'

* tr/gitk-doc-range-trace:
  Documentation/gitk: document -L option

10 years agoMerge branch 'jk/mark-edges-uninteresting'
Junio C Hamano [Mon, 27 Jan 2014 18:45:08 +0000 (10:45 -0800)] 
Merge branch 'jk/mark-edges-uninteresting'

Fix performance regression in v1.8.4.x and later.

* jk/mark-edges-uninteresting:
  list-objects: only look at cmdline trees with edge_hint
  t/perf: time rev-list with UNINTERESTING commits

10 years agoMerge branch 'jk/diff-filespec-cleanup'
Junio C Hamano [Mon, 27 Jan 2014 18:45:02 +0000 (10:45 -0800)] 
Merge branch 'jk/diff-filespec-cleanup'

* jk/diff-filespec-cleanup:
  diff_filespec: use only 2 bits for is_binary flag
  diff_filespec: reorder is_binary field
  diff_filespec: drop xfrm_flags field
  diff_filespec: drop funcname_pattern_ident field
  diff_filespec: reorder dirty_submodule macro definitions

10 years agoMerge branch 'ef/mingw-write'
Junio C Hamano [Mon, 27 Jan 2014 18:44:59 +0000 (10:44 -0800)] 
Merge branch 'ef/mingw-write'

* ef/mingw-write:
  mingw: remove mingw_write
  prefer xwrite instead of write

10 years agoMerge branch 'rk/send-email-ssl-cert'
Junio C Hamano [Mon, 27 Jan 2014 18:44:34 +0000 (10:44 -0800)] 
Merge branch 'rk/send-email-ssl-cert'

The "if /etc/ssl/certs/ directory exists, explicitly telling the
library to use it as SSL_ca_path" blind-defaulting in "git
send-email" broke platforms where /etc/ssl/certs/ directory exists,
but it cannot used as SSL_ca_path (e.g. Fedora rawhide).  Fix it by
not specifying any SSL_ca_path/SSL_ca_file but still asking for peer
verification in such a case.

* rk/send-email-ssl-cert:
  send-email: /etc/ssl/certs/ directory may not be usable as ca_path

10 years agoMerge branch 'jn/ignore-doc'
Junio C Hamano [Mon, 27 Jan 2014 18:44:26 +0000 (10:44 -0800)] 
Merge branch 'jn/ignore-doc'

Explicitly list $HOME/.config/git/ignore as one of the places you
can use to keep ignore patterns that depend on your personal choice
of tools, e.g. *~ for Emacs users.

* jn/ignore-doc:
  gitignore doc: add global gitignore to synopsis

10 years agoMerge branch 'jk/interpret-branch-name-fix'
Junio C Hamano [Mon, 27 Jan 2014 18:44:20 +0000 (10:44 -0800)] 
Merge branch 'jk/interpret-branch-name-fix'

Fix a handful of bugs around interpreting $branch@{upstream}
notation and its lookalike, when $branch part has interesting
characters, e.g. "@", and ":".

* jk/interpret-branch-name-fix:
  interpret_branch_name: find all possible @-marks
  interpret_branch_name: avoid @{upstream} past colon
  interpret_branch_name: always respect "namelen" parameter
  interpret_branch_name: rename "cp" variable to "at"
  interpret_branch_name: factor out upstream handling

10 years agoMerge branch 'jk/allow-fetch-onelevel-refname'
Junio C Hamano [Mon, 27 Jan 2014 18:44:13 +0000 (10:44 -0800)] 
Merge branch 'jk/allow-fetch-onelevel-refname'

"git clone" would fail to clone from a repository that has a ref
directly under "refs/", e.g. "refs/stash", because different
validation paths do different things on such a refname.  Loosen the
client side's validation to allow such a ref.

* jk/allow-fetch-onelevel-refname:
  fetch-pack: do not filter out one-level refs

10 years agoMerge branch 'jc/revision-range-unpeel'
Junio C Hamano [Mon, 27 Jan 2014 18:44:09 +0000 (10:44 -0800)] 
Merge branch 'jc/revision-range-unpeel'

"git log --left-right A...B" lost the "leftness" of commits
reachable from A when A is a tag as a side effect of a recent
bugfix.  This is a regression in 1.8.4.x series.

* jc/revision-range-unpeel:
  revision: propagate flag bits from tags to pointees
  revision: mark contents of an uninteresting tree uninteresting

10 years agoMerge branch 'mh/retire-ref-fetch-rules'
Junio C Hamano [Mon, 27 Jan 2014 18:44:06 +0000 (10:44 -0800)] 
Merge branch 'mh/retire-ref-fetch-rules'

Code simplification.

* mh/retire-ref-fetch-rules:
  refname_match(): always use the rules in ref_rev_parse_rules

10 years agoMerge branch 'mh/attr-macro-doc'
Junio C Hamano [Mon, 27 Jan 2014 18:44:04 +0000 (10:44 -0800)] 
Merge branch 'mh/attr-macro-doc'

* mh/attr-macro-doc:
  gitattributes: document more clearly where macros are allowed

10 years agoMerge branch 'jc/maint-pull-docfix'
Junio C Hamano [Mon, 27 Jan 2014 18:44:00 +0000 (10:44 -0800)] 
Merge branch 'jc/maint-pull-docfix'

* jc/maint-pull-docfix:
  Documentation: "git pull" does not have the "-m" option
  Documentation: exclude irrelevant options from "git pull"

10 years agoMerge branch 'jk/complete-merge-base'
Junio C Hamano [Mon, 27 Jan 2014 18:43:55 +0000 (10:43 -0800)] 
Merge branch 'jk/complete-merge-base'

* jk/complete-merge-base:
  completion: handle --[no-]fork-point options to git-rebase
  completion: complete merge-base options

10 years agoMerge branch 'ab/subtree-doc'
Junio C Hamano [Mon, 27 Jan 2014 18:43:51 +0000 (10:43 -0800)] 
Merge branch 'ab/subtree-doc'

* ab/subtree-doc:
  subtree: fix argument validation in add/pull/push

10 years agohttp-protocol.txt: don't use uppercase for variable names in "The Negotiation Algorithm"
Thomas Ackermann [Sun, 26 Jan 2014 12:56:17 +0000 (13:56 +0100)] 
http-protocol.txt: don't use uppercase for variable names in "The Negotiation Algorithm"

Signed-off-by: Thomas Ackermann <th.acker@arcor.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoDocumentation: make it easier to maintain enumerated documents
Junio C Hamano [Mon, 27 Jan 2014 17:04:32 +0000 (09:04 -0800)] 
Documentation: make it easier to maintain enumerated documents

Instead of starting an enumeration of documents with a DOC = doc1
followed by DOC += doc2, DOC += doc3, ..., empty it with "DOC =" at
the beginning and consistently add them with "DOC += ...".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocreate HTML for http-protocol.txt
Thomas Ackermann [Sun, 26 Jan 2014 12:57:19 +0000 (13:57 +0100)] 
create HTML for http-protocol.txt

./Documentation/technical/http-protocol.txt was missing from TECH_DOCS in Makefile.
Add it and also improve HTML formatting while still retaining good readability of the ASCII text:
- Use monospace font instead of italicized or roman font for machine output and source text
- Use roman font for things which should be body text
- Use double quotes consistently for "want" and "have" commands
- Use uppercase "C" / "S" consistently for "client" / "server";
  also use "C:" / "S:" instead of "(C)" / "(S)" for consistency and
  to avoid having formatted "(C)" as copyright symbol in HTML
- Use only spaces and not a combination of tabs and spaces for whitespace

Signed-off-by: Thomas Ackermann <th.acker@arcor.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree_entry_interesting: match against all pathspecs
Andy Spencer [Sat, 25 Jan 2014 22:06:46 +0000 (22:06 +0000)] 
tree_entry_interesting: match against all pathspecs

The current basedir compare aborts early in order to avoid futile
recursive searches. However, a match may still be found by another
pathspec. This can cause an error while checking out files from a branch
when using multiple pathspecs:

$ git checkout master -- 'a/*.txt' 'b/*.txt'
error: pathspec 'a/*.txt' did not match any file(s) known to git.

Signed-off-by: Andy Spencer <andy753421@gmail.com>
Acked-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoMakefile: remove redundant object in git-http{fetch,push}
John Keeping [Sat, 25 Jan 2014 13:11:44 +0000 (13:11 +0000)] 
Makefile: remove redundant object in git-http{fetch,push}

revision.o is included in libgit.a which is in $(GITLIBS), so we don't
need to include is separately.  This fixes compilation with
"-fwhole-program" which otherwise fails with messages like this:

  libgit.a(revision.o): In function `mark_tree_uninteresting':
  /home/john/src/git/revision.c:108: multiple definition of `mark_tree_uninteresting'
  /tmp/ccKQRkZV.ltrans2.ltrans.o:/home/john/src/git/revision.c:108: first defined here

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agodoc: remote author/documentation sections from more pages
Michael Haggerty [Sun, 26 Jan 2014 23:43:49 +0000 (00:43 +0100)] 
doc: remote author/documentation sections from more pages

We decided at 48bb914e (doc: drop author/documentation sections from
most pages, 2011-03-11) to remove "author" and "documentation"
sections from our documentation.  Remove a few stragglers.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agol10n: remove 2 blank translations on Danish, Dutch
Jiang Xin [Sat, 18 Jan 2014 09:08:14 +0000 (17:08 +0800)] 
l10n: remove 2 blank translations on Danish, Dutch

Two l10n teams haven't contributed a single translation for about two
years since they was initialized with a blank template.  Remove them
can make the Git package smaller and give opportunities to other
contributors.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
10 years agol10n: zh_CN.po: translate 27 messages (2210t0f0u)
Jiang Xin [Sat, 18 Jan 2014 03:04:21 +0000 (11:04 +0800)] 
l10n: zh_CN.po: translate 27 messages (2210t0f0u)

Translations for git v1.9-rc0, and also update translations on "graft"
and "reference repository".

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
10 years agot7700: do not use "touch" unnecessarily
Jeff King [Thu, 23 Jan 2014 19:55:18 +0000 (14:55 -0500)] 
t7700: do not use "touch" unnecessarily

Some versions of touch (such as /usr/ucb/touch on Solaris)
do not know about the "-r" option. This would make sense as
a feature of test-chmtime, but fortunately this fix is even
easier.

The test does not care about the timestamp of the .keep file it
creates at all, only that it exists. For such a use case, with or
without portability issues around "-r", "touch" should not be used
in the first place.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agot7501: fix "empty commit" test with NO_PERL
Jeff King [Thu, 23 Jan 2014 19:54:57 +0000 (14:54 -0500)] 
t7501: fix "empty commit" test with NO_PERL

t7501.9 tries to check that "git commit" will fail when the
index is unchanged. It relies on previous tests not to have
modified the index. When it was originally written, this was
always the case. However, commit c65dc35 (t7501: test the
right kind of breakage, 2012-03-30) changed earlier tests (4
and 5) to leave a modification in the index.

We never noticed, however, because t7501.7, between the two,
clears the index state as a side effect. However, that test
depends on the PERL prerequisite, and so it does not always
run. Therefore if NO_PERL is set, we do not run the
intervening test, the index is left unclean, and t7501.9
fails.

We could fix this by moving t7501.9 up in the script.
However, this patch instead leaves it in place and adds a
"git reset" before the commit. This makes the test more
explicit about its preconditions, and will future-proof it
against any other changes in the test state.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agotree-walk.c: ignore trailing slash on submodule in tree_entry_interesting()
Nguyễn Thái Ngọc Duy [Thu, 23 Jan 2014 13:22:05 +0000 (20:22 +0700)] 
tree-walk.c: ignore trailing slash on submodule in tree_entry_interesting()

We do ignore trailing slash on a directory, so pathspec "abc/" matches
directory "abc". A submodule is also a directory. Apply the same logic
to it. This makes "git log submodule-path" and "git log submodule-path/"
produce the same output.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorepack: propagate pack-objects options as strings
Jeff King [Thu, 23 Jan 2014 01:30:13 +0000 (20:30 -0500)] 
repack: propagate pack-objects options as strings

In the original shell version of git-repack, any options
destined for pack-objects were left as strings, and passed
as a whole. Since the C rewrite in commit a1bbc6c (repack:
rewrite the shell script in C, 2013-09-15), we now parse
these values to integers internally, then reformat the
integers when passing the option to pack-objects.

This has the advantage that we catch format errors earlier
(i.e., when repack is invoked, rather than when pack-objects
is invoked).

It has three disadvantages, though:

  1. Our internal data types may not be the right size. In
     the case of "--window-memory" and "--max-pack-size",
     these are "unsigned long" in pack-objects, but we can
     only represent a regular "int".

  2. Our parsing routines might not be the same as those of
     pack-objects. For the two options above, pack-objects
     understands "100m" to mean "100 megabytes", but repack
     does not.

  3. We have to keep a sentinel value to know whether it is
     worth passing the option along. In the case of
     "--window-memory", we currently do not pass it if the
     value is "0". But that is a meaningful value to
     pack-objects, where it overrides any configured value.

We can fix all of these by simply passing the strings from
the user along to pack-objects verbatim. This does not
actually fix anything for "--depth" or "--window", but these
are converted, too, for consistency.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorepack: make parsed string options const-correct
Jeff King [Thu, 23 Jan 2014 01:28:30 +0000 (20:28 -0500)] 
repack: make parsed string options const-correct

When we use OPT_STRING to parse an option, we get back a
pointer into the argv array, which should be "const char *".
The compiler doesn't notice because it gets passed through a
"void *" in the option struct.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorepack: fix typo in max-pack-size option
Jeff King [Thu, 23 Jan 2014 01:27:52 +0000 (20:27 -0500)] 
repack: fix typo in max-pack-size option

When we see "--max-pack-size", we accidentally propagated
this to pack-objects as "--max_pack_size", which does not
work at all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoMakefile: Fix compilation of Windows resource file
Johannes Sixt [Thu, 23 Jan 2014 07:28:58 +0000 (08:28 +0100)] 
Makefile: Fix compilation of Windows resource file

If the git version number consists of less than three period
separated numbers, then the Windows resource file compilation
issues a syntax error:

  $ touch git.rc
  $ make V=1 git.res
  GIT_VERSION = 1.9.rc0
  windres -O coff \
            -DMAJOR=1 -DMINOR=9 -DPATCH=rc0 \
            -DGIT_VERSION="\\\"1.9.rc0\\\"" git.rc -o git.res
  C:\msysgit\msysgit\mingw\bin\windres.exe: git.rc:2: syntax error
  make: *** [git.res] Error 1
  $

Note that -DPATCH=rc0.

The values passed via -DMAJOR=, -DMINOR=, and -DPATCH= are used in
FILEVERSION and PRODUCTVERSION statements, which expect up to four numeric
values. These version numbers are intended for machine consumption. They
are typically inspected by installers to decide whether a file to be
installed is newer than one that exists on the system, but are not used
for much else.

We can be pretty certain that there are no tools that look at these
version numbers, not even the installer of Git for Windows does.
Therefore, to fix the syntax error, fill in only the first two numbers,
which we are guaranteed to find in Git version numbers.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Acked-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoMerge git://git.bogomips.org/git-svn
Junio C Hamano [Thu, 23 Jan 2014 16:51:14 +0000 (08:51 -0800)] 
Merge git://git.bogomips.org/git-svn

* 'master' of git://git.bogomips.org/git-svn:
  git-svn: memoize _rev_list and rebuild

10 years agoMerge git://ozlabs.org/~paulus/gitk
Junio C Hamano [Thu, 23 Jan 2014 16:50:50 +0000 (08:50 -0800)] 
Merge git://ozlabs.org/~paulus/gitk

* 'master' of git://ozlabs.org/~paulus/gitk:
  gitk: Indent word-wrapped lines in commit display header
  gitk: Comply with XDG base directory specification
  gitk: Replace "next" and "prev" buttons with down and up arrows
  gitk: chmod +x po2msg.sh
  gitk: Update copyright dates
  gitk: Add Bulgarian translation (304t)
  gitk: Fix mistype

10 years agogitk: Indent word-wrapped lines in commit display header
Paul Mackerras [Thu, 23 Jan 2014 11:06:22 +0000 (22:06 +1100)] 
gitk: Indent word-wrapped lines in commit display header

In the cases where the lines starting with Precedes:, Follows: and
Branches: in the commit display are long enough to be word-wrapped,
this adds a 1cm margin on the left of the wrapped lines, to make
the display more readable.  Suggested by Stephen Rothwell.

Signed-off-by: Paul Mackerras <paulus@samba.org>
10 years agogit-svn: memoize _rev_list and rebuild
lin zuojian [Thu, 23 Jan 2014 02:15:19 +0000 (10:15 +0800)] 
git-svn: memoize _rev_list and rebuild

According to profile data, _rev_list and rebuild consume a large
portion of time.  Memoize the results of _rev_list and memoize
rebuild internals to avoid subprocess invocation.

When importing 15152 revisions on a LAN, time improved from 10
hours to 3-4 hours.

Signed-off-by: lin zuojian <manjian2006@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
10 years agoAdd cross-references between docs for for-each-ref and show-ref
Michael Haggerty [Wed, 22 Jan 2014 11:23:20 +0000 (12:23 +0100)] 
Add cross-references between docs for for-each-ref and show-ref

Add cross-references between the manpages for git-for-each-ref(1) and
git-show-ref(1).

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agosafe_create_leading_directories(): on Windows, \ can separate path components
Michael Haggerty [Sat, 18 Jan 2014 23:40:44 +0000 (00:40 +0100)] 
safe_create_leading_directories(): on Windows, \ can separate path components

When cloning to a directory "C:\foo\bar" from Windows' cmd.exe where
"foo" does not exist yet, Git would throw an error like

    fatal: could not create work tree dir 'c:\foo\bar'.: No such file or directory

Fix this by not hard-coding a platform specific directory separator
into safe_create_leading_directories().

This patch, including its entire commit message, is derived from a
patch by Sebastian Schuberth.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4 doc: use two-line style for options with multiple spellings
Pete Wyckoff [Tue, 21 Jan 2014 23:16:48 +0000 (18:16 -0500)] 
git p4 doc: use two-line style for options with multiple spellings

Thomas Rast noticed the docs have a mix of styles when
it comes to options with multiple spellings.  Standardize
the couple in git-p4.txt that are odd.

Instead of:
  -n, --dry-run::

Do this:
  -n::
  --dry-run::

See
http://thread.gmane.org/gmane.comp.version-control.git/219936/focus=219945

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4 test: examine behavior with locked (+l) files
Pete Wyckoff [Tue, 21 Jan 2014 23:16:47 +0000 (18:16 -0500)] 
git p4 test: examine behavior with locked (+l) files

The p4 server can enforce file locking, so that only one user
can edit a file at a time.  Git p4 is unable to submit changes
to locked files.  Currently it exits poorly.  Ideally it would
notice the locked condition and clean up nicely.

Add a bunch of tests that describe the problem, hoping that
fixes appear in the future.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4: fix an error message when "p4 where" fails
Pete Wyckoff [Tue, 21 Jan 2014 23:16:46 +0000 (18:16 -0500)] 
git p4: fix an error message when "p4 where" fails

When "p4 where" fails, for whatever reason, the error message tries to
show an undefined variable.  This minor bug applies only when using a
client spec, and was introduced recently in 9d57c4a (git p4: implement
view spec wildcards with "p4 where", 2013-08-30).

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4: handle files with wildcards when doing RCS scrubbing
Pete Wyckoff [Tue, 21 Jan 2014 23:16:45 +0000 (18:16 -0500)] 
git p4: handle files with wildcards when doing RCS scrubbing

Commit 9d7d446 (git p4: submit files with wildcards, 2012-04-29)
fixed problems with handling files that had p4 wildcard
characters, like "@" and "*".  But it missed one case, that of
RCS keyword scrubbing, which uses "p4 fstat" to extract type
information.  Fix it by calling wildcard_encode() on the raw
filename.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4 test: do not pollute /tmp
Pete Wyckoff [Tue, 21 Jan 2014 23:16:44 +0000 (18:16 -0500)] 
git p4 test: do not pollute /tmp

Generating the submit template for p4 uses tempfile.mkstemp(),
which by default puts files in /tmp.  For a test that fails,
possibly on purpose, this is not cleaned up.  Run with TMPDIR
pointing into the trash directory so the temp files go away
with the test results.

To do this required some other minor changes.  First, the editor
is launched using system(editor + " " + template_file), using
shell expansion to build the command string.  This doesn't work
if editor has a space in it.  And is generally unwise as it's
easy to fool the shell into doing extra work.  Exec the args
directly, without shell expansion.

Second, without shell expansion, the trick of "P4EDITOR=:" used
in the tests doesn't work.  Use a real command, true, as the
non-interactive editor for testing.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4 test: run as user "author"
Pete Wyckoff [Tue, 21 Jan 2014 23:16:43 +0000 (18:16 -0500)] 
git p4 test: run as user "author"

The tests use author@example.com as the canonical submitter,
but he does not have an entry in the p4 users database.
This causes the generated change description to complain
that the git and p4 users disagree.  The complaint message
is still valid, but isn't useful in tests.  It was introduced
in 848de9c (git-p4: warn if git authorship won't be retained,
2011-05-13).

Fix t9813 to use @example.com instead of @localhost due to
change in p4_add_user().  Move the function into the git p4
test library so author can be added at initialization time.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4 test: is_cli_file_writeable succeeds
Pete Wyckoff [Tue, 21 Jan 2014 23:16:42 +0000 (18:16 -0500)] 
git p4 test: is_cli_file_writeable succeeds

Commit e9df0f9 (git p4: cygwin p4 client does not mark read-only,
2013-01-26) fixed a problem with "test -w" on cygwin, but mistakenly
marked the new test as failing.  Fix this.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4 test: explicitly check p4 wildcard delete
Pete Wyckoff [Tue, 21 Jan 2014 23:16:41 +0000 (18:16 -0500)] 
git p4 test: explicitly check p4 wildcard delete

There was no test where p4 deleted a file with a wildcard
character.  Make sure git p4 applies the wildcard decoding
properly when importing a delete that includes a wildcard.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4: work around p4 bug that causes empty symlinks
Pete Wyckoff [Tue, 21 Jan 2014 23:16:40 +0000 (18:16 -0500)] 
git p4: work around p4 bug that causes empty symlinks

Damien Gérard highlights an interesting problem.  Some p4
repositories end up with symlinks that have an empty target.  It
is not possible to create this with current p4, but they do
indeed exist.

The effect in git p4 is that "p4 print" on the symlink returns an
empty string, confusing the curret symlink-handling code.

Such broken repositories cause problems in p4 as well, even with
no git involved.  In p4, syncing to a change that includes a
bogus symlink causes errors:

    //depot/empty-symlink - updating /home/me/p4/empty-symlink
    rename: /home/me/p4/empty-symlink: No such file or directory

and leaves no symlink.

In git, replicate the p4 behavior by ignoring these bad symlinks.
If, in a later p4 revision, the symlink happens to point to
something non-null, the symlink will be replaced properly.

Add a big test for all this too.

This happens to be a regression introduced by 1292df1 (git-p4:
Fix occasional truncation of symlink contents., 2013-08-08) and
appeared first in 1.8.5.  But it shows up only in p4 repositories
of dubious character, so can wait for a proper release.

Tested-by: Damien Gérard <damien@iwi.me>
Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogitk: Comply with XDG base directory specification
Astril Hayato [Tue, 21 Jan 2014 19:10:16 +0000 (19:10 +0000)] 
gitk: Comply with XDG base directory specification

Write the gitk config data to $XDG_CONFIG_HOME/git/gitk ($HOME/.config/git/gitk
by default) in line with the XDG specification. This makes it consistent with
git which also follows the spec.

If $HOME/.gitk already exists use that for backward compatibility, so only new
installations are affected.

Signed-off-by: Astril Hayato <astrilhayato@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
10 years agogit p4 test: ensure p4 symlink parsing works
Pete Wyckoff [Tue, 21 Jan 2014 23:16:39 +0000 (18:16 -0500)] 
git p4 test: ensure p4 symlink parsing works

While this happens to work, there was no test to make sure
that the basic importing of a symlink from p4 to git functioned.

Add a simple test to create a symlink in p4 and import it into git,
then verify that the symlink exists and has the correct target.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit p4 test: wildcards are supported
Pete Wyckoff [Tue, 21 Jan 2014 23:16:38 +0000 (18:16 -0500)] 
git p4 test: wildcards are supported

Since 9d57c4a (git p4: implement view spec wildcards with "p4
where", 2013-08-30), all the wildcard types should be supported.
Change must-fail tests to mark that they now pass.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agolist-objects: only look at cmdline trees with edge_hint
Jeff King [Tue, 21 Jan 2014 02:25:40 +0000 (21:25 -0500)] 
list-objects: only look at cmdline trees with edge_hint

When rev-list is given a command-line like:

  git rev-list --objects $commit --not --all

the most accurate answer is the difference between the set
of objects reachable from $commit and the set reachable from
all of the existing refs. However, we have not historically
provided that answer, because it is very expensive to
calculate. We would have to open every tree of every commit
in the entire history.

Instead, we find the accurate set difference of the
reachable commits, and then mark the trees at the boundaries
as uninteresting. This misses objects which appear in the
trees of both the interesting commits and deep within the
uninteresting history.

Commit fbd4a70 (list-objects: mark more commits as edges in
mark_edges_uninteresting, 2013-08-16) noticed that we miss
those objects during pack-objects, and added code to examine
the trees of all of the "--not" refs given on the
command-line.  Note that this is still not the complete set
difference, because we look only at the tips of the
command-line arguments, not all of their reachable commits.
But it increases the set of boundary objects we consider,
which is especially important for shallow fetches.  So we
are trading extra CPU time for a larger set of boundary
objects, which can improve the resulting pack size for a
--thin pack.

This tradeoff probably makes sense in the context of
pack-objects, where we have set revs->edge_hint to have the
traversal feed us the set of boundary objects.  For a
regular rev-list, though, it is probably not a good
tradeoff. It is true that it makes our list slightly closer
to a true set difference, but it is a rare case where this
is important. And because we do not have revs->edge_hint
set, we do nothing useful with the larger set of boundary
objects.

This patch therefore ties the extra tree examination to the
revs->edge_hint flag; it is the presence of that flag that
makes the tradeoff worthwhile.

Here is output from the p0001-rev-list showing the
improvement in performance:

Test                                             HEAD^             HEAD
-----------------------------------------------------------------------------------------
0001.1: rev-list --all                           0.69(0.65+0.02)   0.69(0.66+0.02) +0.0%
0001.2: rev-list --all --objects                 3.22(3.19+0.03)   3.23(3.20+0.03) +0.3%
0001.4: rev-list $commit --not --all             0.04(0.04+0.00)   0.04(0.04+0.00) +0.0%
0001.5: rev-list --objects $commit --not --all   0.27(0.26+0.01)   0.04(0.04+0.00) -85.2%

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agot/perf: time rev-list with UNINTERESTING commits
Jeff King [Tue, 21 Jan 2014 02:25:12 +0000 (21:25 -0500)] 
t/perf: time rev-list with UNINTERESTING commits

We time a straight "rev-list --all" and its "--object"
counterpart, both going all the way to the root. However, we
do not time a partial history walk. This patch adds an
extreme case: a walk over a very small slice of history, but
with a very large set of UNINTERESTING tips. This is similar
to the connectivity check run by git on a small fetch, or
the walk done by any pre-receive hooks that want to check
incoming commits.

This test reveals a performance regression in git v1.8.4.2,
caused by fbd4a70 (list-objects: mark more commits as edges
in mark_edges_uninteresting, 2013-08-16):

Test                                             fbd4a703^         fbd4a703
------------------------------------------------------------------------------------------
0001.1: rev-list --all                           0.69(0.67+0.02)   0.69(0.68+0.01) +0.0%
0001.2: rev-list --all --objects                 3.47(3.44+0.02)   3.48(3.44+0.03) +0.3%
0001.4: rev-list $commit --not --all             0.04(0.04+0.00)   0.04(0.04+0.00) +0.0%
0001.5: rev-list --objects $commit --not --all   0.04(0.03+0.00)   0.27(0.24+0.02) +575.0%

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoDocumentation: @{-N} can refer to a commit
Thomas Rast [Sun, 19 Jan 2014 07:01:15 +0000 (08:01 +0100)] 
Documentation: @{-N} can refer to a commit

The @{-N} syntax always referred to the N-th last thing checked out,
which can be either a branch or a commit (for detached HEAD cases).
However, the documentation only mentioned branches.

Edit in a "/commit" in the appropriate places.

Reported-by: Kevin <ikke@ikke.info>
Signed-off-by: Thomas Rast <tr@thomasrast.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorename_tmp_log(): on SCLD_VANISHED, retry
Michael Haggerty [Sat, 18 Jan 2014 22:49:01 +0000 (23:49 +0100)] 
rename_tmp_log(): on SCLD_VANISHED, retry

If safe_create_leading_directories() fails because a file along the
path unexpectedly vanished, try again from the beginning.  Try at most
4 times.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorename_tmp_log(): limit the number of remote_empty_directories() attempts
Michael Haggerty [Sat, 18 Jan 2014 22:49:00 +0000 (23:49 +0100)] 
rename_tmp_log(): limit the number of remote_empty_directories() attempts

This doesn't seem to be a likely error, but we've got the counter
anyway, so we might as well use it for an added bit of safety.

Please note that the first call to rename() is optimistic, and it is
normal for it to fail if there is a directory in the way.  So bump the
total number of allowed attempts to 4, to be sure that we can still
have at least 3 retries in the case of a race.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorename_tmp_log(): handle a possible mkdir/rmdir race
Michael Haggerty [Sat, 18 Jan 2014 22:48:59 +0000 (23:48 +0100)] 
rename_tmp_log(): handle a possible mkdir/rmdir race

If a directory vanishes while renaming the temporary reflog file,
retry (up to 3 times).  This could happen if another process deletes
the directory created by safe_create_leading_directories() just before
we rename the file into the directory.

As far as I can tell, this race could not occur internal to git.  The
only time that a directory under $GIT_DIR/logs is deleted is if room
has to be made for a log file for a reference with the same name;
for example, in the following sequence:

    git branch foo/bar    # Creates file .git/logs/refs/heads/foo/bar
    git branch -d foo/bar # Deletes file but leaves .git/logs/refs/heads/foo/
    git branch foo        # Deletes .git/logs/refs/heads/foo/

But the only reason the last command deletes the directory is because
it wants to create a file with the same name.  So if another process
(e.g.,

    git branch foo/baz

) wants to create that directory, one of the two is doomed to failure
anyway because of a D/F conflict.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>