gitweb.git
remote-curl: refactor smart-http discoveryJeff King Wed, 6 Feb 2019 19:18:48 +0000 (14:18 -0500)

remote-curl: refactor smart-http discovery

After making initial contact with an http server, we have to decide if
the server supports smart-http, and if so, which version. Our rules are
a bit inconsistent:

1. For v0, we require that the content-type indicates a smart-http
response. We also require the response to look vaguely like a
pkt-line starting with "#". If one of those does not match, we fall
back to dumb-http.

But according to our http protocol spec[1]:

Dumb servers MUST NOT return a return type starting with
`application/x-git-`.

If we see the expected content-type, we should consider it
smart-http. At that point we can parse the pkt-line for real, and
complain if it is not syntactically valid.

2. For v2, we do not actually check the content-type. Our v2 protocol
spec says[2]:

When using the http:// or https:// transport a client makes a
"smart" info/refs request as described in `http-protocol.txt`[...]

and the http spec is clear that for a smart-http response[3]:

The Content-Type MUST be `application/x-$servicename-advertisement`.

So it is required according to the spec.

These inconsistencies were easy to miss because of the way the original
code was written as an inline conditional. Let's pull it out into its
own function for readability, and improve a few things:

- we now predicate the smart/dumb decision entirely on the presence of
the correct content-type

