git/git-svn.git
7 years agoref-filter: limit traversal to prefix
Jeff King [Mon, 22 May 2017 14:17:54 +0000 (22 16:17 +0200)]
ref-filter: limit traversal to prefix

When we are matching refnames against a pattern, then we know that the
beginning of any refname that can match the pattern has to match the
part of the pattern up to the first glob character. For example, if
the pattern is `refs/heads/foo*bar`, then it can only match a
reference that has the prefix `refs/heads/foo`.

So pass that prefix to `for_each_fullref_in()`. This lets the ref code
avoid passing us the full set of refs, and in some cases avoid reading
them in the first place.

Note that this applies only when the `match_as_path` flag is set
(i.e., when `for-each-ref` is the caller), as the matching rules for
git-branch and git-tag are subtly different.

This could be generalized to the case of multiple patterns, but (a) it
probably doesn't come up that often, and (b) it is more awkward to
deal with multiple patterns (e.g., the patterns might not be
disjoint). So, since this is just an optimization, punt on the case of
multiple patterns.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocreate_ref_entry(): remove `check_name` option
Michael Haggerty [Mon, 22 May 2017 14:17:53 +0000 (22 16:17 +0200)]
create_ref_entry(): remove `check_name` option

Only one caller was using it, so move the check to that caller.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs_ref_iterator_begin(): handle `GIT_REF_PARANOIA`
Michael Haggerty [Mon, 22 May 2017 14:17:52 +0000 (22 16:17 +0200)]
refs_ref_iterator_begin(): handle `GIT_REF_PARANOIA`

Instead of handling `GIT_REF_PARANOIA` in
`files_ref_iterator_begin()`, handle it in
`refs_ref_iterator_begin()`, where it will cover all reference stores.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoread_packed_refs(): report unexpected fopen() failures
Michael Haggerty [Mon, 22 May 2017 14:17:51 +0000 (22 16:17 +0200)]
read_packed_refs(): report unexpected fopen() failures

The old code ignored any errors encountered when trying to fopen the
"packed-refs" file, treating all such failures as if the file didn't
exist. But it could be that there is some other error opening the
file (e.g., permissions problems), and we don't want to silently
ignore such problems. So report any failures that are not due to
ENOENT.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoread_packed_refs(): do more of the work of reading packed refs
Michael Haggerty [Mon, 22 May 2017 14:17:50 +0000 (22 16:17 +0200)]
read_packed_refs(): do more of the work of reading packed refs

Teach `read_packed_refs()` to also

* Allocate and initialize the new `packed_ref_cache`
* Open and close the `packed-refs` file
* Update the `validity` field of the new object

This decreases the coupling between `packed_refs_cache` and
`files_ref_store` by a little bit.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoget_packed_ref_cache(): assume "packed-refs" won't change while locked
Michael Haggerty [Mon, 22 May 2017 14:17:49 +0000 (22 16:17 +0200)]
get_packed_ref_cache(): assume "packed-refs" won't change while locked

If we've got the "packed-refs" file locked, then it can't change;
there's no need to keep calling `stat_validity_check()` on it.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoshould_pack_ref(): new function, extracted from `files_pack_refs()`
Michael Haggerty [Mon, 22 May 2017 14:17:48 +0000 (22 16:17 +0200)]
should_pack_ref(): new function, extracted from `files_pack_refs()`

Extract a function for deciding whether a reference should be packed.
It is a self-contained bit of logic, so splitting it out improves
readability.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref_update_reject_duplicates(): add a sanity check
Michael Haggerty [Mon, 22 May 2017 14:17:47 +0000 (22 16:17 +0200)]
ref_update_reject_duplicates(): add a sanity check

It's pretty cheap to make sure that the caller didn't pass us an
unsorted list by accident, so do so.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref_update_reject_duplicates(): use `size_t` rather than `int`
Michael Haggerty [Mon, 22 May 2017 14:17:46 +0000 (22 16:17 +0200)]
ref_update_reject_duplicates(): use `size_t` rather than `int`

Eliminate a theoretical risk of integer overflow if the two types have
different sizes.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref_update_reject_duplicates(): expose function to whole refs module
Michael Haggerty [Mon, 22 May 2017 14:17:45 +0000 (22 16:17 +0200)]
ref_update_reject_duplicates(): expose function to whole refs module

It will soon have some other users.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref_transaction_prepare(): new optional step for reference updates
Michael Haggerty [Mon, 22 May 2017 14:17:44 +0000 (22 16:17 +0200)]
ref_transaction_prepare(): new optional step for reference updates

In the future, compound reference stores will sometimes need to modify
references in two different reference stores at the same time, meaning
that a single logical reference transaction might have to be
implemented as two internal sub-transactions. They won't want to call
`ref_transaction_commit()` for the two sub-transactions one after the
other, because that wouldn't be atomic (the first commit could succeed
and the second one fail). Instead, they will want to prepare both
sub-transactions (i.e., obtain any necessary locks and do any
pre-checks), and only if both prepare steps succeed, then commit both
sub-transactions.

Start preparing for that day by adding a new, optional
`ref_transaction_prepare()` step to the reference transaction
sequence, which obtains the locks and does any prechecks, reporting
any errors that occur. Also add a `ref_transaction_abort()` function
that can be used to abort a sub-transaction even if it has already
been prepared.

That is on the side of the public-facing API. On the side of the
`ref_store` VTABLE, get rid of `transaction_commit` and instead add
methods `transaction_prepare`, `transaction_finish`, and
`transaction_abort`. A `ref_transaction_commit()` now basically calls
methods `transaction_prepare` then `transaction_finish`.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref_transaction_commit(): check for valid `transaction->state`
Michael Haggerty [Mon, 22 May 2017 14:17:43 +0000 (22 16:17 +0200)]
ref_transaction_commit(): check for valid `transaction->state`

Move the check that `transaction->state` is valid from
`files_transaction_commit()` to `ref_transaction_commit()`, where
other future reference backends can benefit from it as well.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles_transaction_cleanup(): new helper function
Michael Haggerty [Mon, 22 May 2017 14:17:42 +0000 (22 16:17 +0200)]
files_transaction_cleanup(): new helper function

Extract the cleanup functionality from `files_transaction_commit()`
into a new function. It will soon have another caller.

Use the common cleanup code even on early exit if the transaction is
empty, to reduce code duplication.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles_ref_store: put the packed files lock directly in this struct
Michael Haggerty [Mon, 22 May 2017 14:17:41 +0000 (22 16:17 +0200)]
files_ref_store: put the packed files lock directly in this struct

Instead of using a global `lock_file` instance for the main
"packed-refs" file and using a pointer in `files_ref_store` to keep
track of whether it is locked, embed the `lock_file` instance directly
in the `files_ref_store` struct and use the new
`is_lock_file_locked()` function to keep track of whether it is
locked. This keeps related data together and makes the main reference
store less of a special case.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: move `lock` member to `files_ref_store`
Michael Haggerty [Mon, 22 May 2017 14:17:40 +0000 (22 16:17 +0200)]
files-backend: move `lock` member to `files_ref_store`

