git
6 years agoMerge branch 'rs/cocci-strbuf-addf-to-addstr'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'rs/cocci-strbuf-addf-to-addstr'

* rs/cocci-strbuf-addf-to-addstr:
  cocci: simplify check for trivial format strings

6 years agoMerge branch 'nd/trace-index-ops'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'nd/trace-index-ops'

* nd/trace-index-ops:
  trace: measure where the time is spent in the index-heavy operations

6 years agoMerge branch 'cc/perf-aggregate'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'cc/perf-aggregate'

"make perf" enhancement.

* cc/perf-aggregate:
  perf/aggregate: sort JSON fields in output
  perf/aggregate: add --reponame option
  perf/aggregate: add --subsection option

6 years agoMerge branch 'ab/wildmatch-tests'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'ab/wildmatch-tests'

More tests for wildmatch functions.

* ab/wildmatch-tests:
  wildmatch test: mark test as EXPENSIVE_ON_WINDOWS
  test-lib: add an EXPENSIVE_ON_WINDOWS prerequisite
  wildmatch test: create & test files on disk in addition to in-memory
  wildmatch test: perform all tests under all wildmatch() modes
  wildmatch test: use test_must_fail, not ! for test-wildmatch
  wildmatch test: remove dead fnmatch() test code
  wildmatch test: use a paranoia pattern from nul_match()
  wildmatch test: don't try to vertically align our output
  wildmatch test: use more standard shell style
  wildmatch test: indent with tabs, not spaces

6 years agoMerge branch 'po/object-id'
Junio C Hamano [Thu, 15 Feb 2018 22:55:43 +0000 (14:55 -0800)] 
Merge branch 'po/object-id'

Conversion from uchar[20] to struct object_id continues.

* po/object-id:
  sha1_file: rename hash_sha1_file_literally
  sha1_file: convert write_loose_object to object_id
  sha1_file: convert force_object_loose to object_id
  sha1_file: convert write_sha1_file to object_id
  notes: convert write_notes_tree to object_id
  notes: convert combine_notes_* to object_id
  commit: convert commit_tree* to object_id
  match-trees: convert splice_tree to object_id
  cache: clear whole hash buffer with oidclr
  sha1_file: convert hash_sha1_file to object_id
  dir: convert struct sha1_stat to use object_id
  sha1_file: convert pretend_sha1_file to object_id

6 years agoMerge branch 'sb/pull-rebase-submodule'
Junio C Hamano [Thu, 15 Feb 2018 22:55:43 +0000 (14:55 -0800)] 
Merge branch 'sb/pull-rebase-submodule'

"git pull --rebase" did not pass verbosity setting down when
recursing into a submodule.

* sb/pull-rebase-submodule:
  builtin/pull: respect verbosity settings in submodules

6 years agoMerge branch 'kg/packed-ref-cache-fix'
Junio C Hamano [Thu, 15 Feb 2018 22:55:42 +0000 (14:55 -0800)] 
Merge branch 'kg/packed-ref-cache-fix'

Avoid mmapping small files while using packed refs (especially ones
with zero size, which would cause later munmap() to fail).

* kg/packed-ref-cache-fix:
  packed_ref_cache: don't use mmap() for small files
  load_contents(): don't try to mmap an empty file
  packed_ref_iterator_begin(): make optimization more general
  find_reference_location(): make function safe for empty snapshots
  create_snapshot(): use `xmemdupz()` rather than a strbuf
  struct snapshot: store `start` rather than `header_len`

6 years agoMerge branch 'jt/fsck-code-cleanup'
Junio C Hamano [Thu, 15 Feb 2018 22:55:41 +0000 (14:55 -0800)] 
Merge branch 'jt/fsck-code-cleanup'

Plug recently introduced leaks in fsck.

* jt/fsck-code-cleanup:
  fsck: fix leak when traversing trees

6 years agoMerge branch 'en/merge-recursive-fixes'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)] 
Merge branch 'en/merge-recursive-fixes'

* en/merge-recursive-fixes:
  merge-recursive: add explanation for src_entry and dst_entry
  merge-recursive: fix logic ordering issue
  Tighten and correct a few testcases for merging and cherry-picking

6 years agoMerge branch 'jc/worktree-add-short-help'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)] 
Merge branch 'jc/worktree-add-short-help'

Error message fix.

* jc/worktree-add-short-help:
  worktree: say that "add" takes an arbitrary commit in short-help

6 years agoMerge branch 'ab/sha1dc-build'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)] 
Merge branch 'ab/sha1dc-build'

Push the submodule version of collision-detecting SHA-1 hash
implementation a bit harder on builders.

* ab/sha1dc-build:
  sha1dc_git.h: re-arrange an ifdef chain for a subsequent change
  Makefile: under "make dist", include the sha1collisiondetection submodule
  Makefile: don't error out under DC_SHA1_EXTERNAL if DC_SHA1_SUBMODULE=auto

6 years agoworktree: add: fix 'post-checkout' not knowing new worktree location
Eric Sunshine [Thu, 15 Feb 2018 19:18:41 +0000 (14:18 -0500)] 
worktree: add: fix 'post-checkout' not knowing new worktree location

Although "git worktree add" learned to run the 'post-checkout' hook in
ade546be47 (worktree: invoke post-checkout hook, 2017-12-07), it
neglected to change to the directory of the newly-created worktree
before running the hook. Instead, the hook runs within the directory
from which the "git worktree add" command itself was invoked, which
effectively neuters the hook since it knows nothing about the new
worktree directory.

Further, ade546be47 failed to sanitize the environment before running
the hook, which means that user-assigned values of GIT_DIR and
GIT_WORK_TREE could mislead the hook about the location of the new
worktree. In the case of "git worktree add" being run from a bare
repository, the GIT_DIR="." assigned by Git itself leaks into the hook's
environment and breaks Git commands; this is so even when the working
directory is correctly changed to the new worktree before the hook runs
since ".", relative to the new worktree directory, does not point at the
bare repository.

Fix these problems by (1) changing to the new worktree's directory
before running the hook, and (2) sanitizing the environment of GIT_DIR
and GIT_WORK_TREE so hooks can't be confused by misleading values.

Enhance the t2025 'post-checkout' tests to verify that the hook is
indeed run within the correct directory and that Git commands invoked by
the hook compute Git-dir and top-level worktree locations correctly.

While at it, also add two new tests: (1) verify that the hook is run
within the correct directory even when the new worktree is created from
a sibling worktree (as opposed to the main worktree); (2) verify that
the hook is provided with correct context when the new worktree is
created from a bare repository (test provided by Lars Schneider).

Implementation Notes:

Rather than sanitizing the environment of GIT_DIR and GIT_WORK_TREE, an
alternative would be to set them explicitly, as is already done for
other Git commands run internally by "git worktree add". This patch opts
instead to sanitize the environment in order to clearly document that
the worktree is fully functional by the time the hook is run, thus does
not require special environmental overrides.

The hook is run manually, rather than via run_hook_le(), since it needs
to change the working directory to that of the worktree, and
run_hook_le() does not provide such functionality. As this is a one-off
case, adding 'run_hook' overloads which allow the directory to be set
does not seem warranted at this time.

