git.git
7 years agot3420-rebase-autostash: don't try to grep non-existing files
SZEDER Gábor [Wed, 22 Aug 2018 18:13:20 +0000 (20:13 +0200)]
t3420-rebase-autostash: don't try to grep non-existing files

Several tests in 't3420-rebase-autostash.sh' start various rebase
processes that are expected to fail because of merge conflicts.  These
tests then run '! grep' to ensure that the autostash feature did its
job, and the dirty contents of a file is gone.  However, due to the
test repo's history and the choice of upstream branch that file
shouldn't exist in the conflicted state at all.  Consequently, this
'grep' doesn't fail as expected, because it can't find the dirty
content, but it fails because it can't open the file.

Tighten this check by using 'test_path_is_missing' instead, thereby
avoiding unexpected errors from 'grep' as well.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot3903-stash: don't try to grep non-existing file
SZEDER Gábor [Wed, 22 Aug 2018 18:13:19 +0000 (20:13 +0200)]
t3903-stash: don't try to grep non-existing file

The test 'store updates stash ref and reflog' in 't3903-stash.sh'
creates a stash from a new file, runs 'git reset --hard' to throw away
any modifications to the work tree, and then runs '! grep' to ensure
that the staged contents are gone.  Since the file didn't exist
before, it shouldn't exist after 'git reset' either.  Consequently,
this 'grep' doesn't fail as expected, because it can't find the staged
content, but it fails because it can't open the file.

Tighten this check by using 'test_path_is_missing' instead, thereby
avoiding an unexpected error from 'grep' as well.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'nd/pack-deltify-regression-fix'
Junio C Hamano [Wed, 22 Aug 2018 18:17:05 +0000 (11:17 -0700)]
Merge branch 'nd/pack-deltify-regression-fix'

In a recent update in 2.18 era, "git pack-objects" started
producing a larger than necessary packfiles by missing
opportunities to use large deltas.

* nd/pack-deltify-regression-fix:
  pack-objects: fix performance issues on packing large deltas

7 years agot6018-rev-list-glob: fix 'empty stdin' test
SZEDER Gábor [Wed, 22 Aug 2018 17:48:20 +0000 (19:48 +0200)]
t6018-rev-list-glob: fix 'empty stdin' test

Prior to d3c6751b18 (tests: make use of the test_must_be_empty
function, 2018-07-27), in the test 'rev-list should succeed with empty
output on empty stdin' in 't6018-rev-list-glob' the empty 'expect'
file served dual purpose: besides specifying the expected output, as
usual, it also served as empty input for 'git rev-list --stdin'.

Then d3c6751b18 came along, and, as part of the conversion to
'test_must_be_empty', removed this empty 'expect' file, not realizing
its secondary purpose.  Redirecting stdin from the now non-existing
file failed the test, but since this test expects failure in the first
place, this issue went unnoticed.