Move the `lock` member from `packed_ref_cache` to `files_ref_store`,
since at most one cache can have a locked "packed-refs" file
associated with it. Rename it to `packed_refs_lock` to make its
purpose clearer in its new home. More changes are coming here shortly.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agolockfile: add a new method, is_lock_file_locked()
Michael Haggerty [Mon, 22 May 2017 14:17:39 +0000 (22 16:17 +0200)]
lockfile: add a new method, is_lock_file_locked()

It will soon prove useful.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref_store: take a `msg` parameter when deleting references
Michael Haggerty [Mon, 22 May 2017 14:17:38 +0000 (22 16:17 +0200)]
ref_store: take a `msg` parameter when deleting references

Just because the files backend can't retain reflogs for deleted
references is no reason that they shouldn't be supported by the
virtual method interface. Also, `delete_ref()` and `refs_delete_ref()`
have already gained `msg` parameters. Now let's add them to
`delete_refs()` and `refs_delete_refs()`.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs: use `size_t` indexes when iterating over ref transaction updates
Michael Haggerty [Mon, 22 May 2017 14:17:37 +0000 (22 16:17 +0200)]
refs: use `size_t` indexes when iterating over ref transaction updates

Eliminate any chance of integer overflow on platforms where the two
types have different sizes.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs_ref_iterator_begin(): don't check prefixes redundantly
Michael Haggerty [Mon, 22 May 2017 14:17:36 +0000 (22 16:17 +0200)]
refs_ref_iterator_begin(): don't check prefixes redundantly

The backend already correctly restricts its output to references whose
names start with the prefix. By passing the prefix again to
`prefix_ref_iterator`, we were forcing that iterator to do redundant
prefix comparisons. So set it to the empty string.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoprefix_ref_iterator: don't trim too much
Michael Haggerty [Mon, 22 May 2017 14:17:35 +0000 (22 16:17 +0200)]
prefix_ref_iterator: don't trim too much

The `trim` parameter can be set independently of `prefix`. So if some
caller were to set `trim` to be greater than `strlen(prefix)`, we
could end up pointing the `refname` field of the iterator past the NUL
of the actual reference name string.

That can't happen currently, because `trim` is always set either to
zero or to `strlen(prefix)`. But even the latter could lead to
confusion, if a refname is exactly equal to the prefix, because then
we would set the outgoing `refname` to the empty string.

And we're about to decouple the `prefix` and `trim` arguments even
more, so let's be cautious here. Report a bug if ever asked to trim a
reference whose name is not longer than `trim`.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: use `die("BUG: ...")`, not `die("internal error: ...")`
Michael Haggerty [Mon, 22 May 2017 14:17:34 +0000 (22 16:17 +0200)]
files-backend: use `die("BUG: ...")`, not `die("internal error: ...")`

The former is by far more common in our codebase.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref_iterator_begin_fn(): fix docstring
Michael Haggerty [Mon, 22 May 2017 14:17:33 +0000 (22 16:17 +0200)]
ref_iterator_begin_fn(): fix docstring

The iterator returned by this function only includes references whose
names start with the whole prefix, not all of those in
`find_containing_dir(prefix)` as the old docstring claimed. This
docstring was probably copy-pasted from old ref-cache code, which had
the old specification. But now, `cache_ref_iterator_begin()`
(from which the files reference iterator gets its values)
automatically wraps its output using `prefix_ref_iterator_begin()`
when necessary, so it has the stricter behavior.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs.h: clarify docstring for the ref_transaction_update()-related fns
Michael Haggerty [Mon, 22 May 2017 14:17:32 +0000 (22 16:17 +0200)]
refs.h: clarify docstring for the ref_transaction_update()-related fns

In particular, make it clear that they make copies of the sha1
arguments.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot3600: clean up permissions test properly
Michael Haggerty [Mon, 22 May 2017 14:17:31 +0000 (22 16:17 +0200)]
t3600: clean up permissions test properly

The test of failing `git rm -f` removes the write permissions on the
test directory, but fails to restore them if the test fails. This
means that the test temporary directory cannot be cleaned up, which
means that subsequent attempts to run the test fail mysteriously.

Instead, do the cleanup in a `test_when_finished` block so that it
can't be skipped.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'bc/object-id'
Junio C Hamano [Tue, 23 May 2017 05:29:19 +0000 (23 14:29 +0900)]
Merge branch 'bc/object-id'

* bc/object-id: (53 commits)
  object: convert parse_object* to take struct object_id
  tree: convert parse_tree_indirect to struct object_id
  sequencer: convert do_recursive_merge to struct object_id
  diff-lib: convert do_diff_cache to struct object_id
  builtin/ls-tree: convert to struct object_id
  merge: convert checkout_fast_forward to struct object_id
  sequencer: convert fast_forward_to to struct object_id
  builtin/ls-files: convert overlay_tree_on_cache to object_id
  builtin/read-tree: convert to struct object_id
  sha1_name: convert internals of peel_onion to object_id
  upload-pack: convert remaining parse_object callers to object_id
  revision: convert remaining parse_object callers to object_id
  revision: rename add_pending_sha1 to add_pending_oid
  http-push: convert process_ls_object and descendants to object_id
  refs/files-backend: convert many internals to struct object_id
  refs: convert struct ref_update to use struct object_id
  ref-filter: convert some static functions to struct object_id
  Convert struct ref_array_item to struct object_id
  Convert the verify_pack callback to struct object_id
  Convert lookup_tag to struct object_id
  ...

7 years agoDocumentation: fix reference to ifExists for interpret-trailers
Andreas Heiduk [Mon, 22 May 2017 19:45:33 +0000 (22 21:45 +0200)]
Documentation: fix reference to ifExists for interpret-trailers

The manual for "git interpret-trailers" mentioned a non-existing
literal `overwrite` for its config option `trailer.ifexists`.  The
correct name for that choice is `replace`.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot5531: fix test description
Stefan Beller [Mon, 22 May 2017 19:01:14 +0000 (22 12:01 -0700)]
t5531: fix test description

The description of the test was not enclosed in single quotes, which
broke the coloring scheme that I am used to.  Upon closer inspection
the test is good, but the description is a bit vague. So extend the
description of the first test.

While at it align the description of the file to match what we actually
test in the file.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoSecond batch for 2.14
Junio C Hamano [Tue, 23 May 2017 04:51:32 +0000 (23 13:51 +0900)]
Second batch for 2.14

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'ab/fix-poison-tests'
Junio C Hamano [Tue, 23 May 2017 04:46:08 +0000 (23 13:46 +0900)]
Merge branch 'ab/fix-poison-tests'

Update tests to pass under GETTEXT_POISON (a mechanism to ensure
that output strings that should not be translated are not
translated by mistake), and tell TravisCI to run them.

* ab/fix-poison-tests:
  travis-ci: add job to run tests with GETTEXT_POISON
  travis-ci: setup "prove cache" in "script" step
  tests: fix tests broken under GETTEXT_POISON=YesPlease

7 years agoMerge branch 'tb/dedup-crlf-tests'
Junio C Hamano [Tue, 23 May 2017 04:46:07 +0000 (23 13:46 +0900)]
Merge branch 'tb/dedup-crlf-tests'

* tb/dedup-crlf-tests:
  t0027: tests are not expensive; remove t0025