Reported-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopackfile: refactor hash search with fanout table
Jonathan Tan [Tue, 13 Feb 2018 18:39:39 +0000 (10:39 -0800)] 
packfile: refactor hash search with fanout table

Subsequent patches will introduce file formats that make use of a fanout
array and a sorted table containing hashes, just like packfiles.
Refactor the hash search in packfile.c into its own function, so that
those patches can make use of it as well.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopackfile: remove GIT_DEBUG_LOOKUP log statements
Jonathan Tan [Tue, 13 Feb 2018 18:39:38 +0000 (10:39 -0800)] 
packfile: remove GIT_DEBUG_LOOKUP log statements

In commit 628522ec1439 ("sha1-lookup: more memory efficient search in
sorted list of SHA-1", 2008-04-09), a different algorithm for searching
a sorted list was introduced, together with a set of log statements
guarded by GIT_DEBUG_LOOKUP that are invoked both when using that
algorithm and when using the existing binary search. Those log
statements was meant for experiments and debugging, but with the removal
of the aforementioned different algorithm in commit f1068efefe6d
("sha1_file: drop experimental GIT_USE_LOOKUP search", 2017-08-09),
those log statements are probably no longer necessary.

Remove those statements.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoapply: handle Subversion diffs with /dev/null gracefully
Tatyana Krasnukha [Thu, 15 Feb 2018 00:29:34 +0000 (01:29 +0100)] 
apply: handle Subversion diffs with /dev/null gracefully

Subversion generates diffs that can contain lines like this one:

--- /dev/null  (nonexistent)

Let's teach Git's apply machinery to handle such a line gracefully.

This fixes https://github.com/git-for-windows/git/isues/1489

Signed-off-by: Tatyana Krasnukha <tatyana@synopsys.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoapply: demonstrate a problem applying svn diffs
Johannes Schindelin [Thu, 15 Feb 2018 00:29:27 +0000 (01:29 +0100)] 
apply: demonstrate a problem applying svn diffs

Subversion generates diffs that contain funny ---/+++ lines containing
more than just the file names. Example:

--- a/trunk/README (revision 4711)
+++ /dev/null (nonexistent)

Let's add a test case demonstrating that apply cannot handle the
/dev/null line (although it can handle the trunk/README line just fine).

Reported in https://github.com/git-for-windows/git/issues/1489

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation/git-status: clarify status table for porcelain mode
Stefan Beller [Thu, 15 Feb 2018 00:18:12 +0000 (16:18 -0800)] 
Documentation/git-status: clarify status table for porcelain mode

It is possible to have the output ' A' from 'git status --porcelain'
by adding a file using the '--intend-to-add' flag.  Make this clear by
adding the pattern in the table of the documentation.

However the mode 'DM' (deleted in the index, modified in the working tree)
is not possible in the non-merge case in which the file only shows
as 'D ' (and adding it back to the worktree would show an additional line
of an '??' untracked file). It is also not possible in the merge case as
then the mode involves a 'U' on one side of the merge.
Remove that pattern.

Reported-by: Ross Light <light@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorev-parse: rename 'this' variable
Brandon Williams [Wed, 14 Feb 2018 18:59:27 +0000 (10:59 -0800)] 
rev-parse: rename 'this' variable

Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopack-objects: rename 'this' variables
Brandon Williams [Wed, 14 Feb 2018 18:59:26 +0000 (10:59 -0800)] 
pack-objects: rename 'this' variables

Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoblame: rename 'this' variables
Brandon Williams [Wed, 14 Feb 2018 18:59:25 +0000 (10:59 -0800)] 
blame: rename 'this' variables

Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoobject: rename function 'typename' to 'type_name'
Brandon Williams [Wed, 14 Feb 2018 18:59:24 +0000 (10:59 -0800)] 
object: rename function 'typename' to 'type_name'

Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoobject_info: change member name from 'typename' to 'type_name'
Brandon Williams [Wed, 14 Feb 2018 18:59:23 +0000 (10:59 -0800)] 
object_info: change member name from 'typename' to 'type_name'

Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoCorrect mispellings of ".gitmodule" to ".gitmodules"
Robert P. J. Day [Wed, 14 Feb 2018 00:09:31 +0000 (19:09 -0500)] 
Correct mispellings of ".gitmodule" to ".gitmodules"

There are a small number of misspellings, ".gitmodule", scattered
throughout the code base, correct them ... no apparent functional
changes.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot/: correct obvious typo "detahced"
Robert P. J. Day [Wed, 14 Feb 2018 09:08:01 +0000 (04:08 -0500)] 
t/: correct obvious typo "detahced"

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoam: support --quit
Nguyễn Thái Ngọc Duy [Wed, 14 Feb 2018 11:16:06 +0000 (18:16 +0700)] 
am: support --quit

Among the "in progress" commands, only git-am and git-merge do not
support --quit. Support --quit in git-am too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosq_dequote: fix extra consumption of source string
Jeff King [Tue, 13 Feb 2018 23:41:49 +0000 (18:41 -0500)] 
sq_dequote: fix extra consumption of source string

This fixes a (probably harmless) parsing problem in
sq_dequote_step(), in which we parse some bogus input
incorrectly rather than complaining that it's bogus.

Our shell-dequoting function is very strict: it can unquote
everything generated by sq_quote(), but not arbitrary
strings. In particular, it only allows characters outside of
the single-quoted string if they are immediately backslashed
and then the single-quoted string is resumed. So:

  'foo'\''bar'

is OK. But these are not:

  'foo'\'bar
  'foo'\'
  'foo'\'\''bar'

even though they are all valid shell. The parser has a funny
corner case here. When we see a backslashed character, we
keep incrementing the "src" pointer as we parse it. For a
single sq_dequote() call, that's OK; our next step is to
bail with an error, and we don't care where "src" points.

But if we're parsing multiple strings with sq_dequote_to_argv(),
then our next step is to see if the string is followed by
whitespace. Because we erroneously incremented the "src"
pointer, we don't barf on the bogus backslash that we
skipped. Instead, we may find whitespace that immediately
follows it, and continue as if all is well (skipping the
backslashed character completely!).

In practice, this shouldn't be a big deal. The input is
bogus, and our sq_quote() would never generate this bogus
input. In all but one callers, we are parsing input created
by an earlier call to sq_quote(). That final case is "git
shell", which parses shell-quoting generated by the client.
And in that case we use the singular sq_quote(), which has
always behaved correctly.

One might also wonder if you could provoke a read past the
end of the string. But the answer is no; we still parse
character by character, and would never advance past a NUL.

This patch implements the minimal fix, along with
documenting the restriction (which confused at least me
while reading the code). We should possibly consider
being more liberal in accepting valid shell-quoted words. I
suspect the code may actually be simpler, and it would be
more friendly to anybody generating or editing input by
hand. But I wanted to fix just the immediate bug in this
patch.

We don't have a direct way to unit-test the sq_dequote()
functions, but we can do this by feeding input to
GIT_CONFIG_PARAMETERS (which is not normally a user-facing
interface, but serves here as it expects to see sq_quote()
input from "git -c"). I've included both a bogus example,
and a related "good" one to confirm that we still parse it
correctly.

Noticed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-hashmap: use "unsigned int" for hash storage
Jeff King [Wed, 14 Feb 2018 18:08:57 +0000 (13:08 -0500)] 
test-hashmap: use "unsigned int" for hash storage

The hashmap API always use an unsigned value for storing
and comparing hashes. Whereas this test code uses "int".
This works out in practice since one can typically
round-trip between "int" and "unsigned int". But since this
is essentially reference code for the hashmap API, we should
model using the correct types.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-hashmap: simplify alloc_test_entry
Jeff King [Wed, 14 Feb 2018 18:08:20 +0000 (13:08 -0500)] 
test-hashmap: simplify alloc_test_entry

This function takes two ptr/len pairs, which implies that
they can be arbitrary buffers. But internally, it assumes
that each "ptr" is NUL-terminated at "len" (because we
memcpy an extra byte to pick up the NUL terminator).

In practice this works because each caller only ever passes
strlen(ptr) as the length. But let's drop the "len"
parameters to make our expectations clear.

Note that we can get rid of the "l1" and "l2" variables from
cmd_main() as a further cleanup, since they are now mostly
used to check whether the p1 and p2 arguments are present
(technically the length parameters conflated NULL with the
empty string, which we no longer do, but I think that is
actually an improvement).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-hashmap: use strbuf_getline rather than fgets
Jeff King [Wed, 14 Feb 2018 18:07:19 +0000 (13:07 -0500)] 
test-hashmap: use strbuf_getline rather than fgets

Using fgets() with a fixed-size buffer can lead to lines
being accidentally split across two calls if they are larger
than the buffer size.

As this is just a test helper, this is unlikely to be a
problem in practice. But since people may look at test
helpers as reference code, it's a good idea for them to
model the preferred behavior.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-hashmap: use xsnprintf rather than snprintf
Jeff King [Wed, 14 Feb 2018 18:06:57 +0000 (13:06 -0500)] 
test-hashmap: use xsnprintf rather than snprintf

In general, using a bare snprintf can truncate the resulting
buffer, leading to confusing results. In this case we know
that our buffer is sized large enough to accommodate our
loop, so there's no bug. However, we should use xsnprintf()
to document (and check) that assumption, and to model good
practice to people reading the code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-hashmap: check allocation computation for overflow
Jeff King [Wed, 14 Feb 2018 18:06:34 +0000 (13:06 -0500)] 
test-hashmap: check allocation computation for overflow

When we allocate the test_entry flex-struct, we have to add
up all of the elements that go into the flex array. If these
were to overflow a size_t, this would allocate a too-small
buffer, which we would then overflow in our memcpy steps.

Since this is just a test-helper, it probably doesn't matter
in practice, but we should model the correct technique by
using the st_add() macros.

Unfortunately, we cannot use the FLEX_ALLOC() macros here,
because we are stuffing two different buffers into a single
flex array.

While we're here, let's also swap out "malloc" for our
error-checking "xmalloc", and use the preferred
"sizeof(*var)" instead of "sizeof(type)".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-hashmap: use ALLOC_ARRAY rather than bare malloc
Jeff King [Wed, 14 Feb 2018 18:05:46 +0000 (13:05 -0500)] 
test-hashmap: use ALLOC_ARRAY rather than bare malloc

These two array allocations have several minor flaws:

  - they use bare malloc, rather than our error-checking
    xmalloc

  - they do a bare multiplication to determine the total
    size (which in theory can overflow, though in this case
    the sizes are all constants)

  - they use sizeof(type), but the type in the second one
    doesn't match the actual array (though it's "int" versus
    "unsigned int", which are guaranteed by C99 to have the
    same size)

