gitweb.git
test-tool: handle the `-C <directory>` option just... Johannes Schindelin Thu, 18 Apr 2019 13:16:49 +0000 (06:16 -0700)

test-tool: handle the `-C <directory>` option just like `git`

In preparation for moving `git serve` into `test-tool` (because it
really is only used by the test suite), we teach the `test-tool` the
useful trick to change the working directory before running the test
command, which will avoid introducing subshells in the test code.

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

check-docs: do not bother checking for legacy scripts... Johannes Schindelin Thu, 18 Apr 2019 13:16:46 +0000 (06:16 -0700)

check-docs: do not bother checking for legacy scripts' documentation

In the recent years, there has been a big push to convert more and more
of Git's commands that are implemented as scripts to built-ins written
in pure, portable C, for robustness, speed and portability.

One strategy that served us well is to convert those scripts
incrementally, starting by renaming the scripts to
`git-legacy-<command>`, then introducing a built-in that does nothing
else at first than checking the config setting `<command>.useBuiltin`
(which defaults to `false` at the outset) and handing off to the legacy
script if so asked.

Obviously, those `git-legacy-<command>` commands share the documentation
with the built-in `git-<command>`, and are not intended to be called
directly anyway. So let's not try to ensure that they are documented
separately from their built-in versions.

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

docs: exclude documentation for commands that have... Johannes Schindelin Thu, 18 Apr 2019 13:16:44 +0000 (06:16 -0700)

docs: exclude documentation for commands that have been excluded

When building with certain build options, some commands are excluded
from the build. For example, `git-credential-cache` is skipped when
building with `NO_UNIX_SOCKETS`.

Let's not build or package documentation for those excluded commands.

This issue was pointed out rightfully when running `make check-docs` on
Windows, where we do not yet have Unix sockets, and therefore the
`credential-cache` command is excluded (yet its documentation was built
and shipped).

Note: building the documentation via `make -C Documentation` leaves the
build system with no way to determine which commands have been
excluded. If called thusly, we gracefully fail to exclude their
documentation. Only when building the documentation via the top-level
Makefile will it get excluded properly, or after building
`Documentation/GIT-EXCLUDED-PROGRAMS` manually.

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

check-docs: allow command-list.txt to contain excluded... Johannes Schindelin Thu, 18 Apr 2019 13:16:42 +0000 (06:16 -0700)

check-docs: allow command-list.txt to contain excluded commands

Among other things, the `check-docs` target ensures that
`command-list.txt` no longer contains commands that were dropped (or
that were never added in the first place).

To do so, it compares the list of commands from that file to the
commands listed in `$(ALL_COMMANDS)`.

However, some build options exclude commands from the latter. Fix the
target to handle this situation correctly by taking the just-introduced
`$(EXCLUDED_PROGRAMS)` into account.

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

help -a: do not list commands that are excluded from... Johannes Schindelin Thu, 18 Apr 2019 13:16:40 +0000 (06:16 -0700)

help -a: do not list commands that are excluded from the build

When built with NO_CURL or with NO_UNIX_SOCKETS, some commands are
skipped from the build. It does not make sense to list them in the
output of `git help -a`, so let's just not.

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

Makefile: drop the NO_INSTALL variableJohannes Schindelin Thu, 18 Apr 2019 13:16:39 +0000 (06:16 -0700)

Makefile: drop the NO_INSTALL variable

The last user was just removed; There is no longer any need to carry it
around. Should we ever run into a need for it again, it is easy enough
to revert this commit.

It is unlikely, though, that we need `NO_INSTALL` again: as we saw with
the just-removed item, `git-remote-testgit`, we have better locations
to put executables and scripts that we do not want to install, e.g.
a subdirectory in `t/`, or `contrib/`.

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

autoconf: #include <libintl.h> when checking for gettext()Vadim Kochan Thu, 18 Apr 2019 05:04:19 +0000 (08:04 +0300)

autoconf: #include <libintl.h> when checking for gettext()

Some libc implementations like uclibc or musl provides
gettext stubs via libintl library but this case is not checked
by AC_CHECK_LIB(c, gettext ...) because gcc has gettext as builtin
which passess the check.

So check it with included libintl.h where gettext may unfold into
libintl_gettext which will cause check to fail if libintl_gettext are
needed to be linked with -lintl.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cherry-pick/revert: add scissors line on merge conflictDenton Liu Wed, 17 Apr 2019 10:23:30 +0000 (11:23 +0100)

cherry-pick/revert: add scissors line on merge conflict

Fix a bug where the scissors line is placed after the Conflicts:
section, in the case where a merge conflict occurs and
commit.cleanup = scissors.

Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sequencer.c: save and restore cleanup modePhillip Wood Wed, 17 Apr 2019 10:23:29 +0000 (11:23 +0100)

sequencer.c: save and restore cleanup mode

If the user specifies an explicit cleanup mode then save and restore it
so that it is preserved by 'git cherry-pick --continue'.

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

merge: add scissors line on merge conflictDenton Liu Wed, 17 Apr 2019 10:23:28 +0000 (11:23 +0100)

merge: add scissors line on merge conflict

This fixes a bug where the scissors line is placed after the Conflicts:
section, in the case where a merge conflict occurs and
commit.cleanup = scissors.

Next, if commit.cleanup = scissors is specified, don't produce a
scissors line in commit if one already exists in the MERGE_MSG file.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge: cleanup messages like commitDenton Liu Wed, 17 Apr 2019 10:23:27 +0000 (11:23 +0100)

merge: cleanup messages like commit

