gitweb.git
pack-objects: move tree_depth into 'struct packing_data'Christian Couder Thu, 16 Aug 2018 06:13:12 +0000 (08:13 +0200)

pack-objects: move tree_depth into 'struct packing_data'

This reduces the size of 'struct object_entry' and therefore
makes packing objects more efficient.

This also renames cmp_tree_depth() into tree_depth_compare(),
as it is more modern to have the name of the compare functions
end with "compare".

Helped-by: Jeff King <peff@peff.net>
Helped-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5320: tests for delta islandsJeff King Thu, 16 Aug 2018 06:13:11 +0000 (08:13 +0200)

t5320: tests for delta islands

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

repack: add delta-islands supportJeff King Thu, 16 Aug 2018 06:13:10 +0000 (08:13 +0200)

repack: add delta-islands support

Implement simple support for --delta-islands option and
repack.useDeltaIslands config variable in git repack.

This allows users to setup delta islands in their config and
get the benefit of less disk usage while cloning and fetching
is still quite fast and not much more CPU intensive.

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

pack-objects: add delta-islands supportJeff King Thu, 16 Aug 2018 06:13:09 +0000 (08:13 +0200)

pack-objects: add delta-islands support

Implement support for delta islands in git pack-objects
and document how delta islands work in
"Documentation/git-pack-objects.txt" and Documentation/config.txt.

This allows users to setup delta islands in their config and
get the benefit of less disk usage while cloning and fetching
is still quite fast and not much more CPU intensive.

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

pack-objects: refactor code into compute_layer_order()Christian Couder Thu, 16 Aug 2018 06:13:08 +0000 (08:13 +0200)

pack-objects: refactor code into compute_layer_order()

In a following commit, as we will use delta islands, we will
have to compute the write order for different layers, not just
for one.

Let's prepare for that by refactoring the code that will be
used to compute the write order for a given layer into a new
compute_layer_order() function.

This will make it easier to see and understand what the
following changes are doing.

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

Add delta-islands.{c,h}Jeff King Thu, 16 Aug 2018 06:13:07 +0000 (08:13 +0200)

Add delta-islands.{c,h}

Hosting providers that allow users to "fork" existing
repos want those forks to share as much disk space as
possible.

Alternates are an existing solution to keep all the
objects from all the forks into a unique central repo,
but this can have some drawbacks. Especially when
packing the central repo, deltas will be created
between objects from different forks.

This can make cloning or fetching a fork much slower
and much more CPU intensive as Git might have to
compute new deltas for many objects to avoid sending
objects from a different fork.

Because the inefficiency primarily arises when an
object is deltified against another object that does
not exist in the same fork, we partition objects into
sets that appear in the same fork, and define
"delta islands". When finding delta base, we do not
allow an object outside the same island to be
considered as its base.

So "delta islands" is a way to store objects from
different forks in the same repo and packfile without
having deltas between objects from different forks.

This patch implements the delta islands mechanism in
"delta-islands.{c,h}", but does not yet make use of it.

A few new fields are added in 'struct object_entry'
in "pack-objects.h" though.

The documentation will follow in a patch that actually
uses delta islands in "builtin/pack-objects.c".

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

builtin/submodule--helper: remove stray new lineStefan Beller Thu, 16 Aug 2018 02:30:55 +0000 (19:30 -0700)

builtin/submodule--helper: remove stray new line

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7410: update to new styleStefan Beller Thu, 16 Aug 2018 02:30:54 +0000 (19:30 -0700)

t7410: update to new style

While at it fix a typo (s/independed/independent) and
make sure git is not in a chain of pipes.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cherry-pick: fix --quit not deleting CHERRY_PICK_HEADNguyễn Thái Ngọc Duy Thu, 16 Aug 2018 16:06:08 +0000 (18:06 +0200)

cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD

--quit is supposed to be --abort but without restoring HEAD. Leaving
CHERRY_PICK_HEAD behind could make other commands mistake that
cherry-pick is still ongoing (e.g. "git commit --amend" will refuse to
work). Clean it too.

For --abort, this job of deleting CHERRY_PICK_HEAD is on "git reset"
so we don't need to do anything else. But let's add extra checks in
--abort tests to confirm.

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

rebase -i: fix SIGSEGV when 'merge <branch>' failsPhillip Wood Wed, 15 Aug 2018 09:39:35 +0000 (10:39 +0100)

rebase -i: fix SIGSEGV when 'merge <branch>' fails

If a merge command in the todo list specifies just a branch to merge
with no -C/-c argument then item->commit is NULL. This means that if
there are merge conflicts error_with_patch() is passed a NULL commit
which causes a segmentation fault when make_patch() tries to look it up.

This commit implements a minimal fix which fixes the crash and allows
the user to successfully commit a conflict resolution with 'git rebase
--continue'. It does not write .git/rebase-merge/patch,
.git/rebase-merge/stopped-sha or update REBASE_HEAD. To sensibly get the
hashes of the merge parents would require refactoring do_merge() to
extract the code that parses the merge parents into a separate function
which error_with_patch() could then use to write the parents into the
stopped-sha file. To create meaningful output make_patch() and 'git
rebase --show-current-patch' would also need to be modified to diff the
merge parent and merge base in this case.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t3430: add conflicting commitPhillip Wood Wed, 15 Aug 2018 09:39:34 +0000 (10:39 +0100)

t3430: add conflicting commit

Move the creation of conflicting-G from a test to the setup so that it
can be used in subsequent tests without creating the kind of implicit
dependencies that plague t3404. While we're at it simplify the
arguments to the test_commit() call the creates the conflicting commit.

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

Sixth batch for 2.19 cycleJunio C Hamano Wed, 15 Aug 2018 22:13:39 +0000 (15:13 -0700)

Sixth batch for 2.19 cycle

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

Merge branch 'jt/connectivity-check-after-unshallow'Junio C Hamano Wed, 15 Aug 2018 22:08:28 +0000 (15:08 -0700)