None of these are likely to be problems in practice, and
this is just a test helper. But since people often look at
test helpers as reference code, we should do our best to
model the recommended techniques.

Switching to ALLOC_ARRAY fixes all three.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofsmonitor: update documentation to remove reference to invalid config settings
Ben Peart [Wed, 14 Feb 2018 15:41:30 +0000 (10:41 -0500)] 
fsmonitor: update documentation to remove reference to invalid config settings

Remove the reference to setting core.fsmonitor to `true` (or `false`) as those
are not valid settings.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoSecond batch for 2.17
Junio C Hamano [Wed, 14 Feb 2018 00:22:16 +0000 (16:22 -0800)] 
Second batch for 2.17

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'tz/doc-show-defaults-to-head'
Junio C Hamano [Tue, 13 Feb 2018 21:39:17 +0000 (13:39 -0800)] 
Merge branch 'tz/doc-show-defaults-to-head'

Doc update.

* tz/doc-show-defaults-to-head:
  doc: mention 'git show' defaults to HEAD

6 years agoMerge branch 'ew/svn-branch-segfault-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:16 +0000 (13:39 -0800)] 
Merge branch 'ew/svn-branch-segfault-fix'

Workaround for segfault with more recent versions of SVN.

* ew/svn-branch-segfault-fix:
  git-svn: control destruction order to avoid segfault

6 years agoMerge branch 'sg/travis-linux32-sanity'
Junio C Hamano [Tue, 13 Feb 2018 21:39:16 +0000 (13:39 -0800)] 
Merge branch 'sg/travis-linux32-sanity'

Travis updates.

* sg/travis-linux32-sanity:
  travis-ci: don't fail if user already exists on 32 bit Linux build job
  travis-ci: don't run the test suite as root in the 32 bit Linux build
  travis-ci: don't repeat the path of the cache directory
  travis-ci: use 'set -e' in the 32 bit Linux build job
  travis-ci: use 'set -x' for the commands under 'su' in the 32 bit Linux build

6 years agoMerge branch 'nd/list-merge-strategy'
Junio C Hamano [Tue, 13 Feb 2018 21:39:15 +0000 (13:39 -0800)] 
Merge branch 'nd/list-merge-strategy'

Completion of "git merge -s<strategy>" (in contrib/) did not work
well in non-C locale.

* nd/list-merge-strategy:
  completion: fix completing merge strategies on non-C locales

6 years agoMerge branch 'jt/long-running-process-doc'
Junio C Hamano [Tue, 13 Feb 2018 21:39:15 +0000 (13:39 -0800)] 
Merge branch 'jt/long-running-process-doc'

Doc updates.

* jt/long-running-process-doc:
  Docs: split out long-running subprocess handshake

6 years agoMerge branch 'jk/daemon-fixes'
Junio C Hamano [Tue, 13 Feb 2018 21:39:15 +0000 (13:39 -0800)] 
Merge branch 'jk/daemon-fixes'

Assorted fixes to "git daemon".

* jk/daemon-fixes:
  daemon: fix length computation in newline stripping
  t/lib-git-daemon: add network-protocol helpers
  daemon: handle NULs in extended attribute string
  daemon: fix off-by-one in logging extended attributes
  t/lib-git-daemon: record daemon log
  t5570: use ls-remote instead of clone for interp tests

6 years agoMerge branch 'pw/sequencer-in-process-commit'
Junio C Hamano [Tue, 13 Feb 2018 21:39:15 +0000 (13:39 -0800)] 
Merge branch 'pw/sequencer-in-process-commit'