7 years agoMerge branch 'jt/push-options-doc'
Junio C Hamano [Tue, 23 May 2017 04:46:07 +0000 (23 13:46 +0900)]
Merge branch 'jt/push-options-doc'

The receive-pack program now makes sure that the push certificate
records the same set of push options used for pushing.

* jt/push-options-doc:
  receive-pack: verify push options in cert
  docs: correct receive.advertisePushOptions default

7 years agoMerge branch 'ab/doc-replace-gmane-links'
Junio C Hamano [Tue, 23 May 2017 04:46:05 +0000 (23 13:46 +0900)]
Merge branch 'ab/doc-replace-gmane-links'

The Web interface to gmane news archive is long gone, even though
the articles are still accessible via NTTP.  Replace the links with
ones to public-inbox.org.  Because their message identification is
based on the actual message-id, it is likely that it will be easier
to migrate away from it if/when necessary.

* ab/doc-replace-gmane-links:
  doc: replace more gmane links
  doc: replace a couple of broken gmane links

7 years agoMerge branch 'rs/checkout-am-fix-unborn'
Junio C Hamano [Tue, 23 May 2017 04:46:05 +0000 (23 13:46 +0900)]
Merge branch 'rs/checkout-am-fix-unborn'

A few codepaths in "checkout" and "am" working on an unborn branch
tried to access an uninitialized piece of memory.

* rs/checkout-am-fix-unborn:
  am: check return value of resolve_refdup before using hash
  checkout: check return value of resolve_refdup before using hash

7 years agoMerge branch 'ls/travis-relays-for-windows-ci'
Junio C Hamano [Tue, 23 May 2017 04:46:03 +0000 (23 13:46 +0900)]
Merge branch 'ls/travis-relays-for-windows-ci'

* ls/travis-relays-for-windows-ci:
  travis-ci: retry if Git for Windows CI returns HTTP error 502 or 503
  travis-ci: handle Git for Windows CI status "failed" explicitly

7 years agoMerge branch 'ah/log-decorate-default-to-auto'
Junio C Hamano [Tue, 23 May 2017 04:46:02 +0000 (23 13:46 +0900)]
Merge branch 'ah/log-decorate-default-to-auto'

Setting "log.decorate=false" in the configuration file did not take
effect in v2.13, which has been corrected.

* ah/log-decorate-default-to-auto:
  builtin/log: honor log.decorate

7 years agoMerge branch 'bw/submodule-with-bs-path'
Junio C Hamano [Tue, 23 May 2017 04:46:01 +0000 (23 13:46 +0900)]
Merge branch 'bw/submodule-with-bs-path'

A hotfix to a topic that is already in v2.13.

* bw/submodule-with-bs-path:
  t7400: add !CYGWIN prerequisite to 'add with \\ in path'

7 years agodir: expose cmp_name() and check_contains()
Samuel Lijin [Thu, 18 May 2017 08:21:53 +0000 (18 04:21 -0400)]
dir: expose cmp_name() and check_contains()

We want to use cmp_name() and check_contains() (which both compare
`struct dir_entry`s, the former in terms of the sort order, the latter
in terms of whether one lexically contains another) outside of dir.c,
so we have to (1) change their linkage and (2) rename them as
appropriate for the global namespace. The second is achieved by
renaming cmp_name() to cmp_dir_entry() and check_contains() to
check_dir_entry_contains().

Signed-off-by: Samuel Lijin <sxlijin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodir: hide untracked contents of untracked dirs
Samuel Lijin [Thu, 18 May 2017 08:21:52 +0000 (18 04:21 -0400)]
dir: hide untracked contents of untracked dirs

When we taught read_directory_recursive() to recurse into untracked
directories in search of ignored files given DIR_SHOW_IGNORED_TOO, that
had the side effect of teaching it to collect the untracked contents of
untracked directories. It doesn't always make sense to return these,
though (we do need them for `clean -d`), so we introduce a flag
(DIR_KEEP_UNTRACKED_CONTENTS) to control whether or not read_directory()
strips dir->entries of the untracked contents of untracked dirs.

We also introduce check_contains() to check if one dir_entry corresponds
to a path which contains the path corresponding to another dir_entry.

This also fixes known breakages in t7061, since status --ignored now
searches untracked directories for ignored files.

Signed-off-by: Samuel Lijin <sxlijin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodir: recurse into untracked dirs for ignored files
Samuel Lijin [Thu, 18 May 2017 08:21:51 +0000 (18 04:21 -0400)]
dir: recurse into untracked dirs for ignored files

We consider directories containing only untracked and ignored files to
be themselves untracked, which in the usual case means we don't have to
search these directories. This is problematic when we want to collect
ignored files with DIR_SHOW_IGNORED_TOO, though, so we teach
read_directory_recursive() to recurse into untracked directories to find
the ignored files they contain when DIR_SHOW_IGNORED_TOO is set. This
has the side effect of also collecting all untracked files in untracked
directories as well.

Signed-off-by: Samuel Lijin <sxlijin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7061: status --ignored should search untracked dirs
Samuel Lijin [Thu, 18 May 2017 08:21:50 +0000 (18 04:21 -0400)]
t7061: status --ignored should search untracked dirs

Per eb8c5b87, `status --ignored` by design does not list ignored files
if they are in a directory which contains only ignored and untracked
files (which is itself considered to be untracked) without `-uall`. This
does not make sense for `--ignored`, which claims to "Show ignored files
as well."

Thus we revisit eb8c5b87 and decide that for such directories, `status
--ignored` will list the directory as untracked *and* list all ignored
files within said directory even without `-uall`.

Signed-off-by: Samuel Lijin <sxlijin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7300: clean -d should skip dirs with ignored files
Samuel Lijin [Thu, 18 May 2017 08:21:49 +0000 (18 04:21 -0400)]
t7300: clean -d should skip dirs with ignored files

If git sees a directory which contains only untracked and ignored
files, clean -d should not remove that directory. It was recently
discovered that this is *not* true of git clean -d, and it's possible
that this has never worked correctly; this test and its accompanying
patch series aims to fix that.

Signed-off-by: Samuel Lijin <sxlijin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agousage: add NORETURN to BUG() function definitions
Ramsay Jones [Sun, 21 May 2017 22:25:39 +0000 (21 23:25 +0100)]
usage: add NORETURN to BUG() function definitions

Commit d8193743e0 ("usage.c: add BUG() function", 12-05-2017) added the
BUG() functions and macros as a replacement for calls to die("BUG: ..").
The use of NORETURN on the declarations (in git-compat-util.h) and the
lack of NORETURN on the function definitions, however, leads sparse to
complain thus:

      SP usage.c
  usage.c:220:6: error: symbol 'BUG_fl' redeclared with different type
  (originally declared at git-compat-util.h:1074) - different modifiers

In order to suppress the sparse error, add the NORETURN to the function
definitions.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosha1dc: update from upstream
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 11:54:28 +0000 (20 11:54 +0000)]
sha1dc: update from upstream

Update sha1dc from the latest version by the upstream
maintainer[1].

This version includes a commit of mine which allows for replacing the
local modifications done to the upstream files in git.git with macro
definitions to monkeypatch it in place.