- we do a real pkt-line parse before deciding how to proceed (and die
if it isn't valid)

- use skip_prefix() for comparing service strings, instead of
constructing expected output in a strbuf; this avoids dealing with
memory cleanup

Note that this _is_ tightening what the client will allow. It's all
according to the spec, but it's possible that other implementations
might violate these. However, violating these particular rules seems
like an odd choice for a server to make.

[1] Documentation/technical/http-protocol.txt, l. 166-167
[2] Documentation/technical/protocol-v2.txt, l. 63-64
[3] Documentation/technical/http-protocol.txt, l. 247

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

test-date: drop unused parameter to getnanos()Jeff King Wed, 6 Feb 2019 19:35:52 +0000 (14:35 -0500)

test-date: drop unused parameter to getnanos()

The getnanos() helper always gets the current time from our
getnanotime() facility. The caller cannot override it via TEST_DATE_NOW,
and hence we simply ignore the "now" parameter to the function. Let's
remove it, as it may mislead callers into thinking it does something.

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

Revert "rebase: introduce a shortcut for --reschedule... Johannes Schindelin Wed, 6 Feb 2019 18:45:17 +0000 (10:45 -0800)

Revert "rebase: introduce a shortcut for --reschedule-failed-exec"

This patch was contributed only as a tentative "we could introduce a
convenient short option if we do not want to change the default behavior
in the long run" patch, opening the discussion whether other people
agree with deprecating the current behavior in favor of the rescheduling
behavior.

But the consensus on the Git mailing list was that it would make sense
to show a warning in the near future, and flip the default
rebase.rescheduleFailedExec to reschedule failed `exec` commands by
default. See e.g.
<CAGZ79kZL5CRqCDRb6B-EedUm8Z_i4JuSF2=UtwwdRXMitrrOBw@mail.gmail.com>

So let's back out that patch that added the `-y` short option that we
agreed was not necessary or desirable.

This reverts commit 81ef8ee75d5f348d3c71ff633d13d302124e1a5e.

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

Fifth batch for 2.21Junio C Hamano Tue, 5 Feb 2019 22:27:34 +0000 (14:27 -0800)

Fifth batch for 2.21

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

Merge branch 'sg/object-as-type-commit-graph-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:19 +0000 (14:26 -0800)

Merge branch 'sg/object-as-type-commit-graph-fix'

The commit-graph facility did not work when in-core objects that
are promoted from unknown type to commit (e.g. a commit that is
accessed via a tag that refers to it) were involved, which has been
corrected.

* sg/object-as-type-commit-graph-fix:
object_as_type: initialize commit-graph-related fields of 'struct commit'

Merge branch 'nd/fetch-compact-update'Junio C Hamano Tue, 5 Feb 2019 22:26:18 +0000 (14:26 -0800)

Merge branch 'nd/fetch-compact-update'

"git fetch" output cleanup.

* nd/fetch-compact-update:
fetch: prefer suffix substitution in compact fetch.output

Merge branch 'sg/strbuf-addbuf-cocci'Junio C Hamano Tue, 5 Feb 2019 22:26:18 +0000 (14:26 -0800)

Merge branch 'sg/strbuf-addbuf-cocci'

Cocci rule update.

* sg/strbuf-addbuf-cocci:
strbuf.cocci: suggest strbuf_addbuf() to add one strbuf to an other

Merge branch 'az/instaweb-py3-http-server'Junio C Hamano Tue, 5 Feb 2019 22:26:18 +0000 (14:26 -0800)

Merge branch 'az/instaweb-py3-http-server'

"git instaweb" learned to drive http.server that comes with
"batteries included" Python installation (both Python2 & 3).

* az/instaweb-py3-http-server:
git-instaweb: add Python builtin http.server support

Merge branch 'pw/no-editor-in-rebase-i-implicit'Junio C Hamano Tue, 5 Feb 2019 22:26:17 +0000 (14:26 -0800)

Merge branch 'pw/no-editor-in-rebase-i-implicit'

When GIT_SEQUENCE_EDITOR is set, the command was incorrectly
started when modes of "git rebase" that implicitly uses the
machinery for the interactive rebase are run, which has been
corrected.

* pw/no-editor-in-rebase-i-implicit:
implicit interactive rebase: don't run sequence editor

Merge branch 'jk/diff-cc-stat-fixes'Junio C Hamano Tue, 5 Feb 2019 22:26:17 +0000 (14:26 -0800)

Merge branch 'jk/diff-cc-stat-fixes'

"git diff --color-moved --cc --stat -p" did not work well due to
funny interaction between a bug in color-moved and the rest, which
has been fixed.

* jk/diff-cc-stat-fixes:
combine-diff: treat --dirstat like --stat
combine-diff: treat --summary like --stat
combine-diff: treat --shortstat like --stat
combine-diff: factor out stat-format mask
diff: clear emitted_symbols flag after use
t4006: resurrect commented-out tests

Merge branch 'bp/checkout-new-branch-optim'Junio C Hamano Tue, 5 Feb 2019 22:26:17 +0000 (14:26 -0800)

Merge branch 'bp/checkout-new-branch-optim'

"git checkout -b <new> [HEAD]" to create a new branch from the
current commit and check it out ought to be a no-op in the index
and the working tree in normal cases, but there are corner cases
that do require updates to the index and the working tree. Running
it immediately after "git clone --no-checkout" is one of these
cases that an earlier optimization kicked in incorrectly, which has
been fixed.

* bp/checkout-new-branch-optim:
checkout: fix regression in checkout -b on intitial checkout
checkout: add test demonstrating regression with checkout -b on initial commit

Merge branch 'ja/doc-style-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:16 +0000 (14:26 -0800)

Merge branch 'ja/doc-style-fix'

Doc typo/stylo fixes.

* ja/doc-style-fix:
doc: tidy asciidoc style

Merge branch 'ph/pack-objects-mutex-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:16 +0000 (14:26 -0800)

Merge branch 'ph/pack-objects-mutex-fix'

"git pack-objects" incorrectly used uninitialized mutex, which has
been corrected.

* ph/pack-objects-mutex-fix:
pack-objects: merge read_lock and lock in packing_data struct
pack-objects: move read mutex to packing_data struct

Merge branch 'jk/attr-macro-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:16 +0000 (14:26 -0800)

Merge branch 'jk/attr-macro-fix'

Asking "git check-attr" about a macro (e.g. "binary") on a specific
path did not work correctly, even though "git check-attr -a" listed
such a macro correctly. This has been corrected.

* jk/attr-macro-fix:
attr: do not mark queried macros as unset

Merge branch 'js/test-git-installed'Junio C Hamano Tue, 5 Feb 2019 22:26:15 +0000 (14:26 -0800)

Merge branch 'js/test-git-installed'

Test fix for Windows.

* js/test-git-installed:
tests: explicitly use `test-tool.exe` on Windows

Merge branch 'js/abspath-part-inside-repo'Junio C Hamano Tue, 5 Feb 2019 22:26:15 +0000 (14:26 -0800)

Merge branch 'js/abspath-part-inside-repo'

On a case-insensitive filesystem, we failed to compare the part of
the path that is above the worktree directory in an absolute
pathname, which has been corrected.

* js/abspath-part-inside-repo:
abspath_part_inside_repo: respect core.ignoreCase

Merge branch 'jt/namespaced-ls-refs-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:15 +0000 (14:26 -0800)

Merge branch 'jt/namespaced-ls-refs-fix'

Fix namespace support in protocol v2.

* jt/namespaced-ls-refs-fix:
ls-refs: filter refs using namespace-stripped name

Merge branch 'ab/commit-graph-write-progress'Junio C Hamano Tue, 5 Feb 2019 22:26:14 +0000 (14:26 -0800)

Merge branch 'ab/commit-graph-write-progress'

The codepath to show progress meter while writing out commit-graph
file has been improved.

* ab/commit-graph-write-progress:
commit-graph write: emit a percentage for all progress
commit-graph write: add itermediate progress
commit-graph write: remove empty line for readability
commit-graph write: add more descriptive progress output
commit-graph write: show progress for object search
commit-graph write: more descriptive "writing out" output
commit-graph write: add "Writing out" progress output
commit-graph: don't call write_graph_chunk_extra_edges() unnecessarily
commit-graph: rename "large edges" to "extra edges"

Merge branch 'ab/commit-graph-write-optim'Junio C Hamano Tue, 5 Feb 2019 22:26:14 +0000 (14:26 -0800)

Merge branch 'ab/commit-graph-write-optim'

The codepath to write out commit-graph has been optimized by
following the usual pattern of visiting objects in in-pack order.

* ab/commit-graph-write-optim:
commit-graph write: use pack order when finding commits

Merge branch 'js/t6042-timing-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:14 +0000 (14:26 -0800)

Merge branch 'js/t6042-timing-fix'

Test update.

* js/t6042-timing-fix:
t6042: work around speed optimization on Windows

Merge branch 'jk/add-ignore-errors-bit-assignment-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:13 +0000 (14:26 -0800)

Merge branch 'jk/add-ignore-errors-bit-assignment-fix'

"git add --ignore-errors" did not work as advertised and instead
worked as an unintended synonym for "git add --renormalize", which
has been fixed.

* jk/add-ignore-errors-bit-assignment-fix:
add: use separate ADD_CACHE_RENORMALIZE flag

Merge branch 'js/mingw-unc-path-w-backslashes'Junio C Hamano Tue, 5 Feb 2019 22:26:13 +0000 (14:26 -0800)

Merge branch 'js/mingw-unc-path-w-backslashes'

In Git for Windows, "git clone \\server\share\path" etc. that uses
UNC paths from command line had bad interaction with its shell
emulation.

* js/mingw-unc-path-w-backslashes:
mingw: special-case arguments to `sh`
mingw (t5580): document bug when cloning from backslashed UNC paths

Merge branch 'cc/test-ref-store-typofix'Junio C Hamano Tue, 5 Feb 2019 22:26:12 +0000 (14:26 -0800)

Merge branch 'cc/test-ref-store-typofix'

An obvious typo in an assertion error message has been fixed.

* cc/test-ref-store-typofix:
helper/test-ref-store: fix "new-sha1" vs "old-sha1" typo

Merge branch 'jt/fetch-v2-sideband'Junio C Hamano Tue, 5 Feb 2019 22:26:11 +0000 (14:26 -0800)

Merge branch 'jt/fetch-v2-sideband'

"git fetch" and "git upload-pack" learned to send all exchange over
the sideband channel while talking the v2 protocol.

* jt/fetch-v2-sideband:
tests: define GIT_TEST_SIDEBAND_ALL
{fetch,upload}-pack: sideband v2 fetch response
sideband: reverse its dependency on pkt-line
pkt-line: introduce struct packet_writer
pack-protocol.txt: accept error packets in any context
Use packet_reader instead of packet_read_line

Merge branch 'sg/obstack-cast-function-type-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:11 +0000 (14:26 -0800)

Merge branch 'sg/obstack-cast-function-type-fix'

The compat/obstack code had casts that -Wcast-function-type
compilation option found questionable.

* sg/obstack-cast-function-type-fix:
compat/obstack: fix -Wcast-function-type warnings

Merge branch 'js/commit-graph-chunk-table-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:11 +0000 (14:26 -0800)

Merge branch 'js/commit-graph-chunk-table-fix'

The codepath to read from the commit-graph file attempted to read
past the end of it when the file's table-of-contents was corrupt.

* js/commit-graph-chunk-table-fix:
Makefile: correct example fuzz build
commit-graph: fix buffer read-overflow
commit-graph, fuzz: add fuzzer for commit-graph

Merge branch 'ld/git-p4-shelve-update-fix'Junio C Hamano Tue, 5 Feb 2019 22:26:10 +0000 (14:26 -0800)

Merge branch 'ld/git-p4-shelve-update-fix'

"git p4" failed to update a shelved change when there were moved
files, which has been corrected.

* ld/git-p4-shelve-update-fix:
git-p4: handle update of moved/copied files when updating a shelve
git-p4: add failing test for shelved CL update involving move/copy

Merge branch 'jt/get-reference-with-commit-graph'Junio C Hamano Tue, 5 Feb 2019 22:26:10 +0000 (14:26 -0800)

Merge branch 'jt/get-reference-with-commit-graph'

Micro-optimize the code that prepares commit objects to be walked
by "git rev-list" when the commit-graph is available.

* jt/get-reference-with-commit-graph:
revision: use commit graph in get_reference()

Merge branch 'js/filter-options-should-use-plain-int'Junio C Hamano Tue, 5 Feb 2019 22:26:09 +0000 (14:26 -0800)

Merge branch 'js/filter-options-should-use-plain-int'

Update the protocol message specification to allow only the limited
use of scaled quantities. This is ensure potential compatibility
issues will not go out of hand.

* js/filter-options-should-use-plain-int:
filter-options: expand scaled numbers
tree:<depth>: skip some trees even when collecting omits
list-objects-filter: teach tree:# how to handle >0

Merge branch 'sb/more-repo-in-api'Junio C Hamano Tue, 5 Feb 2019 22:26:09 +0000 (14:26 -0800)

Merge branch 'sb/more-repo-in-api'

The in-core repository instances are passed through more codepaths.

* sb/more-repo-in-api: (23 commits)
t/helper/test-repository: celebrate independence from the_repository
path.h: make REPO_GIT_PATH_FUNC repository agnostic
commit: prepare free_commit_buffer and release_commit_memory for any repo
commit-graph: convert remaining functions to handle any repo
submodule: don't add submodule as odb for push
submodule: use submodule repos for object lookup
pretty: prepare format_commit_message to handle arbitrary repositories
commit: prepare logmsg_reencode to handle arbitrary repositories
commit: prepare repo_unuse_commit_buffer to handle any repo
commit: prepare get_commit_buffer to handle any repo
commit-reach: prepare in_merge_bases[_many] to handle any repo
commit-reach: prepare get_merge_bases to handle any repo
commit-reach.c: allow get_merge_bases_many_0 to handle any repo
commit-reach.c: allow remove_redundant to handle any repo
commit-reach.c: allow merge_bases_many to handle any repo
commit-reach.c: allow paint_down_to_common to handle any repo
commit: allow parse_commit* to handle any repo
object: parse_object to honor its repository argument
object-store: prepare has_{sha1, object}_file to handle any repo
object-store: prepare read_object_file to deal with any repo
...

Makefile: improve SPARSE_FLAGS customisationRamsay Jones Tue, 5 Feb 2019 02:27:48 +0000 (02:27 +0000)

Makefile: improve SPARSE_FLAGS customisation

In order to enable greater user customisation of the SPARSE_FLAGS
variable, we introduce a new SP_EXTRA_FLAGS variable to use for
target specific settings. Without using the new variable, setting
the SPARSE_FLAGS on the 'make' command-line would also override the
value set by the target-specific rules in the Makefile (effectively
making them useless). Also, this enables the SP_EXTRA_FLAGS to be
used in the future for any other internal customisations, such as
for some platform specific values.

In addition, we initialise the SPARSE_FLAGS to the default (empty)
value using a conditional assignment (?=). This allows SPARSE_FLAGS
to be set from the environment as well as from the command-line.

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

config.mak.uname: remove obsolete SPARSE_FLAGS settingRamsay Jones Tue, 5 Feb 2019 02:25:53 +0000 (02:25 +0000)

config.mak.uname: remove obsolete SPARSE_FLAGS setting

An upcoming commit will change the semantics of the SPARSE_FLAGS
variable from an internal to a user only customisation variable.
The MinGW configuration section contains an obsolete setting for
this variable which was used (some years ago) to cater to an error
in the Win32 system header files. Since 'sparse' does not currently
support the MinGW platform, nobody on that platform can be relying
on this setting today. Remove this use of the SPARSE_FLAGS variable.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-redundant: consistent sort methodJiang Xin Sat, 2 Feb 2019 13:30:17 +0000 (21:30 +0800)

pack-redundant: consistent sort method

SZEDER reported that test case t5323 has different test result on MacOS.
This is because `cmp_pack_list_reverse` cannot give identical result
when two pack being sorted has the same size of remaining_objects.

Changes to the sorting function will make consistent test result for
t5323.

The new algorithm to find redundant packs is a trade-off to save memory
resources, and the result of it may be different with old one, and may
be not the best result sometimes. Update t5323 for the new algorithm.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-redundant: rename pack_list.all_objectsJiang Xin Sat, 2 Feb 2019 13:30:16 +0000 (21:30 +0800)

pack-redundant: rename pack_list.all_objects

New algorithm uses `pack_list.all_objects` to track remaining objects,
so rename it to `pack_list.remaining_objects`.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-redundant: new algorithm to find min packsSun Chao Sat, 2 Feb 2019 13:30:15 +0000 (21:30 +0800)

pack-redundant: new algorithm to find min packs

When calling `git pack-redundant --all`, if there are too many local
packs and too many redundant objects within them, the too deep iteration
of `get_permutations` will exhaust all the resources, and the process of
`git pack-redundant` will be killed.

The following script could create a repository with too many redundant
packs, and running `git pack-redundant --all` in the `test.git` repo
will die soon.

#!/bin/sh

repo="$(pwd)/test.git"
work="$(pwd)/test"
i=1
max=199

if test -d "$repo" || test -d "$work"; then
echo >&2 "ERROR: '$repo' or '$work' already exist"
exit 1
fi

git init -q --bare "$repo"
git --git-dir="$repo" config gc.auto 0
git --git-dir="$repo" config transfer.unpackLimit 0
git clone -q "$repo" "$work" 2>/dev/null

while :; do
cd "$work"
echo "loop $i: $(date +%s)" >$i
git add $i
git commit -q -sm "loop $i"
git push -q origin HEAD:master
printf "\rCreate pack %4d/%d\t" $i $max
if test $i -ge $max; then break; fi

cd "$repo"
git repack -q
if test $(($i % 2)) -eq 0; then
git repack -aq
pack=$(ls -t $repo/objects/pack/*.pack | head -1)
touch "${pack%.pack}.keep"
fi
i=$((i+1))
done
printf "\ndone\n"

To get the `min` unique pack list, we can replace the iteration in
`minimize` function with a new algorithm, and this could solve this
issue:

1. Get the unique and non_uniqe packs, add the unique packs to the
`min` list.

2. Remove the objects of unique packs from non_unique packs, then each
object left in the non_unique packs will have at least two copies.

3. Sort the non_unique packs by the objects' size, more objects first,
and add the first non_unique pack to `min` list.

4. Drop the duplicated objects from other packs in the ordered
non_unique pack list, and repeat step 3.

Some test cases will fail on Mac OS X. Mark them and will resolve in
later commit.

Original PR and discussions: https://github.com/jiangxin/git/pull/25

Signed-off-by: Sun Chao <sunchao9@huawei.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-redundant: delete redundant codeSun Chao Sat, 2 Feb 2019 13:30:14 +0000 (21:30 +0800)

pack-redundant: delete redundant code

The objects in alt-odb are removed from `all_objects` twice in `load_all_objects`
and `scan_alt_odb_packs`, remove it from the later function.

Signed-off-by: Sun Chao <sunchao9@huawei.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-redundant: delay creation of unique_objectsJiang Xin Sat, 2 Feb 2019 13:30:13 +0000 (21:30 +0800)

pack-redundant: delay creation of unique_objects

Instead of initializing unique_objects in `add_pack()`, copy from
all_objects in `cmp_two_packs()`, when unwanted objects are removed from
all_objects.

This will save memory (no allocate memory for alt-odb packs), and run
`llist_sorted_difference_inplace()` only once when removing ignored
objects and removing objects in alt-odb in `scan_alt_odb_packs()`.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5323: test cases for git-pack-redundantJiang Xin Sat, 2 Feb 2019 13:30:12 +0000 (21:30 +0800)

t5323: test cases for git-pack-redundant

Add test cases for git pack-redundant to validate new algorithm for git
pack-redundant.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Sun Chao <sunchao9@huawei.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-submodule.sh: shorten submodule SHA-1s using rev... Sven van Haastregt Sun, 3 Feb 2019 21:00:27 +0000 (21:00 +0000)

git-submodule.sh: shorten submodule SHA-1s using rev-parse

Until now, `git submodule summary` was always emitting 7-character
SHA-1s that have a higher chance of being ambiguous for larger
repositories. Use `git rev-parse --short` instead, which will
determine suitable short SHA-1 lengths.

When a submodule hasn't been initialized with "submodule init" or
not cloned, `git rev-parse` would not work in it yet; as a fallback,
use the original method of cutting at 7 hexdigits.

Signed-off-by: Sven van Haastregt <svenvh@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch-pack: clear alternate shallow when completebrian m. carlson Mon, 4 Feb 2019 00:06:50 +0000 (00:06 +0000)

fetch-pack: clear alternate shallow when complete

When we write an alternate shallow file in update_shallow, we write it
into the lock file. The string stored in alternate_shallow_file is
copied from the lock file path, but it is freed the moment that the lock
file is closed, since we call strbuf_release to free that path.

This used to work, since we did not invoke git index-pack more than
once, but now that we do, we reuse the freed memory. Ensure we reset the
value to NULL to avoid using freed memory. git index-pack will read the
repository's shallow file, which will have been updated with the correct
information.

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

revert "checkout: introduce checkout.overlayMode config"Thomas Gummerer Mon, 4 Feb 2019 21:13:16 +0000 (21:13 +0000)

revert "checkout: introduce checkout.overlayMode config"

This reverts 1495ff7da5 ("checkout: introduce checkout.overlayMode
config", 2019-01-08) and thus removes the checkout.overlayMode config
option.

The option was originally introduced to give users the option to make
the new no-overlay behaviour the default. However users may be using
'git checkout' in scripts, even though it is porcelain. Users setting
the option to false may actually end up accidentally breaking scripts.

With the introduction of a new subcommand that will make the behaviour
the default, the config option will not be needed anymore anyway.
Revert the commit and remove the config option, so we don't risk
breaking scripts.

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

doc-diff: don't `cd_to_toplevel`Martin Ågren Mon, 4 Feb 2019 20:50:37 +0000 (21:50 +0100)

doc-diff: don't `cd_to_toplevel`

`usage` tries to call $0, which might very well be "./doc-diff", so if
we `cd_to_toplevel` before calling `usage`, we'll end with an error to
the effect of "./doc-diff: not found" rather than a friendly `doc-diff
-h` output. This regressed in ad51743007 ("doc-diff: add --clean mode to
remove temporary working gunk", 2018-08-31) where we moved the call to
`cd_to_toplevel` to much earlier.

A general fix might be to teach git-sh-setup to save away the absolute
path for $0 and then use that, instead. I'm not aware of any portable
way of doing that, see, e.g., d2addc3b96 ("t7800: readlink may not be
available", 2016-05-31).

An early version of this patch moved `cd_to_toplevel` back to where it
was before ad51743007 and taught the "--clean" code to cd on its own.
But let's try instead to get rid of the cd-ing entirely. We don't really
need it and we can work with absolute paths instead. There's just one
use of $PWD that we need to adjust by simply dropping it.

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

diff-tree doc: correct & remove wrong documentationÆvar Arnfjörð Bjarmason Mon, 4 Feb 2019 10:36:18 +0000 (11:36 +0100)

diff-tree doc: correct & remove wrong documentation

The documentation saying that diff-tree didn't support anything except
literal prefixes hasn't been true since
d38f28093e ("tree_entry_interesting(): support wildcard matching",
2010-12-15), but this documentation was not updated at the time.

Since this command uses pathspecs like most other commands, there's no
need to show examples of how the various "cmd <revs> <paths>"
invocations work.

Furthermore, the "git diff-tree --abbrev 5319e4" example shown here
never worked. We'd ended up with that through a combination of
62b42d3487 ("docs: fix some antique example output", 2011-05-26) and
ac4e086929 ("Adjust core-git documentation to more recent Linus GIT.",
2005-05-05), but "git diff-tree <tree>" was always invalid.

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

config: allow giving separate author and committer... William Hubbs Mon, 4 Feb 2019 18:48:50 +0000 (12:48 -0600)

config: allow giving separate author and committer idents

The author.email, author.name, committer.email and committer.name
settings are analogous to the GIT_AUTHOR_* and GIT_COMMITTER_*
environment variables, but for the git config system. This allows them
to be set separately for each repository.

Git supports setting different authorship and committer
information with environment variables. However, environment variables
are set in the shell, so if different authorship and committer
information is needed for different repositories an external tool is
required.

This adds support to git config for author.email, author.name,
committer.email and committer.name settings so this information
can be set per repository.

Also, it generalizes the fmt_ident function so it can handle author vs
committer identification.

Signed-off-by: William Hubbs <williamh@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6120: test for describe with a bare repositorySebastian Staudt Sun, 3 Feb 2019 06:00:25 +0000 (07:00 +0100)

t6120: test for describe with a bare repository

This ensures that nothing breaks the basic functionality of describe for
bare repositories. Please note that --broken and --dirty need a working
tree.

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

describe: setup working tree for --dirtySebastian Staudt Sun, 3 Feb 2019 06:00:24 +0000 (07:00 +0100)

describe: setup working tree for --dirty

We don't use NEED_WORK_TREE when running the git-describe builtin,
since you should be able to describe a commit even in a bare repository.
However, the --dirty flag does need a working tree. Since we don't call
setup_work_tree(), it uses whatever directory we happen to be in. That's
unlikely to match our index, meaning we'd say "dirty" even when the real
working tree is clean.

We can fix that by calling setup_work_tree() once we know that the user
has asked for --dirty.

The --broken option also needs a working tree. But because its
implementation calls git-diff-index we don‘t have to setup the working
tree in the git-describe process.

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

travis-ci: make the OSX build jobs' 'brew update' more... SZEDER Gábor Sat, 2 Feb 2019 16:34:21 +0000 (17:34 +0100)

travis-ci: make the OSX build jobs' 'brew update' more quiet

Before installing the necessary dependencies, our OSX build jobs run
'brew update --quiet'. This is problematic for two reasons:

- This '--quiet' flag apparently broke overnight, resulting in
errored builds:

+brew update --quiet
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.3.7.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.3.7.mavericks.bottle.tar.gz
Usage: brew update_report [--preinstall]
The Ruby implementation of brew update. Never called manually.
--preinstall Run in 'auto-update' mode (faster, less
output).
-f, --force Override warnings and enable potentially
unsafe operations.
-d, --debug Display any debugging information.
-v, --verbose Make some output more verbose.
-h, --help Show this message.
Error: invalid option: --quiet
The command "ci/install-dependencies.sh" failed and exited with 1 during .

I belive that this breakage will be noticed and fixed soon-ish, so
we could probably just wait a bit for this issue to solve itself,
but:

- 'brew update --quiet' wasn't really quiet in the first place, as
it listed over about 2000 lines worth of available packages that
we absolutely don't care about, see e.g. one of the latest
'master' builds:

https://travis-ci.org/git/git/jobs/486134962#L113

So drop this '--quiet' option and redirect 'brew update's standard
output to /dev/null to make it really quiet, thereby making the OSX
builds work again despite the above mentioned breakage.

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

git-commit.txt: better description what it doesNguyễn Thái Ngọc Duy Fri, 1 Feb 2019 10:09:10 +0000 (17:09 +0700)

git-commit.txt: better description what it does

The description of git-commit jumps right into the commit content, which
is important, but it fails to mention how the commit is "added" to the
repository. Update the first paragraph saying a bit more about branch
update to fill this gap.

While at there, add a couple linkgit references when the command is
first mentioned.

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

various: tighten constness of some local variablesShahzad Lone Sat, 2 Feb 2019 23:16:45 +0000 (23:16 +0000)

various: tighten constness of some local variables

Signed-off-by: Shahzad Lone <shahzadlone@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

help: align the longest command in the command listingNguyễn Thái Ngọc Duy Thu, 31 Jan 2019 09:23:49 +0000 (16:23 +0700)

help: align the longest command in the command listing

"longest" is used to determine how many extra spaces we need to print
to keep the command description aligned. For the longest command, we
should print no extra space instead of one, or we'll get unaligned
output like this (notice the "checkout" line):

grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and ...
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag ...

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

t1512: test ambiguous cat-file --batch and --batch... Eric Wong Wed, 30 Jan 2019 21:33:49 +0000 (21:33 +0000)

t1512: test ambiguous cat-file --batch and --batch-output

Test the new "ambiguous" result from cat-file --batch and
--batch-check. This is in t1512 instead of t1006 since
we need a repo with ambiguous object_id names.

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Support working-tree-encoding "UTF-16LE-BOM"Torsten Bögershausen Wed, 30 Jan 2019 15:01:52 +0000 (16:01 +0100)

Support working-tree-encoding "UTF-16LE-BOM"

Users who want UTF-16 files in the working tree set the .gitattributes
like this:
test.txt working-tree-encoding=UTF-16

The unicode standard itself defines 3 allowed ways how to encode UTF-16.
The following 3 versions convert all back to 'g' 'i' 't' in UTF-8:

a) UTF-16, without BOM, big endian:
$ printf "\000g\000i\000t" | iconv -f UTF-16 -t UTF-8 | od -c
0000000 g i t

b) UTF-16, with BOM, little endian:
$ printf "\377\376g\000i\000t\000" | iconv -f UTF-16 -t UTF-8 | od -c
0000000 g i t

c) UTF-16, with BOM, big endian:
$ printf "\376\377\000g\000i\000t" | iconv -f UTF-16 -t UTF-8 | od -c
0000000 g i t

Git uses libiconv to convert from UTF-8 in the index into ITF-16 in the
working tree.
After a checkout, the resulting file has a BOM and is encoded in "UTF-16",
in the version (c) above.
This is what iconv generates, more details follow below.

iconv (and libiconv) can generate UTF-16, UTF-16LE or UTF-16BE:

d) UTF-16
$ printf 'git' | iconv -f UTF-8 -t UTF-16 | od -c
0000000 376 377 \0 g \0 i \0 t

e) UTF-16LE
$ printf 'git' | iconv -f UTF-8 -t UTF-16LE | od -c
0000000 g \0 i \0 t \0

f) UTF-16BE
$ printf 'git' | iconv -f UTF-8 -t UTF-16BE | od -c
0000000 \0 g \0 i \0 t

There is no way to generate version (b) from above in a Git working tree,
but that is what some applications need.
(All fully unicode aware applications should be able to read all 3 variants,
but in practise we are not there yet).

When producing UTF-16 as an output, iconv generates the big endian version
with a BOM. (big endian is probably chosen for historical reasons).

iconv can produce UTF-16 files with little endianess by using "UTF-16LE"
as encoding, and that file does not have a BOM.

Not all users (especially under Windows) are happy with this.
Some tools are not fully unicode aware and can only handle version (b).

Today there is no way to produce version (b) with iconv (or libiconv).
Looking into the history of iconv, it seems as if version (c) will
be used in all future iconv versions (for compatibility reasons).

Solve this dilemma and introduce a Git-specific "UTF-16LE-BOM".
libiconv can not handle the encoding, so Git pick it up, handles the BOM
and uses libiconv to convert the rest of the stream.
(UTF-16BE-BOM is added for consistency)

Rported-by: Adrián Gimeno Balaguer <adrigibal@gmail.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

init docs: correct a punctuation typoKyle Meyer Thu, 24 Jan 2019 21:44:16 +0000 (16:44 -0500)

init docs: correct a punctuation typo

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase -x: sanity check commandPhillip Wood Tue, 29 Jan 2019 18:43:27 +0000 (18:43 +0000)

rebase -x: sanity check command

If the user gives an empty argument to --exec then git creates a todo
list that it cannot parse. The rebase starts to run before erroring out
with

error: missing arguments for exec
error: invalid line 2: exec
You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'.
Or you can abort the rebase with 'git rebase --abort'.

Instead check for empty commands before starting the rebase.

Also check that the command does not contain any newlines as the
todo-list format is unable to cope with multiline commands. Note that
this changes the behavior, before this change one could do

git rebase --exec='echo one
exec echo two'

and it would insert two exec lines in the todo list, now it will error
out.

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

Fourth batch after 2.20Junio C Hamano Tue, 29 Jan 2019 20:54:55 +0000 (12:54 -0800)

Fourth batch after 2.20

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

Merge branch 'it/log-format-source'Junio C Hamano Tue, 29 Jan 2019 20:47:56 +0000 (12:47 -0800)

Merge branch 'it/log-format-source'

Custom userformat "log --format" learned %S atom that stands for
the tip the traversal reached the commit from, i.e. --source.

* it/log-format-source:
log: add %S option (like --source) to log --format

Merge branch 'js/add-e-clear-patch-before-stating'Junio C Hamano Tue, 29 Jan 2019 20:47:56 +0000 (12:47 -0800)

Merge branch 'js/add-e-clear-patch-before-stating'

"git add -e" got confused when the change it wants to let the user
edit is smaller than the previous change that was left over in a
temporary file.

* js/add-e-clear-patch-before-stating:
add --edit: truncate the patch file

Merge branch 'bc/tree-walk-oid'Junio C Hamano Tue, 29 Jan 2019 20:47:56 +0000 (12:47 -0800)

Merge branch 'bc/tree-walk-oid'

The code to walk tree objects has been taught that we may be
working with object names that are not computed with SHA-1.

* bc/tree-walk-oid:
cache: make oidcpy always copy GIT_MAX_RAWSZ bytes
tree-walk: store object_id in a separate member
match-trees: use hashcpy to splice trees
match-trees: compute buffer offset correctly when splicing
tree-walk: copy object ID before use

Merge branch 'jt/upload-pack-deepen-relative-proto-v2'Junio C Hamano Tue, 29 Jan 2019 20:47:55 +0000 (12:47 -0800)

Merge branch 'jt/upload-pack-deepen-relative-proto-v2'

"git fetch --deepen=<more>" has been corrected to work over v2
protocol.

* jt/upload-pack-deepen-relative-proto-v2:
upload-pack: teach deepen-relative in protocol v2
fetch-pack: do not take shallow lock unnecessarily

Merge branch 'jk/remote-insteadof-cleanup'Junio C Hamano Tue, 29 Jan 2019 20:47:55 +0000 (12:47 -0800)

Merge branch 'jk/remote-insteadof-cleanup'

Code clean-up.

* jk/remote-insteadof-cleanup:
remote: check config validity before creating rewrite struct

Merge branch 'ms/http-no-more-failonerror'Junio C Hamano Tue, 29 Jan 2019 20:47:55 +0000 (12:47 -0800)

Merge branch 'ms/http-no-more-failonerror'

Debugging help for http transport.

* ms/http-no-more-failonerror:
test: test GIT_CURL_VERBOSE=1 shows an error
remote-curl: unset CURLOPT_FAILONERROR
remote-curl: define struct for CURLOPT_WRITEFUNCTION
http: enable keep_error for HTTP requests
http: support file handles for HTTP_KEEP_ERROR

Merge branch 'os/rebase-runs-post-checkout-hook'Junio C Hamano Tue, 29 Jan 2019 20:47:55 +0000 (12:47 -0800)

Merge branch 'os/rebase-runs-post-checkout-hook'

"git rebase" internally runs "checkout" to switch between branches,
and the command used to call the post-checkout hook, but the
reimplementation stopped doing so, which is getting fixed.

* os/rebase-runs-post-checkout-hook:
rebase: run post-checkout hook on checkout
t5403: simplify by using a single repository

Merge branch 'bc/sha-256'Junio C Hamano Tue, 29 Jan 2019 20:47:55 +0000 (12:47 -0800)

Merge branch 'bc/sha-256'

Add sha-256 hash and plug it through the code to allow building Git
with the "NewHash".

* bc/sha-256:
hash: add an SHA-256 implementation using OpenSSL
sha256: add an SHA-256 implementation using libgcrypt
Add a base implementation of SHA-256 support
commit-graph: convert to using the_hash_algo
t/helper: add a test helper to compute hash speed
sha1-file: add a constant for hash block size
t: make the sha1 test-tool helper generic
t: add basic tests for our SHA-1 implementation
cache: make hashcmp and hasheq work with larger hashes
hex: introduce functions to print arbitrary hashes
sha1-file: provide functions to look up hash algorithms
sha1-file: rename algorithm to "sha1"

Merge branch 'sb/submodule-recursive-fetch-gets-the... Junio C Hamano Tue, 29 Jan 2019 20:47:54 +0000 (12:47 -0800)

Merge branch 'sb/submodule-recursive-fetch-gets-the-tip'

"git fetch --recurse-submodules" may not fetch the necessary commit
that is bound to the superproject, which is getting corrected.

* sb/submodule-recursive-fetch-gets-the-tip:
fetch: ensure submodule objects fetched
submodule.c: fetch in submodules git directory instead of in worktree
submodule: migrate get_next_submodule to use repository structs
repository: repo_submodule_init to take a submodule struct
submodule: store OIDs in changed_submodule_names
submodule.c: tighten scope of changed_submodule_names struct
submodule.c: sort changed_submodule_names before searching it
submodule.c: fix indentation
sha1-array: provide oid_array_filter

Merge branch 'jt/fetch-pack-v2'Junio C Hamano Tue, 29 Jan 2019 20:47:54 +0000 (12:47 -0800)

Merge branch 'jt/fetch-pack-v2'

"git fetch-pack" now can talk the version 2 protocol.

* jt/fetch-pack-v2:
fetch-pack: support protocol version 2

Merge branch 'jk/proto-v2-hidden-refs-fix'Junio C Hamano Tue, 29 Jan 2019 20:47:54 +0000 (12:47 -0800)

Merge branch 'jk/proto-v2-hidden-refs-fix'

The v2 upload-pack protocol implementation failed to honor
hidden-ref configuration, which has been corrected.
An earlier attempt reverted out of 'next'.

* jk/proto-v2-hidden-refs-fix:
upload-pack: support hidden refs with protocol v2

Merge branch 'jk/save-getenv-result'Junio C Hamano Tue, 29 Jan 2019 20:47:53 +0000 (12:47 -0800)

Merge branch 'jk/save-getenv-result'

There were many places the code relied on the string returned from
getenv() to be non-volatile, which is not true, that have been
corrected.

* jk/save-getenv-result:
builtin_diff(): read $GIT_DIFF_OPTS closer to use
merge-recursive: copy $GITHEAD strings
init: make a copy of $GIT_DIR string
config: make a copy of $GIT_CONFIG string
commit: copy saved getenv() result
get_super_prefix(): copy getenv() result

Merge branch 'pw/diff-color-moved-ws-fix'Junio C Hamano Tue, 29 Jan 2019 20:47:53 +0000 (12:47 -0800)

Merge branch 'pw/diff-color-moved-ws-fix'

"git diff --color-moved-ws" updates.

* pw/diff-color-moved-ws-fix:
diff --color-moved-ws: handle blank lines
diff --color-moved-ws: modify allow-indentation-change
diff --color-moved-ws: optimize allow-indentation-change
diff --color-moved=zebra: be stricter with color alternation
diff --color-moved-ws: fix false positives
diff --color-moved-ws: demonstrate false positives
diff: allow --no-color-moved-ws
Use "whitespace" consistently
diff: document --no-color-moved

Merge branch 'ja/doc-build-l10n'Junio C Hamano Tue, 29 Jan 2019 20:47:53 +0000 (12:47 -0800)

Merge branch 'ja/doc-build-l10n'

Prepare Documentation/Makefile so that manpage localization can
reuse it by overriding and tweaking the list of build products.

* ja/doc-build-l10n:
Documentation/Makefile add optional targets for l10n

Merge branch 'js/rebase-i-redo-exec'Junio C Hamano Tue, 29 Jan 2019 20:47:53 +0000 (12:47 -0800)

Merge branch 'js/rebase-i-redo-exec'

"git rebase -i" learned to re-execute a command given with 'exec'
to run after it failed the last time.

* js/rebase-i-redo-exec:
rebase: introduce a shortcut for --reschedule-failed-exec
rebase: add a config option to default to --reschedule-failed-exec
rebase: introduce --reschedule-failed-exec

Merge branch 'cc/fetch-error-message-fix'Junio C Hamano Tue, 29 Jan 2019 20:47:53 +0000 (12:47 -0800)

Merge branch 'cc/fetch-error-message-fix'

Error message fix.

* cc/fetch-error-message-fix:
fetch: fix extensions.partialclone name in error message

Merge branch 'cc/partial-clone-doc-typofix'Junio C Hamano Tue, 29 Jan 2019 20:47:52 +0000 (12:47 -0800)

Merge branch 'cc/partial-clone-doc-typofix'

Doc fix.

* cc/partial-clone-doc-typofix:
partial-clone: add missing 'is' in doc

Merge branch 'kg/external-diff-save-env'Junio C Hamano Tue, 29 Jan 2019 20:47:51 +0000 (12:47 -0800)

Merge branch 'kg/external-diff-save-env'

The code to drive GIT_EXTERNAL_DIFF command relied on the string
returned from getenv() to be non-volatile, which is not true, that
has been corrected.

* kg/external-diff-save-env:
diff: ensure correct lifetime of external_diff_cmd

Makefile: add coverage-prove targetDerrick Stolee Tue, 29 Jan 2019 17:05:18 +0000 (09:05 -0800)

Makefile: add coverage-prove target

Sometimes there are test failures in the 'pu' branch. This
is somewhat expected for a branch that takes the very latest
topics under development, and those sometimes have semantic
conflicts that only show up during test runs. This also can
happen when running the test suite with different GIT_TEST_*
environment variables that interact in unexpected ways

This causes a problem for the test coverage reports, as
the typical 'make coverage-test coverage-report' run halts
at the first failed test. If that test is early in the
suite, then many valuable tests are not exercising the code
and the coverage report becomes noisy with false positives.

Add a new 'coverage-prove' target to the Makefile,
modeled after the 'coverage-test' target. This compiles
the source using the coverage flags, then runs the test
suite using the 'prove' tool. Since the coverage
machinery is not thread-safe, enforce that the tests
are run in sequence by appending '-j1' to GIT_PROVE_OPTS.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pretty: add support for separator option in %(trailers)Anders Waldenborg Mon, 28 Jan 2019 21:33:37 +0000 (22:33 +0100)

pretty: add support for separator option in %(trailers)

By default trailer lines are terminated by linebreaks ('\n'). By
specifying the new 'separator' option they will instead be separated by
user provided string and have separator semantics rather than terminator
semantics. The separator string can contain the literal formatting codes
%n and %xNN allowing it to be things that are otherwise hard to type
such as %x00, or comma and end-parenthesis which would break parsing.

E.g:
$ git log --pretty='%(trailers:key=Reviewed-by,valueonly,separator=%x00)'

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

strbuf: separate callback for strbuf_expand:ing literalsAnders Waldenborg Mon, 28 Jan 2019 21:33:36 +0000 (22:33 +0100)

strbuf: separate callback for strbuf_expand:ing literals

Expanding '%n' and '%xNN' is generic functionality, so extract that from
the pretty.c formatter into a callback that can be reused.

No functional change intended

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pretty: add support for "valueonly" option in %(trailers)Anders Waldenborg Mon, 28 Jan 2019 21:33:35 +0000 (22:33 +0100)

pretty: add support for "valueonly" option in %(trailers)

With the new "key=" option to %(trailers) it often makes little sense to
show the key, as it by definition already is knows which trailer is
printed there. This new "valueonly" option makes it omit the key when
printing trailers.

E.g.:
$ git show -s --pretty='%s%n%(trailers:key=Signed-off-by,valueonly)' aaaa88182
will show:
> upload-pack: fix broken if/else chain in config callback
> Jeff King <peff@peff.net>
> Junio C Hamano <gitster@pobox.com>

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pretty: allow showing specific trailersAnders Waldenborg Mon, 28 Jan 2019 21:33:34 +0000 (22:33 +0100)

pretty: allow showing specific trailers

Adds a new "key=X" option to "%(trailers)" which will cause it to only
print trailer lines which match any of the specified keys.

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pretty: single return path in %(trailers) handlingAnders Waldenborg Mon, 28 Jan 2019 21:33:33 +0000 (22:33 +0100)

pretty: single return path in %(trailers) handling

No functional change intended.

This change may not seem useful on its own, but upcoming commits will do
memory allocation in there, and a single return path makes deallocation
easier.

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pretty: allow %(trailers) options with explicit valueAnders Waldenborg Tue, 29 Jan 2019 06:49:00 +0000 (07:49 +0100)

pretty: allow %(trailers) options with explicit value

In addition to old %(trailers:only) it is now allowed to write
%(trailers:only=yes)

By itself this only gives (the not quite so useful) possibility to have
users change their mind in the middle of a formatting
string (%(trailers:only=true,only=false)). However, it gives users the
opportunity to override defaults from future options.

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Add `human` date format tests.Stephen P. Smith Tue, 29 Jan 2019 03:50:16 +0000 (20:50 -0700)

Add `human` date format tests.

When using `human` several fields are suppressed depending on the time
difference between the reference date and the local computer date. In
cases where the difference is less than a year, the year field is
supppressed. If the time is less than a day; the month and year is
suppressed.

Use TEST_DATE_NOW environment variable when using the test-tool to
hold the expected output strings constant.

Signed-off-by: Stephen P. Smith <ischis2@cox.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Add `human` format to test-toolStephen P. Smith Tue, 29 Jan 2019 03:50:15 +0000 (20:50 -0700)

Add `human` format to test-tool

Add the human format support to the test tool so that
GIT_TEST_DATE_NOW can be used to specify the current time.

The get_time() helper function was created and and checks the
GIT_TEST_DATE_NOW environment variable. If GIT_TEST_DATE_NOW is set,
then that date is used instead of the date returned by by
gettimeofday().

All calls to gettimeofday() were replaced by calls to get_time().

Renamed occurances of TEST_DATE_NOW to GIT_TEST_DATE_NOW since the
variable is now used in the get binary and not just in the test-tool.

Signed-off-by: Stephen P. Smith <ischis2@cox.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ci: parallelize testing on WindowsJohannes Schindelin Tue, 29 Jan 2019 14:19:38 +0000 (06:19 -0800)

ci: parallelize testing on Windows

The fact that Git's test suite is implemented in Unix shell script that
is as portable as we can muster, combined with the fact that Unix shell
scripting is foreign to Windows (and therefore has to be emulated),
results in pretty abysmal speed of the test suite on that platform, for
pretty much no other reason than that language choice.

For comparison: while the Linux build & test is typically done within
about 8 minutes, the Windows build & test typically lasts about 80
minutes in Azure Pipelines.

To help with that, let's use the Azure Pipeline feature where you can
parallelize jobs, make jobs depend on each other, and pass artifacts
between them.

The tests are distributed using the following heuristic: listing all
test scripts ordered by size in descending order (as a cheap way to
estimate the overall run time), every Nth script is run (where N is the
total number of parallel jobs), starting at the index corresponding to
the parallel job. This slicing is performed by a new function that is
added to the `test-tool`.

To optimize the overall runtime of the entire Pipeline, we need to move
the Windows jobs to the beginning (otherwise there would be a very
decent chance for the Pipeline to be run only the Windows build, while
all the parallel Windows test jobs wait for this single one).

We use Azure Pipelines Artifacts for both the minimal Git for Windows
SDK as well as the built executables, as deduplication and caching close
to the agents makes that really fast. For comparison: while downloading
and unpacking the minimal Git for Windows SDK via PowerShell takes only
one minute (down from anywhere between 2.5 to 7 when using a shallow
clone), uploading it as Pipeline Artifact takes less than 30s and
downloading and unpacking less than 20s (sometimes even as little as
only twelve seconds).

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

ci: speed up Windows phaseJohannes Schindelin Tue, 29 Jan 2019 14:19:38 +0000 (06:19 -0800)

ci: speed up Windows phase

As Unix shell scripting comes at a hefty price on Windows, we have to
see where we can save some time to run the test suite.

Let's skip the chain linting and the bin-wrappers/ redirection on
Windows; this seems to shave of anywhere between 10-30% from the overall
runtime.

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

tests: optionally skip bin-wrappers/Johannes Schindelin Tue, 29 Jan 2019 14:19:37 +0000 (06:19 -0800)

tests: optionally skip bin-wrappers/

This speeds up the tests by a bit on Windows, where running Unix shell
scripts (and spawning processes) is not exactly a cheap operation.

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

t0061: workaround issues with --with-dashes and RUNTIME... Johannes Schindelin Tue, 29 Jan 2019 14:19:36 +0000 (06:19 -0800)

t0061: workaround issues with --with-dashes and RUNTIME_PREFIX

When building Git with RUNTIME_PREFIX and starting a test helper from
t/helper/, it fails to detect a system prefix. The reason is that the
RUNTIME_PREFIX feature wants to use the location of the Git executable
to determine where the support files can be found, e.g. system-wide Git
config or the translations. This does not make any sense for the test
helpers, though, as they are distinctly not in a directory structure
resembling the final installation location of Git.

That is the reason why the test helpers rely on environment variables to
indicate the location of the needed support files, e.g.
GIT_TEXTDOMAINDIR. If this information is missing, the output will
contain warnings like this one:

RUNTIME_PREFIX requested, but prefix computation failed. [...]

In t0061, we did not expect that to happen, and it actually does not
happen in the regular case, because bin-wrappers/test-tool specifically
sets GIT_TEXTDOMAINDIR (and as a consequence, nothing in test-tool needs
to know anything about any runtime prefix).

However, with --with-dashes, bin-wrappers/test-tool is no longer called,
but t/helper/test-tool is called directly instead.

So let's just ignore the RUNTIME_PREFIX warning.

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

tests: add t/helper/ to the PATH with --with-dashesJohannes Schindelin Tue, 29 Jan 2019 14:19:35 +0000 (06:19 -0800)

tests: add t/helper/ to the PATH with --with-dashes

We really need to be able to find the test helpers... Really. This
change was forgotten when we moved the test helpers into t/helper/

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

mingw: try to work around issues with the test cleanupJohannes Schindelin Tue, 29 Jan 2019 14:19:35 +0000 (06:19 -0800)

mingw: try to work around issues with the test cleanup

It seems that every once in a while in the Git for Windows SDK, there
are some transient file locking issues preventing the test clean up to
delete the trash directory. Let's be gentle and try again five seconds
later, and only error out if it still fails the second time.

This change helps Windows, and does not hurt any other platform
(normally, it is highly unlikely that said deletion fails, and if it
does, normally it will fail again even 5 seconds later).

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

tests: include detailed trace logs with --write-junit... Johannes Schindelin Tue, 29 Jan 2019 14:19:34 +0000 (06:19 -0800)

tests: include detailed trace logs with --write-junit-xml upon failure

The JUnit XML format lends itself to be presented in a powerful UI,
where you can drill down to the information you are interested in very
quickly.

For test failures, this usually means that you want to see the detailed
trace of the failing tests.

With Travis CI, we passed the `--verbose-log` option to get those
traces. However, that seems excessive, as we do not need/use the logs in
almost all of those cases: only when a test fails do we have a way to
include the trace.

So let's do something different when using Azure DevOps: let's run all
the tests with `--quiet` first, and only if a failure is encountered,
try to trace the commands as they are executed.

Of course, we cannot turn on `--verbose-log` after the fact. So let's
just re-run the test with all the same options, adding `--verbose-log`.
And then munging the output file into the JUnit XML on the fly.

Note: there is an off chance that re-running the test in verbose mode
"fixes" the failures (and this does happen from time to time!). That is
a possibility we should be able to live with. Ideally, we would label
this as "Passed upon rerun", and Azure Pipelines even know about that
outcome, but it is not available when using the JUnit XML format for
now:
https://github.com/Microsoft/azure-pipelines-agent/blob/master/src/Agent.Worker/TestResults/JunitResultReader.cs

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

tests: avoid calling Perl just to determine file sizesJohannes Schindelin Tue, 29 Jan 2019 14:19:33 +0000 (06:19 -0800)

tests: avoid calling Perl just to determine file sizes

It is a bit ridiculous to spin up a full-blown Perl instance (especially
on Windows, where that means spinning up a full POSIX emulation layer,
AKA the MSYS2 runtime) just to tell how large a given file is.

So let's just use the test-tool to do that job instead.

This command will also be used over the next commits, to allow for
cutting out individual test cases' verbose log from the file generated
via --verbose-log.

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

README: add a build badge (status of the Azure Pipeline... Johannes Schindelin Tue, 29 Jan 2019 14:19:32 +0000 (06:19 -0800)

README: add a build badge (status of the Azure Pipelines build)

Just like so many other OSS projects, we now also have a build badge.

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

mingw: be more generous when wrapping up the setitimer... Johannes Schindelin Tue, 29 Jan 2019 14:19:31 +0000 (06:19 -0800)

mingw: be more generous when wrapping up the setitimer() emulation

Every once in a while, the Azure Pipeline fails with some semi-random

error: timer thread did not terminate timely

This error message means that the thread that is used to emulate the
setitimer() function did not terminate within 1,000 milliseconds.

The most likely explanation (and therefore the one we should assume to
be true, according to Occam's Razor) is that the timeout of one second
is simply not enough because we try to run so many tasks in parallel.

So let's give it ten seconds instead of only one. That should be enough.

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

ci: use git-sdk-64-minimal build artifactJohannes Schindelin Tue, 29 Jan 2019 14:19:31 +0000 (06:19 -0800)

ci: use git-sdk-64-minimal build artifact

Instead of a shallow fetch followed by a sparse checkout, we are
better off by using a separate, dedicated Pipeline that bundles
the SDK as a build artifact, and then consuming that build artifact
here.

In fact, since this artifact will be used a lot, we spent substantial
time on figuring out a minimal subset of the Git for Windows SDK, just
enough to build and test Git. The result is a size reduction from around
1GB (compressed) to around 55MB (compressed). This also comes with the
change where we now call `usr\bin\bash.exe` directly, as `git-cmd.exe`
is not included in the minimal SDK.

That reduces the time to initialize Git for Windows' SDK from anywhere
between 2m30s-7m to a little over 1m.

Note: in theory, we could also use the DownloadBuildArtifacts@0 task
here. However, restricted permissions that are in effect when building
from forks would let this fail for PR builds, defeating the whole
purpose of the Azure Pipelines support for git.git.

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

ci: add a Windows job to the Azure Pipelines definitionJohannes Schindelin Tue, 29 Jan 2019 14:19:30 +0000 (06:19 -0800)

ci: add a Windows job to the Azure Pipelines definition

Previously, we did not have robust support for Windows in our CI
definition, simply because Travis cannot accommodate our needs (even
after Travis added experimental Windows support very recently, it takes
longer than Travis' 50 minute timeout to build Git and run the test
suite on Windows). Instead, we used a hack that started a dedicated
Azure Pipeline from Travis and waited for the output, often timing out
(which is quite fragile, as we found out).

With this commit, we finally have first-class support for Windows in our
CI definition (in the Azure Pipelines one, that is).

Due to our reliance on Unix shell scripting in the test suite, combined
with the challenges on executing such scripts on Windows, the Windows
job currently takes a whopping ~1h20m to complete. Which is *far* longer
than the next-longest job takes (linux-gcc, ~35m).

Now, Azure Pipelines's free tier for open source projects (such as Git)
offers up to 10 concurrent jobs for free, meaning that the overall run
time will be dominated by the slowest job(s).

Therefore, it makes sense to start the Windows job first, to minimize
the time the entire build takes from start to end (which is now pretty
safely the run time of the Windows job).

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

Add a build definition for Azure DevOpsJohannes Schindelin Tue, 29 Jan 2019 14:19:29 +0000 (06:19 -0800)

Add a build definition for Azure DevOps

This commit adds an azure-pipelines.yml file which is Azure DevOps'
equivalent to Travis CI's .travis.yml.

The main idea is to replicate the Travis configuration as faithfully as
possible, to make it easy to compare the Azure Pipeline builds to the
Travis ones (spoiler: some parts, especially the macOS jobs, are way
faster in Azure Pileines). Meaning: the number and the order of the jobs
added in this commit faithfully replicates what we have in .travis.yml.

Note: Our .travis.yml configuration has a Windows part that is *not*
replicated in the Azure Pipelines definition. The reason is easy to see:
As Travis cannot support our Windws needs (even with the preliminary
Windows support that was recently added to Travis after waiting for
*years* for that feature, our test suite would simply hit Travis'
timeout every single time).

To make things a bit easier to understand, we refrain from using the
`matrix` feature here because (while it is powerful) it can be a bit
confusing to users who are not familiar with CI setups. Therefore, we
use a separate phase even for similar configurations (such as GCC vs
Clang on Linux, GCC vs Clang on macOS).

Also, we make use of the shiny new feature we just introduced where the
test suite can output JUnit-style .xml files. This information is made
available in a nice UI that allows the viewer to filter by phase and/or
test number, and to see trends such as: number of (failing) tests, time
spent running the test suite, etc. (While this seemingly contradicts the
intention to replicate the Travis configuration as faithfully as
possible, it is just too nice to show off that capability here already.)

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

ci/lib.sh: add support for Azure PipelinesJohannes Schindelin Tue, 29 Jan 2019 14:19:28 +0000 (06:19 -0800)

ci/lib.sh: add support for Azure Pipelines

This patch introduces a conditional arm that defines some environment
variables and a function that displays the URL given the job id (to
identify previous runs for known-good trees).

Because Azure Pipeline's macOS agents already have git-lfs and gettext
installed, we can leave `BREW_INSTALL_PACKAGES` empty (unlike in
Travis' case).

Note: this patch does not introduce an Azure Pipelines definition yet;
That is left for the next patch.

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

tests: optionally write results as JUnit-style .xmlJohannes Schindelin Tue, 29 Jan 2019 14:19:27 +0000 (06:19 -0800)

tests: optionally write results as JUnit-style .xml

This will come in handy when publishing the results of Git's test suite
during an automated Azure DevOps run.

Note: we need to make extra sure that invalid UTF-8 encoding is turned
into valid UTF-8 (using the Replacement Character, \uFFFD) because
t9902's trace contains such invalid byte sequences, and the task in the
Azure Pipeline that uploads the test results would refuse to do anything
if it was asked to parse an .xml file with invalid UTF-8 in it.

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

docs/config: clarify "text property" in core.eolJeff King Tue, 29 Jan 2019 12:41:12 +0000 (07:41 -0500)

docs/config: clarify "text property" in core.eol

The word "property" is vague here. Let's spell out that we mean the path
must be marked with the text attribute.

While we're here, let's make the paragraph a little easier to read by
de-emphasizing the "when core.autocrlf is false" bit. Putting it in the
first sentence obscures the main content, and many readers won't care
about autocrlf (i.e., anyone who is just following the gitattributes(7)
advice, which mainly discusses "text" and "core.eol").

Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc/gitattributes: clarify "autocrlf overrides eol"Jeff King Tue, 29 Jan 2019 12:41:07 +0000 (07:41 -0500)

doc/gitattributes: clarify "autocrlf overrides eol"

We only override core.eol with core.autocrlf when the latter is set to
something besides "false". Let's make this more clear, and point the
reader to the git-config definitions, which discuss this in more detail.

Noticed-by: Sergey Lukashev <lukashev.s@ya.ru>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-lint: only use only sed [-n] [-e command] [-f... Torsten Bögershausen Sun, 20 Jan 2019 07:53:50 +0000 (08:53 +0100)

test-lint: only use only sed [-n] [-e command] [-f command_file]

From `man sed` (on a Mac OS X box):
The -E, -a and -i options are non-standard FreeBSD extensions and may not be available
on other operating systems.

From `man sed` on a Linux box:
REGULAR EXPRESSIONS
POSIX.2 BREs should be supported, but they aren't completely because of
performance problems. The \n sequence in a regular expression matches the newline
character, and similarly for \a, \t, and other sequences.
The -E option switches to using extended regular expressions instead; the -E option
has been supported for years by GNU sed, and is now included in POSIX.

Well, there are still a lot of systems out there, which don't support it.
Beside that, IEEE Std 1003.1TM-2017, see
http://pubs.opengroup.org/onlinepubs/9699919799/
does not mention -E either.

To be on the safe side, don't allow -E (or -r, which is GNU).
Change check-non-portable-shell.pl to only accept the portable options:
sed [-n] [-e command] [-f command_file]

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>