OSDN Git Service

git-core/git.git
7 years agopack-objects: use reachability bitmap index when generating non-stdout pack
Kirill Smelkov [Sat, 10 Sep 2016 15:01:44 +0000 (18:01 +0300)]
pack-objects: use reachability bitmap index when generating non-stdout pack

Starting from 6b8fda2d (pack-objects: use bitmaps when packing objects)
if a repository has bitmap index, pack-objects can nicely speedup
"Counting objects" graph traversal phase. That however was done only for
case when resultant pack is sent to stdout, not written into a file.

The reason here is for on-disk repack by default we want:

- to produce good pack (with bitmap index not-yet-packed objects are
  emitted to pack in suboptimal order).

- to use more robust pack-generation codepath (avoiding possible
  bugs in bitmap code and possible bitmap index corruption).

Jeff King further explains:

    The reason for this split is that pack-objects tries to determine how
    "careful" it should be based on whether we are packing to disk or to
    stdout. Packing to disk implies "git repack", and that we will likely
    delete the old packs after finishing. We want to be more careful (so
    as not to carry forward a corruption, and to generate a more optimal
    pack), and we presumably run less frequently and can afford extra CPU.
    Whereas packing to stdout implies serving a remote via "git fetch" or
    "git push". This happens more frequently (e.g., a server handling many
    fetching clients), and we assume the receiving end takes more
    responsibility for verifying the data.

    But this isn't always the case. One might want to generate on-disk
    packfiles for a specialized object transfer. Just using "--stdout" and
    writing to a file is not optimal, as it will not generate the matching
    pack index.

    So it would be useful to have some way of overriding this heuristic:
    to tell pack-objects that even though it should generate on-disk
    files, it is still OK to use the reachability bitmaps to do the
    traversal.

So we can teach pack-objects to use bitmap index for initial object
counting phase when generating resultant pack file too:

- if we take care to not let it be activated under git-repack:

  See above about repack robustness and not forward-carrying corruption.

- if we know bitmap index generation is not enabled for resultant pack:

  The current code has singleton bitmap_git, so it cannot work
  simultaneously with two bitmap indices.

  We also want to avoid (at least with current implementation)
  generating bitmaps off of bitmaps. The reason here is: when generating
  a pack, not-yet-packed objects will be emitted into pack in
  suboptimal order and added to tail of the bitmap as "extended entries".
  When the resultant pack + some new objects in associated repository
  are in turn used to generate another pack with bitmap, the situation
  repeats: new objects are again not emitted optimally and just added to
  bitmap tail - not in recency order.

  So the pack badness can grow over time when at each step we have
  bitmapped pack + some other objects. That's why we want to avoid
  generating bitmaps off of bitmaps, not to let pack badness grow.

- if we keep pack reuse enabled still only for "send-to-stdout" case:

  Because pack-to-file needs to generate index for destination pack, and
  currently on pack reuse raw entries are directly written out to the
  destination pack by write_reused_pack(), bypassing needed for pack index
  generation bookkeeping done by regular codepath in write_one() and
  friends.

  ( In the future we might teach pack-reuse code about cases when index
    also needs to be generated for resultant pack and remove
    pack-reuse-only-for-stdout limitation )

This way for pack-objects -> file we get nice speedup:

    erp5.git[1] (~230MB) extracted from ~ 5GB lab.nexedi.com backup
    repository managed by git-backup[2] via

    time echo 0186ac99 | git pack-objects --revs erp5pack

before:  37.2s
after:   26.2s

And for `git repack -adb` packed git.git

    time echo 5c589a73 | git pack-objects --revs gitpack

before:   7.1s
after:    3.6s

i.e. it can be 30% - 50% speedup for pack extraction.

git-backup extracts many packs on repositories restoration. That was my
initial motivation for the patch.

[1] https://lab.nexedi.com/nexedi/erp5
[2] https://lab.nexedi.com/kirr/git-backup

NOTE

Jeff also suggests that pack.useBitmaps was probably a mistake to
introduce originally. This way we are not adding another config point,
but instead just always default to-file pack-objects not to use bitmap
index: Tools which need to generate on-disk packs with using bitmap, can
pass --use-bitmap-index explicitly. And git-repack does never pass
--use-bitmap-index, so this way we can be sure regular on-disk repacking
remains robust.

NOTE2

`git pack-objects --stdout >file.pack` + `git index-pack file.pack` is much slower
than `git pack-objects file.pack`. Extracting erp5.git pack from
lab.nexedi.com backup repository:

    $ time echo 0186ac99 | git pack-objects --stdout --revs >erp5pack-stdout.pack

    real    0m22.309s
    user    0m21.148s
    sys     0m0.932s

    $ time git index-pack erp5pack-stdout.pack

    real    0m50.873s   <-- more than 2 times slower than time to generate pack itself!
    user    0m49.300s
    sys     0m1.360s

So the time for

    `pack-object --stdout >file.pack` + `index-pack file.pack`  is  72s,

while

    `pack-objects file.pack` which does both pack and index     is  27s.

And even

    `pack-objects --no-use-bitmap-index file.pack`              is  37s.

Jeff explains:

    The packfile does not carry the sha1 of the objects. A receiving
    index-pack has to compute them itself, including inflating and applying
    all of the deltas.