It also brings in a change[2] upstream made for the breakage 2.13.0
introduced on SPARC and other platforms that forbid unaligned
access[3].

This means that the code customizations done since the initial import
in commit 28dc98e343 ("sha1dc: add collision-detecting sha1
implementation", 2017-03-16) can be done purely via Makefile
definitions and by including the content of our own sha1dc_git.[ch] in
sha1dc/sha1.c via a macro.

1. https://github.com/cr-marcstevens/sha1collisiondetection/commit/cc465543b310e5f59a1d534381690052e8509b22
2. https://github.com/cr-marcstevens/sha1collisiondetection/commit/33a694a9ee1b79c24be45f9eab5ac0e1aeeaf271
3. "Git 2.13.0 segfaults on Solaris SPARC due to DC_SHA1=YesPlease
   being on by default"
   (https://public-inbox.org/git/CACBZZX6nmKK8af0-UpjCKWV4R+hV-uk2xWXVA5U+_UQ3VXU03g@mail.gmail.com/)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoperf: emit progress output when unpacking & building
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:19 +0000 (20 21:42 +0000)]
perf: emit progress output when unpacking & building

Amend the t/perf/run output so that in addition to the "Running N
tests" heading currently being emitted, it also emits "Unpacking $rev"
and "Building $rev" when setting up the build/$rev directory & when
building it, respectively.

This makes it easier to see what's going on and what revision is being
tested as the output scrolls by.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoperf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't do
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:18 +0000 (20 21:42 +0000)]
perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't do

Add a git GIT_PERF_MAKE_COMMAND variable to compliment the existing
GIT_PERF_MAKE_OPTS facility. This allows specifying an arbitrary shell
command to execute instead of 'make'.

This is useful e.g. in cases where the name, semantics or defaults of
a Makefile flag have changed over time. It can even be used to change
the contents of the tree, useful for monkeypatching ancient versions
of git to get them to build.

This opens Pandora's box in some ways, it's now possible to
"jailbreak" the perf environment and e.g. modify the source tree via
this arbitrary instead of just issuing a custom "make" command, such a
command has to be re-entrant in the sense that subsequent perf runs
will re-use the possibly modified tree.

It would be pointless to try to mitigate or work around that caveat in
a tool purely aimed at Git developers, so this change makes no attempt
to do so.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: add tests to fix blind spots with \0 patterns
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:17 +0000 (20 21:42 +0000)]
grep: add tests to fix blind spots with \0 patterns

Address a big blind spot in the tests for patterns containing \0. The
is_fixed() function considers any string that contains \0 fixed, even
if it contains regular expression metacharacters, those patterns are
currently matched with kwset.

Before this change removing that memchr(s, 0, len) check from
is_fixed() wouldn't change the result of any of the tests, since
regcomp() will happily match the part before the \0.

The kwset path is dependent on whether the the -i flag is on, and
whether the pattern has any non-ASCII characters, but none of this was
tested for.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: prepare for testing binary regexes containing rx metacharacters
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:16 +0000 (20 21:42 +0000)]
grep: prepare for testing binary regexes containing rx metacharacters

Add setup code needed for testing regexes that contain both binary
data and regex metacharacters.

The POSIX regcomp() function inherently can't support that, because it
takes a \0-delimited char *, but other regex engines APIs like PCRE v2
take a pattern/length pair, and are thus able to handle \0s in
patterns as well as any other character.

When kwset was imported in commit 9eceddeec6 ("Use kwset in grep",
2011-08-21) this limitation was fixed, but at the expense of
introducing the undocumented limitation that any pattern containing \0
implicitly becomes a fixed match (equivalent to -F having been
provided).

That's not something we'd like to keep in the future. The inability to
match patterns containing \0 is a leaky implementation detail.

So add tests as a first step towards changing that. In order to test
that \0-patterns can properly match as regexes the test string needs
to have some regex metacharacters in it.

There were other blind spots in the tests. The code around kwset
specially handles case-insensitive & non-ASCII data, but there were no
tests for this.

Fix all of that by amending the text being matched to contain both
regex metacharacters & non-ASCII data.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: add a test helper function for less verbose -f \0 tests
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:15 +0000 (20 21:42 +0000)]
grep: add a test helper function for less verbose -f \0 tests

Add a helper function to make the tests which check for patterns with
\0 in them more succinct. Right now this isn't a big win, but
subsequent commits will add a lot more of these tests.

The helper is based on the match() function in t3070-wildmatch.sh.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: add tests for grep pattern types being passed to submodules
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:14 +0000 (20 21:42 +0000)]
grep: add tests for grep pattern types being passed to submodules

Add testing for grep pattern types being correctly passed to
submodules. The pattern "(.|.)[\d]" matches differently under
fixed (not at all), and then matches different lines under
basic/extended & perl regular expressions, so this change asserts that
the pattern type is passed along correctly.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: amend submodule recursion test for regex engine testing
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:13 +0000 (20 21:42 +0000)]
grep: amend submodule recursion test for regex engine testing

Amend the submodule recursion test to prepare it for subsequent tests
of whether it passes along the grep.patternType to the submodule
greps.

This is the result of searching & replacing:

    foobar -> (1|2)d(3|4)
    foo    -> (1|2)
    bar    -> (3|4)

Currently there's no tests for whether e.g. -P or -E is correctly
passed along, tests for that will be added in a follow-up change, but
first add content to the tests which will match differently under
different regex engines.

Reuse the pattern established in an earlier commit of mine in this
series ("log: add exhaustive tests for pattern style options &
config", 2017-04-07). The pattern "(.|.)[\d]" will match this content
differently under fixed/basic/extended & perl.

This test code was originally added in commit 0281e487fd ("grep:
optionally recurse into submodules", 2016-12-16).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: add tests for --threads=N and grep.threads
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:12 +0000 (20 21:42 +0000)]
grep: add tests for --threads=N and grep.threads

Add tests for --threads=N being supplied on the command-line, or when
grep.threads=N being supplied in the configuration.

When the threading support was made run-time configurable in commit
89f09dd34e ("grep: add --threads=<num> option and grep.threads
configuration", 2015-12-15) no tests were added for it.

In developing a change to the grep code I was able to make
'--threads=1 <pat>` segfault, while the test suite still passed. This
change fixes that blind spot in the tests.

In addition to asserting that asking for N threads shouldn't segfault,
test that the grep output given any N is the same.

The choice to test only 1..10 as opposed to 1..8 or 1..16 or whatever
is arbitrary. Testing 1..1024 works locally for me (but gets
noticeably slower as more threads are spawned). Given the structure of
the code there's no reason to test an arbitrary number of threads,
only 0, 1 and >=2 are special modes of operation.

A later patch introduces a PTHREADS test prerequisite which is true
under NO_PTHREADS=UnfortunatelyYes, but even under NO_PTHREADS it's
fine to test --threads=N, we'll just ignore it and not use
threading. So these tests also make sense under that mode to assert
that --threads=N without pthreads still returns expected results.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: change non-ASCII -i test to stop using --debug
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:11 +0000 (20 21:42 +0000)]
grep: change non-ASCII -i test to stop using --debug

Change a non-ASCII case-insensitive test case to stop using --debug,
and instead simply test for the expected results.

The test coverage remains the same with this change, but the test
won't break due to internal refactoring.

This test was added in commit 793dc676e0 ("grep/icase: avoid kwsset
when -F is specified", 2016-06-25). It was asserting that the regex
must be compiled with compile_fixed_regexp(), instead test for the
expected results, allowing the underlying implementation to change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: add a test for backreferences in PCRE patterns
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:10 +0000 (20 21:42 +0000)]
grep: add a test for backreferences in PCRE patterns

Add a test for backreferences such as (.)\1 in PCRE patterns. This
test ensures that the PCRE_NO_AUTO_CAPTURE option isn't turned
on. Before this change turning it on would break these sort of
patterns, but wouldn't break any tests.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: add a test asserting that --perl-regexp dies when !PCRE
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:09 +0000 (20 21:42 +0000)]
grep: add a test asserting that --perl-regexp dies when !PCRE