The sequencer infrastructure is shared across "git cherry-pick",
"git rebase -i", etc., and has always spawned "git commit" when it
needs to create a commit.  It has been taught to do so internally,
when able, by reusing the codepath "git commit" itself uses, which
gives performance boost for a few tens of percents in some sample
scenarios.

* pw/sequencer-in-process-commit:
  sequencer: run 'prepare-commit-msg' hook
  t7505: add tests for cherry-pick and rebase -i/-p
  t7505: style fixes
  sequencer: assign only free()able strings to gpg_sign
  sequencer: improve config handling
  t3512/t3513: remove KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1
  sequencer: try to commit without forking 'git commit'
  sequencer: load commit related config
  sequencer: simplify adding Signed-off-by: trailer
  commit: move print_commit_summary() to libgit
  commit: move post-rewrite code to libgit
  Add a function to update HEAD after creating a commit
  commit: move empty message checks to libgit
  t3404: check intermediate squash messages

6 years agoMerge branch 'nd/shared-index-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:14 +0000 (13:39 -0800)] 
Merge branch 'nd/shared-index-fix'

Code clean-up.

* nd/shared-index-fix:
  read-cache: don't write index twice if we can't write shared index
  read-cache.c: move tempfile creation/cleanup out of write_shared_index
  read-cache.c: change type of "temp" in write_shared_index()

6 years agoMerge branch 'po/http-push-error-message'
Junio C Hamano [Tue, 13 Feb 2018 21:39:14 +0000 (13:39 -0800)] 
Merge branch 'po/http-push-error-message'

Debugging aid.

* po/http-push-error-message:
  http-push: improve error log

6 years agoMerge branch 'po/clang-format-functype-weight'
Junio C Hamano [Tue, 13 Feb 2018 21:39:14 +0000 (13:39 -0800)] 
Merge branch 'po/clang-format-functype-weight'

Prevent "clang-format" from breaking line after function return type.

* po/clang-format-functype-weight:
  clang-format: adjust penalty for return type line break

6 years agoMerge branch 'jc/mailinfo-cleanup-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:14 +0000 (13:39 -0800)] 
Merge branch 'jc/mailinfo-cleanup-fix'

Corner case bugfix.

* jc/mailinfo-cleanup-fix:
  mailinfo: avoid segfault when can't open files

6 years agoMerge branch 'sg/cocci-move-array'
Junio C Hamano [Tue, 13 Feb 2018 21:39:13 +0000 (13:39 -0800)] 
Merge branch 'sg/cocci-move-array'

Code clean-up.

* sg/cocci-move-array:
  Use MOVE_ARRAY

6 years agoMerge branch 'tg/split-index-fixes'
Junio C Hamano [Tue, 13 Feb 2018 21:39:12 +0000 (13:39 -0800)] 
Merge branch 'tg/split-index-fixes'

The split-index mode had a few corner case bugs fixed.

* tg/split-index-fixes:
  travis: run tests with GIT_TEST_SPLIT_INDEX
  split-index: don't write cache tree with null oid entries
  read-cache: fix reading the shared index for other repos

6 years agoMerge branch 'rs/strbuf-cocci-workaround'
Junio C Hamano [Tue, 13 Feb 2018 21:39:12 +0000 (13:39 -0800)] 
Merge branch 'rs/strbuf-cocci-workaround'

Update Coccinelle rules to catch and optimize strbuf_addf(&buf, "%s", str)

* rs/strbuf-cocci-workaround:
  cocci: use format keyword instead of a literal string

6 years agoMerge branch 'mr/packed-ref-store-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:11 +0000 (13:39 -0800)] 
Merge branch 'mr/packed-ref-store-fix'

Crash fix for a corner case where an error codepath tried to unlock
what it did not acquire lock on.

* mr/packed-ref-store-fix:
  files_initial_transaction_commit(): only unlock if locked

6 years agoMerge branch 'jt/http-redact-cookies'
Junio C Hamano [Tue, 13 Feb 2018 21:39:11 +0000 (13:39 -0800)] 
Merge branch 'jt/http-redact-cookies'

The http tracing code, often used to debug connection issues,
learned to redact potentially sensitive information from its output
so that it can be more safely sharable.

* jt/http-redact-cookies:
  http: support omitting data from traces
  http: support cookie redaction when tracing

6 years agoMerge branch 'ds/use-get-be64'
Junio C Hamano [Tue, 13 Feb 2018 21:39:11 +0000 (13:39 -0800)] 
Merge branch 'ds/use-get-be64'

Code clean-up.

* ds/use-get-be64:
  packfile: use get_be64() for large offsets

6 years agoMerge branch 'cc/sha1-file-name'
Junio C Hamano [Tue, 13 Feb 2018 21:39:10 +0000 (13:39 -0800)] 
Merge branch 'cc/sha1-file-name'

Code clean-up.

* cc/sha1-file-name:
  sha1_file: improve sha1_file_name() perfs
  sha1_file: remove static strbuf from sha1_file_name()

6 years agoMerge branch 'nd/trace-with-env'
Junio C Hamano [Tue, 13 Feb 2018 21:39:10 +0000 (13:39 -0800)] 
Merge branch 'nd/trace-with-env'

The tracing machinery learned to report tweaking of environment
variables as well.

* nd/trace-with-env:
  run-command.c: print new cwd in trace_run_command()
  run-command.c: print env vars in trace_run_command()
  run-command.c: print program 'git' when tracing git_cmd mode
  run-command.c: introduce trace_run_command()
  trace.c: move strbuf_release() out of print_trace_line()
  trace: avoid unnecessary quoting
  sq_quote_argv: drop maxlen parameter

6 years agoMerge branch 'pc/submodule-helper'
Junio C Hamano [Tue, 13 Feb 2018 21:39:10 +0000 (13:39 -0800)] 
Merge branch 'pc/submodule-helper'

Rewrite two more "git submodule" subcommands in C.

* pc/submodule-helper:
  submodule: port submodule subcommand 'deinit' from shell to C
  submodule: port submodule subcommand 'sync' from shell to C

6 years agoMerge branch 'rb/hashmap-h-compilation-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:10 +0000 (13:39 -0800)] 
Merge branch 'rb/hashmap-h-compilation-fix'

Code clean-up.

* rb/hashmap-h-compilation-fix:
  hashmap.h: remove unused variable

6 years agoMerge branch 'nd/diff-flush-before-warning'
Junio C Hamano [Tue, 13 Feb 2018 21:39:09 +0000 (13:39 -0800)] 
Merge branch 'nd/diff-flush-before-warning'

Avoid showing a warning message in the middle of a line of "git
diff" output.

* nd/diff-flush-before-warning:
  diff.c: flush stdout before printing rename warnings

6 years agoMerge branch 'tb/crlf-conv-flags'
Junio C Hamano [Tue, 13 Feb 2018 21:39:08 +0000 (13:39 -0800)] 
Merge branch 'tb/crlf-conv-flags'

Code clean-up.

* tb/crlf-conv-flags:
  convert_to_git(): safe_crlf/checksafe becomes int conv_flags