Redirect 'git rev-list's stdin explicitly from /dev/null to provide
empty input.  (Strictly speaking we don't need this redirection,
because the test script's stdin is already redirected from /dev/null
anyway, but I think it's better to be explicit about it.)

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot4051-diff-function-context: read the right file
SZEDER Gábor [Wed, 22 Aug 2018 12:44:37 +0000 (14:44 +0200)]
t4051-diff-function-context: read the right file

The test ' context does not include preceding empty lines' in the
block of tests 'change with long common tail and no context' in
't4051-diff-function-context.sh' tries to read the file
'long_common_tail.diff.diff', but that file doesn't exist as its name
contains one more '.diff' suffixes than necessary.

Despite this error the test still succeeded without checking what it's
supposed to, because this erroneous read is done on the line:

  test "$(first_context_line <long_common_tail.diff.diff)" != " "

which means that:

  - the command substitution hides the error, so it won't fail the
    test, and

  - the result of the command substitution is the empty string, which
    is, of course, not equal to a single space character, so the
    condition is fulfilled, and the test succeeds.

As a minimal fix, fix the name of the file to be read.

In the future we might want to reorganize this test script (1) to use
'test_cmp' instead of 'test's and command substitutions to catch
failing commands and to provide helpful error messages, and (2) to
specify what the expected result actually _is_ instead of what it
isn't.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot0020-crlf: check the right file
SZEDER Gábor [Wed, 22 Aug 2018 12:44:36 +0000 (14:44 +0200)]
t0020-crlf: check the right file

In the test 'checkout with autocrlf=input' in 't0020-crlf.sh', one of
the 'has_cr' checks looks at the non-existing file 'two' instead of
'dir/two'.  The test still succeeds, without actually checking what it
was supposed to, because this check is expected to fail anyway.

As a minimal fix, fix the name of the file to be checked.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot7501-commit: drop silly command substitution
SZEDER Gábor [Tue, 21 Aug 2018 23:28:11 +0000 (01:28 +0200)]
t7501-commit: drop silly command substitution

The test '--dry-run with conflicts fixed from a merge' in
't7501-commit.sh', added in 8dc874b2ee (wt-status.c: set commitable
bit if there is a meaningful merge., 2016-02-15), runs the following
unnecessary and downright bogus command substitution:

  ! $(git merge --no-commit commit-1) &&

I.e. after 'git merge ...' is executed and expectedly fails, the test
attempts to execute its output:

  Merging:
  80f2ea2 commit 2
  virtual commit-1
  found 1 common ancestor:
  e60d113 Initial commit
  Auto-merging test-file
  CONFLICT (content): Merge conflict in test-file
  Automatic merge failed; fix conflicts and then commit the result.

as a command, which most likely fails, because there is no such
command as "Merging:".  Then '!' negates the failed exit status, the
test continues, and eventually succeeds.

Remove this command substitution and use 'test_must_fail' to ensure
that 'git merge' fails.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocommit: use timestamp_t for author_date_slab
Derrick Stolee [Tue, 21 Aug 2018 20:54:12 +0000 (20:54 +0000)]
commit: use timestamp_t for author_date_slab

The author_date_slab is used to store the author date of a commit
when walking with the --author-date flag in rev-list or log. This
was added as an 'unsigned long' in

81c6b38b "log: --author-date-order"

Since 'unsigned long' is ambiguous in its bit-ness across platforms
(64-bit in Linux, 32-bit in Windows, for example), most references
to the author dates in commit.c were converted to timestamp_t in

dddbad72 "timestamp_t: a new data type for timestamps"

However, the slab definition was missed, leading to a mismatch in
the data types in Windows. This would not reveal itself as a bug
unless someone authors a commit after February 2106, but commits
can store anything as their author date.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoSubmittingPatches: mention doc-diff
Jeff King [Tue, 21 Aug 2018 19:23:22 +0000 (15:23 -0400)]
SubmittingPatches: mention doc-diff

We already advise people to make sure their documentation
formats correctly. Let's point them at the doc-diff script,
which can help with that.

Let's also put a brief note in the script about its purpose,
since that otherwise can only be found in the original
commit message. Along with the existing -h/usage text,
that's hopefully enough for developers to make use of it.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agopack-objects: reuse on-disk deltas for thin "have" objects
Jeff King [Tue, 21 Aug 2018 19:07:05 +0000 (15:07 -0400)]
pack-objects: reuse on-disk deltas for thin "have" objects

When we serve a fetch, we pass the "wants" and "haves" from
the fetch negotiation to pack-objects. That tells us not
only which objects we need to send, but we also use the
boundary commits as "preferred bases": their trees and blobs
are candidates for delta bases, both for reusing on-disk
deltas and for finding new ones.

However, this misses some opportunities. Modulo some special
cases like shallow or partial clones, we know that every
object reachable from the "haves" could be a preferred base.
We don't use all of them for two reasons:

  1. It's expensive to traverse the whole history and
     enumerate all of the objects the other side has.

  2. The delta search is expensive, so we want to keep the
     number of candidate bases sane. The boundary commits
     are the most likely to work.

When we have reachability bitmaps, though, reason 1 no
longer applies. We can efficiently compute the set of
reachable objects on the other side (and in fact already did
so as part of the bitmap set-difference to get the list of
interesting objects). And using this set conveniently
covers the shallow and partial cases, since we have to
disable the use of bitmaps for those anyway.

The second reason argues against using these bases in the
search for new deltas. But there's one case where we can use
this information for free: when we have an existing on-disk
delta that we're considering reusing, we can do so if we
know the other side has the base object. This in fact saves
time during the delta search, because it's one less delta we
have to compute.

And that's exactly what this patch does: when we're
considering whether to reuse an on-disk delta, if bitmaps
tell us the other side has the object (and we're making a
thin-pack), then we reuse it.

Here are the results on p5311 using linux.git, which
simulates a client fetching after `N` days since their last
fetch:

 Test                         origin              HEAD
 --------------------------------------------------------------------------
 5311.3: server   (1 days)    0.27(0.27+0.04)     0.12(0.09+0.03) -55.6%
 5311.4: size     (1 days)               0.9M              237.0K -73.7%
 5311.5: client   (1 days)    0.04(0.05+0.00)     0.10(0.10+0.00) +150.0%
 5311.7: server   (2 days)    0.34(0.42+0.04)     0.13(0.10+0.03) -61.8%
 5311.8: size     (2 days)               1.5M              347.7K -76.5%
 5311.9: client   (2 days)    0.07(0.08+0.00)     0.16(0.15+0.01) +128.6%
 5311.11: server   (4 days)   0.56(0.77+0.08)     0.13(0.10+0.02) -76.8%
 5311.12: size     (4 days)              2.8M              566.6K -79.8%
 5311.13: client   (4 days)   0.13(0.15+0.00)     0.34(0.31+0.02) +161.5%
 5311.15: server   (8 days)   0.97(1.39+0.11)     0.30(0.25+0.05) -69.1%
 5311.16: size     (8 days)              4.3M                1.0M -76.0%
 5311.17: client   (8 days)   0.20(0.22+0.01)     0.53(0.52+0.01) +165.0%
 5311.19: server  (16 days)   1.52(2.51+0.12)     0.30(0.26+0.03) -80.3%
 5311.20: size    (16 days)              8.0M                2.0M -74.5%
 5311.21: client  (16 days)   0.40(0.47+0.03)     1.01(0.98+0.04) +152.5%
 5311.23: server  (32 days)   2.40(4.44+0.20)     0.31(0.26+0.04) -87.1%
 5311.24: size    (32 days)             14.1M                4.1M -70.9%
 5311.25: client  (32 days)   0.70(0.90+0.03)     1.81(1.75+0.06) +158.6%
 5311.27: server  (64 days)   11.76(26.57+0.29)   0.55(0.50+0.08) -95.3%
 5311.28: size    (64 days)             89.4M               47.4M -47.0%
 5311.29: client  (64 days)   5.71(9.31+0.27)     15.20(15.20+0.32) +166.2%
 5311.31: server (128 days)   16.15(36.87+0.40)   0.91(0.82+0.14) -94.4%
 5311.32: size   (128 days)            134.8M              100.4M -25.5%
 5311.33: client (128 days)   9.42(16.86+0.49)    25.34(25.80+0.46) +169.0%

In all cases we save CPU time on the server (sometimes
significant) and the resulting pack is smaller. We do spend
more CPU time on the client side, because it has to
reconstruct more deltas. But that's the right tradeoff to
make, since clients tend to outnumber servers. It just means
the thin pack mechanism is doing its job.

From the user's perspective, the end-to-end time of the
operation will generally be faster. E.g., in the 128-day
case, we saved 15s on the server at a cost of 16s on the
client. Since the resulting pack is 34MB smaller, this is a
net win if the network speed is less than 270Mbit/s. And
that's actually the worst case. The 64-day case saves just
over 11s at a cost of just under 11s. So it's a slight win
at any network speed, and the 40MB saved is pure bonus. That
trend continues for the smaller fetches.

The implementation itself is mostly straightforward, with
the new logic going into check_object(). But there are two
tricky bits.

The first is that check_object() needs access to the
relevant information (the thin flag and bitmap result). We
can do this by pushing these into program-lifetime globals.

The second is that the rest of the code assumes that any
reused delta will point to another "struct object_entry" as
its base. But of course the case we are interested in here
is the one where don't have such an entry!

I looked at a number of options that didn't quite work:

 - we could use a flag to signal a reused delta, but it's
   not a single bit. We have to actually store the oid of
   the base, which is normally done by pointing to the
   existing object_entry. And we'd have to modify all the
   code which looks at deltas.

 - we could add the reused bases to the end of the existing
   object_entry array. While this does create some extra
   work as later stages consider the extra entries, it's
   actually not too bad (we're not sending them, so they
   don't cost much in the delta search, and at most we'd
   have 2*N of them).

   But there's a more subtle problem. Adding to the existing
   array means we might need to grow it with realloc, which
   could move the earlier entries around. While many of the
   references to other entries are done by integer index,
   some (including ones on the stack) use pointers, which
   would become invalidated.

   This isn't insurmountable, but it would require quite a
   bit of refactoring (and it's hard to know that you've got
   it all, since it may work _most_ of the time and then
   fail subtly based on memory allocation patterns).

 - we could allocate a new one-off entry for the base. In
   fact, this is what an earlier version of this patch did.
   However, since the refactoring brought in by ad635e82d6
   (Merge branch 'nd/pack-objects-pack-struct', 2018-05-23),
   the delta_idx code requires that both entries be in the
   main packing list.

So taking all of those options into account, what I ended up
with is a separate list of "external bases" that are not
part of the main packing list. Each delta entry that points
to an external base has a single-bit flag to do so; we have a
little breathing room in the bitfield section of
object_entry.

This lets us limit the change primarily to the oe_delta()
and oe_set_delta_ext() functions. And as a bonus, most of
the rest of the code does not consider these dummy entries
at all, saving both runtime CPU and code complexity.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agopack-bitmap: save "have" bitmap from walk
Jeff King [Tue, 21 Aug 2018 19:07:01 +0000 (15:07 -0400)]
pack-bitmap: save "have" bitmap from walk

When we do a bitmap walk, we save the result, which
represents (WANTs & ~HAVEs); i.e., every object we care
about visiting in our walk. However, we throw away the
haves bitmap, which can sometimes be useful, too. Save it
and provide an access function so code which has performed a
walk can query it.

A few notes on the accessor interface:

 - the bitmap code calls these "haves" because it grew out
   of the want/have negotiation for fetches. But really,
   these are simply the objects that would be flagged
   UNINTERESTING in a regular traversal. Let's use that
   more universal nomenclature for the external module
   interface. We may want to change the internal naming
   inside the bitmap code, but that's outside the scope of
   this patch.

 - it still uses a bare "sha1" rather than "oid". That's
   true of all of the bitmap code. And in this particular
   instance, our caller in pack-objects is dealing with the
   bare sha1 that comes from a packed REF_DELTA (we're
   pointing directly to the mmap'd pack on disk). That's
   something we'll have to deal with as we transition to a
   new hash, but we can wait and see how the caller ends up
   being fixed and adjust this interface accordingly.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotest-tool.h: include git-compat-util.h
Jeff King [Tue, 21 Aug 2018 18:41:40 +0000 (14:41 -0400)]
test-tool.h: include git-compat-util.h

The test-tool programs include "test-tool.h" as their first
include, which breaks our CodingGuideline of "the first
include must be git-compat-util.h or an equivalent".

Rather than change them all, let's instead make test-tool.h
one of those equivalents, just like we do for builtin.h
(which many of the actual git builtins include first).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
SZEDER Gábor [Sun, 19 Aug 2018 21:57:25 +0000 (23:57 +0200)]
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'

Using 'test_must_be_empty' is shorter and more idiomatic than

  >empty &&
  test_cmp empty out

as it saves the creation of an empty file.  Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).

These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.

Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:

  - Sometimes the expected output is not hard-coded in the test, but
    'test_cmp' is used to ensure that two similar git commands produce
    the same output, and that output happens to be empty, e.g. the
    test 'submodule update --merge  - ignores --merge  for new
    submodules' in 't7406-submodule-update.sh'.

  - Repetitive common tasks, including preparing the expected results
    and running 'test_cmp', are often extracted into a helper
    function, and some of this helper's callsites expect no output.

  - For the same reason as above, the whole 'test_expect_success'
    block is within a helper function, e.g. in 't3070-wildmatch.sh'.

  - Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
    (-p)' in 't9400-git-cvsserver-server.sh'.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotests: use 'test_must_be_empty' instead of 'test_cmp /dev/null <out>'
SZEDER Gábor [Sun, 19 Aug 2018 21:57:24 +0000 (23:57 +0200)]
tests: use 'test_must_be_empty' instead of 'test_cmp /dev/null <out>'

Using 'test_must_be_empty' is more idiomatic than 'test_cmp /dev/null
out', and its message on error is perhaps a bit more to the point.

This patch was basically created by running:

  sed -i -e 's%test_cmp /dev/null%test_must_be_empty%' t[0-9]*.sh

with the exception of the change in 'should not fail in an empty repo'
in 't7401-submodule-summary.sh', where it was 'test_cmp output
/dev/null'.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotests: use 'test_must_be_empty' instead of 'test ! -s'
SZEDER Gábor [Sun, 19 Aug 2018 21:57:23 +0000 (23:57 +0200)]
tests: use 'test_must_be_empty' instead of 'test ! -s'

Using 'test_must_be_empty' is preferable to 'test ! -s', because it
gives a helpful error message if the given file is unexpectedly no
empty, while the latter remains completely silent.  Furthermore, it
also catches cases when the given file unexpectedly does not exist at
all.

This patch was created by:

  sed -i -e 's/test ! -s/test_must_be_empty/' t[0-9]*.sh

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotests: use 'test_must_be_empty' instead of '! test -s'
SZEDER Gábor [Sun, 19 Aug 2018 21:57:22 +0000 (23:57 +0200)]
tests: use 'test_must_be_empty' instead of '! test -s'

Using 'test_must_be_empty' is preferable to '! test -s', because it
gives a helpful error message if the given file is unexpectedly not
empty, while the latter remains completely silent.  Furthermore, it
also catches cases when the given file unexpectedly does not exist at
all.

This patch was basically created by:

  sed -i -e 's/! test -s/test_must_be_empty/' t[0-9]*.sh

with the following notable exceptions:

  - The '! test -s' check in '.gitmodules ignore=dirty suppresses
    submodules with untracked content' in 't7508-status.sh' is left
    as-is, because it's bogus and, therefore, it's subject of a
    dedicated patch.

  - The '! test -s' checks in 't9131-git-svn-empty-symlink.sh' and
    't9135-git-svn-moved-branch-empty-file.sh' are immediately
    preceeded by a 'test -f' to ensure that the files exist in the
    first place.  'test_must_be_empty' ensures that as well, so those
    'test -f' commands are removed as well.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoparseopt: group literal string alternatives in argument help
René Scharfe [Sun, 19 Aug 2018 17:34:48 +0000 (19:34 +0200)]
parseopt: group literal string alternatives in argument help

This formally clarifies that the "--option=" part is the same for all
alternatives.

Signed-off-by: Rene Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoremote: improve argument help for add --mirror
René Scharfe [Sun, 19 Aug 2018 17:34:43 +0000 (19:34 +0200)]
remote: improve argument help for add --mirror

Group the possible values using a pair of parentheses and don't mark
them for translation, as they are literal strings that have to be used
as-is in any locale.

Signed-off-by: Rene Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocheckout-index: improve argument help for --stage
René Scharfe [Sun, 19 Aug 2018 17:34:35 +0000 (19:34 +0200)]
checkout-index: improve argument help for --stage

Spell out all alternatives and avoid using a numerical range operator,
as it is not mentioned in CodingGuidelines and the resulting string is
still concise.  Wrap them in parentheses to document clearly that the
"--stage=" part is common among them.

Signed-off-by: Rene Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogenerate-cmdlist.sh: collect config from all config.txt files
Nguyễn Thái Ngọc Duy [Sun, 19 Aug 2018 10:52:10 +0000 (12:52 +0200)]
generate-cmdlist.sh: collect config from all config.txt files

This script uses Documentation/config.txt as input for "git help
--config" and "git config" completion but it misses the fact that
config.txt includes other txt files. Include all *config.txt as input
when scanning for config keys. This could produce false positives, but
as long as we stick to the blah-config.txt naming convention, we
should be ok.

While at there, move diff.* from config.txt to diff-config.txt where
all other diff config keys are.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocommit-graph: close_commit_graph before shallow walk
Derrick Stolee [Mon, 20 Aug 2018 18:24:34 +0000 (18:24 +0000)]
commit-graph: close_commit_graph before shallow walk

Call close_commit_graph() when about to start a rev-list walk that
includes shallow commits. This is necessary in code paths that "fake"
shallow commits for the sake of fetch. Specifically, test 351 in
t5500-fetch-pack.sh runs

git fetch --shallow-exclude one origin

with a file-based transfer. When the "remote" has a commit-graph, we do
not prevent the commit-graph from being loaded, but then the commits are
intended to be dynamically transferred into shallow commits during
get_shallow_commits_by_rev_list(). By closing the commit-graph before
this call, we prevent this interaction.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocommit-graph: not compatible with uninitialized repo
Derrick Stolee [Mon, 20 Aug 2018 18:24:32 +0000 (18:24 +0000)]
commit-graph: not compatible with uninitialized repo

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocommit-graph: not compatible with grafts
Derrick Stolee [Mon, 20 Aug 2018 18:24:30 +0000 (18:24 +0000)]
commit-graph: not compatible with grafts

Augment commit_graph_compatible(r) to return false when the given
repository r has commit grafts or is a shallow clone. Test that in these
situations we ignore existing commit-graph files and we do not write new
commit-graph files.

Helped-by: Jakub Narebski <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocommit-graph: not compatible with replace objects
Derrick Stolee [Mon, 20 Aug 2018 18:24:27 +0000 (18:24 +0000)]
commit-graph: not compatible with replace objects

Create new method commit_graph_compatible(r) to check if a given
repository r is compatible with the commit-graph feature. Fill the
method with a check to see if replace-objects exist. Test this
interaction succeeds, including ignoring an existing commit-graph and
failing to write a new commit-graph. However, we do ensure that
we write a new commit-graph by setting read_replace_refs to 0, thereby
ignoring the replace refs.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotest-repository: properly init repo
Derrick Stolee [Mon, 20 Aug 2018 18:24:24 +0000 (18:24 +0000)]
test-repository: properly init repo

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocommit-graph: update design document
Derrick Stolee [Mon, 20 Aug 2018 18:24:21 +0000 (18:24 +0000)]
commit-graph: update design document

As it exists right now, the commit-graph feature may provide
inconsistent results when combined with commit grafts, replace objects,
and shallow clones. Update the design document to discuss why these
interactions are difficult to reconcile and how we will avoid errors by
preventing updates to and reads from the commit-graph file when these
other features exist.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agorefs.c: upgrade for_each_replace_ref to be a each_repo_ref_fn callback
Stefan Beller [Mon, 20 Aug 2018 18:24:19 +0000 (18:24 +0000)]
refs.c: upgrade for_each_replace_ref to be a each_repo_ref_fn callback

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agorefs.c: migrate internal ref iteration to pass thru repository argument
Stefan Beller [Mon, 20 Aug 2018 18:24:16 +0000 (18:24 +0000)]
refs.c: migrate internal ref iteration to pass thru repository argument

In 60ce76d3581 (refs: add repository argument to for_each_replace_ref,
2018-04-11) and 0d296c57aec (refs: allow for_each_replace_ref to handle
arbitrary repositories, 2018-04-11), for_each_replace_ref learned how
to iterate over refs by a given arbitrary repository.
New attempts in the object store conversion have shown that it is useful
to have the repository handle available that the refs iteration is
currently iterating over.

To achieve this goal we will need to add a repository argument to
each_ref_fn in refs.h. However as many callers rely on the signature
such a patch would be too large.

So convert the internals of the ref subsystem first to pass through a
repository argument without exposing the change to the user. Assume
the_repository for the passed through repository, although it is not
used anywhere yet.

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agol10n: git.pot: v2.19.0 round 1 (382 new, 30 removed)
Jiang Xin [Tue, 21 Aug 2018 00:28:47 +0000 (08:28 +0800)]
l10n: git.pot: v2.19.0 round 1 (382 new, 30 removed)

Generate po/git.pot from v2.19.0-rc0 for git v2.19.0 l10n round 1.

Signed-off-by: Jiang Xin <redacted>
7 years agoMerge branch 'maint' of git://github.com/git-l10n/git-po
Jiang Xin [Tue, 21 Aug 2018 00:22:04 +0000 (08:22 +0800)]
Merge branch 'maint' of git://github.com/git-l10n/git-po

* 'maint' of git://github.com/git-l10n/git-po:
  l10n: de.po: translate 108 new messages
  l10n: zh_CN: review for git 2.18.0
  l10n: sv.po: Update Swedish translation(3608t0f0u)

7 years agopack-objects: consider packs in multi-pack-index
Derrick Stolee [Mon, 20 Aug 2018 16:52:08 +0000 (16:52 +0000)]
pack-objects: consider packs in multi-pack-index

When running 'git pack-objects --local', we want to avoid packing
objects that are in an alternate. Currently, we check for these
objects using the packed_git_mru list, which excludes the pack-files
covered by a multi-pack-index.

Add a new iteration over the multi-pack-indexes to find these
copies and mark them as unwanted.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomidx: test a few commands that use get_all_packs
Derrick Stolee [Mon, 20 Aug 2018 16:52:06 +0000 (16:52 +0000)]
midx: test a few commands that use get_all_packs

The new get_all_packs() method exposed the packfiles coverede by
a multi-pack-index. Before, the 'git cat-file --batch' and
'git count-objects' commands would skip objects in an environment
with a multi-pack-index.

Further, a reachability bitmap would be ignored if its pack-file
was covered by a multi-pack-index.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotreewide: use get_all_packs
Derrick Stolee [Mon, 20 Aug 2018 16:52:04 +0000 (16:52 +0000)]
treewide: use get_all_packs

There are many places in the codebase that want to iterate over
all packfiles known to Git. The purposes are wide-ranging, and
those that can take advantage of the multi-pack-index already
do. So, use get_all_packs() instead of get_packed_git() to be
sure we are iterating over all packfiles.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agopackfile: add all_packs list
Derrick Stolee [Mon, 20 Aug 2018 16:52:02 +0000 (16:52 +0000)]
packfile: add all_packs list

If a repo contains a multi-pack-index, then the packed_git list
does not contain the packfiles that are covered by the multi-pack-index.
This is important for doing object lookups, abbreviations, and
approximating object count. However, there are many operations that
really want to iterate over all packfiles.

Create a new 'all_packs' linked list that contains this list, starting
with the packfiles in the multi-pack-index and then continuing along
the packed_git linked list.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomidx: fix bug that skips midx with alternates
Derrick Stolee [Mon, 20 Aug 2018 16:52:00 +0000 (16:52 +0000)]
midx: fix bug that skips midx with alternates

The logic for constructing the linked list of multi-pack-indexes
in the object store is incorrect. If the local object store has
a multi-pack-index, but an alternate does not, then the list is
dropped.

Add tests that would have revealed this bug.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomidx: stop reporting garbage
Derrick Stolee [Mon, 20 Aug 2018 16:51:59 +0000 (16:51 +0000)]
midx: stop reporting garbage

When prepare_packed_git is called with the report_garbage method
initialized, we report unexpected files in the objects directory
as garbage. Stop reporting the multi-pack-index and the pack-files
it covers as garbage.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomidx: mark bad packed objects
Derrick Stolee [Mon, 20 Aug 2018 16:51:57 +0000 (16:51 +0000)]
midx: mark bad packed objects

When an object fails to decompress from a pack-file, we mark the object
as 'bad' so we can retry with a different copy of the object (if such a
copy exists).

Before now, the multi-pack-index did not update the bad objects list for
the pack-files it contains, and we did not check the bad objects list
when reading an object. Now, do both.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomulti-pack-index: store local property
Derrick Stolee [Mon, 20 Aug 2018 16:51:55 +0000 (16:51 +0000)]
multi-pack-index: store local property

A pack-file is 'local' if it is stored within the usual object
directory. If it is stored in an alternate, it is non-local.

Pack-files are stored using a 'pack_local' member in the packed_git
struct. Add a similar 'local' member to the multi_pack_index struct
and 'local' parameters to the methods that load and prepare multi-
pack-indexes.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomulti-pack-index: provide more helpful usage info
Derrick Stolee [Mon, 20 Aug 2018 16:51:53 +0000 (16:51 +0000)]
multi-pack-index: provide more helpful usage info

The multi-pack-index builtin has a very simple command-line
interface. Instead of simply reporting usage, give the user a
hint to why the arguments failed.

Reported-by: Eric Sunshine <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoSync 'ds/multi-pack-index' to v2.19.0-rc0
Junio C Hamano [Mon, 20 Aug 2018 22:29:54 +0000 (15:29 -0700)]
Sync 'ds/multi-pack-index' to v2.19.0-rc0

* ds/multi-pack-index: (23 commits)
  midx: clear midx on repack
  packfile: skip loading index if in multi-pack-index
  midx: prevent duplicate packfile loads
  midx: use midx in approximate_object_count
  midx: use existing midx when writing new one
  midx: use midx in abbreviation calculations
  midx: read objects from multi-pack-index
  config: create core.multiPackIndex setting
  midx: write object offsets
  midx: write object id fanout chunk
  midx: write object ids in a chunk
  midx: sort and deduplicate objects from packfiles
  midx: read pack names into array
  multi-pack-index: write pack names in chunk
  multi-pack-index: read packfile list
  packfile: generalize pack directory list
  t5319: expand test data
  multi-pack-index: load into memory
  midx: write header information to lockfile
  multi-pack-index: add 'write' verb
  ...

7 years agorange-diff: indent special lines as context
Stefan Beller [Fri, 17 Aug 2018 20:43:54 +0000 (13:43 -0700)]
range-diff: indent special lines as context

The range-diff coloring is a bit fuzzy when it comes to special lines of
a diff, such as indicating new and old files with +++ and ---, as it
would pickup the first character and interpret it for its coloring, which
seems annoying as in regular diffs, these lines are colored bold via
DIFF_METAINFO.

By indenting these lines by a white space, they will be treated as context
which is much more useful, an example [1] on the range diff series itself:

[...]
    + diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt
    + new file mode 100644
    + --- /dev/null
    + +++ b/Documentation/git-range-diff.txt
    +@@
    ++git-range-diff(1)
[...]
    +
      diff --git a/Makefile b/Makefile
      --- a/Makefile
      +++ b/Makefile
[...]

The first lines that introduce the new file for the man page will have the
'+' sign colored and the rest of the line will be bold.

The later lines that indicate a change to the Makefile will be treated as
context both in the outer and inner diff, such that those lines stay
regular color.

[1] ./git-range-diff pr-1/dscho/branch-diff-v3...pr-1/dscho/branch-diff-v4
    These tags are found at https://github.com/gitgitgadget/git

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agorange-diff: make use of different output indicators
Stefan Beller [Fri, 17 Aug 2018 20:43:53 +0000 (13:43 -0700)]
range-diff: make use of different output indicators

This change itself only changes the internal communication and should
have no visible effect to the user. We instruct the diff code that
produces the inner diffs to use other markers instead of the
usual markers for new, old and context lines.

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodiff.c: add --output-indicator-{new, old, context}
Stefan Beller [Fri, 17 Aug 2018 20:43:52 +0000 (13:43 -0700)]
diff.c: add --output-indicator-{new, old, context}

This will prove useful in range-diff in a later patch as we will be able to
differentiate between adding a new file (that line is starting with +++
and then the file name) and regular new lines.

It could also be useful for experimentation in new patch formats, i.e.
we could teach git to emit moved lines with lines other than +/-.

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot/perf: add perf tests for fetches from a bitmapped server
Jeff King [Fri, 17 Aug 2018 20:57:41 +0000 (16:57 -0400)]
t/perf: add perf tests for fetches from a bitmapped server

A server with bitmapped packs can serve a clone very
quickly. However, fetches are not necessarily made any
faster, because we spend a lot less time in object traversal
(which is what bitmaps help with) and more time finding
deltas (because we may have to throw out on-disk deltas if
the client does not have the base).

As a first step to making this faster, this patch introduces
a new perf script to measure fetches into a repo of various
ages from a fully-bitmapped server.

We separately measure the work done by the server (in
pack-objects) and that done by the client (in index-pack).
Furthermore, we measure the size of the resulting pack.

Breaking it down like this (instead of just doing a regular
"git fetch") lets us see how much each side benefits from
any changes. And since we know the pack size, if we estimate
the network speed, then one could calculate a complete
wall-clock time for the operation (though the script does
not do this automatically).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot/perf: add infrastructure for measuring sizes
Jeff King [Fri, 17 Aug 2018 20:56:37 +0000 (16:56 -0400)]
t/perf: add infrastructure for measuring sizes

The main objective of scripts in the perf framework is to
run "test_perf", which measures the time it takes to run
some operation. However, it can also be interesting to see
the change in the output size of certain operations.

This patch introduces test_size, which records a single
numeric output from the test and shows it in the aggregated
output (with pretty printing and relative size comparison).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot/perf: factor out percent calculations
Jeff King [Fri, 17 Aug 2018 20:55:24 +0000 (16:55 -0400)]
t/perf: factor out percent calculations

This will let us reuse the code when we add new values to
aggregate besides times.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot/perf: factor boilerplate out of test_perf
Jeff King [Fri, 17 Aug 2018 20:55:06 +0000 (16:55 -0400)]
t/perf: factor boilerplate out of test_perf

About half of test_perf() is boilerplate preparing to run
_any_ test, and the other half is specifically running a
timing test. Let's split it into two functions, so that we
can reuse the boilerplate in future commits.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoGit 2.19-rc0
Junio C Hamano [Mon, 20 Aug 2018 18:37:21 +0000 (11:37 -0700)]
Git 2.19-rc0

Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'ab/checkout-default-remote'
Junio C Hamano [Mon, 20 Aug 2018 19:53:46 +0000 (12:53 -0700)]
Merge branch 'ab/checkout-default-remote'

* ab/checkout-default-remote:
  t2024: mark test using "checkout -p" with PERL prerequisite

7 years agoMerge branch 'hn/highlight-sideband-keywords'
Junio C Hamano [Mon, 20 Aug 2018 19:41:34 +0000 (12:41 -0700)]
Merge branch 'hn/highlight-sideband-keywords'

The sideband code learned to optionally paint selected keywords at
the beginning of incoming lines on the receiving end.

* hn/highlight-sideband-keywords:
  sideband: do not read beyond the end of input
  sideband: highlight keywords in remote sideband output

7 years agoMerge branch 'nd/cherry-pick-quit-fix'
Junio C Hamano [Mon, 20 Aug 2018 19:41:34 +0000 (12:41 -0700)]
Merge branch 'nd/cherry-pick-quit-fix'

"git cherry-pick --quit" failed to remove CHERRY_PICK_HEAD even
though we won't be in a cherry-pick session after it returns, which
has been corrected.

* nd/cherry-pick-quit-fix:
  cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD

7 years agoMerge branch 'sb/submodule-cleanup'
Junio C Hamano [Mon, 20 Aug 2018 19:41:33 +0000 (12:41 -0700)]
Merge branch 'sb/submodule-cleanup'

A few preliminary minor clean-ups in the area around submodules.

* sb/submodule-cleanup:
  builtin/submodule--helper: remove stray new line
  t7410: update to new style

7 years agoMerge branch 'pw/rebase-i-merge-segv-fix'
Junio C Hamano [Mon, 20 Aug 2018 19:41:33 +0000 (12:41 -0700)]
Merge branch 'pw/rebase-i-merge-segv-fix'

"git rebase -i", when a 'merge <branch>' insn in its todo list
fails, segfaulted, which has been (minimally) corrected.

* pw/rebase-i-merge-segv-fix:
  rebase -i: fix SIGSEGV when 'merge <branch>' fails
  t3430: add conflicting commit

7 years agoMerge branch 'pw/rebase-i-squash-number-fix'
Junio C Hamano [Mon, 20 Aug 2018 19:41:33 +0000 (12:41 -0700)]
Merge branch 'pw/rebase-i-squash-number-fix'

When "git rebase -i" is told to squash two or more commits into
one, it labeled the log message for each commit with its number.
It correctly called the first one "1st commit", but the next one
was "commit #1", which was off-by-one.  This has been corrected.

* pw/rebase-i-squash-number-fix:
  rebase -i: fix numbering in squash message

7 years agoMerge branch 'sb/config-write-fix'
Junio C Hamano [Mon, 20 Aug 2018 19:41:32 +0000 (12:41 -0700)]
Merge branch 'sb/config-write-fix'

Recent update to "git config" broke updating variable in a
subsection, which has been corrected.

* sb/config-write-fix:
  git-config: document accidental multi-line setting in deprecated syntax
  config: fix case sensitive subsection names on writing
  t1300: document current behavior of setting options

7 years agoMerge branch 'ab/submodule-relative-url-tests'
Junio C Hamano [Mon, 20 Aug 2018 19:41:32 +0000 (12:41 -0700)]
Merge branch 'ab/submodule-relative-url-tests'

Test updates.

* ab/submodule-relative-url-tests:
  submodule: add more exhaustive up-path testing

7 years agoMerge branch 'en/incl-forward-decl'
Junio C Hamano [Mon, 20 Aug 2018 19:41:32 +0000 (12:41 -0700)]
Merge branch 'en/incl-forward-decl'

Code hygiene improvement for the header files.

* en/incl-forward-decl:
  Remove forward declaration of an enum
  compat/precompose_utf8.h: use more common include guard style
  urlmatch.h: fix include guard
  Move definition of enum branch_track from cache.h to branch.h
  alloc: make allocate_alloc_state and clear_alloc_state more consistent
  Add missing includes and forward declarations

7 years agoMerge branch 'jt/repack-promisor-packs'
Junio C Hamano [Mon, 20 Aug 2018 18:33:55 +0000 (11:33 -0700)]
Merge branch 'jt/repack-promisor-packs'

After a partial clone, repeated fetches from promisor remote would
have accumulated many packfiles marked with .promisor bit without
getting them coalesced into fewer packfiles, hurting performance.
"git repack" now learned to repack them.

* jt/repack-promisor-packs:
  repack: repack promisor objects if -a or -A is set
  repack: refactor setup of pack-objects cmd

7 years agoMerge branch 'wc/make-funnynames-shared-lazy-prereq'
Junio C Hamano [Mon, 20 Aug 2018 18:33:55 +0000 (11:33 -0700)]
Merge branch 'wc/make-funnynames-shared-lazy-prereq'

A test prerequisite defined by various test scripts with slightly
different semantics has been consolidated into a single copy and
made into a lazily defined one.

* wc/make-funnynames-shared-lazy-prereq:
  t: factor out FUNNYNAMES as shared lazy prereq

7 years agoMerge branch 'jh/partial-clone-doc'
Junio C Hamano [Mon, 20 Aug 2018 18:33:55 +0000 (11:33 -0700)]
Merge branch 'jh/partial-clone-doc'

Doc updates.

* jh/partial-clone-doc:
  partial-clone: render design doc using asciidoc

7 years agoMerge branch 'js/chain-lint-attrfix'
Junio C Hamano [Mon, 20 Aug 2018 18:33:54 +0000 (11:33 -0700)]
Merge branch 'js/chain-lint-attrfix'

Test fix.

* js/chain-lint-attrfix:
  chainlint: fix for core.autocrlf=true

7 years agoMerge branch 'sb/pull-rebase-submodule'
Junio C Hamano [Mon, 20 Aug 2018 18:33:54 +0000 (11:33 -0700)]
Merge branch 'sb/pull-rebase-submodule'

"git pull --rebase -v" in a repository with a submodule barfed as
an intermediate process did not understand what "-v(erbose)" flag
meant, which has been fixed.

* sb/pull-rebase-submodule:
  git-submodule.sh: accept verbose flag in cmd_update to be non-quiet

7 years agoMerge branch 'js/range-diff'
Junio C Hamano [Mon, 20 Aug 2018 18:33:53 +0000 (11:33 -0700)]
Merge branch 'js/range-diff'

"git tbdiff" that lets us compare individual patches in two
iterations of a topic has been rewritten and made into a built-in
command.

* js/range-diff: (21 commits)
  range-diff: use dim/bold cues to improve dual color mode
  range-diff: make --dual-color the default mode
  range-diff: left-pad patch numbers
  completion: support `git range-diff`
  range-diff: populate the man page
  range-diff --dual-color: skip white-space warnings
  range-diff: offer to dual-color the diffs
  diff: add an internal option to dual-color diffs of diffs
  color: add the meta color GIT_COLOR_REVERSE
  range-diff: use color for the commit pairs
  range-diff: add tests
  range-diff: do not show "function names" in hunk headers
  range-diff: adjust the output of the commit pairs
  range-diff: suppress the diff headers
  range-diff: indent the diffs just like tbdiff
  range-diff: right-trim commit messages
  range-diff: also show the diff between patches
  range-diff: improve the order of the shown commits
  range-diff: first rudimentary implementation
  Introduce `range-diff` to compare iterations of a topic branch
  ...

7 years agoMerge branch 'nd/no-the-index'
Junio C Hamano [Mon, 20 Aug 2018 18:33:53 +0000 (11:33 -0700)]
Merge branch 'nd/no-the-index'

The more library-ish parts of the codebase learned to work on the
in-core index-state instance that is passed in by their callers,
instead of always working on the singleton "the_index" instance.

* nd/no-the-index: (24 commits)
  blame.c: remove implicit dependency on the_index
  apply.c: remove implicit dependency on the_index
  apply.c: make init_apply_state() take a struct repository
  apply.c: pass struct apply_state to more functions
  resolve-undo.c: use the right index instead of the_index
  archive-*.c: use the right repository
  archive.c: avoid access to the_index
  grep: use the right index instead of the_index
  attr: remove index from git_attr_set_direction()
  entry.c: use the right index instead of the_index
  submodule.c: use the right index instead of the_index
  pathspec.c: use the right index instead of the_index
  unpack-trees: avoid the_index in verify_absent()
  unpack-trees: convert clear_ce_flags* to avoid the_index
  unpack-trees: don't shadow global var the_index
  unpack-trees: add a note about path invalidation
  unpack-trees: remove 'extern' on function declaration
  ls-files: correct index argument to get_convert_attr_ascii()
  preload-index.c: use the right index instead of the_index
  dir.c: remove an implicit dependency on the_index in pathspec code
  ...

7 years agoMerge branch 'es/chain-lint-more'
Junio C Hamano [Mon, 20 Aug 2018 18:33:53 +0000 (11:33 -0700)]
Merge branch 'es/chain-lint-more'

Improve built-in facility to catch broken &&-chain in the tests.

* es/chain-lint-more:
  chainlint: add test of pathological case which triggered false positive
  chainlint: recognize multi-line quoted strings more robustly
  chainlint: let here-doc and multi-line string commence on same line
  chainlint: recognize multi-line $(...) when command cuddled with "$("
  chainlint: match 'quoted' here-doc tags
  chainlint: match arbitrary here-docs tags rather than hard-coded names

7 years agoMerge branch 'sg/t5310-empty-input-fix'
Junio C Hamano [Mon, 20 Aug 2018 18:33:52 +0000 (11:33 -0700)]
Merge branch 'sg/t5310-empty-input-fix'

Test fix.

* sg/t5310-empty-input-fix:
  t5310-pack-bitmaps: fix bogus 'pack-objects to file can use bitmap' test

7 years agoMerge branch 'js/mingw-o-append'
Junio C Hamano [Mon, 20 Aug 2018 18:33:52 +0000 (11:33 -0700)]
Merge branch 'js/mingw-o-append'

Among the three codepaths we use O_APPEND to open a file for
appending, one used for writing GIT_TRACE output requires O_APPEND
implementation that behaves sensibly when multiple processes are
writing to the same file.  POSIX emulation used in the Windows port
has been updated to improve in this area.

* js/mingw-o-append:
  mingw: enable atomic O_APPEND

7 years agoMerge branch 'jk/for-each-object-iteration'
Junio C Hamano [Mon, 20 Aug 2018 18:33:52 +0000 (11:33 -0700)]
Merge branch 'jk/for-each-object-iteration'

The API to iterate over all objects learned to optionally list
objects in the order they appear in packfiles, which helps locality
of access if the caller accesses these objects while as objects are
enumerated.

* jk/for-each-object-iteration:
  for_each_*_object: move declarations to object-store.h
  cat-file: use a single strbuf for all output
  cat-file: split batch "buf" into two variables
  cat-file: use oidset check-and-insert
  cat-file: support "unordered" output for --batch-all-objects
  cat-file: rename batch_{loose,packed}_object callbacks
  t1006: test cat-file --batch-all-objects with duplicates
  for_each_packed_object: support iterating in pack-order
  for_each_*_object: give more comprehensive docstrings
  for_each_*_object: take flag arguments as enum
  for_each_*_object: store flag definitions in a single location

7 years agoMerge branch 'ab/fetch-tags-noclobber'
Junio C Hamano [Mon, 20 Aug 2018 18:33:52 +0000 (11:33 -0700)]
Merge branch 'ab/fetch-tags-noclobber'

Test and doc clean-ups.

* ab/fetch-tags-noclobber:
  pull doc: fix a long-standing grammar error
  fetch tests: correct a comment "remove it" -> "remove them"
  push tests: assert re-pushing annotated tags
  push tests: add more testing for forced tag pushing
  push tests: fix logic error in "push" test assertion
  push tests: remove redundant 'git push' invocation
  fetch tests: change "Tag" test tag to "testTag"

7 years agoMerge branch 'ng/mergetool-lose-final-prompt'
Junio C Hamano [Mon, 20 Aug 2018 18:33:51 +0000 (11:33 -0700)]
Merge branch 'ng/mergetool-lose-final-prompt'

"git mergetool" stopped and gave an extra prompt to continue after
the last path has been handled, which did not make much sense.

* ng/mergetool-lose-final-prompt:
  mergetool: don't suggest to continue after last file

7 years agoMerge branch 'jt/commit-graph-per-object-store'
Junio C Hamano [Mon, 20 Aug 2018 18:33:51 +0000 (11:33 -0700)]
Merge branch 'jt/commit-graph-per-object-store'

Test update.

* jt/commit-graph-per-object-store:
  t5318: avoid unnecessary command substitutions

7 years agoMerge branch 'ds/commit-graph-fsck'
Junio C Hamano [Mon, 20 Aug 2018 18:33:51 +0000 (11:33 -0700)]
Merge branch 'ds/commit-graph-fsck'

Test fix.

* ds/commit-graph-fsck:
  t5318: use 'test_cmp_bin' to compare commit-graph files

7 years agoMerge branch 'jt/fetch-negotiator-skipping'
Junio C Hamano [Mon, 20 Aug 2018 18:33:51 +0000 (11:33 -0700)]
Merge branch 'jt/fetch-negotiator-skipping'

Test fix.

* jt/fetch-negotiator-skipping:
  t5552: suppress upload-pack trace output

7 years agoMerge branch 'jc/gpg-status'
Junio C Hamano [Mon, 20 Aug 2018 18:33:50 +0000 (11:33 -0700)]
Merge branch 'jc/gpg-status'

"git verify-tag" and "git verify-commit" have been taught to use
the exit status of underlying "gpg --verify" to signal bad or
untrusted signature they found.

* jc/gpg-status:
  gpg-interface: propagate exit status from gpg back to the callers

7 years agoMerge branch 'jc/update-index-doc'
Junio C Hamano [Mon, 20 Aug 2018 18:33:50 +0000 (11:33 -0700)]
Merge branch 'jc/update-index-doc'

Doc update.

* jc/update-index-doc:
  update-index: there no longer is `apply --index-info`

7 years agoMerge branch 'en/update-index-doc'
Junio C Hamano [Mon, 20 Aug 2018 18:33:50 +0000 (11:33 -0700)]
Merge branch 'en/update-index-doc'

Doc update.

* en/update-index-doc:
  git-update-index.txt: reword possibly confusing example

7 years agoMerge branch 'js/typofixes'
Junio C Hamano [Mon, 20 Aug 2018 18:33:50 +0000 (11:33 -0700)]
Merge branch 'js/typofixes'

Comment update.

* js/typofixes:
  remote-curl: remove spurious period
  git-compat-util.h: fix typo

7 years agoMerge branch 'sk/instaweb-rh-update'
Junio C Hamano [Mon, 20 Aug 2018 18:33:49 +0000 (11:33 -0700)]
Merge branch 'sk/instaweb-rh-update'

"git instaweb" has been adjusted to run better with newer Apache on
RedHat based distros.

* sk/instaweb-rh-update:
  git-instaweb: fix apache2 config with apache >= 2.4
  git-instaweb: support Fedora/Red Hat apache module path

7 years agoMerge branch 'en/t7406-fixes'
Junio C Hamano [Mon, 20 Aug 2018 18:33:48 +0000 (11:33 -0700)]
Merge branch 'en/t7406-fixes'

Test fixes.

* en/t7406-fixes:
  t7406: avoid using test_must_fail for commands other than git
  t7406: prefer test_* helper functions to test -[feds]
  t7406: avoid having git commands upstream of a pipe
  t7406: simplify by using diff --name-only instead of diff --raw
  t7406: fix call that was failing for the wrong reason

7 years agoMerge branch 'js/rebase-merges-exec-fix'
Junio C Hamano [Mon, 20 Aug 2018 18:33:48 +0000 (11:33 -0700)]
Merge branch 'js/rebase-merges-exec-fix'

The "--exec" option to "git rebase --rebase-merges" placed the exec
commands at wrong places, which has been corrected.

* js/rebase-merges-exec-fix:
  rebase --exec: make it work with --rebase-merges
  t3430: demonstrate what -r, --autosquash & --exec should do

7 years agoMerge branch 'ab/test-must-be-empty-for-master'
Junio C Hamano [Mon, 20 Aug 2018 18:33:48 +0000 (11:33 -0700)]
Merge branch 'ab/test-must-be-empty-for-master'

Test updates.

* ab/test-must-be-empty-for-master:
  tests: make use of the test_must_be_empty function

7 years agoMerge branch 'ab/newhash-is-sha256'
Junio C Hamano [Mon, 20 Aug 2018 18:33:48 +0000 (11:33 -0700)]
Merge branch 'ab/newhash-is-sha256'

Documentation update.

* ab/newhash-is-sha256:
  doc hash-function-transition: pick SHA-256 as NewHash
  doc hash-function-transition: note the lack of a changelog

7 years agocache-tree: verify valid cache-tree in the test suite
Nguyễn Thái Ngọc Duy [Sat, 18 Aug 2018 14:41:28 +0000 (16:41 +0200)]
cache-tree: verify valid cache-tree in the test suite

This makes sure that cache-tree is consistent with the index. The main
purpose is to catch potential problems by saving the index in
unpack_trees() but the line in write_index() would also help spot
missing invalidation in other code.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agounpack-trees: add missing cache invalidation
Nguyễn Thái Ngọc Duy [Sat, 18 Aug 2018 14:41:27 +0000 (16:41 +0200)]
unpack-trees: add missing cache invalidation

Any changes to the output index should be (confusingly) marked in the
source index with invalidate_ce_path(). This is used to make sure we
still have valid untracked cache and cache-tree extensions in the end.

We do a pretty good job of invalidating except in two places.
verify_clean_subdirectory() is part of verify_absent() and
verify_absent_sparse(). The former is usually called by merged_entry()
or directly in threeway_merge(). The latter is obviously used by
sparse checkout.

In these three call sites, only merged_entry() follows up with
invalidate_ce_path(). The other two don't, but they should not trigger
this ce removal because this is about D/F conflicts [1]. But let's be
safe and invalidate_ce_path() here as well.

The second place is keep_entry() which is also used by threeway_merge()
to keep higher stage entries. In order to reuse cache-tree we need to
invalidate these paths as well. It's not a problem in the past because
whenever a higher stage entry is present, cache-tree will not be
created [2]. Now we salvage cache-tree even when higher stage entries
are present, we need more invalidation.

[1] c81935348b (Fix switching to a branch with D/F when current branch
    has file D. - 2007-03-15)

[2] This is probably too strict. We should be able to create and save
    cache-tree for the directories that do not have conflict entries
    in cache_tree_update(). And this becomes more important when
    cache-tree plays bigger role in terms of performance.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agounpack-trees: reuse (still valid) cache-tree from src_index
Nguyễn Thái Ngọc Duy [Sat, 18 Aug 2018 14:41:26 +0000 (16:41 +0200)]
unpack-trees: reuse (still valid) cache-tree from src_index

We do n-way merge by walking the source index and n trees at the same
time and add merge results to a new temporary index called o->result.
The merge result for any given path could be either

- keep_entry(): same old index entry in o->src_index is reused
- merged_entry(): either a new entry is added, or an existing one updated
- deleted_entry(): one entry from o->src_index is removed

For some reason [1] we keep making sure that the source index's
cache-tree is still valid if used by o->result: for all those
merged/deleted entries, we invalidate the same path in o->src_index,
so only cache-trees covering the "keep_entry" parts remain good.

Because of this, the cache-tree from o->src_index can be perfectly
reused in o->result. And in fact we already rely on this logic to
reuse untracked cache in edf3b90553 (unpack-trees: preserve index
extensions - 2017-05-08). Move the cache-tree to o->result before
doing cache_tree_update() to reduce hashing cost.

Since cache_tree_update() has risen up as one of the most expensive
parts in unpack_trees() after the last few patches. This does help
reduce unpack_trees() time significantly (on webkit.git):

    before       after
  --------------------------------------------------------------------
    0.080394752  0.051258167 s:  read cache .git/index
    0.216010838  0.212106298 s:  preload index
    0.008534301  0.280521764 s:  refresh index
    0.251992198  0.218160442 s:   traverse_trees
    0.377031383  0.374948191 s:   check_updates
    0.372768105  0.037040114 s:   cache_tree_update
    1.045887251  0.672031609 s:  unpack_trees
    0.314983512  0.317456290 s:  write index, changed mask = 2e
    0.062572653  0.038382654 s:    traverse_trees
    0.000022544  0.000042731 s:    check_updates
    0.073795585  0.050930053 s:   unpack_trees
    0.073807557  0.051099735 s:  diff-index
    1.938191592  1.614241153 s: git command: git checkout -

[1] I'm pretty sure the reason is an oversight in 34110cd4e3 (Make
    'unpack_trees()' have a separate source and destination index -
    2008-03-06). That patch aims to _not_ update the source index at
    all. The invalidation should have been done on o->result in that
    patch. But then there was no cache-tree on o->result even then so
    it's pointless to do so.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agounpack-trees: reduce malloc in cache-tree walk
