]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
7 years agoDocumentation: build technical/multi-pack-index
Todd Zullinger [Tue, 20 Nov 2018 18:04:54 +0000 (13:04 -0500)] 
Documentation: build technical/multi-pack-index

The git-multi-pack-index doc links to technical/multi-pack-index.html.
Ensure it is built to prevent a broken link.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopack-objects: fix off-by-one in delta-island tree-depth computation
Jeff King [Tue, 20 Nov 2018 09:50:53 +0000 (04:50 -0500)] 
pack-objects: fix off-by-one in delta-island tree-depth computation

When delta-islands are in use, we need to record the deepest path at
which we find each tree and blob. Our loop to do so counts slashes, so
"foo" is depth 0, "foo/bar" is depth 1, and so on.

However, this neglects root trees, which are represented by the empty
string. Those also have depth 0, but are at a layer above "foo". Thus,
"foo" should be 1, "foo/bar" at 2, and so on. We use this depth to
topo-sort the trees in resolve_tree_islands(). As a result, we may fail
to visit a root tree before the sub-trees it contains, and therefore not
correctly pass down the island marks.

That in turn could lead to missing some delta opportunities (objects are
in the same island, but we didn't realize it) or creating unwanted
cross-island deltas (one object is in an island another isn't, but we
don't realize). In practice, it seems to have only a small effect.  Some
experiments on the real-world git/git fork network at GitHub showed an
improvement of only 0.14% in the resulting clone size.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopack-objects: zero-initialize tree_depth/layer arrays
Jeff King [Tue, 20 Nov 2018 09:48:57 +0000 (04:48 -0500)] 
pack-objects: zero-initialize tree_depth/layer arrays

Commit 108f530385 (pack-objects: move tree_depth into 'struct
packing_data', 2018-08-16) started maintaining a tree_depth array that
matches the "objects" array. We extend the array when:

  1. The objects array is extended, in which case we use realloc to
     extend the tree_depth array.

  2. A caller asks to store a tree_depth for object N, and this is the
     first such request; we create the array from scratch and store the
     value for N.

In the latter case, though, we use regular xmalloc(), and the depth
values for any objects besides N is undefined. This happens to not
trigger a bug with the current code, but the reasons are quite subtle:

 - we never ask about the depth for any object with index i < N. This is
   because we store the depth immediately for all trees and blobs. So
   any such "i" must be a non-tree, and therefore we will never need to
   care about its depth (in fact, we really only care about the depth of
   trees).

 - there are no objects at this point with index i > N, because we
   always fill in the depth for a tree immediately after its object
   entry is created (we may still allocate uninitialized depth entries,
   but they'll be initialized by packlist_alloc() when it initializes
   the entry in the "objects" array).

So it works, but only by chance. To be defensive, let's zero the array,
which matches the "unset" values which would be handed out by
oe_tree_depth() already.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopack-objects: fix tree_depth and layer invariants
Jeff King [Tue, 20 Nov 2018 09:46:38 +0000 (04:46 -0500)] 
pack-objects: fix tree_depth and layer invariants

Commit 108f530385 (pack-objects: move tree_depth into 'struct
packing_data', 2018-08-16) dynamically manages a tree_depth array in
packing_data that maintains one of these invariants:

  1. tree_depth is NULL (i.e., the requested options don't require us to
     track tree depths)

  2. tree_depth is non-NULL and has as many entries as the "objects"
     array

We maintain (2) by:

  a. When the objects array grows, grow tree_depth to the same size
     (unless it's NULL, in which case we can leave it).

  b. When a caller asks to set a depth via oe_set_tree_depth(), if
     tree_depth is NULL we allocate it.

But in (b), we use the number of stored objects, _not_ the allocated
size of the objects array. So we can run into a situation like this:

  1. packlist_alloc() needs to store the Nth object, so it grows the
     objects array to M, where M > N.

  2. oe_set_tree_depth() wants to store a depth, so it allocates an
     array of length N. Now we've violated our invariant.

  3. packlist_alloc() needs to store the N+1th object. But it _doesn't_
     grow the objects array, since N <= M still holds. We try to assign
     to tree_depth[N+1], which is out of bounds.

That doesn't happen in our test scripts, because the repositories they
use are so small, but it's easy to trigger by running:

  echo HEAD | git pack-objects --revs --delta-islands --stdout >/dev/null

in any reasonably-sized repo (like git.git).

We can fix it by always growing the array to match pack->nr_alloc, not
pack->nr_objects. Likewise for the "layer" array from fe0ac2fb7f
(pack-objects: move 'layer' into 'struct packing_data', 2018-08-16),
which has the same bug.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorebase: warn about the correct tree's OID
Johannes Schindelin [Tue, 20 Nov 2018 09:44:33 +0000 (01:44 -0800)] 
rebase: warn about the correct tree's OID

This was a simple copy/paste error, and an obvious one at that: if we
cannot fill the tree descriptor, we should show an error message about
*that* tree, not another one.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoieot: default to not writing IEOT section
Jonathan Nieder [Tue, 20 Nov 2018 06:12:22 +0000 (22:12 -0800)] 
ieot: default to not writing IEOT section

As with EOIE, popular versions of Git do not support the new IEOT
extension yet.  When accessing a Git repository written by a more
modern version of Git, they correctly ignore the unrecognized section,
but in the process they loudly warn

ignoring IEOT extension

resulting in confusion for users.  Introduce the index extension more
gently by not writing it yet in this first version with support for
it.  Soon, once sufficiently many users are running a modern version
of Git, we can flip the default so users benefit from this index
extension by default.

Introduce a '[index] recordOffsetTable' configuration variable to
control whether the new index extension is written.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoeoie: default to not writing EOIE section
Jonathan Nieder [Tue, 20 Nov 2018 06:11:47 +0000 (22:11 -0800)] 
eoie: default to not writing EOIE section

Since 3b1d9e04 (eoie: add End of Index Entry (EOIE) extension,
2018-10-10) Git defaults to writing the new EOIE section when writing
out an index file.  Usually that is a good thing because it improves
threaded performance, but when a Git repository is shared with older
versions of Git, it produces a confusing warning:

  $ git status
  ignoring EOIE extension
  HEAD detached at 371ed0defa
  nothing to commit, working tree clean

Let's introduce the new index extension more gently.  First we'll roll
out the new version of Git that understands it, and then once
sufficiently many users are using such a version, we can flip the
default to writing it by default.

Introduce a '[index] recordEndOfIndexEntries' configuration variable
to allow interested users to benefit from this index extension early.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agolegacy-rebase: backport -C<n> and --whitespace=<option> checks
Johannes Schindelin [Tue, 20 Nov 2018 20:02:01 +0000 (12:02 -0800)] 
legacy-rebase: backport -C<n> and --whitespace=<option> checks

Since 04519d720114 (rebase: validate -C<n> and --whitespace=<mode>
parameters early, 2018-11-14), the built-in rebase validates the -C and
--whitespace arguments early. As this commit also introduced a
regression test for this, and as a later commit introduced the
GIT_TEST_REBASE_USE_BUILTIN mode to run tests, we now have a
"regression" in the scripted version of `git rebase` on our hands.

Backport the validation to fix this.

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot0027: squelch checkout path run outside test_expect_* block
Junio C Hamano [Tue, 20 Nov 2018 03:43:24 +0000 (12:43 +0900)] 
t0027: squelch checkout path run outside test_expect_* block

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit-graph: split up close_reachable() progress output
Ævar Arnfjörð Bjarmason [Mon, 19 Nov 2018 20:23:00 +0000 (20:23 +0000)] 
commit-graph: split up close_reachable() progress output

Amend the progress output added in 7b0f229222 ("commit-graph write:
add progress output", 2018-09-17) so that the total numbers it reports
aren't higher than the total number of commits anymore. See [1] for a
bug report pointing that out.

When I added this I wasn't intending to provide an accurate count, but
just have some progress output to show the user the command wasn't
hanging[2]. But since we are showing numbers, let's make them
accurate. The progress descriptions were suggested by Derrick Stolee
in [3].

As noted in [2] we are unlikely to show anything except the "Expanding
reachable..." message even on fairly large repositories such as
linux.git. On a test repository I have with north of 7 million commits
all of these are displayed. Two of them don't show up for long, but as
noted in [5] future-proofing this for if the loops become more
expensive in the future makes sense.

1. https://public-inbox.org/git/20181010203738.GE23446@szeder.dev/
2. https://public-inbox.org/git/87pnwhea8y.fsf@evledraar.gmail.com/
3. https://public-inbox.org/git/f7a0cbee-863c-61d3-4959-5cec8b43c705@gmail.com/
4. https://public-inbox.org/git/20181015160545.GG19800@szeder.dev/
5. https://public-inbox.org/git/87murle8da.fsf@evledraar.gmail.com/

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotest-lib-functions: make 'test_cmp_rev' more informative on failure
SZEDER Gábor [Mon, 19 Nov 2018 13:28:18 +0000 (14:28 +0100)] 
test-lib-functions: make 'test_cmp_rev' more informative on failure

The 'test_cmp_rev' helper is merely a wrapper around 'test_cmp'
checking the output of two 'git rev-parse' commands, which means that
its output on failure is not particularly informative, as it's
basically two OIDs with a bit of extra clutter of the diff header, but
without any indication of which two revisions have caused the failure:

  --- expect.rev  2018-11-17 14:02:11.569747033 +0000
  +++ actual.rev  2018-11-17 14:02:11.569747033 +0000
  @@ -1 +1 @@
  -d79ce1670bdcb76e6d1da2ae095e890ccb326ae9
  +139b20d8e6c5b496de61f033f642d0e3dbff528d

It also pollutes the test repo with these two intermediate files,
though that doesn't seem to cause any complications in our current
tests (meaning that I couldn't find any tests that have to work around
the presence of these files by explicitly removing or ignoring them).

Enhance 'test_cmp_rev' to provide a more useful output on failure with
less clutter:

  error: two revisions point to different objects:
    'HEAD^': d79ce1670bdcb76e6d1da2ae095e890ccb326ae9
    'extra': 139b20d8e6c5b496de61f033f642d0e3dbff528d

Doing so is more convenient when storing the OIDs outputted by 'git
rev-parse' in a local variable each, which, as a bonus, won't pollute
the repository with intermediate files.

While at it, also ensure that 'test_cmp_rev' is invoked with the right
number of parameters, namely two.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotests: send "bug in the test script" errors to the script's stderr
SZEDER Gábor [Mon, 19 Nov 2018 13:13:26 +0000 (14:13 +0100)] 
tests: send "bug in the test script" errors to the script's stderr

Some of the functions in our test library check that they were invoked
properly with conditions like this:

  test "$#" = 2 ||
  error "bug in the test script: not 2 parameters to test-expect-success"

If this particular condition is triggered, then 'error' will abort the
whole test script with a bold red error message [1] right away.

However, under certain circumstances the test script will be aborted
completely silently, namely if:

  - a similar condition in a test helper function like
    'test_line_count' is triggered,
  - which is invoked from the test script's "main" shell [2],
  - and the test script is run manually (i.e. './t1234-foo.sh' as
    opposed to 'make t1234-foo.sh' or 'make test') [3]
  - and without the '--verbose' option,

because the error message is printed from within 'test_eval_', where
standard output is redirected either to /dev/null or to a log file.
The only indication that something is wrong is that not all tests in
the script are executed and at the end of the test script's output
there is no "# passed all N tests" message, which are subtle and can
easily go unnoticed, as I had to experience myself.

Send these "bug in the test script" error messages directly to the
test scripts standard error and thus to the terminal, so those bugs
will be much harder to overlook.  Instead of updating all ~20 such
'error' calls with a redirection, let's add a BUG() function to
'test-lib.sh', wrapping an 'error' call with the proper redirection
and also including the common prefix of those error messages, and
convert all those call sites [4] to use this new BUG() function
instead.

[1] That particular error message from 'test_expect_success' is
    printed in color only when running with or without '--verbose';
    with '--tee' or '--verbose-log' the error is printed without
    color, but it is printed to the terminal nonetheless.

[2] If such a condition is triggered in a subshell of a test, then
    'error' won't be able to abort the whole test script, but only the
    subshell, which in turn causes the test to fail in the usual way,
    indicating loudly and clearly that something is wrong.

[3] Well, 'error' aborts the test script the same way when run
    manually or by 'make' or 'prove', but both 'make' and 'prove' pay
    attention to the test script's exit status, and even a silently
    aborted test script would then trigger those tools' usual
    noticable error messages.

[4] Strictly speaking, not all those 'error' calls need that
    redirection to send their output to the terminal, see e.g.
    'test_expect_success' in the opening example, but I think it's
    better to be consistent.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'master' of git://github.com/git-l10n/git-po
Jiang Xin [Tue, 20 Nov 2018 02:07:25 +0000 (10:07 +0800)] 
Merge branch 'master' of git://github.com/git-l10n/git-po

7 years agol10n: git.pot: v2.20.0 round 1 (254 new, 27 removed)
Jiang Xin [Tue, 20 Nov 2018 02:06:16 +0000 (10:06 +0800)] 
l10n: git.pot: v2.20.0 round 1 (254 new, 27 removed)

Generate po/git.pot from v2.20.0-rc0-23-gbb75be6cb9 for git v2.20.0 l10n
round 1.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
7 years agomsvc: directly use MS version (_stricmp) of strcasecmp
Sven Strickroth [Mon, 19 Nov 2018 15:14:42 +0000 (16:14 +0100)] 
msvc: directly use MS version (_stricmp) of strcasecmp

This also removes an implicit conversion from size_t (unsigned) to int (signed).

_stricmp as well as _strnicmp are both available since VS2012.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoPrepare for 2.20-rc1
Junio C Hamano [Mon, 19 Nov 2018 07:06:54 +0000 (16:06 +0900)] 
Prepare for 2.20-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'sb/cocci-pending'
Junio C Hamano [Mon, 19 Nov 2018 07:24:41 +0000 (16:24 +0900)] 
Merge branch 'sb/cocci-pending'

A coding convention around the Coccinelle semantic patches to have
two classes to ease code migration process has been proposed and
its support has been added to the Makefile.

* sb/cocci-pending:
  coccicheck: introduce 'pending' semantic patches

7 years agoMerge branch 'js/test-git-installed'
Junio C Hamano [Mon, 19 Nov 2018 07:24:41 +0000 (16:24 +0900)] 
Merge branch 'js/test-git-installed'

Update the "test installed Git" mode of our test suite to work better.

* js/test-git-installed:
  tests: explicitly use `git.exe` on Windows
  tests: do not require Git to be built when testing an installed Git
  t/lib-gettext: test installed git-sh-i18n if GIT_TEST_INSTALLED is set
  tests: respect GIT_TEST_INSTALLED when initializing repositories
  tests: fix GIT_TEST_INSTALLED's PATH to include t/helper/

7 years agoMerge branch 'dd/poll-dot-h'
Junio C Hamano [Mon, 19 Nov 2018 07:24:41 +0000 (16:24 +0900)] 
Merge branch 'dd/poll-dot-h'

A build update.

* dd/poll-dot-h:
  git-compat-util: prefer poll.h to sys/poll.h

7 years agoMerge branch 'tb/print-size-t-with-uintmax-format'
Junio C Hamano [Mon, 19 Nov 2018 07:24:41 +0000 (16:24 +0900)] 
Merge branch 'tb/print-size-t-with-uintmax-format'

Code preparation to replace ulong vars with size_t vars where
appropriate.

* tb/print-size-t-with-uintmax-format:
  Upcast size_t variables to uintmax_t when printing

7 years agoMerge branch 'tb/xcurl-off-t'
Junio C Hamano [Mon, 19 Nov 2018 07:24:40 +0000 (16:24 +0900)] 
Merge branch 'tb/xcurl-off-t'

The xcurl_off_t() helper function is used to cast size_t to
curl_off_t, but some compilers gave warnings against the code to
ensure the casting is done without wraparound, when size_t is
narrower than curl_off_t.  This warning has been squelched.

* tb/xcurl-off-t:
  remote-curl.c: xcurl_off_t is not portable (on 32 bit platfoms)

7 years agoMerge branch 'nd/format-patch-cover-letter-stat-width'
Junio C Hamano [Mon, 19 Nov 2018 07:24:40 +0000 (16:24 +0900)] 
Merge branch 'nd/format-patch-cover-letter-stat-width'

"git format-patch --stat=<width>" can be used to specify the width
used by the diffstat (shown in the cover letter).

* nd/format-patch-cover-letter-stat-width:
  format-patch: respect --stat in cover letter's diffstat

7 years agoMerge branch 'ds/push-squelch-ambig-warning'
Junio C Hamano [Mon, 19 Nov 2018 07:24:40 +0000 (16:24 +0900)] 
Merge branch 'ds/push-squelch-ambig-warning'

"git push" used to check ambiguities between object-names and
refnames while processing the list of refs' old and new values,
which was unnecessary (as it knew that it is feeding raw object
names).  This has been optimized out.

* ds/push-squelch-ambig-warning:
  pack-objects: ignore ambiguous object warnings

7 years agoMerge branch 'ab/dynamic-gettext-poison'
Junio C Hamano [Mon, 19 Nov 2018 07:24:39 +0000 (16:24 +0900)] 
Merge branch 'ab/dynamic-gettext-poison'

Our testing framework uses a special i18n "poisoned localization"
feature to find messages that ought to stay constant but are
incorrectly marked to be translated.  This feature has been made
into a runtime option (it used to be a compile-time option).

* ab/dynamic-gettext-poison:
  Makefile: ease dynamic-gettext-poison transition
  i18n: make GETTEXT_POISON a runtime option

7 years agotree-walk: support :(attr) matching
Nguyễn Thái Ngọc Duy [Sun, 18 Nov 2018 16:48:00 +0000 (17:48 +0100)] 
tree-walk: support :(attr) matching

This lets us use :(attr) with "git grep <tree-ish>" or "git log".

:(attr) requires another round of checking before we can declare that
a path is matched. This is done after path matching since we have lots
of optimization to take a shortcut when things don't match.

Note that if :(attr) is present, we can't return
all_entries_interesting / all_entries_not_interesting anymore because
we can't be certain about that. Not until match_pathspec_attrs() can
tell us "yes all these paths satisfy :(attr)".

Second note. Even though we walk a specific tree, we use attributes
from _worktree_ (or falling back to the index), not from .gitattributes
files on that tree. This by itself is not necessarily wrong, but the
user just have to be aware of this.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodir.c: move, rename and export match_attrs()
Nguyễn Thái Ngọc Duy [Sun, 18 Nov 2018 16:47:59 +0000 (17:47 +0100)] 
dir.c: move, rename and export match_attrs()

The function will be reused for matching attributes in pathspec when
walking trees (currently it's used for matching pathspec when walking
a list). pathspec.c would be a more neutral place for this.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec.h: clean up "extern" in function declarations
Nguyễn Thái Ngọc Duy [Sun, 18 Nov 2018 16:47:58 +0000 (17:47 +0100)] 
pathspec.h: clean up "extern" in function declarations

"extern" on functions is not required and the trend has been removing
it from header files.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotree-walk.c: make tree_entry_interesting() take an index
Nguyễn Thái Ngọc Duy [Sun, 18 Nov 2018 16:47:57 +0000 (17:47 +0100)] 
tree-walk.c: make tree_entry_interesting() take an index

In order to support :(attr) when matching pathspec on a tree,
tree_entry_interesting() needs to take an index (because
git_check_attr() needs it). This is the preparation step for it. This
also makes it clearer what index we fall back to when looking up
attributes during an unpack-trees operation: the source index.

This also fixes revs->pruning.repo initialization that should have
been done in 2abf350385 (revision.c: remove implicit dependency on
the_index - 2018-09-21). Without it, skip_uninteresting() will
dereference a NULL pointer through this call chain

  get_revision(revs)
  get_revision_internal
  get_revision_1
  try_to_simplify_commit
  rev_compare_tree
  diff_tree_oid(..., &revs->pruning)
  ll_diff_tree_oid
  diff_tree_paths
  ll_diff_tree
  skip_uninteresting

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotree.c: make read_tree*() take 'struct repository *'
Nguyễn Thái Ngọc Duy [Sun, 18 Nov 2018 16:47:56 +0000 (17:47 +0100)] 
tree.c: make read_tree*() take 'struct repository *'

These functions call tree_entry_interesting() which will soon require
a 'struct index_state *' to be passed in. Instead of just changing the
function signature to take an index, update to take a repo instead
because these functions do need object database access.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoread-cache: make the split index obey umask settings
Ævar Arnfjörð Bjarmason [Sun, 18 Nov 2018 19:04:29 +0000 (19:04 +0000)] 
read-cache: make the split index obey umask settings

Make the split index write out its .git/sharedindex_* files with the
same permissions as .git/index. This only changes the behavior when
core.sharedRepository isn't set, i.e. the user's umask settings will
be respected.

This hasn't been the case ever since the split index was originally
implemented in c18b80a0e8 ("update-index: new options to
enable/disable split index mode", 2014-06-13). A mkstemp()-like
function has always been used to create it. First mkstemp() itself,
and then later our own mkstemp()-like in
f6ecc62dbf ("write_shared_index(): use tempfile module", 2015-08-10)

A related bug was fixed in df801f3f9f ("read-cache: use shared perms
when writing shared index", 2017-06-25). Since then the split index
has respected core.sharedRepository.

However, using that setting should not be required simply to make git
obey the user's umask setting. It's intended for the use-case of
overriding whatever that umask is set to. This fixes cases where the
user has e.g. set his umask to 022 on a shared server in anticipation
of other user's needing to run "status", "log" etc. in his repository.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agostash: tolerate missing user identity
Slavica Djukic [Sun, 18 Nov 2018 13:44:07 +0000 (14:44 +0100)] 
stash: tolerate missing user identity

The "git stash" command insists on having a usable user identity to
the same degree as the "git commit-tree" and "git commit" commands
do, because it uses the same codepath that creates commit objects
as these commands.

It is not strictly necesary to do so. Check if we will barf before
creating commit objects and then supply fake identity to please the
machinery that creates commits.
Add test to document that stash executes correctly both with and
without valid ident.

This is not that much of usability improvement, as the users who run
"git stash" would eventually want to record their changes that are
temporarily stored in the stashes in a more permanent history by
committing, and they must do "git config user.{name,email}" at that
point anyway, so arguably this change is only delaying a step that
is necessary to work in the repository.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Slavica Djukic <slawica92@hotmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoRelNotes: name the release properly
Junio C Hamano [Sun, 18 Nov 2018 23:23:09 +0000 (08:23 +0900)] 
RelNotes: name the release properly

In the title, we should state for which version this release notes
document is about.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'master' of https://github.com/Softcatala/git-po
Jiang Xin [Sun, 18 Nov 2018 13:36:13 +0000 (21:36 +0800)] 
Merge branch 'master' of https://github.com/Softcatala/git-po

7 years agoGit 2.20-rc0 v2.20.0-rc0
Junio C Hamano [Sun, 18 Nov 2018 09:24:49 +0000 (18:24 +0900)] 
Git 2.20-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jk/close-duped-fd-before-unlock-for-bundle'
Junio C Hamano [Sun, 18 Nov 2018 09:23:59 +0000 (18:23 +0900)] 
Merge branch 'jk/close-duped-fd-before-unlock-for-bundle'

When "git bundle" aborts due to an empty commit ranges
(i.e. resulting in an empty pack), it left a file descriptor to an
lockfile open, which resulted in leftover lockfile on Windows where
you cannot remove a file with an open file descriptor.  This has
been corrected.

* jk/close-duped-fd-before-unlock-for-bundle:
  bundle: dup() output descriptor closer to point-of-use

7 years agoMerge branch 'ab/rebase-in-c-escape-hatch'
Junio C Hamano [Sun, 18 Nov 2018 09:23:59 +0000 (18:23 +0900)] 
Merge branch 'ab/rebase-in-c-escape-hatch'

The recently merged "rebase in C" has an escape hatch to use the
scripted version when necessary, but it hasn't been documented,
which has been corrected.

* ab/rebase-in-c-escape-hatch:
  tests: add a special setup where rebase.useBuiltin is off
  rebase doc: document rebase.useBuiltin

7 years agoMerge branch 'js/rebase-am-options'
Junio C Hamano [Sun, 18 Nov 2018 09:23:59 +0000 (18:23 +0900)] 
Merge branch 'js/rebase-am-options'

The way "git rebase" parses and forwards the command line options
meant for underlying "git am" has been revamped, which fixed for
options with parameters that were not passed correctly.

* js/rebase-am-options:
  rebase: validate -C<n> and --whitespace=<mode> parameters early
  rebase: really just passthru the `git am` options

7 years agoMerge branch 'sg/ref-filter-wo-repository'
Junio C Hamano [Sun, 18 Nov 2018 09:23:59 +0000 (18:23 +0900)] 
Merge branch 'sg/ref-filter-wo-repository'

"git ls-remote --sort=<thing>" can feed an object that is not yet
available into the comparison machinery and segfault, which has
been corrected to check such a request upfront and reject it.

* sg/ref-filter-wo-repository:
  ref-filter: don't look for objects when outside of a repository

7 years agoMerge branch 'nd/doc-extensions'
Junio C Hamano [Sun, 18 Nov 2018 09:23:58 +0000 (18:23 +0900)] 
Merge branch 'nd/doc-extensions'

Doc update.

* nd/doc-extensions:
  doc: move extensions.worktreeConfig to the right place

7 years agoMerge branch 'js/fuzz-cxxflags'
Junio C Hamano [Sun, 18 Nov 2018 09:23:58 +0000 (18:23 +0900)] 
Merge branch 'js/fuzz-cxxflags'

The build procedure to link for fuzzing test has been made
customizable with a new Makefile variable.

* js/fuzz-cxxflags:
  Makefile: use FUZZ_CXXFLAGS for linking fuzzers

7 years agoMerge branch 'js/mingw-msdn-url'
Junio C Hamano [Sun, 18 Nov 2018 09:23:58 +0000 (18:23 +0900)] 
Merge branch 'js/mingw-msdn-url'

The URL to an MSDN page in a comment has been updated.

* js/mingw-msdn-url:
  mingw: replace an obsolete link with the superseding one

7 years agoMerge branch 'js/mingw-create-hard-link'
Junio C Hamano [Sun, 18 Nov 2018 09:23:58 +0000 (18:23 +0900)] 
Merge branch 'js/mingw-create-hard-link'

Windows update.

* js/mingw-create-hard-link:
  mingw: use `CreateHardLink()` directly

7 years agoMerge branch 'js/config-sequence'
Junio C Hamano [Sun, 18 Nov 2018 09:23:57 +0000 (18:23 +0900)] 
Merge branch 'js/config-sequence'

A sanity check for start-up sequence has been added in the config
API codepath.

* js/config-sequence:
  config: report a bug if git_dir exists without commondir

7 years agoMerge branch 'lj/mingw-pthread-cond'
Junio C Hamano [Sun, 18 Nov 2018 09:23:57 +0000 (18:23 +0900)] 
Merge branch 'lj/mingw-pthread-cond'

Code simplification.

* lj/mingw-pthread-cond:
  win32: replace pthread_cond_*() with much simpler code

7 years agoMerge branch 'nd/command-list-gen-fix'
Junio C Hamano [Sun, 18 Nov 2018 09:23:57 +0000 (18:23 +0900)] 
Merge branch 'nd/command-list-gen-fix'

Build tweak.

* nd/command-list-gen-fix:
  build: fix broken command-list.h generation with core.autocrlf

7 years agoMerge branch 'ag/p3400-force-checkout'
Junio C Hamano [Sun, 18 Nov 2018 09:23:57 +0000 (18:23 +0900)] 
Merge branch 'ag/p3400-force-checkout'

Perf test tweak.

* ag/p3400-force-checkout:
  p3400: replace calls to `git checkout -b' by `git checkout -B'

7 years agoMerge branch 'cb/notes-freeing-always-null-fix'
Junio C Hamano [Sun, 18 Nov 2018 09:23:57 +0000 (18:23 +0900)] 
Merge branch 'cb/notes-freeing-always-null-fix'

Code cleanup.

* cb/notes-freeing-always-null-fix:
  builtin/notes: remove unnecessary free

7 years agoMerge branch 'js/rebase-r-and-merge-head'
Junio C Hamano [Sun, 18 Nov 2018 09:23:56 +0000 (18:23 +0900)] 
Merge branch 'js/rebase-r-and-merge-head'

Bugfix for the recently graduated "git rebase --rebase-merges".

* js/rebase-r-and-merge-head:
  status: rebase and merge can be in progress at the same time
  built-in rebase --skip/--abort: clean up stale .git/<name> files
  rebase -i: include MERGE_HEAD into files to clean up
  rebase -r: do not write MERGE_HEAD unless needed
  rebase -r: demonstrate bug with conflicting merges

7 years agoMerge branch 'js/apply-recount-allow-noop'
Junio C Hamano [Sun, 18 Nov 2018 09:23:56 +0000 (18:23 +0900)] 
Merge branch 'js/apply-recount-allow-noop'

When editing a patch in a "git add -i" session, a hunk could be
made to no-op.  The "git apply" program used to reject a patch with
such a no-op hunk to catch user mistakes, but it is now updated to
explicitly allow a no-op hunk in an edited patch.

* js/apply-recount-allow-noop:
  apply --recount: allow "no-op hunks"

7 years agoMerge branch 'ra/rev-parse-exclude-glob'
Junio C Hamano [Sun, 18 Nov 2018 09:23:56 +0000 (18:23 +0900)] 
Merge branch 'ra/rev-parse-exclude-glob'

"rev-parse --exclude=<pattern> --branches=<pattern>" etc. did not
quite work, which has been corrected.

* ra/rev-parse-exclude-glob:
  refs: fix some exclude patterns being ignored
  refs: show --exclude failure with --branches/tags/remotes=glob

7 years agoMerge branch 'js/builtin-rebase-perf-fix'
Junio C Hamano [Sun, 18 Nov 2018 09:23:55 +0000 (18:23 +0900)] 
Merge branch 'js/builtin-rebase-perf-fix'

Code clean-up with correction to make the reimplemented "git
rebase" a more faithful rewrite of the original, which also regains
performance.

* js/builtin-rebase-perf-fix:
  built-in rebase: reinstate `checkout -q` behavior where appropriate
  rebase: prepare reset_head() for more flags
  rebase: consolidate clean-up code before leaving reset_head()

7 years agoMerge branch 'js/mailmap'
Junio C Hamano [Sun, 18 Nov 2018 09:23:55 +0000 (18:23 +0900)] 
Merge branch 'js/mailmap'

Update the mailmap to unify multiple entries for the authors with
commits since v2.10.

* js/mailmap:
  Update .mailmap

7 years agoMerge branch 'js/rebase-autostash-detach-fix'
Junio C Hamano [Sun, 18 Nov 2018 09:23:55 +0000 (18:23 +0900)] 
Merge branch 'js/rebase-autostash-detach-fix'

"git rebase --autostash" did not correctly re-attach the HEAD at times.

* js/rebase-autostash-detach-fix:
  built-in rebase --autostash: leave the current branch alone if possible
  built-in rebase: demonstrate regression with --autostash

7 years agoMerge branch 'ab/range-diff-no-patch'
Junio C Hamano [Sun, 18 Nov 2018 09:23:54 +0000 (18:23 +0900)] 
Merge branch 'ab/range-diff-no-patch'

The "--no-patch" option, which can be used to get a high-level
overview without the actual line-by-line patch difference shown, of
the "range-diff" command was earlier broken, which has been
corrected.

* ab/range-diff-no-patch:
  range-diff: make diff option behavior (e.g. --stat) consistent
  range-diff: fix regression in passing along diff options
  range-diff doc: add a section about output stability

7 years agoMerge branch 'jk/verify-sig-merge-into-void'
Junio C Hamano [Sun, 18 Nov 2018 09:23:54 +0000 (18:23 +0900)] 
Merge branch 'jk/verify-sig-merge-into-void'

"git merge" and "git pull" that merges into an unborn branch used
to completely ignore "--verify-signatures", which has been
corrected.

* jk/verify-sig-merge-into-void:
  pull: handle --verify-signatures for unborn branch
  merge: handle --verify-signatures for unborn branch
  merge: extract verify_merge_signature() helper

7 years agoMerge branch 'js/mingw-res-rebuild'
Junio C Hamano [Sun, 18 Nov 2018 09:23:53 +0000 (18:23 +0900)] 
Merge branch 'js/mingw-res-rebuild'

Windows build update.

* js/mingw-res-rebuild:
  Windows: force-recompile git.res for differing architectures

7 years agoMerge branch 'jk/unused-parameter-fixes'
Junio C Hamano [Sun, 18 Nov 2018 09:23:53 +0000 (18:23 +0900)] 
Merge branch 'jk/unused-parameter-fixes'

Various functions have been audited for "-Wunused-parameter" warnings
and bugs in them got fixed.

* jk/unused-parameter-fixes:
  midx: double-check large object write loop
  assert NOARG/NONEG behavior of parse-options callbacks
  parse-options: drop OPT_DATE()
  apply: return -1 from option callback instead of calling exit(1)
  cat-file: report an error on multiple --batch options
  tag: mark "--message" option with NONEG
  show-branch: mark --reflog option as NONEG
  format-patch: mark "--no-numbered" option with NONEG
  status: mark --find-renames option with NONEG
  cat-file: mark batch options with NONEG
  pack-objects: mark index-version option as NONEG
  ls-files: mark exclude options as NONEG
  am: handle --no-patch-format option
  apply: mark include/exclude options as NONEG

7 years agoMerge branch 'jk/curl-ldflags'
Junio C Hamano [Sun, 18 Nov 2018 09:23:53 +0000 (18:23 +0900)] 
Merge branch 'jk/curl-ldflags'

The way -lcurl library gets linked has been simplified by taking
advantage of the fact that we can just ask curl-config command how.

* jk/curl-ldflags:
  build: link with curl-defined linker flags

7 years agoMerge branch 'mg/gpg-fingerprint-test'
Junio C Hamano [Sun, 18 Nov 2018 09:23:53 +0000 (18:23 +0900)] 
Merge branch 'mg/gpg-fingerprint-test'

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

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

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

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

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

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

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

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

7 years agofast-export: add a --show-original-ids option to show original names
Elijah Newren [Fri, 16 Nov 2018 07:59:56 +0000 (23:59 -0800)] 
fast-export: add a --show-original-ids option to show original names

Knowing the original names (hashes) of commits can sometimes enable
post-filtering that would otherwise be difficult or impossible.  In
particular, the desire to rewrite commit messages which refer to other
prior commits (on top of whatever other filtering is being done) is
very difficult without knowing the original names of each commit.

In addition, knowing the original names (hashes) of blobs can allow
filtering by blob-id without requiring re-hashing the content of the
blob, and is thus useful as a small optimization.

Once we add original ids for both commits and blobs, we may as well
add them for tags too for completeness.  Perhaps someone will have a
use for them.

This commit teaches a new --show-original-ids option to fast-export
which will make it add a 'original-oid <hash>' line to blob, commits,
and tags.  It also teaches fast-import to parse (and ignore) such
lines.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofast-import: remove unmaintained duplicate documentation
Elijah Newren [Fri, 16 Nov 2018 07:59:55 +0000 (23:59 -0800)] 
fast-import: remove unmaintained duplicate documentation

fast-import.c has started with a comment for nine and a half years
re-directing the reader to Documentation/git-fast-import.txt for
maintained documentation.  Instead of leaving the unmaintained
documentation in place, just excise it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofast-export: add --reference-excluded-parents option
Elijah Newren [Fri, 16 Nov 2018 07:59:54 +0000 (23:59 -0800)] 
fast-export: add --reference-excluded-parents option

git filter-branch has a nifty feature allowing you to rewrite, e.g. just
the last 8 commits of a linear history
  git filter-branch $OPTIONS HEAD~8..HEAD

If you try the same with git fast-export, you instead get a history of
only 8 commits, with HEAD~7 being rewritten into a root commit.  There
are two alternatives:

  1) Don't use the negative revision specification, and when you're
     filtering the output to make modifications to the last 8 commits,
     just be careful to not modify any earlier commits somehow.

  2) First run 'git fast-export --export-marks=somefile HEAD~8', then
     run 'git fast-export --import-marks=somefile HEAD~8..HEAD'.

Both are more error prone than I'd like (the first for obvious reasons;
with the second option I have sometimes accidentally included too many
revisions in the first command and then found that the corresponding
extra revisions were not exported by the second command and thus were
not modified as I expected).  Also, both are poor from a performance
perspective.

Add a new --reference-excluded-parents option which will cause
fast-export to refer to commits outside the specified rev-list-args
range by their sha1sum.  Such a stream will only be useful in a
repository which already contains the necessary commits (much like the
restriction imposed when using --no-data).

Note from Peff:
  I think we might be able to do a little more optimization here. If
  we're exporting HEAD^..HEAD and there's an object in HEAD^ which is
  unchanged in HEAD, I think we'd still print it (because it would not
  be marked SHOWN), but we could omit it (by walking the tree of the
  boundary commits and marking them shown).  I don't think it's a
  blocker for what you're doing here, but just a possible future
  optimization.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofast-export: ensure we export requested refs
Elijah Newren [Fri, 16 Nov 2018 07:59:53 +0000 (23:59 -0800)] 
fast-export: ensure we export requested refs

If file paths are specified to fast-export and a ref points to a commit
that does not touch any of the relevant paths, then that ref would
sometimes fail to be exported.  (This depends on whether any ancestors
of the commit which do touch the relevant paths would be exported with
that same ref name or a different ref name.)  To avoid this problem,
put *all* specified refs into extra_refs to start, and then as we export
each commit, remove the refname used in the 'commit $REFNAME' directive
from extra_refs.  Then, in handle_tags_and_duplicates() we know which
refs actually do need a manual reset directive in order to be included.

This means that we do need some special handling for excluded refs; e.g.
if someone runs
   git fast-export ^master master
then they've asked for master to be exported, but they have also asked
for the commit which master points to and all of its history to be
excluded.  That logically means ref deletion.  Previously, such refs
were just silently omitted from being exported despite having been
explicitly requested for export.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofast-export: when using paths, avoid corrupt stream with non-existent mark
Elijah Newren [Fri, 16 Nov 2018 07:59:52 +0000 (23:59 -0800)] 
fast-export: when using paths, avoid corrupt stream with non-existent mark

If file paths are specified to fast-export and multiple refs point to a
commit that does not touch any of the relevant file paths, then
fast-export can hit problems.  fast-export has a list of additional refs
that it needs to explicitly set after exporting all blobs and commits,
and when it tries to get_object_mark() on the relevant commit, it can
get a mark of 0, i.e. "not found", because the commit in question did
not touch the relevant paths and thus was not exported.  Trying to
import a stream with a mark corresponding to an unexported object will
cause fast-import to crash.

Avoid this problem by taking the commit the ref points to and finding an
ancestor of it that was exported, and make the ref point to that commit
instead.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofast-export: move commit rewriting logic into a function for reuse
Elijah Newren [Fri, 16 Nov 2018 07:59:51 +0000 (23:59 -0800)] 
fast-export: move commit rewriting logic into a function for reuse

Logic to replace a filtered commit with an unfiltered ancestor is useful
elsewhere; put it into a function we can call.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofast-export: avoid dying when filtering by paths and old tags exist
Elijah Newren [Fri, 16 Nov 2018 07:59:50 +0000 (23:59 -0800)] 
fast-export: avoid dying when filtering by paths and old tags exist

If --tag-of-filtered-object=rewrite is specified along with a set of
paths to limit what is exported, then any tags pointing to old commits
that do not contain any of those specified paths cause problems.  Since
the old tagged commit is not exported, fast-export attempts to rewrite
such tags to an ancestor commit which was exported.  If no such commit
exists, then fast-export currently die()s.  Five years after the tag
rewriting logic was added to fast-export (see commit 2d8ad4691921,
"fast-export: Add a --tag-of-filtered-object  option for newly dangling
tags", 2009-06-25), fast-import gained the ability to delete refs (see
commit 4ee1b225b99f, "fast-import: add support to delete refs",
2014-04-20), so now we do have a valid option to rewrite the tag to.
Delete these tags instead of dying.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofast-export: use value from correct enum
Elijah Newren [Fri, 16 Nov 2018 07:59:49 +0000 (23:59 -0800)] 
fast-export: use value from correct enum

ABORT and ERROR happen to have the same value, but come from differnt
enums.  Use the one from the correct enum, and while at it, rename the
values to avoid such problems.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-fast-export.txt: clarify misleading documentation about rev-list args
Elijah Newren [Fri, 16 Nov 2018 07:59:48 +0000 (23:59 -0800)] 
git-fast-export.txt: clarify misleading documentation about rev-list args

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-fast-import.txt: fix documentation for --quiet option
Elijah Newren [Fri, 16 Nov 2018 07:59:47 +0000 (23:59 -0800)] 
git-fast-import.txt: fix documentation for --quiet option

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofast-export: convert sha1 to oid
Elijah Newren [Fri, 16 Nov 2018 07:59:46 +0000 (23:59 -0800)] 
fast-export: convert sha1 to oid

Rename anonymize_sha1() to anonymize_oid(() and change its signature,
and switch from sha1_to_hex() to oid_to_hex() and from GIT_SHA1_RAWSZ to
the_hash_algo->rawsz.  Also change a comment and a die string to mention
oid instead of sha1.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobundle: dup() output descriptor closer to point-of-use
Jeff King [Fri, 16 Nov 2018 09:43:59 +0000 (04:43 -0500)] 
bundle: dup() output descriptor closer to point-of-use

When writing a bundle to a file, the bundle code actually creates
"your.bundle.lock" using our lockfile interface. We feed that output
descriptor to a child git-pack-objects via run-command, which has the
quirk that it closes the output descriptor in the parent.

To avoid confusing the lockfile code (which still thinks the descriptor
is valid), we dup() it, and operate on the duplicate.

However, this has a confusing side effect: after the dup() but before we
call pack-objects, we have _two_ descriptors open to the lockfile. If we
call die() during that time, the lockfile code will try to clean up the
partially-written file. It knows to close() the file before unlinking,
since on some platforms (i.e., Windows) the open file would block the
deletion. But it doesn't know about the duplicate descriptor. On
Windows, triggering an error at the right part of the code will result
in the cleanup failing and the lockfile being left in the filesystem.

We can solve this by moving the dup() much closer to start_command(),
shrinking the window in which we have the second descriptor open. It's
easy to place this in such a way that no die() is possible. We could
still die due to a signal in the exact wrong moment, but we already
tolerate races there (e.g., a signal could come before we manage to put
the file on the cleanup list in the first place).

As a bonus, this shields create_bundle() itself from the duplicate-fd
trick, and we can simplify its error handling (note that the lock
rollback now happens unconditionally, but that's OK; it's a noop if we
didn't open the lock in the first place).

The included test uses an empty bundle to cause a failure at the right
spot in the code, because that's easy to trigger (the other likely
errors are write() problems like ENOSPC).  Note that it would already
pass on non-Windows systems (because they are happy to unlink an
already-open file).

Based-on-a-patch-by: Gaël Lhez <gael.lhez@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Tested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotests: add a special setup where rebase.useBuiltin is off
Ævar Arnfjörð Bjarmason [Wed, 14 Nov 2018 09:15:06 +0000 (09:15 +0000)] 
tests: add a special setup where rebase.useBuiltin is off

Add a GIT_TEST_REBASE_USE_BUILTIN=false test mode which is equivalent
to running with rebase.useBuiltin=false. This is needed to spot that
we're not introducing any regressions in the legacy rebase version
while we're carrying both it and the new builtin version.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorebase doc: document rebase.useBuiltin
Ævar Arnfjörð Bjarmason [Wed, 14 Nov 2018 09:15:05 +0000 (09:15 +0000)] 
rebase doc: document rebase.useBuiltin

The rebase.useBuiltin variable introduced in 55071ea248 ("rebase:
start implementing it as a builtin", 2018-08-07) was turned on by
default in 5541bd5b8f ("rebase: default to using the builtin rebase",
2018-08-08), but had no documentation.

Let's document it so that users who run into any stability issues with
the C rewrite know there's an escape hatch[1], and make it clear that
needing to turn off builtin rebase means you've found a bug in git.

1. https://public-inbox.org/git/87y39w1wc2.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agomingw: replace an obsolete link with the superseding one
Johannes Schindelin [Thu, 15 Nov 2018 11:22:40 +0000 (03:22 -0800)] 
mingw: replace an obsolete link with the superseding one

The MSDN documentation has been superseded by Microsoft Docs (which is
backed by a repository on GitHub containing many, many files in Markdown
format).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMakefile: use FUZZ_CXXFLAGS for linking fuzzers
Josh Steadmon [Wed, 14 Nov 2018 19:41:47 +0000 (11:41 -0800)] 
Makefile: use FUZZ_CXXFLAGS for linking fuzzers

OSS-Fuzz requires C++-specific flags to link fuzzers. Passing these in
CFLAGS causes lots of build warnings. Using separate FUZZ_CXXFLAGS
avoids this.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotests: explicitly use `git.exe` on Windows
Johannes Schindelin [Wed, 14 Nov 2018 16:32:11 +0000 (08:32 -0800)] 
tests: explicitly use `git.exe` on Windows

On Windows, when we refer to `/an/absolute/path/to/git`, it magically
resolves `git.exe` at that location. Except if something of the name
`git` exists next to that `git.exe`. So if we call `$BUILD_DIR/git`, it
will find `$BUILD_DIR/git.exe` *only* if there is not, say, a directory
called `$BUILD_DIR/git`.

Such a directory, however, exists in Git for Windows when building with
Visual Studio (our Visual Studio project generator defaults to putting
the build files into a directory whose name is the base name of the
corresponding `.exe`).

In the bin-wrappers/* scripts, we already take pains to use `git.exe`
rather than `git`, as this could pick up the wrong thing on Windows
(i.e. if there exists a `git` file or directory in the build directory).

Now we do the same in the tests' start-up code.

This also helps when testing an installed Git, as there might be even
more likely some stray file or directory in the way.

Note: the only way we can record whether the `.exe` suffix is by writing
it to the `GIT-BUILD-OPTIONS` file and sourcing it at the beginning of
`t/test-lib.sh`. This is not a requirement introduced by this patch, but
we move the call to be able to use the `$X` variable that holds the file
extension, if any.

Note also: the many, many calls to `git this` and `git that` are
unaffected, as the regular PATH search will find the `.exe` files on
Windows (and not be confused by a directory of the name `git` that is
in one of the directories listed in the `PATH` variable), while
`/path/to/git` would not, per se, know that it is looking for an
executable and happily prefer such a directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotests: do not require Git to be built when testing an installed Git
Johannes Schindelin [Wed, 14 Nov 2018 16:32:10 +0000 (08:32 -0800)] 
tests: do not require Git to be built when testing an installed Git

We really only need the test helpers to be built in the worktree in that
case, but that is not what we test for.

On the other hand it is a perfect opportunity to verify that
`GIT_TEST_INSTALLED` points to a working Git.

So let's test the appropriate Git executable. While at it, also adjust
the error message in the `GIT_TEST_INSTALLED` case.

This patch is best viewed with `-w --patience`.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodoc: move extensions.worktreeConfig to the right place
Nguyễn Thái Ngọc Duy [Wed, 14 Nov 2018 16:02:47 +0000 (17:02 +0100)] 
doc: move extensions.worktreeConfig to the right place

All config extensions are described in technical/repository-version.txt.
I made a mistake of adding it in config.txt instead. This patch moves
it back to where it belongs.

Since repository-version.txt is not part of officially generated
documents (it's not even part of DOC_HTML target), it's only visible
to developers who read plain .txt files. Let's include it in
gitrepository-layout.5 for more visibility. Some minor asciidoc fixes
are required in repository-version.txt to make this happen.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref-filter: don't look for objects when outside of a repository
SZEDER Gábor [Wed, 14 Nov 2018 12:27:25 +0000 (13:27 +0100)] 
ref-filter: don't look for objects when outside of a repository

The command 'git ls-remote --sort=authordate <remote>' segfaults when
run outside of a repository, ever since the introduction of its
'--sort' option in 1fb20dfd8e (ls-remote: create '--sort' option,
2018-04-09).

While in general the 'git ls-remote' command can be run outside of a
repository just fine, its '--sort=<key>' option with certain keys does
require access to the referenced objects.  This sorting is implemented
using the generic ref-filter sorting facility, which already handles
missing objects gracefully with the appropriate 'missing object
deadbeef for HEAD' message.  However, being generic means that it
checks replace refs while trying to retrieve an object, and while
doing so it accesses the 'git_replace_ref_base' variable, which has
not been initialized and is still a NULL pointer when outside of a
repository, thus causing the segfault.

Make ref-filter more careful upfront while parsing the format string,
and make it error out when encountering a format atom requiring object
access when we are not in a repository.  Also add a test to ensure
that 'git ls-remote --sort' fails gracefully when executed outside of
a repository.

Reported-by: H.Merijn Brand <h.m.brand@xs4all.nl>
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoDocumentation/clone: document ignored configuration variables
SZEDER Gábor [Wed, 14 Nov 2018 10:46:20 +0000 (11:46 +0100)] 
Documentation/clone: document ignored configuration variables

Due to limitations in the current implementation, some configuration
variables specified via 'git clone -c var=val' (or 'git -c var=val
clone') are ignored during the initial fetch and checkout.

Let the users know which configuration variables are known to be
ignored ('remote.origin.mirror' and 'remote.origin.tagOpt') under the
documentation of 'git clone -c', along with hints to use the options
'--mirror' and '--no-tags' instead.

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>
7 years agoclone: respect additional configured fetch refspecs during initial fetch
SZEDER Gábor [Wed, 14 Nov 2018 10:46:19 +0000 (11:46 +0100)] 
clone: respect additional configured fetch refspecs during initial fetch

The initial fetch during a clone doesn't transfer refs matching
additional fetch refspecs given on the command line as configuration
variables, e.g. '-c remote.origin.fetch=<refspec>'.  This contradicts
the documentation stating that configuration variables specified via
'git clone -c <key>=<value> ...' "take effect immediately after the
repository is initialized, but before the remote history is fetched"
and the given example specifically mentions "adding additional fetch
refspecs to the origin remote".  Furthermore, one-shot configuration
variables specified via 'git -c <key>=<value> clone ...', though not
written to the newly created repository's config file, live during the
lifetime of the 'clone' command, including the initial fetch.  All
this implies that any fetch refspecs specified this way should already
be taken into account during the initial fetch.

The reason for this is that the initial fetch is not a fully fledged
'git fetch' but a bunch of direct calls into the fetch/transport
machinery with clone's own refs-to-refspec matching logic, which
bypasses parts of 'git fetch' processing configured fetch refspecs.
This logic only considers a single default refspec, potentially
influenced by options like '--single-branch' and '--mirror'.  The
configured refspecs are, however, already read and parsed properly
when clone calls remote.c:remote_get(), but it never looks at the
parsed refspecs in the resulting 'struct remote'.

Modify clone to take the remote's configured fetch refspecs into
account to retrieve all matching refs during the initial fetch.  Note
that we have to explicitly add the default fetch refspec to the
remote's refspecs, because at that point the remote only includes the
fetch refspecs specified on the command line.

Add tests to check that refspecs given both via 'git clone -c ...' and
'git -c ... clone' retrieve all refs matching either the default or
the additional refspecs, and that it works even when the user
specifies an alternative remote name via '--origin=<name>'.

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>
7 years agoclone: use a more appropriate variable name for the default refspec
SZEDER Gábor [Wed, 14 Nov 2018 10:46:18 +0000 (11:46 +0100)] 
clone: use a more appropriate variable name for the default refspec

cmd_clone() declares two strbufs 'key' and 'value' on the same line,
suggesting that they are used to contruct a config variable's name and
value.  However, this is not the case: 'key' is used to construct the
names of multiple config variables, while 'value' is never used as a
value for any of those config variables, or for any other config
variable for that matter, but only to contruct the default fetch
refspec.

Let's rename 'value' to 'default_refspec' to make the intent clearer.

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>
7 years agoconfig: report a bug if git_dir exists without commondir
Johannes Schindelin [Wed, 14 Nov 2018 13:59:02 +0000 (05:59 -0800)] 
config: report a bug if git_dir exists without commondir

This did happen at some stage, and was fixed relatively quickly. Make
sure that we detect very quickly, too, should that happen again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorebase: validate -C<n> and --whitespace=<mode> parameters early
Johannes Schindelin [Wed, 14 Nov 2018 16:25:31 +0000 (08:25 -0800)] 
rebase: validate -C<n> and --whitespace=<mode> parameters early

It is a good idea to error out early upon seeing, say, `-Cbad`, rather
than starting the rebase only to have the `--am` backend complain later.

Let's do this.

The only options accepting parameters which we pass through to `git am`
(which may, or may not, forward them to `git apply`) are `-C` and
`--whitespace`. The other options we pass through do not accept
parameters, so we do not have to validate them here.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorebase: really just passthru the `git am` options
Johannes Schindelin [Wed, 14 Nov 2018 16:25:29 +0000 (08:25 -0800)] 
rebase: really just passthru the `git am` options

Currently, we parse the options intended for `git am` as if we wanted to
handle them in `git rebase`, and then reconstruct them painstakingly to
define the `git_am_opt` variable.

However, there is a much better way (that I was unaware of, at the time
when I mentored Pratik to implement these options): OPT_PASSTHRU_ARGV.
It is intended for exactly this use case, where command-line options
want to be parsed into a separate `argv_array`.

Let's use this feature.

Incidentally, this also allows us to address a bug discovered by Phillip
Wood, where the built-in rebase failed to understand that the `-C`
option takes an optional argument.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopretty: prepare format_commit_message to handle arbitrary repositories
Stefan Beller [Wed, 14 Nov 2018 00:13:00 +0000 (16:13 -0800)] 
pretty: prepare format_commit_message to handle arbitrary repositories

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit: prepare logmsg_reencode to handle arbitrary repositories
Stefan Beller [Wed, 14 Nov 2018 00:12:59 +0000 (16:12 -0800)] 
commit: prepare logmsg_reencode to handle arbitrary repositories

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit: prepare repo_unuse_commit_buffer to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:58 +0000 (16:12 -0800)] 
commit: prepare repo_unuse_commit_buffer to handle any repo

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit: prepare get_commit_buffer to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:57 +0000 (16:12 -0800)] 
commit: prepare get_commit_buffer to handle any repo

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit-reach: prepare in_merge_bases[_many] to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:56 +0000 (16:12 -0800)] 
commit-reach: prepare in_merge_bases[_many] to handle any repo

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit-reach: prepare get_merge_bases to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:55 +0000 (16:12 -0800)] 
commit-reach: prepare get_merge_bases to handle any repo

Similarly to previous patches, the get_merge_base functions are used
often in the code base, which makes migrating them hard.

Implement the new functions, prefixed with 'repo_' and hide the old
functions behind a wrapper macro.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit-reach.c: allow get_merge_bases_many_0 to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:54 +0000 (16:12 -0800)] 
commit-reach.c: allow get_merge_bases_many_0 to handle any repo

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit-reach.c: allow remove_redundant to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:53 +0000 (16:12 -0800)] 
commit-reach.c: allow remove_redundant to handle any repo

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit-reach.c: allow merge_bases_many to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:52 +0000 (16:12 -0800)] 
commit-reach.c: allow merge_bases_many to handle any repo

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit-reach.c: allow paint_down_to_common to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:51 +0000 (16:12 -0800)] 
commit-reach.c: allow paint_down_to_common to handle any repo

As the function is file local and not widely used, migrate it all at once.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocommit: allow parse_commit* to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:50 +0000 (16:12 -0800)] 
commit: allow parse_commit* to handle any repo

Just like the previous commit, parse_commit and friends are used a lot
and are found in new patches, so we cannot change their signature easily.

Re-introduce these function prefixed with 'repo_' that take a repository
argument and keep the original as a shallow macro.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoobject: parse_object to honor its repository argument
Stefan Beller [Wed, 14 Nov 2018 00:12:49 +0000 (16:12 -0800)] 
object: parse_object to honor its repository argument

In 8e4b0b6047 (object.c: allow parse_object to handle
arbitrary repositories, 2018-06-28), we forgot to pass the
repository down to the read_object_file.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoobject-store: prepare has_{sha1, object}_file to handle any repo
Stefan Beller [Wed, 14 Nov 2018 00:12:48 +0000 (16:12 -0800)] 
object-store: prepare has_{sha1, object}_file to handle any repo

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