git
5 years agoMerge branch 'jk/tests-timestamp-fix' into master
Junio C Hamano [Thu, 30 Jul 2020 20:20:31 +0000 (13:20 -0700)] 
Merge branch 'jk/tests-timestamp-fix' into master

The test framework has been updated so that most tests will run
with predictable (artificial) timestamps.

* jk/tests-timestamp-fix:
  t9100: stop depending on commit timestamps
  test-lib: set deterministic default author/committer date
  t9100: explicitly unset GIT_COMMITTER_DATE
  t5539: make timestamp requirements more explicit
  t9700: loosen ident timezone regex
  t6000: use test_tick consistently

5 years agoMerge branch 'ds/commit-graph-bloom-updates' into master
Junio C Hamano [Thu, 30 Jul 2020 20:20:31 +0000 (13:20 -0700)] 
Merge branch 'ds/commit-graph-bloom-updates' into master

Updates to the changed-paths bloom filter.

* ds/commit-graph-bloom-updates:
  commit-graph: check all leading directories in changed path Bloom filters
  revision: empty pathspecs should not use Bloom filters
  revision.c: fix whitespace
  commit-graph: check chunk sizes after writing
  commit-graph: simplify chunk writes into loop
  commit-graph: unify the signatures of all write_graph_chunk_*() functions
  commit-graph: persist existence of changed-paths
  bloom: fix logic in get_bloom_filter()
  commit-graph: change test to die on parse, not load
  commit-graph: place bloom_settings in context

5 years agoMerge branch 'sg/commit-graph-cleanups' into master
Junio C Hamano [Thu, 30 Jul 2020 20:20:30 +0000 (13:20 -0700)] 
Merge branch 'sg/commit-graph-cleanups' into master

The changed-path Bloom filter is improved using ideas from an
independent implementation.

* sg/commit-graph-cleanups:
  commit-graph: simplify write_commit_graph_file() #2
  commit-graph: simplify write_commit_graph_file() #1
  commit-graph: simplify parse_commit_graph() #2
  commit-graph: simplify parse_commit_graph() #1
  commit-graph: clean up #includes
  diff.h: drop diff_tree_oid() & friends' return value
  commit-slab: add a function to deep free entries on the slab
  commit-graph-format.txt: all multi-byte numbers are in network byte order
  commit-graph: fix parsing the Chunk Lookup table
  tree-walk.c: don't match submodule entries for 'submod/anything'

5 years agoGit 2.28 v2.28.0
Junio C Hamano [Mon, 27 Jul 2020 01:01:43 +0000 (18:01 -0700)] 
Git 2.28

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge tag 'l10n-2.28.0-rnd1' of https://www.github.com/git-l10n/git-po into master
Junio C Hamano [Sun, 26 Jul 2020 16:48:11 +0000 (09:48 -0700)] 
Merge tag 'l10n-2.28.0-rnd1' of https://github.com/git-l10n/git-po into master

l10n-2.28.0-rnd1

* tag 'l10n-2.28.0-rnd1' of https://www.github.com/git-l10n/git-po:
  l10n: es: 2.28.0 round 1
  l10n: de.po: Update German translation for Git v2.28.0
  l10n: de.po: fix grammar
  l10n: zh_CN: for git v2.28.0 l10n round 1
  l10n: zh_TW.po: v2.28.0 round 1 (0 untranslated)
  l10n: vi.po: correct "ident line" translation
  l10n: vi.po(4931t): Updated translation for v2.28.0
  l10n: fr v2.28.0 round 1
  l10n: sv.po: Update Swedish translation (4931t0f0u)
  l10n: it.po: update the Italian translation for Git 2.28.0 round 1
  l10n: tr: v2.28.0 round 1
  l10n: git.pot: v2.28.0 round 1 (70 new, 14 removed)
  l10n: Update Catalan translation

5 years agoMerge branch 'master' of github.com:Softcatala/git-po
Jiang Xin [Sun, 26 Jul 2020 16:05:41 +0000 (00:05 +0800)] 
Merge branch 'master' of github.com:Softcatala/git-po

* 'master' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

5 years agol10n: es: 2.28.0 round 1
Christopher Diaz Riveros [Sun, 26 Jul 2020 15:12:01 +0000 (10:12 -0500)] 
l10n: es: 2.28.0 round 1

Signed-off-by: Christopher Diaz Riveros <christopher.diaz.riv@gmail.com>
5 years agoMerge branch 'ps/ref-transaction-hook' into master
Junio C Hamano [Fri, 24 Jul 2020 22:54:05 +0000 (15:54 -0700)] 
Merge branch 'ps/ref-transaction-hook' into master

A new hook.

* ps/ref-transaction-hook:
  githooks.txt: use correct "reference-transaction" hook name

5 years agogithooks.txt: use correct "reference-transaction" hook name
Bojun Chen [Fri, 24 Jul 2020 13:57:57 +0000 (13:57 +0000)] 
githooks.txt: use correct "reference-transaction" hook name

The "reference transaction" hook was introduced in commit 6754159767
(refs: implement reference transaction hook, 2020-06-19). The name of
the hook is declared as "reference-transaction" in "refs.c" and
testcases, but the name declared in "githooks.txt" is different.

Signed-off-by: Bojun Chen <bojun.cbj@alibaba-inc.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agol10n: de.po: Update German translation for Git v2.28.0
Matthias Rüster [Sun, 12 Jul 2020 11:18:30 +0000 (13:18 +0200)] 
l10n: de.po: Update German translation for Git v2.28.0

Reviewed-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com>
5 years agol10n: de.po: fix grammar
Ralf Thielow [Sun, 5 Jul 2020 15:35:21 +0000 (17:35 +0200)] 
l10n: de.po: fix grammar

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com>
5 years agoDocumentation/RelNotes: fix a typo in 2.28's relnotes
Taylor Blau [Wed, 22 Jul 2020 20:29:40 +0000 (16:29 -0400)] 
Documentation/RelNotes: fix a typo in 2.28's relnotes

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoGit 2.28-rc2 v2.28.0-rc2
Junio C Hamano [Wed, 22 Jul 2020 16:30:01 +0000 (09:30 -0700)] 
Git 2.28-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'en/sparse-status' into master
Junio C Hamano [Tue, 21 Jul 2020 21:19:09 +0000 (14:19 -0700)] 
Merge branch 'en/sparse-status' into master

Fix to a "git prompt" regression during this development cycle.

* en/sparse-status:
  git-prompt: change == to = for zsh's sake

5 years agol10n: zh_CN: for git v2.28.0 l10n round 1
Jiang Xin [Fri, 10 Jul 2020 02:32:01 +0000 (10:32 +0800)] 
l10n: zh_CN: for git v2.28.0 l10n round 1

Translate 70 new messages (4931t0f0u) for git 2.28.0.

Reviewed-by: Fangyi Zhou <me@fangyi.io>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
5 years agoMerge branch 'l10n/zh_TW/200716' of github.com:l10n-tw/git-po
Jiang Xin [Tue, 21 Jul 2020 08:00:54 +0000 (16:00 +0800)] 
Merge branch 'l10n/zh_TW/200716' of github.com:l10n-tw/git-po

* 'l10n/zh_TW/200716' of github.com:l10n-tw/git-po:
  l10n: zh_TW.po: v2.28.0 round 1 (0 untranslated)

5 years agogit-prompt: change == to = for zsh's sake
David J. Malan [Tue, 21 Jul 2020 00:15:31 +0000 (00:15 +0000)] 
git-prompt: change == to = for zsh's sake

When using git-prompt.sh with zsh, __git_ps1 currently errs
when inside a repo with:

__git_ps1:96: = not found

Avoid using non-portable "==" that is only understood by bash
and not zsh. Change to "=" so that the prompt script becomes
usable with zsh again.

Signed-off-by: David J. Malan <malan@harvard.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge https://github.com/prati0100/git-gui into master
Junio C Hamano [Mon, 20 Jul 2020 19:04:06 +0000 (12:04 -0700)] 
Merge https://github.com/prati0100/git-gui into master

* https://github.com/prati0100/git-gui:
  git-gui: allow opening work trees from the startup dialog

5 years agol10n: zh_TW.po: v2.28.0 round 1 (0 untranslated)
Yi-Jyun Pan [Thu, 16 Jul 2020 10:40:58 +0000 (18:40 +0800)] 
l10n: zh_TW.po: v2.28.0 round 1 (0 untranslated)

Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
5 years agol10n: vi.po: correct "ident line" translation
Đoàn Trần Công Danh [Thu, 16 Jul 2020 13:32:51 +0000 (20:32 +0700)] 
l10n: vi.po: correct "ident line" translation