6 years agoMerge branch 'rs/describe-unique-abbrev'
Junio C Hamano [Tue, 13 Feb 2018 21:39:07 +0000 (13:39 -0800)] 
Merge branch 'rs/describe-unique-abbrev'

Code clean-up.

* rs/describe-unique-abbrev:
  describe: use strbuf_add_unique_abbrev() for adding short hashes

6 years agoMerge branch 'ks/submodule-doc-updates'
Junio C Hamano [Tue, 13 Feb 2018 21:39:07 +0000 (13:39 -0800)] 
Merge branch 'ks/submodule-doc-updates'

Doc updates.

* ks/submodule-doc-updates:
  Doc/git-submodule: improve readability and grammar of a sentence
  Doc/gitsubmodules: make some changes to improve readability and syntax

6 years agoMerge branch 'cl/t9001-cleanup'
Junio C Hamano [Tue, 13 Feb 2018 21:39:07 +0000 (13:39 -0800)] 
Merge branch 'cl/t9001-cleanup'

Test clean-up.

* cl/t9001-cleanup:
  t9001: use existing helper in send-email test

6 years agoMerge branch 'gs/retire-mru'
Junio C Hamano [Tue, 13 Feb 2018 21:39:06 +0000 (13:39 -0800)] 
Merge branch 'gs/retire-mru'

Retire mru API as it does not give enough abstraction over
underlying list API to be worth it.

* gs/retire-mru:
  mru: Replace mru.[ch] with list.h implementation

6 years agoMerge branch 'ot/mru-on-list'
Junio C Hamano [Tue, 13 Feb 2018 21:39:05 +0000 (13:39 -0800)] 
Merge branch 'ot/mru-on-list'

The first step to getting rid of mru API and using the
doubly-linked list API directly instead.

* ot/mru-on-list:
  mru: use double-linked list from list.h

6 years agoMerge branch 'jh/partial-clone'
Junio C Hamano [Tue, 13 Feb 2018 21:39:04 +0000 (13:39 -0800)] 
Merge branch 'jh/partial-clone'

The machinery to clone & fetch, which in turn involves packing and
unpacking objects, have been told how to omit certain objects using
the filtering mechanism introduced by the jh/object-filtering
topic, and also mark the resulting pack as a promisor pack to
tolerate missing objects, taking advantage of the mechanism
introduced by the jh/fsck-promisors topic.

* jh/partial-clone:
  t5616: test bulk prefetch after partial fetch
  fetch: inherit filter-spec from partial clone
  t5616: end-to-end tests for partial clone
  fetch-pack: restore save_commit_buffer after use
  unpack-trees: batch fetching of missing blobs
  clone: partial clone
  partial-clone: define partial clone settings in config
  fetch: support filters
  fetch: refactor calculation of remote list
  fetch-pack: test support excluding large blobs
  fetch-pack: add --no-filter
  fetch-pack, index-pack, transport: partial clone
  upload-pack: add object filtering for partial clone

6 years agoMerge branch 'jh/fsck-promisors'
Junio C Hamano [Tue, 13 Feb 2018 21:39:03 +0000 (13:39 -0800)] 
Merge branch 'jh/fsck-promisors'

In preparation for implementing narrow/partial clone, the machinery
for checking object connectivity used by gc and fsck has been
taught that a missing object is OK when it is referenced by a
packfile specially marked as coming from trusted repository that
promises to make them available on-demand and lazily.

* jh/fsck-promisors:
  gc: do not repack promisor packfiles
  rev-list: support termination at promisor objects
  sha1_file: support lazily fetching missing objects
  introduce fetch-object: fetch one promisor object
  index-pack: refactor writing of .keep files
  fsck: support promisor objects as CLI argument
  fsck: support referenced promisor objects
  fsck: support refs pointing to promisor objects
  fsck: introduce partialclone extension
  extension.partialclone: introduce partial clone extension

6 years agoMerge branch 'ab/simplify-perl-makefile'
Junio C Hamano [Tue, 13 Feb 2018 21:39:03 +0000 (13:39 -0800)] 
Merge branch 'ab/simplify-perl-makefile'

The build procedure for perl/ part has been greatly simplified by
weaning ourselves off of MakeMaker.

* ab/simplify-perl-makefile:
  perl: treat PERLLIB_EXTRA as an extra path again
  perl: avoid *.pmc and fix Error.pm further
  Makefile: replace perl/Makefile.PL with simple make rules

6 years agoMark messages for translations
Alexander Shopov [Tue, 13 Feb 2018 13:19:15 +0000 (14:19 +0100)] 
Mark messages for translations

Small changes in messages to fit the style and typography of rest.
Reuse already translated messages if possible.
Do not translate messages aimed at developers of git.
Fix unit tests depending on the original string.
Use `test_i18ngrep` for tests with translatable strings.
Change and verify rest of tests via `make GETTEXT_POISON=1 test`.

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodocs/interpret-trailers: fix agreement error
brian m. carlson [Tue, 13 Feb 2018 02:23:52 +0000 (02:23 +0000)] 
docs/interpret-trailers: fix agreement error

In the description of git interpret-trailers, we describe "a group…of
lines" that have certain characteristics.  Ensure both options
describing this group use a singular verb for parallelism.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase: introduce and use pseudo-ref REBASE_HEAD
Nguyễn Thái Ngọc Duy [Sun, 11 Feb 2018 09:43:28 +0000 (16:43 +0700)] 
rebase: introduce and use pseudo-ref REBASE_HEAD

The new command `git rebase --show-current-patch` is useful for seeing
the commit related to the current rebase state. Some however may find
the "git show" command behind it too limiting. You may want to
increase context lines, do a diff that ignores whitespaces...

For these advanced use cases, the user can execute any command they
want with the new pseudo ref REBASE_HEAD.

This also helps show where the stopped commit is from, which is hard
to see from the previous patch which implements --show-current-patch.

Helped-by: Tim Landscheidt <tim@tim-landscheidt.de>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase: add --show-current-patch
Nguyễn Thái Ngọc Duy [Sun, 11 Feb 2018 09:43:27 +0000 (16:43 +0700)] 
rebase: add --show-current-patch

It is useful to see the full patch while resolving conflicts in a
rebase. The only way to do it now is

    less .git/rebase-*/patch

which could turn out to be a lot longer to type if you are in a
linked worktree, or not at top-dir. On top of that, an ordinary user
should not need to peek into .git directory. The new option is
provided to examine the patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoam: add --show-current-patch
Nguyễn Thái Ngọc Duy [Sun, 11 Feb 2018 09:43:26 +0000 (16:43 +0700)] 
am: add --show-current-patch

Pointing the user to $GIT_DIR/rebase-apply may encourage them to mess
around in there, which is not a good thing. With this, the user does
not have to keep the path around somewhere (because after a couple of
commands, the path may be out of scrollback buffer) when they need to
look at the patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoworktree remove: allow it when $GIT_WORK_TREE is already gone
Nguyễn Thái Ngọc Duy [Mon, 12 Feb 2018 09:49:40 +0000 (16:49 +0700)] 
worktree remove: allow it when $GIT_WORK_TREE is already gone

