gitweb.git
Merge branch 'jk/loose-object-fsck'Junio C Hamano Mon, 24 Apr 2017 05:07:50 +0000 (22:07 -0700)

Merge branch 'jk/loose-object-fsck'

Code cleanup.

* jk/loose-object-fsck:
sha1_file: remove an used fd variable

Merge branch 'bw/submodule-with-bs-path'Junio C Hamano Mon, 24 Apr 2017 05:07:50 +0000 (22:07 -0700)

Merge branch 'bw/submodule-with-bs-path'

"git submodule" script does not work well with strange pathnames.
Protect it from a path with slashes in them, at least.

* bw/submodule-with-bs-path:
submodule: prevent backslash expantion in submodule names

Merge branch 'jh/verify-index-checksum-only-in-fsck'Junio C Hamano Mon, 24 Apr 2017 05:07:49 +0000 (22:07 -0700)

Merge branch 'jh/verify-index-checksum-only-in-fsck'

The index file has a trailing SHA-1 checksum to detect file
corruption, and historically we checked it every time the index
file is used. Omit the validation during normal use, and instead
verify only in "git fsck".

* jh/verify-index-checksum-only-in-fsck:
read-cache: force_verify_index_checksum

Merge branch 'jh/unpack-trees-micro-optim'Junio C Hamano Mon, 24 Apr 2017 05:07:48 +0000 (22:07 -0700)

Merge branch 'jh/unpack-trees-micro-optim'

In a 2- and 3-way merge of trees, more than one source trees often
end up sharing an identical subtree; optimize by not reading the
same tree multiple times in such a case.

* jh/unpack-trees-micro-optim:
unpack-trees: avoid duplicate ODB lookups during checkout

Merge branch 'jh/string-list-micro-optim'Junio C Hamano Mon, 24 Apr 2017 05:07:47 +0000 (22:07 -0700)

Merge branch 'jh/string-list-micro-optim'

The string-list API used a custom reallocation strategy that was
very inefficient, instead of using the usual ALLOC_GROW() macro,
which has been fixed.

* jh/string-list-micro-optim:
string-list: use ALLOC_GROW macro when reallocing string_list

Merge branch 'nd/conditional-config-include'Junio C Hamano Mon, 24 Apr 2017 05:07:46 +0000 (22:07 -0700)

Merge branch 'nd/conditional-config-include'

$GIT_DIR may in some cases be normalized with all symlinks resolved
while "gitdir" path expansion in the pattern does not receive the
same treatment, leading to incorrect mismatch. This has been fixed.

* nd/conditional-config-include:
config: resolve symlinks in conditional include's patterns
path.c: and an option to call real_path() in expand_user_path()

Merge branch 'dt/http-postbuffer-can-be-large'Junio C Hamano Mon, 24 Apr 2017 05:07:45 +0000 (22:07 -0700)

Merge branch 'dt/http-postbuffer-can-be-large'

Allow the http.postbuffer configuration variable to be set to a
size that can be expressed in size_t, which can be larger than
ulong on some platforms.

* dt/http-postbuffer-can-be-large:
http.postbuffer: allow full range of ssize_t values

Merge branch 'tb/doc-eol-normalization'Junio C Hamano Mon, 24 Apr 2017 05:07:44 +0000 (22:07 -0700)

Merge branch 'tb/doc-eol-normalization'

Doc update.

* tb/doc-eol-normalization:
gitattributes.txt: document how to normalize the line endings

Merge branch 'sr/http-proxy-configuration-fix'Junio C Hamano Mon, 24 Apr 2017 05:07:44 +0000 (22:07 -0700)

Merge branch 'sr/http-proxy-configuration-fix'

"http.proxy" set to an empty string is used to disable the usage of
proxy. We broke this early last year.

* sr/http-proxy-configuration-fix:
http: fix the silent ignoring of proxy misconfiguraion
http: honor empty http.proxy option to bypass proxy

t/perf: correctly align non-ASCII descriptions in outputÆvar Arnfjörð Bjarmason Fri, 21 Apr 2017 19:44:28 +0000 (19:44 +0000)

t/perf: correctly align non-ASCII descriptions in output

Change the test descriptions from being treated as binary blobs by
perl to being treated as UTF-8. This ensures that e.g. a test
description like "æ" is counted as 1 character, not 2.

I have WIP performance tests for non-ASCII grep patterns on another
topic that are affected by this.

Now instead of:

$ ./run p0000-perf-lib-sanity.sh
[...]
0000.4: export a weird var 0.00(0.00+0.00)
0000.5: éḿíẗ ńöń-ÁŚĆÍÍ ćḧáŕáćẗéŕś 0.00(0.00+0.00)
0000.7: important variables available in subshells 0.00(0.00+0.00)
[...]

We emit:

[...]
0000.4: export a weird var 0.00(0.00+0.00)
0000.5: éḿíẗ ńöń-ÁŚĆÍÍ ćḧáŕáćẗéŕś 0.00(0.00+0.00)
0000.7: important variables available in subshells 0.00(0.00+0.00)
[...]