that's why for `git-backup restore` we want to teach `git pack-objects
file.pack` to use bitmaps instead of using `git pack-objects --stdout
>file.pack` + `git index-pack file.pack`.

NOTE3

The speedup is now tracked via t/perf/p5310-pack-bitmaps.sh

    Test                                    56dfeb62          this tree
    --------------------------------------------------------------------------------
    5310.2: repack to disk                  8.98(8.05+0.29)   9.05(8.08+0.33) +0.8%
    5310.3: simulated clone                 2.02(2.27+0.09)   2.01(2.25+0.08) -0.5%
    5310.4: simulated fetch                 0.81(1.07+0.02)   0.81(1.05+0.04) +0.0%
    5310.5: pack to file                    7.58(7.04+0.28)   7.60(7.04+0.30) +0.3%
    5310.6: pack to file (bitmap)           7.55(7.02+0.28)   3.25(2.82+0.18) -57.0%
    5310.8: clone (partial bitmap)          1.83(2.26+0.12)   1.82(2.22+0.14) -0.5%
    5310.9: pack to file (partial bitmap)   6.86(6.58+0.30)   2.87(2.74+0.20) -58.2%

More context:

    http://marc.info/?t=146792101400001&r=1&w=2
    http://public-inbox.org/git/20160707190917.20011-1-kirr@nexedi.com/T/#t

Cc: Vicent Marti <tanoku@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopack-objects: respect --local/--honor-pack-keep/--incremental when bitmap is in use
Kirill Smelkov [Sat, 10 Sep 2016 15:01:10 +0000 (18:01 +0300)]
pack-objects: respect --local/--honor-pack-keep/--incremental when bitmap is in use

Since 6b8fda2d (pack-objects: use bitmaps when packing objects) there
are two codepaths in pack-objects: with & without using bitmap
reachability index.

However add_object_entry_from_bitmap(), despite its non-bitmapped
counterpart add_object_entry(), in no way does check for whether --local
or --honor-pack-keep or --incremental should be respected. In
non-bitmapped codepath this is handled in want_object_in_pack(), but
bitmapped codepath has simply no such checking at all.

The bitmapped codepath however was allowing to pass in all those options
and with bitmap indices still being used under such conditions -
potentially giving wrong output (e.g. including objects from non-local or
.keep'ed pack).

We can easily fix this by noting the following: when an object comes to
add_object_entry_from_bitmap() it can come for two reasons:

    1. entries coming from main pack covered by bitmap index, and
    2. object coming from, possibly alternate, loose or other packs.

"2" can be already handled by want_object_in_pack() and to cover
"1" we can teach want_object_in_pack() to expect that *found_pack can be
non-NULL, meaning calling client already found object's pack entry.

In want_object_in_pack() we care to start the checks from already found
pack, if we have one, this way determining the answer right away
in case neither --local nor --honour-pack-keep are active. In
particular, as p5310-pack-bitmaps.sh shows (3 consecutive runs), we do
not do harm to served-with-bitmap clones performance-wise:

    Test                      56dfeb62          this tree
    -----------------------------------------------------------------
    5310.2: repack to disk    9.08(8.20+0.25)   9.09(8.14+0.32) +0.1%
    5310.3: simulated clone   1.92(2.12+0.08)   1.93(2.12+0.09) +0.5%
    5310.4: simulated fetch   0.82(1.07+0.04)   0.82(1.06+0.04) +0.0%
    5310.6: partial bitmap    1.96(2.42+0.13)   1.95(2.40+0.15) -0.5%

    Test                      56dfeb62          this tree
    -----------------------------------------------------------------
    5310.2: repack to disk    9.11(8.16+0.32)   9.11(8.19+0.28) +0.0%
    5310.3: simulated clone   1.93(2.14+0.07)   1.92(2.11+0.10) -0.5%
    5310.4: simulated fetch   0.82(1.06+0.04)   0.82(1.04+0.05) +0.0%
    5310.6: partial bitmap    1.95(2.38+0.16)   1.94(2.39+0.14) -0.5%

    Test                      56dfeb62          this tree
    -----------------------------------------------------------------
    5310.2: repack to disk    9.13(8.17+0.31)   9.07(8.13+0.28) -0.7%
    5310.3: simulated clone   1.92(2.13+0.07)   1.91(2.12+0.06) -0.5%
    5310.4: simulated fetch   0.82(1.08+0.03)   0.82(1.08+0.03) +0.0%
    5310.6: partial bitmap    1.96(2.43+0.14)   1.96(2.42+0.14) +0.0%

with delta timings showing they are all within noise from run to run.

In the general case we do not want to call find_pack_entry_one() more than
once, because it is expensive. This patch splits the loop in
want_object_in_pack() into two parts: finding the object and seeing if it
impacts our choice to include it in the pack. We may call the inexpensive
want_found_object() twice, but we will never call find_pack_entry_one() if we
do not need to.

I appreciate help and discussing this change with Junio C Hamano and
Jeff King.

Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agopack-objects: compute local/ignore_pack_keep early
Jeff King [Fri, 29 Jul 2016 04:11:31 +0000 (00:11 -0400)]
pack-objects: compute local/ignore_pack_keep early

In want_object_in_pack(), we can exit early from our loop if
neither "local" nor "ignore_pack_keep" are set. If they are,
however, we must examine each pack to see if it has the
object and is non-local or has a ".keep".

It's quite common for there to be no non-local or .keep
packs at all, in which case we know ahead of time that
looking further will be pointless. We can pre-compute this
by simply iterating over the list of packs ahead of time,
and dropping the flags if there are no packs that could
match.

Another similar strategy would be to modify the loop in
want_object_in_pack() to notice that we have already found
the object once, and that we are looping only to check for
"local" and "keep" attributes. If a pack has neither of
those, we can skip the call to find_pack_entry_one(), which
is the expensive part of the loop.

This has two advantages:

  - it isn't all-or-nothing; we still get some improvement
    when there's a small number of kept or non-local packs,
    and a large number of non-kept local packs

  - it eliminates any possible race where we add new
    non-local or kept packs after our initial scan. In
    practice, I don't think this race matters; we already
    cache the packed_git information, so somebody who adds a
    new pack or .keep file after we've started will not be
    noticed at all, unless we happen to need to call
    reprepare_packed_git() because a lookup fails.

    In other words, we're already racy, and the race is not
    a big deal (losing the race means we might include an
    object in the pack that would not otherwise be, which is
    an acceptable outcome).

However, it also has a disadvantage: we still loop over the
rest of the packs for each object to check their flags. This
is much less expensive than doing the object lookup, but
still not free. So if we wanted to implement that strategy
to cover the non-all-or-nothing cases, we could do so in
addition to this one (so you get the most speedup in the
all-or-nothing case, and the best we can do in the other
cases). But given that the all-or-nothing case is likely the
most common, it is probably not worth the trouble, and we
can revisit this later if evidence points otherwise.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agopack-objects: break out of want_object loop early
Jeff King [Fri, 29 Jul 2016 04:10:31 +0000 (00:10 -0400)]
pack-objects: break out of want_object loop early

When pack-objects collects the list of objects to pack
(either from stdin, or via its internal rev-list), it
filters each one through want_object_in_pack().

This function loops through each existing packfile, looking
for the object. When we find it, we mark the pack/offset
combo for later use. However, we can't just return "yes, we
want it" at that point. If --honor-pack-keep is in effect,
we must keep looking to find it in _all_ packs, to make sure
none of them has a .keep. Likewise, if --local is in effect,
we must make sure it is not present in any non-local pack.

As a result, the sum effort of these calls is effectively
O(nr_objects * nr_packs). In an ordinary repository, we have
only a handful of packs, and this doesn't make a big
difference. But in pathological cases, it can slow the
counting phase to a crawl.

This patch notices the case that we have neither "--local"
nor "--honor-pack-keep" in effect and breaks out of the loop
early, after finding the first instance. Note that our worst
case is still "objects * packs" (i.e., we might find each
object in the last pack we look in), but in practice we will
often break out early. On an "average" repo, my git.git with
8 packs, this shows a modest 2% (a few dozen milliseconds)
improvement in the counting-objects phase of "git
pack-objects --all <foo" (hackily instrumented by sticking
exit(0) right after list_objects).

But in a much more pathological case, it makes a bigger
difference. I ran the same command on a real-world example
with ~9 million objects across 1300 packs. The counting time
dropped from 413s to 45s, an improvement of about 89%.

Note that this patch won't do anything by itself for a
normal "git gc", as it uses both --honor-pack-keep and
--local.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agofind_pack_entry: replace last_found_pack with MRU cache
Jeff King [Fri, 29 Jul 2016 04:09:46 +0000 (00:09 -0400)]
find_pack_entry: replace last_found_pack with MRU cache

Each pack has an index for looking up entries in O(log n)
time, but if we have multiple packs, we have to scan through
them linearly. This can produce a measurable overhead for
some operations.

We dealt with this long ago in f7c22cc (always start looking
up objects in the last used pack first, 2007-05-30), which
keeps what is essentially a 1-element most-recently-used
cache. In theory, we should be able to do better by keeping
a similar but longer cache, that is the same length as the
pack-list itself.

Since we now have a convenient generic MRU structure, we can
plug it in and measure. Here are the numbers for running
p5303 against linux.git:

Test                      HEAD^                HEAD
------------------------------------------------------------------------
5303.3: rev-list (1)      31.56(31.28+0.27)    31.30(31.08+0.20) -0.8%
5303.4: repack (1)        40.62(39.35+2.36)    40.60(39.27+2.44) -0.0%
5303.6: rev-list (50)     31.31(31.06+0.23)    31.23(31.00+0.22) -0.3%
5303.7: repack (50)       58.65(69.12+1.94)    58.27(68.64+2.05) -0.6%
5303.9: rev-list (1000)   38.74(38.40+0.33)    31.87(31.62+0.24) -17.7%
5303.10: repack (1000)    367.20(441.80+4.62)  342.00(414.04+3.72) -6.9%

The main numbers of interest here are the rev-list ones
(since that is exercising the normal object lookup code
path).  The single-pack case shouldn't improve at all; the
260ms speedup there is just part of the run-to-run noise
(but it's important to note that we didn't make anything
worse with the overhead of maintaining our cache). In the
50-pack case, we see similar results. There may be a slight
improvement, but it's mostly within the noise.

The 1000-pack case does show a big improvement, though. That
carries over to the repack case, as well. Even though we
haven't touched its pack-search loop yet, it does still do a
lot of normal object lookups (e.g., for the internal
revision walk), and so improves.

As a point of reference, I also ran the 1000-pack test
against a version of HEAD^ with the last_found_pack
optimization disabled. It takes ~60s, so that gives an
indication of how much even the single-element cache is
helping.

For comparison, here's a smaller repository, git.git:

Test                      HEAD^               HEAD
---------------------------------------------------------------------
5303.3: rev-list (1)      1.56(1.54+0.01)    1.54(1.51+0.02) -1.3%
5303.4: repack (1)        1.84(1.80+0.10)    1.82(1.80+0.09) -1.1%
5303.6: rev-list (50)     1.58(1.55+0.02)    1.59(1.57+0.01) +0.6%
5303.7: repack (50)       2.50(3.18+0.04)    2.50(3.14+0.04) +0.0%
5303.9: rev-list (1000)   2.76(2.71+0.04)    2.24(2.21+0.02) -18.8%
5303.10: repack (1000)    13.21(19.56+0.25)  11.66(18.01+0.21) -11.7%

You can see that the percentage improvement is similar.
That's because the lookup we are optimizing is roughly
O(nr_objects * nr_packs). Since the number of packs is
constant in both tests, we'd expect the improvement to be
linear in the number of objects. But the whole process is
also linear in the number of objects, so the improvement
is a constant factor.

The exact improvement does also depend on the contents of
the packs. In p5303, the extra packs all have 5 first-parent
commits in them, which is a reasonable simulation of a
pushed-to repository. But it also means that only 250
first-parent commits are in those packs (compared to almost
50,000 total in linux.git), and the rest are in the huge
"base" pack. So once we start looking at history in taht big
pack, that's where we'll find most everything, and even the
1-element cache gets close to 100% cache hits.  You could
almost certainly show better numbers with a more
pathological case (e.g., distributing the objects more
evenly across the packs). But that's simply not that
realistic a scenario, so it makes more sense to focus on
these numbers.

The implementation itself is a straightforward application
of the MRU code. We provide an MRU-ordered list of packs
that shadows the packed_git list. This is easy to do because
we only create and revise the pack list in one place. The
"reprepare" code path actually drops the whole MRU and
replaces it for simplicity. It would be more efficient to
just add new entries, but there's not much point in
optimizing here; repreparing happens rarely, and only after
doing a lot of other expensive work.  The key things to keep
optimized are traversal (which is just a normal linked list,
albeit with one extra level of indirection over the regular
packed_git list), and marking (which is a constant number of
pointer assignments, though slightly more than the old
last_found_pack was; it doesn't seem to create a measurable
slowdown, though).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoadd generic most-recently-used list
Jeff King [Fri, 29 Jul 2016 04:06:59 +0000 (00:06 -0400)]
add generic most-recently-used list

There are a few places in Git that would benefit from a fast
most-recently-used cache (e.g., the list of packs, which we
search linearly but would like to order based on locality).
This patch introduces a generic list that can be used to
store arbitrary pointers in most-recently-used order.

The implementation is just a doubly-linked list, where
"marking" an item as used moves it to the front of the list.
Insertion and marking are O(1), and iteration is O(n).

There's no lookup support provided; if you need fast
lookups, you are better off with a different data structure
in the first place.

There is also no deletion support. This would not be hard to
do, but it's not necessary for handling pack structs, which
are created and never removed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agosha1_file: drop free_pack_by_name
Jeff King [Fri, 29 Jul 2016 04:06:48 +0000 (00:06 -0400)]
sha1_file: drop free_pack_by_name

The point of this function is to drop an entry from the
"packed_git" cache that points to a file we might be
overwriting, because our contents may not be the same (and
hence the only caller was pack-objects as it moved a
temporary packfile into place).

In older versions of git, this could happen because the
names of packfiles were derived from the set of objects they
contained, not the actual bits on disk. But since 1190a1a
(pack-objects: name pack files after trailer hash,
2013-12-05), the name reflects the actual bits on disk, and
any two packfiles with the same name can be used
interchangeably.

Dropping this function not only saves a few lines of code,
it makes the lifetime of "struct packed_git" much easier to
reason about: namely, we now do not ever free these structs.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agot/perf: add tests for many-pack scenarios
Jeff King [Fri, 29 Jul 2016 04:06:09 +0000 (00:06 -0400)]
t/perf: add tests for many-pack scenarios

Git's pack storage does efficient (log n) lookups in a
single packfile's index, but if we have multiple packfiles,
we have to linearly search each for a given object.  This
patch introduces some timing tests for cases where we have a
large number of packs, so that we can measure any
improvements we make in the following patches.

The main thing we want to time is object lookup. To do this,
we measure "git rev-list --objects --all", which does a
fairly large number of object lookups (essentially one per
object in the repository).

However, we also measure the time to do a full repack, which
is interesting for two reasons. One is that in addition to
the usual pack lookup, it has its own linear iteration over
the list of packs. And two is that because it it is the tool
one uses to go from an inefficient many-pack situation back
to a single pack, we care about its performance not only at
marginal numbers of packs, but at the extreme cases (e.g.,
if you somehow end up with 5,000 packs, it is the only way
to get back to 1 pack, so we need to make sure it performs
well).

We measure the performance of each command in three
scenarios: 1 pack, 50 packs, and 1,000 packs.

The 1-pack case is a baseline; any optimizations we do to
handle multiple packs cannot possibly perform better than
this.

The 50-pack case is as far as Git should generally allow
your repository to go, if you have auto-gc enabled with the
default settings. So this represents the maximum performance
improvement we would expect under normal circumstances.

The 1,000-pack case is hopefully rare, though I have seen it
in the wild where automatic maintenance was broken for some
time (and the repository continued to receive pushes). This
represents cases where we care less about general
performance, but want to make sure that a full repack
command does not take excessively long.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoSixth batch of topics for 2.10
Junio C Hamano [Tue, 19 Jul 2016 20:26:16 +0000 (13:26 -0700)]
Sixth batch of topics for 2.10

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoMerge branch 'ls/p4-tmp-refs'
Junio C Hamano [Tue, 19 Jul 2016 20:22:24 +0000 (13:22 -0700)]
Merge branch 'ls/p4-tmp-refs'

"git p4" used a location outside $GIT_DIR/refs/ to place its
temporary branches, which has been moved to refs/git-p4-tmp/.

* ls/p4-tmp-refs:
  git-p4: place temporary refs used for branch import under refs/git-p4-tmp

8 years agoMerge branch 'js/am-call-theirs-theirs-in-fallback-3way'
Junio C Hamano [Tue, 19 Jul 2016 20:22:23 +0000 (13:22 -0700)]
Merge branch 'js/am-call-theirs-theirs-in-fallback-3way'

One part of "git am" had an oddball helper function that called
stuff from outside "his" as opposed to calling what we have "ours",
which was not gender-neutral and also inconsistent with the rest of
the system where outside stuff is usuall called "theirs" in
contrast to "ours".

* js/am-call-theirs-theirs-in-fallback-3way:
  am: counteract gender bias

8 years agoMerge branch 'jk/write-file'
Junio C Hamano [Tue, 19 Jul 2016 20:22:23 +0000 (13:22 -0700)]
Merge branch 'jk/write-file'

General code clean-up around a helper function to write a
single-liner to a file.

* jk/write-file:
  branch: use write_file_buf instead of write_file
  use write_file_buf where applicable
  write_file: add format attribute
  write_file: add pointer+len variant
  write_file: use xopen
  write_file: drop "gently" form
  branch: use non-gentle write_file for branch description
  am: ignore return value of write_file()
  config: fix bogus fd check when setting up default config

8 years agoMerge branch 'jk/printf-format'
Junio C Hamano [Tue, 19 Jul 2016 20:22:22 +0000 (13:22 -0700)]
Merge branch 'jk/printf-format'

Code clean-up to avoid using a variable string that compilers may
feel untrustable as printf-style format given to write_file()
helper function.

* jk/printf-format:
  commit.c: remove print_commit_list()
  avoid using sha1_to_hex output as printf format
  walker: let walker_say take arbitrary formats

8 years agoMerge branch 'rs/help-c-source-with-gitattributes'
Junio C Hamano [Tue, 19 Jul 2016 20:22:21 +0000 (13:22 -0700)]
Merge branch 'rs/help-c-source-with-gitattributes'

The .c/.h sources are marked as such in our .gitattributes file so
that "git diff -W" and friends would work better.

* rs/help-c-source-with-gitattributes:
  .gitattributes: set file type for C files

8 years agoMerge branch 'nd/fetch-ref-summary'
Junio C Hamano [Tue, 19 Jul 2016 20:22:21 +0000 (13:22 -0700)]
Merge branch 'nd/fetch-ref-summary'

Improve the look of the way "git fetch" reports what happened to
each ref that was fetched.

* nd/fetch-ref-summary:
  fetch: reduce duplicate in ref update status lines with placeholder
  fetch: align all "remote -> local" output
  fetch: change flag code for displaying tag update and deleted ref
  fetch: refactor ref update status formatting code
  git-fetch.txt: document fetch output

8 years agoMerge branch 'jk/test-match-signal'
Junio C Hamano [Tue, 19 Jul 2016 20:22:20 +0000 (13:22 -0700)]
Merge branch 'jk/test-match-signal'

The test framework learned a new helper test_match_signal to
check an exit code from getting killed by an expected signal.

* jk/test-match-signal:
  t/lib-git-daemon: use test_match_signal
  test_must_fail: use test_match_signal
  t0005: use test_match_signal as appropriate
  tests: factor portable signal check out of t0005

8 years agoMerge branch 'jk/common-main'
Junio C Hamano [Tue, 19 Jul 2016 20:22:19 +0000 (13:22 -0700)]
Merge branch 'jk/common-main'

There are certain house-keeping tasks that need to be performed at
the very beginning of any Git program, and programs that are not
built-in commands had to do them exactly the same way as "git"
potty does.  It was easy to make mistakes in one-off standalone
programs (like test helpers).  A common "main()" function that
calls cmd_main() of individual program has been introduced to
make it harder to make mistakes.

* jk/common-main:
  mingw: declare main()'s argv as const
  common-main: call git_setup_gettext()
  common-main: call restore_sigpipe_to_default()
  common-main: call sanitize_stdfds()
  common-main: call git_extract_argv0_path()
  add an extra level of indirection to main()

8 years agoMerge branch 'ak/lazy-prereq-mktemp'
Junio C Hamano [Tue, 19 Jul 2016 20:22:18 +0000 (13:22 -0700)]
Merge branch 'ak/lazy-prereq-mktemp'

A test that unconditionally used "mktemp" learned that the command
is not necessarily available everywhere.

* ak/lazy-prereq-mktemp:
  t7610: test for mktemp before test execution

8 years agoMerge branch 'nd/icase'
Junio C Hamano [Tue, 19 Jul 2016 20:22:17 +0000 (13:22 -0700)]
Merge branch 'nd/icase'

"git grep -i" has been taught to fold case in non-ascii locales
correctly.

* nd/icase:
  grep.c: reuse "icase" variable
  diffcore-pickaxe: support case insensitive match on non-ascii
  diffcore-pickaxe: Add regcomp_or_die()
  grep/pcre: support utf-8
  gettext: add is_utf8_locale()
  grep/pcre: prepare locale-dependent tables for icase matching
  grep: rewrite an if/else condition to avoid duplicate expression
  grep/icase: avoid kwsset when -F is specified
  grep/icase: avoid kwsset on literal non-ascii strings
  test-regex: expose full regcomp() to the command line
  test-regex: isolate the bug test code
  grep: break down an "if" stmt in preparation for next changes

8 years agoMerge branch 'bc/cocci'
Junio C Hamano [Tue, 19 Jul 2016 20:22:16 +0000 (13:22 -0700)]
Merge branch 'bc/cocci'

Conversion from unsigned char sha1[20] to struct object_id
continues.

* bc/cocci:
  diff: convert prep_temp_blob() to struct object_id
  merge-recursive: convert merge_recursive_generic() to object_id
  merge-recursive: convert leaf functions to use struct object_id
  merge-recursive: convert struct merge_file_info to object_id
  merge-recursive: convert struct stage_data to use object_id
  diff: rename struct diff_filespec's sha1_valid member
  diff: convert struct diff_filespec to struct object_id
  coccinelle: apply object_id Coccinelle transformations
  coccinelle: convert hashcpy() with null_sha1 to hashclr()
  contrib/coccinelle: add basic Coccinelle transforms
  hex: add oid_to_hex_r()

8 years agoMerge branch 'js/log-to-diffopt-file'
Junio C Hamano [Tue, 19 Jul 2016 20:22:15 +0000 (13:22 -0700)]
Merge branch 'js/log-to-diffopt-file'

The commands in the "log/diff" family have had an FILE* pointer in the
data structure they pass around for a long time, but some codepaths
used to always write to the standard output.  As a preparatory step
to make "git format-patch" available to the internal callers, these
codepaths have been updated to consistently write into that FILE*
instead.

* js/log-to-diffopt-file:
  mingw: fix the shortlog --output=<file> test
  diff: do not color output when --color=auto and --output=<file> is given
  t4211: ensure that log respects --output=<file>
  shortlog: respect the --output=<file> setting
  format-patch: use stdout directly
  format-patch: avoid freopen()
  format-patch: explicitly switch off color when writing to files
  shortlog: support outputting to streams other than stdout
  graph: respect the diffopt.file setting
  line-log: respect diffopt's configured output file stream
  log-tree: respect diffopt's configured output file stream
  log: prepare log/log-tree to reuse the diffopt.close_file attribute

8 years agoMerge branch 'sb/submodule-parallel-fetch'
Junio C Hamano [Tue, 19 Jul 2016 20:22:14 +0000 (13:22 -0700)]
Merge branch 'sb/submodule-parallel-fetch'

Fix recently introduced codepaths that are involved in parallel
submodule operations, which gave up on reading too early, and
could have wasted CPU while attempting to write under a corner
case condition.

* sb/submodule-parallel-fetch:
  hoist out handle_nonblock function for xread and xwrite
  xwrite: poll on non-blocking FDs
  xread: retry after poll on EAGAIN/EWOULDBLOCK

8 years agoMerge branch 'lf/recv-sideband-cleanup'
Junio C Hamano [Tue, 19 Jul 2016 20:22:14 +0000 (13:22 -0700)]
Merge branch 'lf/recv-sideband-cleanup'

Code simplification.

* lf/recv-sideband-cleanup:
  sideband.c: small optimization of strbuf usage
  sideband.c: refactor recv_sideband()

8 years agoMerge branch 'dk/blame-move-no-reason-for-1-line-context'
Junio C Hamano [Tue, 19 Jul 2016 20:22:12 +0000 (13:22 -0700)]
Merge branch 'dk/blame-move-no-reason-for-1-line-context'

"git blame -M" missed a single line that was moved within the file.

* dk/blame-move-no-reason-for-1-line-context:
  blame: require 0 context lines while finding moved lines with -M

8 years agoMerge branch 'nd/connect-ssh-command-config'
Junio C Hamano [Tue, 19 Jul 2016 20:22:12 +0000 (13:22 -0700)]
Merge branch 'nd/connect-ssh-command-config'

A new configuration variable core.sshCommand has been added to
specify what value for GIT_SSH_COMMAND to use per repository.

* nd/connect-ssh-command-config:
  connect: read $GIT_SSH_COMMAND from config file

8 years agoarchive-tar: huge offset and future timestamps would not work on 32-bit
Junio C Hamano [Thu, 14 Jul 2016 20:04:43 +0000 (13:04 -0700)]
archive-tar: huge offset and future timestamps would not work on 32-bit

As we are not yet moving everything to size_t but still using ulong
internally when talking about the size of object, platforms with
32-bit long will not be able to produce tar archive with 4GB+ file,
and cannot grok 077777777777UL as a constant.  Disable the extended
header feature and do not test it on them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoSync with 2.9.2
Junio C Hamano [Fri, 15 Jul 2016 17:49:23 +0000 (10:49 -0700)]
Sync with 2.9.2

* maint:
  Git 2.9.2
  t0006: skip "far in the future" test when unsigned long is not long enough

8 years agoGit 2.9.2 v2.9.2
Junio C Hamano [Fri, 15 Jul 2016 17:48:16 +0000 (10:48 -0700)]
Git 2.9.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoMerge branch 'jk/tzoffset-fix' into maint
Junio C Hamano [Fri, 15 Jul 2016 16:43:42 +0000 (09:43 -0700)]
Merge branch 'jk/tzoffset-fix' into maint

Skip tests that are unrunnable on platforms without 64-bit long
to avoid unnecessary test failures.

* jk/tzoffset-fix:
  t0006: skip "far in the future" test when unsigned long is not long enough

8 years agot0006: skip "far in the future" test when unsigned long is not long enough
Jeff King [Mon, 11 Jul 2016 23:54:18 +0000 (19:54 -0400)]
t0006: skip "far in the future" test when unsigned long is not long enough

Git's source code refers to timestamps as unsigned longs.  On 32-bit
platforms, as well as on Windows, unsigned long is not large enough
to capture dates that are "absurdly far in the future".

While we can fix this issue properly by replacing unsigned long with
a larger type, we want to be a bit more conservative and just skip
those tests on the maint track.

Signed-off-by: Jeff King <peff@peff.net>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoMerge branch 'jk/upload-pack-hook'
Junio C Hamano [Thu, 14 Jul 2016 17:38:57 +0000 (10:38 -0700)]
Merge branch 'jk/upload-pack-hook'

A hot-fix to make a test working in mingw again.

* jk/upload-pack-hook:
  mingw: fix regression in t1308-config-set

8 years agomingw: fix regression in t1308-config-set
Johannes Schindelin [Thu, 14 Jul 2016 13:58:59 +0000 (15:58 +0200)]
mingw: fix regression in t1308-config-set

When we tried to fix in 58461bd (t1308: do not get fooled by symbolic
links to the source tree, 2016-06-02) an obscure case where the user
cd's into Git's source code via a symbolic link, a regression was
introduced that affects all test runs on Windows.

The original patch introducing the test case in question was careful to
use `$(pwd)` instead of `$PWD`.

This was done to account for the fact that Git's test suite uses shell
scripting even on Windows, where the shell's Unix-y paths are
incompatible with the main Git executable's idea of paths: it only
accepts Windows paths.

It is an awkward but necessary thing, then, to use `$(pwd)` (which gives
us a Windows path) when interacting with the Git executable and `$PWD`
(which gives the shell's idea of the current working directory in Unix-y
form) for shell scripts, including the test suite itself.

Obviously this broke the use case of the Git maintainer when changing
the working directory into Git's source code directory via a symlink,
i.e. when `$(pwd)` does not agree with `$PWD`.

However, we must not fix that use case at the expense of regressing
another use case.

Let's special-case Windows here, even if it is ugly, for lack of a more
elegant solution.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoFifth batch of topics for 2.10
Junio C Hamano [Wed, 13 Jul 2016 18:26:49 +0000 (11:26 -0700)]
Fifth batch of topics for 2.10

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoMerge branch 'jk/big-and-future-archive-tar'
Junio C Hamano [Wed, 13 Jul 2016 18:24:18 +0000 (11:24 -0700)]
Merge branch 'jk/big-and-future-archive-tar'

"git archive" learned to handle files that are larger than 8GB and
commits far in the future than expressible by the traditional US-TAR
format.

* jk/big-and-future-archive-tar:
  archive-tar: drop return value
  archive-tar: write extended headers for far-future mtime
  archive-tar: write extended headers for file sizes >= 8GB
  t5000: test tar files that overflow ustar headers
  t9300: factor out portable "head -c" replacement

8 years agoMerge branch 'nd/ita-cleanup'
Junio C Hamano [Wed, 13 Jul 2016 18:24:17 +0000 (11:24 -0700)]
Merge branch 'nd/ita-cleanup'

Git does not know what the contents in the index should be for a
path added with "git add -N" yet, so "git grep --cached" should not
show hits (or show lack of hits, with -L) in such a path, but that
logic does not apply to "git grep", i.e. searching in the working
tree files.  But we did so by mistake, which has been corrected.

* nd/ita-cleanup:
  grep: fix grepping for "intent to add" files
  t7810-grep.sh: fix a whitespace inconsistency
  t7810-grep.sh: fix duplicated test name

8 years agoMerge branch 'ps/rebase-i-auto-unstash-upon-abort'
Junio C Hamano [Wed, 13 Jul 2016 18:24:16 +0000 (11:24 -0700)]
Merge branch 'ps/rebase-i-auto-unstash-upon-abort'

"git rebase -i --autostash" did not restore the auto-stashed change
when the operation was aborted.

* ps/rebase-i-auto-unstash-upon-abort:
  rebase -i: restore autostash on abort

8 years agoMerge branch 'js/t3404-grammo-fix'
Junio C Hamano [Wed, 13 Jul 2016 18:24:16 +0000 (11:24 -0700)]
Merge branch 'js/t3404-grammo-fix'

Grammofix.

* js/t3404-grammo-fix:
  t3404: fix a grammo (commands are ran -> commands are run)

8 years agoMerge branch 'js/sign-empty-commit-fix'
Junio C Hamano [Wed, 13 Jul 2016 18:24:14 +0000 (11:24 -0700)]
Merge branch 'js/sign-empty-commit-fix'

"git commit --amend --allow-empty-message -S" for a commit without
any message body could have misidentified where the header of the
commit object ends.

* js/sign-empty-commit-fix:
  commit -S: avoid invalid pointer with empty message

8 years agoMerge branch 'mm/doc-tt'
Junio C Hamano [Wed, 13 Jul 2016 18:24:14 +0000 (11:24 -0700)]
Merge branch 'mm/doc-tt'

More mark-up updates to typeset strings that are expected to
literally typed by the end user in fixed-width font.

* mm/doc-tt:
  doc: typeset HEAD and variants as literal
  CodingGuidelines: formatting HEAD in documentation
  doc: typeset long options with argument as literal
  doc: typeset '--' as literal
  doc: typeset long command-line options as literal
  doc: typeset short command-line options as literal
  Documentation/git-mv.txt: fix whitespace indentation

8 years agoMerge branch 'dg/subtree-rebase-test'
Junio C Hamano [Wed, 13 Jul 2016 18:24:13 +0000 (11:24 -0700)]
Merge branch 'dg/subtree-rebase-test'

Add a test to specify the desired behaviour that currently is not
available in "git rebase -Xsubtree=...".

* dg/subtree-rebase-test:
  contrib/subtree: Add a test for subtree rebase that loses commits

8 years agoMerge branch 'nd/doc-new-command'
Junio C Hamano [Wed, 13 Jul 2016 18:24:12 +0000 (11:24 -0700)]
Merge branch 'nd/doc-new-command'

Typofix in a doc.

* nd/doc-new-command:
  new-command.txt: correct the command description file

8 years agoMerge branch 'ew/gc-auto-pack-limit-fix'
Junio C Hamano [Wed, 13 Jul 2016 18:24:12 +0000 (11:24 -0700)]
Merge branch 'ew/gc-auto-pack-limit-fix'

"gc.autoPackLimit" when set to 1 should not trigger a repacking
when there is only one pack, but the code counted poorly and did
so.

* ew/gc-auto-pack-limit-fix:
  gc: fix off-by-one error with gc.autoPackLimit

8 years agoMerge branch 'ah/unpack-trees-advice-messages'
Junio C Hamano [Wed, 13 Jul 2016 18:24:11 +0000 (11:24 -0700)]
Merge branch 'ah/unpack-trees-advice-messages'

Grammofix.

* ah/unpack-trees-advice-messages:
  unpack-trees: fix English grammar in do-this-before-that messages

8 years agoMerge branch 'va/i18n-even-more'
Junio C Hamano [Wed, 13 Jul 2016 18:24:10 +0000 (11:24 -0700)]
Merge branch 'va/i18n-even-more'

More markings of messages for i18n, with updates to various tests
to pass GETTEXT_POISON tests.

One patch from the original submission dropped due to conflicts
with jk/upload-pack-hook, which is still in flux.

* va/i18n-even-more: (38 commits)
  t5541: become resilient to GETTEXT_POISON
  i18n: branch: mark comment when editing branch description for translation
  i18n: unmark die messages for translation
  i18n: submodule: escape shell variables inside eval_gettext
  i18n: submodule: join strings marked for translation
  i18n: init-db: join message pieces
  i18n: remote: allow translations to reorder message
  i18n: remote: mark URL fallback text for translation
  i18n: standardise messages
  i18n: sequencer: add period to error message
  i18n: merge: change command option help to lowercase
  i18n: merge: mark messages for translation
  i18n: notes: mark options for translation
  i18n: notes: mark strings for translation
  i18n: transport-helper.c: change N_() call to _()
  i18n: bisect: mark strings for translation
  t5523: use test_i18ngrep for negation
  t4153: fix negated test_i18ngrep call
  t9003: become resilient to GETTEXT_POISON
  tests: unpack-trees: update to use test_i18n* functions
  ...

8 years agomingw: fix the shortlog --output=<file> test
Johannes Schindelin [Mon, 11 Jul 2016 13:11:37 +0000 (15:11 +0200)]
mingw: fix the shortlog --output=<file> test

Adjust t4201 to pass on Windows; a couple of test cases need to be
skipped on Windows which leads to a different shortlog than on Linux.

Let's just fix that by limiting the shortlog's commit range to traverse
only one commit: that guarantees that it does not matter how many test
cases were skipped.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoSync with v2.9.1
Junio C Hamano [Mon, 11 Jul 2016 17:46:39 +0000 (10:46 -0700)]
Sync with v2.9.1

* maint:
  Git 2.9.1

8 years agoGit 2.9.1 v2.9.1
Junio C Hamano [Mon, 11 Jul 2016 17:45:50 +0000 (10:45 -0700)]
Git 2.9.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoMerge branch 'jc/t2300-setup' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:19 +0000 (10:44 -0700)]
Merge branch 'jc/t2300-setup' into maint

Portability fix for Windows.

* jc/t2300-setup:
  t2300: "git --exec-path" is not usable in $PATH on Windows as-is

8 years agoMerge branch 'cb/t7810-test-label-fix' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:18 +0000 (10:44 -0700)]
Merge branch 'cb/t7810-test-label-fix' into maint

Test clean-up.

* cb/t7810-test-label-fix:
  t7810: fix duplicated test title

8 years agoMerge branch 'sb/t5614-modernize' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:17 +0000 (10:44 -0700)]
Merge branch 'sb/t5614-modernize' into maint

Test clean-up.

* sb/t5614-modernize:
  t5614: don't use subshells

8 years agoMerge branch 'jn/preformatted-doc-url' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:16 +0000 (10:44 -0700)]
Merge branch 'jn/preformatted-doc-url' into maint

The top level documentation "git help git" still pointed at the
documentation set hosted at now-defunct google-code repository.
Update it to point to https://git.github.io/htmldocs/git.html
instead.

* jn/preformatted-doc-url:
  doc: git-htmldocs.googlecode.com is no more

8 years agoMerge branch 'ao/p4-has-branch-prefix-fix' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:16 +0000 (10:44 -0700)]
Merge branch 'ao/p4-has-branch-prefix-fix' into maint

A bug, which caused "git p4" while running under verbose mode to
report paths that are omitted due to branch prefix incorrectly, has
been fixed; the command said "Ignoring file outside of prefix" for
paths that are _inside_.

* ao/p4-has-branch-prefix-fix:
  git-p4: correct hasBranchPrefix verbose output

8 years agoMerge branch 'js/perf-on-apple' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:15 +0000 (10:44 -0700)]
Merge branch 'js/perf-on-apple' into maint

t/perf needs /usr/bin/time with GNU extension; the invocation of it
is updated to "gtime" on Darwin.

* js/perf-on-apple:
  perf: accommodate for MacOSX

8 years agoMerge branch 'ak/t7800-wo-readlink' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:15 +0000 (10:44 -0700)]
Merge branch 'ak/t7800-wo-readlink' into maint

One among four invocations of readlink(1) in our test suite has
been rewritten so that the test can run on systems without the
command (others are in valgrind test framework and t9802).

* ak/t7800-wo-readlink:
  t7800: readlink may not be available

8 years agoMerge branch 'jk/tzoffset-fix' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:14 +0000 (10:44 -0700)]
Merge branch 'jk/tzoffset-fix' into maint

The internal code used to show local timezone offset is not
prepared to handle timestamps beyond year 2100, and gave a
bogus offset value to the caller.  Use a more benign looking
+0000 instead and let "git log" going in such a case, instead
of aborting.

* jk/tzoffset-fix:
  local_tzoffset: detect errors from tm_to_time_t
  t0006: test various date formats
  t0006: rename test-date's "show" to "relative"

8 years agoMerge branch 'js/mingw-parameter-less-c-functions' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:13 +0000 (10:44 -0700)]
Merge branch 'js/mingw-parameter-less-c-functions' into maint

Some platform-specific code had non-ANSI strict declarations of C
functions that do not take any parameters, which has been
corrected.

* js/mingw-parameter-less-c-functions:
  mingw: let the build succeed with DEVELOPER=1

8 years agoMerge branch 'lc/shell-default-value-noexpand' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:13 +0000 (10:44 -0700)]
Merge branch 'lc/shell-default-value-noexpand' into maint

Fix unnecessarily waste in the idiomatic use of ': ${VAR=default}'
to set the default value, without enclosing it in double quotes.

* lc/shell-default-value-noexpand:
  sh-setup: enclose setting of ${VAR=default} in double-quotes

8 years agoMerge branch 'sb/clone-shallow-passthru' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:12 +0000 (10:44 -0700)]
Merge branch 'sb/clone-shallow-passthru' into maint

Fix an unintended regression in v2.9 that breaks "clone --depth"
that recurses down to submodules by forcing the submodules to also
be cloned shallowly, which many server instances that host upstream
of the submodules are not prepared for.

* sb/clone-shallow-passthru:
  clone: do not let --depth imply --shallow-submodules

8 years agoMerge branch 'mg/signature-doc' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:11 +0000 (10:44 -0700)]
Merge branch 'mg/signature-doc' into maint

Formats of the various data (and how to validate them) where we use
GPG signature have been documented.

* mg/signature-doc:
  Documentation/technical: signed merge tag format
  Documentation/technical: signed commit format
  Documentation/technical: signed tag format
  Documentation/technical: describe signature formats

8 years agoMerge branch 'jk/bisect-show-tree' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:11 +0000 (10:44 -0700)]
Merge branch 'jk/bisect-show-tree' into maint

"git bisect" makes an internal call to "git diff-tree" when
bisection finds the culprit, but this call did not initialize the
data structure to pass to the diff-tree API correctly.

* jk/bisect-show-tree:
  bisect: always call setup_revisions after init_revisions

8 years agoMerge branch 'km/fetch-do-not-free-remote-name' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:10 +0000 (10:44 -0700)]
Merge branch 'km/fetch-do-not-free-remote-name' into maint

The ownership rule for the piece of memory that hold references to
be fetched in "git fetch" was screwy, which has been cleaned up.

* km/fetch-do-not-free-remote-name:
  builtin/fetch.c: don't free remote->name after fetch

8 years agoMerge branch 'nd/graph-width-padded' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:09 +0000 (10:44 -0700)]
Merge branch 'nd/graph-width-padded' into maint

"log --graph --format=" learned that "%>|(N)" specifies the width
relative to the terminal's left edge, not relative to the area to
draw text that is to the right of the ancestry-graph section.  It
also now accepts negative N that means the column limit is relative
to the right border.

* nd/graph-width-padded:
  pretty.c: support <direction>|(<negative number>) forms
  pretty: pass graph width to pretty formatting for use in '%>|(N)'

8 years agoMerge branch 'jk/add-i-diff-compact-heuristics' into maint
Junio C Hamano [Mon, 11 Jul 2016 17:44:09 +0000 (10:44 -0700)]
Merge branch 'jk/add-i-diff-compact-heuristics' into maint

"git add -i/-p" learned to honor diff.compactionHeuristic
experimental knob, so that the user can work on the same hunk split
as "git diff" output.

* jk/add-i-diff-compact-heuristics:
  add--interactive: respect diff.compactionHeuristic

8 years agoFourth batch of topics for 2.10
Junio C Hamano [Mon, 11 Jul 2016 17:36:29 +0000 (10:36 -0700)]
Fourth batch of topics for 2.10

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoMerge branch 'master' of git://bogomips.org/git-svn
Junio C Hamano [Mon, 11 Jul 2016 17:31:52 +0000 (10:31 -0700)]
Merge branch 'master' of git://bogomips.org/git-svn

* 'master' of git://bogomips.org/git-svn:
  git-svn: warn instead of dying when commit data is missing
  git-svn: clone: Fail on missing url argument

8 years agoMerge branch 'js/color-on-windows-comment'
Junio C Hamano [Mon, 11 Jul 2016 17:31:09 +0000 (10:31 -0700)]
Merge branch 'js/color-on-windows-comment'

For a long time, we carried an in-code comment that said our
colored output would work only when we use fprintf/fputs on
Windows, which no longer is the case for the past few years.

* js/color-on-windows-comment:
  color.h: remove obsolete comment about limitations on Windows

8 years agoMerge branch 'mj/log-show-signature-conf'
Junio C Hamano [Mon, 11 Jul 2016 17:31:08 +0000 (10:31 -0700)]
Merge branch 'mj/log-show-signature-conf'

"git log" learns log.showSignature configuration variable, and a
command line option "--no-show-signature" to countermand it.

* mj/log-show-signature-conf:
  log: add log.showSignature configuration variable
  log: add "--no-show-signature" command line option
  t4202: refactor test

8 years agoMerge branch 'js/find-commit-subject-ignore-leading-blanks'
Junio C Hamano [Mon, 11 Jul 2016 17:31:07 +0000 (10:31 -0700)]
Merge branch 'js/find-commit-subject-ignore-leading-blanks'

A helper function that takes the contents of a commit object and
finds its subject line did not ignore leading blank lines, as is
commonly done by other codepaths.  Make it ignore leading blank
lines to match.

* js/find-commit-subject-ignore-leading-blanks:
  reset --hard: skip blank lines when reporting the commit subject
  sequencer: use skip_blank_lines() to find the commit subject
  commit -C: skip blank lines at the beginning of the message
  commit.c: make find_commit_subject() more robust
  pretty: make the skip_blank_lines() function public

8 years agoMerge branch 'jn/preformatted-doc-url'
Junio C Hamano [Mon, 11 Jul 2016 17:31:06 +0000 (10:31 -0700)]
Merge branch 'jn/preformatted-doc-url'

The top level documentation "git help git" still pointed at the
documentation set hosted at now-defunct google-code repository.
Update it to point to https://git.github.io/htmldocs/git.html
instead.

* jn/preformatted-doc-url:
  doc: git-htmldocs.googlecode.com is no more

8 years agoMerge branch 'jk/perf-any-version'
Junio C Hamano [Mon, 11 Jul 2016 17:31:06 +0000 (10:31 -0700)]
Merge branch 'jk/perf-any-version'

Allow t/perf framework to use the features from the most recent
version of Git even when testing an older installed version.

* jk/perf-any-version:
  p4211: explicitly disable renames in no-rename test
  t/perf: fix regression in testing older versions of git

8 years agoMerge branch 'jk/ansi-color'
Junio C Hamano [Mon, 11 Jul 2016 17:31:05 +0000 (10:31 -0700)]
Merge branch 'jk/ansi-color'

The output coloring scheme learned two new attributes, italic and
strike, in addition to existing bold, reverse, etc.

* jk/ansi-color:
  color: support strike-through attribute
  color: support "italic" attribute
  color: allow "no-" for negating attributes
  color: refactor parse_attr
  add skip_prefix_mem helper
  doc: refactor description of color format
  color: fix max-size comment

8 years agoMerge branch 'sb/submodule-clone-retry'
Junio C Hamano [Mon, 11 Jul 2016 17:31:04 +0000 (10:31 -0700)]
Merge branch 'sb/submodule-clone-retry'

"git submodule update" that drives many "git clone" could
eventually hit flaky servers/network conditions on one of the
submodules; the command learned to retry the attempt.

* sb/submodule-clone-retry:
  submodule update: continue when a clone fails
  submodule--helper: initial clone learns retry logic

8 years agoMerge branch 'jc/send-email-skip-backup'
Junio C Hamano [Mon, 11 Jul 2016 17:31:04 +0000 (10:31 -0700)]
Merge branch 'jc/send-email-skip-backup'

A careless invocation of "git send-email directory/" after editing
0001-change.patch with an editor often ends up sending both
0001-change.patch and its backup file, 0001-change.patch~, causing
embarrassment and a minor confusion.  Detect such an input and
offer to skip the backup files when sending the patches out.

* jc/send-email-skip-backup:
  send-email: detect and offer to skip backup files

8 years agohoist out handle_nonblock function for xread and xwrite
Eric Wong [Sun, 10 Jul 2016 08:20:46 +0000 (08:20 +0000)]
hoist out handle_nonblock function for xread and xwrite

At least for me, this improves the readability of xread and
xwrite; hopefully allowing missing "continue" statements to
be spotted more easily.

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agogit-svn: warn instead of dying when commit data is missing
Eric Wong [Sat, 2 Jul 2016 10:33:18 +0000 (10:33 +0000)]
git-svn: warn instead of dying when commit data is missing

It is possible to have refs globbed by git-svn which stores data
purely in git; gently skip those instead of dying and assuming
user error.

ref: http://mid.gmane.org/CALi1mtdtNF_GtzyPTbfb7N51wwxsFY7zm8hsgwxr3tHcZZboyg@mail.gmail.com

Suggested-by: Jacob Godserv <jacobgodserv@gmail.com>
Cc: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agogit-p4: place temporary refs used for branch import under refs/git-p4-tmp
Lars Schneider [Wed, 29 Jun 2016 07:35:27 +0000 (09:35 +0200)]
git-p4: place temporary refs used for branch import under refs/git-p4-tmp

Git-P4 used to place temporary refs under "git-p4-tmp". Since 3da1f37
Git checks that all refs are placed under "refs". Instruct Git-P4 to
place temporary refs under "refs/git-p4-tmp". There are no backwards
compatibility considerations as these refs are transient.

Use "git show-ref --verify" to check the (non-)existience of the refs
instead of file checks assuming the file-based ref backend.

All refs under "refs" are shared across all worktrees. This is not
desired for temporary Git-P4 refs and will be adressed in a later patch.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Reviewed-by: Vitor Antunes <vitor.hda@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoam: counteract gender bias
Johannes Schindelin [Fri, 8 Jul 2016 07:17:34 +0000 (09:17 +0200)]
am: counteract gender bias

Since 47f0b6d5 (Fall back to three-way merge when applying a patch.,
2005-10-06), i.e. for almost 11 years already, we used a male form
to describe "the other tree".

While it was unintended, this gave the erroneous impression as if
the Git developers thought of users as male, and were unaware of the
important role in software development played by female actors such
as Ada Lovelace, Grace Hopper and Margaret Hamilton. In fact, the
first professional software developers were all female.

Let's change those unfortunate references to the gender neutral
"their tree".  Doing so also makes the fallback_merge_recursive(),
which is an oddball, more in line with the other parts of the system
where we contrast what we have vs what we obtain from others by
saying "ours" vs "theirs".  This inconsistency was also unintended.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agocommit.c: remove print_commit_list()
Junio C Hamano [Fri, 8 Jul 2016 17:09:28 +0000 (10:09 -0700)]
commit.c: remove print_commit_list()

The helper function tries to offer a way to conveniently show the
last one differently from others, presumably to allow you to say
something like

A, B, and C.

while iterating over a list that has these three elements.

However, there is only one caller, and it passes the same format
string "%s\n" for both the last one and the other ones.  Retire the
helper function and update the caller with a simplified version.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoavoid using sha1_to_hex output as printf format
Jeff King [Fri, 8 Jul 2016 10:35:15 +0000 (06:35 -0400)]
avoid using sha1_to_hex output as printf format

We know that it should not contain any percent-signs, but
it's a good habit not to feed non-literals to printf
formatters.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agowalker: let walker_say take arbitrary formats
Jeff King [Fri, 8 Jul 2016 09:25:23 +0000 (05:25 -0400)]
walker: let walker_say take arbitrary formats

We take a printf-style format and a single "char *"
parameter, and the format must therefore have at most one
"%s" in it. Besides being error-prone (and tickling
-Wformat-nonliteral), this is unnecessarily restrictive. We
can just provide the usual varargs interface.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agobranch: use write_file_buf instead of write_file
Jeff King [Fri, 8 Jul 2016 09:16:53 +0000 (05:16 -0400)]
branch: use write_file_buf instead of write_file

If we already have a strbuf, then using write_file_buf is a
little nicer to read (no wondering whether "%s" will eat
your NULs), and it's more efficient (no extra formatting
step).

We don't care about the newline magic of write_file(), as we
have our own multi-line content.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agouse write_file_buf where applicable
Jeff King [Fri, 8 Jul 2016 09:12:55 +0000 (05:12 -0400)]
use write_file_buf where applicable

There are several places where we open a file, write some
content from a strbuf, and close it. These can be simplified
with write_file_buf(). As a bonus, many of these did not
catch write problems at close() time.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agowrite_file: add format attribute
Jeff King [Fri, 8 Jul 2016 09:12:42 +0000 (05:12 -0400)]
write_file: add format attribute

This gives us compile-time checking of our format strings,
which is a good thing.

I had also hoped it would help with confusing write_file()
and write_file_buf(), since the former's "..." can make it
match the signature of the latter. But given that the buffer
for write_file_buf() is generally not a string literal, the
compiler won't complain unless -Wformat-nonliteral is on,
and that creates a ton of false positives elsewhere in the
code base.

While we're there, let's also give the function a docstring,
which it never had.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agowrite_file: add pointer+len variant
Jeff King [Fri, 8 Jul 2016 09:12:22 +0000 (05:12 -0400)]
write_file: add pointer+len variant

There are many callsites which could use write_file, but for
which it is a little awkward because they have a strbuf or
other pointer/len combo. Specifically:

 1. write_file() takes a format string, so we have to use
    "%s" or "%.*s", which are ugly.

 2. Using any form of "%s" does not handle embedded NULs in
    the output. That probably doesn't matter for our
    call-sites, but it's nicer not to have to worry.

 3. It's less efficient; we format into another strbuf
    just to do the write. That's probably not measurably
    slow for our uses, but it's simply inelegant.

We can fix this by providing a helper to write out the
formatted buffer, and just calling it from write_file().

Note that we don't do the usual "complete with a newline"
that write_file does. If the caller has their own buffer,
there's a reasonable chance they're doing something more
complicated than a single line, and they can call
strbuf_complete_line() themselves.

We could go even further and add strbuf_write_file(), but it
doesn't save much:

  -  write_file_buf(path, sb.buf, sb.len);
  +  strbuf_write_file(&sb, path);

It would also be somewhat asymmetric with strbuf_read_file,
which actually returns errors rather than dying (and the
error handling is most of the benefit of write_file() in the
first place).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agowrite_file: use xopen
Jeff King [Fri, 8 Jul 2016 09:10:08 +0000 (05:10 -0400)]
write_file: use xopen

This simplifies the code a tiny bit, and provides consistent
error messages with other users of xopen().

While we're here, let's also switch to using O_WRONLY. We
know we're only going to open/write/close the file, so
there's no point in asking for O_RDWR.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agowrite_file: drop "gently" form
Jeff King [Fri, 8 Jul 2016 09:09:34 +0000 (05:09 -0400)]
write_file: drop "gently" form

There are no callers left of write_file_gently(). Let's drop
it, as it doesn't seem likely for new callers to be added
(since its inception, the only callers who wanted the gentle
form generally just died immediately themselves, and have
since been converted).

While we're there, let's also drop the "int" return from
write_file, as it is never meaningful (in the non-gentle
form, we always either die or return 0).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agobranch: use non-gentle write_file for branch description
Jeff King [Fri, 8 Jul 2016 09:08:54 +0000 (05:08 -0400)]
branch: use non-gentle write_file for branch description

We use write_file_gently() to do this job currently.
However, if we see an error, we simply complain via
error_errno() and then end up exiting with an error code.

By switching to the non-gentle form, the function will die
for us, with a better error. It is more specific about which
syscall caused the error, and that mentions the
actual filename we're trying to write.

Our exit code for the error case does switch from "1" to
"128", but that's OK; it wasn't a meaningful documented code
(and in fact it was odd that it was a different exit code
than most other error conditions).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoam: ignore return value of write_file()
René Scharfe [Fri, 8 Jul 2016 09:08:05 +0000 (05:08 -0400)]
am: ignore return value of write_file()

write_file() either returns 0 or dies, so there is no point in checking
its return value.  The callers of the wrappers write_state_text(),
write_state_count() and write_state_bool() consequently already ignore
their return values.  Stop pretending we care and make them void.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoconfig: fix bogus fd check when setting up default config
Jeff King [Fri, 8 Jul 2016 09:06:50 +0000 (05:06 -0400)]
config: fix bogus fd check when setting up default config

Since 9830534 (config --global --edit: create a template
file if needed, 2014-07-25), an edit of the global config
file will try to open() it with O_EXCL, and wants to handle
three cases:

  1. We succeeded; the user has no config file, and we
     should fill in the default template.

  2. We got EEXIST; they have a file already, proceed as usual.

  3. We got another error; we should complain.

However, the check for case 1 does "if (fd)", which will
generally _always_ be true (except for the oddball case that
somehow our stdin got closed and opening really did give us
a new descriptor 0).

So in the EEXIST case, we tried to write the default config
anyway! Fortunately, this turns out to be a noop, since we
just end up writing to and closing "-1", which does nothing.

But in case 3, we would fail to notice any other errors, and
just silently continue (given that we don't actually notice
write errors for the template either, it's probably not that
big a deal; we're about to spawn the editor, so it would
notice any problems. But the code is clearly _trying_ to hit
cover this case and failing).

We can fix it easily by using "fd >= 0" for case 1.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years ago.gitattributes: set file type for C files
René Scharfe [Thu, 7 Jul 2016 20:11:50 +0000 (22:11 +0200)]
.gitattributes: set file type for C files

Set the diff attribute for C source file to "cpp" in order to improve
git's ability to determine hunk headers.  In particular it helps avoid
showing unindented labels in hunk headers.  That in turn is useful for
git diff -W and git grep -W, which show whole functions now instead of
stopping at a label.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agosideband.c: small optimization of strbuf usage
Nicolas Pitre [Tue, 5 Jul 2016 20:35:50 +0000 (16:35 -0400)]
sideband.c: small optimization of strbuf usage

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoconnect: read $GIT_SSH_COMMAND from config file
Nguyễn Thái Ngọc Duy [Sun, 26 Jun 2016 11:16:35 +0000 (13:16 +0200)]
connect: read $GIT_SSH_COMMAND from config file

Similar to $GIT_ASKPASS or $GIT_PROXY_COMMAND, we also read from
config file first then fall back to $GIT_SSH_COMMAND.

This is useful for selecting different private keys targetting the
same host (e.g. github)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoThird batch of topics for 2.10
Junio C Hamano [Wed, 6 Jul 2016 20:42:58 +0000 (13:42 -0700)]
Third batch of topics for 2.10

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 years agoSync with maint
Junio C Hamano [Wed, 6 Jul 2016 20:42:37 +0000 (13:42 -0700)]
Sync with maint

* maint:
  More fixes for 2.9.1
  mailmap: use main email address for dturner

8 years agoMerge branch 'jc/t2300-setup'
Junio C Hamano [Wed, 6 Jul 2016 20:38:19 +0000 (13:38 -0700)]
Merge branch 'jc/t2300-setup'

Portability fix for Windows.

* jc/t2300-setup:
  t2300: "git --exec-path" is not usable in $PATH on Windows as-is

8 years agoMerge branch 'ao/p4-has-branch-prefix-fix'
Junio C Hamano [Wed, 6 Jul 2016 20:38:19 +0000 (13:38 -0700)]
Merge branch 'ao/p4-has-branch-prefix-fix'

A bug, which caused "git p4" while running under verbose mode to
report paths that are omitted due to branch prefix incorrectly, has
been fixed; the command said "Ignoring file outside of prefix" for
paths that are _inside_.

* ao/p4-has-branch-prefix-fix:
  git-p4: correct hasBranchPrefix verbose output

8 years agoMerge branch 'cb/t7810-test-label-fix'
Junio C Hamano [Wed, 6 Jul 2016 20:38:18 +0000 (13:38 -0700)]
Merge branch 'cb/t7810-test-label-fix'

Test clean-up.

* cb/t7810-test-label-fix:
  t7810: fix duplicated test title

8 years agoMerge branch 'sb/t5614-modernize'
Junio C Hamano [Wed, 6 Jul 2016 20:38:17 +0000 (13:38 -0700)]
Merge branch 'sb/t5614-modernize'

Test clean-up.

* sb/t5614-modernize:
  t5614: don't use subshells

8 years agoMerge branch 'js/perf-on-apple'
Junio C Hamano [Wed, 6 Jul 2016 20:38:16 +0000 (13:38 -0700)]
Merge branch 'js/perf-on-apple'

t/perf needs /usr/bin/time with GNU extension; the invocation of it
is updated to "gtime" on Darwin.

* js/perf-on-apple:
  perf: accommodate for MacOSX

8 years agoMerge branch 'ak/t7800-wo-readlink'
Junio C Hamano [Wed, 6 Jul 2016 20:38:16 +0000 (13:38 -0700)]
Merge branch 'ak/t7800-wo-readlink'

One among four invocations of readlink(1) in our test suite has
been rewritten so that the test can run on systems without the
command (others are in valgrind test framework and t9802).

* ak/t7800-wo-readlink:
  t7800: readlink may not be available