This change allows git-merge messages to be cleaned up with the
commit.cleanup configuration or --cleanup option, just like how
git-commit does it.

We also give git-pull the option of --cleanup so that it can also take
advantage of this change.

Finally, add testing to ensure that messages are properly cleaned up.
Note that some newlines that were added to the commit message were
removed so that if a file were read via -F, it would be copied
faithfully.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parse-options.h: extract common --cleanup optionDenton Liu Wed, 17 Apr 2019 10:23:26 +0000 (11:23 +0100)

parse-options.h: extract common --cleanup option

The --cleanup option is commonly used. Extract it so that its definition
is not repeated.

Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: extract cleanup_mode functions to sequencerDenton Liu Wed, 17 Apr 2019 10:23:25 +0000 (11:23 +0100)

commit: extract cleanup_mode functions to sequencer

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7502: clean up styleDenton Liu Wed, 17 Apr 2019 10:23:24 +0000 (11:23 +0100)

t7502: clean up style

Refactor out Git commands that were upstream of a pipe. Remove spaces
after "> ". Indent here-docs appropriately. Convert echo chains to use
the test_write_lines function. Refactor 'sign off' test to use test_cmp
instead of comparing variables.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7604: clean up styleDenton Liu Wed, 17 Apr 2019 10:23:23 +0000 (11:23 +0100)

t7604: clean up style

Before, we had some Git commands which were upstream of the pipe. This
meant that if it produced an error, it would've gone unnoticed. Refactor
to place Git commands on their own.

Also, while we're at it, remove spaces after redirection operators.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t3507: clean up styleDenton Liu Wed, 17 Apr 2019 10:23:22 +0000 (11:23 +0100)

t3507: clean up style

Remove space after redirection operators for style. Also, remove a git
command which was upstream of a pipe. Finally, let grep and sed open
their own input instead of letting the shell redirect the input.

Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7600: clean up styleDenton Liu Wed, 17 Apr 2019 10:23:21 +0000 (11:23 +0100)

t7600: clean up style

Clean up the 'merge --squash c3 with c7' test by removing some
unnecessary braces and removing a pipe.

Also, generally cleanup style by unindenting a here-doc, removing stray
spaces after a redirection operator and allowing sed to open its own
input instead of redirecting input from the shell.

Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sequencer: fix cleanup with --signoff and -xPhillip Wood Fri, 29 Mar 2019 11:08:42 +0000 (11:08 +0000)

sequencer: fix cleanup with --signoff and -x

