gitweb.git
Merge branch 'mg/gpg-fingerprint-test'Junio C Hamano Sun, 18 Nov 2018 09:23:53 +0000 (18:23 +0900)

Merge branch 'mg/gpg-fingerprint-test'

Add a few tests for a topic already in 'master'.

* mg/gpg-fingerprint-test:
t/t7510-signed-commit.sh: add signing subkey to Eris Discordia key
t/t7510-signed-commit.sh: Add %GP to custom format checks

Merge branch 'nd/pthreads'Junio C Hamano Sun, 18 Nov 2018 09:23:52 +0000 (18:23 +0900)

Merge branch 'nd/pthreads'

The codebase has been cleaned up to reduce "#ifndef NO_PTHREADS".

* nd/pthreads:
Clean up pthread_create() error handling
read-cache.c: initialize copy_len to shut up gcc 8
read-cache.c: reduce branching based on HAVE_THREADS
read-cache.c: remove #ifdef NO_PTHREADS
pack-objects: remove #ifdef NO_PTHREADS
preload-index.c: remove #ifdef NO_PTHREADS
grep: clean up num_threads handling
grep: remove #ifdef NO_PTHREADS
attr.c: remove #ifdef NO_PTHREADS
name-hash.c: remove #ifdef NO_PTHREADS
index-pack: remove #ifdef NO_PTHREADS
send-pack.c: move async's #ifdef NO_PTHREADS back to run-command.c
run-command.h: include thread-utils.h instead of pthread.h
thread-utils: macros to unconditionally compile pthreads API

Merge branch 'ds/reachable-topo-order'Junio C Hamano Sun, 18 Nov 2018 09:23:52 +0000 (18:23 +0900)

Merge branch 'ds/reachable-topo-order'

The revision walker machinery learned to take advantage of the
commit generation numbers stored in the commit-graph file.

* ds/reachable-topo-order:
t6012: make rev-list tests more interesting
revision.c: generation-based topo-order algorithm
commit/revisions: bookkeeping before refactoring
revision.c: begin refactoring --topo-order logic
test-reach: add rev-list tests
test-reach: add run_three_modes method
prio-queue: add 'peek' operation

Tenth batch for 2.20Junio C Hamano Tue, 13 Nov 2018 13:13:52 +0000 (22:13 +0900)

Tenth batch for 2.20

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

Merge branch 'nd/complete-format-patch'Junio C Hamano Tue, 13 Nov 2018 13:37:28 +0000 (22:37 +0900)

Merge branch 'nd/complete-format-patch'

The support for format-patch (and send-email) by the command-line
completion script (in contrib/) has been simplified a bit.

* nd/complete-format-patch:
completion: use __gitcomp_builtin for format-patch

Merge branch 'nd/tree-walk-path-exclusion'Junio C Hamano Tue, 13 Nov 2018 13:37:28 +0000 (22:37 +0900)

Merge branch 'nd/tree-walk-path-exclusion'

Pathspec matching against a tree object were buggy when negative
pathspec elements were involved, which has been fixed.

* nd/tree-walk-path-exclusion:
tree-walk.c: fix overoptimistic inclusion in :(exclude) matching

Merge branch 'sg/travis-install-dependencies'Junio C Hamano Tue, 13 Nov 2018 13:37:27 +0000 (22:37 +0900)

Merge branch 'sg/travis-install-dependencies'

The procedure to install dependencies before testing at Travis CI
is getting revamped for both simplicity and flexibility, taking
advantage of the recent move to the vm-based environment.

* sg/travis-install-dependencies:
travis-ci: install packages in 'ci/install-dependencies.sh'

Merge branch 'bp/add-diff-files-optim'Junio C Hamano Tue, 13 Nov 2018 13:37:27 +0000 (22:37 +0900)

Merge branch 'bp/add-diff-files-optim'

"git add" needs to internally run "diff-files" equivalent, and the
codepath learned the same optimization as "diff-files" has to run
lstat(2) in parallel to find which paths have been updated in the
working tree.

* bp/add-diff-files-optim:
add: speed up cmd_add() by utilizing read_cache_preload()

Merge branch 'jk/xdiff-interface'Junio C Hamano Tue, 13 Nov 2018 13:37:27 +0000 (22:37 +0900)

Merge branch 'jk/xdiff-interface'

The interface into "xdiff" library used to discover the offset and
size of a generated patch hunk by first formatting it into the
textual hunk header "@@ -n,m +k,l @@" and then parsing the numbers
out. A new interface has been introduced to allow callers a more
direct access to them.

* jk/xdiff-interface:
xdiff-interface: drop parse_hunk_header()
range-diff: use a hunk callback
diff: convert --check to use a hunk callback
combine-diff: use an xdiff hunk callback
diff: use hunk callback for word-diff
diff: discard hunk headers for patch-ids earlier
diff: avoid generating unused hunk header lines
xdiff-interface: provide a separate consume callback for hunks
xdiff: provide a separate emit callback for hunks

Merge branch 'jk/misc-unused-fixes'Junio C Hamano Tue, 13 Nov 2018 13:37:26 +0000 (22:37 +0900)

Merge branch 'jk/misc-unused-fixes'

Assorted fixes for bugs found while auditing -Wunused-parameter
warnings.

* jk/misc-unused-fixes:
approxidate: fix NULL dereference in date_time()
pathspec: handle non-terminated strings with :(attr)
approxidate: handle pending number for "specials"
rev-list: handle flags for --indexed-objects

Merge branch 'nd/per-worktree-ref-iteration'Junio C Hamano Tue, 13 Nov 2018 13:37:26 +0000 (22:37 +0900)

Merge branch 'nd/per-worktree-ref-iteration'

The code to traverse objects for reachability, used to decide what
objects are unreferenced and expendable, have been taught to also
consider per-worktree refs of other worktrees as starting points to
prevent data loss.

* nd/per-worktree-ref-iteration:
git-worktree.txt: correct linkgit command name
reflog expire: cover reflog from all worktrees
fsck: check HEAD and reflog from other worktrees
fsck: move fsck_head_link() to get_default_heads() to avoid some globals
revision.c: better error reporting on ref from different worktrees
revision.c: correct a parameter name
refs: new ref types to make per-worktree refs visible to all worktrees
Add a place for (not) sharing stuff between worktrees
refs.c: indent with tabs, not spaces

Merge branch 'bp/refresh-index-using-preload'Junio C Hamano Tue, 13 Nov 2018 13:37:25 +0000 (22:37 +0900)

Merge branch 'bp/refresh-index-using-preload'

The helper function to refresh the cached stat information in the
in-core index has learned to perform the lstat() part of the
operation in parallel on multi-core platforms.

* bp/refresh-index-using-preload:
refresh_index: remove unnecessary calls to preload_index()
speed up refresh_index() by utilizing preload_index()

Merge branch 'ag/rebase-i-in-c'Junio C Hamano Tue, 13 Nov 2018 13:37:25 +0000 (22:37 +0900)

Merge branch 'ag/rebase-i-in-c'

Code clean-up for a topic already in 'master'.

* ag/rebase-i-in-c:
sequencer.c: remove a stray semicolon

Merge branch 'al/send-email-auto-cte-fixup'Junio C Hamano Tue, 13 Nov 2018 13:37:25 +0000 (22:37 +0900)

Merge branch 'al/send-email-auto-cte-fixup'

