gitweb.git
stash: drop superfluos pathspec parameterThomas Gummerer Wed, 21 Mar 2018 21:53:10 +0000 (21:53 +0000)

stash: drop superfluos pathspec parameter

Since 833622a945 ("stash push: avoid printing errors", 2018-03-19) we
don't use the 'git clean' call for the pathspec case anymore. The
commit however forgot to remove the pathspec argument to the call.
Remove the superfluos argument to make the code a little more obvious.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 2.17-rc1 v2.17.0-rc1Junio C Hamano Wed, 21 Mar 2018 19:02:04 +0000 (12:02 -0700)

Git 2.17-rc1

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

Merge branch 'jk/attributes-path-doc'Junio C Hamano Wed, 21 Mar 2018 18:30:15 +0000 (11:30 -0700)

Merge branch 'jk/attributes-path-doc'

Doc update.

* jk/attributes-path-doc:
doc/gitattributes: mention non-recursive behavior

Merge branch 'rj/warning-uninitialized-fix'Junio C Hamano Wed, 21 Mar 2018 18:30:15 +0000 (11:30 -0700)

Merge branch 'rj/warning-uninitialized-fix'

Compilation fix.

* rj/warning-uninitialized-fix:
read-cache: fix an -Wmaybe-uninitialized warning
-Wuninitialized: remove some 'init-self' workarounds

Merge branch 'tz/complete-tag-delete-tagname'Junio C Hamano Wed, 21 Mar 2018 18:30:15 +0000 (11:30 -0700)

Merge branch 'tz/complete-tag-delete-tagname'

* tz/complete-tag-delete-tagname:
completion: complete tags with git tag --delete/--verify

Merge branch 'ml/filter-branch-portability-fix'Junio C Hamano Wed, 21 Mar 2018 18:30:14 +0000 (11:30 -0700)

Merge branch 'ml/filter-branch-portability-fix'

Shell script portability fix.

* ml/filter-branch-portability-fix:
filter-branch: use printf instead of echo -e

Merge branch 'js/ming-strftime'Junio C Hamano Wed, 21 Mar 2018 18:30:14 +0000 (11:30 -0700)

Merge branch 'js/ming-strftime'

* js/ming-strftime:
mingw: abort on invalid strftime formats

Merge branch 'dp/merge-strategy-doc-fix'Junio C Hamano Wed, 21 Mar 2018 18:30:13 +0000 (11:30 -0700)

Merge branch 'dp/merge-strategy-doc-fix'

Doc fix.

* dp/merge-strategy-doc-fix:
Documentation/merge-strategies: typofix

Merge branch 'tz/relnotes-1.7-on-perl'Junio C Hamano Wed, 21 Mar 2018 18:30:12 +0000 (11:30 -0700)

Merge branch 'tz/relnotes-1.7-on-perl'

* tz/relnotes-1.7-on-perl:
RelNotes: add details on Perl module changes

Merge branch 'rj/http-code-cleanup'Junio C Hamano Wed, 21 Mar 2018 18:30:12 +0000 (11:30 -0700)

Merge branch 'rj/http-code-cleanup'

There was an unused file-scope static variable left in http.c when
building for versions of libCURL that is older than 7.19.4, which
has been fixed.

* rj/http-code-cleanup:
http: fix an unused variable warning for 'curl_no_proxy'

Merge branch 'ks/t3200-typofix'Junio C Hamano Wed, 21 Mar 2018 18:30:12 +0000 (11:30 -0700)

Merge branch 'ks/t3200-typofix'

Test typofix.

* ks/t3200-typofix:
t/t3200: fix a typo in a test description

Merge branch 'jt/transfer-fsck-with-promissor'Junio C Hamano Wed, 21 Mar 2018 18:30:11 +0000 (11:30 -0700)

Merge branch 'jt/transfer-fsck-with-promissor'

The transfer.fsckobjects configuration tells "git fetch" to
validate the data and connected-ness of objects in the received
pack; the code to perform this check has been taught about the
narrow clone's convention that missing objects that are reachable
from objects in a pack that came from a promissor remote is OK.

* jt/transfer-fsck-with-promissor:
fetch-pack: do not check links for partial fetch
index-pack: support checking objects but not links

Merge branch 'bp/refresh-cache-ent-rehash-fix'Junio C Hamano Wed, 21 Mar 2018 18:30:11 +0000 (11:30 -0700)

Merge branch 'bp/refresh-cache-ent-rehash-fix'

The codepath to replace an existing entry in the index had a bug in
updating the name hash structure, which has been fixed.

* bp/refresh-cache-ent-rehash-fix:
Fix bugs preventing adding updated cache entries to the name hash

Merge branch 'jh/fsck-promisors'Junio C Hamano Wed, 21 Mar 2018 18:30:10 +0000 (11:30 -0700)

Merge branch 'jh/fsck-promisors'

A hotfix to a topic that graduated recently.

* jh/fsck-promisors:
sha1_file: restore OBJECT_INFO_QUICK functionality

Merge branch 'ma/skip-writing-unchanged-index'Junio C Hamano Wed, 21 Mar 2018 18:30:10 +0000 (11:30 -0700)

Merge branch 'ma/skip-writing-unchanged-index'

Internal API clean-up to allow write_locked_index() optionally skip
writing the in-core index when it is not modified.

* ma/skip-writing-unchanged-index:
write_locked_index(): add flag to avoid writing unchanged index

Merge branch 'ma/config-page-only-in-list-mode'Junio C Hamano Wed, 21 Mar 2018 18:30:09 +0000 (11:30 -0700)

Merge branch 'ma/config-page-only-in-list-mode'

In a way similar to how "git tag" learned to honor the pager
setting only in the list mode, "git config" learned to ignore the
pager setting when it is used for setting values (i.e. when the
purpose of the operation is not to "show").

* ma/config-page-only-in-list-mode:
config: change default of `pager.config` to "on"
config: respect `pager.config` in list/get-mode only
t7006: add tests for how git config paginates

diff-highlight: detect --graph by indentJeff King Wed, 21 Mar 2018 05:59:01 +0000 (01:59 -0400)

diff-highlight: detect --graph by indent

This patch fixes a corner case where diff-highlight may
scramble some diffs when combined with --graph.

Commit 7e4ffb4c17 (diff-highlight: add support for --graph
output, 2016-08-29) taught diff-highlight to skip past the
graph characters at the start of each line with this regex:

($COLOR?\|$COLOR?\s+)*

I.e., any series of pipes separated by and followed by
arbitrary whitespace. We need to match more than just a
single space because the commit in question may be indented
to accommodate other parts of the graph drawing. E.g.:

* commit 1234abcd
| ...
| diff --git ...

has only a single space, but for the last commit before a
fork:

| | |
| * | commit 1234abcd
| |/ ...
| | diff --git