Merge branch 'jt/connectivity-check-after-unshallow'

"git fetch" sometimes failed to update the remote-tracking refs,
which has been corrected.

* jt/connectivity-check-after-unshallow:
fetch-pack: unify ref in and out param

Merge branch 'sg/travis-retrieve-trash-upon-failure'Junio C Hamano Wed, 15 Aug 2018 22:08:28 +0000 (15:08 -0700)

Merge branch 'sg/travis-retrieve-trash-upon-failure'

The Travis CI scripts were taught to ship back the test data from
failed tests.

* sg/travis-retrieve-trash-upon-failure:
travis-ci: include the trash directories of failed tests in the trace log

Merge branch 'rs/remote-mv-leakfix'Junio C Hamano Wed, 15 Aug 2018 22:08:28 +0000 (15:08 -0700)

Merge branch 'rs/remote-mv-leakfix'

Leakfix.

* rs/remote-mv-leakfix:
remote: clear string_list after use in mv()

Merge branch 'es/mw-to-git-chain-fix'Junio C Hamano Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)

Merge branch 'es/mw-to-git-chain-fix'

Test fix.

* es/mw-to-git-chain-fix:
mw-to-git/t9360: fix broken &&-chain

Merge branch 'ms/http-proto-doc'Junio C Hamano Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)

Merge branch 'ms/http-proto-doc'

Doc fix.

* ms/http-proto-doc:
doc: fix want-capability separator

Merge branch 'nd/pack-objects-threading-doc'Junio C Hamano Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)

Merge branch 'nd/pack-objects-threading-doc'

Doc fix.

* nd/pack-objects-threading-doc:
pack-objects: document about thread synchronization

Merge branch 'jn/subtree-test-fixes'Junio C Hamano Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)

Merge branch 'jn/subtree-test-fixes'

Test fix.

* jn/subtree-test-fixes:
subtree test: simplify preparation of expected results
subtree test: add missing && to &&-chain

Merge branch 'cb/p4-pre-submit-hook'Junio C Hamano Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)

Merge branch 'cb/p4-pre-submit-hook'

"git p4 submit" learns to ask its own pre-submit hook if it should
continue with submitting.

* cb/p4-pre-submit-hook:
git-p4: add the `p4-pre-submit` hook

Merge branch 'js/vscode'Junio C Hamano Wed, 15 Aug 2018 22:08:26 +0000 (15:08 -0700)

Merge branch 'js/vscode'

Add a script (in contrib/) to help users of VSCode work better with
our codebase.

* js/vscode:
vscode: let cSpell work on commit messages, too
vscode: add a dictionary for cSpell
vscode: use 8-space tabs, no trailing ws, etc for Git's source code
vscode: wrap commit messages at column 72 by default
vscode: only overwrite C/C++ settings
mingw: define WIN32 explicitly
cache.h: extract enum declaration from inside a struct declaration
vscode: hard-code a couple defines
contrib: add a script to initialize VS Code configuration

Merge branch 'bb/redecl-enum-fix'Junio C Hamano Wed, 15 Aug 2018 22:08:26 +0000 (15:08 -0700)

Merge branch 'bb/redecl-enum-fix'

Compilation fix.

* bb/redecl-enum-fix:
packfile: ensure that enum object_type is defined

Merge branch 'jk/banned-function'Junio C Hamano Wed, 15 Aug 2018 22:08:26 +0000 (15:08 -0700)

Merge branch 'jk/banned-function'

It is too easy to misuse system API functions such as strcat();
these selected functions are now forbidden in this codebase and
will cause a compilation failure.

* jk/banned-function:
banned.h: mark strncpy() as banned
banned.h: mark sprintf() as banned
banned.h: mark strcat() as banned
automatically ban strcpy()

Merge branch 'en/merge-recursive-skip-fix'Junio C Hamano Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)

Merge branch 'en/merge-recursive-skip-fix'

When the sparse checkout feature is in use, "git cherry-pick" and
other mergy operations lost the skip_worktree bit when a path that
is excluded from checkout requires content level merge, which is
resolved as the same as the HEAD version, without materializing the
merge result in the working tree, which made the path appear as
deleted. This has been corrected by preserving the skip_worktree
bit (and not materializing the file in the working tree).

* en/merge-recursive-skip-fix:
merge-recursive: preserve skip_worktree bit when necessary
t3507: add a testcase showing failure with sparse checkout

Merge branch 'jt/tag-following-with-proto-v2-fix'Junio C Hamano Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)

Merge branch 'jt/tag-following-with-proto-v2-fix'

The wire-protocol v2 relies on the client to send "ref prefixes" to
limit the bandwidth spent on the initial ref advertisement. "git
fetch $remote branch:branch" that asks tags that point into the
history leading to the "branch" automatically followed sent to
narrow prefix and broke the tag following, which has been fixed.

* jt/tag-following-with-proto-v2-fix:
fetch: send "refs/tags/" prefix upon CLI refspecs
t5702: test fetch with multiple refspecs at a time

Merge branch 'jk/size-t'Junio C Hamano Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)

Merge branch 'jk/size-t'

Code clean-up to use size_t/ssize_t when they are the right type.

* jk/size-t:
strbuf_humanise: use unsigned variables
pass st.st_size as hint for strbuf_readlink()
strbuf_readlink: use ssize_t
strbuf: use size_t for length in intermediate variables
reencode_string: use size_t for string lengths
reencode_string: use st_add/st_mult helpers

Merge branch 'sg/coccicheck-updates'Junio C Hamano Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)

Merge branch 'sg/coccicheck-updates'

Update the way we use Coccinelle to find out-of-style code that
need to be modernised.

* sg/coccicheck-updates:
coccinelle: extract dedicated make target to clean Coccinelle's results
coccinelle: put sane filenames into output patches
coccinelle: exclude sha1dc source files from static analysis
coccinelle: use $(addsuffix) in 'coccicheck' make target
coccinelle: mark the 'coccicheck' make target as .PHONY