Add a test asserting that when --perl-regexp (and -P for grep) is
given to git-grep & git-log that we die with an error.

In developing the PCRE v2 series I introduced a regression where -P
would (through control-flow fall-through) become synonymous with basic
POSIX matching. I.e. 'git grep -P '[\d]' would match "d" instead of
digits.

The entire test suite would still pass with this serious regression,
since everything that tested for --perl-regexp would be guarded by the
PCRE prerequisite, fix that blind-spot by adding tests under !PCRE
asserting that git must die when given --perl-regexp or -P.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agolog: make --regexp-ignore-case work with --perl-regexp
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:08 +0000 (20 21:42 +0000)]
log: make --regexp-ignore-case work with --perl-regexp

Make the --regexp-ignore-case option work with --perl-regexp. This
never worked, and there was no test for this. Fix the bug and add a
test.

When PCRE support was added in commit 63e7e9d8b6 ("git-grep: Learn
PCRE", 2011-05-09) compile_pcre_regexp() would only check
opt->ignore_case, but when the --perl-regexp option was added in
commit 727b6fc3ed ("log --grep: accept --basic-regexp and
--perl-regexp", 2012-10-03) the code didn't set the opt->ignore_case.

Change the test suite to test for -i and --invert-regexp with
basic/extended/perl patterns in addition to fixed, which was the only
patternType that was tested for before in combination with those
options.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agolog: add exhaustive tests for pattern style options & config
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:07 +0000 (20 21:42 +0000)]
log: add exhaustive tests for pattern style options & config

Add exhaustive tests for how the different grep.patternType options &
the corresponding command-line options affect git-log.

Before this change it was possible to patch revision.c so that the
--basic-regexp option was synonymous with --extended-regexp, and
--perl-regexp wasn't recognized at all, and still have 100% of the
test suite pass.

This was because the first test being modified here, added in commit
34a4ae55b2 ("log --grep: use the same helper to set -E/-F options as
"git grep"", 2012-10-03), didn't actually check whether we'd enabled
extended regular expressions as distinct from re-toggling non-fixed
string support.

Fix that by changing the pattern to a pattern that'll only match if
--extended-regexp option is provided, but won't match under the
default --basic-regexp option.

Other potential regressions were possible since there were no tests
for the rest of the combinations of grep.patternType configuration
toggles & corresponding git-log command-line options. Add exhaustive
tests for those.

The patterns being passed to fixed/basic/extended/PCRE are carefully
crafted to return the wrong thing if the grep engine were to pick any
other matching method than the one it's told to use.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotest-lib: rename the LIBPCRE prerequisite to PCRE
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:06 +0000 (20 21:42 +0000)]
test-lib: rename the LIBPCRE prerequisite to PCRE

Rename the LIBPCRE prerequisite to PCRE. This is for preparation for
libpcre2 support, where having just "LIBPCRE" would be confusing as it
implies v1 of the library.

None of these tests are incompatible between versions 1 & 2 of
libpcre, it's less confusing to give them a more general name to make
it clear that they work on both library versions.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep & rev-list doc: stop promising libpcre for --perl-regexp
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:05 +0000 (20 21:42 +0000)]
grep & rev-list doc: stop promising libpcre for --perl-regexp

Stop promising in our grep & rev-list options documentation that we're
always going to be using libpcre when given the --perl-regexp option.

Instead talk about using "Perl-compatible regular expressions" and
using these types of patterns using "a compile-time dependency".

Saying "libpcre" means that we're talking about libpcre.so, which is
always going to be v1. This change is part of an ongoing saga to add
support for libpcre2, which comes with PCRE v2.

In the future we might use some completely unrelated library to
provide perl-compatible regular expression support. By wording the
documentation differently and not promising any specific version of
PCRE or even PCRE at all we have more wiggle room to change the
implementation.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMakefile & configure: reword inaccurate comment about PCRE
Ævar Arnfjörð Bjarmason [Sat, 20 May 2017 21:42:04 +0000 (20 21:42 +0000)]
Makefile & configure: reword inaccurate comment about PCRE

Reword an outdated & inaccurate comment which suggests that only
git-grep can use PCRE.

This comment was added back when PCRE support was initially added in
commit 63e7e9d8b6 ("git-grep: Learn PCRE", 2011-05-09), and was true
at the time.