the diff lines have more spaces between the pipes and the
start of the diff.

However, when we soak up all of those spaces with the
$GRAPH regex, we may accidentally include the leading space
for a context line. That means we may consider the actual
contents of a context line as part of the diff syntax. In
other words, something like this:

normal context line
-old line
+new line
-this is a context line with a leading dash

would cause us to see that final context line as a removal
line, and we'd end up showing the hunk in the wrong order:

normal context line
-old line
-this is a context line with a leading dash
+new line

Instead, let's a be a little more clever about parsing the
graph. We'll look for the actual "*" line that marks the
start of a commit, and record the indentation we see there.
Then we can skip past that indentation when checking whether
the line is a hunk header, removal, addition, etc.

There is one tricky thing: the indentation in bytes may be
different for various lines of the graph due to coloring.
E.g., the "*" on a commit line is generally shown without
color, but on the actual diff lines, it will be replaced
with a colorized "|" character, adding several bytes. We
work around this here by counting "visible" bytes. This is
unfortunately a bit more expensive, making us about twice as
slow to handle --graph output. But since this is meant to be
used interactively anyway, it's tolerably fast (and the
non-graph case is unaffected).

One alternative would be to search for hunk header lines and
use their indentation (since they'd have the same colors as
the diff lines which follow). But that just opens up
different corner cases. If we see:

| | @@ 1,2 1,3 @@

we cannot know if this is a real diff that has been
indented due to the graph, or if it's a context line that
happens to look like a diff header. We can only be sure of
the indent on the "*" lines, since we know those don't
contain arbitrary data (technically the user could include a
bunch of extra indentation via --format, but that's rare
enough to disregard).

Reported-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff-highlight: use flush() helper consistentlyJeff King Wed, 21 Mar 2018 05:56:37 +0000 (01:56 -0400)

diff-highlight: use flush() helper consistently

The current flush() helper only shows the queued diff but
does not clear the queue. This is conceptually a bug, but it
works because we only call it once at the end of the
program.

Let's teach it to clear the queue, which will let us use it
in more places (one for now, but more in future patches).

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

diff-highlight: test graphs with --colorJeff King Wed, 21 Mar 2018 05:49:57 +0000 (01:49 -0400)

diff-highlight: test graphs with --color

Our tests send git's output directly to files or pipes, so
there will never be any color. Let's do at least one --color
test to make sure that we can handle this case (which we
currently can, but will be an easy thing to mess up when we
touch the graph code in a future patch).

We'll just cover the --graph case, since this is much more
complex than the earlier cases (i.e., if it manages to
highlight, then the non-graph case definitely would).

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

diff-highlight: test interleaved parallel lines of... Jeff King Wed, 21 Mar 2018 05:49:26 +0000 (01:49 -0400)

diff-highlight: test interleaved parallel lines of history

The graph test in t9400 covers the case of two simultaneous
branches, but all of the commits during this time are on the
right-hand branch. So we test a graph structure like:

| |
| * commit ...
| |

but we never see the reverse, a commit on the left-hand
branch:

| |
* | commit ...
| |

Since this is an easy thing to get wrong when touching the
graph-matching code, let's cover it by adding one more
commit with its timestamp interleaved with the other branch.

Note that we need to pass --date-order to convince Git to
show it this way (since --topo-order tries to keep lines of
history separate).

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

diff-highlight: prefer "echo" to "cat" in testsJeff King Wed, 21 Mar 2018 05:48:53 +0000 (01:48 -0400)

diff-highlight: prefer "echo" to "cat" in tests

We generate a bunch of one-line files whose contents match
their names, and then generate our commits by cat-ing those
files. Let's just echo the contents directly, which saves
some processes.

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

diff-highlight: use test_tick in graph testJeff King Wed, 21 Mar 2018 05:48:40 +0000 (01:48 -0400)

diff-highlight: use test_tick in graph test

The exact ordering output by Git may depend on the commit
timestamps, so let's make sure they're actually
monotonically increasing, and not all the same (or worse,
subject to how long the test script takes to run).