"git send-email --transfer-encoding=..." in recent versions of Git
sometimes produced an empty "Content-Transfer-Encoding:" header,
which has been corrected.

* al/send-email-auto-cte-fixup:
send-email: avoid empty transfer encoding header

Merge branch 'ds/add-missing-tags'Junio C Hamano Tue, 13 Nov 2018 13:37:24 +0000 (22:37 +0900)

Merge branch 'ds/add-missing-tags'

The history traversal used to implement the tag-following has been
optimized by introducing a new helper.

* ds/add-missing-tags:
remote: make add_missing_tags() linear
test-reach: test get_reachable_subset
commit-reach: implement get_reachable_subset

Merge branch 'sh/mingw-safer-compat-poll'Junio C Hamano Tue, 13 Nov 2018 13:37:24 +0000 (22:37 +0900)

Merge branch 'sh/mingw-safer-compat-poll'

Windows fix.

* sh/mingw-safer-compat-poll:
poll: use GetTickCount64() to avoid wrap-around issues

Merge branch 'js/rebase-p-tests'Junio C Hamano Tue, 13 Nov 2018 13:37:24 +0000 (22:37 +0900)

Merge branch 'js/rebase-p-tests'

In preparation to the day when we can deprecate and remove the
"rebase -p", make sure we can skip and later remove tests for
it.

* js/rebase-p-tests:
tests: optionally skip `git rebase -p` tests
t3418: decouple test cases from a previous `rebase -p` test case
t3404: decouple some test cases from outcomes of previous test cases

Merge branch 'pw/am-rebase-read-author-script'Junio C Hamano Tue, 13 Nov 2018 13:37:23 +0000 (22:37 +0900)

Merge branch 'pw/am-rebase-read-author-script'

Unify code to read the author-script used in "git am" and the
commands that use the sequencer machinery, e.g. "git rebase -i".

* pw/am-rebase-read-author-script:
sequencer: use read_author_script()
add read_author_script() to libgit
am: rename read_author_script()
am: improve author-script error reporting
am: don't die in read_author_script()

Merge branch 'jc/war-on-string-list'Junio C Hamano Tue, 13 Nov 2018 13:37:23 +0000 (22:37 +0900)

Merge branch 'jc/war-on-string-list'

Replace three string-list instances used as look-up tables in "git
fetch" with hashmaps.

* jc/war-on-string-list:
fetch: replace string-list used as a look-up table with a hashmap

Merge branch 'ag/rev-parse-all-exclude-fix'Junio C Hamano Tue, 13 Nov 2018 13:37:23 +0000 (22:37 +0900)

Merge branch 'ag/rev-parse-all-exclude-fix'