Merge branch 'sb/histogram-less-memory'Junio C Hamano Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)

Merge branch 'sb/histogram-less-memory'

"git diff --histogram" had a bad memory usage pattern, which has
been rearranged to reduce the peak usage.

* sb/histogram-less-memory:
xdiff/histogram: remove tail recursion
xdiff/xhistogram: move index allocation into find_lcs
xdiff/xhistogram: factor out memory cleanup into free_index()
xdiff/xhistogram: pass arguments directly to fall_back_to_classic_diff

Merge branch 'nd/i18n'Junio C Hamano Wed, 15 Aug 2018 22:08:23 +0000 (15:08 -0700)

Merge branch 'nd/i18n'

Many more strings are prepared for l10n.

* nd/i18n: (23 commits)
transport-helper.c: mark more strings for translation
transport.c: mark more strings for translation
sha1-file.c: mark more strings for translation
sequencer.c: mark more strings for translation
replace-object.c: mark more strings for translation
refspec.c: mark more strings for translation
refs.c: mark more strings for translation
pkt-line.c: mark more strings for translation
object.c: mark more strings for translation
exec-cmd.c: mark more strings for translation
environment.c: mark more strings for translation
dir.c: mark more strings for translation
convert.c: mark more strings for translation
connect.c: mark more strings for translation
config.c: mark more strings for translation
commit-graph.c: mark more strings for translation
builtin/replace.c: mark more strings for translation
builtin/pack-objects.c: mark more strings for translation
builtin/grep.c: mark strings for translation
builtin/config.c: mark more strings for translation
...

Merge branch 'hs/gpgsm'Junio C Hamano Wed, 15 Aug 2018 22:08:23 +0000 (15:08 -0700)

Merge branch 'hs/gpgsm'

Teach "git tag -s" etc. a few configuration variables (gpg.format
that can be set to "openpgp" or "x509", and gpg.<format>.program
that is used to specify what program to use to deal with the format)
to allow x.509 certs with CMS via "gpgsm" to be used instead of
openpgp via "gnupg".

* hs/gpgsm:
gpg-interface t: extend the existing GPG tests with GPGSM
gpg-interface: introduce new signature format "x509" using gpgsm
gpg-interface: introduce new config to select per gpg format program
gpg-interface: do not hardcode the key string len anymore
gpg-interface: introduce an abstraction for multiple gpg formats
t/t7510: check the validation of the new config gpg.format
gpg-interface: add new config to select how to sign a commit

Merge branch 'bw/clone-ref-prefixes'Junio C Hamano Wed, 15 Aug 2018 22:08:23 +0000 (15:08 -0700)

Merge branch 'bw/clone-ref-prefixes'

The wire-protocol v2 relies on the client to send "ref prefixes" to
limit the bandwidth spent on the initial ref advertisement. "git
clone" when learned to speak v2 forgot to do so, which has been
corrected.

* bw/clone-ref-prefixes:
clone: send ref-prefixes when using protocol v2

Merge branch 'jk/core-use-replace-refs'Junio C Hamano Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)

Merge branch 'jk/core-use-replace-refs'

A new configuration variable core.usereplacerefs has been added,
primarily to help server installations that want to ignore the
replace mechanism altogether.

* jk/core-use-replace-refs:
add core.usereplacerefs config option
check_replace_refs: rename to read_replace_refs
check_replace_refs: fix outdated comment

Merge branch 'jh/json-writer'Junio C Hamano Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)

Merge branch 'jh/json-writer'

Preparatory code to later add json output for telemetry data.

* jh/json-writer:
json_writer: new routines to create JSON data

Merge branch 'bb/make-developer-pedantic'Junio C Hamano Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)

Merge branch 'bb/make-developer-pedantic'

"make DEVELOPER=1 DEVOPTS=pedantic" allows developers to compile
with -pedantic option, which may catch more problematic program
constructs and potential bugs.

* bb/make-developer-pedantic:
Makefile: add a DEVOPTS flag to get pedantic compilation

Merge branch 'es/diff-color-moved-fix'Junio C Hamano Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)

Merge branch 'es/diff-color-moved-fix'

One of the "diff --color-moved" mode "dimmed_zebra" that was named
in an unusual way has been deprecated and replaced by
"dimmed-zebra".

* es/diff-color-moved-fix:
diff: --color-moved: rename "dimmed_zebra" to "dimmed-zebra"

Merge branch 'bw/protocol-v2'Junio C Hamano Wed, 15 Aug 2018 22:08:21 +0000 (15:08 -0700)

Merge branch 'bw/protocol-v2'

Doc update.

* bw/protocol-v2:
pack-protocol: mention and point to docs for protocol v2

Merge branch 'sg/travis-cocci-diagnose-failure'Junio C Hamano Wed, 15 Aug 2018 22:08:21 +0000 (15:08 -0700)

Merge branch 'sg/travis-cocci-diagnose-failure'

Update the way we run static analysis tool at TravisCI to make it
easier to use its findings.

* sg/travis-cocci-diagnose-failure:
travis-ci: fail if Coccinelle static analysis found something to transform
travis-ci: run Coccinelle static analysis with two parallel jobs

Merge branch 'js/t7406-recursive-submodule-update-order... Junio C Hamano Wed, 15 Aug 2018 22:08:21 +0000 (15:08 -0700)

Merge branch 'js/t7406-recursive-submodule-update-order-fix'

Test fix.

* js/t7406-recursive-submodule-update-order-fix:
t7406: avoid failures solely due to timing issues

Merge branch 'bw/fetch-pack-i18n'Junio C Hamano Wed, 15 Aug 2018 22:08:20 +0000 (15:08 -0700)

Merge branch 'bw/fetch-pack-i18n'

i18n updates.

* bw/fetch-pack-i18n:
fetch-pack: mark die strings for translation