Before commit 356ee4659b ("sequencer: try to commit without forking 'git
commit'", 2017-11-24) when --signoff or -x were given on the command
line the commit message was cleaned up with --cleanup=space or
commit.cleanup if it was set. Unfortunately this behavior was lost when
I implemented committing without forking. Fix this and add some tests to
catch future regressions.

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

clone: send server options when using protocol v2Jonathan Tan Fri, 12 Apr 2019 19:51:22 +0000 (12:51 -0700)

clone: send server options when using protocol v2

Commit 5e3548ef16 ("fetch: send server options when using protocol v2",
2018-04-24) taught "fetch" the ability to send server options when using
protocol v2, but not "clone". This ability is triggered by "-o" or
"--server-option".

Teach "clone" the same ability, except that because "clone" already
has "-o" for another parameter, teach "clone" only to receive
"--server-option".

Explain in the documentation, both for clone and for fetch, that server
handling of server options are server-specific. This is similar to
receive-pack's handling of push options - currently, they are just sent
to hooks to interpret as they see fit.

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

transport: die if server options are unsupportedJonathan Tan Fri, 12 Apr 2019 19:51:21 +0000 (12:51 -0700)

transport: die if server options are unsupported

Server options were added in commit 5e3548ef16 ("fetch: send server
options when using protocol v2", 2018-04-24), supported only for
protocol version 2. But if the user specifies server options, and the
protocol version being used doesn't support them, the server options are
silently ignored.

Teach any transport users to die instead in this situation, just like
how "push" dies if push options are provided when the server doesn't
support them.

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

ref-filter: use correct branch for %(push:track)Damien Robert Tue, 16 Apr 2019 12:16:46 +0000 (14:16 +0200)

ref-filter: use correct branch for %(push:track)

In ref-filter.c, when processing the atom %(push:track), the
ahead/behind values are computed using `stat_tracking_info` which refers
to the upstream branch.

Fix that by introducing a new flag `for_push` in `stat_tracking_info`
in remote.c, which does the same thing but for the push branch.
Update the few callers of `stat_tracking_info` to handle this flag. This
ensure that whenever we use this function in the future, we are careful
to specify is this should apply to the upstream or the push branch.

This bug was not detected in t/t6300-for-each-ref.sh because in the test
for push:track, both the upstream and the push branches were behind by 1
from the local branch. Change the test so that the upstream branch is
behind by 1 while the push branch is ahead by 1. This allows us to test
that %(push:track) refers to the correct branch.

This changes the expected value of some following tests (by introducing
new references), so update them too.

Signed-off-by: Damien Robert <damien.olivier.robert+git@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

The fifth batchJunio C Hamano Tue, 16 Apr 2019 10:33:35 +0000 (19:33 +0900)

The fifth batch

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

Merge branch 'sg/t5318-cleanup'Junio C Hamano Tue, 16 Apr 2019 10:28:12 +0000 (19:28 +0900)

Merge branch 'sg/t5318-cleanup'

Code cleanup.

* sg/t5318-cleanup:
t5318-commit-graph: remove unused variable

Merge branch 'jt/t5551-protocol-v2-does-not-have-half... Junio C Hamano Tue, 16 Apr 2019 10:28:12 +0000 (19:28 +0900)

Merge branch 'jt/t5551-protocol-v2-does-not-have-half-auth'

Test update.

* jt/t5551-protocol-v2-does-not-have-half-auth:
t5551: mark half-auth no-op fetch test as v0-only

Merge branch 'jk/http-walker-status-fix'Junio C Hamano Tue, 16 Apr 2019 10:28:11 +0000 (19:28 +0900)

Merge branch 'jk/http-walker-status-fix'

dumb-http walker has been updated to share more error recovery
strategy with the normal codepath.

* jk/http-walker-status-fix:
http: use normalize_curl_result() instead of manual conversion
http: normalize curl results for dumb loose and alternates fetches
http: factor out curl result code normalization

Merge branch 'jh/midx-verify-too-many-packs'Junio C Hamano Tue, 16 Apr 2019 10:28:11 +0000 (19:28 +0900)

Merge branch 'jh/midx-verify-too-many-packs'

"git multi-pack-index verify" did not scale well with the number of
packfiles, which is being improved.

* jh/midx-verify-too-many-packs:
midx: during verify group objects by packfile to speed verification
midx: add progress indicators in multi-pack-index verify
trace2:data: add trace2 data to midx
progress: add sparse mode to force 100% complete message

Merge branch 'bb/unicode-12'Junio C Hamano Tue, 16 Apr 2019 10:28:11 +0000 (19:28 +0900)

Merge branch 'bb/unicode-12'

Unicode update.

* bb/unicode-12:
unicode: update the width tables to Unicode 12

Merge branch 'jk/refs-double-abort'Junio C Hamano Tue, 16 Apr 2019 10:28:11 +0000 (19:28 +0900)

Merge branch 'jk/refs-double-abort'

A corner case bug in the refs API has been corrected.

* jk/refs-double-abort:
refs/files-backend: don't look at an aborted transaction
refs/files-backend: handle packed transaction prepare failure

Merge branch 'nd/checkout-m-doc-update'Junio C Hamano Tue, 16 Apr 2019 10:28:10 +0000 (19:28 +0900)

Merge branch 'nd/checkout-m-doc-update'

Doc about the above.

* nd/checkout-m-doc-update:
checkout.txt: note about losing staged changes with --merge

Merge branch 'tb/trace2-va-list-fix'Junio C Hamano Tue, 16 Apr 2019 10:28:10 +0000 (19:28 +0900)

Merge branch 'tb/trace2-va-list-fix'

Fix some code that passed a NULL when a va_list was expected.

* tb/trace2-va-list-fix:
trace2: NULL is not allowed for va_list

Merge branch 'tz/completion'Junio C Hamano Tue, 16 Apr 2019 10:28:09 +0000 (19:28 +0900)

Merge branch 'tz/completion'

The completion helper code now pays attention to repository-local
configuration (when available), which allows --list-cmds to honour
a repository specific setting of completion.commands, for example.

* tz/completion:
completion: use __git when calling --list-cmds
completion: fix multiple command removals
t9902: test multiple removals via completion.commands
git: read local config in --list-cmds

Merge branch 'ma/doc-diff-doc-vs-doctor-comparison'Junio C Hamano Tue, 16 Apr 2019 10:28:09 +0000 (19:28 +0900)

Merge branch 'ma/doc-diff-doc-vs-doctor-comparison'

Dev support update to make it easier to compare two formatted
results from our documentation.

* ma/doc-diff-doc-vs-doctor-comparison:
doc-diff: add `--cut-header-footer`
doc-diff: support diffing from/to AsciiDoc(tor)
doc-diff: let `render_tree()` take an explicit directory name
Doc: auto-detect changed build flags

Merge branch 'tz/t4038-bash-redirect-target-workaround'Junio C Hamano Tue, 16 Apr 2019 10:28:09 +0000 (19:28 +0900)

Merge branch 'tz/t4038-bash-redirect-target-workaround'

Work-around extra warning from bash in our tests.

* tz/t4038-bash-redirect-target-workaround:
t4038-diff-combined: quote paths with whitespace

Merge branch 'ab/drop-scripted-rebase'Junio C Hamano Tue, 16 Apr 2019 10:28:09 +0000 (19:28 +0900)

Merge branch 'ab/drop-scripted-rebase'

Retire scripted "git rebase" implementation.

* ab/drop-scripted-rebase:
rebase: remove the rebase.useBuiltin setting

Merge branch 'jk/perf-lib-tee'Junio C Hamano Tue, 16 Apr 2019 10:28:08 +0000 (19:28 +0900)

Merge branch 'jk/perf-lib-tee'

Code cleanup in the test framework.

* jk/perf-lib-tee:
perf-lib.sh: rely on test-lib.sh for --tee handling

Merge branch 'ab/doc-misc-typofixes'Junio C Hamano Tue, 16 Apr 2019 10:28:08 +0000 (19:28 +0900)

Merge branch 'ab/doc-misc-typofixes'

Typofixes.

* ab/doc-misc-typofixes:
doc: fix typos in man pages

Merge branch 'mh/pack-protocol-doc-fix'Junio C Hamano Tue, 16 Apr 2019 10:28:08 +0000 (19:28 +0900)

Merge branch 'mh/pack-protocol-doc-fix'

Docfix.

* mh/pack-protocol-doc-fix:
fix pack protocol example client/server communication

Merge branch 'tg/glossary-overlay'Junio C Hamano Tue, 16 Apr 2019 10:28:07 +0000 (19:28 +0900)

Merge branch 'tg/glossary-overlay'

Doc update.

* tg/glossary-overlay:
glossary: add definition for overlay

Merge branch 'nd/checkout-f-while-conflicted-fix'Junio C Hamano Tue, 16 Apr 2019 10:28:07 +0000 (19:28 +0900)

Merge branch 'nd/checkout-f-while-conflicted-fix'

"git checkout -f <branch>" while the index has an unmerged path
incorrectly left some paths in an unmerged state, which has been
corrected.

* nd/checkout-f-while-conflicted-fix:
unpack-trees: fix oneway_merge accidentally carry over stage index

Merge branch 'pw/rerere-autoupdate'Junio C Hamano Tue, 16 Apr 2019 10:28:07 +0000 (19:28 +0900)

Merge branch 'pw/rerere-autoupdate'

Doc updates.

* pw/rerere-autoupdate:
merge: tweak --rerere-autoupdate documentation
am/cherry-pick/rebase/revert: document --rerere-autoupdate

Merge branch 'jc/format-patch-error-check'Junio C Hamano Tue, 16 Apr 2019 10:28:06 +0000 (19:28 +0900)

Merge branch 'jc/format-patch-error-check'

"git format-patch" used overwrite an existing patch/cover-letter
file. A new "--no-clobber" option stops it.

* jc/format-patch-error-check:
format-patch: notice failure to open cover letter for writing
builtin/log: downcase the beginning of error messages

Merge branch 'js/get-short-oid-drop-cache'Junio C Hamano Tue, 16 Apr 2019 10:28:06 +0000 (19:28 +0900)

Merge branch 'js/get-short-oid-drop-cache'

A corner-case object name ambiguity while the sequencer machinery
is working (e.g. "rebase -i -x") has been (half) fixed.

* js/get-short-oid-drop-cache:
get_oid(): when an object was not found, try harder
sequencer: move stale comment into correct location
sequencer: improve error message when an OID could not be parsed
rebase -i: demonstrate obscure loose object cache bug

Merge branch 'dl/subtree-limit-to-one-rev'Junio C Hamano Tue, 16 Apr 2019 10:28:06 +0000 (19:28 +0900)

Merge branch 'dl/subtree-limit-to-one-rev'

"git subtree" (in contrib/) update.

* dl/subtree-limit-to-one-rev:
contrib/subtree: ensure only one rev is provided

Merge branch 'js/init-db-update-for-mingw'Junio C Hamano Tue, 16 Apr 2019 10:28:05 +0000 (19:28 +0900)

Merge branch 'js/init-db-update-for-mingw'

"git init" forgot to read platform-specific repository
configuration, which made Windows port to ignore settings of
core.hidedotfiles, for example.

* js/init-db-update-for-mingw:
mingw: respect core.hidedotfiles = false in git-init again

Merge branch 'js/remote-curl-i18n'Junio C Hamano Tue, 16 Apr 2019 10:28:05 +0000 (19:28 +0900)

Merge branch 'js/remote-curl-i18n'

Error messages given from the http transport have been updated so
that they can be localized.

* js/remote-curl-i18n:
remote-curl: mark all error messages for translation

Merge branch 'js/anonymize-remote-curl-diag'Junio C Hamano Tue, 16 Apr 2019 10:28:04 +0000 (19:28 +0900)

Merge branch 'js/anonymize-remote-curl-diag'

remote-http transport did not anonymize URLs reported in its error
messages at places.

* js/anonymize-remote-curl-diag:
curl: anonymize URLs in error messages and warnings

Merge branch 'ma/asciidoctor-fixes-more'Junio C Hamano Tue, 16 Apr 2019 10:28:04 +0000 (19:28 +0900)

Merge branch 'ma/asciidoctor-fixes-more'

Documentation mark-up fixes.

* ma/asciidoctor-fixes-more:
Documentation: turn middle-of-line tabs into spaces
git-svn.txt: drop escaping '\' that ends up being rendered
git.txt: remove empty line before list continuation
config/fsck.txt: avoid starting line with dash
config/diff.txt: drop spurious backtick

Merge branch 'ma/asciidoctor-fixes'Junio C Hamano Tue, 16 Apr 2019 10:28:03 +0000 (19:28 +0900)

Merge branch 'ma/asciidoctor-fixes'

Build fix around use of asciidoctor instead of asciidoc

* ma/asciidoctor-fixes:
asciidoctor-extensions: fix spurious space after linkgit
Documentation/Makefile: add missing dependency on asciidoctor-extensions
Documentation/Makefile: add missing xsl dependencies for manpages

Merge branch 'jt/test-protocol-version'Junio C Hamano Tue, 16 Apr 2019 10:28:03 +0000 (19:28 +0900)

Merge branch 'jt/test-protocol-version'

Help developers by making it easier to run most of the tests under
different versions of over-the-wire protocols.

* jt/test-protocol-version:
t5552: compensate for v2 filtering ref adv.
tests: fix protocol version for overspecifications
t5700: only run with protocol version 1
t5512: compensate for v0 only sending HEAD symrefs
t5503: fix overspecification of trace expectation
tests: always test fetch of unreachable with v0
t5601: check ssh command only with protocol v0
tests: define GIT_TEST_PROTOCOL_VERSION

Merge branch 'nd/diff-parseopt-3'Junio C Hamano Tue, 16 Apr 2019 10:28:03 +0000 (19:28 +0900)

Merge branch 'nd/diff-parseopt-3'

Third batch to teach the diff machinery to use the parse-options
API.

* nd/diff-parseopt-3:
diff-parseopt: convert --submodule
diff-parseopt: convert --ignore-submodules
diff-parseopt: convert --textconv
diff-parseopt: convert --ext-diff
diff-parseopt: convert --quiet
diff-parseopt: convert --exit-code
diff-parseopt: convert --color-words
diff-parseopt: convert --word-diff-regex
diff-parseopt: convert --word-diff
diff-parseopt: convert --[no-]color
diff-parseopt: convert --[no-]follow
diff-parseopt: convert -R
diff-parseopt: convert -a|--text
diff-parseopt: convert --full-index
diff-parseopt: convert --binary
diff-parseopt: convert --anchored
diff-parseopt: convert --diff-algorithm
diff-parseopt: convert --histogram
diff-parseopt: convert --patience
diff-parseopt: convert --[no-]indent-heuristic

sha1-name.c: remove the_repo from get_oid_mb()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:41 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from get_oid_mb()

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

sha1-name.c: remove the_repo from other get_oid_*Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:40 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from other get_oid_*

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

sha1-name.c: remove the_repo from maybe_die_on_misspelt... Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:39 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from maybe_die_on_misspelt_object_name

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

submodule-config.c: use repo_get_oid for reading .gitmo... Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:38 +0000 (16:33 +0700)

submodule-config.c: use repo_get_oid for reading .gitmodules

Since 76e9bdc437 (submodule: support reading .gitmodules when it's not
in the working tree - 2018-10-25), every time you do

git grep --recurse-submodules

you are likely to see one warning line per submodule (unless all those
submodules also have submodules). On a superproject with plenty of
submodules (I've seen one with 67) this is really annoying.

The warning was there because we could not resolve extended SHA-1
syntax on a submodule. We can now. Make use of the new API and get rid
of the warning.

It would be even better if config_with_options() supports multiple
repositories too. But one step at a time.

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

sha1-name.c: add repo_get_oid()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:37 +0000 (16:33 +0700)

sha1-name.c: add repo_get_oid()

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

sha1-name.c: remove the_repo from get_oid_with_context_1()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:36 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from get_oid_with_context_1()

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

sha1-name.c: remove the_repo from resolve_relative_path()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:35 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from resolve_relative_path()

"remove" is not entirely correct. But at least the function is aware
that if the given repo is not the_repository, then $CWD and
is_inside_work_tree() means nothing.

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

sha1-name.c: remove the_repo from diagnose_invalid_inde... Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:34 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from diagnose_invalid_index_path()

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

sha1-name.c: remove the_repo from handle_one_ref()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:33 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from handle_one_ref()

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

sha1-name.c: remove the_repo from get_oid_1()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:32 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from get_oid_1()

There is a cyclic dependency between one of these functions so they
cannot be converted one by one, so all related functions are converted
at once.

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

sha1-name.c: remove the_repo from get_oid_basic()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:31 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from get_oid_basic()

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

sha1-name.c: remove the_repo from get_describe_name()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:30 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from get_describe_name()

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

sha1-name.c: remove the_repo from get_oid_oneline()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:29 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from get_oid_oneline()

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

sha1-name.c: add repo_interpret_branch_name()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:28 +0000 (16:33 +0700)

sha1-name.c: add repo_interpret_branch_name()

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

sha1-name.c: remove the_repo from interpret_branch_mark()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:27 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from interpret_branch_mark()

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

sha1-name.c: remove the_repo from interpret_nth_prior_c... Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:26 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from interpret_nth_prior_checkout()

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

sha1-name.c: remove the_repo from get_short_oid()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:25 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from get_short_oid()

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

sha1-name.c: add repo_for_each_abbrev()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:24 +0000 (16:33 +0700)

sha1-name.c: add repo_for_each_abbrev()

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

sha1-name.c: store and use repo in struct disambiguate_... Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:23 +0000 (16:33 +0700)

sha1-name.c: store and use repo in struct disambiguate_state

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

sha1-name.c: add repo_find_unique_abbrev_r()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:22 +0000 (16:33 +0700)

sha1-name.c: add repo_find_unique_abbrev_r()

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

sha1-name.c: remove the_repo from find_abbrev_len_packed()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:21 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from find_abbrev_len_packed()

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

sha1-name.c: remove the_repo from sort_ambiguous()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:20 +0000 (16:33 +0700)

sha1-name.c: remove the_repo from sort_ambiguous()

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

commit.c: add repo_get_commit_tree()Nguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:19 +0000 (16:33 +0700)

commit.c: add repo_get_commit_tree()

Remove the implicit dependency on the_repository in this function.
It will be used in sha1-name.c functions when they are updated to take
any 'struct repository'. get_commit_tree() remains as a compat wrapper,
to be slowly replaced later.

Any access to "maybe_tree" field directly will result in _broken_ code
after running through commit.cocci because we can't know what is the
right repository to use.

the_repository would be correct most of the time. But we're relying less
and less on the_repository and that assumption may no longer be
true. The transformation now is more of a poor man replacement for a C++
compiler catching access to private fields.

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

commit.cocci: refactor code, avoid double rewriteNguyễn Thái Ngọc Duy Tue, 16 Apr 2019 09:33:18 +0000 (16:33 +0700)

commit.cocci: refactor code, avoid double rewrite

"maybe" pointer in 'struct commit' is tricky because it can be lazily
initialized to take advantage of commit-graph if available. This makes
it not safe to access directly.

This leads to a rule in commit.cocci to rewrite 'x->maybe_tree' to
'get_commit_tree(x)'. But that rule alone could lead to incorrectly
rewrite assignments, e.g. from

x->maybe_tree = yes

to

get_commit_tree(x) = yes

Because of this we have a second rule to revert this effect. Szeder
found out that we could do better by performing the assignment rewrite
rule first, then the remaining is read-only access and handled by the
current first rule.

For this to work, we need to transform "x->maybe_tree = y" to something
that does NOT contain "x->maybe_tree" to avoid the original first
rule. This is where set_commit_tree() comes in.

Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

update_info_refs(): drop unused force parameterJeff King Fri, 5 Apr 2019 18:14:07 +0000 (14:14 -0400)

update_info_refs(): drop unused force parameter

Once upon a time the force flag meant something when writing info/refs,
but it hasn't done anything since 60d0526aaa (Unoptimize info/refs
creation., 2005-09-14).

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

server-info: drop objdirlen pointer arithmeticJeff King Fri, 5 Apr 2019 18:14:04 +0000 (14:14 -0400)

server-info: drop objdirlen pointer arithmetic

When writing objects/info/packs, we use the basename of each pack
(i.e., just the "pack-1234abcd.pack" part). We compute that manually by
adding "objdirlen + 6" to the name.

This _should_ work consistently, as we do not include non-local packs,
meaning everything should be in $objdir/pack/. Before f13d7db4af
(server-info.c: use pack_local like everybody else., 2005-12-05), this
was definitely true, since we computed "local" based on comparing the
objdir string. Since then, we're relying on the code on packfile.c to
match our expectations of p->pack_name and p->local.

I think our expectations do still hold today, but we can be a bit more
defensive by just using pack_basename() to get the base. That
future-proofs us, and should hopefully be more obviously safe to
somebody reading the code.

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

server-info: drop nr_alloc struct memberJeff King Fri, 5 Apr 2019 18:14:00 +0000 (14:14 -0400)

server-info: drop nr_alloc struct member

We keep an array of struct pointers, with each one representing a single
packfile. But for some reason there is a nr_alloc parameter inside each
struct, which has never been used.

This is probably cruft left over from development, where we might have
wanted a nr_alloc to dynamically grow the list. But as it turns out, we
do not dynamically grow the list at all, but rather count up the total
number of packs and use that as a maximum size. So while we're thinking
of this, let's add an assert() that documents (and checks!) that our
allocation and fill loops stay in sync.

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

server-info: use strbuf to read old info/packs fileJeff King Fri, 5 Apr 2019 18:13:56 +0000 (14:13 -0400)

server-info: use strbuf to read old info/packs file

This old code uses fgets with a fixed-size buffer. Let's use a strbuf
instead, so we don't have to wonder if "1000" is big enough, or what
happens if we see a long line.

This also lets us drop our custom code to trim the newline.

Probably nobody actually cares about the 1000-char limit (after all, the
lines generally only say "P pack-[0-9a-f]{40}.pack"), so this is mostly
just about cleanup/readability.

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

server-info: simplify cleanup in parse_pack_def()Jeff King Fri, 5 Apr 2019 18:13:14 +0000 (14:13 -0400)

server-info: simplify cleanup in parse_pack_def()

We have two exits from the function: either we jump to the out_stale
label or not. But in both exits we repeat our cleanup, and the only
difference is our return value. Let's just use a variable for the return
value to avoid repeating ourselves.

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

server-info: fix blind pointer arithmeticJeff King Fri, 5 Apr 2019 18:13:10 +0000 (14:13 -0400)

server-info: fix blind pointer arithmetic

When we're writing out a new objects/info/packs file, we read back the
old one to try to keep the ordering the same. When we see a line
starting with "P", we expect "P pack-1234..." and blindly jump to "line
+ 2" to parse the pack name. If we saw a line with _just_ "P" and
nothing else, we'd jump past the end of the buffer and start reading
arbitrary memory.

This shouldn't be a big attack vector, as the files are local to the
repository and written by us, but it's clearly worth fixing (we do read
remote copies of the file for dumb-http fetches, but using a totally
different parser!).

Let's instead use skip_prefix() here, which avoids pointer arithmetic
altogether. Note that this converts our switch statement to an if/else
chain, making it slightly more verbose. But it will also make it easier
to do a few follow-on cleanups.

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

http: simplify parsing of remote objects/info/packsJeff King Fri, 5 Apr 2019 18:12:55 +0000 (14:12 -0400)

http: simplify parsing of remote objects/info/packs

We can use skip_prefix() and parse_oid_hex() to continuously increment
our pointer, rather than dealing with magic numbers. This also fixes a
few small shortcomings:

- if we see a line with the right prefix, suffix, and length, i.e.
matching /P pack-.{40}.pack\n/, we'll interpret the middle part as
hex without checking if it could be parsed. This could lead to us
looking at uninitialized garbage in the hash array. In practice this
means we'll just make a garbage request to the server which will
fail, though it's interesting that a malicious server could convince
us to leak 40 bytes of uninitialized stack to them.

- the current code is picky about seeing a newline at the end of file,
but we can easily be more liberal

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

packfile: fix pack basename computationJeff King Fri, 5 Apr 2019 18:06:22 +0000 (14:06 -0400)

packfile: fix pack basename computation

When we have a multi-pack-index that covers many packfiles, we try to
avoid opening the .idx for those packfiles. To do that we feed the pack
name to midx_contains_pack(). But that function wants to see only the
basename, which we compute using strrchr() to find the final slash. But
that leaves an extra "/" at the start of our string.

We can fix this by incrementing the pointer. That also raises the
question of what to do when the name does not have a '/' at all. This
should generally not happen (we always find files in "pack/"), but it
doesn't hurt to be defensive here.

Let's wrap all of that up in a helper function and make it publicly
available, since a later patch will need to use it, too.

The tests don't notice because there's nothing about opening those .idx
files that would cause us to give incorrect output. It's just a little
slower. The new test checks this case by corrupting the covered .idx,
and then making sure we don't complain about it.

We also have to tweak t5570, which intentionally corrupts a .idx file
and expects us to notice it. When run with GIT_TEST_MULTI_PACK_INDEX,
this will fail since we now will (correctly) not bother opening the .idx
at all. We can fix that by unconditionally dropping any midx that's
there, which ensures we'll have to read the .idx.

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

midx: check both pack and index names for containmentJeff King Fri, 5 Apr 2019 18:06:04 +0000 (14:06 -0400)

midx: check both pack and index names for containment

A midx file (and the struct we parse from it) contains a list of all of
the covered packfiles, mentioned by their ".idx" names (e.g.,
"pack-1234.idx", etc). And thus calls to midx_contains_pack() expect
callers to provide the idx name.

This works for most of the calls, but the one in open_packed_git_1()
tries to feed a packed_git->pack_name, which is the ".pack" name,
meaning we'll never find a match (even if the pack is covered by the
midx).

