gitweb.git
commit-graph: clean up leaked memory during writeDerrick Stolee Wed, 3 Oct 2018 17:12:15 +0000 (10:12 -0700)

commit-graph: clean up leaked memory during write

The write_commit_graph() method in commit-graph.c leaks some lits
and strings during execution. In addition, a list of strings is
leaked in write_commit_graph_reachable(). Clean these up so our
memory checking is cleaner.

Further, if we use a list of pack-files to find the commits, we
can leak the packed_git structs after scanning them for commits.

Running the following commands demonstrates the leak before and
the fix after:

* valgrind --leak-check=full ./git commit-graph write --reachable
* valgrind --leak-check=full ./git commit-graph write --stdin-packs

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

subtree: improve decision on merges kept in splitStrain, Roger L Fri, 28 Sep 2018 18:35:40 +0000 (13:35 -0500)

subtree: improve decision on merges kept in split

When multiple identical parents are detected for a commit being considered
for copying, explicitly check whether one is the common merge base between
the commits. If so, the other commit can be used as the identical parent;
if not, a merge must be performed to maintain history.

In some situations two parents of a merge commit may appear to both have
identical subtree content with each other and the current commit. However,
those parents can potentially come from different commit graphs.

Previous behavior would simply select one of the identical parents to
serve as the replacement for this commit, based on the order in which they
were processed.

New behavior compares the merge base between the commits to determine if
a new merge commit is necessary to maintain history despite the identical
content.

Signed-off-by: Strain, Roger L <roger.strain@swri.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

subtree: use commits before rejoins for splitsStrain, Roger L Fri, 28 Sep 2018 18:35:39 +0000 (13:35 -0500)

subtree: use commits before rejoins for splits

Adds recursive evaluation of parent commits which were not part of the
initial commit list when performing a split.

Split expects all relevant commits to be reachable from the target commit
but not reachable from any previous rejoins. However, a branch could be
based on a commit prior to a rejoin, then later merged back into the
current code. In this case, a parent to the commit will not be present in
the initial list of commits, trigging an "incorrect order" warning.

Previous behavior was to consider that commit to have no parent, creating
an original commit containing all subtree content. This commit is not
present in an existing subtree commit graph, changing commit hashes and
making pushing to a subtree repo impossible.

New behavior will recursively check these unexpected parent commits to
track them back to either an earlier rejoin, or a true original commit.
The generated synthetic commits will properly match previously-generated
commits, allowing successful pushing to a prior subtree repo.

Signed-off-by: Strain, Roger L <roger.strain@swri.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

subtree: make --ignore-joins pay attention to addsStrain, Roger L Fri, 28 Sep 2018 18:35:38 +0000 (13:35 -0500)

subtree: make --ignore-joins pay attention to adds

Changes the behavior of --ignore-joins to always consider a subtree add
commit, and ignore only splits and squashes.

The --ignore-joins option is documented to ignore prior --rejoin commits.
However, it additionally ignored subtree add commits generated when a
subtree was initially added to a repo.

Due to the logic which determines whether a commit is a mainline commit
or a subtree commit (namely, the presence or absence of content in the
subtree prefix) this causes commits before the initial add to appear to
be part of the subtree. An --ignore-joins split would therefore consider
those commits part of the subtree history and include them at the
beginning of the synthetic history, causing the resulting hashes to be
incorrect for all later commits.

Signed-off-by: Strain, Roger L <roger.strain@swri.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

subtree: refactor split of a commit into standalone... Strain, Roger L Fri, 28 Sep 2018 18:35:37 +0000 (13:35 -0500)

subtree: refactor split of a commit into standalone method

In a particularly complex repo, subtree split was not creating
compatible splits for pushing back to a separate repo. Addressing
one of the issues requires recursive handling of parent commits
that were not initially considered by the algorithm. This commit
makes no functional changes, but relocates the code to be called
recursively into a new method to simply comparisons of later
commits.

Signed-off-by: Strain, Roger L <roger.strain@swri.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff --color-moved: fix a memory leakPhillip Wood Thu, 4 Oct 2018 10:07:45 +0000 (11:07 +0100)

diff --color-moved: fix a memory leak

Free the hashmap items as well as the hashmap itself. This was found
with asan.

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

diff --color-moved-ws: fix another memory leakPhillip Wood Thu, 4 Oct 2018 10:07:44 +0000 (11:07 +0100)

diff --color-moved-ws: fix another memory leak

This is obvious in retrospect, it was found with asan.

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

diff --color-moved-ws: fix a memory leakPhillip Wood Thu, 4 Oct 2018 10:07:43 +0000 (11:07 +0100)

diff --color-moved-ws: fix a memory leak

Don't duplicate the indentation string if we're not going to use it.
This was found with asan.

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

diff --color-moved-ws: fix out of bounds string accessPhillip Wood Thu, 4 Oct 2018 10:07:42 +0000 (11:07 +0100)

diff --color-moved-ws: fix out of bounds string access

When adjusting the start of the string to take account of the change
in indentation the code was not checking that the string being
adjusted was in fact longer than the indentation change. This was
detected by asan.

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

diff --color-moved-ws: fix double free crashPhillip Wood Thu, 4 Oct 2018 10:07:41 +0000 (11:07 +0100)

diff --color-moved-ws: fix double free crash

Running

git diff --color-moved-ws=allow-indentation-change v2.18.0 v2.19.0

results in a crash due to a double free. This happens when two
potential moved blocks start with consecutive lines. As
pmb_advance_or_null_multi_match() advances it copies the ws_delta from
the last matching line to the next. When the first of our consecutive
lines is advanced its ws_delta well be copied to the second,
overwriting the ws_delta of the block containing the second line. Then
when the second line is advanced it will copy the new ws_delta to the
line below it and so on. Eventually one of these blocks will stop
matching and the ws_delta will be freed. From then on the other block
is in a use-after-free state and when it stops matching it will try to
free the ws_delta that has already been freed by the other block.

The solution is to store the ws_delta in the array of potential moved
blocks rather than with the lines. This means that it no longer needs
to be copied around and one block cannot overwrite the ws_delta of
another. Additionally it saves some malloc/free calls as we don't keep
allocating and freeing ws_deltas.

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

oidset: uninline oidset_init()René Scharfe Thu, 4 Oct 2018 15:14:37 +0000 (17:14 +0200)

oidset: uninline oidset_init()

There is no need to inline oidset_init(), as it's typically only called
twice in the lifetime of an oidset (once at the beginning and at the end
by oidset_clear()) and kh_resize_* is quite big, so move its definition
to oidset.c. Document it while we're at it.

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

oidset: use khashRené Scharfe Thu, 4 Oct 2018 15:13:06 +0000 (17:13 +0200)

oidset: use khash

Reimplement oidset using khash.h in order to reduce its memory footprint
and make it faster.

Performance of a command that mainly checks for duplicate objects using
an oidset, with master and Clang 6.0.1:

$ cmd="./git-cat-file --batch-all-objects --unordered --buffer --batch-check='%(objectname)'"