Fixes code originally added in 342e9ef2d9 ("Introduce a performance
testing framework", 2012-02-17).

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

cache-tree: reject entries with null sha1Jeff King Fri, 21 Apr 2017 18:46:17 +0000 (14:46 -0400)

cache-tree: reject entries with null sha1

We generally disallow null sha1s from entering the index,
due to 4337b5856 (do not write null sha1s to on-disk index,
2012-07-28). However, we loosened that in 83bd7437c
(write_index: optionally allow broken null sha1s,
2013-08-27) so that tools like filter-branch could be used
to repair broken history.

However, we should make sure that these broken entries do
not get propagated into new trees. For most entries, we'd
catch them with the missing-object check (since presumably
the null sha1 does not exist in our object database). But
gitlink entries do not need reachability, so we may blindly
copy the entry into a bogus tree.

This patch rejects all null sha1s (with the same "invalid
entry" message that missing objects get) when building trees
from the index. It does so even for non-gitlinks, and even
when "write-tree" is given the --missing-ok flag. The null
sha1 is a special sentinel value that is already rejected in
trees by fsck; whether the object exists or not, it is an
error to put it in a tree.

Note that for this to work, we must also avoid reusing an
existing cache-tree that contains the null sha1. This patch
does so by just refusing to write out any cache tree when
the index contains a null sha1. This is blunter than we need
to be; we could just reject the subtree that contains the
offending entry. But it's not worth the complexity. The
behavior is unchanged unless you have a broken index entry,
and even then we'd refuse the whole index write unless the
emergency GIT_ALLOW_NULL_SHA1 is in use. And even then the
end result is only a performance drop (any write-tree will
have to generate the whole cache-tree from scratch).

The tests bear some explanation.

The existing test in t7009 doesn't catch this problem,
because our index-filter runs "git rm --cached", which will
try to rewrite the updated index and barf on the bogus
entry. So we never even make it to write-tree. The new test
there adds a noop index-filter, which does show the problem.

The new tests in t1601 are slightly redundant with what
filter-branch is doing under the hood in t7009. But as
they're much more direct, they're easier to reason about.
And should filter-branch ever change or go away, we'd want
to make sure that these plumbing commands behave sanely.

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

completion: optionally disable checkout DWIMJeff King Fri, 21 Apr 2017 20:27:06 +0000 (16:27 -0400)

completion: optionally disable checkout DWIM

When we complete branch names for "git checkout", we also
complete remote branch names that could trigger the DWIM
behavior. Depending on your workflow and project, this can
be either convenient or annoying.

For instance, my clone of gitster.git contains 74 local
"jk/*" branches, but origin contains another 147. When I
want to checkout a local branch but can't quite remember the
name, tab completion shows me 251 entries. And worse, for a
topic that has been picked up for pu, the upstream branch
name is likely to be similar to mine, leading to a high
probability that I pick the wrong one and accidentally
create a new branch.

This patch adds a way for the user to tell the completion
code not to include DWIM suggestions for checkout. This can
already be done by typing:

git checkout --no-guess jk/<TAB>

but that's rather cumbersome. The downside, of course, is
that you no longer get completion support when you _do_ want
to invoke the DWIM behavior. But depending on your workflow,
that may not be a big loss (for instance, in git.git I am
much more likely to want to detach, so I'd type "git
checkout origin/jk/<TAB>" anyway).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: expand "push --delete <remote> <ref>" for... Ævar Arnfjörð Bjarmason Sat, 22 Apr 2017 17:55:04 +0000 (17:55 +0000)

completion: expand "push --delete <remote> <ref>" for refs on that <remote>

Change the completion of "push --delete <remote> <ref>" to complete
refs on that <remote>, not all refs.

Before this cloning git.git and doing "git push --delete origin
p<TAB>" will complete nothing, since a fresh clone of git.git will
have no "pu" branch, whereas origin/p<TAB> will uselessly complete
origin/pu, but fully qualified references aren't accepted by
"--delete".

Now p<TAB> will complete as "pu". The completion of giving --delete
later, e.g. "git push origin --delete p<TAB>" remains unchanged, this
is a bug, but is a general existing limitation of the bash completion,
and not how git-push is documented, so I'm not fixing that case, but
adding a failing TODO test for it.

The testing code was supplied by SZEDER Gábor in
<20170421122832.24617-1-szeder.dev@gmail.com> with minor setup
modifications on my part.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
Test-code-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: sv.po: Update Swedish translation (3199t0f0u)Peter Krefting Sun, 23 Apr 2017 18:47:34 +0000 (19:47 +0100)

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

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

l10n: git.pot: v2.13.0 round 1 (96 new, 37 removed)Jiang Xin Sun, 23 Apr 2017 01:55:51 +0000 (09:55 +0800)

l10n: git.pot: v2.13.0 round 1 (96 new, 37 removed)

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

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

Increase core.packedGitLimitDavid Turner Thu, 20 Apr 2017 20:41:18 +0000 (16:41 -0400)

Increase core.packedGitLimit

When core.packedGitLimit is exceeded, git will close packs. If there
is a repack operation going on in parallel with a fetch, the fetch
might open a pack, and then be forced to close it due to
packedGitLimit being hit. The repack could then delete the pack
out from under the fetch, causing the fetch to fail.

Increase core.packedGitLimit's default value to prevent
this.

On current 64-bit x86_64 machines, 48 bits of address space are
available. It appears that 64-bit ARM machines have no standard
amount of address space (that is, it varies by manufacturer), and IA64
and POWER machines have the full 64 bits. So 48 bits is the only
limit that we can reasonably care about. We reserve a few bits of the
48-bit address space for the kernel's use (this is not strictly
necessary, but it's better to be safe), and use up to the remaining
45. No git repository will be anywhere near this large any time soon,
so this should prevent the failure.

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

docs/bisect-lk2009: update java code conventions linkJeff King Thu, 20 Apr 2017 20:35:36 +0000 (16:35 -0400)

docs/bisect-lk2009: update java code conventions link

The old link just redirects to a big index page. I was able
to find a new link for the original document via Google.

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

docs/bisect-lk2009: update nist report linkJeff King Thu, 20 Apr 2017 20:35:28 +0000 (16:35 -0400)

docs/bisect-lk2009: update nist report link

The original NIST press release linked here is no longer
available. But it was just a one-page summary of a larger
planning report; we can link to the report and point people
to the executive summary, which contains the same
information.

Ideally we'd cite it with a DOI, but I couldn't dig one up
for this particular document. I found many URLs pointing to
this report, but they all end up redirecting to this one
(and it looks somewhat official).

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

docs/archimport: quote sourcecontrol.net referenceJeff King Thu, 20 Apr 2017 20:34:41 +0000 (16:34 -0400)

docs/archimport: quote sourcecontrol.net reference

git-archimport has an option to register archives at
mirrors.sourcecontrol.net. The sourcecontrol.net domain
still exists, but that hostname no longer exists.

That means this feature is presumably broken. I'll leave the
examination and modification of that to people who might
actually use archimport. But in the meantime, let's wrap the
reference in the documentation in backticks, which will
avoid turning it into a broken link (and thus polluting
linkchecker results).

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

gitcore-tutorial: update broken linkJeff King Thu, 20 Apr 2017 20:33:49 +0000 (16:33 -0400)

gitcore-tutorial: update broken link

The slides for the Linux-mentoring presentation are no
longer available. Let's point to the wayback version of the
page, which works.

Note that the referenced diagram is also available on page
15 of [1]. We could link to that instead, but it's not clear
from the URL scheme ("uploads") whether it's going to stick
around forever.

[1] https://www.linuxfoundation.jp/jp_uploads/seminar20070313/Randy.pdf

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

doc: replace or.cz gitwiki link with git.wiki.Jeff King Thu, 20 Apr 2017 20:32:39 +0000 (16:32 -0400)

doc: replace or.cz gitwiki link with git.wiki.

The or.cz version of the Git wiki went away long ago, and
now just redirects to kernel.org.

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

doc: use https links to avoid http redirectJeff King Thu, 20 Apr 2017 20:32:33 +0000 (16:32 -0400)

doc: use https links to avoid http redirect

Many sites these days unconditionally redirect http requests
to their https equivalents. Let's make our links https in
the first place to save the client a redirect.

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

connect.c: fix leak in handle_ssh_variantJeff King Thu, 20 Apr 2017 20:21:58 +0000 (16:21 -0400)

connect.c: fix leak in handle_ssh_variant

When we see an error from split_cmdline(), we exit the
function without freeing the copy of the command string we
made.

This was sort-of introduced by 22e5ae5c8 (connect.c: handle
errors from split_cmdline, 2017-04-10). The leak existed
before that, but before that commit fixed the bug, we could
never trigger this else clause in the first place.

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

am: drop "dir" parameter from am_state_initJeff King Thu, 20 Apr 2017 21:09:35 +0000 (17:09 -0400)

am: drop "dir" parameter from am_state_init

The only caller of this function passes in a static buffer
returned from git_path(). This looks dangerous at first
glance, but turns out to be OK because the first thing we do
is xstrdup() the result.

Let's turn this into a git_pathdup(). That's slightly more
efficient (no extra copy), and makes it easier to audit for
dangerous git_path() invocations.

Since there's only a single caller, let's just set this
default path inside the init function. That makes the memory
ownership clear.

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

replace strbuf_addstr(git_path()) with git_path_buf()Jeff King Thu, 20 Apr 2017 21:09:30 +0000 (17:09 -0400)

replace strbuf_addstr(git_path()) with git_path_buf()

Writing directly into the strbuf avoids a useless copy of
the data, and dropping calls to git_path() makes it easier
to audit for dangerous calls.

Note that git_path() does an implicit strbuf_reset(), but in
each of these cases we were either already doing that reset,
or writing into a fresh strbuf anyway.

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

replace xstrdup(git_path(...)) with git_pathdup(...)Jeff King Thu, 20 Apr 2017 21:09:09 +0000 (17:09 -0400)

replace xstrdup(git_path(...)) with git_pathdup(...)

It's more efficient to use git_pathdup(), as it skips an
extra copy of the path. And by removing some calls to
git_path(), it makes it easier to audit for dangerous uses.

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

use git_path_* helper functionsJeff King Thu, 20 Apr 2017 21:08:54 +0000 (17:08 -0400)

use git_path_* helper functions

Long ago we added functions like git_path_merge_msg() to
replace the more dangerous git_path("MERGE_MSG"). Over time
some new calls to the latter have crept it. Let's convert
them to use the safer form.

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

branch: add edit_description() helperJeff King Thu, 20 Apr 2017 21:08:41 +0000 (17:08 -0400)

branch: add edit_description() helper

Rather than have a variable with a short name that is fed to
git_path(), let's add a helper function that returns the
full path. This avoids the dangerous git_path() function.

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

bisect: add git_path_bisect_terms helperJeff King Thu, 20 Apr 2017 21:08:25 +0000 (17:08 -0400)

bisect: add git_path_bisect_terms helper

This avoids using the dangerous git_path(). Right now
there's only one call site (because the writing half is
still part of the shell script), but it may come in handy in
the future as more of bisect is written in C. It also
matches how we access the other BISECT_* files.

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

read-cache: avoid using git_path() in freshen_shared_in... Christian Couder Thu, 30 Mar 2017 21:03:54 +0000 (23:03 +0200)

read-cache: avoid using git_path() in freshen_shared_index()

When performing an interactive rebase in split-index mode,
the commit message that one should rework when squashing commits
can contain some garbage instead of the usual concatenation of
both of the commit messages.

The code uses git_path() to compute the shared index filename, and
passes it to check_and_freshen_file() as its argument; there is no
guarantee that the rotating pathname buffer passed as argument will
stay valid during the life of this call. Make our own copy before
calling the function and pass the copy as its argument to avoid this
risky pattern.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

worktree add: add --lock optionNguyễn Thái Ngọc Duy Wed, 12 Apr 2017 13:58:05 +0000 (20:58 +0700)

worktree add: add --lock option

As explained in the document. This option has an advantage over the
command sequence "git worktree add && git worktree lock": there will be
no gap that somebody can accidentally "prune" the new worktree (or soon,
explicitly "worktree remove" it).

"worktree add" does keep a lock on while it's preparing the worktree.
If --lock is specified, this lock remains after the worktree is created.

Suggested-by: David Taylor <David.Taylor@dell.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 2.13-rc0 v2.13.0-rc0Junio C Hamano Thu, 20 Apr 2017 04:42:08 +0000 (21:42 -0700)

Git 2.13-rc0

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

Merge branch 'jh/memihash-opt'Junio C Hamano Thu, 20 Apr 2017 04:37:25 +0000 (21:37 -0700)

Merge branch 'jh/memihash-opt'

Hotfix for a topic that is already in 'master'.

* jh/memihash-opt:
p0004: make perf test executable
t3008: skip lazy-init test on a single-core box
test-online-cpus: helper to return cpu count
name-hash: fix buffer overrun

Merge branch 'vn/revision-shorthand-for-side-branch... Junio C Hamano Thu, 20 Apr 2017 04:37:25 +0000 (21:37 -0700)

Merge branch 'vn/revision-shorthand-for-side-branch-log'

Doc cleanup.

* vn/revision-shorthand-for-side-branch-log:
doc/revisions: remove brackets from rev^-n shorthand

Merge branch 'sf/putty-w-args'Junio C Hamano Thu, 20 Apr 2017 04:37:24 +0000 (21:37 -0700)

Merge branch 'sf/putty-w-args'

* sf/putty-w-args:
connect.c: handle errors from split_cmdline

Merge branch 'ld/p4-current-branch-fix'Junio C Hamano Thu, 20 Apr 2017 04:37:23 +0000 (21:37 -0700)

Merge branch 'ld/p4-current-branch-fix'

"git p4" used "name-rev HEAD" when it wants to learn what branch is
checked out; it should use "symbolic-ref HEAD".

* ld/p4-current-branch-fix:
git-p4: don't use name-rev to get current branch
git-p4: add read_pipe_text() internal function
git-p4: add failing test for name-rev rather than symbolic-ref

Merge branch 'dt/gc-ignore-old-gc-logs'Junio C Hamano Thu, 20 Apr 2017 04:37:22 +0000 (21:37 -0700)

Merge branch 'dt/gc-ignore-old-gc-logs'

* dt/gc-ignore-old-gc-logs:
t6500: wait for detached auto gc at the end of the test script

Merge branch 'bw/attr-pathspec'Junio C Hamano Thu, 20 Apr 2017 04:37:21 +0000 (21:37 -0700)

Merge branch 'bw/attr-pathspec'

* bw/attr-pathspec:
pathspec: fix segfault in clear_pathspec

Merge branch 'ab/grep-plug-pathspec-leak'Junio C Hamano Thu, 20 Apr 2017 04:37:21 +0000 (21:37 -0700)

Merge branch 'ab/grep-plug-pathspec-leak'

Call clear_pathspec() to release resources immediately before the
cmd_grep() function returns.

* ab/grep-plug-pathspec-leak:
grep: plug a trivial memory leak

Merge branch 'jk/no-looking-at-dotgit-outside-repo'Junio C Hamano Thu, 20 Apr 2017 04:37:20 +0000 (21:37 -0700)

Merge branch 'jk/no-looking-at-dotgit-outside-repo'

Clean up fallouts from recent tightening of the set-up sequence,
where Git barfs when repository information is accessed without
first ensuring that it was started in a repository.

* jk/no-looking-at-dotgit-outside-repo:
test-read-cache: setup git dir
has_sha1_file: don't bother if we are not in a repository

Merge branch 'nd/files-backend-git-dir'Junio C Hamano Thu, 20 Apr 2017 04:37:19 +0000 (21:37 -0700)

Merge branch 'nd/files-backend-git-dir'

The "submodule" specific field in the ref_store structure is
replaced with a more generic "gitdir" that can later be used also
when dealing with ref_store that represents the set of refs visible
from the other worktrees.

* nd/files-backend-git-dir: (28 commits)
refs.h: add a note about sorting order of for_each_ref_*
t1406: new tests for submodule ref store
t1405: some basic tests on main ref store
t/helper: add test-ref-store to test ref-store functions
refs: delete pack_refs() in favor of refs_pack_refs()
files-backend: avoid ref api targeting main ref store
refs: new transaction related ref-store api
refs: add new ref-store api
refs: rename get_ref_store() to get_submodule_ref_store() and make it public
files-backend: replace submodule_allowed check in files_downcast()
refs: move submodule code out of files-backend.c
path.c: move some code out of strbuf_git_path_submodule()
refs.c: make get_main_ref_store() public and use it
refs.c: kill register_ref_store(), add register_submodule_ref_store()
refs.c: flatten get_ref_store() a bit
refs: rename lookup_ref_store() to lookup_submodule_ref_store()
refs.c: introduce get_main_ref_store()
files-backend: remove the use of git_path()
files-backend: add and use files_ref_path()
files-backend: add and use files_reflog_path()
...

Merge branch 'bw/submodule-is-active'Junio C Hamano Thu, 20 Apr 2017 04:37:18 +0000 (21:37 -0700)

Merge branch 'bw/submodule-is-active'

Error message fix.

* bw/submodule-is-active:
submodule--helper: fix typo in is_active error message

Merge branch 'va/i18n-perl-scripts'Junio C Hamano Thu, 20 Apr 2017 04:37:17 +0000 (21:37 -0700)

Merge branch 'va/i18n-perl-scripts'

Message fix.

* va/i18n-perl-scripts:
git-add--interactive.perl: add missing dot in a message

Merge branch 'sb/submodule-rm-absorb'Junio C Hamano Thu, 20 Apr 2017 04:37:17 +0000 (21:37 -0700)

Merge branch 'sb/submodule-rm-absorb'

Error message fix.

* sb/submodule-rm-absorb:
submodule.c: add missing ' in error messages

Merge branch 'ah/diff-files-ours-theirs-doc'Junio C Hamano Thu, 20 Apr 2017 04:37:16 +0000 (21:37 -0700)

Merge branch 'ah/diff-files-ours-theirs-doc'

The diff options "--ours", "--theirs" exist for quite some time.
But so far they were not documented. Now they are.

* ah/diff-files-ours-theirs-doc:
diff-files: document --ours etc.

Merge branch 'lt/mailinfo-in-body-header-continuation'Junio C Hamano Thu, 20 Apr 2017 04:37:15 +0000 (21:37 -0700)

Merge branch 'lt/mailinfo-in-body-header-continuation'

If a patch e-mail had its first paragraph after an in-body header
indented (even after a blank line after the in-body header line),
the indented line was mistook as a continuation of the in-body
header. This has been fixed.

* lt/mailinfo-in-body-header-continuation:
mailinfo: fix in-body header continuations

Merge branch 'bw/push-options-recursively-to-submodules'Junio C Hamano Thu, 20 Apr 2017 04:37:14 +0000 (21:37 -0700)

Merge branch 'bw/push-options-recursively-to-submodules'

"git push --recurse-submodules --push-option=<string>" learned to
propagate the push option recursively down to pushes in submodules.

* bw/push-options-recursively-to-submodules:
push: propagate remote and refspec with --recurse-submodules
submodule--helper: add push-check subcommand
remote: expose parse_push_refspec function
push: propagate push-options with --recurse-submodules
push: unmark a local variable as static

Merge branch 'bc/object-id'Junio C Hamano Thu, 20 Apr 2017 04:37:13 +0000 (21:37 -0700)

Merge branch 'bc/object-id'

Conversion from unsigned char [40] to struct object_id continues.

* bc/object-id:
Documentation: update and rename api-sha1-array.txt
Rename sha1_array to oid_array
Convert sha1_array_for_each_unique and for_each_abbrev to object_id
Convert sha1_array_lookup to take struct object_id
Convert remaining callers of sha1_array_lookup to object_id
Make sha1_array_append take a struct object_id *
sha1-array: convert internal storage for struct sha1_array to object_id
builtin/pull: convert to struct object_id
submodule: convert check_for_new_submodule_commits to object_id
sha1_name: convert disambiguate_hint_fn to take object_id
sha1_name: convert struct disambiguate_state to object_id
test-sha1-array: convert most code to struct object_id
parse-options-cb: convert sha1_array_append caller to struct object_id
fsck: convert init_skiplist to struct object_id
builtin/receive-pack: convert portions to struct object_id
builtin/pull: convert portions to struct object_id
builtin/diff: convert to struct object_id
Convert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZ
Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZ
Define new hash-size constants for allocating memory

Merge branch 'sb/submodule-short-status'Junio C Hamano Thu, 20 Apr 2017 04:37:12 +0000 (21:37 -0700)

Merge branch 'sb/submodule-short-status'

The output from "git status --short" has been extended to show
various kinds of dirtyness in submodules differently; instead of to
"M" for modified, 'm' and '?' can be shown to signal changes only
to the working tree of the submodule but not the commit that is
checked out.

* sb/submodule-short-status:
submodule.c: correctly handle nested submodules in is_submodule_modified
short status: improve reporting for submodule changes
submodule.c: stricter checking for submodules in is_submodule_modified
submodule.c: port is_submodule_modified to use porcelain 2
submodule.c: convert is_submodule_modified to use strbuf_getwholeline
submodule.c: factor out early loop termination in is_submodule_modified
submodule.c: use argv_array in is_submodule_modified

read-cache: speed up has_dir_name (part 2)Jeff Hostetler Wed, 19 Apr 2017 17:06:18 +0000 (17:06 +0000)

read-cache: speed up has_dir_name (part 2)

Teach has_dir_name() to see if the path of the new item
is greater than the last path in the index array before
attempting to search for it.

has_dir_name() is looking for file/directory collisions
in the index and has to consider each sub-directory
prefix in turn. This can cause multiple binary searches
for each path.

During operations like checkout, merge_working_tree()
populates the new index in sorted order, so we expect
to be able to append in many cases.

This commit is part 2 of 2. This commit handles the
additional possible short-cuts as we look at each
sub-directory prefix.

The net-net gains for add_index_entry_with_check() and
both had_dir_name() commits are best seen for very
large repos.

Here are results for an INFLATED version of linux.git
with 1M files.

$ GIT_PERF_REPO=/mnt/test/linux_inflated.git/ ./run upstream/base HEAD ./p0006-read-tree-checkout.sh
Test upstream/base HEAD
0006.2: read-tree br_base br_ballast (1043893) 3.79(3.63+0.15) 2.68(2.52+0.15) -29.3%
0006.3: switch between br_base br_ballast (1043893) 7.55(6.58+0.44) 6.03(4.60+0.43) -20.1%
0006.4: switch between br_ballast br_ballast_plus_1 (1043893) 10.84(9.26+0.59) 8.44(7.06+0.65) -22.1%
0006.5: switch between aliases (1043893) 10.93(9.39+0.58) 10.24(7.04+0.63) -6.3%

Here are results for a synthetic repo with 4.2M files.

$ GIT_PERF_REPO=~/work/gfw/t/perf/repos/gen-many-files-10.4.3.git/ ./run HEAD~3 HEAD ./p0006-read-tree-checkout.sh
Test HEAD~3 HEAD
0006.2: read-tree br_base br_ballast (4194305) 29.96(19.26+10.50) 23.76(13.42+10.12) -20.7%
0006.3: switch between br_base br_ballast (4194305) 56.95(36.08+16.83) 45.54(25.94+15.68) -20.0%
0006.4: switch between br_ballast br_ballast_plus_1 (4194305) 90.94(51.50+31.52) 78.22(39.39+30.70) -14.0%
0006.5: switch between aliases (4194305) 93.72(51.63+34.09) 77.94(39.00+30.88) -16.8%

Results for medium repos (like linux.git) are mixed and have
more variance (probably do to disk IO unrelated to this test.

$ GIT_PERF_REPO=/mnt/test/linux.git/ ./run HEAD~3 HEAD ./p0006-read-tree-checkout.sh
Test HEAD~3 HEAD
0006.2: read-tree br_base br_ballast (57994) 0.25(0.21+0.03) 0.20(0.17+0.02) -20.0%
0006.3: switch between br_base br_ballast (57994) 10.67(6.06+2.92) 10.51(5.94+2.91) -1.5%
0006.4: switch between br_ballast br_ballast_plus_1 (57994) 0.59(0.47+0.16) 0.52(0.40+0.13) -11.9%
0006.5: switch between aliases (57994) 0.59(0.44+0.17) 0.51(0.38+0.14) -13.6%

$ GIT_PERF_REPO=/mnt/test/linux.git/ ./run HEAD~3 HEAD ./p0006-read-tree-checkout.sh
Test HEAD~3 HEAD
0006.2: read-tree br_base br_ballast (57994) 0.24(0.21+0.02) 0.21(0.18+0.02) -12.5%
0006.3: switch between br_base br_ballast (57994) 10.42(5.98+2.91) 10.66(5.86+3.09) +2.3%
0006.4: switch between br_ballast br_ballast_plus_1 (57994) 0.59(0.49+0.13) 0.53(0.37+0.16) -10.2%
0006.5: switch between aliases (57994) 0.59(0.43+0.17) 0.50(0.37+0.14) -15.3%

Results for smaller repos (like git.git) are not significant.
$ ./run HEAD~3 HEAD ./p0006-read-tree-checkout.sh
Test HEAD~3 HEAD
0006.2: read-tree br_base br_ballast (3043) 0.01(0.00+0.00) 0.01(0.00+0.00) +0.0%
0006.3: switch between br_base br_ballast (3043) 0.31(0.17+0.11) 0.29(0.19+0.08) -6.5%
0006.4: switch between br_ballast br_ballast_plus_1 (3043) 0.03(0.02+0.00) 0.03(0.02+0.00) +0.0%
0006.5: switch between aliases (3043) 0.03(0.02+0.00) 0.03(0.02+0.00) +0.0%

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

read-cache: speed up has_dir_name (part 1)Jeff Hostetler Wed, 19 Apr 2017 17:06:17 +0000 (17:06 +0000)

read-cache: speed up has_dir_name (part 1)

Teach has_dir_name() to see if the path of the new item
is greater than the last path in the index array before
attempting to search for it.

has_dir_name() is looking for file/directory collisions
in the index and has to consider each sub-directory
prefix in turn. This can cause multiple binary searches
for each path.

During operations like checkout, merge_working_tree()
populates the new index in sorted order, so we expect
to be able to append in many cases.

This commit is part 1 of 2. This commit handles the top
of has_dir_name() and the trivial optimization.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

read-cache: speed up add_index_entry during checkoutJeff Hostetler Wed, 19 Apr 2017 17:06:16 +0000 (17:06 +0000)

read-cache: speed up add_index_entry during checkout

Teach add_index_entry_with_check() to see if the path
of the new item is greater than the last path in the
index array before attempting to search for it.

During checkout, merge_working_tree() populates the new
index in sorted order, so this change will save a binary
lookups per file. This preserves the original behavior
but simply checks the last element before starting the
search.

This helps performance on very large repositories.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

p0006-read-tree-checkout: perf test to time read-treeJeff Hostetler Wed, 19 Apr 2017 17:06:15 +0000 (17:06 +0000)

p0006-read-tree-checkout: perf test to time read-tree

Created t/perf/repos/many-files.sh to generate large, but
artificial repositories.

Created t/perf/inflate-repo.sh to alter an EXISTING repo
to have a set of large commits. This can be used to create
a branch with 1M+ files in repositories like git.git or
linux.git, but with more realistic content. It does this
by making multiple copies of the entire worktree in a series
of sub-directories.

The branch name and ballast structure created by both scripts
match, so either script can be used to generate very large
test repositories for the following perf test.

Created t/perf/p0006-read-tree-checkout.sh to measure
performance on various read-tree, checkout, and update-index
operations. This test can run using either normal repos or
ones from the above scripts.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitmodules: clarify the ignore option valuesSebastian Schuberth Wed, 19 Apr 2017 09:15:15 +0000 (09:15 +0000)

gitmodules: clarify the ignore option values

Add more structure and describe each possible option in a self-contained
way, not referring to any of the previously described options.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitmodules: clarify what history depth a shallow clone hasSebastian Schuberth Wed, 19 Apr 2017 07:56:33 +0000 (07:56 +0000)

gitmodules: clarify what history depth a shallow clone has

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: document & test --force-with-lease with multiple... Ævar Arnfjörð Bjarmason Wed, 19 Apr 2017 09:22:03 +0000 (09:22 +0000)

push: document & test --force-with-lease with multiple remotes

Document & test for cases where there are two remotes pointing to the
same URL, and a background fetch & subsequent `git push
--force-with-lease` shouldn't clobber un-updated references we haven't
fetched.

Some editors like Microsoft's VSC have a feature to auto-fetch in the
background, this bypasses the protections offered by
--force-with-lease & --force-with-lease=<refname>, as noted in the
documentation being added here.

See the 'Tools that do an automatic fetch defeat "git push
--force-with-lease"' (<1491617750.2149.10.camel@mattmccutchen.net>)
git mailing list thread for more details. Jakub Narębski suggested
this method of adding another remote to bypass this edge case,
document that & add a test for it.

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

config: correct file reading order in read_early_config()Nguyễn Thái Ngọc Duy Mon, 17 Apr 2017 10:10:02 +0000 (17:10 +0700)

config: correct file reading order in read_early_config()

Config file reading order is important because each file can override
values in the previous files and this is expected behavior. Normally
we read in this order, all in do_git_config_sequence():

1. $HOME/.gitconfig
2. $GIT_DIR/config
3. config from command line

However in read_early_config() the order may be swapped a bit if
setup_git_directory() has not been called:

1. $HOME/.gitconfig
2. $GIT_DIR/config is NOT read because .git dir is not found _yet_
3. config from command line
4. $GIT_DIR/config is now READ (after discover_git_directory() call)

The reading at step 4 could override config at step 3, which is not
the expectation.

Now that we could pass the .git dir around, we could feed
discover_git_directory() back to step 2, so that it works again, and
remove step 4.

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

rebase: pass --[no-]signoff option to git amGiuseppe Bilotta Tue, 18 Apr 2017 09:29:05 +0000 (11:29 +0200)

rebase: pass --[no-]signoff option to git am

This makes it easy to sign off a whole patchset before submission.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

xgethostname: handle long hostnamesDavid Turner Tue, 18 Apr 2017 21:57:43 +0000 (17:57 -0400)

xgethostname: handle long hostnames

If the full hostname doesn't fit in the buffer supplied to
gethostname, POSIX does not specify whether the buffer will be
null-terminated, so to be safe, we should do it ourselves. Introduce
new function, xgethostname, which ensures that there is always a \0
at the end of the buffer.

Signed-off-by: David Turner <dturner@twosigma.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use HOST_NAME_MAX to size buffers for gethostname(2)René Scharfe Tue, 18 Apr 2017 21:57:42 +0000 (17:57 -0400)

use HOST_NAME_MAX to size buffers for gethostname(2)

POSIX limits the length of host names to HOST_NAME_MAX. Export the
fallback definition from daemon.c and use this constant to make all
buffers used with gethostname(2) big enough for any possible result
and a terminating NUL.

Inspired-by: David Turner <dturner@twosigma.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: David Turner <dturner@twosigma.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

p0004: make perf test executableChristian Couder Tue, 18 Apr 2017 14:24:07 +0000 (16:24 +0200)

p0004: make perf test executable

It looks like in 89c3b0ad43 (name-hash: add perf test for lazy_init_name_hash,
2017-03-23) p0004 was not created with the execute unix rights.
Let's fix that.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Acked-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: fix path used when recursing into submodulesJacob Keller Thu, 13 Apr 2017 17:12:24 +0000 (10:12 -0700)

ls-files: fix path used when recursing into submodules

Don't assume that the current working directory is the root of the
repository. Correctly generate the path for the recursing child
processes by building it from the work_tree() root instead. Otherwise if
we run ls-files using --git-dir or --work-tree it will not work
correctly as it attempts to change directory into a potentially invalid
location. Best case, it doesn't exist and we produce an error. Worst
case we cd into the wrong location and unknown behavior occurs.

Add a new test which highlights this possibility.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

replace: plug a memory leakJunio C Hamano Tue, 18 Apr 2017 04:56:54 +0000 (21:56 -0700)

replace: plug a memory leak

Recent update to for_each_replace_name() to make it use a strbuf in
place of a fixed buffer forgot to release the memory held by the
strbuf before leaving the function.

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

doc: trivial typo in git-format-patch.txtGiuseppe Bilotta Mon, 17 Apr 2017 22:32:53 +0000 (00:32 +0200)

doc: trivial typo in git-format-patch.txt

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: handle conditional include when $GIT_DIR is... Nguyễn Thái Ngọc Duy Mon, 17 Apr 2017 10:10:01 +0000 (17:10 +0700)

config: handle conditional include when $GIT_DIR is not set up

If setup_git_directory() and friends have not been called,
get_git_dir() (because of includeIf.gitdir:XXX) would lead to

die("BUG: setup_git_env called without repository");

There are two cases when a config file could be read before $GIT_DIR
is located.

The first one is check_repository_format(), where we read just the one
file $GIT_DIR/config to check if we could understand this
repository. This case should be safe. We do not parse include
directives, which can only be triggered from git_config_with_options,
but setup code uses a lower-level function. The concerned variables
should never be hidden away behind includes anyway.

The second one is triggered in check_pager_config() when we're about
to run an external git command. We might be able to find $GIT_DIR in
this case, which is exactly what read_early_config() does (and also is
what check_pager_config() uses). Conditional includes and
get_git_dir() could be triggered by the first
git_config_with_options() call there, before discover_git_directory()
is used as a fallback $GIT_DIR detection.

Detect this special "early reading" case, pass down the $GIT_DIR,
either from previous setup or detected by discover_git_directory(),
and make conditional include use it.

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

config: prepare to pass more info in git_config_with_op... Nguyễn Thái Ngọc Duy Mon, 17 Apr 2017 10:10:00 +0000 (17:10 +0700)

config: prepare to pass more info in git_config_with_options()

So far we can only pass one flag, respect_includes, to thie function. We
need to pass some more (non-flag even), so let's make it accept a struct
instead of an integer.

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

ls-files: fix recurse-submodules with nested submodulesJacob Keller Thu, 13 Apr 2017 17:12:23 +0000 (10:12 -0700)

ls-files: fix recurse-submodules with nested submodules

Since commit e77aa336f116 ("ls-files: optionally recurse into
submodules", 2016-10-07) ls-files has known how to recurse into
submodules when displaying files.

Unfortunately this fails for certain cases, including when nesting more
than one submodule, called from within a submodule that itself has
submodules, or when the GIT_DIR environemnt variable is set.

Prior to commit b58a68c1c187 ("setup: allow for prefix to be passed to
git commands", 2017-03-17) this resulted in an error indicating that
--prefix and --super-prefix were incompatible.

After this commit, instead, the process loops forever with a GIT_DIR set
to the parent and continuously reads the parent submodule files and
recursing forever.

Fix this by preparing the environment properly for submodules when
setting up the child process. This is similar to how other commands such
as grep behave.

This was not caught by the original tests because the scenario is
avoided if the submodules are created separately and not stored as the
standard method of putting the submodule git directory under
.git/modules/<name>. We can update the test to show the failure by the
addition of "git submodule absorbgitdirs" to the test case. However,
note that this new test would run forever without the necessary fix in
this patch.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch-pack: show clearer error message upon ERRJonathan Tan Wed, 12 Apr 2017 18:06:02 +0000 (11:06 -0700)

fetch-pack: show clearer error message upon ERR

Currently, fetch-pack prints a confusing error message ("expected
ACK/NAK") when the server it's communicating with sends a pkt-line
starting with "ERR". Replace it with a less confusing error message.

Also update the documentation describing the fetch-pack/upload-pack
protocol (pack-protocol.txt) to indicate that "ERR" can be sent in the
place of "ACK" or "NAK". In practice, this has been done for quite some
time by other Git implementations (e.g. JGit sends "want $id not valid")
and by Git itself (since commit bdb31ea: "upload-pack: report "not our
ref" to client", 2017-02-23) whenever a "want" line references an object
that it does not have. (This is uncommon, but can happen if a repository
is garbage-collected during a negotiation.)

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

submodule: remove a superfluous second check for the... Sebastian Schuberth Mon, 17 Apr 2017 07:59:47 +0000 (07:59 +0000)

submodule: remove a superfluous second check for the "new" variable

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

server-info: avoid calling fclose(3) twice in update_in... René Scharfe Sun, 16 Apr 2017 16:55:58 +0000 (18:55 +0200)

server-info: avoid calling fclose(3) twice in update_info_file()

If an error occurs when or after closing the stream we call fclose(3)
again in the error handler. The second call can exhibit undefined
behavior, so make sure to call fclose(3) at most once. Also avoid
calling close(2) after fd has been successfully associated with the
stream, as fclose(3) has become responsible for doing that beyond
this point.

Found with Cppcheck.

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

files_for_each_reflog_ent_reverse(): close stream and... René Scharfe Sun, 16 Apr 2017 16:55:46 +0000 (18:55 +0200)

files_for_each_reflog_ent_reverse(): close stream and free strbuf on error

Exit the loop orderly through the cleanup code, instead of dashing out
with logfp still open and sb leaking.

Found with Cppcheck.

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

t1400: use consistent style for test_expect_success... Kyle Meyer Sun, 16 Apr 2017 02:31:02 +0000 (22:31 -0400)

t1400: use consistent style for test_expect_success calls

Structure calls as

test_expect_success 'description' '
body
'

Use double quotes for the description if it requires parameter
expansion or contains a single quote.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc/revisions: remove brackets from rev^-n shorthandKyle Meyer Sun, 16 Apr 2017 04:07:57 +0000 (00:07 -0400)

doc/revisions: remove brackets from rev^-n shorthand

Given that other instances of "{...}" in the revision documentation
represent literal characters of revision specifications, describing
the rev^-n shorthand as "<rev>^-{<n>}" incorrectly suggests that
something like "master^-{1}" is an acceptable form.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Twelfth batch for 2.13Junio C Hamano Mon, 17 Apr 2017 06:30:49 +0000 (23:30 -0700)

Twelfth batch for 2.13

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

Merge branch 'js/difftool-builtin'Junio C Hamano Mon, 17 Apr 2017 06:29:34 +0000 (23:29 -0700)

Merge branch 'js/difftool-builtin'

Code cleanup.

* js/difftool-builtin:
difftool: fix use-after-free
difftool: avoid strcpy

Merge branch 'sb/unpack-trees-would-lose-submodule... Junio C Hamano Mon, 17 Apr 2017 06:29:34 +0000 (23:29 -0700)

Merge branch 'sb/unpack-trees-would-lose-submodule-message-update'

Update an error message.

* sb/unpack-trees-would-lose-submodule-message-update:
unpack-trees.c: align submodule error message to the other error messages

Merge branch 'ab/regen-perl-mak-with-different-perl'Junio C Hamano Mon, 17 Apr 2017 06:29:33 +0000 (23:29 -0700)

Merge branch 'ab/regen-perl-mak-with-different-perl'

Update the build dependency so that an update to /usr/bin/perl
etc. result in recomputation of perl.mak file.

* ab/regen-perl-mak-with-different-perl:
perl: regenerate perl.mak if perl -V changes

Merge branch 'sb/show-diff-for-submodule-in-diff-fix'Junio C Hamano Mon, 17 Apr 2017 06:29:32 +0000 (23:29 -0700)

Merge branch 'sb/show-diff-for-submodule-in-diff-fix'

"git diff --submodule=diff" learned to work better in a project
with a submodule that in turn has its own submodules.

* sb/show-diff-for-submodule-in-diff-fix:
diff: submodule inline diff to initialize env array.

Merge branch 'qp/bisect-docfix'Junio C Hamano Mon, 17 Apr 2017 06:29:31 +0000 (23:29 -0700)

Merge branch 'qp/bisect-docfix'

Doc update.

* qp/bisect-docfix:
git-bisect.txt: add missing word

Merge branch 'mm/ls-files-s-doc'Junio C Hamano Mon, 17 Apr 2017 06:29:30 +0000 (23:29 -0700)

Merge branch 'mm/ls-files-s-doc'

Doc update.

* mm/ls-files-s-doc:
Documentation: document elements in "ls-files -s" output in order

Merge branch 'jk/loose-object-info-report-error'Junio C Hamano Mon, 17 Apr 2017 06:29:30 +0000 (23:29 -0700)

Merge branch 'jk/loose-object-info-report-error'

Update error handling for codepath that deals with corrupt loose
objects.

* jk/loose-object-info-report-error:
index-pack: detect local corruption in collision check
sha1_loose_object_info: return error for corrupted objects

Merge branch 'jc/bs-t-is-not-a-tab-for-sed'Junio C Hamano Mon, 17 Apr 2017 06:29:28 +0000 (23:29 -0700)

Merge branch 'jc/bs-t-is-not-a-tab-for-sed'

Code cleanup.

* jc/bs-t-is-not-a-tab-for-sed:
contrib/git-resurrect.sh: do not write \t for HT in sed scripts

Merge branch 'jc/unused-symbols'Junio C Hamano Mon, 17 Apr 2017 06:29:27 +0000 (23:29 -0700)

Merge branch 'jc/unused-symbols'

Code cleanup.

* jc/unused-symbols:
remote.[ch]: parse_push_cas_option() can be static

Merge branch 'jk/snprintf-cleanups'Junio C Hamano Mon, 17 Apr 2017 06:29:26 +0000 (23:29 -0700)

Merge branch 'jk/snprintf-cleanups'

Code clean-up.

* jk/snprintf-cleanups:
daemon: use an argv_array to exec children
gc: replace local buffer with git_path
transport-helper: replace checked snprintf with xsnprintf
convert unchecked snprintf into xsnprintf
combine-diff: replace malloc/snprintf with xstrfmt
replace unchecked snprintf calls with heap buffers
receive-pack: print --pack-header directly into argv array
name-rev: replace static buffer with strbuf
create_branch: use xstrfmt for reflog message
create_branch: move msg setup closer to point of use
avoid using mksnpath for refs
avoid using fixed PATH_MAX buffers for refs
fetch: use heap buffer to format reflog
tag: use strbuf to format tag header
diff: avoid fixed-size buffer for patch-ids
odb_mkstemp: use git_path_buf
odb_mkstemp: write filename into strbuf
do not check odb_mkstemp return value for errors

do_for_each_entry_in_dir(): delete functionMichael Haggerty Sun, 16 Apr 2017 06:41:42 +0000 (08:41 +0200)

do_for_each_entry_in_dir(): delete function

Its only remaining caller was itself.

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

files_pack_refs(): use reference iterationMichael Haggerty Sun, 16 Apr 2017 06:41:41 +0000 (08:41 +0200)

files_pack_refs(): use reference iteration

Use reference iteration rather than `do_for_each_entry_in_dir()` in
the definition of `files_pack_refs()`. This makes the code shorter and
easier to follow, because the logic can be inline rather than spread
between the main function and a callback function, and it removes the
need to use `pack_refs_cb_data` to preserve intermediate state.

This removes the last callers of `entry_resolves_to_object()` and
`get_loose_ref_dir()`, so delete those functions.

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

commit_packed_refs(): use reference iterationMichael Haggerty Sun, 16 Apr 2017 06:41:40 +0000 (08:41 +0200)

commit_packed_refs(): use reference iteration

Use reference iteration rather than do_for_each_entry_in_dir() in the
definition of commit_packed_refs().

Note that an internal consistency check that was previously done in
`write_packed_entry_fn()` is not there anymore. This is actually an
improvement:

The old error message was emitted when there is an entry in the
packed-ref cache that is not `REF_KNOWS_PEELED`, and when we attempted
to peel the reference, the result was `PEEL_INVALID`,
`PEEL_IS_SYMREF`, or `PEEL_BROKEN`. Since a packed ref cannot be a
symref, `PEEL_IS_SYMREF` and `PEEL_BROKEN` can be ruled out. So we're
left with `PEEL_INVALID`.

An entry without `REF_KNOWS_PEELED` can get into the packed-refs cache
in the following two ways:

* The reference was read from a `packed-refs` file that didn't have
the `fully-peeled` attribute. In that case, we *don't want* to emit
an error, because the broken value is presumably a stale value of
the reference that is now masked by a loose version of the same
reference (which we just don't happen to be packing this time). This
is a perfectly legitimate situation and doesn't indicate that the
repository is corrupt. The old code incorrectly emits an error
message in this case. (It was probably never reported as a bug
because this scenario is rare.)

* The reference was a loose reference that was just added to the
packed ref cache by `files_packed_refs()` via
`pack_if_possible_fn()` in preparation for being packed. The latter
function refuses to pack a reference for which
`entry_resolves_to_object()` returns false, and otherwise calls
`peel_entry()` itself and checks the return value. So an entry added
this way should always have `REF_KNOWS_PEELED` and shouldn't trigger
the error message in either the old code or the new.

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

cache_ref_iterator_begin(): make function smarterMichael Haggerty Sun, 16 Apr 2017 06:41:39 +0000 (08:41 +0200)

cache_ref_iterator_begin(): make function smarter

Change `cache_ref_iterator_begin()` to take two new arguments:

* `prefix` -- to iterate only over references with the specified
prefix.

* `prime_dir` -- to "prime" (i.e., pre-load) the cache before starting
the iteration.

The new functionality makes it possible for
`files_ref_iterator_begin()` to be made more ignorant of the internals
of `ref_cache`, and `find_containing_dir()` and `prime_ref_dir()` to
be made private.

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

get_loose_ref_cache(): new functionMichael Haggerty Sun, 16 Apr 2017 06:41:38 +0000 (08:41 +0200)

get_loose_ref_cache(): new function

Extract a new function, `get_loose_ref_cache()`, from
get_loose_ref_dir(). The function returns the `ref_cache` for the
loose refs of a `files_ref_store`.

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

get_loose_ref_dir(): function renamed from get_loose_refs()Michael Haggerty Sun, 16 Apr 2017 06:41:37 +0000 (08:41 +0200)

get_loose_ref_dir(): function renamed from get_loose_refs()

The new name is more analogous to `get_packed_ref_dir()`.

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

do_for_each_entry_in_dir(): eliminate `offset` argumentMichael Haggerty Sun, 16 Apr 2017 06:41:36 +0000 (08:41 +0200)

do_for_each_entry_in_dir(): eliminate `offset` argument

It was never used.

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

refs: handle "refs/bisect/" in `loose_fill_ref_dir()`Michael Haggerty Sun, 16 Apr 2017 06:41:35 +0000 (08:41 +0200)

refs: handle "refs/bisect/" in `loose_fill_ref_dir()`

That "refs/bisect/" has to be handled specially when filling the
ref_cache for loose references is a peculiarity of the files backend,
and the ref-cache code shouldn't need to know about it. So move this
code to the callback function, `loose_fill_ref_dir()`.

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

ref-cache: use a callback function to fill the cacheMichael Haggerty Sun, 16 Apr 2017 06:41:34 +0000 (08:41 +0200)

ref-cache: use a callback function to fill the cache

It is a leveling violation for `ref_cache` to know about
`files_ref_store` or that it should call `read_loose_refs()` to lazily
fill cache directories. So instead, have its constructor take as an
argument a callback function that it should use for lazy-filling, and
change `files_ref_store` to supply a pointer to function
`read_loose_refs` (renamed to `loose_fill_ref_dir`) when creating the
ref cache for its loose refs.

This means that we can generify the type of the back-pointer in
`struct ref_cache` from `files_ref_store` to `ref_store`.

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

refs: record the ref_store in ref_cache, not ref_dirMichael Haggerty Sun, 16 Apr 2017 06:41:33 +0000 (08:41 +0200)

refs: record the ref_store in ref_cache, not ref_dir

Instead of keeping a pointer to the `ref_store` in every `ref_dir`
entry, store it once in `struct ref_cache`, and change `struct
ref_dir` to include a pointer to its containing `ref_cache` instead.
This makes it easier to add to the information that is accessible from
a `ref_dir` without increasing the size of every `ref_dir` instance.

Note that previously, every `ref_dir` pointed at the containing
`files_ref_store` regardless of whether it was a part of the loose or
packed reference cache. Now we have to be sure to initialize the
instances to point at the correct containing `ref_cache`. So change
`create_dir_entry()` to take a `ref_cache` parameter, and change its
callers to pass the correct `ref_cache` depending on the purpose of
the new `dir_entry`.

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

ref-cache: introduce a new type, ref_cacheMichael Haggerty Sun, 16 Apr 2017 06:41:32 +0000 (08:41 +0200)

ref-cache: introduce a new type, ref_cache

For now, it just wraps a `ref_entry *` that points at the root of the
tree. Soon it will hold more information.

Add two new functions, `create_ref_cache()` and `free_ref_cache()`.
Make `free_ref_entry()` private.

Change files-backend to use this type to hold its caches.

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

refs: split `ref_cache` code into separate filesMichael Haggerty Sun, 16 Apr 2017 06:41:31 +0000 (08:41 +0200)

refs: split `ref_cache` code into separate files

The `ref_cache` code is currently too tightly coupled to
`files-backend`, making the code harder to understand and making it
awkward for new code to use `ref_cache` (as we indeed have planned).
Start loosening that coupling by splitting `ref_cache` into a separate
module.

This commit moves code, adds declarations, and changes the visibility
of some functions, but doesn't change any code.

The modules are still too tightly coupled, but the situation will be
improved in subsequent commits.

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

ref-cache: rename `remove_entry()` to `remove_entry_fro... Michael Haggerty Sun, 16 Apr 2017 06:41:30 +0000 (08:41 +0200)

ref-cache: rename `remove_entry()` to `remove_entry_from_dir()`

This function's visibility is about to be increased, so give it a more
distinctive name.

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

ref-cache: rename `find_ref()` to `find_ref_entry()`Michael Haggerty Sun, 16 Apr 2017 06:41:29 +0000 (08:41 +0200)

ref-cache: rename `find_ref()` to `find_ref_entry()`

This function's visibility is about to be increased, so give it a more
distinctive name.

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

ref-cache: rename `add_ref()` to `add_ref_entry()`Michael Haggerty Sun, 16 Apr 2017 06:41:28 +0000 (08:41 +0200)

ref-cache: rename `add_ref()` to `add_ref_entry()`

This function's visibility is about to be increased, so give it a more
distinctive name.

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

refs_verify_refname_available(): use function in more... Michael Haggerty Sun, 16 Apr 2017 06:41:27 +0000 (08:41 +0200)

refs_verify_refname_available(): use function in more places

Change `lock_raw_ref()` and `lock_ref_sha1_basic()` to use
`refs_verify_refname_available()` instead of
`verify_refname_available_dir()`. This means that those callsites now
check for conflicts with all references rather than just packed refs,
but the performance cost shouldn't be significant (and will be
regained later).

These were the last callers of `verify_refname_available_dir()`, so
also delete that (very complicated) function.

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