We can fix this by converting the ".pack" to ".idx" in the caller.
However, that requires allocating a new string. Instead, let's make
midx_contains_pack() a bit friendlier, and allow it take _either_ the
.pack or .idx variant.

All cleverness in the matching code is credited to René. Bugs are mine.

There's no test here, because while this does fix _a_ bug, it's masked
by another bug in that same caller. That will be covered (with a test)
in the next patch.

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

t5319: drop useless --buffer from cat-fileJeff King Fri, 5 Apr 2019 18:05:03 +0000 (14:05 -0400)

t5319: drop useless --buffer from cat-file

The cat-file --buffer option is the default already when using
--batch-all-objects. It doesn't hurt to specify it, but it's nice for
the test scripts to model good usage.

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

t5319: fix bogus cat-file argumentJeff King Fri, 5 Apr 2019 18:04:56 +0000 (14:04 -0400)

t5319: fix bogus cat-file argument

There's no such argument as "--unsorted"; it's spelled "--unordered".
But our test failed to notice that cat-file didn't run at all because:

1. It lost the exit code of git on the left-hand side of a pipe.

2. It was comparing two runs of the broken invocation with and without
a particular config variable (and indeed, both cases produced no
output!).

Let's fix the option, but also tweak the helper function to check the
exit code.

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