$ /usr/bin/time $cmd >/dev/null
0.22user 0.03system 0:00.25elapsed 99%CPU (0avgtext+0avgdata 48484maxresident)k
0inputs+0outputs (0major+11204minor)pagefaults 0swaps

$ hyperfine "$cmd"
Benchmark #1: ./git-cat-file --batch-all-objects --unordered --buffer --batch-check='%(objectname)'

Time (mean ± σ): 250.0 ms ± 6.0 ms [User: 225.9 ms, System: 23.6 ms]

Range (min … max): 242.0 ms … 261.1 ms

And with this patch:

$ /usr/bin/time $cmd >/dev/null
0.14user 0.00system 0:00.15elapsed 100%CPU (0avgtext+0avgdata 41396maxresident)k
0inputs+0outputs (0major+8318minor)pagefaults 0swaps

$ hyperfine "$cmd"
Benchmark #1: ./git-cat-file --batch-all-objects --unordered --buffer --batch-check='%(objectname)'

Time (mean ± σ): 151.9 ms ± 4.9 ms [User: 130.5 ms, System: 21.2 ms]

Range (min … max): 148.2 ms … 170.4 ms

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

khash: factor out kh_release_*René Scharfe Thu, 4 Oct 2018 15:10:54 +0000 (17:10 +0200)

khash: factor out kh_release_*

Add a function for releasing the khash-internal allocations, but not the
khash structure itself. It can be used with on-stack khash structs.

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

fetch-pack: load tip_oids eagerly iff neededRené Scharfe Thu, 4 Oct 2018 15:09:39 +0000 (17:09 +0200)

fetch-pack: load tip_oids eagerly iff needed

tip_oids_contain() lazily loads refs into an oidset at its first call.
It abuses the internal (sub)member .map.tablesize of that oidset to
check if it has done that already.

Determine if the oidset needs to be populated upfront and then do that
instead. This duplicates a loop, but simplifies the existing one by
separating concerns between the two.

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

fetch-pack: factor out is_unmatched_ref()René Scharfe Thu, 4 Oct 2018 15:09:06 +0000 (17:09 +0200)

fetch-pack: factor out is_unmatched_ref()

Move the code to determine if a request is unmatched to its own little
helper. This allows us to reuse it in a subsequent patch.

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

fetch-pack: exclude blobs when lazy-fetching treesJonathan Tan Wed, 3 Oct 2018 23:04:53 +0000 (16:04 -0700)

fetch-pack: exclude blobs when lazy-fetching trees

A partial clone with missing trees can be obtained using "git clone
--filter=tree:none <repo>". In such a repository, when a tree needs to
be lazily fetched, any tree or blob it directly or indirectly references
is fetched as well, regardless of whether the original command required
those objects, or if the local repository already had some of them.

This is because the fetch protocol, which the lazy fetch uses, does not
allow clients to request that only the wanted objects be sent, which
would be the ideal solution. This patch implements a partial solution:
specify the "blob:none" filter, somewhat reducing the fetch payload.

This change has no effect when lazily fetching blobs (due to how filters
work). And if lazily fetching a commit (such repositories are difficult
to construct and is not a use case we support very well, but it is
possible), referenced commits and trees are still fetched - only the
blobs are not fetched.

The necessary code change is done in fetch_pack() instead of somewhere
closer to where the "filter" instruction is written to the wire so that
only one part of the code needs to be changed in order for users of all
protocol versions to benefit from this optimization.

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

fetch-pack: avoid object flags if no_dependentsJonathan Tan Wed, 3 Oct 2018 23:04:52 +0000 (16:04 -0700)

fetch-pack: avoid object flags if no_dependents

When fetch_pack() is invoked as part of another Git command (due to a
lazy fetch from a partial clone, for example), it uses object flags that
may already be used by the outer Git command.

The commit that introduced the lazy fetch feature (88e2f9ed8e
("introduce fetch-object: fetch one promisor object", 2017-12-05)) tried
to avoid this overlap, but it did not avoid it totally. It was
successful in avoiding writing COMPLETE, but did not avoid reading
COMPLETE, and did not avoid writing and reading ALTERNATE.

Ensure that no flags are written or read by fetch_pack() in the case
where it is used to perform a lazy fetch. To do this, it is sufficient
to avoid checking completeness of wanted refs (unnecessary in the case
of lazy fetches), and to avoid negotiation-related work (in the current
implementation, already, no negotiation is performed). After that was
done, the lack of overlap was verified by checking all direct and
indirect usages of COMPLETE and ALTERNATE - that they are read or
written only if no_dependents is false.

There are other possible solutions to this issue:

(1) Split fetch-pack.{c,h} into a flag-using part and a non-flag-using
part, and whenever no_dependents is set, only use the
non-flag-using part.
(2) Make fetch_pack() be able to be used with arbitrary repository
objects. fetch_pack() should then create its own repository object
based on the given repository object, with its own object
hashtable, so that the flags do not conflict.

(1) is possible but invasive - some functions would need to be split;
and such invasiveness would potentially be unnecessary if we ever were
to need (2) anyway. (2) would be useful if we were to support, say,
submodules that were partial clones themselves, but I don't know when or
if the Git project plans to support those.

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

mingw: bump the minimum Windows version to VistaJohannes Schindelin Wed, 3 Oct 2018 19:43:44 +0000 (12:43 -0700)

mingw: bump the minimum Windows version to Vista

Quite some time ago, a last plea to the XP users out there who want to
see Windows XP support in Git for Windows, asking them to get engaged
and help, vanished into the depths of the universe.

We tried for a long time to play nice with the last remaining XP users
who somehow manage to build Git from source, but a recent update of
mingw-w64 (7.0.0.5233.e0c09544 -> 7.0.0.5245.edf66197) finally dropped
the last sign of XP support, and Git for Windows' SDK is no longer able
to build core Git's `master` branch as a consequence. (Git for Windows'
`master` branch already bumped the minimum Windows version to Vista a
while ago, so it is fine.)

It is time to require Windows Vista or later to build Git from source.
This, incidentally, lets us use quite a few nice new APIs.

It also means that we no longer need the inet_pton() and inet_ntop()
emulation, which is nice.

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

mingw: set _WIN32_WINNT explicitly for Git for WindowsJohannes Schindelin Wed, 3 Oct 2018 19:43:43 +0000 (12:43 -0700)

mingw: set _WIN32_WINNT explicitly for Git for Windows

Previously, we only ever declared a target Windows version if compiling
with Visual C.

Which meant that we were relying on the MinGW headers to guess which
Windows version we want to target...

Let's be explicit about it, in particular because we actually want to
bump the target Windows version to Vista (which we will do in the next
commit).

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

compat/poll: prepare for targeting Windows VistaJohannes Schindelin Wed, 3 Oct 2018 19:43:41 +0000 (12:43 -0700)

compat/poll: prepare for targeting Windows Vista

Windows Vista (and later) actually have a working poll(), but we still
cannot use it because it only works on sockets.

So let's detect when we are targeting Windows Vista and undefine those
constants, and define `pollfd` so that we can declare our own pollfd
struct.

We also need to make sure that we override those constants *after*
`winsock2.h` has been `#include`d (otherwise we would not really
override those constants).

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