It hasn't been telling the full truth since git-log learned to use
PCRE with --grep in commit 727b6fc3ed ("log --grep: accept
--basic-regexp and --perl-regexp", 2012-10-03), and more importantly
is likely to get more inaccurate over time as more use is made of PCRE
in other areas.

Reword it to be more future-proof, and to more clearly explain that
this enables user-initiated runtime behavior.

Copy/pasting this so much in configure.ac is lame, these Makefile-like
flags aren't even used by autoconf, just the corresponding
--with[out]-* options. But copy/pasting the comments that make sense
for the Makefile to configure.ac where they make less sense is the
pattern everything else follows in that file. I'm not going to war
against that as part of this change, just following the existing
pattern.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosend-email: Net::SMTP::SSL is obsolete, use only when necessary
Dennis Kaarsemaker [Fri, 24 Mar 2017 21:37:32 +0000 (24 22:37 +0100)]
send-email: Net::SMTP::SSL is obsolete, use only when necessary

Net::SMTP itself can do the necessary SSL and STARTTLS bits just fine
since version 1.28, and Net::SMTP::SSL is now deprecated. Since 1.28
isn't that old yet, keep the old code in place and use it when
necessary.

While we're in the area, mark some messages for translation that were
not yet marked as such.

Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorevision.c: ignore broken tags with ignore_missing_links
Jeff King [Sat, 20 May 2017 08:30:25 +0000 (20 04:30 -0400)]
revision.c: ignore broken tags with ignore_missing_links

When peeling a tag for prepare_revision_walk(), we do not
respect the ignore_missing_links flag. This can lead to a
bogus error when pack-objects walks the possibly-broken
unreachable-but-recent part of the object graph.

The other link-following all happens via traverse_commit_list(),
which explains why this case was missed. And our tests
covered only broken links from commits. Let's be more
comprehensive and cover broken tree entries (which do work)
and tags (which shows off this bug).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconfig.txt: add an entry for log.showSignature
Kyle Meyer [Fri, 19 May 2017 02:44:51 +0000 (18 22:44 -0400)]
config.txt: add an entry for log.showSignature

The configuration variable log.showSignature is mentioned in git-log's
manpage.  Document it in git-config's manpage as well.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agounpack-trees: preserve index extensions
David Turner [Mon, 8 May 2017 09:41:42 +0000 (8 11:41 +0200)]
unpack-trees: preserve index extensions

Make git checkout (and other unpack_tree operations) preserve the
untracked cache. This is valuable for two reasons:

1. Often, an unpack_tree operation will not touch large parts of the
working tree, and thus most of the untracked cache will continue to be
valid.

2. Even if the untracked cache were entirely invalidated by such an
operation, the user has signaled their intention to have such a cache,
and we don't want to throw it away.

[jes: backed out the watchman-specific parts]

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorebase -i: add missing newline to end of message
Phillip Wood [Fri, 19 May 2017 14:32:48 +0000 (19 15:32 +0100)]
rebase -i: add missing newline to end of message

The message that's printed when auto-stashed changes are successfully
restored was missing '\n' at the end.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorebase -i: silence stash apply
Phillip Wood [Thu, 18 May 2017 10:02:33 +0000 (18 11:02 +0100)]
rebase -i: silence stash apply

The shell version of rebase -i silences the status output from 'git
stash apply' when restoring the autostashed changes. The C version
does not.

Having the output from git stash apply on the screen is
distracting as it makes it difficult to find the message from git
rebase saying that the rebase succeeded. Also the status information
that git stash prints talks about looking in .git/rebase-merge/done to
see which commits have been applied. As .git/rebase-merge is removed
shortly after the message is printed before rebase -i exits this is
confusing.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorebase -i: fix reflog message
Phillip Wood [Thu, 18 May 2017 10:02:32 +0000 (18 11:02 +0100)]
rebase -i: fix reflog message

When rebase -i was converted to C a bug was introduced into the code
that creates the reflog message. Instead of saying
rebase -i (finish): <head-name> onto <onto>
it says
rebase -i (finish): <head-name> onto <orig-head><onto>
as the strbuf is not reset between reading the value of <orig-head>
and <onto>.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref-filter: resolve HEAD when parsing %(HEAD) atom
Jeff King [Fri, 19 May 2017 06:12:12 +0000 (19 02:12 -0400)]
ref-filter: resolve HEAD when parsing %(HEAD) atom

If the user asks to display (or sort by) the %(HEAD) atom,
ref-filter has to compare each refname to the value of HEAD.
We do so by resolving HEAD fresh when calling populate_value()
on each ref. If there are a large number of refs, this can
have a measurable impact on runtime.

Instead, let's resolve HEAD once when we realize we need the
%(HEAD) atom, allowing us to do a simple string comparison
for each ref. On a repository with 3000 branches (high, but
an actual example found in the wild) this drops the
best-of-five time to run "git branch >/dev/null" from 59ms
to 48ms (~20% savings).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoname-rev: change a "long" variable to timestamp_t
Junio C Hamano [Sat, 20 May 2017 05:39:43 +0000 (20 14:39 +0900)]
name-rev: change a "long" variable to timestamp_t

Earlier dddbad72 ("timestamp_t: a new data type for timestamps",
2017-04-26) updated all in-core variables, fields and function
return values that are used to store "seconds since epoch" to a new
type timestamp_t.  Unfortunately one variable "cutoff", which is
used to keep track of the oldest timestamp of commit we saw on the
command line, was "long" and left behind.

Update it to timestamp_t as well.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agointerpret-trailers: honor the cut line
Brian Malehorn [Tue, 16 May 2017 06:06:49 +0000 (15 23:06 -0700)]
interpret-trailers: honor the cut line

If a commit message is edited with the "verbose" option, the buffer
will have a cut line and diff after the log message, like so:

    my subject

    # ------------------------ >8 ------------------------
    # Do not touch the line above.
    # Everything below will be removed.
    diff --git a/foo.txt b/foo.txt
    index 5716ca5..7601807 100644
    --- a/foo.txt
    +++ b/foo.txt
    @@ -1 +1 @@
    -bar
    +baz

"git interpret-trailers" is unaware of the cut line, and assumes the
trailer block would be at the end of the whole thing.  This can easily
be seen with:

     $ GIT_EDITOR='git interpret-trailers --in-place --trailer Acked-by:me' \
       git commit --amend -v

Teach "git interpret-trailers" to notice the cut-line and ignore the
remainder of the input when looking for a place to add new trailer
block.  This makes it consistent with how "git commit -v -s" inserts a
new Signed-off-by: line.

This can be done by the same logic as the existing helper function,
wt_status_truncate_message_at_cut_line(), uses, but it wants the caller
to pass a strbuf to it.  Because the function ignore_non_trailer() used
by the command takes a <pointer, length> pair, not a strbuf, steal the
logic from wt_status_truncate_message_at_cut_line() to create a new
wt_status_locate_end() helper function that takes <pointer, length>
pair, and make ignore_non_trailer() call it to help "interpret-trailers".

Since there is only one caller of wt_status_truncate_message_at_cut_line()
in cmd_commit(), rewrite it to call wt_status_locate_end() helper instead
and remove the old helper that no longer has any caller.

Signed-off-by: Brian Malehorn <bmalehorn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot5400: avoid concurrent writes into a trace file
Jeff King [Thu, 18 May 2017 05:02:09 +0000 (18 01:02 -0400)]
t5400: avoid concurrent writes into a trace file

One test in t5400 examines the packet exchange between git-push and
git-receive-pack. The latter inherits the GIT_TRACE_PACKET environment
variable, so that both processes dump trace data into the same file
concurrently. This should not be a problem because the trace file is
opened with O_APPEND.

On Windows, however, O_APPEND is not atomic as it should be: it is
emulated as lseek(SEEK_END) followed by write(). For this reason, the
test is unreliable: it can happen that one process overwrites a line
that was just written by the other process. As a consequence, the test
sometimes does not find one or another line that is expected (and it is
also successful occasionally).

The test case is actually only interested in the output of git-push.
To ensure that only git-push writes to the trace file, override the
receive-pack command such that it does not even open the trace file.

Reported-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot5545: enhance test coverage when no http server is installed
Stefan Beller [Wed, 17 May 2017 03:11:03 +0000 (16 20:11 -0700)]
t5545: enhance test coverage when no http server is installed

In commit 438fc68462 ("push options: pass push options to the transport
helper", 08-02-2017), the test coverage was reduced to run no tests at all
if you lack a http server.  Move the http initialization to the end,
such that only http tests are skipped when a http server is missing.

The test in between that tests submodule propagation is safe to run before
the http tests as it makes its own test directories `parent` and
`parent_upstream`.

Noticed-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotest: allow skipping the remainder
Junio C Hamano [Thu, 18 May 2017 02:52:20 +0000 (18 11:52 +0900)]
test: allow skipping the remainder

Because TAP output does not like to see the remainder of the test
getting skipped after running one or more tests, bf4b7219
("test-lib.sh: Add check for invalid use of 'skip_all' facility",
2012-09-01) made sure that test_done errors out when this happens.

Instead, loosen the check so that we only pretend that the rest of
the test script did not exist in such a case.  We'd lose a bit of
information (i.e. TAP does not notice that we are skipping some
tests), but not very much (i.e. TAP wasn't told how many tests are
skipped anyway).

This will allow inclusion of lib-httpd.sh in the middle of a test,
which will skip the remainder of the test scripts when tests that
involve web server are declined with GIT_TEST_HTTPD=false, for
example.

Acked-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocompletion: add git stash push
Thomas Gummerer [Tue, 16 May 2017 19:59:45 +0000 (16 20:59 +0100)]
completion: add git stash push

When introducing git stash push in f5727e26e4 ("stash: introduce push
verb", 2017-02-19), I forgot to add it to the completion code. Add it
now.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconfig: match both symlink & realpath versions in IncludeIf.gitdir:*
Ævar Arnfjörð Bjarmason [Tue, 16 May 2017 08:28:46 +0000 (16 08:28 +0000)]
config: match both symlink & realpath versions in IncludeIf.gitdir:*

Change the conditional inclusion mechanism to support
e.g. gitdir:~/git_tree/repo where ~/git_tree is a symlink to
/mnt/stuff/repo.

This worked in the initial version of this facility[1], but regressed
later in the series while solving a related bug[2].

Now gitdir: will match against the symlinked
path (e.g. gitdir:~/git_tree/repo) in addition to the current
/mnt/stuff/repo path.

Since this is already in a release version note in the documentation
that this behavior changed, so users who expect their configuration to
work on both v2.13.0 and some future version of git with this fix
aren't utterly confused.

1. commit 3efd0bedc6 ("config: add conditional include", 2017-03-01)
2. commit 86f9515708 ("config: resolve symlinks in conditional
   include's patterns", 2017-04-05)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoStart post 2.13 cycle
Junio C Hamano [Tue, 16 May 2017 02:52:09 +0000 (16 11:52 +0900)]
Start post 2.13 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'js/larger-timestamps'
Junio C Hamano [Tue, 16 May 2017 02:51:59 +0000 (16 11:51 +0900)]
Merge branch 'js/larger-timestamps'

Some platforms have ulong that is smaller than time_t, and our
historical use of ulong for timestamp would mean they cannot
represent some timestamp that the platform allows.  Invent a
separate and dedicated timestamp_t (so that we can distingiuish
timestamps and a vanilla ulongs, which along is already a good
move), and then declare uintmax_t is the type to be used as the
timestamp_t.

* js/larger-timestamps:
  archive-tar: fix a sparse 'constant too large' warning
  use uintmax_t for timestamps
  date.c: abort if the system time cannot handle one of our timestamps
  timestamp_t: a new data type for timestamps
  PRItime: introduce a new "printf format" for timestamps
  parse_timestamp(): specify explicitly where we parse timestamps
  t0006 & t5000: skip "far in the future" test when time_t is too limited
  t0006 & t5000: prepare for 64-bit timestamps
  ref-filter: avoid using `unsigned long` for catch-all data type

7 years agoMerge branch 'jc/apply-fix-mismerge'
Junio C Hamano [Tue, 16 May 2017 02:51:59 +0000 (16 11:51 +0900)]
Merge branch 'jc/apply-fix-mismerge'

* jc/apply-fix-mismerge:
  apply.c: fix whitespace-only mismerge

7 years agoMerge branch 'ab/aix-needs-compat-regex'
Junio C Hamano [Tue, 16 May 2017 02:51:58 +0000 (16 11:51 +0900)]
Merge branch 'ab/aix-needs-compat-regex'

Build fix.

* ab/aix-needs-compat-regex:
  config.mak.uname: set NO_REGEX=NeedsStartEnd on AIX

7 years agoMerge branch 'jn/credential-doc-on-clear'
Junio C Hamano [Tue, 16 May 2017 02:51:57 +0000 (16 11:51 +0900)]
Merge branch 'jn/credential-doc-on-clear'

Doc update.

* jn/credential-doc-on-clear:
  credential doc: make multiple-helper behavior more prominent

7 years agoMerge branch 'jn/clone-add-empty-config-from-command-line'
Junio C Hamano [Tue, 16 May 2017 02:51:56 +0000 (16 11:51 +0900)]
Merge branch 'jn/clone-add-empty-config-from-command-line'

"git clone --config var=val" is a way to populate the
per-repository configuration file of the new repository, but it did
not work well when val is an empty string.  This has been fixed.

* jn/clone-add-empty-config-from-command-line:
  clone: handle empty config values in -c

7 years agoMerge branch 'bw/submodule-has-commits-update'
Junio C Hamano [Tue, 16 May 2017 02:51:56 +0000 (16 11:51 +0900)]
Merge branch 'bw/submodule-has-commits-update'

Code clean-up and duplicate removal.

* bw/submodule-has-commits-update:
  submodule: refactor logic to determine changed submodules
  submodule: improve submodule_has_commits()
  submodule: change string_list changed_submodule_paths
  submodule: remove add_oid_to_argv()
  submodule: rename free_submodules_sha1s()
  submodule: rename add_sha1_to_array()

7 years agoMerge branch 'ls/travis-doc-asciidoctor'
Junio C Hamano [Tue, 16 May 2017 02:51:55 +0000 (16 11:51 +0900)]
Merge branch 'ls/travis-doc-asciidoctor'

Travis CI gained a task to format the documentation with both
AsciiDoc and AsciiDoctor.

* ls/travis-doc-asciidoctor:
  travis-ci: check AsciiDoc/AsciiDoctor stderr output
  travis-ci: unset compiler for jobs that do not need one
  travis-ci: parallelize documentation build
  travis-ci: build documentation with AsciiDoc and Asciidoctor

7 years agoMerge branch 'rs/large-zip'
Junio C Hamano [Tue, 16 May 2017 02:51:54 +0000 (16 11:51 +0900)]
Merge branch 'rs/large-zip'

"git archive --format=zip" learned to use zip64 extension when
necessary to go beyond the 4GB limit.

* rs/large-zip:
  t5004: require 64-bit support for big ZIP tests
  archive-zip: set version field for big files correctly
  archive-zip: support files bigger than 4GB
  archive-zip: support archives bigger than 4GB
  archive-zip: write ZIP dir entry directly to strbuf
  archive-zip: use strbuf for ZIP directory
  archive-zip: add tests for big ZIP archives

7 years agoMerge branch 'ab/clone-no-tags'
Junio C Hamano [Tue, 16 May 2017 02:51:54 +0000 (16 11:51 +0900)]
Merge branch 'ab/clone-no-tags'

"git clone" learned the "--no-tags" option not to fetch all tags
initially, and also set up the tagopt not to follow any tags in
subsequent fetches.

* ab/clone-no-tags:
  tests: rename a test having to do with shallow submodules
  clone: add a --no-tags option to clone without tags
  tests: change "cd ... && git fetch" to "cd &&\n\tgit fetch"

7 years agoMerge branch 'sk/status-short-branch-color-config'
Junio C Hamano [Tue, 16 May 2017 02:51:53 +0000 (16 11:51 +0900)]
Merge branch 'sk/status-short-branch-color-config'

The colors in which "git status --short --branch" showed the names
of the current branch and its remote-tracking branch are now
configurable.

* sk/status-short-branch-color-config:
  status: add color config slots for branch info in "--short --branch"
  status: fix missing newline when comment chars are disabled

7 years agoMerge branch 'jk/am-leakfix'
Junio C Hamano [Tue, 16 May 2017 02:51:53 +0000 (16 11:51 +0900)]
Merge branch 'jk/am-leakfix'

The codepath in "git am" that is used when running "git rebase"
leaked memory held for the log message of the commits being rebased.

* jk/am-leakfix:
  am: shorten ident_split variable name in get_commit_info()
  am: simplify allocations in get_commit_info()
  am: fix commit buffer leak in get_commit_info()

7 years agoMerge branch 'jt/use-trailer-api-in-commands'
Junio C Hamano [Tue, 16 May 2017 02:51:52 +0000 (16 11:51 +0900)]
Merge branch 'jt/use-trailer-api-in-commands'

"git cherry-pick" and other uses of the sequencer machinery
mishandled a trailer block whose last line is an incomplete line.
This has been fixed so that an additional sign-off etc. are added
after completing the existing incomplete line.

* jt/use-trailer-api-in-commands:
  sequencer: add newline before adding footers

7 years agoMerge branch 'nd/worktree-kill-parse-ref'
Junio C Hamano [Tue, 16 May 2017 02:51:51 +0000 (16 11:51 +0900)]
Merge branch 'nd/worktree-kill-parse-ref'

"git gc" did not interact well with "git worktree"-managed
per-worktree refs.

* nd/worktree-kill-parse-ref:
  refs: kill set_worktree_head_symref()
  worktree.c: kill parse_ref() in favor of refs_resolve_ref_unsafe()
  refs: introduce get_worktree_ref_store()
  refs: add REFS_STORE_ALL_CAPS
  refs.c: make submodule ref store hashmap generic
  environment.c: fix potential segfault by get_git_common_dir()

7 years agoMerge branch 'dt/gc-ignore-old-gc-logs'
Junio C Hamano [Tue, 16 May 2017 02:51:50 +0000 (16 11:51 +0900)]
Merge branch 'dt/gc-ignore-old-gc-logs'

Attempt to allow us notice "fishy" situation where we fail to
remove the temporary directory used during the test.

* dt/gc-ignore-old-gc-logs:
  test-lib: retire $remove_trash variable
  test-lib.sh: do not barf under --debug at the end of the test
  test-lib: abort when can't remove trash directory

7 years agoMerge branch 'jk/no-null-sha1-in-cache-tree'
Junio C Hamano [Tue, 16 May 2017 02:51:50 +0000 (16 11:51 +0900)]
Merge branch 'jk/no-null-sha1-in-cache-tree'

Code to update the cache-tree has been tightened so that we won't
accidentally write out any 0{40} entry in the tree object.

* jk/no-null-sha1-in-cache-tree:
  cache-tree: reject entries with null sha1

7 years agoMerge branch 'dt/raise-core-packed-git-limit'
Junio C Hamano [Tue, 16 May 2017 02:51:49 +0000 (16 11:51 +0900)]
Merge branch 'dt/raise-core-packed-git-limit'

The default packed-git limit value has been raised on larger
platforms to save "git fetch" from a (recoverable) failure while
"gc" is running in parallel.

* dt/raise-core-packed-git-limit:
  Increase core.packedGitLimit

7 years agosend-email: support validate hook
Jonathan Tan [Fri, 12 May 2017 22:38:26 +0000 (12 15:38 -0700)]
send-email: support validate hook

Currently, send-email has support for rudimentary e-mail validation.
Allow the user to add support for more validation by providing a
sendemail-validate hook.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agop0004: don't error out if test repo is too small
René Scharfe [Sat, 13 May 2017 16:03:50 +0000 (13 18:03 +0200)]
p0004: don't error out if test repo is too small

Repositories with less than 4000 entries are always handled using a
single thread, causing test-lazy-init-name-hash --multi to error out.
Don't abort the whole test script in that case, but simply skip the
multi-threaded performance check.  We can still use it to compare the
single-threaded speed of different versions in that case.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agop0004: don't abort if multi-threaded is too slow
René Scharfe [Sat, 13 May 2017 16:03:22 +0000 (13 18:03 +0200)]
p0004: don't abort if multi-threaded is too slow

If the single-threaded variant beats the multi-threaded one then we may
have a performance bug, but that doesn't justify aborting the test.
Drop that check; we can compare the results for --single and --multi
using the actual performance tests.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agop0004: use test_perf
René Scharfe [Sat, 13 May 2017 16:02:32 +0000 (13 18:02 +0200)]
p0004: use test_perf

The perf test suite (more specifically: t/perf/aggregate.perl) requires
each test script to write test results into a file, otherwise it aborts
when aggregating.  Add actual performance tests with test_perf to allow
p0004 to be run together with other perf scripts.

Calibrate the value for the parameter --count based on the size of the
test repository, in order to get meaningful results with smaller repos
yet still be able to finish the script against huge ones without having
to wait for hours.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agop0004: avoid using pipes
René Scharfe [Sat, 13 May 2017 16:00:15 +0000 (13 18:00 +0200)]
p0004: avoid using pipes

The return code of commands on the producing end of a pipe is ignored.
Evaluate the outcome of test-lazy-init-name-hash by calling sort
separately.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agop0004: simplify calls of test-lazy-init-name-hash
René Scharfe [Sat, 13 May 2017 15:59:46 +0000 (13 17:59 +0200)]
p0004: simplify calls of test-lazy-init-name-hash

The test library puts helpers into $PATH, so we can simply call them
without specifying their location.

The suffix $X is also not necessary because .exe files on Windows can be
started without specifying their extension, and on other platforms it's
empty anyway.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofetch-pack: always allow fetching of literal SHA1s
Jonathan Tan [Mon, 15 May 2017 17:32:20 +0000 (15 10:32 -0700)]
fetch-pack: always allow fetching of literal SHA1s

fetch-pack, when fetching a literal SHA-1 from a server that is not
configured with uploadpack.allowtipsha1inwant (or similar), always
returns an error message of the form "Server does not allow request for
unadvertised object %s". However, it is sometimes the case that such
object is advertised. This situation would occur, for example, if a user
or a script was provided a SHA-1 instead of a branch or tag name for
fetching, and wanted to invoke "git fetch" or "git fetch-pack" using
that SHA-1.

Teach fetch-pack to also check the SHA-1s of the refs in the received
ref advertisement if a literal SHA-1 was given by the user.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodoc: use https links to Wikipedia to avoid http redirects
Sven Strickroth [Sat, 13 May 2017 09:54:51 +0000 (13 11:54 +0200)]
doc: use https links to Wikipedia to avoid http redirects

Signed-off-by: Sven Strickroth <email@cs-ware.de>
Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconvert: update subprocess_read_status() to not die on EOF
Ben Peart [Fri, 5 May 2017 15:28:02 +0000 (5 11:28 -0400)]
convert: update subprocess_read_status() to not die on EOF

Enable sub-processes to gracefully handle when the process dies by
updating subprocess_read_status to return an error on EOF instead of
dying.

Update apply_multi_file_filter to take advantage of the revised
subprocess_read_status.

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