Merge branch 'sg/fast-import-dump-refs-on-checkpoint... Junio C Hamano Wed, 15 Aug 2018 22:08:20 +0000 (15:08 -0700)

Merge branch 'sg/fast-import-dump-refs-on-checkpoint-fix'

Test update.

* sg/fast-import-dump-refs-on-checkpoint-fix:
t9300: wait for background fast-import process to die after killing it

Merge branch 'sb/trailers-docfix'Junio C Hamano Wed, 15 Aug 2018 22:08:19 +0000 (15:08 -0700)

Merge branch 'sb/trailers-docfix'

Doc update.

* sb/trailers-docfix:
Documentation/git-interpret-trailers: explain possible values

Merge branch 'jk/ui-color-always-to-auto'Junio C Hamano Wed, 15 Aug 2018 22:08:19 +0000 (15:08 -0700)

Merge branch 'jk/ui-color-always-to-auto'

Doc formatting fix.

* jk/ui-color-always-to-auto:
Documentation: fix --color option formatting

Remove forward declaration of an enumElijah Newren Wed, 15 Aug 2018 17:54:10 +0000 (10:54 -0700)

Remove forward declaration of an enum

According to http://c-faq.com/null/machexamp.html, sizeof(char*) !=
sizeof(int*) on some platforms. Since an enum could be a char or int
(or long or...), knowing the size of the enum thus is important to
knowing the size of a pointer to an enum, so we cannot just forward
declare an enum the way we can a struct. (Also, modern C++ compilers
apparently define forward declarations of an enum to either be useless
because the enum was defined, or require an explicit size specifier, or
be a compilation error.)

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

compat/precompose_utf8.h: use more common include guard... Elijah Newren Wed, 15 Aug 2018 17:54:09 +0000 (10:54 -0700)

compat/precompose_utf8.h: use more common include guard style

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

urlmatch.h: fix include guardElijah Newren Wed, 15 Aug 2018 17:54:08 +0000 (10:54 -0700)

urlmatch.h: fix include guard

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Move definition of enum branch_track from cache.h to... Elijah Newren Wed, 15 Aug 2018 17:54:07 +0000 (10:54 -0700)

Move definition of enum branch_track from cache.h to branch.h

'branch_track' feels more closely related to branching, and it is
needed later in branch.h; rather than #include'ing cache.h in branch.h
for this small enum, just move the enum and the external declaration
for git_branch_track to branch.h.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

alloc: make allocate_alloc_state and clear_alloc_state... Elijah Newren Wed, 15 Aug 2018 17:54:06 +0000 (10:54 -0700)

alloc: make allocate_alloc_state and clear_alloc_state more consistent

Since both functions are using the same data type, they should either both
refer to it as void *, or both use the real type (struct alloc_state *).
Opt for the latter.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Add missing includes and forward declarationsElijah Newren Wed, 15 Aug 2018 17:54:05 +0000 (10:54 -0700)

Add missing includes and forward declarations

I looped over the toplevel header files, creating a temporary two-line C
program for each consisting of
#include "git-compat-util.h"
#include $HEADER
This patch is the result of manually fixing errors in compiling those
tiny programs.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase -i: fix numbering in squash messagePhillip Wood Wed, 15 Aug 2018 09:41:25 +0000 (10:41 +0100)

rebase -i: fix numbering in squash message