more oideq/hasheq conversionsJeff King Tue, 2 Oct 2018 21:19:21 +0000 (17:19 -0400)

more oideq/hasheq conversions

We added faster equality-comparison functions for hashes in
14438c4497 (introduce hasheq() and oideq(), 2018-08-28). A
few topics were in-flight at the time, and can now be
converted. This covers all spots found by "make coccicheck"
in master (the coccicheck results were tweaked by hand for
style).

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

roll wt_status_state into wt_status and populate in... Stephen P. Smith Sun, 30 Sep 2018 14:12:45 +0000 (07:12 -0700)

roll wt_status_state into wt_status and populate in the collect phase

Status variables were initialized in the collect phase and some
variables were later freed in the print functions.

A "struct wt_status" used to be sufficient for the output phase to
work. It was designed to be filled in the collect phase and consumed
in the output phase, but over time some fields were added and output
phase started filling the fields.

A "struct wt_status_state" that was used in other codepaths turned out
to be useful in the "git status" output. This is not tied to "struct
wt_status", so filling in the collect phase was not consistently
followed.

Move the status state structure variables into the status state
structure and populate them in the collect functions.

Create a new function to free the buffers that were being freed in the
print function. Call this new function in commit.c where both the
collect and print functions were being called.

Based on a patch suggestion by Junio C Hamano. [1]

[1] https://public-inbox.org/git/xmqqr2i5ueg4.fsf@gitster-ct.c.googlers.com/

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

grep: add -r/--[no-]recursiveRené Scharfe Mon, 1 Oct 2018 19:15:57 +0000 (21:15 +0200)

grep: add -r/--[no-]recursive

Recognize -r and --recursive as synonyms for --max-depth=-1 for
compatibility with GNU grep; it's still the default for git grep.

This also adds --no-recursive as synonym for --max-depth=0 for free,
which is welcome for completeness and consistency.

Fix the description for --max-depth, while we're at it -- negative
values other than -1 actually disable recursion, i.e. they are
equivalent to --max-depth=0.

Requested-by: Christoph Berg <myon@debian.org>
Suggested-by: Junio C Hamano <gitster@pobox.com>
Initial-patch-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

help -a: improve and make --verbose defaultNguyễn Thái Ngọc Duy Sat, 29 Sep 2018 06:08:14 +0000 (08:08 +0200)

help -a: improve and make --verbose default

When you type "git help" (or just "git") you are greeted with a list
with commonly used commands and their short description and are
suggested to use "git help -a" or "git help -g" for more details.

"git help -av" would be more friendly and inline with what is shown
with "git help" since it shows list of commands with description as
well, and commands are properly grouped.

