gitweb.git
t3700: merge two tests into oneIngo Brückl Sat, 30 Jul 2016 20:13:48 +0000 (22:13 +0200)

t3700: merge two tests into one

Depending on the underlying platform a chmod may be a noop. Although it
wouldn't harm the result of the '--chmod=-x' test, there is a more
robust way to make sure the --chmod option works both ways.

Merge the two separate tests for the --chmod option into one, checking
both permissions on the same file.

Signed-off-by: Ingo Brückl <ib@wupperonline.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t3700: remove unwanted leftover files before running... Ingo Brückl Sat, 30 Jul 2016 20:13:38 +0000 (22:13 +0200)

t3700: remove unwanted leftover files before running new tests

When an earlier test that has prerequisite is skipped, files
used by later tests may be left in the working tree in an
unexpected state. For example, a test runs this sequence:

echo foo >xfoo1 && chmod 755 xfoo1

to create an executable file xfoo1, expecting that xfoo1
does not exist before it runs in the test sequence.
However, the absence of this file depends on "git reset
--hard" done in an earlier test, that is skipped when SANITY
prerequisite is not met, and worse yet, xfoo1 originally is
created as a symbolic link, which means the chmod does not
affect the modes of xfoo1 as this test expects.

Fix this by starting the test with "rm -f xfoo1" to make
sure the file is created from scratch, and do the same to
other similar tests.

Signed-off-by: Ingo Brückl <ib@wupperonline.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pass constants as first argument to st_mult()René Scharfe Sat, 30 Jul 2016 18:18:31 +0000 (20:18 +0200)

pass constants as first argument to st_mult()

The result of st_mult() is the same no matter the order of its
arguments. It invokes the macro unsigned_mult_overflows(), which
divides the second parameter by the first one. Pass constants
first to allow that division to be done already at compile time.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use strbuf_addstr() for adding constant strings to... René Scharfe Sat, 30 Jul 2016 17:36:23 +0000 (19:36 +0200)

use strbuf_addstr() for adding constant strings to a strbuf

Replace uses of strbuf_addf() for adding strings with more lightweight
strbuf_addstr() calls.

In http-push.c it becomes easier to see what's going on without having
to verfiy that the definition of PROPFIND_ALL_REQUEST doesn't contain
any format specifiers.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

format-patch: format.from gives the default for --fromJosh Triplett Sat, 30 Jul 2016 09:41:56 +0000 (02:41 -0700)

format-patch: format.from gives the default for --from

This helps users who would prefer format-patch to default to --from,
and makes it easier to change the default in the future.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: escape link body in format_ref_markerAndreas Brauchli Fri, 29 Jul 2016 14:49:37 +0000 (16:49 +0200)

gitweb: escape link body in format_ref_marker

Fix a case where an html link can be generated from unescaped input
resulting in invalid strict xhtml or potentially injected code.

An overview of a repo with a tag "1.0.0&0.0.1" would previously result
in an unescaped ampersand in the link body.

Signed-off-by: Andreas Brauchli <a.brauchli@elementarea.net>
Acked-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: flush output buffer even when erroring outJohannes Schindelin Mon, 1 Aug 2016 11:44:57 +0000 (13:44 +0200)

merge-recursive: flush output buffer even when erroring out

Ever since 66a155b (Enable output buffering in merge-recursive.,
2007-01-14), we had a problem: When the merge failed in a fatal way, all
regular output was swallowed because we called die() and did not get a
chance to drain the output buffers.

To fix this, several modifications were necessary:

- we needed to stop die()ing, to give callers a chance to do something
when an error occurred (in this case, flush the output buffers),

- we needed to delay printing the error message so that the caller can
print the buffered output before that, and

- we needed to make sure that the output buffers are flushed even when
the return value indicates an error.

The first two changes were introduced through earlier commits in this
patch series, and this commit addresses the third one.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge_trees(): ensure that the callers release output... Johannes Schindelin Mon, 1 Aug 2016 11:44:53 +0000 (13:44 +0200)

merge_trees(): ensure that the callers release output buffer

The recursive merge machinery accumulates its output in an output
buffer, to be flushed at the end of merge_recursive(). At this point,
we forgot to release the output buffer.

When calling merge_trees() (i.e. the non-recursive part of the recursive
merge) directly, the output buffer is never flushed because the caller
may be merge_recursive() which wants to flush the output itself.

For the same reason, merge_trees() cannot release the output buffer: it
may still be needed.

Forgetting to release the output buffer did not matter much when running
git-checkout, or git-merge-recursive, because we exited after the
operation anyway. Ever since cherry-pick learned to pick a commit range,
however, this memory leak had the potential of becoming a problem.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: offer an option to retain the output... Johannes Schindelin Mon, 1 Aug 2016 11:44:50 +0000 (13:44 +0200)

merge-recursive: offer an option to retain the output in 'obuf'

Since 66a155b (Enable output buffering in merge-recursive., 2007-01-14),
we already accumulate the output in a buffer. The idea was to avoid
interfering with the progress output that goes to stderr, which is
unbuffered, when we write to stdout, which is buffered.

We extend that buffering to allow the caller to handle the output
(possibly suppressing it). This will help us when extending the
sequencer to do rebase -i's brunt work: it does not want the picks to
print anything by default but instead determine itself whether to print
the output or not.

Note that we also redirect the error messages into the output buffer
when the caller asked not to flush the output buffer, for two reasons:
1) to retain the correct output order, and 2) to allow the caller to
suppress *all* output.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: write the commit title in one goJohannes Schindelin Mon, 1 Aug 2016 11:44:45 +0000 (13:44 +0200)

merge-recursive: write the commit title in one go

In 66a155b (Enable output buffering in merge-recursive., 2007-01-14), we
changed the code such that it prints the output in one go, to avoid
interfering with the progress output.