Let's use test_tick to make sure this is stable. Note that
we actually have to rearrange the order of the branches to
match the expected graph structure (which means that
previously we might racily have been testing a slightly
different output, though the test is written in such a way
that we'd still pass).

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

diff-highlight: correct test graph diagramJeff King Wed, 21 Mar 2018 05:47:45 +0000 (01:47 -0400)

diff-highlight: correct test graph diagram

We actually branch "A" off of "D". The sample "--graph"
output is right, but the left-to-right diagram is
misleading. Let's fix it.

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

Merge branch 'master' of git://github.com/nafmo/git... Jiang Xin Wed, 21 Mar 2018 14:13:51 +0000 (22:13 +0800)

Merge branch 'master' of git://github.com/nafmo/git-l10n-sv

* 'master' of git://github.com/nafmo/git-l10n-sv:
l10n: sv.po: Update Swedish translation (3376t0f0u)

Merge branch 'master' of https://github.com/Softcatala... Jiang Xin Wed, 21 Mar 2018 14:07:53 +0000 (22:07 +0800)

Merge branch 'master' of https://github.com/Softcatala/git-po

* 'master' of https://github.com/Softcatala/git-po:
l10n: Update Catalan translation

doc/gitattributes: mention non-recursive behaviorJeff King Tue, 20 Mar 2018 04:14:54 +0000 (00:14 -0400)

doc/gitattributes: mention non-recursive behavior

The gitattributes documentation claims that the pattern
rules are largely the same as for gitignore. However, the
rules for recursion are different.

In an ideal world, we would make them the same (if for
nothing else than consistency and simplicity), but that
would create backwards compatibility issues. For some
discussion, see this thread:

https://public-inbox.org/git/slrnkldd3g.1l4.jan@majutsushi.net/

But let's at least document the differences instead of
actively misleading the user by claiming that they're the
same.

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

read-cache: fix an -Wmaybe-uninitialized warningRamsay Jones Mon, 19 Mar 2018 17:56:11 +0000 (17:56 +0000)

read-cache: fix an -Wmaybe-uninitialized warning

The function ce_write_entry() uses a 'self-initialised' variable
construct, for the symbol 'saved_namelen', to suppress a gcc
'-Wmaybe-uninitialized' warning, given that the warning is a false
positive.

For the purposes of this discussion, the ce_write_entry() function has
three code blocks of interest, that look like so:

/* block #1 */
if (ce->ce_flags & CE_STRIP_NAME) {
saved_namelen = ce_namelen(ce);
ce->ce_namelen = 0;
}

/* block #2 */
/*
* several code blocks that contain, among others, calls
* to copy_cache_entry_to_ondisk(ondisk, ce);
*/

/* block #3 */
if (ce->ce_flags & CE_STRIP_NAME) {
ce->ce_namelen = saved_namelen;
ce->ce_flags &= ~CE_STRIP_NAME;
}

The warning implies that gcc thinks it is possible that the first
block is not entered, the calls to copy_cache_entry_to_ondisk()
could toggle the CE_STRIP_NAME flag on, thereby entering block #3
with saved_namelen unset. However, the copy_cache_entry_to_ondisk()
function does not write to ce->ce_flags (it only reads). gcc could
easily determine this, since that function is local to this file,
but it obviously doesn't.

In order to suppress this warning, we make it clear to the reader
(human and compiler), that block #3 will only be entered when the
first block has been entered, by introducing a new 'stripped_name'
boolean variable. We also take the opportunity to change the type
of 'saved_namelen' to 'unsigned int' to match ce->ce_namelen.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

-Wuninitialized: remove some 'init-self' workaroundsRamsay Jones Mon, 19 Mar 2018 17:54:35 +0000 (17:54 +0000)

-Wuninitialized: remove some 'init-self' workarounds

The 'self-initialised' variables construct (ie <type> var = var;) has
been used to silence gcc '-W[maybe-]uninitialized' warnings. This has,
unfortunately, caused MSVC to issue 'uninitialized variable' warnings.
Also, using clang static analysis causes complaints about an 'Assigned
value is garbage or undefined'.

There are six such constructs in the current codebase. Only one of the
six causes gcc to issue a '-Wmaybe-uninitialized' warning (which will
be addressed elsewhere). The remaining five 'init-self' gcc workarounds
are noted below, along with the commit which introduced them:

1. builtin/rev-list.c: 'reaches' and 'all', see commit 457f08a030
("git-rev-list: add --bisect-vars option.", 2007-03-21).

2. merge-recursive.c:2064 'mrtree', see commit f120ae2a8e ("merge-
recursive.c: mrtree in merge() is not used before set", 2007-10-29).

3. fast-import.c:3023 'oe', see commit 85c62395b1 ("fast-import: let
importers retrieve blobs", 2010-11-28).

4. fast-import.c:3006 'oe', see commit 28c7b1f7b7 ("fast-import: add a
get-mark command", 2015-07-01).

Remove the 'self-initialised' variable constructs noted above.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash push -u: don't create empty stashThomas Gummerer Mon, 19 Mar 2018 23:21:56 +0000 (23:21 +0000)

stash push -u: don't create empty stash

When introducing the stash push feature, and thus allowing users to pass
in a pathspec to limit the files that would get stashed in
df6bba0937 ("stash: teach 'push' (and 'create_stash') to honor
pathspec", 2017-02-28), this developer missed one place where the
pathspec should be passed in.

Namely in the call to the 'untracked_files()' function in the
'no_changes()' function. This resulted in 'git stash push -u --
<non-existant>' creating an empty stash when there are untracked files
in the repository other that don't match the pathspec.

As 'git stash' never creates empty stashes, this behaviour is wrong and
confusing for users. Instead it should just show a message "No local
changes to save", and not create a stash.

Luckily the 'untracked_files()' function already correctly respects
pathspecs that are passed to it, so the fix is simply to pass the
pathspec along to the function.

Reported-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash push: avoid printing errorsThomas Gummerer Mon, 19 Mar 2018 23:21:55 +0000 (23:21 +0000)

stash push: avoid printing errors

'git stash push -u -- <pathspec>' prints the following errors if
<pathspec> only matches untracked files:

fatal: pathspec 'untracked' did not match any files
error: unrecognized input

This is because we first clean up the untracked files using 'git clean
<pathspec>', and then use a command chain involving 'git add -u
<pathspec>' and 'git apply' to clear the changes to files that are in
the index and were stashed.

As the <pathspec> only includes untracked files that were already
removed by 'git clean', the 'git add' call will barf, and so will 'git
apply', as there are no changes that need to be applied.

Fix this by avoiding the 'git clean' if a pathspec is given, and use the
pipeline that's used for pathspec mode to get rid of the untracked files
as well.

Reported-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: fix nonsense pipelineJunio C Hamano Mon, 19 Mar 2018 23:21:54 +0000 (23:21 +0000)

stash: fix nonsense pipeline

An earlier change bba067d2 ("stash: don't delete untracked files
that match pathspec", 2018-01-06) was made by taking a suggestion in
a list discussion [1] but did not copy the suggested snippet
correctly. And the bug was unnoticed during the review and slipped
through.

This fixes it.

[1] https://public-inbox.org/git/xmqqpo7byjwb.fsf@gitster.mtv.corp.google.com/

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

filter-branch: use printf instead of echo -eMichele Locati Mon, 19 Mar 2018 15:52:59 +0000 (16:52 +0100)

filter-branch: use printf instead of echo -e

In order to echo a tab character, it's better to use printf instead of
"echo -e", because it's more portable (for instance, "echo -e" doesn't work
as expected on a Mac).

This solves the "fatal: Not a valid object name" error in git-filter-branch
when using the --state-branch option.

Furthermore, let's switch from "/bin/echo" to just "echo", so that the
built-in echo command is used where available.

Signed-off-by: Michele Locati <michele@locati.it>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mingw: abort on invalid strftime formatsJohannes Schindelin Mon, 19 Mar 2018 16:49:22 +0000 (17:49 +0100)

mingw: abort on invalid strftime formats

On Windows, strftime() does not silently ignore invalid formats, but
warns about them and then returns 0 and sets errno to EINVAL.

Unfortunately, Git does not expect such a behavior, as it disagrees
with strftime()'s semantics on Linux. As a consequence, Git
misinterprets the return value 0 as "I need more space" and grows the
buffer. As the larger buffer does not fix the format, the buffer grows
and grows and grows until we are out of memory and abort.

Ideally, we would switch off the parameter validation just for
strftime(), but we cannot even override the invalid parameter handler
via _set_thread_local_invalid_parameter_handler() using MINGW because
that function is not declared. Even _set_invalid_parameter_handler(),
which *is* declared, does not help, as it simply does... nothing.

So let's just bite the bullet and override strftime() for MINGW and
abort on an invalid format string. While this does not provide the
best user experience, it is the best we can do.

See https://msdn.microsoft.com/en-us/library/fe06s4ak.aspx for more
details.

This fixes https://github.com/git-for-windows/git/issues/863

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

completion: complete tags with git tag --delete/--verifyTodd Zullinger Sun, 18 Mar 2018 04:01:35 +0000 (00:01 -0400)

completion: complete tags with git tag --delete/--verify

Completion of tag names has worked for the short -d/-v options since
88e21dc746 ("Teach bash about completing arguments for git-tag",
2007-08-31). The long options were not added to "git tag" until many
years later, in c97eff5a95 ("git-tag: introduce long forms for the
options", 2011-08-28).

Extend tag name completion to --delete/--verify.

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

Documentation/merge-strategies: typofixDavid Pursehouse Sat, 17 Mar 2018 03:31:42 +0000 (12:31 +0900)

Documentation/merge-strategies: typofix

It's strategy, not stragegy.

Signed-off-by: David Pursehouse <dpursehouse@collab.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: sv.po: Update Swedish translation (3376t0f0u)Peter Krefting Sun, 18 Mar 2018 19:57:00 +0000 (20:57 +0100)

l10n: sv.po: Update Swedish translation (3376t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>

l10n: Update Catalan translationJordi Mas Sun, 18 Mar 2018 15:03:18 +0000 (16:03 +0100)

l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>

Merge branch 'fr_v2.17.0' of git://github.com/jnavila/gitJiang Xin Sun, 18 Mar 2018 11:46:38 +0000 (19:46 +0800)

Merge branch 'fr_v2.17.0' of git://github.com/jnavila/git

* 'fr_v2.17.0' of git://github.com/jnavila/git:
l10n: fr.po v2.17.0 round 1

l10n: fr.po v2.17.0 round 1Jean-Noël Avila Fri, 16 Mar 2018 22:39:49 +0000 (23:39 +0100)

l10n: fr.po v2.17.0 round 1

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>

Merge branch 'master' of https://github.com/vnwildman/gitJiang Xin Sat, 17 Mar 2018 03:27:05 +0000 (11:27 +0800)

Merge branch 'master' of https://github.com/vnwildman/git

* 'master' of https://github.com/vnwildman/git:
l10n: vi.po(3376t): Updated Vietnamese translation for v2.17

Merge branch 'master' of git://github.com/alshopov... Jiang Xin Sat, 17 Mar 2018 03:24:53 +0000 (11:24 +0800)

Merge branch 'master' of git://github.com/alshopov/git-po

* 'master' of git://github.com/alshopov/git-po:
l10n: bg.po: Updated Bulgarian translation (3376t)

l10n: vi.po(3376t): Updated Vietnamese translation... Tran Ngoc Quan Sat, 17 Mar 2018 00:53:33 +0000 (07:53 +0700)

l10n: vi.po(3376t): Updated Vietnamese translation for v2.17

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>

RelNotes: add details on Perl module changesTodd Zullinger Fri, 16 Mar 2018 22:07:48 +0000 (18:07 -0400)

RelNotes: add details on Perl module changes

Document changes to core and non-core Perl module handling in 2.17.

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

l10n: bg.po: Updated Bulgarian translation (3376t)Alexander Shopov Fri, 16 Mar 2018 08:55:13 +0000 (09:55 +0100)

l10n: bg.po: Updated Bulgarian translation (3376t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>

l10n: es.po: Update Spanish translation 2.17.0Christopher Diaz Riveros Fri, 16 Mar 2018 02:55:20 +0000 (21:55 -0500)

l10n: es.po: Update Spanish translation 2.17.0

Signed-off-by: Christopher Diaz Riveros <chrisadr@gentoo.org>

Merge remote-tracking branch 'git-po/maint'Jiang Xin Thu, 15 Mar 2018 23:36:32 +0000 (07:36 +0800)

Merge remote-tracking branch 'git-po/maint'

* git-po/maint:
l10n: es.po: fixes to Spanish translation

l10n: git.pot: v2.17.0 round 1 (132 new, 44 removed)Jiang Xin Thu, 15 Mar 2018 23:34:52 +0000 (07:34 +0800)

l10n: git.pot: v2.17.0 round 1 (132 new, 44 removed)

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

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>

Git 2.17-rc0 v2.17.0-rc0Junio C Hamano Thu, 15 Mar 2018 22:01:05 +0000 (15:01 -0700)

Git 2.17-rc0

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

Merge branch 'tl/userdiff-csharp-async'Junio C Hamano Thu, 15 Mar 2018 22:00:47 +0000 (15:00 -0700)

Merge branch 'tl/userdiff-csharp-async'

Update funcname pattern used for C# to recognize "async" keyword.

* tl/userdiff-csharp-async:
userdiff.c: add C# async keyword in diff pattern

Merge branch 'sg/cvs-tests-with-x'Junio C Hamano Thu, 15 Mar 2018 22:00:46 +0000 (15:00 -0700)

Merge branch 'sg/cvs-tests-with-x'

Allow running a couple of tests with "sh -x".

* sg/cvs-tests-with-x:
t9402-git-cvsserver-refs: don't check the stderr of a subshell
t9400-git-cvsserver-server: don't rely on the output of 'test_cmp'

Merge branch 'ab/man-sec-list'Junio C Hamano Thu, 15 Mar 2018 22:00:46 +0000 (15:00 -0700)

Merge branch 'ab/man-sec-list'

Doc update.

* ab/man-sec-list:
git manpage: note git-security@googlegroups.com

Merge branch 'ab/perl-fixes'Junio C Hamano Thu, 15 Mar 2018 22:00:46 +0000 (15:00 -0700)

Merge branch 'ab/perl-fixes'

Clean-up to various pieces of Perl code we have.

* ab/perl-fixes:
perl Git::LoadCPAN: emit better errors under NO_PERL_CPAN_FALLBACKS
Makefile: add NO_PERL_CPAN_FALLBACKS knob
perl: move the perl/Git/FromCPAN tree to perl/FromCPAN
perl: generalize the Git::LoadCPAN facility
perl: move CPAN loader wrappers to another namespace
perl: update our copy of Mail::Address
perl: update our ancient copy of Error.pm
git-send-email: unconditionally use Net::{SMTP,Domain}
Git.pm: hard-depend on the File::{Temp,Spec} modules
gitweb: hard-depend on the Digest::MD5 5.8 module
Git.pm: add the "use warnings" pragma
Git.pm: remove redundant "use strict" from sub-package
perl: *.pm files should not have the executable bit

Merge branch 'cl/send-email-reply-to'Junio C Hamano Thu, 15 Mar 2018 22:00:45 +0000 (15:00 -0700)

Merge branch 'cl/send-email-reply-to'

"git send-email" learned "--reply-to=<address>" option.

* cl/send-email-reply-to:
send-email: support separate Reply-To address
send-email: rename variable for clarity

Merge branch 'np/send-email-header-parsing'Junio C Hamano Thu, 15 Mar 2018 22:00:45 +0000 (15:00 -0700)

Merge branch 'np/send-email-header-parsing'

Code refactoring.

* np/send-email-header-parsing:
send-email: extract email-parsing code into a subroutine

t/t3200: fix a typo in a test descriptionKaartic Sivaraam Sat, 10 Mar 2018 15:54:16 +0000 (21:24 +0530)

t/t3200: fix a typo in a test description

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http: fix an unused variable warning for 'curl_no_proxy'Ramsay Jones Wed, 14 Mar 2018 21:56:06 +0000 (21:56 +0000)

http: fix an unused variable warning for 'curl_no_proxy'

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: optionally symlink libexec/git-core binaries... Ævar Arnfjörð Bjarmason Tue, 13 Mar 2018 20:39:35 +0000 (20:39 +0000)

Makefile: optionally symlink libexec/git-core binaries to bin/git

Add a INSTALL_SYMLINKS option which if enabled, changes the default
hardlink installation method to one where the relevant binaries in
libexec/git-core are symlinked back to ../../bin, instead of being
hardlinked.

This new option also overrides the behavior of the existing
NO_*_HARDLINKS variables which in some cases would produce symlinks
within to libexec/, e.g. "git-add" symlinked to "git" which would be
copy of the "git" found in bin/, now "git-add" in libexec/ is always
going to be symlinked to the "git" found in the bin/ directory.

This option is being added because:

1) I think it makes what we're doing a lot more obvious. E.g. I'd
never noticed that the libexec binaries were really just hardlinks
since e.g. ls(1) won't show that in any obvious way. You need to
start stat(1)-ing things and look at the inodes to see what's
going on.

2) Some tools have very crappy support for hardlinks, e.g. the Git
shipped with GitLab is much bigger than it should be because
they're using a chef module that doesn't know about hardlinks, see
https://github.com/chef/omnibus/issues/827

I've also ran into other related issues that I think are explained
by this, e.g. compiling git with debugging and rpm refusing to
install a ~200MB git package with 2GB left on the FS, I think that
was because it doesn't consider hardlinks, just the sum of the
byte size of everything in the package.

As for the implementation, the "../../bin" noted above will vary given
some given some values of "../.." and "bin" depending on the depth of
the gitexecdir relative to the destdir, and the "bindir" target,
e.g. setting "bindir=/tmp/git/binaries gitexecdir=foo/bar/baz" will do
the right thing and produce this result:

$ file /tmp/git/foo/bar/baz/git-add
/tmp/git/foo/bar/baz/git-add: symbolic link to ../../../binaries/git

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: add a gitexecdir_relative variableÆvar Arnfjörð Bjarmason Tue, 13 Mar 2018 20:39:34 +0000 (20:39 +0000)

Makefile: add a gitexecdir_relative variable

This variable will be e.g. "libexec/git-core" if
gitexecdir=/tmp/git/libexec/git-core is given. It'll be used by a
subsequent change.

This is stolen from the yet-to-be integrated (needs resubmission)
"Makefile: add Perl runtime prefix support" patch on the mailing
list. See
<20180108030239.92036-3-dnj@google.com> (https://public-inbox.org/git/20180108030239.92036-3-dnj@google.com/).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: fix broken bindir_relative variableÆvar Arnfjörð Bjarmason Tue, 13 Mar 2018 20:39:33 +0000 (20:39 +0000)

Makefile: fix broken bindir_relative variable

Change the bindir_relative variable to work like the other *_relative
variables, which are computed as a function of the absolute
path. Before this change, supplying e.g. bindir=/tmp/git/binaries to
the Makefile would yield a bindir_relative of just "bin", as opposed
to "binaries".

This logic was originally added back in 026fa0d5ad ("Move computation
of absolute paths from Makefile to runtime (in preparation for
RUNTIME_PREFIX)", 2009-01-18), then later in 971f85388f ("Makefile:
make mandir, htmldir and infodir absolute", 2013-02-24) when
more *_relative variables were added those new variables didn't have
this bug, but bindir_relative was never fixed.

There is a small change in behavior here, which is that setting
bindir_relative as an argument to the Makefile won't work anymore, I
think that's fine, since this was always intended as an internal
variable (e.g. INSTALL documents bindir=*, not bindir_relative=*).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

worktree prune: improve prune logic when worktree is... Nguyễn Thái Ngọc Duy Thu, 15 Mar 2018 16:44:12 +0000 (17:44 +0100)

worktree prune: improve prune logic when worktree is moved

Automatic detection of worktree relocation by a user (via 'mv', for
instance) was removed by 618244e160 (worktree: stop supporting moving
worktrees manually - 2016-01-22). Prior to that,
.git/worktrees/<tag>/gitdir was updated whenever the worktree was
accessed in order to let the pruning logic know that the worktree was
"active" even if it disappeared for a while (due to being located on
removable media, for instance).

"git worktree move" has come so we don't really need this, but since
it's easy to do, perhaps we could keep supporting manual worktree move
a bit longer. Notice that when a worktree is active, the "index" file
should be updated pretty often in common case. The logic is updated to
check for index mtime to see if the worktree is alive.

The old logic of checking gitdir's mtime is dropped because nobody
updates it anyway. The new corner case is, if the index file does not
exist, we immediately remove the stale worktree. But if the "index"
file does not exist, you may have a bigger problem.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

worktree: delete dead codeNguyễn Thái Ngọc Duy Thu, 15 Mar 2018 16:44:11 +0000 (17:44 +0100)

worktree: delete dead code

This "link" was a feature in early iterations of multiple worktree
functionality for some reason it was dropped [1]. Since nobody creates
this "link", there's no need to check it.

This is mostly used to let the user moves a worktree manually [2]. If
you move a worktree within the same file system, this hard link count
lets us know the worktree is still there even if we don't know where it
is.

We support 'worktree move' now and don't need this anymore.

[1] last appearance in v4 message-id:
1393675983-3232-25-git-send-email-pclouds@gmail.com
and the reason in v5 was "revisit later", message-id:
1394246900-31535-1-git-send-email-pclouds@gmail.com
[2] 23af91d102 (prune: strategies for linked checkouts - 2014-11-30)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc.txt: more details about what gc doesNguyễn Thái Ngọc Duy Thu, 15 Mar 2018 16:44:10 +0000 (17:44 +0100)

gc.txt: more details about what gc does

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Fix bugs preventing adding updated cache entries to... Ben Peart Thu, 15 Mar 2018 15:25:20 +0000 (11:25 -0400)

Fix bugs preventing adding updated cache entries to the name hash

Update replace_index_entry() to clear the CE_HASHED flag from the new cache
entry so that it can add it to the name hash in set_index_entry()

Fix refresh_cache_ent() to use the copy_cache_entry() macro instead of memcpy()
so that it doesn't incorrectly copy the hash state from the old entry.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

filter-branch: return 2 when nothing to rewriteMichele Locati Thu, 15 Mar 2018 17:09:18 +0000 (18:09 +0100)

filter-branch: return 2 when nothing to rewrite

Using the --state-branch option allows us to perform incremental filtering.
This may lead to having nothing to rewrite in subsequent filtering, so we need
a way to recognize this case.
So, let's exit with 2 instead of 1 when this "error" occurs.

Signed-off-by: Michele Locati <michele@locati.it>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

shortlog: disallow left-over arguments outside repoMartin Ågren Wed, 14 Mar 2018 21:34:19 +0000 (22:34 +0100)

shortlog: disallow left-over arguments outside repo

If we are outside a repo and have any arguments left after
option-parsing, `setup_revisions()` will try to do its job and
something like this will happen:

$ git shortlog v2.16.0..
BUG: environment.c:183: git environment hasn't been setup
Aborted (core dumped)

The usage is wrong, but we could obviously handle this better. Note that
commit abe549e179 (shortlog: do not require to run from inside a git
repository, 2008-03-14) explicitly enabled `git shortlog` to run from
outside a repo, since we do not need a repo for parsing data from stdin.

Disallow left-over arguments when run from outside a repo.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch-pack: do not check links for partial fetchJonathan Tan Wed, 14 Mar 2018 18:42:41 +0000 (11:42 -0700)

fetch-pack: do not check links for partial fetch

When doing a partial clone or fetch with transfer.fsckobjects=1, use the
--fsck-objects instead of the --strict flag when invoking index-pack so
that links are not checked, only objects. This is because incomplete
links are expected when doing a partial clone or fetch.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

index-pack: support checking objects but not linksJonathan Tan Wed, 14 Mar 2018 18:42:40 +0000 (11:42 -0700)

index-pack: support checking objects but not links

The index-pack command currently supports the
--check-self-contained-and-connected argument, for internal use only,
that instructs it to only check for broken links and not broken objects.
For partial clones, we need the inverse, so add a --fsck-objects
argument that checks for broken objects and not broken links, also for
internal use only.

This will be used by fetch-pack in a subsequent patch.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: make USE_LIBPCRE=YesPlease mean v2, not v1Ævar Arnfjörð Bjarmason Sun, 11 Mar 2018 13:26:09 +0000 (13:26 +0000)

Makefile: make USE_LIBPCRE=YesPlease mean v2, not v1

Change the USE_LIBPCRE flag from being an alias for USE_LIBPCRE1 to
being an alias for USE_LIBPCRE2.

When support for v2 was added in my 94da9193a6 ("grep: add support for
PCRE v2", 2017-06-01) the existing USE_LIBPCRE flag was left as
meaning v1, with a note that this would likely change in a future
release. That optional support for v2 first made it into Git version
2.14.0.

The PCRE v2 support has been shown to be stable, and the upstream PCRE
project is highly encouraging downstream users to move to v2, so it
makes sense to give packagers of Git who haven't heard the news about
PCRE v2 a further nudge to move to v2.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

configure: detect redundant --with-libpcre & --with... Ævar Arnfjörð Bjarmason Sun, 11 Mar 2018 13:26:08 +0000 (13:26 +0000)

configure: detect redundant --with-libpcre & --with-libpcre1

The --with-libpcre option is a synonym for the --with-libpcre1 flag,
but the configure script allowed for redundantly specifying both.

Nothing broke as a result of this, but it's confusing, so let's
disallow it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

configure: fix a regression in PCRE v1 detectionÆvar Arnfjörð Bjarmason Sun, 11 Mar 2018 13:26:07 +0000 (13:26 +0000)

configure: fix a regression in PCRE v1 detection

Change the check for PCRE v1 to disable the --with-libpcre1 option if
the pcre_version() function can't be found in the pcre library. I
unintentionally changed this in my 94da9193a6 ("grep: add support for
PCRE v2", 2017-06-01) while renaming moving some variables.

The intent of this check ever since it was added in
a119f91e57 ("configure: Check for libpcre", 2011-05-09) is to
second-guess the user and turn off an explicitly provided
--with-libpcre if the library can't be found.

I don't think that behavior makes any sense, we shouldn't be
second-guessing the user with an auto-detection, but changing that
needs a bigger refactoring of this script, and only has marginal
benefits. So let's fix it to work as it was intended to work again.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'nd/parseopt-completion'Junio C Hamano Wed, 14 Mar 2018 19:01:06 +0000 (12:01 -0700)

Merge branch 'nd/parseopt-completion'

Teach parse-options API an option to help the completion script,
and make use of the mechanism in command line completion.

* nd/parseopt-completion: (45 commits)
completion: more subcommands in _git_notes()
completion: complete --{reuse,reedit}-message= for all notes subcmds
completion: simplify _git_notes
completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate
completion: use __gitcomp_builtin in _git_worktree
completion: use __gitcomp_builtin in _git_tag
completion: use __gitcomp_builtin in _git_status
completion: use __gitcomp_builtin in _git_show_branch
completion: use __gitcomp_builtin in _git_rm
completion: use __gitcomp_builtin in _git_revert
completion: use __gitcomp_builtin in _git_reset
completion: use __gitcomp_builtin in _git_replace
remote: force completing --mirror= instead of --mirror
completion: use __gitcomp_builtin in _git_remote
completion: use __gitcomp_builtin in _git_push
completion: use __gitcomp_builtin in _git_pull
completion: use __gitcomp_builtin in _git_notes
completion: use __gitcomp_builtin in _git_name_rev
completion: use __gitcomp_builtin in _git_mv
completion: use __gitcomp_builtin in _git_merge_base
...

Merge branch 'nd/object-allocation-comments'Junio C Hamano Wed, 14 Mar 2018 19:01:06 +0000 (12:01 -0700)

Merge branch 'nd/object-allocation-comments'

Code doc update.

* nd/object-allocation-comments:
object.h: realign object flag allocation comment
object.h: update flag allocation comment

Merge branch 'jk/smart-http-protocol-doc-fix'Junio C Hamano Wed, 14 Mar 2018 19:01:05 +0000 (12:01 -0700)

Merge branch 'jk/smart-http-protocol-doc-fix'

A doc update.

* jk/smart-http-protocol-doc-fix:
smart-http: document flush after "# service" line

Merge branch 'jk/add-i-diff-filter'Junio C Hamano Wed, 14 Mar 2018 19:01:05 +0000 (12:01 -0700)

Merge branch 'jk/add-i-diff-filter'

The "interactive.diffFilter" used by "git add -i" must retain
one-to-one correspondence between its input and output, but it was
not enforced and caused end-user confusion. We now at least make
sure the filtered result has the same number of lines as its input
to detect a broken filter.

* jk/add-i-diff-filter:
add--interactive: detect bogus diffFilter output
t3701: add a test for interactive.diffFilter

Merge branch 'nd/worktree-move'Junio C Hamano Wed, 14 Mar 2018 19:01:05 +0000 (12:01 -0700)

Merge branch 'nd/worktree-move'

"git worktree" learned move and remove subcommands.

* nd/worktree-move:
t2028: fix minor error and issues in newly-added "worktree move" tests
worktree remove: allow it when $GIT_WORK_TREE is already gone
worktree remove: new command
worktree move: refuse to move worktrees with submodules
worktree move: accept destination as directory
worktree move: new command
worktree.c: add update_worktree_location()
worktree.c: add validate_worktree()

Merge branch 'pw/add-p-recount'Junio C Hamano Wed, 14 Mar 2018 19:01:04 +0000 (12:01 -0700)

Merge branch 'pw/add-p-recount'

"git add -p" has been lazy in coalescing split patches before
passing the result to underlying "git apply", leading to corner
case bugs; the logic to prepare the patch to be applied after hunk
selections has been tightened.

* pw/add-p-recount:
add -p: don't rely on apply's '--recount' option
add -p: fix counting when splitting and coalescing
add -p: calculate offset delta for edited patches
add -p: adjust offsets of subsequent hunks when one is skipped
t3701: add failing test for pathological context lines
t3701: don't hard code sha1 hash values
t3701: use test_write_lines and write_script
t3701: indent here documents
add -i: add function to format hunk header

Merge branch 'ab/pre-auto-gc-battery'Junio C Hamano Wed, 14 Mar 2018 19:01:04 +0000 (12:01 -0700)

Merge branch 'ab/pre-auto-gc-battery'

A sample auto-gc hook (in contrib/) to skip auto-gc while on
battery has been updated to almost always allow running auto-gc
unless on_ac_power command is absolutely sure that we are on
battery power (earlier, it skipped unless the command is sure that
we are on ac power).

* ab/pre-auto-gc-battery:
hooks/pre-auto-gc-battery: allow gc to run on non-laptops

Merge branch 'sg/test-x'Junio C Hamano Wed, 14 Mar 2018 19:01:03 +0000 (12:01 -0700)

Merge branch 'sg/test-x'

Running test scripts under -x option of the shell is often not a
useful way to debug them, because the error messages from the
commands tests try to capture and inspect are contaminated by the
tracing output by the shell. An earlier work done to make it more
pleasant to run tests under -x with recent versions of bash is
extended to cover posix shells that do not support BASH_XTRACEFD.

* sg/test-x:
travis-ci: run tests with '-x' tracing
t/README: add a note about don't saving stderr of compound commands
t1510-repo-setup: mark as untraceable with '-x'
t9903-bash-prompt: don't check the stderr of __git_ps1()
t5570-git-daemon: don't check the stderr of a subshell
t5526: use $TRASH_DIRECTORY to specify the path of GIT_TRACE log file
t5500-fetch-pack: don't check the stderr of a subshell
t3030-merge-recursive: don't check the stderr of a subshell
t1507-rev-parse-upstream: don't check the stderr of a shell function
t: add means to disable '-x' tracing for individual test scripts
t: prevent '-x' tracing from interfering with test helpers' stderr

Merge branch 'rj/test-i18ngrep'Junio C Hamano Wed, 14 Mar 2018 19:01:03 +0000 (12:01 -0700)

Merge branch 'rj/test-i18ngrep'

Test updates.

* rj/test-i18ngrep:
t5536: simplify checking of messages output to stderr
t4151: consolidate multiple calls to test_i18ngrep

Merge branch 'ma/roll-back-lockfiles'Junio C Hamano Wed, 14 Mar 2018 19:01:03 +0000 (12:01 -0700)

Merge branch 'ma/roll-back-lockfiles'

Some codepaths used to take a lockfile and did not roll it back;
they are automatically rolled back at program exit, so there is no
real "breakage", but it still is a good practice to roll back when
you are done with a lockfile.

* ma/roll-back-lockfiles:
sequencer: do not roll back lockfile unnecessarily
merge: always roll back lock in `checkout_fast_forward()`
merge-recursive: always roll back lock in `merge_recursive_generic()`
sequencer: always roll back lock in `do_recursive_merge()`
sequencer: make lockfiles non-static

Merge branch 'nd/diff-stat-with-summary'Junio C Hamano Wed, 14 Mar 2018 19:01:02 +0000 (12:01 -0700)

Merge branch 'nd/diff-stat-with-summary'

"git diff" and friends learned "--compact-summary" that shows the
information usually given with the "--summary" option on the same
line as the diffstat output of the "--stat" option (which saves
vertical space and keeps info on a single path at the same place).

* nd/diff-stat-with-summary:
diff: add --compact-summary
diff.c: refactor pprint_rename() to use strbuf

fetch-pack.c: use oidset to check existence of loose... Takuto Ikuta Wed, 14 Mar 2018 06:32:42 +0000 (15:32 +0900)

fetch-pack.c: use oidset to check existence of loose object

When fetching from a repository with large number of refs, because to
check existence of each refs in local repository to packed and loose
objects, 'git fetch' ends up doing a lot of lstat(2) to non-existing
loose form, which makes it slow.

Instead of making as many lstat(2) calls as the refs the remote side
advertised to see if these objects exist in the loose form, first
enumerate all the existing loose objects in hashmap beforehand and use
it to check existence of them if the number of refs is larger than the
number of loose objects.

With this patch, the number of lstat(2) calls in `git fetch` is reduced
from 411412 to 13794 for chromium repository, it has more than 480000
remote refs.

I took time stat of `git fetch` when fetch-pack happens for chromium
repository 3 times on linux with SSD.
* with this patch
8.105s
8.309s
7.640s
avg: 8.018s

* master
12.287s
11.175s
12.227s
avg: 11.896s

On my MacBook Air which has slower lstat(2).
* with this patch
14.501s

* master
1m16.027s

`git fetch` on slow disk will be improved largely.

Signed-off-by: Takuto Ikuta <tikuta@chromium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: convert to struct object_idbrian m. carlson Mon, 12 Mar 2018 02:27:56 +0000 (02:27 +0000)

convert: convert to struct object_id

Convert convert.c to struct object_id. Add a use of the_hash_algo to
replace hard-coded constants and change a strbuf_add to a strbuf_addstr
to avoid another hard-coded constant.

Note that a strict conversion using the hexsz constant would cause
problems in the future if the internal and user-visible hash algorithms
differed, as anticipated by the hash function transition plan.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: introduce a constant for max header lengthbrian m. carlson Mon, 12 Mar 2018 02:27:55 +0000 (02:27 +0000)

sha1_file: introduce a constant for max header length

There were several instances of 32 sprinkled throughout this file, all
of which were used for allocating a buffer to store the header of an
object. Introduce a constant, MAX_HEADER_LEN, for this purpose.

Note that this constant is slightly larger than required; the longest
possible header is 28 (7 for "commit", 1 for a space, 20 for a 63-bit
length in decimal, and 1 for the NUL). However, the overallocation
should not cause any problems, so leave it as it is.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Convert lookup_replace_object to struct object_idbrian m. carlson Mon, 12 Mar 2018 02:27:54 +0000 (02:27 +0000)

Convert lookup_replace_object to struct object_id

Convert both the argument and the return value to be pointers to struct
object_id. Update the callers and their internals to deal with the new
type. Remove several temporaries which are no longer needed.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: convert read_sha1_file to struct object_idbrian m. carlson Mon, 12 Mar 2018 02:27:53 +0000 (02:27 +0000)

sha1_file: convert read_sha1_file to struct object_id

Convert read_sha1_file to take a pointer to struct object_id and rename
it read_object_file. Do the same for read_sha1_file_extended.

Convert one use in grep.c to use the new function without any other code
change, since the pointer being passed is a void pointer that is already
initialized with a pointer to struct object_id. Update the declaration
and definitions of the modified functions, and apply the following
semantic patch to convert the remaining callers:

@@
expression E1, E2, E3;
@@
- read_sha1_file(E1.hash, E2, E3)
+ read_object_file(&E1, E2, E3)

@@
expression E1, E2, E3;
@@
- read_sha1_file(E1->hash, E2, E3)
+ read_object_file(E1, E2, E3)

@@
expression E1, E2, E3, E4;
@@
- read_sha1_file_extended(E1.hash, E2, E3, E4)
+ read_object_file_extended(&E1, E2, E3, E4)

@@
expression E1, E2, E3, E4;
@@
- read_sha1_file_extended(E1->hash, E2, E3, E4)
+ read_object_file_extended(E1, E2, E3, E4)

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: convert read_object_with_reference to object_idbrian m. carlson Mon, 12 Mar 2018 02:27:52 +0000 (02:27 +0000)

sha1_file: convert read_object_with_reference to object_id

Convert read_object_with_reference to take pointers to struct object_id.
Update the internals of the function accordingly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tree-walk: convert tree entry functions to object_idbrian m. carlson Mon, 12 Mar 2018 02:27:51 +0000 (02:27 +0000)

tree-walk: convert tree entry functions to object_id

Convert get_tree_entry and find_tree_entry to take pointers to struct
object_id.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

streaming: convert istream internals to struct object_idbrian m. carlson Mon, 12 Mar 2018 02:27:50 +0000 (02:27 +0000)

streaming: convert istream internals to struct object_id

Convert the various open_istream variants to take a pointer to struct
object_id. Introduce a temporary, which will be removed later, to work
around the fact that lookup_replace_object still returns a pointer to
unsigned char.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tree-walk: convert get_tree_entry_follow_symlinks inter... brian m. carlson Mon, 12 Mar 2018 02:27:49 +0000 (02:27 +0000)

tree-walk: convert get_tree_entry_follow_symlinks internals to object_id

Convert the internals of this function to use struct object_id. This is
one of the last remaining callers of read_sha1_file_extended that has
not been converted yet.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/notes: convert static functions to object_idbrian m. carlson Mon, 12 Mar 2018 02:27:48 +0000 (02:27 +0000)

builtin/notes: convert static functions to object_id

Convert the remaining static functions to take pointers to struct
object_id.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/fmt-merge-msg: convert remaining code to object_idbrian m. carlson Mon, 12 Mar 2018 02:27:47 +0000 (02:27 +0000)

builtin/fmt-merge-msg: convert remaining code to object_id

We were using the util pointer, which is a pointer to void, as an
unsigned char pointer. The pointer actually points to a struct
origin_data, which has a struct object_id as its first member, which in
turn has an unsigned char array as its first member, so this was valid.
Since we want to convert this to struct object_id, simply change the
pointer we're using.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: convert sha1_object_info* to object_idbrian m. carlson Mon, 12 Mar 2018 02:27:46 +0000 (02:27 +0000)

sha1_file: convert sha1_object_info* to object_id

Convert sha1_object_info and sha1_object_info_extended to take pointers
to struct object_id and rename them to use "oid" instead of "sha1" in
their names. Update the declaration and definition and apply the
following semantic patch, plus the standard object_id transforms:

@@
expression E1, E2;
@@
- sha1_object_info(E1.hash, E2)
+ oid_object_info(&E1, E2)

@@
expression E1, E2;
@@
- sha1_object_info(E1->hash, E2)
+ oid_object_info(E1, E2)

@@
expression E1, E2, E3;
@@
- sha1_object_info_extended(E1.hash, E2, E3)
+ oid_object_info_extended(&E1, E2, E3)

@@
expression E1, E2, E3;
@@
- sha1_object_info_extended(E1->hash, E2, E3)
+ oid_object_info_extended(E1, E2, E3)

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

Convert remaining callers of sha1_object_info_extended... brian m. carlson Mon, 12 Mar 2018 02:27:45 +0000 (02:27 +0000)

Convert remaining callers of sha1_object_info_extended to object_id

Convert the remaining caller of sha1_object_info_extended to use struct
object_id. Introduce temporaries, which will be removed later, since
there is a dependency loop between sha1_object_info_extended and
lookup_replace_object_extended. This allows us to convert the code in a
piecemeal fashion instead of all at once.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

packfile: convert unpack_entry to struct object_idbrian m. carlson Mon, 12 Mar 2018 02:27:44 +0000 (02:27 +0000)

packfile: convert unpack_entry to struct object_id

Convert unpack_entry and read_object to use struct object_id.

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

sha1_file: convert retry_bad_packed_offset to struct... brian m. carlson Mon, 12 Mar 2018 02:27:43 +0000 (02:27 +0000)

sha1_file: convert retry_bad_packed_offset to struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: convert assert_sha1_type to object_idbrian m. carlson Mon, 12 Mar 2018 02:27:42 +0000 (02:27 +0000)

sha1_file: convert assert_sha1_type to object_id

Convert this function to take a pointer to struct object_id and rename
it to assert_oid_type.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/mktree: convert to struct object_idbrian m. carlson Mon, 12 Mar 2018 02:27:41 +0000 (02:27 +0000)

builtin/mktree: convert to struct object_id

Convert this file to use struct object_id. Modify one use of
get_sha1_hex into parse_oid_hex; this is safe since we get the data from
a strbuf.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

streaming: convert open_istream to use struct object_idbrian m. carlson Mon, 12 Mar 2018 02:27:40 +0000 (02:27 +0000)

streaming: convert open_istream to use struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: convert check_sha1_signature to struct object_idbrian m. carlson Mon, 12 Mar 2018 02:27:39 +0000 (02:27 +0000)

sha1_file: convert check_sha1_signature to struct object_id

Convert this function to take a pointer to struct object_id and rename
it check_object_signature. Introduce temporaries to convert the return
values of lookup_replace_object and lookup_replace_object_extended into
struct object_id.

The temporaries are needed because in order to convert
lookup_replace_object, open_istream needs to be converted, and
open_istream needs check_sha1_signature to be converted, causing a loop
of dependencies. The temporaries will be removed in a future patch.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>