"help -av" does not show everything "help -a" shows though. Add
external command section in "help -av" for this. While at there, add a
section for aliases as well (until now aliases have no UI, just "git
config").

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

sequencer: use return value of oidset_insert()René Scharfe Wed, 3 Oct 2018 13:06:49 +0000 (15:06 +0200)

sequencer: use return value of oidset_insert()

oidset_insert() returns 1 if the object ID is already in the set and
doesn't add it again, or 0 if it hadn't been present. Make use of that
fact instead of checking with an extra oidset_contains() call.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config.txt: correct the note about uploadpack.packObjec... Nguyễn Thái Ngọc Duy Sat, 29 Sep 2018 06:50:56 +0000 (08:50 +0200)

config.txt: correct the note about uploadpack.packObjectsHook

Document for uploadpack.packObjectsHook is added in [1] and consists
of two paragraphs, the second one is quite important about where this
variable can stay.

When the paragraph about uploadpack.allowFilter is added in [2], it's
added in between the two paragraphs. This makes the "this is non-repo
level config" note incorrectly apply to allowFilter instead of
packObjectsHook. Move allowFilter paragraph down to fix this.

[1] 20b20a22f8 (upload-pack: provide a hook for running pack-objects -
2016-05-18)

[2] 10ac85c785 (upload-pack: add object filtering for partial clone -
2017-12-08)

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

git doc: direct bug reporters to mailing list archiveJonathan Nieder Fri, 28 Sep 2018 21:20:49 +0000 (14:20 -0700)

git doc: direct bug reporters to mailing list archive

The mailing list archive can help a user encountering a bug to tell
whether a recent regression has already been reported and whether a
longstanding bug has already had some discussion to start their
thinking.

Based-on-patch-by: Martin Ågren <martin.agren@gmail.com>
Improved-by: Junio C Hamano <gitster@pobox.com>
Improved-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

CodingGuidelines: document the API in *.h filesJunio C Hamano Fri, 28 Sep 2018 16:50:14 +0000 (09:50 -0700)

CodingGuidelines: document the API in *.h files

It makes it harder to let the API description and the reality drift
apart if the doc is kept close to the implementation or the header
of the API. We have been slowly migrating API docs out of the
Documentation/technical/api-* to *.h files, and the development
community generally considers that how inline docs in strbuf.h is
done the best current practice.

We recommend documenting in the header over documenting near the
implementation to encourage people to write the docs that are
readable without peeking at the implemention.

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

git-rebase.sh: fix typos in error messagesRalf Thielow Fri, 28 Sep 2018 19:28:49 +0000 (21:28 +0200)

git-rebase.sh: fix typos in error messages

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7005-editor: quote filename to fix whitespace-issueAlexander Pyhalov Wed, 26 Sep 2018 16:14:11 +0000 (18:14 +0200)

t7005-editor: quote filename to fix whitespace-issue

Commit 4362da078e (t7005-editor: get rid of the SPACES_IN_FILENAMES
prereq, 2018-05-14) removed code for detecting whether spaces in
filenames work. Since we rely on spaces throughout the test suite
("trash directory.t1234-foo"), testing whether we can use the filename
"e space.sh" was redundant and unnecessary.

In simplifying the code, though, this introduced a regression around how
spaces are handled, not in the /name/ of the editor script, but /in/ the
script itself. The script just does `echo space >$1`, where $1 is for
example "/foo/t/trash directory.t7005-editor/.git/COMMIT_EDITMSG".

With most shells, or with Bash in posix mode, $1 will not be subjected
to field splitting. But if we invoke Bash directly, which will happen if
we build Git with SHELL_PATH=/bin/bash, it will detect and complain
about an "ambiguous redirect". More details can be found in [1], thanks
to SZEDER Gábor.

Make sure that the editor script quotes "$1" to remove the ambiguity.

[1] https://public-inbox.org/git/20180926121107.GH27036@localhost/

Signed-off-by: Alexander Pyhalov <apyhalov@gmail.com>
Commit-message-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rev-parse: --show-superproject-working-tree should... Sam McKelvie Thu, 27 Sep 2018 18:10:54 +0000 (11:10 -0700)

rev-parse: --show-superproject-working-tree should work during a merge

Invoking 'git rev-parse --show-superproject-working-tree' exits with

"fatal: BUG: returned path string doesn't match cwd?"

when the superproject has an unmerged entry for the current submodule,
instead of displaying the superproject's working tree.

The problem is due to the fact that when a merge of the submodule reference
is in progress, "git ls-files --stage —full-name <submodule-relative-path>”
returns three seperate entries for the submodule (one for each stage) rather
than a single entry; e.g.,

$ git ls-files --stage --full-name submodule-child-test
160000 dbbd2766fa330fa741ea59bb38689fcc2d283ac5 1 submodule-child-test
160000 f174d1dbfe863a59692c3bdae730a36f2a788c51 2 submodule-child-test
160000 e6178f3a58b958543952e12824aa2106d560f21d 3 submodule-child-test

The code in get_superproject_working_tree() expected exactly one entry to
be returned; this patch makes it use the first entry if multiple entries
are returned.

Test t1500-rev-parse is extended to cover this case.

Signed-off-by: Sam McKelvie <sammck@gmail.com>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t1400: drop debug `echo` to actually execute `test`Martin Ågren Fri, 28 Sep 2018 15:43:59 +0000 (17:43 +0200)

t1400: drop debug `echo` to actually execute `test`

Instead of running `test "foo" = "$(bar)"`, we prefix the whole thing
with `echo`. Comparing to nearby tests makes it clear that this is just
debug leftover. This line has actually been modified four times since it
was introduced in e52290428b (General ref log reading improvements.,
2006-05-19) and the `echo` has always survived. Let's finally drop it.

This script could need some more cleanups. This is just an immediate fix
so that we actually test what we intend to.

All other hits for `git grep "\<echo test " -- t/` seem fine. They want
to create some input or expected output data.

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

t0000: do not get self-test disrupted by environment... Junio C Hamano Thu, 20 Sep 2018 18:43:43 +0000 (11:43 -0700)

t0000: do not get self-test disrupted by environment warnings

The test framework test-lib.sh itself would want to give warnings
and hints, e.g. when it sees a deprecated environment variable is in
use that we want to encourage users to migrate to another variable.

The self-test of test framework done in t0000 however do not expect
to see these warnings and hints, so depending on the settings of
environment variables, a running test may or may not produce these
messages to the standard error output, breaking the expectations of
self-test test framework does on itself. Here is what we see:

$ TEST_GIT_INDEX_VERSION=4 sh t0000-basic.sh -i -v
...
'err' is not empty, it contains:
warning: TEST_GIT_INDEX_VERSION is now GIT_TEST_INDEX_VERSION
hint: set GIT_TEST_INDEX_VERSION too during the transition period
not ok 5 - pretend we have a fully passing test suite

The following quick attempt to work it around does not work, because
some tests in t0000 do want to see expected errors from the test
framework itself.

t/t0000-basic.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 850f651e4e..88c6ed4696 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -88,7 +88,7 @@ _run_sub_test_lib_test_common () {
'

# Point to the t/test-lib.sh, which isn't in ../ as usual
- . "\$TEST_DIRECTORY"/test-lib.sh
+ . "\$TEST_DIRECTORY"/test-lib.sh >/dev/null 2>&1
EOF
cat >>"$name.sh" &&
chmod +x "$name.sh" &&

There are a few possible ways to work this around:

* We could strip the warning: and hint: unconditionally from the
error output before the error messages are checked in the
self-test (helper functions check_sub_test_lib_test_err and
check_sub_test_lib_test); the problem with this approach is that
it will make it impossible to write self-tests to ensure that
right warnings and hints are given.

* We could force a sane environment settings before the test helper
_run_sub_test_lib_test_common dot-sources test-lib.sh; the
problem with this approach is that _run_sub_test_lib_test_common
now needs to be aware of what pairs of environment variables are
checked in test-lib.sh using check_var_migration helper.

The final patch I came up with is probably the solution that is
least bad. Set a variable to tell test-lib.sh that we are running
a self-test, so that various pieces in test-lib.sh can react to keep
the output stable.

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

preload-index: update GIT_FORCE_PRELOAD_TEST supportBen Peart Tue, 18 Sep 2018 23:29:37 +0000 (23:29 +0000)

preload-index: update GIT_FORCE_PRELOAD_TEST support

Rename GIT_FORCE_PRELOAD_TEST to GIT_TEST_PRELOAD_INDEX for consistency with
the other GIT_TEST_ special setups and properly document its use.

Add logic in t/test-lib.sh to give a warning when the old variable is set to
let people know they need to update their environment to use the new
variable.

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

read-cache: update TEST_GIT_INDEX_VERSION supportBen Peart Tue, 18 Sep 2018 23:29:36 +0000 (23:29 +0000)

read-cache: update TEST_GIT_INDEX_VERSION support

Rename TEST_GIT_INDEX_VERSION to GIT_TEST_INDEX_VERSION for consistency with
the other GIT_TEST_ special setups and properly document its use.

Add logic in t/test-lib.sh to give a warning when the old variable is set to
let people know they need to update their environment to use the new
variable.

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

fsmonitor: update GIT_TEST_FSMONITOR supportBen Peart Tue, 18 Sep 2018 23:29:35 +0000 (23:29 +0000)

fsmonitor: update GIT_TEST_FSMONITOR support

Rename GIT_FSMONITOR_TEST to GIT_TEST_FSMONITOR for consistency with the
other GIT_TEST_ special setups and properly document its use.

Add logic in t/test-lib.sh to give a warning when the old variable is set to
let people know they need to update their environment to use the new
variable.

Remove the outdated instructions on how to run the test suite utilizing
fsmonitor now that it is properly documented in t/README.

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

t1700-split-index: document why FSMONITOR is disabled... SZEDER Gábor Fri, 28 Sep 2018 16:24:54 +0000 (18:24 +0200)

t1700-split-index: document why FSMONITOR is disabled in this test script

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

Doc: refer to the "commit-graph file" with dashMartin Ågren Thu, 27 Sep 2018 19:12:22 +0000 (21:12 +0200)

Doc: refer to the "commit-graph file" with dash

The file processed by `git commit-graph` is referred to as the
"commit-graph file", also with a dash. We have a few references to the
"commit graph file", though, without the dash. These occur in
git-commit-graph.txt as well as in Doc/technical/commit-graph.txt. Fix
them.

Do not change the references to the "commit graph" (without "... file")
as a data structure.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-commit-graph.txt: refer to "*commit*-graph file"Martin Ågren Thu, 27 Sep 2018 19:12:21 +0000 (21:12 +0200)

git-commit-graph.txt: refer to "*commit*-graph file"

This document sometimes refers to the "commit-graph file" as just "the
graph file". This saves a couple of words here and there at the risk of
confusion. In particular, the documentation for `git commit-graph read`
appears to suggest that there are indeed different types of graph files.

Let's just write out the full name everywhere.

The full name, by the way, is not the dash-less "commit graph file".
Use the dashed form. (The next commit will fix the remaining few
instances of the "commit graph file" in this document.)

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-commit-graph.txt: typeset more in monospaceMartin Ågren Thu, 27 Sep 2018 19:12:20 +0000 (21:12 +0200)

git-commit-graph.txt: typeset more in monospace

While we're here, fix an instance of "folder" to be "directory".

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-commit-graph.txt: fix bullet listsMartin Ågren Thu, 27 Sep 2018 19:12:19 +0000 (21:12 +0200)

git-commit-graph.txt: fix bullet lists

We have a couple of bullet items which span multiple lines, and where we
have prefixed each line with a `*`. (This might be the result of a text
editor trying to help.) This results in each line being typeset as a
separate bullet item. Drop the extra `*`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: clarify gitcredentials path component matchingDavid Zych Wed, 26 Sep 2018 22:23:11 +0000 (22:23 +0000)

doc: clarify gitcredentials path component matching

The gitcredentials documentation implied that the config file's
"pattern" URL might include a path component, but did not explain that
it must match exactly (potentially leaving readers with the false hope
that it would support a more flexible prefix match).

Signed-off-by: David Zych <dmrz@illinois.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: fix erroneous BUG, 'multiple renames on the... Elijah Newren Thu, 27 Sep 2018 17:36:57 +0000 (10:36 -0700)

commit: fix erroneous BUG, 'multiple renames on the same target? how?'

builtin/commit.c:prepare_to_commit() can call run_status() twice if
using the editor, including status, and the user attempts to record a
non-merge empty commit without explicit --allow-empty. If there is also
a rename involved as well (due to using 'git add -N'), then a BUG in
wt-status.c is triggered:

BUG: wt-status.c:476: multiple renames on the same target? how?

The reason we hit this bug is that both run_status() calls use the same
struct wt_status * (named s), and s->change is not freed between runs.
Changes are inserted into s with string_list_insert, which usually means
that the second run just recomputes all the same results and overwrites
what was computed the first time. However, ever since commit
176ea7479309 ("wt-status.c: handle worktree renames", 2017-12-27),
wt-status started checking for renames and copies but also added a
preventative check that d->rename_status wasn't already set and output a
BUG message if it was. The problem isn't that there are multiple rename
targets to a single path as the error implies, the problem is that 's'
is not freed/cleared between the two run_status() calls.

Ever since commit dc6b1d92ca9c ("wt-status: use settings from
git_diff_ui_config", 2018-05-04), which stopped hardcoding
DIFF_DETECT_RENAME and allowed users to ask for copy detection, this bug
has also been triggerable with a copy instead of a rename.

Fix the bug by clearing s->change. A better change might be to clean up
all of s between the two run_status() calls. A good first step towards
such a goal might be writing a function to free the necessary fields in
the wt_status * struct; a cursory glance at the code suggests all of its
allocated data is probably leaked. However, doing all that cleanup is a
bigger task for someone else interested to tackle; just fix the bug for
now.

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

Sync with 2.19.1Junio C Hamano Thu, 27 Sep 2018 18:53:39 +0000 (11:53 -0700)

Sync with 2.19.1

* maint:
Git 2.19.1
Git 2.18.1
Git 2.17.2
fsck: detect submodule paths starting with dash
fsck: detect submodule urls starting with dash
Git 2.16.5
Git 2.15.3
Git 2.14.5
submodule-config: ban submodule paths that start with a dash
submodule-config: ban submodule urls that start with dash
submodule--helper: use "--" to signal end of clone options

Git 2.19.1 v2.19.1Junio C Hamano Thu, 27 Sep 2018 18:52:33 +0000 (11:52 -0700)

Git 2.19.1

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

Sync with 2.18.1Junio C Hamano Thu, 27 Sep 2018 18:50:45 +0000 (11:50 -0700)

Sync with 2.18.1

* maint-2.18:
Git 2.18.1
Git 2.17.2
fsck: detect submodule paths starting with dash
fsck: detect submodule urls starting with dash
Git 2.16.5
Git 2.15.3
Git 2.14.5
submodule-config: ban submodule paths that start with a dash
submodule-config: ban submodule urls that start with dash
submodule--helper: use "--" to signal end of clone options

Git 2.18.1 v2.18.1Junio C Hamano Thu, 27 Sep 2018 18:48:19 +0000 (11:48 -0700)

Git 2.18.1

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

Sync with 2.17.2Junio C Hamano Thu, 27 Sep 2018 18:45:01 +0000 (11:45 -0700)

Sync with 2.17.2

* maint-2.17:
Git 2.17.2
fsck: detect submodule paths starting with dash
fsck: detect submodule urls starting with dash
Git 2.16.5
Git 2.15.3
Git 2.14.5
submodule-config: ban submodule paths that start with a dash
submodule-config: ban submodule urls that start with dash
submodule--helper: use "--" to signal end of clone options

Git 2.17.2 v2.17.2Junio C Hamano Thu, 27 Sep 2018 18:44:07 +0000 (11:44 -0700)

Git 2.17.2

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

fsck: detect submodule paths starting with dashJeff King Mon, 24 Sep 2018 08:42:19 +0000 (04:42 -0400)

fsck: detect submodule paths starting with dash

As with urls, submodule paths with dashes are ignored by
git, but may end up confusing older versions. Detecting them
via fsck lets us prevent modern versions of git from being a
vector to spread broken .gitmodules to older versions.

Compared to blocking leading-dash urls, though, this
detection may be less of a good idea:

1. While such paths provide confusing and broken results,
they don't seem to actually work as option injections
against anything except "cd". In particular, the
submodule code seems to canonicalize to an absolute
path before running "git clone" (so it passes
/your/clone/-sub).

2. It's more likely that we may one day make such names
actually work correctly. Even after we revert this fsck
check, it will continue to be a hassle until hosting
servers are all updated.

On the other hand, it's not entirely clear that the behavior
in older versions is safe. And if we do want to eventually
allow this, we may end up doing so with a special syntax
anyway (e.g., writing "./-sub" in the .gitmodules file, and
teaching the submodule code to canonicalize it when
comparing).

So on balance, this is probably a good protection.

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

fsck: detect submodule urls starting with dashJeff King Mon, 24 Sep 2018 08:37:17 +0000 (04:37 -0400)

fsck: detect submodule urls starting with dash

Urls with leading dashes can cause mischief on older
versions of Git. We should detect them so that they can be
rejected by receive.fsckObjects, preventing modern versions
of git from being a vector by which attacks can spread.

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

Sync with 2.16.5Junio C Hamano Thu, 27 Sep 2018 18:41:02 +0000 (11:41 -0700)

Sync with 2.16.5

* maint-2.16:
Git 2.16.5
Git 2.15.3
Git 2.14.5
submodule-config: ban submodule paths that start with a dash
submodule-config: ban submodule urls that start with dash
submodule--helper: use "--" to signal end of clone options

Git 2.16.5 v2.16.5Junio C Hamano Thu, 27 Sep 2018 18:38:32 +0000 (11:38 -0700)

Git 2.16.5

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

Sync with 2.15.3Junio C Hamano Thu, 27 Sep 2018 18:35:43 +0000 (11:35 -0700)

Sync with 2.15.3

* maint-2.15:
Git 2.15.3
Git 2.14.5
submodule-config: ban submodule paths that start with a dash
submodule-config: ban submodule urls that start with dash
submodule--helper: use "--" to signal end of clone options

Git 2.15.3 v2.15.3Junio C Hamano Thu, 27 Sep 2018 18:33:47 +0000 (11:33 -0700)

Git 2.15.3

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

Sync with Git 2.14.4Junio C Hamano Thu, 27 Sep 2018 18:20:22 +0000 (11:20 -0700)

Sync with Git 2.14.4

* maint-2.14:
Git 2.14.5
submodule-config: ban submodule paths that start with a dash
submodule-config: ban submodule urls that start with dash
submodule--helper: use "--" to signal end of clone options

Git 2.14.5 v2.14.5Junio C Hamano Thu, 27 Sep 2018 18:19:11 +0000 (11:19 -0700)

Git 2.14.5

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

submodule-config: ban submodule paths that start with... Jeff King Mon, 24 Sep 2018 08:39:55 +0000 (04:39 -0400)

submodule-config: ban submodule paths that start with a dash

We recently banned submodule urls that look like
command-line options. This is the matching change to ban
leading-dash paths.

As with the urls, this should not break any use cases that
currently work. Even with our "--" separator passed to
git-clone, git-submodule.sh gets confused. Without the code
portion of this patch, the clone of "-sub" added in t7417
would yield results like:

/path/to/git-submodule: 410: cd: Illegal option -s
/path/to/git-submodule: 417: cd: Illegal option -s
/path/to/git-submodule: 410: cd: Illegal option -s
/path/to/git-submodule: 417: cd: Illegal option -s
Fetched in submodule path '-sub', but it did not contain b56243f8f4eb91b2f1f8109452e659f14dd3fbe4. Direct fetching of that commit failed.

Moreover, naively adding such a submodule doesn't work:

$ git submodule add $url -sub
The following path is ignored by one of your .gitignore files:
-sub

even though there is no such ignore pattern (the test script
hacks around this with a well-placed "git mv").

Unlike leading-dash urls, though, it's possible that such a
path _could_ be useful if we eventually made it work. So
this commit should be seen not as recommending a particular
policy, but rather temporarily closing off a broken and
possibly dangerous code-path. We may revisit this decision
later.

There are two minor differences to the tests in t7416 (that
covered urls):

1. We don't have a "./-sub" escape hatch to make this
work, since the submodule code expects to be able to
match canonical index names to the path field (so you
are free to add submodule config with that path, but we
would never actually use it, since an index entry would
never start with "./").

2. After this patch, cloning actually succeeds. Since we
ignore the submodule.*.path value, we fail to find a
config stanza for our submodule at all, and simply
treat it as inactive. We still check for the "ignoring"
message.

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

submodule-config: ban submodule urls that start with... Jeff King Mon, 24 Sep 2018 08:36:30 +0000 (04:36 -0400)

submodule-config: ban submodule urls that start with dash

The previous commit taught the submodule code to invoke our
"git clone $url $path" with a "--" separator so that we
aren't confused by urls or paths that start with dashes.

However, that's just one code path. It's not clear if there
are others, and it would be an easy mistake to add one in
the future. Moreover, even with the fix in the previous
commit, it's quite hard to actually do anything useful with
such an entry. Any url starting with a dash must fall into
one of three categories:

- it's meant as a file url, like "-path". But then any
clone is not going to have the matching path, since it's
by definition relative inside the newly created clone. If
you spell it as "./-path", the submodule code sees the
"/" and translates this to an absolute path, so it at
least works (assuming the receiver has the same
filesystem layout as you). But that trick does not apply
for a bare "-path".

- it's meant as an ssh url, like "-host:path". But this
already doesn't work, as we explicitly disallow ssh
hostnames that begin with a dash (to avoid option
injection against ssh).

- it's a remote-helper scheme, like "-scheme::data". This
_could_ work if the receiver bends over backwards and
creates a funny-named helper like "git-remote--scheme".
But normally there would not be any helper that matches.

Since such a url does not work today and is not likely to do
anything useful in the future, let's simply disallow them
entirely. That protects the existing "git clone" path (in a
belt-and-suspenders way), along with any others that might
exist.

Our tests cover two cases:

1. A file url with "./" continues to work, showing that
there's an escape hatch for people with truly silly
repo names.

2. A url starting with "-" is rejected.

Note that we expect case (2) to fail, but it would have done
so even without this commit, for the reasons given above.
So instead of just expecting failure, let's also check for
the magic word "ignoring" on stderr. That lets us know that
we failed for the right reason.

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

submodule--helper: use "--" to signal end of clone... Jeff King Mon, 24 Sep 2018 08:32:15 +0000 (04:32 -0400)

submodule--helper: use "--" to signal end of clone options

When we clone a submodule, we call "git clone $url $path".
But there's nothing to say that those components can't begin
with a dash themselves, confusing git-clone into thinking
they're options. Let's pass "--" to make it clear what we
expect.

There's no test here, because it's actually quite hard to
make these names work, even with "git clone" parsing them
correctly. And we're going to restrict these cases even
further in future commits. So we'll leave off testing until
then; this is just the minimal fix to prevent us from doing
something stupid with a badly formed entry.

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

read-cache.c: optimize reading index format v4Nguyễn Thái Ngọc Duy Wed, 26 Sep 2018 19:54:36 +0000 (15:54 -0400)

read-cache.c: optimize reading index format v4

Index format v4 requires some more computation to assemble a path
based on a previous one. The current code is not very efficient
because

- it doubles memory copy, we assemble the final path in a temporary
first before putting it back to a cache_entry

- strbuf_remove() in expand_name_field() is not exactly a good fit
for stripping a part at the end, _setlen() would do the same job
and is much cheaper.

- the open-coded loop to find the end of the string in
expand_name_field() can't beat an optimized strlen()

This patch avoids the temporary buffer and writes directly to the new
cache_entry, which addresses the first two points. The last point
could also be avoided if the total string length fits in the first 12
bits of ce_flags, if not we fall back to strlen().

Running "test-tool read-cache 100" on webkit.git (275k files), reading
v2 only takes 4.226 seconds, while v4 takes 5.711 seconds, 35% more
time. The patch reduces read time on v4 to 4.319 seconds.

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

mailmap: consistently normalize brian m. carlson's... Jonathan Nieder Mon, 24 Sep 2018 17:39:02 +0000 (10:39 -0700)

mailmap: consistently normalize brian m. carlson's name

v2.18.0-rc0~70^2 (mailmap: update brian m. carlson's email address,
2018-05-08) changed the mailmap to map

sandals@crustytoothpaste.ath.cx
-> brian m. carlson <sandals@crustytoothpaste.net>

instead of

sandals@crustytoothpaste.net
-> brian m. carlson <sandals@crustytoothpaste.ath.cx>

That means the mapping

Brian M. Carlson <sandals@crustytoothpaste.ath.cx>
-> brian m. carlson <sandals@crustytoothpaste.net>

is redundant, so we can remove it. More importantly, it means that
the identity "Brian M. Carlson <sandals@crustytoothpaste.net>" used in
some commits is not normalized any more. Add a mapping for it.

Noticed while updating Debian's Git packaging, which uses "git
shortlog --no-merges" to produce a list of changes in each version,
grouped by author's (normalized) name.

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

receive-pack: update comment with check_everything_conn... Jeff King Fri, 21 Sep 2018 23:04:45 +0000 (19:04 -0400)

receive-pack: update comment with check_everything_connected

That function is now called "check_connected()", but we forgot to update
this comment in 7043c7071c (check_everything_connected: use a struct
with named options, 2016-07-15).

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

commit-reach: cleanups in can_all_from_reach...Derrick Stolee Tue, 25 Sep 2018 13:27:41 +0000 (13:27 +0000)

commit-reach: cleanups in can_all_from_reach...

Due to a regression introduced by 4fbcca4e "commit-reach: make
can_all_from_reach... linear" the series including b67f6b26
"commit-reach: properly peel tags" was merged to master quickly.

There were a few more cleanups left to apply in the series, which
are included by this change:

1. Clean up a comment that is in the incorrect style.

2. Replace multiple calls to clear_commit_marks() with one call to
clear_commit_marks_many().

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

Second batch post 2.19Junio C Hamano Mon, 24 Sep 2018 17:31:26 +0000 (10:31 -0700)

Second batch post 2.19

Merge branch 'tg/range-diff-corner-case-fix'Junio C Hamano Mon, 24 Sep 2018 17:30:53 +0000 (10:30 -0700)

Merge branch 'tg/range-diff-corner-case-fix'

Recently added "range-diff" had a corner-case bug to cause it
segfault, which has been corrected.

* tg/range-diff-corner-case-fix:
linear-assignment: fix potential out of bounds memory access

Merge branch 'sg/split-index-test'Junio C Hamano Mon, 24 Sep 2018 17:30:53 +0000 (10:30 -0700)

Merge branch 'sg/split-index-test'

Test updates.

* sg/split-index-test:
t0090: disable GIT_TEST_SPLIT_INDEX for the test checking split index
t1700-split-index: drop unnecessary 'grep'

Merge branch 'en/update-ref-no-deref-stdin'Junio C Hamano Mon, 24 Sep 2018 17:30:53 +0000 (10:30 -0700)

Merge branch 'en/update-ref-no-deref-stdin'

"git update-ref" learned to make both "--no-deref" and "--stdin"
work at the same time.

* en/update-ref-no-deref-stdin:
update-ref: allow --no-deref with --stdin
update-ref: fix type of update_flags variable to match its usage

Merge branch 'ms/remote-error-message-update'Junio C Hamano Mon, 24 Sep 2018 17:30:52 +0000 (10:30 -0700)

Merge branch 'ms/remote-error-message-update'

Update error messages given by "git remote" and make them consistent.

* ms/remote-error-message-update:
builtin/remote: quote remote name on error to display empty name

Merge branch 'jt/lazy-object-fetch-fix'Junio C Hamano Mon, 24 Sep 2018 17:30:52 +0000 (10:30 -0700)

Merge branch 'jt/lazy-object-fetch-fix'

The code to backfill objects in lazily cloned repository did not
work correctly, which has been corrected.

* jt/lazy-object-fetch-fix:
fetch-object: set exact_oid when fetching
fetch-object: unify fetch_object[s] functions

Merge branch 'en/sequencer-empty-edit-result-aborts'Junio C Hamano Mon, 24 Sep 2018 17:30:52 +0000 (10:30 -0700)

Merge branch 'en/sequencer-empty-edit-result-aborts'

"git rebase" etc. in Git 2.19 fails to abort when given an empty
commit log message as result of editing, which has been corrected.

* en/sequencer-empty-edit-result-aborts:
sequencer: fix --allow-empty-message behavior, make it smarter

Merge branch 'ds/reachable'Junio C Hamano Mon, 24 Sep 2018 17:30:52 +0000 (10:30 -0700)

Merge branch 'ds/reachable'

Recent update broke the reachability algorithm when refs (e.g.
tags) that point at objects that are not commit were involved,
which has been fixed.

* ds/reachable:
commit-reach: fix memory and flag leaks
commit-reach: properly peel tags

Merge branch 'nd/attr-pathspec-fix'Junio C Hamano Mon, 24 Sep 2018 17:30:51 +0000 (10:30 -0700)

Merge branch 'nd/attr-pathspec-fix'

"git add ':(attr:foo)'" is not supported and is supposed to be
rejected while the command line arguments are parsed, but we fail
to reject such a command line upfront.

* nd/attr-pathspec-fix:
add: do not accept pathspec magic 'attr'

Merge branch 'bw/protocol-v2'Junio C Hamano Mon, 24 Sep 2018 17:30:50 +0000 (10:30 -0700)

Merge branch 'bw/protocol-v2'

Doc fix.

* bw/protocol-v2:
config: document value 2 for protocol.version

Merge branch 'sb/string-list-remove-unused'Junio C Hamano Mon, 24 Sep 2018 17:30:50 +0000 (10:30 -0700)

Merge branch 'sb/string-list-remove-unused'

Code clean-up.

* sb/string-list-remove-unused:
string-list: remove unused function print_string_list

Merge branch 'jk/dev-build-format-security'Junio C Hamano Mon, 24 Sep 2018 17:30:49 +0000 (10:30 -0700)

Merge branch 'jk/dev-build-format-security'

Build tweak to help developers.

* jk/dev-build-format-security:
config.mak.dev: add -Wformat-security

Merge branch 'sg/t3701-tighten-trace'Junio C Hamano Mon, 24 Sep 2018 17:30:49 +0000 (10:30 -0700)

Merge branch 'sg/t3701-tighten-trace'

Test update.

* sg/t3701-tighten-trace:
t3701-add-interactive: tighten the check of trace output

Merge branch 'sb/diff-color-move-more'Junio C Hamano Mon, 24 Sep 2018 17:30:48 +0000 (10:30 -0700)

Merge branch 'sb/diff-color-move-more'

Bugfix.

* sb/diff-color-move-more:
diff: fix --color-moved-ws=allow-indentation-change

Merge branch 'en/rerere-multi-stage-1-fix'Junio C Hamano Mon, 24 Sep 2018 17:30:48 +0000 (10:30 -0700)

Merge branch 'en/rerere-multi-stage-1-fix'

A corner case bugfix in "git rerere" code.

* en/rerere-multi-stage-1-fix:
rerere: avoid buffer overrun
t4200: demonstrate rerere segfault on specially crafted merge

Merge branch 'js/mingw-o-append'Junio C Hamano Mon, 24 Sep 2018 17:30:47 +0000 (10:30 -0700)

Merge branch 'js/mingw-o-append'

Further fix for O_APPEND emulation on Windows

* js/mingw-o-append:
mingw: fix mingw_open_append to work with named pipes
t0051: test GIT_TRACE to a windows named pipe

Merge branch 'en/double-semicolon-fix'Junio C Hamano Mon, 24 Sep 2018 17:30:47 +0000 (10:30 -0700)

Merge branch 'en/double-semicolon-fix'

Code clean-up.

* en/double-semicolon-fix:
Remove superfluous trailing semicolons

Merge branch 'jk/reopen-tempfile-truncate'Junio C Hamano Mon, 24 Sep 2018 17:30:46 +0000 (10:30 -0700)

Merge branch 'jk/reopen-tempfile-truncate'

Fix for a long-standing bug that leaves the index file corrupt when
it shrinks during a partial commit.

* jk/reopen-tempfile-truncate:
reopen_tempfile(): truncate opened file

Merge branch 'bp/mv-submodules-with-fsmonitor'Junio C Hamano Mon, 24 Sep 2018 17:30:46 +0000 (10:30 -0700)

Merge branch 'bp/mv-submodules-with-fsmonitor'

When fsmonitor is in use, after operation on submodules updates
.gitmodules, we lost track of the fact that we did so and relied on
stale fsmonitor data.

* bp/mv-submodules-with-fsmonitor:
git-mv: allow submodules and fsmonitor to work together

Merge branch 'ds/format-patch-range-diff-test'Junio C Hamano Mon, 24 Sep 2018 17:30:45 +0000 (10:30 -0700)

Merge branch 'ds/format-patch-range-diff-test'

* ds/format-patch-range-diff-test:
t3206-range-diff.sh: cover single-patch case

Merge branch 'tb/void-check-attr'Junio C Hamano Mon, 24 Sep 2018 17:30:45 +0000 (10:30 -0700)

Merge branch 'tb/void-check-attr'

Code clean-up.

* tb/void-check-attr:
Make git_check_attr() a void function

Merge branch 'js/rebase-i-autosquash-fix'Junio C Hamano Mon, 24 Sep 2018 17:30:45 +0000 (10:30 -0700)

Merge branch 'js/rebase-i-autosquash-fix'

"git rebase -i" did not clear the state files correctly when a run
of "squash/fixup" is aborted and then the user manually amended the
commit instead, which has been corrected.

* js/rebase-i-autosquash-fix:
rebase -i: be careful to wrap up fixup/squash chains
rebase -i --autosquash: demonstrate a problem skipping the last squash

t5551: compare sorted cookies filesThomas Gummerer Mon, 17 Sep 2018 21:46:28 +0000 (22:46 +0100)

t5551: compare sorted cookies files

In t5551 we check that we save cookies correctly to a file when
http.cookiefile and http.savecookies are set. To do so we create an
expect file that expects the cookies in a certain order.

However after e2ef8d6fa ("cookies: support creation-time attribute for
cookies", 2018-08-28) in curl.git (released in curl 7.61.1) that order
changed.

We document the file format as "Netscape/Mozilla cookie file
format (see curl(1))", so any format produced by libcurl should be
fine here. Sort the files, to be agnostic to the order of the
cookies, and make the test pass with both curl versions > 7.61.1 and
earlier curl versions.

Reported-by: Todd Zullinger <tmz@pobox.com>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5551: move setup code inside test_expect blocksThomas Gummerer Mon, 17 Sep 2018 21:46:27 +0000 (22:46 +0100)

t5551: move setup code inside test_expect blocks

Move setup code inside test_expect blocks, to catch unexpected
failures in the setup steps, and bring the test scripts in line with
our modern test style.

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

fetch: in partial clone, check presence of targetsJonathan Tan Fri, 21 Sep 2018 18:22:38 +0000 (11:22 -0700)

fetch: in partial clone, check presence of targets

When fetching an object that is known as a promisor object to the local
repository, the connectivity check in quickfetch() in builtin/fetch.c
succeeds, causing object transfer to be bypassed. However, this should
not happen if that object is merely promised and not actually present.

Because this happens, when a user invokes "git fetch origin <sha-1>" on
the command-line, the <sha-1> object may not actually be fetched even
though the command returns an exit code of 0. This is a similar issue
(but with a different cause) to the one fixed by a0c9016abd
("upload-pack: send refs' objects despite "filter"", 2018-07-09).

Therefore, update quickfetch() to also directly check for the presence
of all objects to be fetched. Its documentation and name are also
updated to better reflect what it does.

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

connected: document connectivity in partial clonesJonathan Tan Fri, 21 Sep 2018 18:22:37 +0000 (11:22 -0700)

connected: document connectivity in partial clones

In acb0c57260 ("fetch: support filters", 2017-12-08), check_connected()
was extended to allow objects to either be promised to be available (if
the repository is a partial clone) or to be present; previously, this
function required the latter. However, this change was not reflected in
the documentation of that function. Update the documentation
accordingly.

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

commit-reach: fix memory and flag leaksDerrick Stolee Fri, 21 Sep 2018 15:05:27 +0000 (08:05 -0700)

commit-reach: fix memory and flag leaks

The can_all_from_reach_with_flag() method uses 'assign_flag' as a
value we can use to mark objects temporarily during our commit walk.
The intent is that these flags are removed from all objects before
returning. However, this is not the case.

The 'from' array could also contain objects that are not commits, and
we mark those objects with 'assign_flag'. Add a loop to the 'cleanup'
section that removes these markers.

Also, we forgot to free() the memory for 'list', so add that to the
'cleanup' section.

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

commit-reach: properly peel tagsDerrick Stolee Fri, 21 Sep 2018 15:05:26 +0000 (08:05 -0700)

commit-reach: properly peel tags

The can_all_from_reach_with_flag() algorithm was refactored in 4fbcca4e
"commit-reach: make can_all_from_reach... linear" but incorrectly
assumed that all objects provided were commits. During a fetch
negotiation, ok_to_give_up() in upload-pack.c may provide unpeeled tags
to the 'from' array. The current code creates a segfault.

Add a direct call to can_all_from_reach_with_flag() in 'test-tool reach'
and add a test in t6600-test-reach.sh that demonstrates this segfault.

Correct the issue by peeling tags when investigating the initial list
of objects in the 'from' array.

Signed-off-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: reduce implicit dependency the_repositoryNguyễn Thái Ngọc Duy Fri, 21 Sep 2018 15:57:39 +0000 (17:57 +0200)

revision.c: reduce implicit dependency the_repository

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

revision.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Fri, 21 Sep 2018 15:57:38 +0000 (17:57 +0200)

revision.c: remove implicit dependency 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>

ws.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Fri, 21 Sep 2018 15:57:37 +0000 (17:57 +0200)

ws.c: remove implicit dependency 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>

tree-diff.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Fri, 21 Sep 2018 15:57:36 +0000 (17:57 +0200)

tree-diff.c: remove implicit dependency 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>

submodule.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Fri, 21 Sep 2018 15:57:35 +0000 (17:57 +0200)

submodule.c: remove implicit dependency 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>

line-range.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Fri, 21 Sep 2018 15:57:34 +0000 (17:57 +0200)

line-range.c: remove implicit dependency 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>

userdiff.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Fri, 21 Sep 2018 15:57:33 +0000 (17:57 +0200)

userdiff.c: remove implicit dependency on the_index

[jc: squashed in missing forward decl in userdiff.h found by Ramsay]

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

rerere.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Fri, 21 Sep 2018 15:57:32 +0000 (17:57 +0200)

rerere.c: remove implicit dependency on the_index

The reason rerere(), rerere_forget() and rerere_remaining() take a
struct repository instead of struct index_state is not obvious from
the patch:

Deep in update_paths() and find_conflict(), hold_locked_index() and
read_index() are called. These functions assumes the index path at
$GIT_DIR/index which is not always true when you take an arbitrary
index state. Taking a repository will allow us to point to the right
index path later when we replace them with repo_ versions.

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