Commit e12a7ef597 ("rebase -i: Handle "combination of <n> commits" with
GETTEXT_POISON", 2018-04-27) changed the way that individual commit
messages are labelled when squashing commits together. In doing so a
regression was introduced where the numbering of the messages is off by
one. This commit fixes that and adds a test for the numbering.

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

chainlint: fix for core.autocrlf=trueJohannes Schindelin Wed, 15 Aug 2018 14:33:44 +0000 (07:33 -0700)

chainlint: fix for core.autocrlf=true

The `chainlint` target compares actual output to expected output, where
the actual output is generated from files that are specifically checked
out with LF-only line endings. So the expected output needs to be
checked out with LF-only line endings, too.

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

partial-clone: render design doc using asciidocJonathan Nieder Tue, 14 Aug 2018 22:28:46 +0000 (15:28 -0700)

partial-clone: render design doc using asciidoc

Rendered documentation can be easier to read than raw text because
headings and emphasized phrases stand out. Add the missing markup and
Makefile rule required to render this design document using asciidoc.

Tested by running

make -C Documentation technical/partial-clone.html

and viewing the output in a browser.

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

format-patch: allow --range-diff to apply to a lone... Eric Sunshine Sun, 22 Jul 2018 09:57:17 +0000 (05:57 -0400)

format-patch: allow --range-diff to apply to a lone-patch

When submitting a revised version of a patch or series, it can be
helpful (to reviewers) to include a summary of changes since the
previous attempt in the form of a range-diff, typically in the cover
letter. However, it is occasionally useful, despite making for a noisy
read, to insert a range-diff into the commentary section of the lone
patch of a 1-patch series.

Therefore, extend "git format-patch --range-diff=<refspec>" to insert a
range-diff into the commentary section of a lone patch rather than
requiring a cover letter.

Implementation note: Generating a range-diff for insertion into the
commentary section of a patch which itself is currently being generated
requires invoking the diffing machinery recursively. However, the
machinery does not (presently) support this since it uses global state.
Consequently, we need to take care to stash away the state of the
in-progress operation while generating the range-diff, and restore it
after.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

format-patch: add --creation-factor tweak for --range... Eric Sunshine Sun, 22 Jul 2018 09:57:16 +0000 (05:57 -0400)

format-patch: add --creation-factor tweak for --range-diff

When generating a range-diff, matching up commits between two version of
a patch series involves heuristics, thus may give unexpected results.
git-range-diff allows tweaking the heuristic via --creation-factor.
Follow suit by accepting --creation-factor in combination with
--range-diff when generating a range-diff for a cover-letter.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

format-patch: teach --range-diff to respect -v/--reroll... Eric Sunshine Sun, 22 Jul 2018 09:57:15 +0000 (05:57 -0400)

format-patch: teach --range-diff to respect -v/--reroll-count

The --range-diff option announces the embedded range-diff generically
as "Range-diff:", however, we can do better when --reroll-count is
specified by emitting "Range-diff against v{n}:" instead.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

format-patch: extend --range-diff to accept revision... Eric Sunshine Sun, 22 Jul 2018 09:57:14 +0000 (05:57 -0400)

format-patch: extend --range-diff to accept revision range

When submitting a revised a patch series, the --range-diff option embeds
a range-diff in the cover letter showing changes since the previous
version of the patch series. The argument to --range-diff is a simple
revision naming the tip of the previous series, which works fine if the
previous and current versions of the patch series share a common base.

However, it fails if the revision ranges of the old and new versions of
the series are disjoint. To address this shortcoming, extend
--range-diff to also accept an explicit revision range for the previous
series. For example:

git format-patch --cover-letter --range-diff=v1~3..v1 -3 v2

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

format-patch: add --range-diff option to embed diff... Eric Sunshine Sun, 22 Jul 2018 09:57:13 +0000 (05:57 -0400)

format-patch: add --range-diff option to embed diff in cover letter

When submitting a revised version of a patch series, it can be helpful
(to reviewers) to include a summary of changes since the previous
attempt in the form of a range-diff, however, doing so involves manually
copy/pasting the diff into the cover letter.

Add a --range-diff option to automate this process. The argument to
--range-diff specifies the tip of the previous attempt against which to
generate the range-diff. For example:

git format-patch --cover-letter --range-diff=v1 -3 v2

(At this stage, the previous attempt and the patch series being
formatted must share a common base, however, a subsequent enhancement
will make it possible to specify an explicit revision range for the
previous attempt.)

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

range-diff: relieve callers of low-level configuration... Eric Sunshine Sun, 22 Jul 2018 09:57:12 +0000 (05:57 -0400)

range-diff: relieve callers of low-level configuration burden

There are a number of very low-level configuration details which need to
be managed precisely to generate a proper range-diff. In particular,
'diff_options' output format, header suppression, indentation, and
dual-color mode must all be set appropriately to ensure proper behavior.

Handle these details locally in the libified range-diff back-end rather
than forcing each caller to have specialized knowledge of these
implementation details, and to avoid duplication as new callers are
added.

While at it, localize these tweaks to be active only while generating
the range-diff, so they don't clobber the caller-provided
'diff_options', which might be used beyond range-diff generation.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

range-diff: publish default creation factorEric Sunshine Sun, 22 Jul 2018 09:57:11 +0000 (05:57 -0400)

range-diff: publish default creation factor

The range-diff back-end allows its heuristic to be tweaked via the
"creation factor". git-range-diff, the only client of the back-end,
defaults the factor to 60% (hard-coded in builtin/range-diff.c), but
allows the user to override it with the --creation-factor option.

Publish the default range factor to allow new callers of the range-diff
back-end to default to the same value without duplicating the hard-coded
constant, and to avoid worrying about various callers becoming
out-of-sync if the default ever needs to change.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

range-diff: respect diff_option.file rather than assumi... Eric Sunshine Sun, 22 Jul 2018 09:57:10 +0000 (05:57 -0400)

range-diff: respect diff_option.file rather than assuming 'stdout'

The actual diffs output by range-diff respect diff_option.file, which
range-diff passes down the call-chain, thus are destination-agnostic.
However, output_pair_header() is hard-coded to emit to 'stdout'. Fix
this by making output_pair_header() respect diff_option.file, as well.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'es/format-patch-interdiff' into es/format... Junio C Hamano Tue, 14 Aug 2018 21:23:53 +0000 (14:23 -0700)

Merge branch 'es/format-patch-interdiff' into es/format-patch-rangediff

* es/format-patch-interdiff:
format-patch: allow --interdiff to apply to a lone-patch
log-tree: show_log: make commentary block delimiting reusable
interdiff: teach show_interdiff() to indent interdiff
format-patch: teach --interdiff to respect -v/--reroll-count
format-patch: add --interdiff option to embed diff in cover letter
format-patch: allow additional generated content in make_cover_letter()

Merge branch 'js/range-diff' into es/format-patch-rangediffJunio C Hamano Tue, 14 Aug 2018 21:21:46 +0000 (14:21 -0700)

Merge branch 'js/range-diff' into es/format-patch-rangediff

* js/range-diff: (21 commits)
range-diff: use dim/bold cues to improve dual color mode
range-diff: make --dual-color the default mode
range-diff: left-pad patch numbers
completion: support `git range-diff`
range-diff: populate the man page
range-diff --dual-color: skip white-space warnings
range-diff: offer to dual-color the diffs
diff: add an internal option to dual-color diffs of diffs
color: add the meta color GIT_COLOR_REVERSE
range-diff: use color for the commit pairs
range-diff: add tests
range-diff: do not show "function names" in hunk headers
range-diff: adjust the output of the commit pairs
range-diff: suppress the diff headers
range-diff: indent the diffs just like tbdiff
range-diff: right-trim commit messages
range-diff: also show the diff between patches
range-diff: improve the order of the shown commits
range-diff: first rudimentary implementation
Introduce `range-diff` to compare iterations of a topic branch
...

diff.c: rewrite emit_line_0 more understandablyStefan Beller Tue, 14 Aug 2018 01:41:22 +0000 (18:41 -0700)

diff.c: rewrite emit_line_0 more understandably

Rewrite emit_line_0 to have fewer (nested) conditions.

The change in 'emit_line' makes sure that 'first' is never user data,
but always under our control, a sign or special character in the
beginning of the line (or 0, in which case we ignore it).
So from now on, let's pass only a diff marker or 0 as the 'first'
character of the line.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff.c: omit check for line prefix in emit_line_0Stefan Beller Tue, 14 Aug 2018 01:41:21 +0000 (18:41 -0700)

diff.c: omit check for line prefix in emit_line_0

As the previous patch made sure we only call emit_line_0 once per line,
we do not need the work around introduced in f7c3b4e2d8c (diff: add an
internal option to dual-color diffs of diffs, 2018-08-13) that would ensure
we'd emit 'diff_line_prefix(o)' just once per line.

By having just one call of emit_line_0 per line, the checks are dead code.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff: use emit_line_0 once per lineStefan Beller Tue, 14 Aug 2018 01:41:20 +0000 (18:41 -0700)

diff: use emit_line_0 once per line

All lines that use emit_line_0 multiple times per line, are combined
into a single call to emit_line_0, making use of the 'set' argument.

We gain a little efficiency here, as we can omit emission of color and
accompanying reset if 'len == 0'.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff.c: add set_sign to emit_line_0Stefan Beller Tue, 14 Aug 2018 01:41:19 +0000 (18:41 -0700)

diff.c: add set_sign to emit_line_0

Split the meaning of the `set` parameter that is passed to
emit_line_0()` to separate between the color of the "sign" (i.e.
the diff marker '+', '-' or ' ' that is passed in as the `first`
parameter) and the color of the rest of the line.

This changes the meaning of the `set` parameter to no longer refer
to the color of the diff marker, but instead to refer to the color
of the rest of the line. A value of `NULL` indicates that the rest
of the line wants to be colored the same as the diff marker.

Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff.c: reorder arguments for emit_line_ws_markupStefan Beller Tue, 14 Aug 2018 01:41:18 +0000 (18:41 -0700)

diff.c: reorder arguments for emit_line_ws_markup

The order shall be all colors first, then the content, flags at the end.
The colors are in the order of occurrence, i.e. first the color for the
sign and then the color for the rest of the line.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff.c: simplify caller of emit_line_0Stefan Beller Tue, 14 Aug 2018 01:41:17 +0000 (18:41 -0700)

diff.c: simplify caller of emit_line_0

Due to the previous condition we know "set_sign != NULL" at that point.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t3206: add color test for range-diff --dual-colorStefan Beller Tue, 14 Aug 2018 01:41:16 +0000 (18:41 -0700)

t3206: add color test for range-diff --dual-color

The 'expect'ed outcome has been taken by running the 'range-diff | decode'.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test_decode_color: understand FAINT and ITALICStefan Beller Tue, 14 Aug 2018 01:41:15 +0000 (18:41 -0700)

test_decode_color: understand FAINT and ITALIC

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule--helper: introduce new update-module-mode... Stefan Beller Mon, 13 Aug 2018 22:42:35 +0000 (15:42 -0700)

submodule--helper: introduce new update-module-mode helper

This chews off a bit of the shell part of the update command in
git-submodule.sh. When writing the C code, keep in mind that the
submodule--helper part will go away eventually and we want to have
a C function that is able to determine the submodule update strategy,
it as a nicety, make determine_submodule_update_strategy accessible
for arbitrary repositories.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule--helper: replace connect-gitdir-workingtree... Stefan Beller Mon, 13 Aug 2018 22:42:34 +0000 (15:42 -0700)

submodule--helper: replace connect-gitdir-workingtree by ensure-core-worktree

e98317508c0 (submodule: ensure core.worktree is set after update,
2018-06-18) was overly aggressive in calling connect_work_tree_and_git_dir
as that ensures both the 'core.worktree' configuration is set as well as
setting up correct gitlink file pointing at the git directory.

We do not need to check for the gitlink in this part of the cmd_update
in git-submodule.sh, as the initial call to update-clone will have ensured
that. So we can reduce the work to only (check and potentially) set the
'core.worktree' setting.

While at it move the check from shell to C as that proves to be useful in
a follow up patch, as we do not need the 'name' in shell now.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: add more exhaustive up-path testingÆvar Arnfjörð Bjarmason Tue, 14 Aug 2018 18:59:06 +0000 (18:59 +0000)

submodule: add more exhaustive up-path testing

The tests added in 63e95beb08 ("submodule: port resolve_relative_url
from shell to C", 2016-04-15) didn't do a good job of testing various
up-path invocations where the up-path would bring us beyond even the
URL in question without emitting an error.

These results look nonsensical, but it's worth exhaustively testing
them before fixing any of this code, so we can see which of these
cases were changed.

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

git-submodule.sh: accept verbose flag in cmd_update... Stefan Beller Tue, 14 Aug 2018 18:22:02 +0000 (11:22 -0700)

git-submodule.sh: accept verbose flag in cmd_update to be non-quiet

In a56771a668d (builtin/pull: respect verbosity settings in submodules,
2018-01-25), we made sure to pass on both quiet and verbose flag from
builtin/pull.c to the submodule shell script. However git-submodule doesn't
understand a verbose flag, which results in a bug when invoking

git pull --recurse-submodules -v [...]

There are a few different approaches to fix this bug:

1) rewrite 'argv_push_verbosity' or its caller in builtin/pull.c to
cap opt_verbosity at 0. Then 'argv_push_verbosity' would only add
'-q' if any.

2) Have a flag in 'argv_push_verbosity' that specifies if we allow adding
-q or -v (or both).

3) Add -v to git-submodule.sh and make it a no-op

(1) seems like a maintenance burden: What if we add code after
the submodule operations or move submodule operations higher up,
then we have altered the opt_verbosity setting further down the line
in builtin/pull.c.

(2) seems like it could work reasonably well without more regressions

(3) seems easiest to implement as well as actually is a feature with the
last-one-wins rule of passing flags to Git commands.

Reported-by: Jochen Kühner
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

for_each_*_object: move declarations to object-store.hJeff King Tue, 14 Aug 2018 18:21:18 +0000 (14:21 -0400)

for_each_*_object: move declarations to object-store.h

The for_each_loose_object() and for_each_packed_object()
functions are meant to be part of a unified interface: they
use the same set of for_each_object_flags, and it's not
inconceivable that we might one day add a single
for_each_object() wrapper around them.

Let's put them together in a single file, so we can avoid
awkwardness like saying "the flags for this function are
over in cache.h". Moving the loose functions to packfile.h
is silly. Moving the packed functions to cache.h works, but
makes the "cache.h is a kitchen sink" problem worse. The
best place is the recently-created object-store.h, since
these are quite obviously related to object storage.

The for_each_*_in_objdir() functions do not use the same
flags, but they are logically part of the same interface as
for_each_loose_object(), and share callback signatures. So
we'll move those, as well, as they also make sense in
object-store.h.

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

cat-file: use a single strbuf for all outputJeff King Tue, 14 Aug 2018 18:20:22 +0000 (14:20 -0400)

cat-file: use a single strbuf for all output

When we're in batch mode, we end up in batch_object_write()
for each object, which allocates its own strbuf for each
call. Instead, we can provide a single "scratch" buffer that
gets reused for each output. When running:

git cat-file --batch-all-objects --batch-check='%(objectname)'

on git.git, my best-of-five time drops from:

real 0m0.171s
user 0m0.159s
sys 0m0.012s

to:

real 0m0.133s
user 0m0.121s
sys 0m0.012s

Note that we could do this just by putting the "scratch"
pointer into "struct expand_data", but I chose instead to
add an extra parameter to the callstack. That's more
verbose, but it makes it a bit more obvious what is going
on, which in turn makes it easy to see where we need to be
releasing the string in the caller (right after the loop
which uses it in each case).

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

cat-file: split batch "buf" into two variablesJeff King Tue, 14 Aug 2018 18:18:06 +0000 (14:18 -0400)

cat-file: split batch "buf" into two variables

We use the "buf" strbuf for two things: to read incoming
lines, and as a scratch space for test-expanding the
user-provided format. Let's split this into two variables
with descriptive names, which makes their purpose and
lifetime more clear.

It will also help in a future patch when we start using the
"output" buffer for more expansions.

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

cat-file: use oidset check-and-insertJeff King Tue, 14 Aug 2018 18:14:27 +0000 (14:14 -0400)

cat-file: use oidset check-and-insert

We don't need to check if the oidset has our object before
we insert it; that's done as part of the insertion. We can
just rely on the return value from oidset_insert(), which
saves one hash lookup per object.

This measurable speedup is tiny and within the run-to-run
noise, but the result is simpler to read, too.

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

t5310-pack-bitmaps: fix bogus 'pack-objects to file... SZEDER Gábor Tue, 14 Aug 2018 11:47:21 +0000 (13:47 +0200)

t5310-pack-bitmaps: fix bogus 'pack-objects to file can use bitmap' test

The test 'pack-objects to file can use bitmap' added in 645c432d61
(pack-objects: use reachability bitmap index when generating
non-stdout pack, 2016-09-10) is silently buggy and doesn't check what
it's supposed to.

In 't5310-pack-bitmaps.sh', the 'list_packed_objects' helper function
does what its name implies by running:

git show-index <"$1" | cut -d' ' -f2

The test in question invokes this function like this:

list_packed_objects <packa-$packasha1.idx >packa.objects &&
list_packed_objects <packb-$packbsha1.idx >packb.objects &&
test_cmp packa.objects packb.objects

Note how these two callsites don't specify the name of the pack index
file as the function's parameter, but redirect the function's standard
input from it. This triggers an error message from the shell, as it
has no filename to redirect from in the function, but this error is
ignored, because it happens upstream of a pipe. Consequently, both
invocations produce empty 'pack{a,b}.objects' files, and the
subsequent 'test_cmp' happily finds those two empty files identical.

Fix these two 'list_packed_objects' invocations by specifying the pack
index files as parameters. Furthermore, eliminate the pipe in that
function by replacing it with an &&-chained pair of commands using an
intermediate file, so a failure of 'git show-index' or the shell
redirection will fail the test.

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

mingw: enable atomic O_APPENDJohannes Sixt Mon, 13 Aug 2018 19:02:50 +0000 (21:02 +0200)

mingw: enable atomic O_APPEND

The Windows CRT implements O_APPEND "manually": on write() calls, the
file pointer is set to EOF before the data is written. Clearly, this is
not atomic. And in fact, this is the root cause of failures observed in
t5552-skipping-fetch-negotiator.sh and t5503-tagfollow.sh, where
different processes write to the same trace file simultanously; it also
occurred in t5400-send-pack.sh, but there it was worked around in
71406ed4d6 ("t5400: avoid concurrent writes into a trace file",
2017-05-18).

Fortunately, Windows does support atomic O_APPEND semantics using the
file access mode FILE_APPEND_DATA. Provide an implementation that does.

This implementation is minimal in such a way that it only implements
the open modes that are actually used in the Git code base. Emulation
for other modes can be added as necessary later. To become aware of
the necessity early, the unusal error ENOSYS is reported if an
unsupported mode is encountered.

Diagnosed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Helped-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

blame.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:41 +0000 (18:14 +0200)

blame.c: remove implicit dependency on the_index

Side note, since we gain access to the right repository, we can stop
rely on the_repository in this code as well.

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

apply.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:40 +0000 (18:14 +0200)

apply.c: remove implicit dependency on the_index

Use apply_state->repo->index instead of the_index (in most cases,
unless we need to use a temporary index in some functions). Let the
callers (am and apply) tell us what to use, instead of always assuming
to operate on the_index.

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

apply.c: make init_apply_state() take a struct repositoryNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:39 +0000 (18:14 +0200)

apply.c: make init_apply_state() take a struct repository

We're moving away from the_index in this code. "struct index_state *"
could be added to struct apply_state. But let's aim long term and put
struct repository here instead so that we could even avoid more global
states in the future. The index will be available via
apply_state->repo->index.

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

apply.c: pass struct apply_state to more functionsNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:38 +0000 (18:14 +0200)

apply.c: pass struct apply_state to more functions

we're going to remove the dependency on the_index by moving 'struct
index_state *' to somewhere inside struct apply_state. Let's make sure
relevant functions have access to this struct now and reduce the diff
noise when the actual conversion happens.

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

resolve-undo.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:37 +0000 (18:14 +0200)

resolve-undo.c: use the right index instead of the_index

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

archive-*.c: use the right repositoryNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:36 +0000 (18:14 +0200)

archive-*.c: use the right repository

With 'struct archive_args' gaining new repository pointer, we don't
have to assume the_repository in the archive backends anymore.

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

archive.c: avoid access to the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:35 +0000 (18:14 +0200)

archive.c: avoid access to the_index

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

grep: use the right index instead of the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:34 +0000 (18:14 +0200)

grep: use the right index instead of the_index

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

attr: remove index from git_attr_set_direction()Nguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:33 +0000 (18:14 +0200)

attr: remove index from git_attr_set_direction()

Since attr checking API now take the index, there's no need to set an
index in advance with this call. Most call sites are straightforward
because they either pass the_index or NULL (which defaults back to
the_index previously). There's only one suspicious call site in
unpack-trees.c where it sets a different index.

This code in unpack-trees is about to check out entries from the
new/temporary index after merging is done in it. The attributes will
be used by entry.c code to do crlf conversion if needed. entry.c now
respects struct checkout's istate field, and this field is correctly
set in unpack-trees.c, there should be no regression from this change.

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

entry.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:32 +0000 (18:14 +0200)

entry.c: use the right index instead of the_index

checkout-index.c needs update because if checkout->istate is NULL,
ie_match_stat() will crash. Previously this is ie_match_stat(&the_index, ..)
so it will not crash, but it is not technically correct either.

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

submodule.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:31 +0000 (18:14 +0200)

submodule.c: use the right index instead of the_index

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

pathspec.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:30 +0000 (18:14 +0200)

pathspec.c: use the right index instead of the_index

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

unpack-trees: avoid the_index in verify_absent()Nguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:29 +0000 (18:14 +0200)

unpack-trees: avoid the_index in verify_absent()

Both functions that are updated in this commit are called by
verify_absent(), which is part of the "unpack-trees" operation that is
supposed to work on any index file specified by the caller. Thanks to
Brandon [1] [2], an implicit dependency on the_index is exposed. This
commit fixes it.

In both functions, it makes sense to use src_index to check for
exclusion because it's almost unchanged and should give us the same
outcome as if running the exclude check before the unpack.

It's "almost unchanged" because we do invalidate cache-tree and
untracked cache in the source index. But this should not affect how
exclude machinery uses the index: to see if a file is tracked, and to
read a blob from the index instead of worktree if it's marked
skip-worktree (i.e. it's not available in worktree)

[1] a0bba65b10 (dir: convert is_excluded to take an index - 2017-05-05
[2] 2c1eb10454 (dir: convert read_directory to take an index - 2017-05-05)

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

unpack-trees: convert clear_ce_flags* to avoid the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:28 +0000 (18:14 +0200)

unpack-trees: convert clear_ce_flags* to avoid the_index

Prior to fba92be8f7, this code implicitly (and incorrectly) assumes
the_index when running the exclude machinery. fba92be8f7 helps show
this problem clearer because unpack-trees operation is supposed to
work on whatever index the caller specifies... not specifically
the_index.

Update the code to use "istate" argument that's originally from
mark_new_skip_worktree(). From the call sites, both in unpack_trees(),
you can see that this function works on two separate indexes:
o->src_index and o->result. The second mark_new_skip_worktree() so far
has incorecctly applied exclude rules on o->src_index instead of
o->result. It's unclear what is the consequences of this, but it's
definitely wrong.

[1] fba92be8f7 (dir: convert is_excluded_from_list to take an index -
2017-05-05)

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

unpack-trees: don't shadow global var the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:27 +0000 (18:14 +0200)

unpack-trees: don't shadow global var the_index

This function mark_new_skip_worktree() has an argument named the_index
which is also the name of a global variable. While they have different
types (the global the_index is not a pointer) mistakes can easily
happen and it's also confusing for readers. Rename the function
argument to something other than the_index.

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

unpack-trees: add a note about path invalidationNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:26 +0000 (18:14 +0200)

unpack-trees: add a note about path invalidation

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

unpack-trees: remove 'extern' on function declarationNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:25 +0000 (18:14 +0200)

unpack-trees: remove 'extern' on function declaration

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

ls-files: correct index argument to get_convert_attr_as... Nguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:24 +0000 (18:14 +0200)

ls-files: correct index argument to get_convert_attr_ascii()

write_eolinfo() does take an istate as function argument and it should
be used instead of the_index.

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: use the right index instead of the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:23 +0000 (18:14 +0200)

preload-index.c: use the right index instead of the_index

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

dir.c: remove an implicit dependency on the_index in... Nguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:22 +0000 (18:14 +0200)

dir.c: remove an implicit dependency on the_index in pathspec code

Make the match_patchspec API and friends take an index_state instead
of assuming the_index in dir.c. All external call sites are converted
blindly to keep the patch simple and retain current behavior.
Individual call sites may receive further updates to use the right
index instead of the_index.

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

convert.c: remove an implicit dependency on the_indexNguyễn Thái Ngọc Duy Mon, 13 Aug 2018 16:14:21 +0000 (18:14 +0200)

convert.c: remove an implicit dependency on the_index

Make the convert API take an index_state instead of assuming the_index
in convert.c. All external call sites are converted blindly to keep
the patch simple and retain current behavior. Individual call sites
may receive further updates to use the right index instead of
the_index.

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