Let's make sure that the same holds true when outputting the commit
title: previously, we used several printf() statements to stdout and
assumed that stdout's buffer is large enough to hold the entire
commit title.

Apart from making that speculation unnecessary, we change the code to
add the message to the output buffer before flushing for another reason:
the next commit will introduce a new level of output buffering, where
the caller can request the output not to be flushed, but to be retained
for further processing.

This latter feature will be needed when teaching the sequencer to do
rebase -i's brunt work: it wants to control the output of the
cherry-picks (i.e. recursive merges).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: flush output buffer before printing... Johannes Schindelin Mon, 1 Aug 2016 11:44:37 +0000 (13:44 +0200)

merge-recursive: flush output buffer before printing error messages

The data structure passed to the recursive merge machinery has a feature
where the caller can ask for the output to be buffered into a strbuf, by
setting the field 'buffer_output'.

Previously, we died without flushing, losing accumulated output. With
this patch, we show the output first, and only then print the error
message.

Currently, the only user of that buffering is merge_recursive() itself,
to avoid the progress output to interfere.

In the next patches, we will introduce a new buffer_output mode that
forces merge_recursive() to retain the output buffer for further
processing by the caller. If the caller asked for that, we will then
also write the error messages into the output buffer. This is necessary
to give the caller more control not only how to react in case of errors
but also control how/if to display the error messages.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

patch-ids: add flag to create the diff patch id using... Kevin Willford Fri, 29 Jul 2016 16:19:19 +0000 (12:19 -0400)

patch-ids: add flag to create the diff patch id using header only data

This will allow a diff patch id to be created using only the header data
so that the contents of the file will not have to be loaded.

Signed-off-by: Kevin Willford <kcwillford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

patch-ids: replace the seen indicator with a commit... Kevin Willford Fri, 29 Jul 2016 16:19:18 +0000 (12:19 -0400)

patch-ids: replace the seen indicator with a commit pointer

The cherry_pick_list was looping through the original side checking the
seen indicator and setting the cherry_flag on the commit. If we save
off the commit in the patch_id we can set the cherry_flag on the correct
commit when running through the other side when a patch_id match is found.

Signed-off-by: Kevin Willford <kcwillford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

patch-ids: stop using a hand-rolled hashmap implementationKevin Willford Fri, 29 Jul 2016 16:19:17 +0000 (12:19 -0400)

patch-ids: stop using a hand-rolled hashmap implementation

This change will use the hashmap from the hashmap.h to keep track of the
patch_ids that have been encountered instead of using an internal
implementation. This simplifies the implementation of the patch ids.

Signed-off-by: Kevin Willford <kcwillford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-objects: compute local/ignore_pack_keep earlyJeff 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>

pack-objects: break out of want_object loop earlyJeff 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>

find_pack_entry: replace last_found_pack with MRU cacheJeff 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>

add generic most-recently-used listJeff 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>

sha1_file: drop free_pack_by_nameJeff 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>

t/perf: add tests for many-pack scenariosJeff 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>

Sync with maintJunio C Hamano Thu, 28 Jul 2016 21:21:18 +0000 (14:21 -0700)

Sync with maint

* maint:
Some fixes for 2.9.3

Eighth batch of topics for 2.10Junio C Hamano Thu, 28 Jul 2016 20:14:53 +0000 (13:14 -0700)

Eighth batch of topics for 2.10

Signed-off-by: Junio C Hamano <gitster@pobox.com>

t9100: portability fixJunio C Hamano Thu, 28 Jul 2016 21:20:13 +0000 (14:20 -0700)

t9100: portability fix

Do not say "export VAR=VAL"; "VAR=VAL && export VAR" is always more
portable.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

difftool: use Git::* functions instead of passing aroun... David Aguilar Tue, 19 Jul 2016 03:57:56 +0000 (20:57 -0700)

difftool: use Git::* functions instead of passing around state

Call Git::command() and friends directly wherever possible.
This makes it clear that these operations can be invoked directly
without needing to manage the current directory and related GIT_*
environment variables.

Eliminate find_repository() since we can now use wc_path() and
not worry about side-effects involving environment variables.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

difftool: avoid $GIT_DIR and $GIT_WORK_TREEDavid Aguilar Tue, 19 Jul 2016 03:57:55 +0000 (20:57 -0700)

difftool: avoid $GIT_DIR and $GIT_WORK_TREE

Environment variables are global and hard to reason about.
Use the `--git-dir` and `--work-tree` arguments when invoking `git`
instead of relying on the environment.

Add a test to ensure that difftool's dir-diff feature works when these
variables are present in the environment.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase-interactive: trim leading whitespace from progre... Johannes Sixt Thu, 28 Jul 2016 17:47:23 +0000 (19:47 +0200)

rebase-interactive: trim leading whitespace from progress count

Interactive rebase uses 'wc -l' to write the current patch number
in a progress report. Some implementations of 'wc -l' produce spaces
before the number, leading to ugly output such as

Rebasing ( 3/8)

Remove the spaces using a trivial arithmetic evaluation.

Before 9588c52 (i18n: rebase-interactive: mark strings for
translation) this was not a problem because printf was used to
generate the text. Since that commit, the count is interpolated
directly from a shell variable into the text, where the spaces
remain. The total number of patches does not have this problem
even though it is interpolated from a shell variable in the same
manner, because the variable is set by an arithmetic evaluation.

Later in the script, there is a virtually identical case where
leading spaces are trimmed, but it uses a pattern substitution:

todocount=$(git stripspace --strip-comments <"$todo" | wc -l)
todocount=${todocount##* }

I did not choose this idiom because it adds a line of code, and
there is already an arithmetic evaluation in the vicinity of the
line that is changed here.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'master' of git://git.bogomips.org/git-svnJunio C Hamano Thu, 28 Jul 2016 20:13:53 +0000 (13:13 -0700)

Merge branch 'master' of git://git.bogomips.org/git-svn

* 'master' of git://git.bogomips.org/git-svn:
git-svn: allow --version to work anywhere
git-svn: document svn.authorsProg in config

submodule-config: fix test binary crashing when no... Heiko Voigt Thu, 28 Jul 2016 12:50:05 +0000 (14:50 +0200)

submodule-config: fix test binary crashing when no arguments given

Since arg[0] will be NULL without any argument here and starts_with()
does not like NULL-pointers.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule-config: combine early return code into one... Heiko Voigt Thu, 28 Jul 2016 12:49:47 +0000 (14:49 +0200)

submodule-config: combine early return code into one goto

So we have simpler return handling code and all the cleanup code in
almost one place.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule-config: passing name reference for .gitmodule... Heiko Voigt Thu, 28 Jul 2016 12:49:11 +0000 (14:49 +0200)

submodule-config: passing name reference for .gitmodule blobs

Commit 959b5455 (submodule: implement a config API for lookup of
.gitmodules values, 2015-08-18) implemented the initial version of the
submodule config cache. During development of that initial version we
extracted the function gitmodule_sha1_from_commit(). During that process
we missed that the strbuf rev was still used in config_from() and now is
left empty. Lets fix this by also returning this string.

This means that now when reading .gitmodules from revisions, the error
messages also contain a reference to the blob they are from.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Some fixes for 2.9.3Junio C Hamano Thu, 28 Jul 2016 18:28:32 +0000 (11:28 -0700)

Some fixes for 2.9.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'ak/lazy-prereq-mktemp' into maintJunio C Hamano Thu, 28 Jul 2016 18:26:03 +0000 (11:26 -0700)

Merge branch 'ak/lazy-prereq-mktemp' into maint

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

Merge branch 'nd/icase' into maintJunio C Hamano Thu, 28 Jul 2016 18:26:03 +0000 (11:26 -0700)

Merge branch 'nd/icase' into maint

"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

Merge branch 'sb/submodule-parallel-fetch' into maintJunio C Hamano Thu, 28 Jul 2016 18:26:02 +0000 (11:26 -0700)

Merge branch 'sb/submodule-parallel-fetch' into maint

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

Merge branch 'dk/blame-move-no-reason-for-1-line-contex... Junio C Hamano Thu, 28 Jul 2016 18:26:01 +0000 (11:26 -0700)

Merge branch 'dk/blame-move-no-reason-for-1-line-context' into maint

"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

Merge branch 'jk/test-match-signal' into maintJunio C Hamano Thu, 28 Jul 2016 18:26:00 +0000 (11:26 -0700)

Merge branch 'jk/test-match-signal' into maint

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

Merge branch 'js/am-call-theirs-theirs-in-fallback... Junio C Hamano Thu, 28 Jul 2016 18:25:59 +0000 (11:25 -0700)

Merge branch 'js/am-call-theirs-theirs-in-fallback-3way' into maint

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

Merge branch 'js/t3404-grammo-fix' into maintJunio C Hamano Thu, 28 Jul 2016 18:25:58 +0000 (11:25 -0700)

Merge branch 'js/t3404-grammo-fix' into maint

Grammofix.

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

Merge branch 'nd/doc-new-command' into maintJunio C Hamano Thu, 28 Jul 2016 18:25:57 +0000 (11:25 -0700)

Merge branch 'nd/doc-new-command' into maint

Typofix in a doc.

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

Merge branch 'ew/gc-auto-pack-limit-fix' into maintJunio C Hamano Thu, 28 Jul 2016 18:25:56 +0000 (11:25 -0700)

Merge branch 'ew/gc-auto-pack-limit-fix' into maint

"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

Merge branch 'js/color-on-windows-comment' into maintJunio C Hamano Thu, 28 Jul 2016 18:25:55 +0000 (11:25 -0700)

Merge branch 'js/color-on-windows-comment' into maint

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

Merge branch 'mm/doc-tt' into maintJunio C Hamano Thu, 28 Jul 2016 18:25:54 +0000 (11:25 -0700)

Merge branch 'mm/doc-tt' into maint

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

Merge branch 'js/sign-empty-commit-fix' into maintJunio C Hamano Thu, 28 Jul 2016 18:25:53 +0000 (11:25 -0700)

Merge branch 'js/sign-empty-commit-fix' into maint

"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

Merge branch 'ps/rebase-i-auto-unstash-upon-abort'... Junio C Hamano Thu, 28 Jul 2016 18:25:52 +0000 (11:25 -0700)

Merge branch 'ps/rebase-i-auto-unstash-upon-abort' into maint

"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

Merge branch 'nd/ita-cleanup' into maintJunio C Hamano Thu, 28 Jul 2016 18:25:51 +0000 (11:25 -0700)

Merge branch 'nd/ita-cleanup' into maint

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

Merge branch 'js/find-commit-subject-ignore-leading... Junio C Hamano Thu, 28 Jul 2016 18:25:50 +0000 (11:25 -0700)

Merge branch 'js/find-commit-subject-ignore-leading-blanks' into maint

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

Merge branch 'dg/subtree-rebase-test' into maintJunio C Hamano Thu, 28 Jul 2016 18:25:49 +0000 (11:25 -0700)

Merge branch 'dg/subtree-rebase-test' into maint

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

Merge branch 'sb/submodule-deinit-all'Junio C Hamano Thu, 28 Jul 2016 17:34:45 +0000 (10:34 -0700)

Merge branch 'sb/submodule-deinit-all'

A comment update for a topic that was merged to Git v2.8.

* sb/submodule-deinit-all:
submodule deinit: remove outdated comment

Merge branch 'ew/find-perl-on-freebsd-in-local'Junio C Hamano Thu, 28 Jul 2016 17:34:44 +0000 (10:34 -0700)

Merge branch 'ew/find-perl-on-freebsd-in-local'

Recent FreeBSD stopped making perl available at /usr/bin/perl;
switch the default the built-in path to /usr/local/bin/perl on not
too ancient FreeBSD releases.

* ew/find-perl-on-freebsd-in-local:
config.mak.uname: correct perl path on FreeBSD

Merge branch 'ew/daemon-socket-keepalive'Junio C Hamano Thu, 28 Jul 2016 17:34:43 +0000 (10:34 -0700)

Merge branch 'ew/daemon-socket-keepalive'

Recent update to "git daemon" tries to enable the socket-level
KEEPALIVE, but when it is spawned via inetd, the standard input
file descriptor may not necessarily be connected to a socket.
Suppress an ENOTSOCK error from setsockopt().

* ew/daemon-socket-keepalive:
Windows: add missing definition of ENOTSOCK
daemon: ignore ENOTSOCK from setsockopt

Merge branch 'nd/pack-ofs-4gb-limit'Junio C Hamano Thu, 28 Jul 2016 17:34:42 +0000 (10:34 -0700)

Merge branch 'nd/pack-ofs-4gb-limit'

"git pack-objects" and "git index-pack" mostly operate with off_t
when talking about the offset of objects in a packfile, but there
were a handful of places that used "unsigned long" to hold that
value, leading to an unintended truncation.

* nd/pack-ofs-4gb-limit:
fsck: use streaming interface for large blobs in pack
pack-objects: do not truncate result in-pack object size on 32-bit systems
index-pack: correct "offset" type in unpack_entry_data()
index-pack: report correct bad object offsets even if they are large
index-pack: correct "len" type in unpack_data()
sha1_file.c: use type off_t* for object_info->disk_sizep
pack-objects: pass length to check_pack_crc() without truncation

Merge branch 'nd/worktree-lock'Junio C Hamano Thu, 28 Jul 2016 17:34:41 +0000 (10:34 -0700)

Merge branch 'nd/worktree-lock'

"git worktree prune" protected worktrees that are marked as
"locked" by creating a file in a known location. "git worktree"
command learned a dedicated command pair to create and remove such
a file, so that the users do not have to do this with editor.

* nd/worktree-lock:
worktree.c: find_worktree() search by path suffix
worktree: add "unlock" command
worktree: add "lock" command
worktree.c: add is_worktree_locked()
worktree.c: add is_main_worktree()
worktree.c: add find_worktree()

Merge branch 'rs/notes-merge-no-toctou'Junio C Hamano Thu, 28 Jul 2016 17:34:41 +0000 (10:34 -0700)

Merge branch 'rs/notes-merge-no-toctou'

"git notes merge" had a code to see if a path exists (and fails if
it does) and then open the path for writing (when it doesn't).
Replace it with open with O_EXCL.

* rs/notes-merge-no-toctou:
notes-merge: use O_EXCL to avoid overwriting existing files

Merge branch 'js/rebase-i-tests'Junio C Hamano Thu, 28 Jul 2016 17:34:40 +0000 (10:34 -0700)

Merge branch 'js/rebase-i-tests'

A few tests that specifically target "git rebase -i" have been
added.

* js/rebase-i-tests:
rebase -i: we allow extra spaces after fixup!/squash!
rebase -i: demonstrate a bug with --autosquash
t3404: add a test for the --gpg-sign option

i18n: config: unfold error messages marked for translationVasco Almeida Thu, 28 Jul 2016 13:14:03 +0000 (13:14 +0000)

i18n: config: unfold error messages marked for translation

Introduced in 473166b ("config: add 'origin_type' to config_source
struct", 2016-02-19), Git can inform the user about the origin of a
config error, but the implementation does not allow translators to
translate the keywords 'file', 'blob, 'standard input', and
'submodule-blob'. Moreover, for the second message, a reason for the
error is appended to the message, not allowing translators to translate
that reason either.

Unfold the message into several templates for each known origin_type.
That would result in better translation at the expense of code
verbosity.

Add enum config_oringin_type to ease management of the various
configuration origin types (blob, file, etc). Previously origin type
was considered from command line if cf->origin_type == NULL, i.e.,
uninitialized. Now we set origin_type to CONFIG_ORIGIN_CMDLINE in
git_config_from_parameters() and configset_add_value().

For error message in git_parse_source(), use xstrfmt() function to
prepare the message string, instead of doing something like it's done
for die_bad_number(), because intelligibility and code conciseness are
improved for that instance.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

i18n: notes: mark comment for translationVasco Almeida Thu, 28 Jul 2016 11:26:15 +0000 (11:26 +0000)

i18n: notes: mark comment for translation

Mark comment displayed when editing a note for translation.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

subtree: adjust function definitions to match CodingGui... David Aguilar Thu, 28 Jul 2016 00:16:50 +0000 (17:16 -0700)

subtree: adjust function definitions to match CodingGuidelines

We prefer a space between the function name and the parentheses, and no
space inside the parentheses.

The opening "{" should also be on the same line.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

subtree: adjust style to match CodingGuidelinesDavid Aguilar Thu, 28 Jul 2016 00:16:49 +0000 (17:16 -0700)

subtree: adjust style to match CodingGuidelines

Prefer "test" over "[ ... ]", use double-quotes around variables, break
long lines, and properly indent "case" statements.

Helped-by: Johannes Sixt <j6t@kdbg.org>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

date: clarify --date=raw descriptionJunio C Hamano Wed, 27 Jul 2016 20:07:29 +0000 (13:07 -0700)

date: clarify --date=raw description

"... in the internal raw Git format `%s %z` format." was clunky in
repeating "format" twice, and would not have helped those who do not
immediately get that these are strftime(3) conversion specifiers.

Explain them with words, and demote the mention of `%s %z` to a
hint to help those who know them.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

date: add "unix" formatJeff King Fri, 22 Jul 2016 19:51:49 +0000 (15:51 -0400)

date: add "unix" format

We already have "--date=raw", which is a Unix epoch
timestamp plus a contextual timezone (either the author's or
the local). But one may not care about the timezone and just
want the epoch timestamp by itself. It's not hard to parse
the two apart, but if you are using a pretty-print format,
you may want git to show the "finished" form that the user
will see.

We can accomodate this by adding a new date format, "unix",
which is basically "raw" without the timezone.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

date: document and test "raw-local" modeJeff King Wed, 27 Jul 2016 13:44:41 +0000 (09:44 -0400)

date: document and test "raw-local" mode

The "raw" format shows a Unix epoch timestamp, but with a
timezone tacked on. The timestamp is not _in_ that zone, but
it is extra information about the time (by default, the zone
the author was in).

The documentation claims that "raw-local" does not work. It
does, but the end result is rather subtle. Let's describe it
in better detail, and test to make sure it works (namely,
the epoch time doesn't change, but the zone does).

While we are rewording the documentation in this area, let's
not use the phrase "does not work" for the remaining option,
"--date=relative". It's vague; do we accept it or not? We do
accept it, but it has no effect (which is a reasonable
outcome). We should also refer to the option not as
"--relative" (which is the historical synonym, and does not
take "-local" at all), but as "--date=relative".

Helped-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t4205: indent here documentsJeff King Wed, 27 Jul 2016 18:55:23 +0000 (14:55 -0400)

t4205: indent here documents

Our usual style in the test scripts is to indent here
documents with tabs, and use "<<-" to strip the tabs. The
result is easier to read.

This old test script did not do so in its inception, and
further tests added onto it followed the local style. Let's
bring it in line with our usual style.

Some of the tests actually care quite a bit about
whitespace, but none of them do so at the beginning of the
line (because they use things like qz_to_tab_space to avoid
depending on the literal whitespace), so we can do a fairly
mechanical conversion.

Most of the here-docs also use interpolation, so they have
been left as "<<-EOF". In a few cases, though, where
interpolation was not in use, I've converted them to
"<<-\EOF" to match our usual "don't interpolate unless you
need to" style.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t4205: drop top-level &&-chainingJeff King Wed, 27 Jul 2016 18:55:02 +0000 (14:55 -0400)

t4205: drop top-level &&-chaining

The test currently does something like:

do_one() &&
do_two() &&
test_expect_success ...

We generally avoid performing actions at the top-level of
the script (outside of a test_expect block) for two reasons:

1. The test harness is not checking and reporting if they
fail.

2. Their output is not handled correctly (not hidden by
default, nor shown with "-v").

Using &&-chains seems like it should help with (1), but it
doesn't. If either of the commands fails, we simply skip
running the follow-on test entirely, and the test harness
has no idea.

We can fix this by pushing that setup into its own block.
It _could_ go into the following test block, but since the
result in this case is used by multiple tests, it's more
clear to mark it explicitly as a distinct setup step.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: add option '--recurse-submodules' to 'git... Chris Packham Wed, 27 Jul 2016 08:34:06 +0000 (20:34 +1200)

completion: add option '--recurse-submodules' to 'git clone'

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

subtree: fix "git subtree split --rejoin"David Aguilar Tue, 26 Jul 2016 04:14:15 +0000 (21:14 -0700)

subtree: fix "git subtree split --rejoin"

"git merge" in v2.9 prevents merging unrelated histories.

"git subtree split --rejoin" creates unrelated histories when
creating a split repo from a raw sub-directory that did not
originate from an invocation of "git subtree add".

Restore the original behavior by passing --allow-unrelated-histories
when merging subtrees. This ensures that the synthetic history
created by "git subtree split" can be merged.

Add a test to ensure that this feature works as advertised.

Reported-by: Brett Cundal <brett.cundal@iugome.com>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7900-subtree.sh: fix quoting and broken && chainsDavid Aguilar Tue, 26 Jul 2016 04:14:14 +0000 (21:14 -0700)

t7900-subtree.sh: fix quoting and broken && chains

Allow whitespace in arguments to subtree_test_create_repo.
Add missing && chains.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule deinit: remove outdated commentStefan Beller Tue, 26 Jul 2016 00:35:38 +0000 (17:35 -0700)

submodule deinit: remove outdated comment

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: allow pushing new branches with --force-with... John Keeping Tue, 26 Jul 2016 20:44:45 +0000 (21:44 +0100)

push: allow pushing new branches with --force-with-lease

If there is no upstream information for a branch, it is likely that it
is newly created and can safely be pushed under the normal fast-forward
rules. Relax the --force-with-lease check so that we do not reject
these branches immediately but rather attempt to push them as new
branches, using the null SHA-1 as the expected value.

In fact, it is already possible to push new branches using the explicit
--force-with-lease=<branch>:<expect> syntax, so all we do here is make
this behaviour the default if no explicit "expect" value is specified.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: add shorthand for --force-with-lease branch creationJohn Keeping Tue, 26 Jul 2016 20:44:44 +0000 (21:44 +0100)

push: add shorthand for --force-with-lease branch creation

Allow the empty string to stand in for the null SHA-1 when pushing a new
branch, like we do when deleting branches.

This means that the following command ensures that `new-branch` is
created on the remote (that is, is must not already exist):

git push --force-with-lease=new-branch: origin new-branch

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: describe that --no-verify skips the commit... Orgad Shaneh Tue, 26 Jul 2016 14:00:15 +0000 (17:00 +0300)

commit: describe that --no-verify skips the commit-msg hook in the help text

This brings the short help in line with the documentation.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

am -3: use merge_recursive() directly againJohannes Schindelin Tue, 26 Jul 2016 16:06:30 +0000 (18:06 +0200)

am -3: use merge_recursive() directly again

Last October, we had to change this code to run `git merge-recursive`
in a child process: git-am wants to print some helpful advice when the
merge failed, but the code in question was not prepared to return, it
die()d instead.

We are finally at a point when the code *is* prepared to return errors,
and can avoid the child process again.

This reverts commit c63d4b2 (am -3: do not let failed merge from
completing the error codepath, 2015-10-09), with the necessary changes
to adjust for the fact that Git's source code changed in the meantime
(such as: using OIDs instead of hashes in the recursive merge, and a
removed gender bias).

Note: the code now calls merge_recursive_generic() again. Unlike
merge_trees() and merge_recursive(), this function returns 0 upon success,
as most of Git's functions. Therefore, the error value -1 naturally is
handled correctly, and we do not have to take care of it specifically.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: switch to returning errors instead... Johannes Schindelin Tue, 26 Jul 2016 16:06:26 +0000 (18:06 +0200)

merge-recursive: switch to returning errors instead of dying

The recursive merge machinery is supposed to be a library function, i.e.
it should return an error when it fails. Originally the functions were
part of the builtin "merge-recursive", though, where it was simpler to
call die() and be done with error handling.

The existing callers were already prepared to detect negative return
values to indicate errors and to behave as previously: exit with code 128
(which is the same thing that die() does, after printing the message).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: handle return values indicating errorsJohannes Schindelin Tue, 26 Jul 2016 16:06:21 +0000 (18:06 +0200)

merge-recursive: handle return values indicating errors

We are about to libify the recursive merge machinery, where we only
die() in case of a bug or memory contention. To that end, we must heed
negative return values as indicating errors.

This requires our functions to be careful to pass through error
conditions in call chains, and for quite a few functions this means
that they have to return values to begin with.

The next step will be to convert the places where we currently die() to
return negative values (read: -1) instead.

Note that we ignore errors reported by make_room_for_path(), consistent
with the previous behavior (update_file_flags() used the return value of
make_room_for_path() only to indicate an early return, but not a fatal
error): if the error is really a fatal error, we will notice later; If
not, it was not that serious a problem to begin with. (Witnesses in
favor of this reasoning are t4151-am-abort and t7610-mergetool, which
would start failing if we stopped on errors reported by
make_room_for_path()).

Also note: while this patch makes the code slightly less readable in
update_file_flags() (we introduce a new "goto free_buf;" instead of
an explicit "free(buf); return;"), it is a preparatory change for
the next patch where we will convert all of the die() calls in the same
function to go through the free_buf return path instead.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: allow write_tree_from_memory() to... Johannes Schindelin Tue, 26 Jul 2016 16:06:17 +0000 (18:06 +0200)

merge-recursive: allow write_tree_from_memory() to error out

It is possible that a tree cannot be written (think: disk full). We
will want to give the caller a chance to clean up instead of letting
the program die() in such a case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: avoid returning a wholesale structJohannes Schindelin Tue, 26 Jul 2016 16:06:10 +0000 (18:06 +0200)

merge-recursive: avoid returning a wholesale struct

It is technically allowed, as per C89, for functions' return type to
be complete structs (i.e. *not* just pointers to structs).

However, it was just an oversight of this developer when converting
Python code to C code in 6d297f8 (Status update on merge-recursive in
C, 2006-07-08) which introduced such a return type.

Besides, by converting this construct to pass in the struct, we can now
start returning a value that can indicate errors in future patches. This
will help the current effort to libify merge-recursive.c.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge_recursive: abort properly upon errorsJohannes Schindelin Tue, 26 Jul 2016 16:06:07 +0000 (18:06 +0200)

merge_recursive: abort properly upon errors

There are a couple of places where return values never indicated errors
before, as we simply died instead of returning.

But now negative return values mean that there was an error and we have to
abort the operation. Let's do exactly that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

prepare the builtins for a libified merge_recursive()Johannes Schindelin Tue, 26 Jul 2016 16:06:02 +0000 (18:06 +0200)

prepare the builtins for a libified merge_recursive()

Previously, callers of merge_trees() or merge_recursive() expected that
code to die() with an error message. This used to be okay because we
called those commands from scripts, and had a chance to print out a
message in case the command failed fatally (read: with exit code 128).

As scripting incurs its own set of problems (portability, speed,
idiosyncrasies of different shells, limited data structures leading to
inefficient code), we are converting more and more of these scripts into
builtins, using library functions directly.

We already tried to use merge_recursive() directly in the builtin
git-am, for example. Unfortunately, we had to roll it back temporarily
because some of the code in merge-recursive.c still deemed it okay to
call die(), when the builtin am code really wanted to print out a useful
advice after the merge failed fatally. In the next commits, we want to
fix that.

The code touched by this commit expected merge_trees() to die() with
some useful message when there is an error condition, but merge_trees()
is going to be improved by converting all die() calls to return error()
instead (i.e. return value -1 after printing out the message as before),
so that the caller can react more flexibly.

This is a step to prepare for the version of merge_trees() that no
longer dies, even if we just imitate the previous behavior by calling
exit(128): this is what callers of e.g. `git merge` have come to expect.

Note that the callers of the sequencer (revert and cherry-pick) already
fail fast even for the return value -1; The only difference is that they
now get a chance to say "<command> failed".

A caller of merge_trees() might want handle error messages themselves
(or even suppress them). As this patch is already complex enough, we
leave that change for a later patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: clarify code in was_tracked()Johannes Schindelin Tue, 26 Jul 2016 16:05:57 +0000 (18:05 +0200)

merge-recursive: clarify code in was_tracked()

It can be puzzling to see that was_tracked() asks to get an index entry
by name, but does not take a negative return value for an answer.

The reason we have to do this is that cache_name_pos() only looks for
entries in stage 0, even if nobody asked for any stage in particular.

Let's rewrite the logic a little bit, to handle the easy case early: if
cache_name_pos() returned a non-negative position, we know it is a match,
and we do not even have to compare the name again (cache_name_pos() did
that for us already). We can say right away: yes, this file was tracked.

Only if there was no exact match do we need to look harder for any
matching entry in stage 2.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

die(_("BUG")): avoid translating bug messagesJohannes Schindelin Tue, 26 Jul 2016 16:05:53 +0000 (18:05 +0200)

die(_("BUG")): avoid translating bug messages

While working on the patch series that avoids die()ing in recursive
merges, the issue came up that bug reports (i.e. die("BUG: ...")
constructs) should never be translated, as the target audience is the
Git developer community, not necessarily the current user, and hence
a translated message would make it *harder* to address the problem.

So let's stop translating the obvious ones. As it is really, really
outside the purview of this patch series to see whether there are more
die() statements that report bugs and are currently translated, that
task is left for another day and patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

die("bug"): report bugs consistentlyJohannes Schindelin Tue, 26 Jul 2016 16:05:50 +0000 (18:05 +0200)

die("bug"): report bugs consistently

The vast majority of error messages in Git's source code which report a
bug use the convention to prefix the message with "BUG:".

As part of cleaning up merge-recursive to stop die()ing except in case of
detected bugs, let's just make the remainder of the bug reports consistent
with the de facto rule.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5520: verify that `pull --rebase` shows the helpful... Johannes Schindelin Tue, 26 Jul 2016 16:05:43 +0000 (18:05 +0200)

t5520: verify that `pull --rebase` shows the helpful advice when failing

It was noticed by Brendan Forster last October that the builtin `git am`
regressed on that. Our hot fix reverted to spawning the recursive merge
instead of using it as a library function.

As we are about to revert that hot fix, after making the recursive merge a
true library function (i.e. a function that does not die() in case of
"normal" errors), let's add a test that verifies that we do not regress on
the same problem which made the hot fix necessary in the first place.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5510: skip tests under GETTEXT_POISON buildVasco Almeida Tue, 26 Jul 2016 12:58:54 +0000 (12:58 +0000)

t5510: skip tests under GETTEXT_POISON build

Skip tests when running under GETTEXT_POISON build and run them with
C_LOCALE_OUTPUT prerequisite.

These tests are irrelevant under GETTEXT_POISON because they test text
output alignment which GETTEXT_POISON turns useless.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config.mak.uname: correct perl path on FreeBSDNguyễn Thái Ngọc Duy Mon, 25 Jul 2016 16:21:25 +0000 (18:21 +0200)

config.mak.uname: correct perl path on FreeBSD

It looks the the symlink /usr/bin/perl (to /usr/local/bin/perl) has
been removed at least on FreeBSD 10.3. See [1] for more information.

[1] https://svnweb.freebsd.org/ports/head/UPDATING?r1=386270&r2=386269&pathrev=386270&diff_format=c

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Helped-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-push: fix placeholder formattingJohn Keeping Mon, 25 Jul 2016 21:59:55 +0000 (22:59 +0100)

Documentation/git-push: fix placeholder formatting

Format the placeholder as monospace to match other occurrences in this
file and obey CodingGuidelines.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Seventh batch of topics for 2.10Junio C Hamano Mon, 25 Jul 2016 21:17:28 +0000 (14:17 -0700)

Seventh batch of topics for 2.10

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'rs/use-strbuf-addbuf'Junio C Hamano Mon, 25 Jul 2016 21:13:47 +0000 (14:13 -0700)

Merge branch 'rs/use-strbuf-addbuf'

Code cleanup.

* rs/use-strbuf-addbuf:
strbuf: avoid calling strbuf_grow() twice in strbuf_addbuf()
use strbuf_addbuf() for appending a strbuf to another

Merge branch 'ew/autoconf-pthread'Junio C Hamano Mon, 25 Jul 2016 21:13:46 +0000 (14:13 -0700)

Merge branch 'ew/autoconf-pthread'

Existing autoconf generated test for the need to link with pthread
library did not check all the functions from pthread libraries;
recent FreeBSD has some functions in libc but not others, and we
mistakenly thought linking with libc is enough when it is not.

* ew/autoconf-pthread:
configure.ac: stronger test for pthread linkage

Merge branch 'mh/blame-worktree'Junio C Hamano Mon, 25 Jul 2016 21:13:45 +0000 (14:13 -0700)

Merge branch 'mh/blame-worktree'

"git blame file" allowed the lineage of lines in the uncommitted,
unadded contents of "file" to be inspected, but it refused when
"file" did not appear in the current commit. When "file" was
created by renaming an existing file (but the change has not been
committed), this restriction was unnecessarily tight.

* mh/blame-worktree:
t/t8003-blame-corner-cases.sh: Use here documents
blame: allow to blame paths freshly added to the index

Merge branch 'js/fsck-name-object'Junio C Hamano Mon, 25 Jul 2016 21:13:44 +0000 (14:13 -0700)

Merge branch 'js/fsck-name-object'

When "git fsck" reports a broken link (e.g. a tree object contains
a blob that does not exist), both containing object and the object
that is referred to were reported with their 40-hex object names.
The command learned the "--name-objects" option to show the path to
the containing object from existing refs (e.g. "HEAD~24^2:file.txt").

* js/fsck-name-object:
fsck: optionally show more helpful info for broken links
fsck: give the error function a chance to see the fsck_options
fsck_walk(): optionally name objects on the go
fsck: refactor how to describe objects

Merge branch 'nd/cache-tree-ita'Junio C Hamano Mon, 25 Jul 2016 21:13:44 +0000 (14:13 -0700)

Merge branch 'nd/cache-tree-ita'

"git add -N dir/file && git write-tree" produced an incorrect tree
when there are other paths in the same directory that sorts after
"file".

* nd/cache-tree-ita:
cache-tree: do not generate empty trees as a result of all i-t-a subentries
cache-tree.c: fix i-t-a entry skipping directory updates sometimes
test-lib.sh: introduce and use $EMPTY_BLOB
test-lib.sh: introduce and use $EMPTY_TREE

Merge branch 'jk/push-scrub-url'Junio C Hamano Mon, 25 Jul 2016 21:13:43 +0000 (14:13 -0700)

Merge branch 'jk/push-scrub-url'

"git fetch http://user:pass@host/repo..." scrubbed the userinfo
part, but "git push" didn't.

* jk/push-scrub-url:
t5541: fix url scrubbing test when GPG is not set
push: anonymize URL in status output

Merge branch 'nd/test-helpers'Junio C Hamano Mon, 25 Jul 2016 21:13:42 +0000 (14:13 -0700)

Merge branch 'nd/test-helpers'

Build clean-up.

* nd/test-helpers:
t/test-lib.sh: fix running tests with --valgrind
Makefile: use VCSSVN_LIB to refer to svn library
Makefile: drop extra dependencies for test helpers

Merge branch 'jc/doc-diff-filter-exclude'Junio C Hamano Mon, 25 Jul 2016 21:13:41 +0000 (14:13 -0700)

Merge branch 'jc/doc-diff-filter-exclude'

Belated doc update for a feature added in v1.8.5.

* jc/doc-diff-filter-exclude:
diff: document diff-filter exclusion

Merge branch 'ls/travis-enable-httpd-tests'Junio C Hamano Mon, 25 Jul 2016 21:13:39 +0000 (14:13 -0700)

Merge branch 'ls/travis-enable-httpd-tests'

Allow http daemon tests in Travis CI tests.

* ls/travis-enable-httpd-tests:
travis-ci: enable web server tests t55xx on Linux

Merge branch 'jc/renormalize-merge-kill-safer-crlf'Junio C Hamano Mon, 25 Jul 2016 21:13:38 +0000 (14:13 -0700)

Merge branch 'jc/renormalize-merge-kill-safer-crlf'

"git merge" with renormalization did not work well with
merge-recursive, due to "safer crlf" conversion kicking in when it
shouldn't.

* jc/renormalize-merge-kill-safer-crlf:
merge: avoid "safer crlf" during recording of merge results
convert: unify the "auto" handling of CRLF

Merge branch 'rs/worktree-use-strbuf-absolute-path'Junio C Hamano Mon, 25 Jul 2016 21:13:37 +0000 (14:13 -0700)

Merge branch 'rs/worktree-use-strbuf-absolute-path'

Code simplification.

* rs/worktree-use-strbuf-absolute-path:
worktree: use strbuf_add_absolute_path() directly

Merge branch 'rs/rm-strbuf-optim'Junio C Hamano Mon, 25 Jul 2016 21:13:36 +0000 (14:13 -0700)

Merge branch 'rs/rm-strbuf-optim'

The use of strbuf in "git rm" to build filename to remove was a bit
suboptimal, which has been fixed.

* rs/rm-strbuf-optim:
rm: reuse strbuf for all remove_dir_recursively() calls

Merge branch 'rw/make-needs-librt'Junio C Hamano Mon, 25 Jul 2016 21:13:35 +0000 (14:13 -0700)

Merge branch 'rw/make-needs-librt'

Makefile assumed that -lrt is always available on platforms that
want to use clock_gettime() and CLOCK_MONOTONIC, which is not a
case for recent Mac OS X. The necessary symbols are often found in
libc on many modern systems and having -lrt on the command line, as
long as the library exists, had no effect, but when the platform
removes librt.a that is a different matter--having -lrt will break
the linkage.

This change could be seen as a regression for those who do need to
specify -lrt, as they now specifically ask for NEEDS_LIBRT when
building. Hopefully they are in the minority these days.

* rw/make-needs-librt:
config.mak.uname: define NEEDS_LIBRT under Linux, for now
Makefile: add NEEDS_LIBRT to optionally link with librt

Merge branch 'js/ignore-space-at-eol'Junio C Hamano Mon, 25 Jul 2016 21:13:35 +0000 (14:13 -0700)

Merge branch 'js/ignore-space-at-eol'

An age old bug that caused "git diff --ignore-space-at-eol"
misbehave has been fixed.

* js/ignore-space-at-eol:
diff: fix a double off-by-one with --ignore-space-at-eol
diff: demonstrate a bug with --patience and --ignore-space-at-eol

Merge branch 'mh/ref-iterators'Junio C Hamano Mon, 25 Jul 2016 21:13:33 +0000 (14:13 -0700)

Merge branch 'mh/ref-iterators'

The API to iterate over all the refs (i.e. for_each_ref(), etc.)
has been revamped.

* mh/ref-iterators:
for_each_reflog(): reimplement using iterators
dir_iterator: new API for iterating over a directory tree
for_each_reflog(): don't abort for bad references
do_for_each_ref(): reimplement using reference iteration
refs: introduce an iterator interface
ref_resolves_to_object(): new function
entry_resolves_to_object(): rename function from ref_resolves_to_object()
get_ref_cache(): only create an instance if there is a submodule
remote rm: handle symbolic refs correctly
delete_refs(): add a flags argument
refs: use name "prefix" consistently
do_for_each_ref(): move docstring to the header file
refs: remove unnecessary "extern" keywords