Nguyễn Thái Ngọc Duy [Sat, 18 Aug 2018 14:41:25 +0000 (16:41 +0200)]
unpack-trees: reduce malloc in cache-tree walk

This is a micro optimization that probably only shines on repos with
deep directory structure. Instead of allocating and freeing a new
cache_entry in every iteration, we reuse the last one and only update
the parts that are new each iteration.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agounpack-trees: optimize walking same trees with cache-tree
Nguyễn Thái Ngọc Duy [Sat, 18 Aug 2018 14:41:24 +0000 (16:41 +0200)]
unpack-trees: optimize walking same trees with cache-tree

In order to merge one or many trees with the index, unpack-trees code
walks multiple trees in parallel with the index and performs n-way
merge. If we find out at start of a directory that all trees are the
same (by comparing OID) and cache-tree happens to be available for
that directory as well, we could avoid walking the trees because we
already know what these trees contain: it's flattened in what's called
"the index".

The upside is of course a lot less I/O since we can potentially skip
lots of trees (think subtrees). We also save CPU because we don't have
to inflate and apply the deltas. The downside is of course more
fragile code since the logic in some functions are now duplicated
elsewhere.

"checkout -" with this patch on webkit.git (275k files):

    baseline      new
  --------------------------------------------------------------------
    0.056651714   0.080394752 s:  read cache .git/index
    0.183101080   0.216010838 s:  preload index
    0.008584433   0.008534301 s:  refresh index
    0.633767589   0.251992198 s:   traverse_trees
    0.340265448   0.377031383 s:   check_updates
    0.381884638   0.372768105 s:   cache_tree_update
    1.401562947   1.045887251 s:  unpack_trees
    0.338687914   0.314983512 s:  write index, changed mask = 2e
    0.411927922   0.062572653 s:    traverse_trees
    0.000023335   0.000022544 s:    check_updates
    0.423697246   0.073795585 s:   unpack_trees
    0.423708360   0.073807557 s:  diff-index
    2.559524127   1.938191592 s: git command: git checkout -