pack-revindex: open index if necessaryJeff King Fri, 5 Apr 2019 18:04:24 +0000 (14:04 -0400)

pack-revindex: open index if necessary

We can't create a pack revindex if we haven't actually looked at the
index. Normally we would never get as far as creating a revindex without
having already been looking in the pack, so this code never bothered to
double-check that pack->index_data had been loaded.

But with the new multi-pack-index feature, many code paths might not
load the individual pack .idx at all (they'd find objects via the midx
and then open the .pack, but not its index).

This can't yet be triggered in practice, because a bug in the midx code
means we accidentally open up the individual .idx files anyway. But in
preparation for fixing that, let's have the revindex code check that
everything it needs has been loaded.

In most cases this will just be a quick noop. But note that this does
introduce a possibility of error (if we have to open the index and it's
corrupt), so load_pack_revindex() now returns a result code, and callers
need to handle the error.

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

packfile.h: drop extern from function declarationsJeff King Fri, 5 Apr 2019 18:03:41 +0000 (14:03 -0400)

packfile.h: drop extern from function declarations

As CodingGuidelines recommends, we do not need an "extern" when
declaring a public function. Let's drop these. Note that we leave the
extern on report_garbage(), as that is actually a function pointer, not
a function itself.

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

trace2: update docs to describe system/global config... Jeff Hostetler Mon, 15 Apr 2019 20:39:50 +0000 (13:39 -0700)