"git worktree remove" basically consists of two things

- delete $GIT_WORK_TREE
- delete $GIT_DIR (which is $SUPER_GIT_DIR/worktrees/something)

If $GIT_WORK_TREE is already gone for some reason, we should be able
to finish the job by deleting $GIT_DIR.

Two notes:

- $GIT_WORK_TREE _can_ be missing if the worktree is locked. In that
  case we must not delete $GIT_DIR because the real $GIT_WORK_TREE may
  be in a usb stick somewhere. This is already handled because we
  check for lock first.

- validate_worktree() is still called because it may do more checks in
  future (and it already does something else, like checking main
  worktree, but that's irrelevant in this case)

Noticed-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoworktree remove: new command
Nguyễn Thái Ngọc Duy [Mon, 12 Feb 2018 09:49:39 +0000 (16:49 +0700)] 
worktree remove: new command

This command allows to delete a worktree. Like 'move' you cannot
remove the main worktree, or one with submodules inside [1].

For deleting $GIT_WORK_TREE, Untracked files or any staged entries are
considered precious and therefore prevent removal by default. Ignored
files are not precious.

When it comes to deleting $GIT_DIR, there's no "clean" check because
there should not be any valuable data in there, except:

- HEAD reflog. There is nothing we can do about this until somebody
  steps up and implements the ref graveyard.

- Detached HEAD. Technically it can still be recovered. Although it
  may be nice to warn about orphan commits like 'git checkout' does.

[1] We do 'git status' with --ignore-submodules=all for safety
    anyway. But this needs a closer look by submodule people before we
    can allow deletion. For example, if a submodule is totally clean,
    but its repo not absorbed to the main .git dir, then deleting
    worktree also deletes the valuable .submodule repo too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoworktree move: refuse to move worktrees with submodules
Nguyễn Thái Ngọc Duy [Mon, 12 Feb 2018 09:49:38 +0000 (16:49 +0700)] 
worktree move: refuse to move worktrees with submodules

Submodules contains .git files with relative paths. After a worktree
move, these files need to be updated or they may point to nowhere.

This is a bandage patch to make sure "worktree move" don't break
people's worktrees by accident. When .git file update code is in
place, this validate_no_submodules() could be removed.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoworktree move: accept destination as directory
Nguyễn Thái Ngọc Duy [Mon, 12 Feb 2018 09:49:37 +0000 (16:49 +0700)] 
worktree move: accept destination as directory

Similar to "mv a b/", which is actually "mv a b/a", we extract basename
of source worktree and create a directory of the same name at
destination if dst path is a directory.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoworktree move: new command
Nguyễn Thái Ngọc Duy [Mon, 12 Feb 2018 09:49:36 +0000 (16:49 +0700)] 
worktree move: new command

This command allows to relocate linked worktrees. Main worktree cannot
(yet) be moved.

There are two options to move the main worktree, but both have
complications, so it's not implemented yet. Anyway the options are:

- convert the main worktree to a linked one and move it away, leave
  the git repository where it is. The repo essentially becomes bare
  after this move.

- move the repository with the main worktree. The tricky part is make
  sure all file descriptors to the repository are closed, or it may
  fail on Windows.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoworktree.c: add update_worktree_location()
Nguyễn Thái Ngọc Duy [Mon, 12 Feb 2018 09:49:35 +0000 (16:49 +0700)] 
worktree.c: add update_worktree_location()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocheck-ignore: fix mix of directories and other file types
René Scharfe [Sat, 10 Feb 2018 12:38:29 +0000 (13:38 +0100)] 
check-ignore: fix mix of directories and other file types

In check_ignore(), the first pathspec item determines the dtype for any
subsequent ones.  That means that a pathspec matching a regular file can
prevent following pathspecs from matching directories, which makes no
sense.  Fix that by determining the dtype for each pathspec separately,
by passing the value DT_UNKNOWN to last_exclude_matching() each time.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosend-email: error out when relogin delay is missing
Stefan Beller [Mon, 12 Feb 2018 19:44:04 +0000 (11:44 -0800)] 
send-email: error out when relogin delay is missing

When the batch size is neither configured nor given on the command
line, but the relogin delay is given, then the current code ignores
the relogin delay setting.

This is unsafe as there was some intention when setting the batch size.
One workaround would be to just assume a batch size of 1 as a default.
This however may be bad UX, as then the user may wonder why it is sending
slowly without apparent batching.

Error out for now instead of potentially confusing the user.
As 5453b83bdf (send-email: --batch-size to work around some SMTP
server limit, 2017-05-21) lays out, we rather want to not have this
interface anyway and would rather want to react on the server throttling
dynamically.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodescribe: confirm that blobs actually exist
Jeff King [Mon, 12 Feb 2018 17:23:06 +0000 (12:23 -0500)] 
describe: confirm that blobs actually exist

Prior to 644eb60bd0 (builtin/describe.c: describe a blob,
2017-11-15), we noticed and complained about missing
objects, since they were not valid commits:

  $ git describe 0000000000000000000000000000000000000000
  fatal: 0000000000000000000000000000000000000000 is not a valid 'commit' object

After that commit, we feed any non-commit to lookup_blob(),
and complain only if it returns NULL. But the lookup_*
functions do not actually look at the on-disk object
database at all. They return an entry from the in-memory
object hash if present (and if it matches the requested
type), and otherwise auto-create a "struct object" of the
requested type.

A missing object would hit that latter case: we create a
bogus blob struct, walk all of history looking for it, and
then exit successfully having produced no output.

One reason nobody may have noticed this is that some related
cases do still work OK:

  1. If we ask for a tree by sha1, then the call to
     lookup_commit_referecne_gently() would have parsed it,
     and we would have its true type in the in-memory object
     hash.

  2. If we ask for a name that doesn't exist but isn't a
     40-hex sha1, then get_oid() would complain before we
     even look at the objects at all.

We can fix this by replacing the lookup_blob() call with a
check of the true type via sha1_object_info(). This is not
quite as efficient as we could possibly make this check. We
know in most cases that the object was already parsed in the
earlier commit lookup, so we could call lookup_object(),
which does auto-create, and check the resulting struct's
type (or NULL).  However it's not worth the fragility nor
code complexity to save a single object lookup.

The new tests cover this case, as well as that of a
tree-by-sha1 (which does work as described above, but was
not explicitly tested).

Noticed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMakefile: suppress a sparse warning for pack-revindex.c
Ramsay Jones [Mon, 12 Feb 2018 00:21:02 +0000 (00:21 +0000)] 
Makefile: suppress a sparse warning for pack-revindex.c

Sparse has, for a long time, been issuing the following warning against
the pack-revindex.c file:

      SP pack-revindex.c
  pack-revindex.c:64:23: warning: memset with byte count of 262144

This results from a unconditional check, with a hard-coded limit, which
is really only appropriate for the kernel source code. (The check is for
a 'large' byte count in a call to memcpy(), memset(), copy_from_user()
and copy_to_user() functions).

A recent release of sparse (v0.5.1) has introduced some options to allow
this check to be turned off (-Wno-memcpy-max-count) or to specify the
actual limit used (-fmemcpy-max-count=COUNT), rather than a hard-coded
limit of 100000.

In order to suppress the warning, add a target for pack-revindex.sp that
adds the '-Wno-memcpy-max-count' option to the SPARSE_FLAGS variable.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig.mak.uname: remove SPARSE_FLAGS setting for cygwin
Ramsay Jones [Mon, 12 Feb 2018 00:20:08 +0000 (00:20 +0000)] 
config.mak.uname: remove SPARSE_FLAGS setting for cygwin

Since commit f66450ae9 ("cygwin: Remove the Win32 l/stat() implementation",
2013-06-22), the cygwin build has not used the WIN32 API/header files.
This means that the '-isystem /usr/include/w32api' option to sparse is
no longer necessary (to allow sparse to find the WIN32 header files).
In addition, the '-Wno-one-bit-signed-bitfield' option can be removed,
since the warning suppressed by that option was only provoked by a WIN32
header file.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot0002: simplify error checking
Jeff King [Sat, 10 Feb 2018 11:31:29 +0000 (06:31 -0500)] 
t0002: simplify error checking

This ancient test script does a lot of manual checking of
test conditions with "if" blocks. We can simplify this
by relying on helpers like test_must_fail.

Note that a failing "grep" call here won't produce any
verbose output, but that's OK. These days we rely on "-x" to
tell us about such commands. And in addition, these greps
are soon to be converted to test_i18ngrep (which is itself
soon learning to be more verbose).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot: document 'test_must_fail ok=<signal-name>'
SZEDER Gábor [Fri, 9 Feb 2018 02:42:33 +0000 (03:42 +0100)] 
t: document 'test_must_fail ok=<signal-name>'

Since 'test_might_fail' is implemented as a thin wrapper around
'test_must_fail', it also accepts the same options.  Mention this in
the docs as well.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoupdate-index doc: note the caveat with "could not open..."
Ævar Arnfjörð Bjarmason [Fri, 9 Feb 2018 21:04:31 +0000 (21:04 +0000)] 
update-index doc: note the caveat with "could not open..."

Note the caveat where 2.17 is stricter about index validation
potentially causing "could not open directory" warnings when git is
upgraded. See the preceding "dir.c: stop ignoring opendir() error in
open_cached_dir()" change.

This caused some mayhem when I upgraded git to a version with this
series at Booking.com, and other users have doubtless enabled the UC
extension and are in for a surprise when they upgrade. Let's give them
a headsup in the docs.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoupdate-index doc: note a fixed bug in the untracked cache
Ævar Arnfjörð Bjarmason [Fri, 9 Feb 2018 21:04:30 +0000 (21:04 +0000)] 
update-index doc: note a fixed bug in the untracked cache

Document the bug tested for in my "status: add a failing test showing
a core.untrackedCache bug" and fixed in Duy's "dir.c: fix missing dir
invalidation in untracked code".

Since this is very likely something others will encounter in the
future on older versions, and it's not obvious how to fix it let's
document both that it exists, and how to "fix" it with a one-off
command.

As noted in that commit, even though this bug gets the untracked cache
into a bad state, we have not yet found a case where this is user
visible, and thus it makes sense for these docs to focus on the
symlink case only.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohash: update obsolete reference to SHA1_HEADER
brian m. carlson [Thu, 8 Feb 2018 02:48:58 +0000 (02:48 +0000)] 
hash: update obsolete reference to SHA1_HEADER

We moved away from SHA1_HEADER to a preprocessor if chain, but didn't
update the comment discussing the platform defines.  Update this comment
so it reflects the current state of our codebase.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase -p: fix incorrect commit message when calling `git merge`.
Gregory Herrero [Thu, 8 Feb 2018 20:42:41 +0000 (21:42 +0100)] 
rebase -p: fix incorrect commit message when calling `git merge`.

Since commit dd6fb0053 ("rebase -p: fix quoting when calling `git
merge`"), commit message of the merge commit being rebased is passed to
the merge command using a subshell executing 'git rev-parse --sq-quote'.

Double quotes are needed around this subshell so that, newlines are
kept for the git merge command.

Before this patch, following merge message:

    "Merge mybranch into mynewbranch

    Awesome commit."

becomes:

    "Merge mybranch into mynewbranch Awesome commit."

after a rebase -p.

Fixes: "dd6fb0053 rebase -p: fix quoting when calling `git merge`"
Reported-by: Jamie Iles <jamie.iles@oracle.com>
Suggested-by: Vegard Nossum <vegard.nossum@oracle.com>
Suggested-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoCodingGuidelines: mention "static" and "extern"
Jeff King [Thu, 8 Feb 2018 21:38:06 +0000 (16:38 -0500)] 
CodingGuidelines: mention "static" and "extern"

It perhaps goes without saying that file-local stuff should
be marked static, but it does not hurt to remind people.

Less obvious is that we are settling on "do not include
extern in function declarations". It is already the default
unless the function was previously declared static (but if
you are following a static declaration with an unmarked one,
you should think about why you are declaring the thing
twice). And so it just becomes an extra noise-word in our
header files.

We used to give the opposite advice, so there are quite a
few "extern" markers in early Git code. But this at least
makes a concrete suggestion that we can follow going
forward.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoalways check for NULL return from packet_read_line()
Jon Simons [Thu, 8 Feb 2018 18:47:50 +0000 (13:47 -0500)] 
always check for NULL return from packet_read_line()

The packet_read_line() function will die if it sees any
protocol or socket errors. But it will return NULL for a
flush packet; some callers which are not expecting this may
dereference NULL if they get an unexpected flush. This would
involve the other side breaking protocol, but we should
flag the error rather than segfault.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocorrect error messages for NULL packet_read_line()
Jeff King [Thu, 8 Feb 2018 18:47:49 +0000 (13:47 -0500)] 
correct error messages for NULL packet_read_line()

The packet_read_line() function dies if it gets an
unexpected EOF. It only returns NULL if we get a flush
packet (or technically, a zero-length "0004" packet, but
nobody is supposed to send those, and they are
indistinguishable from a flush in this interface).

Let's correct error messages which claim an unexpected EOF;
it's really an unexpected flush packet.

While we're here, let's also check "!line" instead of
"!len" in the second case. The two events should always
coincide, but checking "!line" makes it more obvious that we
are not about to dereference NULL.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoname-hash: properly fold directory names in adjust_dirname_case()
Ben Peart [Thu, 8 Feb 2018 19:23:33 +0000 (14:23 -0500)] 
name-hash: properly fold directory names in adjust_dirname_case()

Correct the pointer arithmetic in adjust_dirname_case() so that it calls
find_dir_entry() with the correct string length.  Previously passing in
"dir1/foo" would pass a length of 6 instead of the correct 4.  This resulted in
find_dir_entry() never finding the entry and so the subsequent memcpy that would
fold the name to the version with the correct case never executed.

Add a test to validate the corrected behavior with name folding of directories.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot: make 'test_i18ngrep' more informative on failure
SZEDER Gábor [Thu, 8 Feb 2018 15:56:56 +0000 (16:56 +0100)] 
t: make 'test_i18ngrep' more informative on failure

When 'test_i18ngrep' can't find the expected pattern, it exits
completely silently; when its negated form does find the pattern that
shouldn't be there, it prints the matching line(s) but otherwise exits
without any error message.  This leaves the developer puzzled about
what could have gone wrong.

Make 'test_i18ngrep' more informative on failure by printing an error
message including the invoked 'grep' command and the contents of the
file it had to scan through.

Note that this "dump the scanned file" part is not quite perfect, as
it dumps only the file specified as the function's last positional
parameter, thus assuming that there is only a single file parameter.
I think that's a reasonable assumption to make, one that holds true in
the current code base.  And even if someone were to scan multiple
files at once in the future, the worst thing that could happen is that
the verbose error message won't include the contents of all those
files, only the last one.  Alas, we can't really do any better than
this, because checking whether the other positional parameters match a
filename can result in false positives: 't3400-rebase.sh' and
't3404-rebase-interactive.sh' contain one test each, where the
'test_i18ngrep's pattern verbatimly matches a file in the trash
directory.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot: validate 'test_i18ngrep's parameters
SZEDER Gábor [Thu, 8 Feb 2018 15:56:55 +0000 (16:56 +0100)] 
t: validate 'test_i18ngrep's parameters

Some of the previous patches in this series fixed bogus
'test_i18ngrep' invocations:

  - Two invocations where the tested git command's standard output is
    directly piped into 'test_i18ngrep'.  While convenient, this is an
    antipattern, because the pipe hides the git command's exit code,
    and the test could continue even if the command exited with error.

  - Two invocations that had neither a filename parameter nor anything
    piped into their standard input, yet both managed to remain
    unnoticed for years.  A third similarly bogus invocation is
    currently lurking in 'pu' for a couple of weeks now.

Prevent similar mistakes in the future by validating 'test_i18ngrep's
parameters requiring that

  - The last parameter names an existing file to be read, effectively
    forbidding piping into 'test_i18ngrep'.

    Note that this change will also forbid cases where 'test_i18ngrep'
    would legitimately read its standard input, e.g. when its standard
    input is redirected from a file, or when a git command's standard
    output is first written to an intermediate file, which is then
    preprocessed by a non-git command before the results are piped
    into 'test_i18ngrep'.  See two of the previous patches for the
    only such cases we had in our test suite.  However, reliably
    preventing the piping antipattern is arguably more important than
    supporting these cases, which can be easily worked around by
    opening the file directly or using an intermediate file anyway.

  - There are at least two parameters, not including the optional '!'
    to negate the pattern.  This ought to catch corner cases when
    'test_i18ngrep' looks for the name of an existing file on its
    standard input; the above check would miss this case becase the
    filename as pattern would be the last parameter.

    Note that this is not quite perfect, as it doesn't account for any
    'grep --options' given as parameters.  However, doing so would be
    far too complicated, considering that patterns can start with
    dashes as well, and in the majority of the cases we don't use any
    such options anyway.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'
SZEDER Gábor [Thu, 8 Feb 2018 15:56:54 +0000 (16:56 +0100)] 
t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'

Both 'test_i18ncmp' and 'test_i18ngrep' helper functions are supposed
to be called from our test scripts, so they should be in
'test-lib-functions.sh'.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5536: let 'test_i18ngrep' read the file without redirection
SZEDER Gábor [Thu, 8 Feb 2018 15:56:53 +0000 (16:56 +0100)] 
t5536: let 'test_i18ngrep' read the file without redirection

Redirecting 'test_i18ngrep's standard input from a file will interfere
with the linting that will be added in a later patch.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5510: consolidate 'grep' and 'test_i18ngrep' patterns
SZEDER Gábor [Thu, 8 Feb 2018 15:56:52 +0000 (16:56 +0100)] 
t5510: consolidate 'grep' and 'test_i18ngrep' patterns

One of the tests in 't5510-fetch.sh' checks the output of 'git fetch'
using 'test_i18ngrep', and while doing so it prefilters the output
with 'grep' before piping the result into 'test_i18ngrep'.

This prefiltering is unnecessary, with the appropriate pattern
'test_i18ngrep' can do it all by itself.  Furthermore, piping data
into 'test_i18ngrep' will interfere with the linting that will be
added in a later patch.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot4001: don't run 'git status' upstream of a pipe
SZEDER Gábor [Thu, 8 Feb 2018 15:56:51 +0000 (16:56 +0100)] 
t4001: don't run 'git status' upstream of a pipe

The primary purpose of three tests in 't4001-diff-rename.sh' is to
check rename detection in 'git status', but all three do so by running
'git status' upstream of a pipe, hiding its exit code.  Consequently,
the test could continue even if 'git status' exited with error.

Use an intermediate file between 'git status' and 'test_i18ngrep' to
catch a potential failure of the former.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot6022: don't run 'git merge' upstream of a pipe
SZEDER Gábor [Thu, 8 Feb 2018 15:56:50 +0000 (16:56 +0100)] 
t6022: don't run 'git merge' upstream of a pipe

The primary purpose of 't6022-merge-rename.sh' is to test 'git merge',
but one of the tests runs it upstream of a pipe, hiding its exit code.
Consequently, the test could continue even if 'git merge' exited with
error.

Use an intermediate file between 'git merge' and 'test_i18ngrep' to
catch a potential failure of the former.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5812: add 'test_i18ngrep's missing filename parameter
SZEDER Gábor [Thu, 8 Feb 2018 15:56:49 +0000 (16:56 +0100)] 
t5812: add 'test_i18ngrep's missing filename parameter

The second 'test_i18ngrep' invocation in the test 'curl redirects
respect whitelist' is missing its filename parameter.  This has
remained unnoticed since its introduction in f4113cac0 (http: limit
redirection to protocol-whitelist, 2015-09-22), because it would only
cause the test to fail if Git was built with a sufficiently old
libcurl version.  The test's two ||-chained 'test_i18ngrep'
invocations are supposed to check that either one of the two patterns
is present in 'git clone's error message.  As it happens, the first
invocation covers the error message from any reasonably up-to-date
libcurl, thus the second invocation, the one without the filename
parameter, isn't executed at all.  Apparently no one has run the test
suite's httpd tests with such an old libcurl in the last 2+ years, or
at least they haven't bothered to notify us about the failed test.

Fix this by consolidating the two patterns into a single extended
regexp, eliminating the need for an ||-chained second 'test_i18ngrep'
invocation.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5541: add 'test_i18ngrep's missing filename parameter
SZEDER Gábor [Thu, 8 Feb 2018 15:56:48 +0000 (16:56 +0100)] 
t5541: add 'test_i18ngrep's missing filename parameter

The test 'push --no-progress silences progress but not status' runs
'test_i18ngrep' without specifying a filename parameter.  This has
remained unnoticed since its introduction in e304aeba2 (t5541: test
more combinations of --progress, 2012-05-01), because that
'test_i18ngrep' is supposed to check that the given pattern is not
present in its input, and of course it won't find that pattern if its
input is empty (as it comes from /dev/null).  This also means that
this test could miss a potential breakage of 'git push --no-progress'.

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