Another measurement from Ben's running "git checkout" with over 500k
trees (on the whole series):

    baseline        new
  ----------------------------------------------------------------------
    0.535510167     0.556558733     s: read cache .git/index
    0.3057373       0.3147105       s: initialize name hash
    0.0184082       0.023558433     s: preload index
    0.086910967     0.089085967     s: refresh index
    7.889590767     2.191554433     s: unpack trees
    0.120760833     0.131941267     s: update worktree after a merge
    2.2583504       2.572663167     s: repair cache-tree
    0.8916137       0.959495233     s: write index, changed mask = 28
    3.405199233     0.2710663       s: unpack trees
    0.000999667     0.0021554       s: update worktree after a merge
    3.4063306       0.273318333     s: diff-index
    16.9524923      9.462943133     s: git command: git.exe checkout

This command calls unpack_trees() twice, the first time on 2way merge
and the second 1way merge. In both times, "unpack trees" time is
reduced to one third. Overall time reduction is not that impressive of
course because index operations take a big chunk. And there's that
repair cache-tree line.

PS. A note about cache-tree invalidation and the use of it in this
code.

We do invalidate cache-tree in _source_ index when we add new entries
to the (temporary) "result" index. But we also use the cache-tree from
source index in this optimization. Does this mean we end up having no
cache-tree in the source index to activate this optimization?