trace2: update docs to describe system/global config settings

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

trace2: make SIDs more uniqueJeff Hostetler Mon, 15 Apr 2019 20:39:49 +0000 (13:39 -0700)

trace2: make SIDs more unique

Update SID component construction to use the current UTC datetime
and a portion of the SHA1 of the hostname.

Use an simplified date/time format to make it easier to use the
SID component as a logfile filename.

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

trace2: clarify UTC datetime formattingJeff Hostetler Mon, 15 Apr 2019 20:39:48 +0000 (13:39 -0700)

trace2: clarify UTC datetime formatting

Update tr2_tbuf_utc_datetime to generate extended UTC format.
Update tr2_tgt_event target to use extended format in 'time' columns.

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

trace2: report peak memory usage of the processJeff Hostetler Mon, 15 Apr 2019 20:39:48 +0000 (13:39 -0700)

trace2: report peak memory usage of the process

Teach Windows version of git to report peak memory usage
during exit() processing.

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

trace2: use system/global config for default trace2... Jeff Hostetler Mon, 15 Apr 2019 20:39:47 +0000 (13:39 -0700)

trace2: use system/global config for default trace2 settings

Teach git to read the system and global config files for
default Trace2 settings. This allows system-wide Trace2 settings to
be installed and inherited to make it easier to manage a collection of
systems.