While we're at it, fix some minor misspelling
and improve translation for 3-way-merging.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
5 years agol10n: vi.po(4931t): Updated translation for v2.28.0
Tran Ngoc Quan [Wed, 15 Jul 2020 08:31:56 +0000 (15:31 +0700)] 
l10n: vi.po(4931t): Updated translation for v2.28.0

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
5 years agoMerge branch 'dl/branch-cleanup' into master
Junio C Hamano [Sat, 18 Jul 2020 23:35:22 +0000 (16:35 -0700)] 
Merge branch 'dl/branch-cleanup' into master

Last minute fix-up to tests for portability.

* dl/branch-cleanup:
  t3200: don't grep for `strerror()` string

5 years agoMerge branch 'js/pu-to-seen' into master
Junio C Hamano [Sat, 18 Jul 2020 23:35:21 +0000 (16:35 -0700)] 
Merge branch 'js/pu-to-seen' into master

Last minute fix-up to documentation.

* js/pu-to-seen:
  gitworkflows.txt: fix broken subsection underline

5 years agoMerge branch 'jc/relnotes-v0-extension-update' into master
Junio C Hamano [Sat, 18 Jul 2020 23:35:20 +0000 (16:35 -0700)] 
Merge branch 'jc/relnotes-v0-extension-update' into master

Last minute fix-up to the release notes.

* jc/relnotes-v0-extension-update:
  RelNotes: update the v0 with extension situation

5 years agot3200: don't grep for `strerror()` string
Martin Ågren [Sat, 18 Jul 2020 09:48:40 +0000 (11:48 +0200)] 
t3200: don't grep for `strerror()` string

In 6b7093064a ("t3200: test for specific errors", 2020-06-15), we
learned to grep stderr to ensure that the failing `git branch`
invocations fail for the right reason. In two of these tests, we grep
for "File exists", expecting the string to show up there since config.c
calls `error_errno()`, which ends up including `strerror(errno)` in the
error message.