The answer is twisted: the order of finding a good cache-tree and
invalidating it matters. In this case we check for a good cache-tree
first in all_trees_same_as_cache_tree(), then we start to merge things
and potentially invalidate that same cache-tree in the process. Since
cache-tree invalidation happens after the optimization kicks in, we're
still good. But we may lose that cache-tree at the very first
call_unpack_fn() call in traverse_by_cache_tree().

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agounpack-trees: add performance tracing
Nguyễn Thái Ngọc Duy [Sat, 18 Aug 2018 14:41:23 +0000 (16:41 +0200)]
unpack-trees: add performance tracing

We're going to optimize unpack_trees() a bit in the following
patches. Let's add some tracing to measure how long it takes before
and after. This is the baseline ("git checkout -" on webkit.git, 275k
files on worktree)

    performance: 0.056651714 s:  read cache .git/index
    performance: 0.183101080 s:  preload index
    performance: 0.008584433 s:  refresh index
    performance: 0.633767589 s:   traverse_trees
    performance: 0.340265448 s:   check_updates
    performance: 0.381884638 s:   cache_tree_update
    performance: 1.401562947 s:  unpack_trees
    performance: 0.338687914 s:  write index, changed mask = 2e
    performance: 0.411927922 s:    traverse_trees
    performance: 0.000023335 s:    check_updates
    performance: 0.423697246 s:   unpack_trees
    performance: 0.423708360 s:  diff-index
    performance: 2.559524127 s: git command: git checkout -

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotrace.h: support nested performance tracing
Nguyễn Thái Ngọc Duy [Sat, 18 Aug 2018 14:41:22 +0000 (16:41 +0200)]
trace.h: support nested performance tracing