The original GIT_TR2* environment variables are loaded afterwards and
can be used to override the system settings.

Only the system and global config files are used. Repo and worktree
local config files are ignored. Likewise, the "-c" command line
arguments are also ignored. These limits are for performance reasons.

(1) For users not using Trace2, there should be minimal overhead to
detect that Trace2 is not enabled. In particular, Trace2 should not
allocate lots of otherwise unused data strucutres.

(2) For accurate performance measurements, Trace2 should be initialized
as early in the git process as possible, and before most of the normal
git process initialization (which involves discovering the .git directory
and reading a hierarchy of config files).

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

config: add read_very_early_config()Jeff Hostetler Mon, 15 Apr 2019 20:39:46 +0000 (13:39 -0700)

config: add read_very_early_config()

Created an even lighter version of read_early_config() that
only looks at system and global config settings. It omits
repo-local, worktree-local, and command-line settings.

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

trace2: find exec-dir before trace2 initializationJeff Hostetler Mon, 15 Apr 2019 20:39:45 +0000 (13:39 -0700)

trace2: find exec-dir before trace2 initialization

Teach Git to resolve the executable directory before initializing
Trace2. This allows the system configuration directory to be
discovered earlier (because it is sometimes relative to the prefix
or runtime-prefix).

This will be used by the next commit to allow trace2 settings to
be loaded from the system config.

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