"git rev-parse --exclude=* --branches --branches" (i.e. first
saying "add only things that do not match '*' out of all branches"
and then adding all branches, without any exclusion this time")
worked as expected, but "--exclude=* --all --all" did not work the
same way, which has been fixed.

* ag/rev-parse-all-exclude-fix:
rev-parse: clear --exclude list after 'git rev-parse --all'

Merge branch 'jt/tighten-fetch-proto-v2-response'Junio C Hamano Tue, 13 Nov 2018 13:37:22 +0000 (22:37 +0900)

Merge branch 'jt/tighten-fetch-proto-v2-response'

"git fetch" was a bit loose in parsing resposes from the other side
when talking over the protocol v2.

* jt/tighten-fetch-proto-v2-response:
fetch-pack: be more precise in parsing v2 response

Merge branch 'ao/submodule-wo-gitmodules-checked-out'Junio C Hamano Tue, 13 Nov 2018 13:37:22 +0000 (22:37 +0900)

Merge branch 'ao/submodule-wo-gitmodules-checked-out'

The submodule support has been updated to read from the blob at
HEAD:.gitmodules when the .gitmodules file is missing from the
working tree.

* ao/submodule-wo-gitmodules-checked-out:
t/helper: add test-submodule-nested-repo-config
submodule: support reading .gitmodules when it's not in the working tree
submodule: add a helper to check if it is safe to write to .gitmodules
t7506: clean up .gitmodules properly before setting up new scenario
submodule: use the 'submodule--helper config' command
submodule--helper: add a new 'config' subcommand
t7411: be nicer to future tests and really clean things up
t7411: merge tests 5 and 6
submodule: factor out a config_set_in_gitmodules_file_gently function
submodule: add a print_config_from_gitmodules() helper

Merge branch 'nb/worktree-api-doc'Junio C Hamano Tue, 13 Nov 2018 13:37:21 +0000 (22:37 +0900)

Merge branch 'nb/worktree-api-doc'

Code readability fix.

* nb/worktree-api-doc:
worktree: rename is_worktree_locked to worktree_lock_reason
worktree: update documentation for lock_reason and lock_reason_valid

Merge branch 'ma/sequencer-do-reset-saner-loop-termination'Junio C Hamano Tue, 13 Nov 2018 13:37:21 +0000 (22:37 +0900)

Merge branch 'ma/sequencer-do-reset-saner-loop-termination'

Code readability fix.

* ma/sequencer-do-reset-saner-loop-termination:
sequencer: break out of loop explicitly

Merge branch 'js/mingw-utf8-env'Junio C Hamano Tue, 13 Nov 2018 13:37:21 +0000 (22:37 +0900)

Merge branch 'js/mingw-utf8-env'

Windows fix.

* js/mingw-utf8-env:
mingw: reencode environment variables on the fly (UTF-16 <-> UTF-8)
t7800: fix quoting

Merge branch 'js/mingw-perl5lib'Junio C Hamano Tue, 13 Nov 2018 13:37:20 +0000 (22:37 +0900)

Merge branch 'js/mingw-perl5lib'

Windows fix.

* js/mingw-perl5lib:
mingw: unset PERL5LIB by default
config: move Windows-specific config settings into compat/mingw.c
config: allow for platform-specific core.* config settings
config: rename `dummy` parameter to `cb` in git_default_config()

Merge branch 'js/mingw-isatty-and-dup2'Junio C Hamano Tue, 13 Nov 2018 13:37:20 +0000 (22:37 +0900)

Merge branch 'js/mingw-isatty-and-dup2'

Windows fix.

* js/mingw-isatty-and-dup2:
mingw: fix isatty() after dup2()

Merge branch 'ab/pack-tests-cleanup'Junio C Hamano Tue, 13 Nov 2018 13:37:20 +0000 (22:37 +0900)

Merge branch 'ab/pack-tests-cleanup'

A couple of tests used to leave the repository in a state that is
deliberately corrupt, which have been corrected.

* ab/pack-tests-cleanup:
index-pack tests: don't leave test repo dirty at end
pack-objects tests: don't leave test .git corrupt at end
pack-objects test: modernize style

Merge branch 'ds/test-multi-pack-index'Junio C Hamano Tue, 13 Nov 2018 13:37:19 +0000 (22:37 +0900)

Merge branch 'ds/test-multi-pack-index'

Tests for the recently introduced multi-pack index machinery.

* ds/test-multi-pack-index:
packfile: close multi-pack-index in close_all_packs
multi-pack-index: define GIT_TEST_MULTI_PACK_INDEX
midx: close multi-pack-index on repack
midx: fix broken free() in close_midx()

Merge branch 'nd/wildmatch-double-asterisk'Junio C Hamano Tue, 13 Nov 2018 13:37:19 +0000 (22:37 +0900)

Merge branch 'nd/wildmatch-double-asterisk'

A pattern with '**' that does not have a slash on either side used
to be an invalid one, but the code now treats such double-asterisks
the same way as two normal asterisks that happen to be adjacent to
each other.

* nd/wildmatch-double-asterisk:
wildmatch: change behavior of "foo**bar" in WM_PATHNAME mode

Merge branch 'nd/per-worktree-config'Junio C Hamano Tue, 13 Nov 2018 13:37:18 +0000 (22:37 +0900)

Merge branch 'nd/per-worktree-config'

A fourth class of configuration files (in addition to the
traditional "system wide", "per user in the $HOME directory" and
"per repository in the $GIT_DIR/config") has been introduced so
that different worktrees that share the same repository (hence the
same $GIT_DIR/config file) can use different customization.

* nd/per-worktree-config:
worktree: add per-worktree config files
t1300: extract and use test_cmp_config()

Merge branch 'jk/stream-pack-non-delta-clarification'Junio C Hamano Tue, 13 Nov 2018 13:37:18 +0000 (22:37 +0900)

Merge branch 'jk/stream-pack-non-delta-clarification'

Additional comment on a tricky piece of code to help developers.

* jk/stream-pack-non-delta-clarification:
read_istream_pack_non_delta(): document input handling

Merge branch 'jk/proto-v2-ref-prefix-fix'Junio C Hamano Tue, 13 Nov 2018 13:37:17 +0000 (22:37 +0900)

Merge branch 'jk/proto-v2-ref-prefix-fix'

"git ls-remote $there foo" was broken by recent update for the
protocol v2 and stopped showing refs that match 'foo' that are not
refs/{heads,tags}/foo, which has been fixed.

* jk/proto-v2-ref-prefix-fix:
ls-remote: pass heads/tags prefixes to transport
ls-remote: do not send ref prefixes for patterns

Merge branch 'jk/detect-truncated-zlib-input'Junio C Hamano Tue, 13 Nov 2018 13:37:17 +0000 (22:37 +0900)

Merge branch 'jk/detect-truncated-zlib-input'

A regression in Git 2.12 era made "git fsck" fall into an infinite
loop while processing truncated loose objects.

* jk/detect-truncated-zlib-input:
cat-file: handle streaming failures consistently
check_stream_sha1(): handle input underflow
t1450: check large blob in trailing-garbage test

Merge branch 'nd/config-split'Junio C Hamano Tue, 13 Nov 2018 13:37:16 +0000 (22:37 +0900)

Merge branch 'nd/config-split'

Split the overly large Documentation/config.txt file into million
little pieces. This potentially allows each individual piece
included into the manual page of the command it affects more easily.

* nd/config-split: (81 commits)
config.txt: remove config/dummy.txt
config.txt: move worktree.* to a separate file
config.txt: move web.* to a separate file
config.txt: move versionsort.* to a separate file
config.txt: move user.* to a separate file
config.txt: move url.* to a separate file
config.txt: move uploadpack.* to a separate file
config.txt: move uploadarchive.* to a separate file
config.txt: move transfer.* to a separate file
config.txt: move tag.* to a separate file
config.txt: move submodule.* to a separate file
config.txt: move stash.* to a separate file
config.txt: move status.* to a separate file
config.txt: move splitIndex.* to a separate file
config.txt: move showBranch.* to a separate file
config.txt: move sequencer.* to a separate file
config.txt: move sendemail-config.txt to config/
config.txt: move reset.* to a separate file
config.txt: move rerere.* to a separate file
config.txt: move repack.* to a separate file
...

approxidate: fix NULL dereference in date_time()Jeff King Wed, 7 Nov 2018 01:12:53 +0000 (20:12 -0500)

approxidate: fix NULL dereference in date_time()

When we see a time like "noon", we pass "12" to our date_time() helper,
which sets the hour to 12pm. If the current time is before noon, then we
wrap around to yesterday using date_yesterday(). But unlike the normal
calls to date_yesterday() from approxidate_alpha(), we pass a NULL "num"
parameter. Since c27cc94fad (approxidate: handle pending number for
"specials", 2018-11-02), that causes a segfault.

One way to fix this is by checking for NULL. But arguably date_time() is
abusing our helper by passing NULL in the first place (and this is the
only case where one of these "special" parsers is used this way). So
instead, let's have it just do the 1-day subtraction itself. It's still
just a one-liner due to our update_tm() helper.

Note that the test added here is a little funny, as we say "10am noon",
which makes the "10am" seem pointless. But this bug can only be
triggered when it the currently-parsed hour is before the special time.
The latest special time is "tea" at 1700, but t0006 uses a hard-coded
TEST_DATE_NOW of 1900. We could reset TEST_DATE_NOW, but that may lead
to confusion in other tests. Just saying "10am noon" makes this test
self-contained.

Reported-by: Carlo Arenas <carenas@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ninth batch for 2.20Junio C Hamano Tue, 6 Nov 2018 06:51:23 +0000 (15:51 +0900)

Ninth batch for 2.20

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

Merge branch 'sg/test-verbose-log'Junio C Hamano Tue, 6 Nov 2018 06:50:23 +0000 (15:50 +0900)

Merge branch 'sg/test-verbose-log'

Our test scripts can now take the '-V' option as a synonym for the
'--verbose-log' option.

* sg/test-verbose-log:
test-lib: introduce the '-V' short option for '--verbose-log'

Merge branch 'rj/header-cleanup'Junio C Hamano Tue, 6 Nov 2018 06:50:23 +0000 (15:50 +0900)

Merge branch 'rj/header-cleanup'

Code cleanup.

* rj/header-cleanup:
commit-reach.h: add missing declarations (hdr-check)
ewok_rlw.h: add missing 'inline' to function definition
fetch-object.h: add missing declaration (hdr-check)

Merge branch 'ss/travis-ci-force-vm-mode'Junio C Hamano Tue, 6 Nov 2018 06:50:23 +0000 (15:50 +0900)

Merge branch 'ss/travis-ci-force-vm-mode'

The "container" mode of TravisCI is going away. Our .travis.yml
file is getting prepared for the transition.

* ss/travis-ci-force-vm-mode:
travis-ci: no longer use containers

Merge branch 'sg/test-rebase-editor-fix'Junio C Hamano Tue, 6 Nov 2018 06:50:22 +0000 (15:50 +0900)

Merge branch 'sg/test-rebase-editor-fix'

* sg/test-rebase-editor-fix:
t3404-rebase-interactive: test abbreviated commands

Merge branch 'tb/char-may-be-unsigned'Junio C Hamano Tue, 6 Nov 2018 06:50:22 +0000 (15:50 +0900)

Merge branch 'tb/char-may-be-unsigned'

Build portability fix.

* tb/char-may-be-unsigned:
path.c: char is not (always) signed

Merge branch 'js/mingw-ns-filetime'Junio C Hamano Tue, 6 Nov 2018 06:50:21 +0000 (15:50 +0900)

Merge branch 'js/mingw-ns-filetime'

Windows port learned to use nano-second resolution file timestamps.

* js/mingw-ns-filetime:
mingw: implement nanosecond-precision file times
mingw: replace MSVCRT's fstat() with a Win32-based implementation
mingw: factor out code to set stat() data

Merge branch 'md/exclude-promisor-objects-fix'Junio C Hamano Tue, 6 Nov 2018 06:50:21 +0000 (15:50 +0900)

Merge branch 'md/exclude-promisor-objects-fix'

Operations on promisor objects make sense in the context of only a
small subset of the commands that internally use the revisions
machinery, but the "--exclude-promisor-objects" option were taken
and led to nonsense results by commands like "log", to which it
didn't make much sense. This has been corrected.

* md/exclude-promisor-objects-fix:
exclude-promisor-objects: declare when option is allowed
Documentation/git-log.txt: do not show --exclude-promisor-objects

Merge branch 'jw/send-email-no-auth'Junio C Hamano Tue, 6 Nov 2018 06:50:20 +0000 (15:50 +0900)

Merge branch 'jw/send-email-no-auth'

"git send-email" learned to disable SMTP authentication via the
"--smtp-auth=none" option, even when the smtp username is given
(which turns the authentication on by default).

* jw/send-email-no-auth:
send-email: explicitly disable authentication

Merge branch 'nd/submodule-unused-vars'Junio C Hamano Tue, 6 Nov 2018 06:50:20 +0000 (15:50 +0900)

Merge branch 'nd/submodule-unused-vars'

Code clean-up.

* nd/submodule-unused-vars:
submodule.c: remove some of the_repository references

Merge branch 'nd/unpack-trees-with-cache-tree'Junio C Hamano Tue, 6 Nov 2018 06:50:20 +0000 (15:50 +0900)

Merge branch 'nd/unpack-trees-with-cache-tree'

Trivial bugfix.

* nd/unpack-trees-with-cache-tree:
read-cache: use of memory after it is freed

Merge branch 'nd/completion-negation'Junio C Hamano Tue, 6 Nov 2018 06:50:19 +0000 (15:50 +0900)

Merge branch 'nd/completion-negation'

The command line completion machinery (in contrib/) has been
updated to allow the completion script to tweak the list of options
that are reported by the parse-options machinery correctly.

* nd/completion-negation:
completion: fix __gitcomp_builtin no longer consider extra options

Merge branch 'jt/upload-pack-v2-fix-shallow'Junio C Hamano Tue, 6 Nov 2018 06:50:19 +0000 (15:50 +0900)

Merge branch 'jt/upload-pack-v2-fix-shallow'

"git fetch" over protocol v2 into a shallow repository failed to
fetch full history behind a new tip of history that was diverged
before the cut-off point of the history that was previously fetched
shallowly.

* jt/upload-pack-v2-fix-shallow:
upload-pack: clear flags before each v2 request
upload-pack: make want_obj not global
upload-pack: make have_obj not global

Merge branch 'sb/submodule-url-to-absolute'Junio C Hamano Tue, 6 Nov 2018 06:50:19 +0000 (15:50 +0900)

Merge branch 'sb/submodule-url-to-absolute'

Some codepaths failed to form a proper URL when .gitmodules record
the URL to a submodule repository as relative to the repository of
superproject, which has been corrected.

* sb/submodule-url-to-absolute:
submodule helper: convert relative URL to absolute URL if needed

Merge branch 'js/shallow-and-fetch-prune'Junio C Hamano Tue, 6 Nov 2018 06:50:18 +0000 (15:50 +0900)

Merge branch 'js/shallow-and-fetch-prune'

"git repack" in a shallow clone did not correctly update the
shallow points in the repository, leading to a repository that
does not pass fsck.

* js/shallow-and-fetch-prune:
repack -ad: prune the list of shallow commits
shallow: offer to prune only non-existing entries
repack: point out a bug handling stale shallow info

Merge branch 'js/remote-archive-dwimfix'Junio C Hamano Tue, 6 Nov 2018 06:50:18 +0000 (15:50 +0900)

Merge branch 'js/remote-archive-dwimfix'

The logic to determine the archive type "git archive" uses did not
correctly kick in for "git archive --remote", which has been
corrected.

* js/remote-archive-dwimfix:
archive: initialize archivers earlier

completion: use __gitcomp_builtin for format-patchDuy Nguyen Sat, 3 Nov 2018 06:03:18 +0000 (07:03 +0100)

completion: use __gitcomp_builtin for format-patch

This helps format-patch gain completion for a couple new options,
notably --range-diff.

Since send-email completion relies on $__git_format_patch_options
which is now reduced, we need to do something not to regress
send-email completion.

The workaround here is implement --git-completion-helper in
send-email.perl just as a bridge to "format-patch --git-completion-helper".
This is enough to use __gitcomp_builtin on send-email (to take
advantage of caching).

In the end, send-email.perl can probably reuse the same info it passes
to GetOptions() to generate full --git-completion-helper output so
that we don't need to keep track of its options in git-completion.bash
anymore. But that's something for another boring day.

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

refresh_index: remove unnecessary calls to preload_index()Ben Peart Mon, 5 Nov 2018 19:27:51 +0000 (14:27 -0500)

refresh_index: remove unnecessary calls to preload_index()

With refresh_index() learning to utilize preload_index() to speed up its
operation there is no longer any benefit to having the caller preload the
index first. Remove those unneeded calls by calling read_index() instead of
the preload variant.

There is no measurable performance impact of this patch - the 2nd call to
preload_index() bails out quickly but there is no reason to call it twice.

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

Clean up pthread_create() error handlingNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:50 +0000 (09:48 +0100)

Clean up pthread_create() error handling

Normally pthread_create() rarely fails. But with new pthreads wrapper,
pthread_create() will return ENOSYS on a system without thread support.

Threaded code _is_ protected by HAVE_THREADS and pthread_create()
should never run in the first place. But the situation could change in
the future and bugs may sneak in. Make sure that all pthread_create()
reports the error cause.

While at there, mark these strings for translation if they aren't.

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

read-cache.c: initialize copy_len to shut up gcc 8Nguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:49 +0000 (09:48 +0100)

read-cache.c: initialize copy_len to shut up gcc 8

It was reported that when building with NO_PTHREADS=1,
-Wmaybe-uninitialized is triggered. Just initialize the variable from
the beginning to shut the compiler up (because this warning is enabled
in config.dev)

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

read-cache.c: reduce branching based on HAVE_THREADSNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:48 +0000 (09:48 +0100)

read-cache.c: reduce branching based on HAVE_THREADS

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

read-cache.c: remove #ifdef NO_PTHREADSNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:47 +0000 (09:48 +0100)

read-cache.c: remove #ifdef NO_PTHREADS

This is a faithful conversion with no attempt to clean up whatsoever.
Code indentation is left broken. There will be another commit to clean
it up and un-indent if we just indent now. It's just more code noise.

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

pack-objects: remove #ifdef NO_PTHREADSNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:46 +0000 (09:48 +0100)

pack-objects: remove #ifdef NO_PTHREADS

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

preload-index.c: remove #ifdef NO_PTHREADSNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:45 +0000 (09:48 +0100)

preload-index.c: remove #ifdef NO_PTHREADS

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

grep: clean up num_threads handlingNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:44 +0000 (09:48 +0100)

grep: clean up num_threads handling

When NO_PTHREADS is still used in this file, we have two separate code
paths for thread and no thread support. The latter will always have
num_threads remain zero while the former uses num_threads zero as
"default number of threads".

With recent changes blur the line between thread and no-thread
support, this num_threads handling becomes a bit strange so let's
redefine it like this:

- num_threads == 0 means default number of threads and should become
positive after all configuration and option parsing is done if
multithread is supported.

- num_threads <= 1 runs no threads. It does not matter if the platform
supports threading or not.

- num_threads > 1 will run multiple threads and is invalid if
HAVE_THREADS is false. pthread API is only used in this case.

PS. a new warning is also added when num_threads is forced back to one
because a thread-incompatible option is specified.

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

grep: remove #ifdef NO_PTHREADSNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:43 +0000 (09:48 +0100)

grep: remove #ifdef NO_PTHREADS

This is a faithful conversion without attempting to improve
anything. That comes later.

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

attr.c: remove #ifdef NO_PTHREADSNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:42 +0000 (09:48 +0100)

attr.c: remove #ifdef NO_PTHREADS

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

name-hash.c: remove #ifdef NO_PTHREADSNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:41 +0000 (09:48 +0100)

name-hash.c: remove #ifdef NO_PTHREADS

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

index-pack: remove #ifdef NO_PTHREADSNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:40 +0000 (09:48 +0100)

index-pack: remove #ifdef NO_PTHREADS

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

send-pack.c: move async's #ifdef NO_PTHREADS back to... Nguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:39 +0000 (09:48 +0100)

send-pack.c: move async's #ifdef NO_PTHREADS back to run-command.c

On systems that do not support multithread, start_async() is
implemented with fork(). This implementation details unfortunately
leak out at least in send-pack.c [1].

To keep the code base clean of NO_PTHREADS, move the this #ifdef back
to run-command.c. The new wrapper function async_with_fork() at least
helps suggest that this special "close()" is related to async in fork
mode.

[1] 09c9957cf7 (send-pack: avoid deadlock when pack-object dies early
- 2011-04-25)

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

run-command.h: include thread-utils.h instead of pthread.hNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:38 +0000 (09:48 +0100)

run-command.h: include thread-utils.h instead of pthread.h

run-command.c may use threads for its async support. But instead of
including pthread.h directly, let's include thread-utils.h.

run-command.c probably never needs the dummy bits in thread-utils.h
when NO_PTHREADS is defined. But this makes sure we have consistent
HAVE_THREADS behavior everywhere. From now on outside compat/,
thread-utils.h is the only place that includes pthread.h

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

xdiff-interface: drop parse_hunk_header()Jeff King Fri, 2 Nov 2018 06:40:13 +0000 (02:40 -0400)

xdiff-interface: drop parse_hunk_header()

This function was used only for parsing the hunk headers generated by
xdiff. Now that we can use hunk callbacks to get that information
directly, it has outlived its usefulness.

Note to anyone who wants to resurrect it: the "len" parameter was
totally unused, meaning that the function could read past the end of the
"line" array. In practice this never happened, because we only used it
to parse xdiff's generated header lines. But it would be dangerous to
use it for other cases without fixing this defect.

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

range-diff: use a hunk callbackJeff King Fri, 2 Nov 2018 06:39:40 +0000 (02:39 -0400)

range-diff: use a hunk callback

When we count the lines in a diff, we don't actually care about the
contents of each line. By using a hunk callback, we tell xdiff that it
does not need to even bother generating a hunk header line, saving a
small amount of work.

Arguably we could even ignore the hunk headers completely, since we're
just computing a cost function between patches. But doing it this way
maintains the exact same behavior before and after.

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

diff: convert --check to use a hunk callbackJeff King Fri, 2 Nov 2018 06:39:03 +0000 (02:39 -0400)

diff: convert --check to use a hunk callback

The "diff --check" code needs to know the line number on which each hunk
starts in order to generate its output. We get that now by parsing the
hunk header line generated by xdiff, but it's much simpler to just pass
it directly using a hunk callback.

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

combine-diff: use an xdiff hunk callbackJeff King Fri, 2 Nov 2018 06:38:20 +0000 (02:38 -0400)

combine-diff: use an xdiff hunk callback

A combined diff has to line up the hunks for all of the individual
pairwise diffs, and thus needs to know their line numbers and sizes. We
get that now by parsing the hunk header line that xdiff generates.
However, now that xdiff supports a hunk callback, we can just use the
values directly.

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

diff: use hunk callback for word-diffJeff King Fri, 2 Nov 2018 06:37:18 +0000 (02:37 -0400)

diff: use hunk callback for word-diff

Our word-diff does not look at the -/+ lines generated by xdiff at all
(because they are not real lines to show the user, but just the
tokenized words split into lines). Instead we use the line numbers from
the hunk headers to index our own data structure.

As a result, our xdi_diff_outf() callback throws away all lines except
hunk headers. We can instead use a hunk callback, which has two
benefits:

1. We don't have to re-parse the generated hunk header line, but can
use the passed parameters directly.

2. By setting our line callback to NULL, we can tell xdiff-interface
that it does not even need to bother generating the other lines,
saving a small amount of work.

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

diff: discard hunk headers for patch-ids earlierJeff King Fri, 2 Nov 2018 06:36:36 +0000 (02:36 -0400)

diff: discard hunk headers for patch-ids earlier

We do not include hunk header lines when computing patch-ids, since
the line numbers would create false negatives. Rather than detect and
skip them in our line callback, we can simply tell xdiff to avoid
generating them.

This is similar to the previous commit, but split out because it
actually requires modifying the matching line callback.

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

diff: avoid generating unused hunk header linesJeff King Fri, 2 Nov 2018 06:36:06 +0000 (02:36 -0400)

diff: avoid generating unused hunk header lines

Some callers of xdi_diff_outf() do not look at the generated hunk header
lines at all. By plugging in a no-op hunk callback, this tells xdiff not
to even bother formatting them.

This patch introduces a stock no-op callback and uses it with a few
callers whose line callbacks explicitly ignore hunk headers (because
they look only for +/- lines).

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

poll: use GetTickCount64() to avoid wrap-around issuesSteve Hoelzer Wed, 31 Oct 2018 21:11:36 +0000 (14:11 -0700)

poll: use GetTickCount64() to avoid wrap-around issues

The value of timeout starts as an int value, and for this reason it
cannot overflow unsigned long long aka ULONGLONG. The unsigned version
of this initial value is available in orig_timeout. The difference
(orig_timeout - elapsed) cannot wrap around because it is protected by
a conditional (as can be seen in the patch text). Hence, the ULONGLONG
difference can only have values that are smaller than the initial
timeout value and truncation to int cannot overflow.

Signed-off-by: Steve Hoelzer <shoelzer@gmail.com>
[j6t: improved both implementation and log message]
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t7510-signed-commit.sh: add signing subkey to Eris... Michał Górny Sun, 4 Nov 2018 09:47:10 +0000 (10:47 +0100)

t/t7510-signed-commit.sh: add signing subkey to Eris Discordia key

Add a dedicated signing subkey to the key identified as 'Eris
Discordia', and update tests appropriately. GnuPG will now sign commits
using the dedicated signing subkey, changing the value of %GK and %GF,
and effectively creating a test case for %GF!=%GP.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t7510-signed-commit.sh: Add %GP to custom format... Michał Górny Sun, 4 Nov 2018 09:47:09 +0000 (10:47 +0100)

t/t7510-signed-commit.sh: Add %GP to custom format checks

Test %GP in addition to %GF in custom format checks. With current
keyring, both have the same value.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tree-walk.c: fix overoptimistic inclusion in :(exclude... Nguyễn Thái Ngọc Duy Sun, 4 Nov 2018 05:28:51 +0000 (06:28 +0100)

tree-walk.c: fix overoptimistic inclusion in :(exclude) matching

tree_entry_interesting() is used for matching pathspec on a tree. The
interesting thing about this function is that, because the tree
entries are known to be sorted, this function can return more than
just "yes, matched" and "no, not matched". It can also say "yes, this
entry is matched and so is the remaining entries in the tree".

This is where I made a mistake when matching exclude pathspec. For
exclude pathspec, we do matching twice, one with positive patterns and
one with negative ones, then a rule table is applied to determine the
final "include or exclude" result. Note that "matched" does not
necessarily mean include. For negative patterns, "matched" means
exclude.

This particular rule is too eager to include everything. Rule 8 says
that "if all entries are positively matched" and the current entry is
not negatively matched (i.e. not excluded), then all entries are
positively matched and therefore included. But this is not true. If
the _current_ entry is not negatively matched, it does not mean the
next one will not be and we cannot conclude right away that all
remaining entries are positively matched and can be included.

Rules 8 and 18 are now updated to be less eager. We conclude that the
current entry is positively matched and included. But we say nothing
about remaining entries. tree_entry_interesting() will be called again
for those entries where we will determine entries individually.

Reported-by: Christophe Bliard <christophe.bliard@trux.info>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sequencer.c: remove a stray semicolonNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 14:32:29 +0000 (15:32 +0100)

sequencer.c: remove a stray semicolon

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

git-worktree.txt: correct linkgit command nameNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 05:14:18 +0000 (06:14 +0100)

git-worktree.txt: correct linkgit command name

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

Merge branch 'jc/http-curlver-warnings'Junio C Hamano Fri, 2 Nov 2018 15:53:59 +0000 (00:53 +0900)

Merge branch 'jc/http-curlver-warnings'

Warning message fix.

* jc/http-curlver-warnings:
http: give curl version warnings consistently

Merge branch 'js/mingw-http-ssl'Junio C Hamano Fri, 2 Nov 2018 15:53:58 +0000 (00:53 +0900)

Merge branch 'js/mingw-http-ssl'

On platforms with recent cURL library, http.sslBackend configuration
variable can be used to choose a different SSL backend at runtime.
The Windows port uses this mechanism to switch between OpenSSL and
Secure Channel while talking over the HTTPS protocol.

* js/mingw-http-ssl:
http: when using Secure Channel, ignore sslCAInfo by default
http: add support for disabling SSL revocation checks in cURL
http: add support for selecting SSL backends at runtime

Merge branch 'mg/gpg-fingerprint'Junio C Hamano Fri, 2 Nov 2018 15:53:58 +0000 (00:53 +0900)

Merge branch 'mg/gpg-fingerprint'

New "--pretty=format:" placeholders %GF and %GP that show the GPG
key fingerprints have been invented.

* mg/gpg-fingerprint:
gpg-interface.c: obtain primary key fingerprint as well
gpg-interface.c: support getting key fingerprint via %GF format
gpg-interface.c: use flags to determine key/signer info presence

Merge branch 'mg/gpg-parse-tighten'Junio C Hamano Fri, 2 Nov 2018 15:53:57 +0000 (00:53 +0900)

Merge branch 'mg/gpg-parse-tighten'

Detect and reject a signature block that has more than one GPG
signature.

* mg/gpg-parse-tighten:
gpg-interface.c: detect and reject multiple signatures on commits

Merge branch 'en/merge-cleanup-more'Junio C Hamano Fri, 2 Nov 2018 15:53:57 +0000 (00:53 +0900)

Merge branch 'en/merge-cleanup-more'

Further clean-up of merge-recursive machinery.

* en/merge-cleanup-more:
merge-recursive: avoid showing conflicts with merge branch before HEAD
merge-recursive: improve auto-merging messages with path collisions

add: speed up cmd_add() by utilizing read_cache_preload()Ben Peart Fri, 2 Nov 2018 13:30:50 +0000 (09:30 -0400)

add: speed up cmd_add() by utilizing read_cache_preload()

During an "add", a call is made to run_diff_files() which calls
check_removed() for each index-entry. The preload_index() code
distributes some of the costs across multiple threads.

Because the files checked are restricted to pathspec, adding
individual files makes no measurable impact but on a Windows repo
with ~200K files, 'git add .' drops from 6.3 seconds to 3.3 seconds
for a 47% savings.

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

remote: make add_missing_tags() linearDerrick Stolee Fri, 2 Nov 2018 13:14:49 +0000 (06:14 -0700)

remote: make add_missing_tags() linear

The add_missing_tags() method currently has quadratic behavior.
This is due to a linear number (based on number of tags T) of
calls to in_merge_bases_many, which has linear performance (based
on number of commits C in the repository).

Replace this O(T * C) algorithm with an O(T + C) algorithm by
using get_reachable_subset(). We ignore the return list and focus
instead on the reachable_flag assigned to the commits we care
about, because we need to interact with the tag ref and not just
the commit object.

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

test-reach: test get_reachable_subsetDerrick Stolee Fri, 2 Nov 2018 13:14:47 +0000 (06:14 -0700)

test-reach: test get_reachable_subset

The get_reachable_subset() method returns the list of commits in
the 'to' array that are reachable from at least one commit in the
'from' array. Add tests that check this method works in a few
cases:

1. All commits in the 'to' list are reachable. This exercises the
early-termination condition.

2. Some commits in the 'to' list are reachable. This exercises the
loop-termination condition.

3. No commits in the 'to' list are reachable. This exercises the
NULL return condition.

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

commit-reach: implement get_reachable_subsetDerrick Stolee Fri, 2 Nov 2018 13:14:45 +0000 (06:14 -0700)

commit-reach: implement get_reachable_subset

The existing reachability algorithms in commit-reach.c focus on
finding merge-bases or determining if all commits in a set X can
reach at least one commit in a set Y. However, for two commits sets
X and Y, we may also care about which commits in Y are reachable
from at least one commit in X.

Implement get_reachable_subset() which answers this question. Given
two arrays of commits, 'from' and 'to', return a commit_list with
every commit from the 'to' array that is reachable from at least
one commit in the 'from' array.

The algorithm is a simple walk starting at the 'from' commits, using
the PARENT2 flag to indicate "this commit has already been added to
the walk queue". By marking the 'to' commits with the PARENT1 flag,
we can determine when we see a commit from the 'to' array. We remove
the PARENT1 flag as we add that commit to the result list to avoid
duplicates.

The order of the resulting list is a reverse of the order that the
commits are discovered in the walk.

There are a couple shortcuts to avoid walking more than we need:

1. We determine the minimum generation number of commits in the
'to' array. We do not walk commits with generation number
below this minimum.

2. We count how many distinct commits are in the 'to' array, and
decrement this count when we discover a 'to' commit during the
walk. If this number reaches zero, then we can terminate the
walk.

Tests will be added using the 'test-tool reach' helper in a
subsequent commit.

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

send-email: avoid empty transfer encoding headerAaron Lindsay Fri, 2 Nov 2018 09:52:38 +0000 (05:52 -0400)

send-email: avoid empty transfer encoding header

Fix a small bug introduced by "7a36987ff (send-email: add an auto option
for transfer encoding, 2018-07-14)".

I saw the following message when setting --transfer-encoding for a file
with the same encoding:

$ git send-email --transfer-encoding=8bit example.patch
Use of uninitialized value $xfer_encoding in concatenation (.) or string
at /usr/lib/git-core/git-send-email line 1744.

The new tests are by brian m. carlson.

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

pathspec: handle non-terminated strings with :(attr)Jeff King Fri, 2 Nov 2018 05:23:22 +0000 (01:23 -0400)

pathspec: handle non-terminated strings with :(attr)

The pathspec code always takes names to be matched as a
name/namelen pair, but match_attrs() never looks at namelen,
and just treats "name" like a NUL-terminated string, passing
it to git_check_attr().

This usually works anyway. Every caller passes a
NUL-terminated string, and in all but one the passed-in
length is the same as the length of the string (the
exception is dir_path_match(), which may pass a smaller
length to drop a trailing slash). So we won't currently ever
read random memory, and the one case I found actually
happens to work correctly because the attr code can handle
the trailing slash itself.

But it's still worth addressing, as the function interface
implies that the name does not have to be NUL-terminated,
making this an accident waiting to happen.

Since teaching git_check_attr() to take a ptr/len pair would
be a big refactor, we'll just allocate a new string. We can
do this only when necessary, which avoids paying the cost
for most callers.

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

approxidate: handle pending number for "specials"Jeff King Fri, 2 Nov 2018 05:23:09 +0000 (01:23 -0400)

approxidate: handle pending number for "specials"

The approxidate parser has a table of special keywords like
"yesterday", "noon", "pm", etc. Some of these, like "pm", do
the right thing if we've recently seen a number: "3pm" is
what you'd think.

However, most of them do not look at or modify the
pending-number flag at all, which means a number may "jump"
across a significant keyword and be used unexpectedly. For
example, when parsing:

January 5th noon pm

we'd connect the "5" to "pm", and ignore it as a
day-of-month. This is obviously a bit silly, as "noon"
already implies "pm". And other mis-parsed things are
generally as silly ("January 5th noon, years ago" would
connect the 5 to "years", but probably nobody would type
that).

However, the fix is simple: when we see a keyword like
"noon", we should flush the pending number (as we would if
we hit another number, or the end of the string). In a few
of the specials that actually modify the day, we can simply
throw away the number (saying "Jan 5 yesterday" should not
respect the number at all).

Note that we have to either move or forward-declare the
static pending_number() to make it accessible to these
functions; this patch moves it.

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

rev-list: handle flags for --indexed-objectsJeff King Fri, 2 Nov 2018 05:22:59 +0000 (01:22 -0400)

rev-list: handle flags for --indexed-objects

When a traversal sees the --indexed-objects option, it adds
all blobs and valid cache-trees from the index to the
traversal using add_index_objects_to_pending(). But that
function totally ignores its flags parameter!

That means that doing:

git rev-list --objects --indexed-objects

and

git rev-list --objects --not --indexed-objects

produce the same output, because we ignore the UNINTERESTING
flag when walking the index in the second example.

Nobody noticed because this feature was added as a way for
tools like repack to increase their coverage of reachable
objects, meaning it would only be used like the first
example above.

But since it's user facing (and because the documentation
describes it "as if the objects are listed on the command
line"), we should make sure the negative case behaves
sensibly.

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

xdiff-interface: provide a separate consume callback... Jeff King Fri, 2 Nov 2018 06:35:45 +0000 (02:35 -0400)

xdiff-interface: provide a separate consume callback for hunks

The previous commit taught xdiff to optionally provide the hunk header
data to a specialized callback. But most users of xdiff actually use our
more convenient xdi_diff_outf() helper, which ensures that our callbacks
are always fed whole lines.

Let's plumb the special hunk-callback through this interface, too. It
will follow the same rule as xdiff when the hunk callback is NULL (i.e.,
continue to pass a stringified hunk header to the line callback). Since
we add NULL to each caller, there should be no behavior change yet.

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

xdiff: provide a separate emit callback for hunksJeff King Fri, 2 Nov 2018 06:35:01 +0000 (02:35 -0400)

xdiff: provide a separate emit callback for hunks

The xdiff library always emits hunk header lines to our callbacks as
formatted strings like "@@ -a,b +c,d @@\n". This is convenient if we're
going to output a diff, but less so if we actually need to compute using
those numbers, which requires re-parsing the line.

In preparation for moving away from this, let's teach xdiff a new
callback function which gets the broken-out hunk information. To help
callers that don't want to use this new callback, if it's NULL we'll
continue to format the hunk header into a string.

Note that this function renames the "outf" callback to "out_line", as
well. This isn't strictly necessary, but helps in two ways:

1. Now that there are two callbacks, it's nice to use more descriptive
names.

2. Many callers did not zero the emit_callback_data struct, and needed
to be modified to set ecb.out_hunk to NULL. By changing the name of
the existing struct member, that guarantees that any new callers
from in-flight topics will break the build and be examined
manually.

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

t6012: make rev-list tests more interestingDerrick Stolee Thu, 1 Nov 2018 13:46:23 +0000 (13:46 +0000)

t6012: make rev-list tests more interesting

As we are working to rewrite some of the revision-walk machinery,
there could easily be some interesting interactions between the
options that force topological constraints (--topo-order,
--date-order, and --author-date-order) along with specifying a
path.

Add extra tests to t6012-rev-list-simplify.sh to add coverage of
these interactions. To ensure interesting things occur, alter the
repo data shape to have different orders depending on topo-, date-,
or author-date-order.

When testing using GIT_TEST_COMMIT_GRAPH, this assists in covering
the new logic for topo-order walks using generation numbers. The
extra tests can be added indepently.

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

revision.c: generation-based topo-order algorithmDerrick Stolee Thu, 1 Nov 2018 13:46:22 +0000 (13:46 +0000)

revision.c: generation-based topo-order algorithm

The current --topo-order algorithm requires walking all
reachable commits up front, topo-sorting them, all before
outputting the first value. This patch introduces a new
algorithm which uses stored generation numbers to
incrementally walk in topo-order, outputting commits as
we go. This can dramatically reduce the computation time
to write a fixed number of commits, such as when limiting
with "-n <N>" or filling the first page of a pager.

When running a command like 'git rev-list --topo-order HEAD',
Git performed the following steps:

1. Run limit_list(), which parses all reachable commits,
adds them to a linked list, and distributes UNINTERESTING
flags. If all unprocessed commits are UNINTERESTING, then
it may terminate without walking all reachable commits.
This does not occur if we do not specify UNINTERESTING
commits.

2. Run sort_in_topological_order(), which is an implementation
of Kahn's algorithm. It first iterates through the entire
set of important commits and computes the in-degree of each
(plus one, as we use 'zero' as a special value here). Then,
we walk the commits in priority order, adding them to the
priority queue if and only if their in-degree is one. As
we remove commits from this priority queue, we decrement the
in-degree of their parents.

3. While we are peeling commits for output, get_revision_1()
uses pop_commit on the full list of commits computed by
sort_in_topological_order().

In the new algorithm, these three steps correspond to three
different commit walks. We run these walks simultaneously,
and advance each only as far as necessary to satisfy the
requirements of the 'higher order' walk. We know when we can
pause each walk by using generation numbers from the commit-
graph feature.

Recall that the generation number of a commit satisfies:

* If the commit has at least one parent, then the generation
number is one more than the maximum generation number among
its parents.

* If the commit has no parent, then the generation number is one.

There are two special generation numbers:

* GENERATION_NUMBER_INFINITY: this value is 0xffffffff and
indicates that the commit is not stored in the commit-graph and
the generation number was not previously calculated.

* GENERATION_NUMBER_ZERO: this value (0) is a special indicator
to say that the commit-graph was generated by a version of Git
that does not compute generation numbers (such as v2.18.0).

Since we use generation_numbers_enabled() before using the new
algorithm, we do not need to worry about GENERATION_NUMBER_ZERO.
However, the existence of GENERATION_NUMBER_INFINITY implies the
following weaker statement than the usual we expect from
generation numbers:

If A and B are commits with generation numbers gen(A) and
gen(B) and gen(A) < gen(B), then A cannot reach B.

Thus, we will walk in each of our stages until the "maximum
unexpanded generation number" is strictly lower than the
generation number of a commit we are about to use.

The walks are as follows:

1. EXPLORE: using the explore_queue priority queue (ordered by
maximizing the generation number), parse each reachable
commit until all commits in the queue have generation
number strictly lower than needed. During this walk, update
the UNINTERESTING flags as necessary.

2. INDEGREE: using the indegree_queue priority queue (ordered
by maximizing the generation number), add one to the in-
degree of each parent for each commit that is walked. Since
we walk in order of decreasing generation number, we know
that discovering an in-degree value of 0 means the value for
that commit was not initialized, so should be initialized to
two. (Recall that in-degree value "1" is what we use to say a
commit is ready for output.) As we iterate the parents of a
commit during this walk, ensure the EXPLORE walk has walked
beyond their generation numbers.

3. TOPO: using the topo_queue priority queue (ordered based on
the sort_order given, which could be commit-date, author-
date, or typical topo-order which treats the queue as a LIFO
stack), remove a commit from the queue and decrement the
in-degree of each parent. If a parent has an in-degree of
one, then we add it to the topo_queue. Before we decrement
the in-degree, however, ensure the INDEGREE walk has walked
beyond that generation number.

The implementations of these walks are in the following methods:

* explore_walk_step and explore_to_depth
* indegree_walk_step and compute_indegrees_to_depth
* next_topo_commit and expand_topo_walk

These methods have some patterns that may seem strange at first,
but they are probably carry-overs from their equivalents in
limit_list and sort_in_topological_order.

One thing that is missing from this implementation is a proper
way to stop walking when the entire queue is UNINTERESTING, so
this implementation is not enabled by comparisions, such as in
'git rev-list --topo-order A..B'. This can be updated in the
future.

In my local testing, I used the following Git commands on the
Linux repository in three modes: HEAD~1 with no commit-graph,
HEAD~1 with a commit-graph, and HEAD with a commit-graph. This
allows comparing the benefits we get from parsing commits from
the commit-graph and then again the benefits we get by
restricting the set of commits we walk.

Test: git rev-list --topo-order -100 HEAD
HEAD~1, no commit-graph: 6.80 s
HEAD~1, w/ commit-graph: 0.77 s
HEAD, w/ commit-graph: 0.02 s

Test: git rev-list --topo-order -100 HEAD -- tools
HEAD~1, no commit-graph: 9.63 s
HEAD~1, w/ commit-graph: 6.06 s
HEAD, w/ commit-graph: 0.06 s

This speedup is due to a few things. First, the new generation-
number-enabled algorithm walks commits on order of the number of
results output (subject to some branching structure expectations).
Since we limit to 100 results, we are running a query similar to
filling a single page of results. Second, when specifying a path,
we must parse the root tree object for each commit we walk. The
previous benefits from the commit-graph are entirely from reading
the commit-graph instead of parsing commits. Since we need to
parse trees for the same number of commits as before, we slow
down significantly from the non-path-based query.

For the test above, I specifically selected a path that is changed
frequently, including by merge commits. A less-frequently-changed
path (such as 'README') has similar end-to-end time since we need
to walk the same number of commits (before determining we do not
have 100 hits). However, get the benefit that the output is
presented to the user as it is discovered, much the same as a
normal 'git log' command (no '--topo-order'). This is an improved
user experience, even if the command has the same runtime.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit/revisions: bookkeeping before refactoringDerrick Stolee Thu, 1 Nov 2018 13:46:21 +0000 (13:46 +0000)

commit/revisions: bookkeeping before refactoring

There are a few things that need to move around a little before
making a big refactoring in the topo-order logic:

1. We need access to record_author_date() and
compare_commits_by_author_date() in revision.c. These are used
currently by sort_in_topological_order() in commit.c.

2. Moving these methods to commit.h requires adding an author_date_slab
declaration to commit.h. Consumers will need their own implementation.

3. The add_parents_to_list() method in revision.c performs logic
around the UNINTERESTING flag and other special cases depending
on the struct rev_info. Allow this method to ignore a NULL 'list'
parameter, as we will not be populating the list for our walk.
Also rename the method to the slightly more generic name
process_parents() to make clear that this method does more than
add to a list (and no list is required anymore).

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

revision.c: begin refactoring --topo-order logicDerrick Stolee Thu, 1 Nov 2018 13:46:20 +0000 (13:46 +0000)

revision.c: begin refactoring --topo-order logic

When running 'git rev-list --topo-order' and its kin, the topo_order
setting in struct rev_info implies the limited setting. This means
that the following things happen during prepare_revision_walk():

* revs->limited implies we run limit_list() to walk the entire
reachable set. There are some short-cuts here, such as if we
perform a range query like 'git rev-list COMPARE..HEAD' and we
can stop limit_list() when all queued commits are uninteresting.

* revs->topo_order implies we run sort_in_topological_order(). See
the implementation of that method in commit.c. It implies that
the full set of commits to order is in the given commit_list.

These two methods imply that a 'git rev-list --topo-order HEAD'
command must walk the entire reachable set of commits _twice_ before
returning a single result.

If we have a commit-graph file with generation numbers computed, then
there is a better way. This patch introduces some necessary logic
redirection when we are in this situation.

In v2.18.0, the commit-graph file contains zero-valued bytes in the
positions where the generation number is stored in v2.19.0 and later.
Thus, we use generation_numbers_enabled() to check if the commit-graph
is available and has non-zero generation numbers.

When setting revs->limited only because revs->topo_order is true,
only do so if generation numbers are not available. There is no
reason to use the new logic as it will behave similarly when all
generation numbers are INFINITY or ZERO.

In prepare_revision_walk(), if we have revs->topo_order but not
revs->limited, then we trigger the new logic. It breaks the logic
into three pieces, to fit with the existing framework:

1. init_topo_walk() fills a new struct topo_walk_info in the rev_info
struct. We use the presence of this struct as a signal to use the
new methods during our walk. In this patch, this method simply
calls limit_list() and sort_in_topological_order(). In the future,
this method will set up a new data structure to perform that logic
in-line.

2. next_topo_commit() provides get_revision_1() with the next topo-
ordered commit in the list. Currently, this simply pops the commit
from revs->commits.

3. expand_topo_walk() provides get_revision_1() with a way to signal
walking beyond the latest commit. Currently, this calls
add_parents_to_list() exactly like the old logic.

While this commit presents method redirection for performing the
exact same logic as before, it allows the next commit to focus only
on the new logic.

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

test-reach: add rev-list testsDerrick Stolee Thu, 1 Nov 2018 13:46:19 +0000 (13:46 +0000)

test-reach: add rev-list tests

The rev-list command is critical to Git's functionality. Ensure it
works in the three commit-graph environments constructed in
t6600-test-reach.sh. Here are a few important types of rev-list
operations:

* Basic: git rev-list --topo-order HEAD
* Range: git rev-list --topo-order compare..HEAD
* Ancestry: git rev-list --topo-order --ancestry-path compare..HEAD
* Symmetric Difference: git rev-list --topo-order compare...HEAD

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