Performance measurements are listed right now as a flat list, which is
fine when we measure big blocks. But when we start adding more and
more measurements, some of them could be just part of a bigger
measurement and a flat list gives a wrong impression that they are
executed at the same level instead of nested.

Add trace_performance_enter() and trace_performance_leave() to allow
indent these nested measurements. For now it does not help much
because the only nested thing is (lazy) name hash initialization
(e.g. called in diff-index from "git status"). This will help more
because I'm going to add some more tracing that's actually nested.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot2024: mark test using "checkout -p" with PERL prerequisite
Ævar Arnfjörð Bjarmason [Sat, 18 Aug 2018 07:01:47 +0000 (07:01 +0000)]
t2024: mark test using "checkout -p" with PERL prerequisite

Checkout with the -p switch uses the "add interactive" framework which
is written in Perl.

One test added in 8d7b558bae ("checkout & worktree: introduce
checkout.defaultRemote", 2018-06-05) didn't declare the PERL
prerequisite, breaking the test when built with NO_PERL.

Reported-by: CB Bailey <redacted>
Signed-off-by: CB Bailey <redacted>
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agosideband: do not read beyond the end of input
Junio C Hamano [Sat, 18 Aug 2018 16:16:28 +0000 (09:16 -0700)]
sideband: do not read beyond the end of input

The caller of maybe_colorize_sideband() gives a counted buffer
<src, n>, but the callee checked src[] as if it were a NUL terminated
buffer.  If src[] had all isspace() bytes in it, we would have made
n negative, and then

 (1) made number of strncasecmp() calls to see if the remaining
     bytes in src[] matched keywords, reading beyond the end of the
     array (this actually happens even if n does not go negative),
     and/or

 (2) called strbuf_add() with negative count, most likely triggering
     the "you want to use way too much memory" error due to unsigned
     integer overflow.

Fix both issues by making sure we do not go beyond &src[n].

In the longer term we may want to accept size_t as parameter for
clarity (even though we know that a sideband message we are painting
typically would fit on a line on a terminal and int is sufficient).
Write it down as a NEEDSWORK comment.

Helped-by: Jonathan Nieder <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoworktree: add --quiet option
Elia Pinto [Wed, 15 Aug 2018 20:56:30 +0000 (20:56 +0000)]
worktree: add --quiet option

Add the '--quiet' option to git worktree, as for the other git
commands. 'add' is the only command affected by it since all other
commands, except 'list', are currently silent by default.

[jc: appiled trivial fix-up to keep the tests from touching outside
the scratch area]

Helped-by: Martin Ågren <redacted>
Helped-by: Duy Nguyen <redacted>
Helped-by: Eric Sunshine <redacted>
Signed-off-by: Elia Pinto <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoSeventh batch for 2.19 cycle
Junio C Hamano [Fri, 17 Aug 2018 20:15:06 +0000 (13:15 -0700)]
Seventh batch for 2.19 cycle

Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'nd/complete-config-vars'
Junio C Hamano [Fri, 17 Aug 2018 20:09:59 +0000 (13:09 -0700)]
Merge branch 'nd/complete-config-vars'

Build fix.

* nd/complete-config-vars:
  Makefile: add missing dependency for command-list.h

7 years agoMerge branch 'ar/t4150-am-scissors-test-fix'
Junio C Hamano [Fri, 17 Aug 2018 20:09:59 +0000 (13:09 -0700)]
Merge branch 'ar/t4150-am-scissors-test-fix'

Test fix.

* ar/t4150-am-scissors-test-fix:
  t4150: fix broken test for am --scissors

7 years agoMerge branch 'js/pull-rebase-type-shorthand'
Junio C Hamano [Fri, 17 Aug 2018 20:09:59 +0000 (13:09 -0700)]
Merge branch 'js/pull-rebase-type-shorthand'

"git pull --rebase=interactive" learned "i" as a short-hand for
"interactive".

* js/pull-rebase-type-shorthand:
  pull --rebase=<type>: allow single-letter abbreviations for the type

7 years agoMerge branch 'jk/diff-rendered-docs'
Junio C Hamano [Fri, 17 Aug 2018 20:09:58 +0000 (13:09 -0700)]
Merge branch 'jk/diff-rendered-docs'

The end result of documentation update has been made to be
inspected more easily to help developers.

* jk/diff-rendered-docs:
  add a script to diff rendered documentation

7 years agoMerge branch 'hn/config-in-code-comment'
Junio C Hamano [Fri, 17 Aug 2018 20:09:58 +0000 (13:09 -0700)]
Merge branch 'hn/config-in-code-comment'

Header update.

* hn/config-in-code-comment:
  config: document git config getter return value

7 years agoMerge branch 'nd/config-blame-sort'
Junio C Hamano [Fri, 17 Aug 2018 20:09:58 +0000 (13:09 -0700)]
Merge branch 'nd/config-blame-sort'

Doc fix.

* nd/config-blame-sort:
  config.txt: reorder blame stuff to keep config keys sorted

7 years agoMerge branch 'en/t3031-title-fix'
Junio C Hamano [Fri, 17 Aug 2018 20:09:58 +0000 (13:09 -0700)]
Merge branch 'en/t3031-title-fix'

Test fix.

* en/t3031-title-fix:
  t3031: update test description to mention desired behavior

git clone https://git.99rst.org/PROJECT