trace2: add absolute elapsed time to start eventJeff Hostetler Mon, 15 Apr 2019 20:39:44 +0000 (13:39 -0700)

trace2: add absolute elapsed time to start event

Add elapsed process time to "start" event to measure
the performance of early process startup.

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

trace2: refactor setting process starting timeJeff Hostetler Mon, 15 Apr 2019 20:39:43 +0000 (13:39 -0700)

trace2: refactor setting process starting time

Create trace2_initialize_clock() and call from main() to capture
process start time in isolation and before other sub-systems are
ready.

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

config: initialize opts structure in repo_read_config()Jeff Hostetler Mon, 15 Apr 2019 20:39:42 +0000 (13:39 -0700)

config: initialize opts structure in repo_read_config()

Initialize opts structure in repo_read_config().

This change fixes a crash in later commit after a new field is added
to the structure.

In commit 3b256228a66f8587661481ef3e08259864f3ba2a, repo_read_config()
was added. It only initializes 3 fields in the opts structure. It is
passed to config_with_options() and then to do_git_config_sequence().
However, do_git_config_sequence() drops the opts on the floor and calls
git_config_from_file() rather than git_config_from_file_with_options(),
so that may be why this hasn't been a problem in the past.

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

remote-testgit: move it into the support directory... Johannes Schindelin Fri, 12 Apr 2019 12:00:31 +0000 (05:00 -0700)

remote-testgit: move it into the support directory for t5801

The `git-remote-testgit` script is really only used in
`t5801-remote-helpers.sh`. It does not even contain any `@@<MAGIC>@@`
placeholders that would need to be interpolated via `make
git-remote-testgit`.

Let's just move it to a new home, decluttering the top-level directory
and clarifying that this is just a test helper, not an official Git
command that we would want to ever support.

Suggested by Ævar Arnfjörð Bjarmason.

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

fetch: do not consider peeled tags as advertised tipsJeff King Sat, 13 Apr 2019 05:57:37 +0000 (01:57 -0400)

fetch: do not consider peeled tags as advertised tips

Our filter_refs() function accidentally considers the target of a peeled
tag to be advertised by the server, even though upload-pack on the
server side does not consider it so. This can result in the client
making a bogus fetch to the server, which will end with the server
complaining "not our ref". Whereas the correct behavior is for the
client to notice that the server will not allow the request and error
out immediately.

So as bugs go, this is not very serious (the outcome is the same either
way -- the fetch fails). But it's worth making the logic here correct
and consistent with other related cases (e.g., fetching an oid that the
server did not mention at all).

The crux of the issue comes from fdb69d33c4 (fetch-pack: always allow
fetching of literal SHA1s, 2017-05-15). After that, the strategy of
filter_refs() is basically:

- for each advertised ref, try to match it with a "sought" ref
provided by the user. Skip any malformed refs (which includes
peeled values like "refs/tags/foo^{}"), and place any unmatched
items onto the unmatched list.

- if there are unmatched sought refs, then put all of the advertised
tips into an oidset, including the unmatched ones.

- for each sought ref, see if it's in the oidset, in which case it's
legal for us to ask the server for it

The problem is in the second step. Our list of unmatched refs includes
the peeled refs, even though upload-pack does not allow them to be
directly fetched. So the simplest fix would be to exclude them during
that step.

However, we can observe that the unmatched list isn't used for anything
else, and is freed at the end. We can just free those malformed refs
immediately. That saves us having to check each ref a second time to see
if it's malformed.

Note that this code only kicks in when "strict" is in effect. I.e., if
we are using the v0 protocol and uploadpack.allowReachableSHA1InWant is
not in effect. With v2, all oids are allowed, and we do not bother
creating or consulting the oidset at all. To future-proof our test
against the upcoming GIT_TEST_PROTOCOL_VERSION flag, we'll manually mark
it as a v0-only test.

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

remote.c: make singular free_ref() publicJeff King Sat, 13 Apr 2019 05:54:31 +0000 (01:54 -0400)

remote.c: make singular free_ref() public

We provide a free_refs() function to free a list, but there's no easy
way for a caller to free a single ref. Let's make our singular
free_ref() function public. Since its name is so similar to the
list-freeing free_refs(), and because both of those functions have the
same signature, it might be easy to accidentally use the wrong one.
Let's call the singular version the more verbose "free_one_ref()" to
distinguish it.

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