But as we saw in 4605a73073 ("t1091: don't grep for `strerror()`
string", 2020-03-08), there exists at least one implementation where
`strerror()` yields a slightly different string than the one we're
grepping for. In particular, these tests fail on the NonStop platform.

Similar to 4605a73073, grep for the beginning of the string instead to
avoid relying on `strerror()` behavior.

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agogitworkflows.txt: fix broken subsection underline
Martin Ågren [Sat, 18 Jul 2020 20:17:23 +0000 (22:17 +0200)] 
gitworkflows.txt: fix broken subsection underline

AsciiDoctor renders the "~~~~~~~~~" literally. That's not our intention:
it is supposed to indicate a level 2 subsection. In 828197de8f ("docs:
adjust for the recent rename of `pu` to `seen`", 2020-06-25), the length
of this section header grew by two characters but we didn't adjust the
number of ~ characters accordingly. AsciiDoc handles this discrepancy ok
and still picks this up as a subsection title, but Asciidoctor is not as
forgiving.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoRelNotes: update the v0 with extension situation
Junio C Hamano [Fri, 17 Jul 2020 20:33:04 +0000 (13:33 -0700)] 
RelNotes: update the v0 with extension situation

With the two-patch series for regression fix, to the users from 2.27
days, there is no visible behaviour change---we do not warn and fail
use of v0 repositories with newer extensions yet, so there is nothing
to note in the backward compatibility section.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoGit 2.28-rc1 v2.28.0-rc1
Junio C Hamano [Fri, 17 Jul 2020 01:02:52 +0000 (18:02 -0700)] 
Git 2.28-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'jn/v0-with-extensions-fix' into master
Junio C Hamano [Fri, 17 Jul 2020 00:58:42 +0000 (17:58 -0700)] 
Merge branch 'jn/v0-with-extensions-fix' into master

In 2.28-rc0, we corrected a bug that some repository extensions are
honored by mistake even in a version 0 repositories (these
configuration variables in extensions.* namespace were supposed to
have special meaning in repositories whose version numbers are 1 or
higher), but this was a bit too big a change.

* jn/v0-with-extensions-fix:
  repository: allow repository format upgrade with extensions
  Revert "check_repository_format_gently(): refuse extensions for old repositories"

5 years agorepository: allow repository format upgrade with extensions
Jonathan Nieder [Thu, 16 Jul 2020 06:28:18 +0000 (23:28 -0700)] 
repository: allow repository format upgrade with extensions

Now that we officially permit repository extensions in repository
format v0, permit upgrading a repository with extensions from v0 to v1
as well.

For example, this means a repository where the user has set
"extensions.preciousObjects" can use "git fetch --filter=blob:none
origin" to upgrade the repository to use v1 and the partial clone
extension.

To avoid mistakes, continue to forbid repository format upgrades in v0
repositories with an unrecognized extension.  This way, a v0 user
using a misspelled extension field gets a chance to correct the
mistake before updating to the less forgiving v1 format.

While we're here, make the error message for failure to upgrade the
repository format a bit shorter, and present it as an error, not a
warning.

Reported-by: Huan Huan Chen <huanhuanchen@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoRevert "check_repository_format_gently(): refuse extensions for old repositories"
Jonathan Nieder [Thu, 16 Jul 2020 06:24:29 +0000 (23:24 -0700)] 
Revert "check_repository_format_gently(): refuse extensions for old repositories"

This reverts commit 14c7fa269e42df4133edd9ae7763b678ed6594cd.

The core.repositoryFormatVersion field was introduced in ab9cb76f661
(Repository format version check., 2005-11-25), providing a welcome
bit of forward compatibility, thanks to some welcome analysis by
Martin Atukunda.  The semantics are simple: a repository with
core.repositoryFormatVersion set to 0 should be comprehensible by all
Git implementations in active use; and Git implementations should
error out early instead of trying to act on Git repositories with
higher core.repositoryFormatVersion values representing new formats
that they do not understand.

A new repository format did not need to be defined until 00a09d57eb8
(introduce "extensions" form of core.repositoryformatversion,
2015-06-23).  This provided a finer-grained extension mechanism for
Git repositories.  In a repository with core.repositoryFormatVersion
set to 1, Git implementations can act on "extensions.*" settings that
modify how a repository is interpreted.  In repository format version
1, unrecognized extensions settings cause Git to error out.

What happens if a user sets an extension setting but forgets to
increase the repository format version to 1?  The extension settings
were still recognized in that case; worse, unrecognized extensions
settings do *not* cause Git to error out.  So combining repository
format version 0 with extensions settings produces in some sense the
worst of both worlds.

To improve that situation, since 14c7fa269e4
(check_repository_format_gently(): refuse extensions for old
repositories, 2020-06-05) Git instead ignores extensions in v0 mode.
This way, v0 repositories get the historical (pre-2015) behavior and
maintain compatibility with Git implementations that do not know about
the v1 format.  Unfortunately, users had been using this sort of
configuration and this behavior change came to many as a surprise:

- users of "git config --worktree" that had followed its advice
  to enable extensions.worktreeConfig (without also increasing the
  repository format version) would find their worktree configuration
  no longer taking effect

- tools such as copybara[*] that had set extensions.partialClone in
  existing repositories (without also increasing the repository format
  version) would find that setting no longer taking effect

The behavior introduced in 14c7fa269e4 might be a good behavior if we
were traveling back in time to 2015, but we're far too late.  For some
reason I thought that it was what had been originally implemented and
that it had regressed.  Apologies for not doing my research when
14c7fa269e4 was under development.

Let's return to the behavior we've had since 2015: always act on
extensions.* settings, regardless of repository format version.  While
we're here, include some tests to describe the effect on the "upgrade
repository version" code path.

[*] https://github.com/google/copybara/commit/ca76c0b1e13c4e36448d12c2aba4a5d9d98fb6e7

Reported-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoHopefully the last batch before -rc1
Junio C Hamano [Wed, 15 Jul 2020 23:29:51 +0000 (16:29 -0700)] 
Hopefully the last batch before -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'tb/commit-graph-no-check-oids' into master
Junio C Hamano [Wed, 15 Jul 2020 23:29:45 +0000 (16:29 -0700)] 
Merge branch 'tb/commit-graph-no-check-oids' into master

Fix to the code to produce progress bar, which is new in the
upcoming release.

* tb/commit-graph-no-check-oids:
  commit-graph: fix "Collecting commits from input" progress line

5 years agoMerge branch 'ct/diff-with-merge-base-clarification' into master
Junio C Hamano [Wed, 15 Jul 2020 23:29:44 +0000 (16:29 -0700)] 
Merge branch 'ct/diff-with-merge-base-clarification' into master

Doc update.

* ct/diff-with-merge-base-clarification:
  git-diff.txt: reorder possible usages
  git-diff.txt: don't mark required argument as optional

5 years agoMerge branch 'sg/commit-graph-progress-fix' into master
Junio C Hamano [Wed, 15 Jul 2020 23:29:43 +0000 (16:29 -0700)] 
Merge branch 'sg/commit-graph-progress-fix' into master

The code to produce progress output from "git commit-graph --write"
had a few breakages, which have been fixed.

* sg/commit-graph-progress-fix:
  commit-graph: fix "Writing out commit graph" progress counter
  commit-graph: fix progress of reachable commits

5 years agoMerge branch 'ta/wait-on-aliased-commands-upon-signal' into master
Junio C Hamano [Wed, 15 Jul 2020 23:29:43 +0000 (16:29 -0700)] 
Merge branch 'ta/wait-on-aliased-commands-upon-signal' into master

When an aliased command, whose output is piped to a pager by git,
gets killed by a signal, the pager got into a funny state, which
has been corrected (again).

* ta/wait-on-aliased-commands-upon-signal:
  Wait for child on signal death for aliases to externals
  Wait for child on signal death for aliases to builtins

5 years agocommit-graph: fix "Collecting commits from input" progress line
SZEDER Gábor [Fri, 10 Jul 2020 19:02:38 +0000 (21:02 +0200)] 
commit-graph: fix "Collecting commits from input" progress line

To display a progress line while reading commits from standard input
and looking them up, 5b6653e523 (builtin/commit-graph.c: dereference
tags in builtin, 2020-05-13) should have added a pair of
start_delayed_progress() and stop_progress() calls around the loop
reading stdin.  Alas, the stop_progress() call ended up at the wrong
place, after write_commit_graph(), which does all the commit-graph
computation and writing, and has several progress lines of its own.
Consequently, that new

  Collecting commits from input: 1234

progress line is overwritten by the first progress line shown by
write_commit_graph(), and its final "done" line is shown last, after
everything is finished:

  $ { sleep 3 ; git rev-list -3 HEAD ; sleep 1 ; } | ~/src/git/git commit-graph write --stdin-commits
  Expanding reachable commits in commit graph: 873402, done.
  Writing out commit graph in 4 passes: 100% (3493608/3493608), done.
  Collecting commits from input: 3, done.

Furthermore, that stop_progress() call was added after the 'cleanup'
label, where that loop reading stdin jumps in case of an error.  In
case of invalid input this then results in the "done" line shown after
the error message:

  $ { sleep 3 ; git rev-list -3 HEAD ; echo junk ; } | ~/src/git/git commit-graph write --stdin-commits
  error: unexpected non-hex object ID: junk
  Collecting commits from input: 3, done.

Move that stop_progress() call to the right place.

While at it, drop the unnecessary 'if (progress)' condition protecting
the stop_progress() call, because that function is prepared to handle
a NULL progress struct.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot9100: stop depending on commit timestamps
Jeff King [Wed, 15 Jul 2020 07:42:50 +0000 (03:42 -0400)] 
t9100: stop depending on commit timestamps

An earlier "fix" to this script gave up updating it not to rely on
the current time because we cannot control what timestamp subversion
gives its commits.  We however could solve the issue in a different
way and still use deterministic timestamps on Git commits.

One fix would be to sort the list of trees before removing duplicates,
but that loses information:

  - we do care that the fetched history is in the same order

  - there's a tree which appears twice in the history, and we'd want to
    make sure that it's there both times

So instead, let's de-duplicate using a hash (preserving the order), and
drop only lines with identical trees and subjects (preserving the tree
which appears twice, since it has different subjects each time).

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agotest-lib: set deterministic default author/committer date
Jeff King [Thu, 9 Jul 2020 20:42:04 +0000 (16:42 -0400)] 
test-lib: set deterministic default author/committer date

We always set the name and email for committer and author idents to make
the test suite more deterministic, but not timestamps. Many scripts use
test_tick to get consistent and sensibly incrementing timestamps as they
create commits. But other scripts don't particularly care about the
timestamp, and are happy to use whatever the current system time is.

This non-determinism can be annoying:

  - when debugging a test, comparing results between two runs can be
    difficult, because the commit ids change

  - this can sometimes cause tests to be racy. E.g., traversal order
    depends on timestamp order. Even in a well-ordered set of commands,
    because our timestamp granularity is one second, two commits might
    sometimes have the same timestamp and sometimes differ.

Let's set a default timestamp for all scripts to use. Any that use
test_tick already will be unaffected (because their first test_tick call
will overwrite our default), but it will make things a bit more
deterministic for those that don't.

We should be able to choose any time we want here. I picked this one
because:

  - it differs from the initial test_tick default, which may make it
    easier to distinguish when debugging tests. I picked "April 1st
    13:14:15" in the hope that it might stand out.

  - it's slightly before the test_tick default. Some tests create some
    commits before the first call to test_tick, so using an older
    timestamps for those makes sense chronologically. Note that this
    isn't how things currently work (where system times are usually more
    recent than test_tick), but that also allows us to flush out a few
    hidden timestamp dependencies (like the one recently fixed in
    t5539).

  - we could likewise pick any timezone we want. Choosing +0000 would
    have required fixing up fewer tests, but we're more likely to turn
    up interesting cases by not matching $TZ exactly. And since
    test_tick already checks "-0700", let's try something in the "+"
    zone range for variety.

It's possible that the non-deterministic times could help flush out bugs
(e.g., if something broke when the clock flipped over to 2021, our test
suite would let us know). But historically that hasn't been the case;
all time-dependent outcomes we've seen turned out to be accidentally
flaky tests (which we fixed by using test_tick). If we do want to cover
handling the current time, we should dedicate one script to doing so,
and have it unset GIT_COMMITTER_DATE explicitly.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot9100: explicitly unset GIT_COMMITTER_DATE
Jeff King [Tue, 14 Jul 2020 12:31:42 +0000 (08:31 -0400)] 
t9100: explicitly unset GIT_COMMITTER_DATE

The early part of t9100 creates an unusual "doubled" history in the
"git-svn" ref. When we get to t9100.17, it looks like this:

  $ git log --oneline --graph git-svn
  [...]
  *   efd0303 detect node change from file to directory #2
  |\
  * | 3e727c0 detect node change from file to directory #2
  |/
  *   3b00468 try a deep --rmdir with a commit
  |\
  * | b4832d8 try a deep --rmdir with a commit
  |/
  * f0d7bd5 import for git svn

Each commit we make with "git commit" is paired with one from "git svn
set-tree", with the latter as a merge of the first and its grandparent.

Later, t9100.17 wants to check that "git svn fetch" gets the same trees.
And it does, but just one copy of each. So it uses rev-list to get the
tree of each commit and pipes it to "uniq" to drop the duplicates. Our
input isn't sorted, but it will find adjacent duplicates. This works
reliably because the order of commits from rev-list always shows the
duplicates next to each other. For any one of those merges, we could
choose to show its duplicate or the grandparent first. But barring
clocks running backwards, the duplicate will always have a time equal to
or greater than the grandparent. Even if equal, we break ties by showing
the first-parent first, so the duplicates remain adjacent.

But this would break if the timestamps stopped moving in chronological
order. Normally we would rely on test_tick for this, but we have _two_
sources of time here:

  - "git commit" creates one commit based on GIT_COMMITTER_DATE (which
    respects test_tick)

  - the "svn set-tree" one is based on subversion, which does not have
    an easy way to specify a timestamp

So using test_tick actually breaks the test, because now the duplicates
are far in the past, and we'll show the grandparent before the
duplicate. And likewise, a proposed change to set GIT_COMMITTER_DATE in
all scripts will break it.

We _could_ fix this by sorting before removing duplicates, but
presumably it's a useful part of the test to make sure the trees appear
in the same order in both spots. Likewise, we could use something like:

  perl -ne 'print unless $seen{$_}++'

to remove duplicates without impacting the order. But that doesn't work
either, because there are actually multiple (non-duplicate) commits with
the same trees (we change a file mode and then change it back). So we'd
actually have to de-duplicate the combination of subject and tree. Which
then further throws off t9100.18, which compares the tree hashes
exactly; we'd have to strip the result back down.

Since this test _isn't_ buggy, the simplest thing is to just work around
the proposed change by documenting our expectation that git-created
commits are correctly interleaved using the current time.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agogit-diff.txt: reorder possible usages
Martin Ågren [Mon, 13 Jul 2020 19:10:09 +0000 (21:10 +0200)] 
git-diff.txt: reorder possible usages

The description of `git diff` goes through several different invocations
(numbering added by me):

  1. git diff [<options>] [--] [<path>...]
  2. git diff [<options>] --no-index [--] <path> <path>
  3. git diff [<options>] --cached [<commit>] [--] [<path>...]
  4. git diff [<options>] <commit> [--] [<path>...]
  5. git diff [<options>] <commit> <commit> [--] [<path>...]
  6. git diff [<options>] <commit>..<commit> [--] [<path>...]
  7. git diff [<options>] <commit> <commit>... <commit> [--] [<path>...]
  8. git diff [<options>] <commit>...<commit> [--] [<path>...]

It then goes on to say that "all of the <commit> in the above
description, except in the last two forms that use '..' notations, can
be any <tree>". The "last two" actually refers to 6 and 8. This got out
of sync in commit b7e10b2ca2 ("Documentation: usage for diff combined
commits", 2020-06-12) which added item 7 to the mix.

As a further complication, after b7e10b2ca2 we also have some potential
confusion around "the '..' notation". The "..[.]" in items 6 and 8 are
part of the rev notation, whereas the "..." in item 7 is manpage
language for "one or more".

Move item 6 down, i.e., to between 7 and 8, to restore the ordering.
Because 6 refers to 5 ("synonymous to the previous form") we need to
tweak the language a bit.

An added bonus of this commit is that we're trying to steer users away
from `git diff <commit>..<commit>` and moving it further down probably
doesn't hurt.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agogit-diff.txt: don't mark required argument as optional
Martin Ågren [Mon, 13 Jul 2020 19:10:08 +0000 (21:10 +0200)] 
git-diff.txt: don't mark required argument as optional

Commit b7e10b2ca2 ("Documentation: usage for diff combined commits",
2020-06-12) modified the synopsis by adding an optional "[<commit>...]"
to

  'git diff' [<options>] <commit> <commit> [--] [<path>...]

to effectively add

  'git diff' [<options>] <commit> <commit>... <commit> [--] [<path>...]

as another valid invocation. Which makes sense.

Further down, in the description, it left the existing entry for

  'git diff' [<options>] <commit> <commit> [--] [<path>...]

intact and added a new entry on

  'git diff' [<options>] <commit> [<commit>...] <commit> [--] [<path>...]

where it says that "[t]his form is to view the results of a merge
commit" and details how "the first listed commit must be the merge
itself". But one possible instantiation of this form is `git diff
<commit> <commit>` for which the added text doesn't really apply.

Remove the brackets so that we lose this overlap between the two
descriptions. We can still use the more compact representation in the
synopsis.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'fr_v2.28.0_rnd1' of github.com:jnavila/git
Jiang Xin [Mon, 13 Jul 2020 00:39:23 +0000 (08:39 +0800)] 
Merge branch 'fr_v2.28.0_rnd1' of github.com:jnavila/git

* 'fr_v2.28.0_rnd1' of github.com:jnavila/git:
  l10n: fr v2.28.0 round 1

5 years agol10n: fr v2.28.0 round 1
Jean-Noël Avila [Sun, 12 Jul 2020 16:15:44 +0000 (18:15 +0200)] 
l10n: fr v2.28.0 round 1

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
5 years agoMerge branch 'master' of github.com:nafmo/git-l10n-sv
Jiang Xin [Sun, 12 Jul 2020 09:53:39 +0000 (17:53 +0800)] 
Merge branch 'master' of github.com:nafmo/git-l10n-sv

* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation (4931t0f0u)

5 years agol10n: sv.po: Update Swedish translation (4931t0f0u)
Peter Krefting [Sat, 11 Jul 2020 16:52:35 +0000 (17:52 +0100)] 
l10n: sv.po: Update Swedish translation (4931t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
5 years agol10n: it.po: update the Italian translation for Git 2.28.0 round 1
Alessandro Menti [Sat, 11 Jul 2020 13:35:23 +0000 (15:35 +0200)] 
l10n: it.po: update the Italian translation for Git 2.28.0 round 1

Signed-off-by: Alessandro Menti <alessandro.menti@alessandromenti.it>
5 years agot5539: make timestamp requirements more explicit
Jeff King [Thu, 9 Jul 2020 20:39:09 +0000 (16:39 -0400)] 
t5539: make timestamp requirements more explicit

The test for "no shallow lines after receiving ACK ready" is very
sensitive to the timestamps of the commits we create. It's looking for
the fetch negotiation to send a "ready", which in turn depends on the
order in which we traverse commits during the negotiation.

It works reliably now because the base commit "7" is created without
test_commit, and thus gets a commit time matching the current system
clock. Whereas the new commits created in this test do use test_commit,
and get the usual test_tick time from 2005. So the fetch into the
"clone" repository results in a commit graph like this (I omitted some
of the "unrelated" commits for clarity; they're all just a sequence of
test_ticks):

  $ git log --graph --format='%ct %s %d'
  * 1112912953 new  (origin/master, origin/HEAD)
  * 1594322236 7  (grafted, master)
  * 1112912893 unrelated15  (origin/unrelated15, unrelated15)
  [...]
  * 1112912053 unrelated1  (origin/unrelated1, unrelated1)
  * 1112911993 new-too  (HEAD -> newnew, tag: new-too)

The important things to see are:

  - "7" is way in the future compared to the other commits

  - "new-too" in the fetching repo is older than "new" (and its
    "unrelated" ancestors) in the shallow repo

If we change our "setup shallow clone" step to use test_tick, too (and
get rid of the dependency on the system clock), then the test will fail.
The resulting graph looks like this:

  $ git log --graph --format='%ct %s %d'
  * 1112913373 new  (origin/master, origin/HEAD)
  * 1112912353 7  (grafted, master)
  * 1112913313 unrelated15  (origin/unrelated15, unrelated15)
  [...]
  * 1112912473 unrelated1  (origin/unrelated1, unrelated1)
  * 1112912413 new-too  (HEAD -> newnew, tag: new-too)

Our "new-too" is still older than "new" and "unrelated", but now "7" is
older than all of them (because it advanced test_tick, which the other
tests built on top of). In the original, we advertised "7" as the first
"have" before anything else, but now "new-too" is more recent. You'd see
the same thing in the unlikely event that the system clock was set
before our test_tick default in 2005.

Let's make the timing requirements more explicit. The important thing is
that the client advertise all of its shared commits first, before
presenting its unique "new-too" commit. We can do that and get rid of
the system clock dependency at the same time by creating all of the
shared commits around time X (using test_tick), and then creating
"new-too" with some time long before X. The resulting graph looks like
this:

  $ git log --graph --format='%ct %s %d'
  * 1500001380 new  (origin/master, origin/HEAD)
  * 1500000420 7  (grafted, master)
  * 1500001320 unrelated15  (origin/unrelated15, unrelated15)
  [...]
  * 1500000480 unrelated1  (origin/unrelated1, unrelated1)
  * 1400000060 new-too  (HEAD -> newnew, tag: new-too)

That also lets us get rid of the hacky test_tick added by f0e802ca20
(t5539: update a flaky test, 2014-07-14). That was clearly dancing
around the same problem, but only addressed the relationship between
commits created in the two subshells (which did use test_tick, but
overlapped because increments of test_tick in subshells are lost). Now
that we're using consistent and well-placed times for both lines of
history, we don't have to care about a one-tick difference between the
two sides.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot9700: loosen ident timezone regex
Jeff King [Thu, 9 Jul 2020 20:35:50 +0000 (16:35 -0400)] 
t9700: loosen ident timezone regex

A few of the perl tests in t9700 ask for the author and committer ident,
and then make sure we get something sensible. For the timestamp portion,
we just match [0-9]+, because the actual value will depend on when the
test is run. However, we do require that the timezone be "+0000". This
works reliably because we set $TZ in test-lib.sh. But in preparation for
changing the default timezone, let's be a bit more flexible. We don't
actually care about the exact value here, just that we were able to get
a sensible output from the perl module's access methods.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agol10n: tr: v2.28.0 round 1
Emir Sarı [Fri, 10 Jul 2020 10:07:30 +0000 (13:07 +0300)] 
l10n: tr: v2.28.0 round 1

Signed-off-by: Emir Sarı <bitigchi@me.com>
5 years agol10n: git.pot: v2.28.0 round 1 (70 new, 14 removed)
Jiang Xin [Fri, 10 Jul 2020 01:54:33 +0000 (09:54 +0800)] 
l10n: git.pot: v2.28.0 round 1 (70 new, 14 removed)

Generate po/git.pot from v2.28.0-rc0 for git v2.28.0 l10n round 1.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
5 years agoGit 2.28-rc0 v2.28.0-rc0
Junio C Hamano [Thu, 9 Jul 2020 20:45:21 +0000 (13:45 -0700)] 
Git 2.28-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'mt/entry-fstat-fallback-fix' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:45 +0000 (14:00 -0700)] 
Merge branch 'mt/entry-fstat-fallback-fix' into master

"git checkout" failed to catch an error from fstat() after updating
a path in the working tree.

* mt/entry-fstat-fallback-fix:
  entry: check for fstat() errors after checkout

5 years agoMerge branch 'ma/rebase-doc-typofix' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:44 +0000 (14:00 -0700)] 
Merge branch 'ma/rebase-doc-typofix' into master

Typofix.

* ma/rebase-doc-typofix:
  git-rebase.txt: fix description list separator

5 years agoMerge branch 'jn/eject-fetch-write-commit-graph-out-of-experimental' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:44 +0000 (14:00 -0700)] 
Merge branch 'jn/eject-fetch-write-commit-graph-out-of-experimental' into master

"fetch.writeCommitGraph" was enabled when "feature.experimental" is
asked for, but it was found to be a bit too risky even for bold
folks in its current shape.  The configuration has been ejected, at
least for now, from the "experimental" feature set.

* jn/eject-fetch-write-commit-graph-out-of-experimental:
  experimental: default to fetch.writeCommitGraph=false

5 years agoMerge branch 'tb/fix-persistent-shallow' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:44 +0000 (14:00 -0700)] 
Merge branch 'tb/fix-persistent-shallow' into master

When "fetch.writeCommitGraph" configuration is set in a shallow
repository and a fetch moves the shallow boundary, we wrote out
broken commit-graph files that do not match the reality, which has
been corrected.

* tb/fix-persistent-shallow:
  commit.c: don't persist substituted parents when unshallowing

5 years agoMerge branch 'ct/diff-with-merge-base-clarification' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:43 +0000 (14:00 -0700)] 
Merge branch 'ct/diff-with-merge-base-clarification' into master

Recent update to "git diff" meant as a code clean-up introduced a
bug in its error handling code, which has been corrected.

* ct/diff-with-merge-base-clarification:
  diff: check for merge bases before assigning sym->base

5 years agoMerge branch 'rs/line-log-until' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:42 +0000 (14:00 -0700)] 
Merge branch 'rs/line-log-until' into master

"git log -Lx,y:path --before=date" lost track of where the range
should be because it didn't take the changes made by the youngest
commits that are omitted from the output into account.

* rs/line-log-until:
  revision: disable min_age optimization with line-log

5 years agoMerge branch 'ra/send-email-in-reply-to-from-command-line-wins' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:42 +0000 (14:00 -0700)] 
Merge branch 'ra/send-email-in-reply-to-from-command-line-wins' into master

"git send-email --in-reply-to=<msg>" did not use the In-Reply-To:
header with the value given from the command line, and let it be
overridden by the value on In-Reply-To: header in the messages
being sent out (if exists).

* ra/send-email-in-reply-to-from-command-line-wins:
  send-email: restore --in-reply-to superseding behavior

5 years agoMerge branch 'vs/completion-with-set-u' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:41 +0000 (14:00 -0700)] 
Merge branch 'vs/completion-with-set-u' into master

The command line completion support (in contrib/) used to be
prepared to work with "set -u" but recent changes got a bit more
sloppy.  This has been corrected.

* vs/completion-with-set-u:
  completion: nounset mode fixes

5 years agoMerge branch 'cc/cat-file-usage-update' into master
Junio C Hamano [Thu, 9 Jul 2020 21:00:41 +0000 (14:00 -0700)] 
Merge branch 'cc/cat-file-usage-update' into master

Doc/usage update.

* cc/cat-file-usage-update:
  cat-file: add missing [=<format>] to usage/synopsis

5 years agogit-rebase.txt: fix description list separator
Martin Ågren [Thu, 9 Jul 2020 18:24:38 +0000 (20:24 +0200)] 
git-rebase.txt: fix description list separator

We don't give a "::" for the list separator, but just a single ":". This
ends up rendering literally, "--apply: Use applying strategies ...". As
a follow-on error, the list continuation, "+", also ends up rendering
literally (because we don't have a list).

This was introduced in 52eb738d6b ("rebase: add an --am option",
2020-02-15) and survived the rename in 10cdb9f38a ("rebase: rename the
two primary rebase backends", 2020-02-15).

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agol10n: Update Catalan translation
Jordi Mas [Thu, 9 Jul 2020 18:01:42 +0000 (20:01 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
5 years agocommit-graph: fix "Writing out commit graph" progress counter
SZEDER Gábor [Thu, 9 Jul 2020 17:00:03 +0000 (19:00 +0200)] 
commit-graph: fix "Writing out commit graph" progress counter

76ffbca71a (commit-graph: write Bloom filters to commit graph file,
2020-04-06) added two delayed progress lines to writing the Bloom
filter index and data chunk.  This is wrong, because a single common
progress is used while writing all chunks, which is not updated while
writing these two new chunks, resulting in incomplete-looking "done"
lines:

  Expanding reachable commits in commit graph: 888679, done.
  Computing commit changed paths Bloom filters: 100% (888678/888678), done.
  Writing out commit graph in 6 passes:  66% (3554712/5332068), done.

Use the common 'struct progress' instance while writing the Bloom
filter chunks as well.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocommit-graph: fix progress of reachable commits
SZEDER Gábor [Thu, 9 Jul 2020 16:54:32 +0000 (18:54 +0200)] 
commit-graph: fix progress of reachable commits

To display a progress line while iterating over all refs,
d335ce8f24 (commit-graph.c: show progress of finding reachable
commits, 2020-05-13) should have added a pair of
start_delayed_progress() and stop_progress() calls around a
for_each_ref() invocation.  Alas, the stop_progress() call ended up at
the wrong place, after write_commit_graph(), which does all the
commit-graph computation and writing, and has several progress lines
of its own.  Consequently, that new

  Collecting referenced commits: 123

progress line is overwritten by the first progress line shown by
write_commit_graph(), and its final "done" line is shown last, after
everything is finished:

  Expanding reachable commits in commit graph: 344786, done.
  Computing commit changed paths Bloom filters: 100% (344786/344786), done.
  Collecting referenced commits: 154, done.

Move that stop_progress() call to the right place.

While at it, drop the unnecessary 'if (data.progress)' condition
protecting the stop_progress() call, because that function is prepared
to handle a NULL progress struct.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoentry: check for fstat() errors after checkout
Matheus Tavares [Thu, 9 Jul 2020 02:10:39 +0000 (23:10 -0300)] 
entry: check for fstat() errors after checkout

In 11179eb311 ("entry.c: check if file exists after checkout",
2017-10-05) we started checking the result of the lstat() call done
after writing a file, to avoid writing garbage to the corresponding
cache entry. However, the code skips calling lstat() if it's possible
to use fstat() when it still has the file descriptor open. And when
calling fstat() we don't do the same error checking. To fix that, let
the callers of fstat_output() know when fstat() fails. In this case,
write_entry() will try to use lstat() and properly report an error if
that fails as well.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoexperimental: default to fetch.writeCommitGraph=false
Jonathan Nieder [Tue, 7 Jul 2020 06:20:39 +0000 (23:20 -0700)] 
experimental: default to fetch.writeCommitGraph=false

The fetch.writeCommitGraph feature makes fetches write out a commit
graph file for the newly downloaded pack on fetch.  This improves the
performance of various commands that would perform a revision walk and
eventually ought to be the default for everyone.  To prepare for that
future, it's enabled by default for users that set
feature.experimental=true to experience such future defaults.

Alas, for --unshallow fetches from a shallow clone it runs into a
snag: by the time Git has fetched the new objects and is writing a
commit graph, it has performed a revision walk and r->parsed_objects
contains information about the shallow boundary from *before* the
fetch.  The commit graph writing code is careful to avoid writing a
commit graph file in shallow repositories, but the new state is not
shallow, and the result is that from that point on, commands like "git
log" make use of a newly written commit graph file representing a
fictional history with the old shallow boundary.

We could fix this by making the commit graph writing code more careful
to avoid writing a commit graph that could have used any grafts or
shallow state, but it is possible that there are other pieces of
mutated state that fetch's commit graph writing code may be relying
on.  So disable it in the feature.experimental configuration.

Google developers have been running in this configuration (by setting
fetch.writeCommitGraph=false in the system config) to work around this
bug since it was discovered in April.  Once the fix lands, we'll
enable fetch.writeCommitGraph=true again to give it some early testing
before rolling out to a wider audience.

In other words:

- this patch only affects behavior with feature.experimental=true

- it makes feature.experimental match the configuration Google has
  been using for the last few months, meaning it would leave users in
  a better tested state than without it

- this should improve testing for other features guarded by
  feature.experimental, by making feature.experimental safer to use

Reported-by: Jay Conrod <jayconrod@google.com>
Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocommit.c: don't persist substituted parents when unshallowing
Taylor Blau [Wed, 8 Jul 2020 21:10:53 +0000 (17:10 -0400)] 
commit.c: don't persist substituted parents when unshallowing

Since 37b9dcabfc (shallow.c: use '{commit,rollback}_shallow_file',
2020-04-22), Git knows how to reset stat-validity checks for the
$GIT_DIR/shallow file, allowing it to change between a shallow and
non-shallow state in the same process (e.g., in the case of 'git fetch
--unshallow').

However, when $GIT_DIR/shallow changes, Git does not alter or remove any
grafts (nor substituted parents) in memory.

This comes up in a "git fetch --unshallow" with fetch.writeCommitGraph
set to true. Ordinarily in a shallow repository (and before 37b9dcabfc,
even in this case), commit_graph_compatible() would return false,
indicating that the repository should not be used to write a
commit-graphs (since commit-graph files cannot represent a shallow
history). But since 37b9dcabfc, in an --unshallow operation that check
succeeds.

Thus even though the repository isn't shallow any longer (that is, we
have all of the objects), the in-core representation of those objects
still has munged parents at the shallow boundaries.  When the
commit-graph write proceeds, we use the incorrect parentage, producing
wrong results.

There are two ways for a user to work around this: either (1) set
'fetch.writeCommitGraph' to 'false', or (2) drop the commit-graph after
unshallowing.

One way to fix this would be to reset the parsed object pool entirely
(flushing the cache and thus preventing subsequent reads from modifying
their parents) after unshallowing. That would produce a problem when
callers have a now-stale reference to the old pool, and so this patch
implements a different approach. Instead, attach a new bit to the pool,
'substituted_parent', which indicates if the repository *ever* stored a
commit which had its parents modified (i.e., the shallow boundary
prior to unshallowing).

This bit needs to be sticky because all reads subsequent to modifying a
commit's parents are unreliable when unshallowing. Modify the check in
'commit_graph_compatible' to take this bit into account, and correctly
avoid generating commit-graphs in this case, thus solving the bug.

Helped-by: Derrick Stolee <dstolee@microsoft.com>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Reported-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agodiff: check for merge bases before assigning sym->base
Jeff King [Wed, 8 Jul 2020 04:38:19 +0000 (00:38 -0400)] 
diff: check for merge bases before assigning sym->base

In symdiff_prepare(), we iterate over the set of parsed objects to pick
out any symmetric differences, including the left, right, and base
elements. We assign the results into pointers in a "struct symdiff", and
then complain if we didn't find a base, like so:

    sym->left = rev->pending.objects[lpos].name;
    sym->right = rev->pending.objects[rpos].name;
    sym->base = rev->pending.objects[basepos].name;
    if (basecount == 0)
            die(_("%s...%s: no merge base"), sym->left, sym->right);

But the least lines are backwards. If basecount is 0, then basepos will
be -1, and we will access memory outside of the pending array. This
isn't usually that big a deal, since we don't do anything besides a
single pointer-sized read before exiting anyway, but it does violate the
C standard, and of course memory-checking tools like ASan complain.

Let's put the basecount check first. Note that we haveto split it from
the other assignments, since the die() relies on sym->left and
sym->right having been assigned (this isn't strictly necessary, but is
easier to read than dereferencing the pending array again).

Reported-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot6000: use test_tick consistently
Jeff King [Tue, 7 Jul 2020 21:41:51 +0000 (17:41 -0400)] 
t6000: use test_tick consistently

The first two commits created in t6000 are done without test_tick,
meaning they use the current system clock. After that, we create one
with test_tick, which means it uses a deterministic time in the past.

The result of the "symleft flag bit is propagated down from tag" test
relies on the output order of commits from git-log, which in turn
depends on these timestamps. So this test is technically dependent on
the system clock time, though in practice it would only matter if your
system clock was set before test_tick's default time (which is in 2005).

However, let's use test_tick consistently for those early commits (and
update the expected output to match). This makes the test deterministic,
which is in turn easier to reason about and debug.

Note that there's also a fourth commit here, and it does not use
test_tick. It does have a deterministic timestamp because of the prior
use of test_tick in the script, but it will always be the same time as
the third commit. Let's use test_tick here, too, for consistency.  The
matching timestamps between the third and fourth commit are not an
important part of the test.

We could also use test_commit in all of these cases, as it runs
test_tick under the hood. But it would be awkward to do so, as these
tests diverge from the usual test_commit patterns (e.g., by creating
multiple files in a single commit).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoWait for child on signal death for aliases to externals
Trygve Aaberge [Tue, 7 Jul 2020 12:17:15 +0000 (14:17 +0200)] 
Wait for child on signal death for aliases to externals

When we are running an alias to an external command, we want to wait for
that process to exit even after receiving ^C which normally kills the
git process. This is useful when the process is ignoring SIGINT (which
e.g. pagers often do), and then we don't want it to be killed.

Having an alias which invokes a pager is probably not common, but it can
be useful e.g. if you have an alias to a git command which uses a
subshell as one of the arguments (in which case you have to use an
external command, not an alias to a builtin).

This patch is similar to the previous commit, but the previous commit
fixed this only for aliases to builtins, while this commit does the same
for aliases to external commands. In addition to waiting after clean
like the previous commit, this also enables cleaning the child (that was
already enabled for aliases to builtins before the previous commit),
because wait_after_clean relies on it. Lastly, while the previous commit
fixed a regression, I don't think this has ever worked properly.

Signed-off-by: Trygve Aaberge <trygveaa@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoWait for child on signal death for aliases to builtins
Trygve Aaberge [Tue, 7 Jul 2020 12:17:14 +0000 (14:17 +0200)] 
Wait for child on signal death for aliases to builtins

When you hit ^C all the processes in the tree receives it. When a git
command uses a pager, git ignores this and waits until the pager quits.
However, when using an alias there is an additional process in the tree
which didn't ignore the signal. That caused it to exit which in turn
caused the pager to exit. This fixes that for aliases to builtins.

This was originally fixed in 46df6906 (execv_dashed_external: wait
for child on signal death, 2017-01-06), but was broken by ee4512ed
(trace2: create new combined trace facility, 2019-02-22) and then
b9140840 (git: avoid calling aliased builtins via their dashed form,
2019-07-29).

Signed-off-by: Trygve Aaberge <trygveaa@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoThe seventh batch
Junio C Hamano [Tue, 7 Jul 2020 05:13:31 +0000 (22:13 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'es/worktree-code-cleanup'
Junio C Hamano [Tue, 7 Jul 2020 05:09:19 +0000 (22:09 -0700)] 
Merge branch 'es/worktree-code-cleanup'

Code cleanup.

* es/worktree-code-cleanup:
  worktree: avoid dead-code in conditional

5 years agoMerge branch 'dl/test-must-fail-fixes-5'
Junio C Hamano [Tue, 7 Jul 2020 05:09:18 +0000 (22:09 -0700)] 
Merge branch 'dl/test-must-fail-fixes-5'

The effort to avoid using test_must_fail on non-git command continues.

* dl/test-must-fail-fixes-5:
  lib-submodule-update: pass 'test_must_fail' as an argument
  lib-submodule-update: prepend "git" to $command
  lib-submodule-update: consolidate --recurse-submodules
  lib-submodule-update: add space after function name

5 years agoMerge branch 'jk/fast-export-anonym-alt'
Junio C Hamano [Tue, 7 Jul 2020 05:09:17 +0000 (22:09 -0700)] 
Merge branch 'jk/fast-export-anonym-alt'

"git fast-export --anonymize" learned to take customized mapping to
allow its users to tweak its output more usable for debugging.

* jk/fast-export-anonym-alt:
  fast-export: use local array to store anonymized oid
  fast-export: anonymize "master" refname
  fast-export: allow seeding the anonymized mapping
  fast-export: add a "data" callback parameter to anonymize_str()
  fast-export: move global "idents" anonymize hashmap into function
  fast-export: use a flex array to store anonymized entries
  fast-export: stop storing lengths in anonymized hashmaps
  fast-export: tighten anonymize_mem() interface to handle only strings
  fast-export: store anonymized oids as hex strings
  fast-export: use xmemdupz() for anonymizing oids
  t9351: derive anonymized tree checks from original repo

5 years agoMerge branch 'js/diff-files-i-t-a-fix-for-difftool'
Junio C Hamano [Tue, 7 Jul 2020 05:09:17 +0000 (22:09 -0700)] 
Merge branch 'js/diff-files-i-t-a-fix-for-difftool'

"git difftool" has trouble dealing with paths added to the index
with the intent-to-add bit.

* js/diff-files-i-t-a-fix-for-difftool:
  difftool -d: ensure that intent-to-add files are handled correctly
  diff-files --raw: show correct post-image of intent-to-add files

5 years agoMerge branch 'js/default-branch-name'
Junio C Hamano [Tue, 7 Jul 2020 05:09:17 +0000 (22:09 -0700)] 
Merge branch 'js/default-branch-name'

The name of the primary branch in existing repositories, and the
default name used for the first branch in newly created
repositories, is made configurable, so that we can eventually wean
ourselves off of the hardcoded 'master'.

* js/default-branch-name:
  contrib: subtree: adjust test to change in fmt-merge-msg
  testsvn: respect `init.defaultBranch`
  remote: use the configured default branch name when appropriate
  clone: use configured default branch name when appropriate
  init: allow setting the default for the initial branch name via the config
  init: allow specifying the initial branch name for the new repository
  docs: add missing diamond brackets
  submodule: fall back to remote's HEAD for missing remote.<name>.branch
  send-pack/transport-helper: avoid mentioning a particular branch
  fmt-merge-msg: stop treating `master` specially

5 years agoMerge branch 'rs/pack-bits-in-object-better'
Junio C Hamano [Tue, 7 Jul 2020 05:09:17 +0000 (22:09 -0700)] 
Merge branch 'rs/pack-bits-in-object-better'

By renumbering object flag bits, "struct object" managed to lose
bloated inter-field padding.

* rs/pack-bits-in-object-better:
  revision: reallocate TOPO_WALK object flags

5 years agoMerge branch 'bc/http-push-flagsfix'
Junio C Hamano [Tue, 7 Jul 2020 05:09:17 +0000 (22:09 -0700)] 
Merge branch 'bc/http-push-flagsfix'

The code to push changes over "dumb" HTTP had a bad interaction
with the commit reachability code due to incorrect allocation of
object flag bits, which has been corrected.

* bc/http-push-flagsfix:
  http-push: ensure unforced pushes fail when data would be lost

5 years agoMerge branch 'js/pu-to-seen'
Junio C Hamano [Tue, 7 Jul 2020 05:09:16 +0000 (22:09 -0700)] 
Merge branch 'js/pu-to-seen'

The documentation and some tests have been adjusted for the recent
renaming of "pu" branch to "seen".

* js/pu-to-seen:
  tests: reference `seen` wherever `pu` was referenced
  docs: adjust the technical overview for the rename `pu` -> `seen`
  docs: adjust for the recent rename of `pu` to `seen`

5 years agoMerge branch 'cb/is-descendant-of'
Junio C Hamano [Tue, 7 Jul 2020 05:09:15 +0000 (22:09 -0700)] 
Merge branch 'cb/is-descendant-of'

Code clean-up.

* cb/is-descendant-of:
  commit-reach: avoid is_descendant_of() shim

5 years agoMerge branch 'mk/pb-pretty-email-without-domain-part-fix'
Junio C Hamano [Tue, 7 Jul 2020 05:09:15 +0000 (22:09 -0700)] 
Merge branch 'mk/pb-pretty-email-without-domain-part-fix'

Docfix.

* mk/pb-pretty-email-without-domain-part-fix:
  doc: fix author vs. committer copy/paste error

5 years agoMerge branch 'jl/complete-git-prune'
Junio C Hamano [Tue, 7 Jul 2020 05:09:15 +0000 (22:09 -0700)] 
Merge branch 'jl/complete-git-prune'

Add "git prune" to the completion (in contrib/), which could be
typed by end-users from the command line.

* jl/complete-git-prune:
  bash-completion: add git-prune into bash completion

5 years agoMerge branch 'es/get-worktrees-unsort'
Junio C Hamano [Tue, 7 Jul 2020 05:09:15 +0000 (22:09 -0700)] 
Merge branch 'es/get-worktrees-unsort'

API cleanup for get_worktrees()

* es/get-worktrees-unsort:
  worktree: drop get_worktrees() unused 'flags' argument
  worktree: drop get_worktrees() special-purpose sorting option

5 years agoMerge branch 'bc/sha-256-cvs-svn-updates'
Junio C Hamano [Tue, 7 Jul 2020 05:09:14 +0000 (22:09 -0700)] 
Merge branch 'bc/sha-256-cvs-svn-updates'

CVS/SVN interface have been prepared for SHA-256 transition

* bc/sha-256-cvs-svn-updates:
  git-cvsexportcommit: port to SHA-256
  git-cvsimport: port to SHA-256
  git-cvsserver: port to SHA-256
  git-svn: set the OID length based on hash algorithm
  perl: make SVN code hash independent
  perl: make Git::IndexInfo work with SHA-256
  perl: create and switch variables for hash constants
  t/lib-git-svn: make hash size independent
  t9101: make hash independent
  t9104: make hash size independent
  t9100: make test work with SHA-256
  t9108: make test hash independent
  t9168: make test hash independent
  t9109: make test hash independent

5 years agoMerge branch 'ak/commit-graph-to-slab'
Junio C Hamano [Tue, 7 Jul 2020 05:09:13 +0000 (22:09 -0700)] 
Merge branch 'ak/commit-graph-to-slab'

A few fields in "struct commit" that do not have to always be
present have been moved to commit slabs.

* ak/commit-graph-to-slab:
  commit-graph: minimize commit_graph_data_slab access
  commit: move members graph_pos, generation to a slab
  commit-graph: introduce commit_graph_data_slab
  object: drop parsed_object_pool->commit_count

5 years agoMerge branch 'en/sparse-status'
Junio C Hamano [Tue, 7 Jul 2020 05:09:13 +0000 (22:09 -0700)] 
Merge branch 'en/sparse-status'

"git status" learned to report the status of sparse checkout.

* en/sparse-status:
  git-prompt: include sparsity state as well
  git-prompt: document how in-progress operations affect the prompt
  wt-status: show sparse checkout status as well

5 years agoMerge branch 'ps/ref-transaction-hook'
Junio C Hamano [Tue, 7 Jul 2020 05:09:13 +0000 (22:09 -0700)] 
Merge branch 'ps/ref-transaction-hook'

A new hook.

* ps/ref-transaction-hook:
  refs: implement reference transaction hook

5 years agoMerge branch 'bc/sha-256-part-2'
Junio C Hamano [Tue, 7 Jul 2020 05:09:13 +0000 (22:09 -0700)] 
Merge branch 'bc/sha-256-part-2'

SHA-256 migration work continues.

* bc/sha-256-part-2: (44 commits)
  remote-testgit: adapt for object-format
  bundle: detect hash algorithm when reading refs
  t5300: pass --object-format to git index-pack
  t5704: send object-format capability with SHA-256
  t5703: use object-format serve option
  t5702: offer an object-format capability in the test
  t/helper: initialize the repository for test-sha1-array
  remote-curl: avoid truncating refs with ls-remote
  t1050: pass algorithm to index-pack when outside repo
  builtin/index-pack: add option to specify hash algorithm
  remote-curl: detect algorithm for dumb HTTP by size
  builtin/ls-remote: initialize repository based on fetch
  t5500: make hash independent
  serve: advertise object-format capability for protocol v2
  connect: parse v2 refs with correct hash algorithm
  connect: pass full packet reader when parsing v2 refs
  Documentation/technical: document object-format for protocol v2
  t1302: expect repo format version 1 for SHA-256
  builtin/show-index: provide options to determine hash algo
  t5302: modernize test formatting
  ...

5 years agorevision: disable min_age optimization with line-log
René Scharfe [Sat, 4 Jul 2020 12:56:32 +0000 (14:56 +0200)] 
revision: disable min_age optimization with line-log

If one of the options --before, --min-age or --until is given,
limit_list() filters out younger commits early on.  Line-log needs all
those commits to trace the movement of line ranges, though.  Skip this
optimization if both are used together.

Reported-by: Мария Долгополова <dolgopolovamariia@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agodifftool -d: ensure that intent-to-add files are handled correctly
Johannes Schindelin [Wed, 1 Jul 2020 21:19:07 +0000 (21:19 +0000)] 
difftool -d: ensure that intent-to-add files are handled correctly

In https://github.com/git-for-windows/git/issues/2677, a `git difftool
-d` problem was reported. The underlying cause was a bug in `git
diff-files --raw` that we just fixed: it reported intent-to-add files
with the empty _tree_ as the post-image OID, when we need to show
an all-zero (or, "null") OID instead, to indicate to the caller that
they have to look at the worktree file.

The symptom of that problem shown by `git difftool` was this:

error: unable to read sha1 file of <path> (<empty-tree-OID>)
error: could not write '<filename>'

Make sure that the reported `difftool` problem stays fixed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agodiff-files --raw: show correct post-image of intent-to-add files
Johannes Schindelin [Wed, 1 Jul 2020 21:19:06 +0000 (21:19 +0000)] 
diff-files --raw: show correct post-image of intent-to-add files

The documented behavior of `git diff-files --raw` is to display

[...] 0{40} if creation, unmerged or "look at work tree".

on the right hand (i.e. postimage) side. This happens for files that
have unstaged modifications, and for files that are unmodified but
stat-dirty.

For intent-to-add files, we used to show the empty blob's hash instead.
In c26022ea8f5 (diff: convert diff_addremove to struct object_id,
2017-05-30), we made that worse by inadvertently changing that to the
hash of the empty tree.

Let's make the behavior consistent with files that have unstaged
modifications (which applies to intent-to-add files, too) by showing
all-zero values also for intent-to-add files.

Accordingly, this patch adjusts the expectations set by the regression
test introduced in feea6946a5b (diff-files: treat "i-t-a" files as
"not-in-index", 2020-06-20).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosend-email: restore --in-reply-to superseding behavior
Rafael Aquini [Mon, 29 Jun 2020 14:11:04 +0000 (10:11 -0400)] 
send-email: restore --in-reply-to superseding behavior

git send-email --in-reply-to= fails to override In-Reply-To email headers,
if they're present in the output of format-patch, even when explicitly
told to do so by the option --no-thread, which breaks the contract of the
command line switch option, per its man page.

"
   --in-reply-to=<identifier>
       Make the first mail (or all the mails with --no-thread) appear as
       a reply to the given Message-Id, which avoids breaking threads to
       provide a new patch series.
"

This patch fixes the aformentioned issue, by bringing --in-reply-to's old
overriding behavior back.

The test was donated by Carlo Marcelo Arenas Belón.

Signed-off-by: Rafael Aquini <aquini@redhat.com>
Helped-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocat-file: add missing [=<format>] to usage/synopsis
Christian Couder [Wed, 1 Jul 2020 10:16:18 +0000 (12:16 +0200)] 
cat-file: add missing [=<format>] to usage/synopsis

When displaying cat-file usage, the fact that a <format> can
be specified is only visible when lookling at the --batch and
--batch-check options which are shown like this:

    --batch[=<format>]    show info and content of objects fed from the standard input
    --batch-check[=<format>]
                          show info about objects fed from the standard input

It seems more coherent and improves discovery to also show it
on the usage line.

In the documentation the DESCRIPTION tells us that "The output
format can be overridden using the optional <format> argument",
but we can't see the <format> argument in the SYNOPSIS above
the description which is confusing.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocompletion: nounset mode fixes
Ville Skyttä [Mon, 29 Jun 2020 18:59:45 +0000 (21:59 +0300)] 
completion: nounset mode fixes

Accessing unset variables results an errors when the shell is in
nounset/-u mode. This fixes the cases I've come across while using git
completion in a shell running in that mode for a while. It's hard to
tell if this is the complete set, but at least it improves things.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocommit-graph: check all leading directories in changed path Bloom filters
SZEDER Gábor [Wed, 1 Jul 2020 13:27:30 +0000 (13:27 +0000)] 
commit-graph: check all leading directories in changed path Bloom filters

The file 'dir/subdir/file' can only be modified if its leading
directories 'dir' and 'dir/subdir' are modified as well.

So when checking modified path Bloom filters looking for commits
modifying a path with multiple path components, then check not only
the full path in the Bloom filters, but all its leading directories as
well.  Take care to check these paths in "deepest first" order,
because it's the full path that is least likely to be modified, and
the Bloom filter queries can short circuit sooner.

This can significantly reduce the average false positive rate, by
about an order of magnitude or three(!), and can further speed up
pathspec-limited revision walks.  The table below compares the average
false positive rate and runtime of

  git rev-list HEAD -- "$path"

before and after this change for 5000+ randomly* selected paths from
each repository:

                    Average false           Average        Average
                    positive rate           runtime        runtime
                  before     after     before     after   difference
  ------------------------------------------------------------------
  git             3.220%   0.7853%     0.0558s   0.0387s   -30.6%
  linux           2.453%   0.0296%     0.1046s   0.0766s   -26.8%
  tensorflow      2.536%   0.6977%     0.0594s   0.0420s   -29.2%

*Path selection was done with the following pipeline:

git ls-tree -r --name-only HEAD | sort -R | head -n 5000

The improvements in runtime are much smaller than the improvements in
average false positive rate, as we are clearly reaching diminishing
returns here.  However, all these timings depend on that accessing
tree objects is reasonably fast (warm caches).  If we had a partial
clone and the tree objects had to be fetched from a promisor remote,
e.g.:

  $ git clone --filter=tree:0 --bare file://.../webkit.git webkit.notrees.git
  $ git -C webkit.git -c core.modifiedPathBloomFilters=1 \
        commit-graph write --reachable
  $ cp webkit.git/objects/info/commit-graph webkit.notrees.git/objects/info/
  $ git -C webkit.notrees.git -c core.modifiedPathBloomFilters=1 \
        rev-list HEAD -- "$path"

then checking all leading path component can reduce the runtime from
over an hour to a few seconds (and this is with the clone and the
promisor on the same machine).

This adjusts the tracing values in t4216-log-bloom.sh, which provides a
concrete way to notice the improvement.

Helped-by: Taylor Blau <me@ttaylorr.com>
Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agorevision: empty pathspecs should not use Bloom filters
Taylor Blau [Wed, 1 Jul 2020 13:27:29 +0000 (13:27 +0000)] 
revision: empty pathspecs should not use Bloom filters

The prepare_to_use_bloom_filter() method was not intended to be called
on an empty pathspec. However, 'git log -- .' and 'git log' are subtly
different: the latter reports all commits while the former will simplify
commits that do not change the root tree.

This means that the path used to construct the bloom_key might be empty,
and that value is not added to the Bloom filter during construction.
That means that the results are likely incorrect!

To resolve the issue, be careful about the length of the path and stop
filling Bloom filters. To be completely sure we do not use them, drop
the pointer to the bloom_filter_settings from the commit-graph. That
allows our test to look at the trace2 logs to verify no Bloom filter
statistics are reported.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agorevision.c: fix whitespace
Derrick Stolee [Wed, 1 Jul 2020 13:27:28 +0000 (13:27 +0000)] 
revision.c: fix whitespace

Here, four spaces were used instead of tab characters.

Reported-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocommit-graph: check chunk sizes after writing
SZEDER Gábor [Wed, 1 Jul 2020 13:27:27 +0000 (13:27 +0000)] 
commit-graph: check chunk sizes after writing

In my experience while experimenting with new commit-graph chunks,
early versions of the corresponding new write_commit_graph_my_chunk()
functions are, sadly but not surprisingly, often buggy, and write more
or less data than they are supposed to, especially if the chunk size
is not directly proportional to the number of commits.  This then
causes all kinds of issues when reading such a bogus commit-graph
file, raising the question of whether the writing or the reading part
happens to be buggy this time.

Let's catch such issues early, already when writing the commit-graph
file, and check that each write_graph_chunk_*() function wrote the
amount of data that it was expected to, and what has been encoded in
the Chunk Lookup table.  Now that all commit-graph chunks are written
in a loop we can do this check in a single place for all chunks, and
any chunks added in the future will get checked as well.

Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>