git
3 years agoMerge branch 'ns/raise-write-index-buffer-size'
Junio C Hamano [Mon, 1 Mar 2021 22:02:58 +0000 (14:02 -0800)] 
Merge branch 'ns/raise-write-index-buffer-size'

Raise the buffer size used when writing the index file out from
(obviously too small) 8kB to (clearly sufficiently large) 128kB.

* ns/raise-write-index-buffer-size:
  read-cache: make the index write buffer size 128K

3 years agoMerge branch 'hv/trailer-formatting'
Junio C Hamano [Mon, 1 Mar 2021 22:02:57 +0000 (14:02 -0800)] 
Merge branch 'hv/trailer-formatting'

The logic to handle "trailer" related placeholders in the
"--format=" mechanisms in the "log" family and "for-each-ref"
family is getting unified.

* hv/trailer-formatting:
  ref-filter: use pretty.c logic for trailers
  pretty.c: capture invalid trailer argument
  pretty.c: refactor trailer logic to `format_set_trailers_options()`
  t6300: use function to test trailer options

3 years agoMerge branch 'hn/reftable-tables-doc-update'
Junio C Hamano [Mon, 1 Mar 2021 22:02:57 +0000 (14:02 -0800)] 
Merge branch 'hn/reftable-tables-doc-update'

Documentation update.

* hn/reftable-tables-doc-update:
  doc/reftable: document how to handle windows

3 years agoMerge branch 'sv/t7001-modernize'
Junio C Hamano [Mon, 1 Mar 2021 22:02:57 +0000 (14:02 -0800)] 
Merge branch 'sv/t7001-modernize'

Test script modernization.

* sv/t7001-modernize:
  t7001: use `test` rather than `[`
  t7001: use here-docs instead of echo
  t7001: put each command on a separate line
  t7001: use '>' rather than 'touch'
  t7001: avoid using `cd` outside of subshells
  t7001: remove whitespace after redirect operators
  t7001: modernize subshell formatting
  t7001: remove unnecessary blank lines
  t7001: indent with TABs instead of spaces
  t7001: modernize test formatting

3 years agoMerge branch 'jt/transfer-fsck-across-packs'
Junio C Hamano [Mon, 1 Mar 2021 22:02:57 +0000 (14:02 -0800)] 
Merge branch 'jt/transfer-fsck-across-packs'

The approach to "fsck" the incoming objects in "index-pack" is
attractive for performance reasons (we have them already in core,
inflated and ready to be inspected), but fundamentally cannot be
applied fully when we receive more than one pack stream, as a tree
object in one pack may refer to a blob object in another pack as
".gitmodules", when we want to inspect blobs that are used as
".gitmodules" file, for example.  Teach "index-pack" to emit
objects that must be inspected later and check them in the calling
"fetch-pack" process.

* jt/transfer-fsck-across-packs:
  fetch-pack: print and use dangling .gitmodules
  fetch-pack: with packfile URIs, use index-pack arg
  http-fetch: allow custom index-pack args
  http: allow custom index-pack args

3 years agoMerge branch 'ds/chunked-file-api'
Junio C Hamano [Mon, 1 Mar 2021 22:02:57 +0000 (14:02 -0800)] 
Merge branch 'ds/chunked-file-api'

The common code to deal with "chunked file format" that is shared
by the multi-pack-index and commit-graph files have been factored
out, to help codepaths for both filetypes to become more robust.

* ds/chunked-file-api:
  commit-graph.c: display correct number of chunks when writing
  chunk-format: add technical docs
  chunk-format: restore duplicate chunk checks
  midx: use 64-bit multiplication for chunk sizes
  midx: use chunk-format read API
  commit-graph: use chunk-format read API
  chunk-format: create read chunk API
  midx: use chunk-format API in write_midx_internal()
  midx: drop chunk progress during write
  midx: return success/failure in chunk write methods
  midx: add num_large_offsets to write_midx_context
  midx: add pack_perm to write_midx_context
  midx: add entries to write_midx_context
  midx: use context in write_midx_pack_names()
  midx: rename pack_info to write_midx_context
  commit-graph: use chunk-format write API
  chunk-format: create chunk format write API
  commit-graph: anonymize data in chunk_write_fn

3 years agoMerge branch 'en/diffcore-rename'
Junio C Hamano [Mon, 1 Mar 2021 22:02:56 +0000 (14:02 -0800)] 
Merge branch 'en/diffcore-rename'

Performance optimization work on the rename detection continues.

* en/diffcore-rename:
  merge-ort: call diffcore_rename() directly
  gitdiffcore doc: mention new preliminary step for rename detection
  diffcore-rename: guide inexact rename detection based on basenames
  diffcore-rename: complete find_basename_matches()
  diffcore-rename: compute basenames of source and dest candidates
  t4001: add a test comparing basename similarity and content similarity
  diffcore-rename: filter rename_src list when possible
  diffcore-rename: no point trying to find a match better than exact

3 years agoMerge branch 'jh/fsmonitor-prework'
Junio C Hamano [Mon, 1 Mar 2021 22:02:56 +0000 (14:02 -0800)] 
Merge branch 'jh/fsmonitor-prework'

Preliminary changes to fsmonitor integration.

* jh/fsmonitor-prework:
  fsmonitor: refactor initialization of fsmonitor_last_update token
  fsmonitor: allow all entries for a folder to be invalidated
  fsmonitor: log FSMN token when reading and writing the index
  fsmonitor: log invocation of FSMonitor hook to trace2
  read-cache: log the number of scanned files to trace2
  read-cache: log the number of lstat calls to trace2
  preload-index: log the number of lstat calls to trace2
  p7519: add trace logging during perf test
  p7519: move watchman cleanup earlier in the test
  p7519: fix watchman watch-list test on Windows
  p7519: do not rely on "xargs -d" in test

3 years agoMerge https://github.com/prati0100/git-gui
Junio C Hamano [Mon, 1 Mar 2021 17:22:18 +0000 (09:22 -0800)] 
Merge https://github.com/prati0100/git-gui

* https://github.com/prati0100/git-gui:
  git-gui: remove lines starting with the comment character
  git-gui: fix typo in russian locale

3 years agoMerge branch 'js/commit-graph-warning'
Junio C Hamano [Mon, 1 Mar 2021 17:21:24 +0000 (09:21 -0800)] 
Merge branch 'js/commit-graph-warning'

* js/commit-graph-warning:
  Revert "commit-graph: when incompatible with graphs, indicate why"

3 years agoRevert "commit-graph: when incompatible with graphs, indicate why"
Junio C Hamano [Mon, 1 Mar 2021 17:19:37 +0000 (09:19 -0800)] 
Revert "commit-graph: when incompatible with graphs, indicate why"

This reverts commit c85eec7fc37e1ca79072f263ae6ea1ee305ba38c, as
it is a bit overzealous, we are in prerelease freeze, and we want
to have enough time to get this right and cook in 'next'.

cf. <8735xgkvuo.fsf@evledraar.gmail.com>

3 years agoGit 2.31-rc0 v2.31.0-rc0
Junio C Hamano [Fri, 26 Feb 2021 00:34:59 +0000 (16:34 -0800)] 
Git 2.31-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/push-delete-nothing'
Junio C Hamano [Fri, 26 Feb 2021 00:43:32 +0000 (16:43 -0800)] 
Merge branch 'jc/push-delete-nothing'

"git push $there --delete ''" should have been diagnosed as an
error, but instead turned into a matching push, which has been
corrected.

* jc/push-delete-nothing:
  push: do not turn --delete '' into a matching push

3 years agoMerge branch 'sh/mergetools-vimdiff1'
Junio C Hamano [Fri, 26 Feb 2021 00:43:32 +0000 (16:43 -0800)] 
Merge branch 'sh/mergetools-vimdiff1'

Mergetools update.

* sh/mergetools-vimdiff1:
  mergetools/vimdiff: add vimdiff1 merge tool variant

3 years agoMerge branch 'dl/doc-config-camelcase'
Junio C Hamano [Fri, 26 Feb 2021 00:43:32 +0000 (16:43 -0800)] 
Merge branch 'dl/doc-config-camelcase'

A handful of multi-word configuration variable names in
documentation that are spelled in all lowercase have been corrected
to use the more canonical camelCase.

* dl/doc-config-camelcase:
  index-format doc: camelCase core.excludesFile
  blame-options.txt: camelcase blame.blankBoundary
  i18n.txt: camel case and monospace "i18n.commitEncoding"

3 years agoMerge branch 'js/params-vs-args'
Junio C Hamano [Fri, 26 Feb 2021 00:43:32 +0000 (16:43 -0800)] 
Merge branch 'js/params-vs-args'

Messages update.

* js/params-vs-args:
  replace "parameters" by "arguments" in error messages

3 years agoMerge branch 'ug/doc-commit-approxidate'
Junio C Hamano [Fri, 26 Feb 2021 00:43:32 +0000 (16:43 -0800)] 
Merge branch 'ug/doc-commit-approxidate'

Doc update.

* ug/doc-commit-approxidate:
  doc: mention approxidates for git-commit --date

3 years agoMerge branch 'es/maintenance-of-bare-repositories'
Junio C Hamano [Fri, 26 Feb 2021 00:43:32 +0000 (16:43 -0800)] 
Merge branch 'es/maintenance-of-bare-repositories'

The "git maintenance register" command had trouble registering bare
repositories, which had been corrected.

* es/maintenance-of-bare-repositories:
  maintenance: fix incorrect `maintenance.repo` path with bare repository

3 years agoMerge branch 'mt/add-chmod-fixes'
Junio C Hamano [Fri, 26 Feb 2021 00:43:31 +0000 (16:43 -0800)] 
Merge branch 'mt/add-chmod-fixes'

Various fixes on "git add --chmod".

* mt/add-chmod-fixes:
  add: propagate --chmod errors to exit status
  add: mark --chmod error string for translation
  add --chmod: don't update index when --dry-run is used

3 years agoMerge branch 'ds/merge-base-independent'
Junio C Hamano [Fri, 26 Feb 2021 00:43:31 +0000 (16:43 -0800)] 
Merge branch 'ds/merge-base-independent'

The code to implement "git merge-base --independent" was poorly
done and was kept from the very beginning of the feature.

* ds/merge-base-independent:
  commit-reach: stale commits may prune generation further
  commit-reach: use heuristic in remove_redundant()
  commit-reach: move compare_commits_by_gen
  commit-reach: use one walk in remove_redundant()
  commit-reach: reduce requirements for remove_redundant()

3 years agoMerge branch 'ah/rebase-no-fork-point-config'
Junio C Hamano [Fri, 26 Feb 2021 00:43:31 +0000 (16:43 -0800)] 
Merge branch 'ah/rebase-no-fork-point-config'

"git rebase --[no-]fork-point" gained a configuration variable
rebase.forkPoint so that users do not have to keep specifying a
non-default setting.

* ah/rebase-no-fork-point-config:
  rebase: add a config option for --no-fork-point

3 years agoMerge branch 'mt/grep-sparse-checkout'
Junio C Hamano [Fri, 26 Feb 2021 00:43:31 +0000 (16:43 -0800)] 
Merge branch 'mt/grep-sparse-checkout'

"git grep" has been tweaked to be limited to the sparse checkout
paths.

* mt/grep-sparse-checkout:
  grep: honor sparse-checkout on working tree searches

3 years agoMerge branch 'ah/commit-graph-leakplug'
Junio C Hamano [Fri, 26 Feb 2021 00:43:31 +0000 (16:43 -0800)] 
Merge branch 'ah/commit-graph-leakplug'

Plug a minor memory leak.

* ah/commit-graph-leakplug:
  commit-graph: avoid leaking topo_levels slab in write_commit_graph()

3 years agoMerge branch 'zh/difftool-skip-to'
Junio C Hamano [Fri, 26 Feb 2021 00:43:31 +0000 (16:43 -0800)] 
Merge branch 'zh/difftool-skip-to'

"git difftool" learned "--skip-to=<path>" option to restart an
interrupted session from an arbitrary path.

* zh/difftool-skip-to:
  difftool.c: learn a new way start at specified file

3 years agoMerge branch 'cw/pack-config-doc'
Junio C Hamano [Fri, 26 Feb 2021 00:43:30 +0000 (16:43 -0800)] 
Merge branch 'cw/pack-config-doc'

Doc update.

* cw/pack-config-doc:
  doc: mention bigFileThreshold for packing

3 years agoMerge branch 'jc/maint-column-doc-typofix'
Junio C Hamano [Fri, 26 Feb 2021 00:43:30 +0000 (16:43 -0800)] 
Merge branch 'jc/maint-column-doc-typofix'

Doc update.

* jc/maint-column-doc-typofix:
  Documentation: typofix --column description

3 years agoMerge branch 'ma/doc-markup-fix'
Junio C Hamano [Fri, 26 Feb 2021 00:43:30 +0000 (16:43 -0800)] 
Merge branch 'ma/doc-markup-fix'

Docfix.

* ma/doc-markup-fix:
  gitmailmap.txt: fix rendering of e-mail addresses
  git.txt: fix monospace rendering
  rev-list-options.txt: fix rendering of bonus paragraph

3 years agoMerge branch 'jc/diffcore-rotate'
Junio C Hamano [Fri, 26 Feb 2021 00:43:30 +0000 (16:43 -0800)] 
Merge branch 'jc/diffcore-rotate'

"git {diff,log} --{skip,rotate}-to=<path>" allows the user to
discard diff output for early paths or move them to the end of the
output.

* jc/diffcore-rotate:
  diff: --{rotate,skip}-to=<path>

3 years agoMerge branch 'mt/checkout-index-corner-cases'
Junio C Hamano [Fri, 26 Feb 2021 00:43:30 +0000 (16:43 -0800)] 
Merge branch 'mt/checkout-index-corner-cases'

The error codepath around the "--temp/--prefix" feature of "git
checkout-index" has been improved.

* mt/checkout-index-corner-cases:
  checkout-index: omit entries with no tempname from --temp output
  write_entry(): fix misuses of `path` in error messages

3 years agoMerge branch 'js/doc-proto-v2-response-end'
Junio C Hamano [Fri, 26 Feb 2021 00:43:30 +0000 (16:43 -0800)] 
Merge branch 'js/doc-proto-v2-response-end'

Docfix.

* js/doc-proto-v2-response-end:
  doc: fix naming of response-end-pkt

3 years agoMerge branch 'rs/blame-optim'
Junio C Hamano [Fri, 26 Feb 2021 00:43:29 +0000 (16:43 -0800)] 
Merge branch 'rs/blame-optim'

Optimization in "git blame"

* rs/blame-optim:
  blame: remove unnecessary use of get_commit_info()

3 years agoMerge branch 'mz/doc-notes-are-not-anchors'
Junio C Hamano [Fri, 26 Feb 2021 00:43:29 +0000 (16:43 -0800)] 
Merge branch 'mz/doc-notes-are-not-anchors'

Objects that lost references can be pruned away, even when they
have notes attached to it (and these notes will become dangling,
which in turn can be pruned with "git notes prune").  This has been
clarified in the documentation.

* mz/doc-notes-are-not-anchors:
  docs: clarify that refs/notes/ do not keep the attached objects alive

3 years agoMerge branch 'ab/detox-gettext-tests'
Junio C Hamano [Fri, 26 Feb 2021 00:43:29 +0000 (16:43 -0800)] 
Merge branch 'ab/detox-gettext-tests'

Removal of GIT_TEST_GETTEXT_POISON continues.

* ab/detox-gettext-tests:
  tests: remove most uses of test_i18ncmp
  tests: remove last uses of C_LOCALE_OUTPUT
  tests: remove most uses of C_LOCALE_OUTPUT
  tests: remove last uses of GIT_TEST_GETTEXT_POISON=false

3 years agoMerge branch 'jk/rev-list-disk-usage'
Junio C Hamano [Fri, 26 Feb 2021 00:43:28 +0000 (16:43 -0800)] 
Merge branch 'jk/rev-list-disk-usage'

"git rev-list" command learned "--disk-usage" option.

* jk/rev-list-disk-usage:
  docs/rev-list: add some examples of --disk-usage
  docs/rev-list: add an examples section
  rev-list: add --disk-usage option for calculating disk usage
  t: add --no-tag option to test_commit

3 years agoindex-format doc: camelCase core.excludesFile
Junio C Hamano [Wed, 24 Feb 2021 20:26:41 +0000 (12:26 -0800)] 
index-format doc: camelCase core.excludesFile

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoblame-options.txt: camelcase blame.blankBoundary
Junio C Hamano [Wed, 24 Feb 2021 20:26:40 +0000 (12:26 -0800)] 
blame-options.txt: camelcase blame.blankBoundary

All other references to blame.* configuration variables are
camelCased already.  Update this one to match.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoi18n.txt: camel case and monospace "i18n.commitEncoding"
Denton Liu [Wed, 24 Feb 2021 20:26:39 +0000 (12:26 -0800)] 
i18n.txt: camel case and monospace "i18n.commitEncoding"

In 95791be750 (doc: camelCase the i18n config variables to improve
readability, 2017-07-17), the other i18n config variables were
camel cased. However, this one instance was missed.

Camel case and monospace "i18n.commitEncoding" so that it matches the
surrounding text.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
[jc: fixed 3 other mistakes that are exactly the same]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoread-cache: make the index write buffer size 128K
Neeraj Singh [Thu, 18 Feb 2021 02:48:26 +0000 (02:48 +0000)] 
read-cache: make the index write buffer size 128K

Writing an index 8K at a time invokes the OS filesystem and caching code
very frequently, introducing noticeable overhead while writing large
indexes. When experimenting with different write buffer sizes on Windows
writing the Windows OS repo index (260MB), most of the benefit came by
bumping the index write buffer size to 64K. I picked 128K to ensure that
we're past the knee of the curve.

With this change, the time under do_write_index for an index with 3M
files goes from ~1.02s to ~0.72s.

Signed-off-by: Neeraj Singh <neerajsi@ntdev.microsoft.com>
Acked-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoadd: propagate --chmod errors to exit status
Matheus Tavares [Tue, 23 Feb 2021 01:10:35 +0000 (22:10 -0300)] 
add: propagate --chmod errors to exit status

If `add` encounters an error while applying the --chmod changes, it
prints a message to stderr, but exits with a success code. This might
have been an oversight, as the command does exit with a non-zero code in
other situations where it cannot (or refuses to) update all of the
requested paths (e.g. when some of the given paths are ignored). So make
the exit behavior more consistent by also propagating --chmod errors to
the exit status.

Note: the test "all statuses changed in folder if . is given" uses paths
added by previous test cases, some of which might be symbolic links.
Because `git add --chmod` will now fail with such paths, this test would
depend on whether all the previous tests were executed, or only some
of them. Avoid that by running the test on a fresh repo with only
regular files.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoadd: mark --chmod error string for translation
Matheus Tavares [Tue, 23 Feb 2021 01:10:34 +0000 (22:10 -0300)] 
add: mark --chmod error string for translation

This error message is intended for humans, so mark it for translation.
Also use error() instead of fprintf(stderr, ...), to make the
corresponding line a bit cleaner, and to display the "error:" prefix,
which helps classifying the nature/severity of the message.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoadd --chmod: don't update index when --dry-run is used
Matheus Tavares [Tue, 23 Feb 2021 01:10:33 +0000 (22:10 -0300)] 
add --chmod: don't update index when --dry-run is used

`git add --chmod` applies the mode changes even when `--dry-run` is
used. Fix that and add some tests for this option combination.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase: add a config option for --no-fork-point
Alex Henrie [Tue, 23 Feb 2021 07:18:40 +0000 (00:18 -0700)] 
rebase: add a config option for --no-fork-point

Some users (myself included) would prefer to have this feature off by
default because it can silently drop commits.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph.c: display correct number of chunks when writing
Taylor Blau [Wed, 24 Feb 2021 17:12:22 +0000 (12:12 -0500)] 
commit-graph.c: display correct number of chunks when writing

When writing a commit-graph, a progress meter is shown which indicates
the number of pieces of data to write (one per commit in each chunk).

In 47410aa837 (commit-graph: use chunk-format write API, 2021-02-18),
the number of chunks became tracked by the new chunk-format API. But a
stray local variable was left behind from when write_commit_graph_file()
used to keep track of the same.

Since this was no longer updated after 47410aa837, the progress meter
appeared broken:

    $ git commit-graph write --reachable
    Expanding reachable commits in commit graph: 837569, done.
    Writing out commit graph in 3 passes: 166% (4187845/2512707), done.

Drop the local variable and rely instead on the chunk-format API to tell
us the correct number of chunks.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopush: do not turn --delete '' into a matching push
Junio C Hamano [Tue, 23 Feb 2021 23:13:32 +0000 (15:13 -0800)] 
push: do not turn --delete '' into a matching push

When we added a syntax sugar "git push remote --delete <ref>" to
"git push" as a synonym to the canonical "git push remote :<ref>"
syntax at f517f1f2 (builtin-push: add --delete as syntactic sugar
for :foo, 2009-12-30), we weren't careful enough to make sure that
<ref> is not empty.

Blindly rewriting "--delete <ref>" to ":<ref>" means that an empty
string <ref> results in refspec ":", which is the syntax to ask for
"matching" push that does not delete anything.

Worse yet, if there were matching refs that can be fast-forwarded,
they would have been published prematurely, even if the user feels
that they are not ready yet to be pushed out, which would be a real
disaster.

Noticed-by: Tilman Vogel <tilman.vogel@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: mention approxidates for git-commit --date
Jeff King [Tue, 23 Feb 2021 20:50:58 +0000 (15:50 -0500)] 
doc: mention approxidates for git-commit --date

We describe the more strict date formats accepted by GIT_COMMITTER_DATE,
etc, but the --date option also allows the looser approxidate formats,
as well. Unfortunately we don't have a good or complete reference for
this format, but let's at least mention that it _is_ looser, and give a
few examples.

If we ever write separate, more complete date-format documentation, we
should refer to it from here.

Based-on-a-patch-by: Utku Gultopu <ugultopu@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoreplace "parameters" by "arguments" in error messages
Johannes Sixt [Tue, 23 Feb 2021 21:11:32 +0000 (22:11 +0100)] 
replace "parameters" by "arguments" in error messages

When an error message informs the user about an incorrect command
invocation, it should refer to "arguments", not "parameters".

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomergetools/vimdiff: add vimdiff1 merge tool variant
Seth House [Sun, 14 Feb 2021 02:28:40 +0000 (19:28 -0700)] 
mergetools/vimdiff: add vimdiff1 merge tool variant

This adds yet another vimdiff/gvimdiff variant and presents conflicts as
a two-way diff between 'LOCAL' and 'REMOTE'. 'MERGED' is not opened
which deviates from the norm so usage text is echoed as a Vim message on
startup that instructs the user with how to proceed and how to abort.

Vimdiff is well-suited to two-way diffs so this is an option for a more
simple, more streamlined conflict resolution. For example: it is
difficult to communicate differences across more than two files using
only syntax highlighting; default vimdiff commands to get and put
changes between buffers do not need the user to manually specify
a source or destination buffer when only using two buffers.

Like other merge tools that directly compare 'LOCAL' with 'REMOTE', this
tool will benefit when paired with the new `mergetool.hideResolved`
setting.

Signed-off-by: Seth House <seth@eseth.com>
Tested-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc/reftable: document how to handle windows
Han-Wen Nienhuys [Tue, 23 Feb 2021 16:57:23 +0000 (16:57 +0000)] 
doc/reftable: document how to handle windows

On Windows we can't delete or overwrite files opened by other processes. Here we
sketch how to handle this situation.

We propose to use a random element in the filename. It's possible to design an
alternate solution based on counters, but that would assign semantics to the
filenames that complicates implementation.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomaintenance: fix incorrect `maintenance.repo` path with bare repository
Eric Sunshine [Tue, 23 Feb 2021 07:31:07 +0000 (02:31 -0500)] 
maintenance: fix incorrect `maintenance.repo` path with bare repository

The periodic maintenance tasks configured by `git maintenance start`
invoke `git for-each-repo` to run `git maintenance run` on each path
specified by the multi-value global configuration variable
`maintenance.repo`. Because `git for-each-repo` will likely be run
outside of the repositories which require periodic maintenance, it is
mandatory that the repository paths specified by `maintenance.repo` are
absolute.

Unfortunately, however, `git maintenance register` does nothing to
ensure that the paths it assigns to `maintenance.repo` are indeed
absolute, and may in fact -- especially in the case of a bare repository
-- assign a relative path to `maintenance.repo` instead. Fix this
problem by converting all paths to absolute before assigning them to
`maintenance.repo`.

While at it, also fix `git maintenance unregister` to convert paths to
absolute, as well, in order to ensure that it can correctly remove from
`maintenance.repo` a path assigned via `git maintenance register`.

Reported-by: Clement Moyroud <clement.moyroud@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe tenth batch
Junio C Hamano [Tue, 23 Feb 2021 00:09:36 +0000 (16:09 -0800)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ab/test-lib'
Junio C Hamano [Tue, 23 Feb 2021 00:12:43 +0000 (16:12 -0800)] 
Merge branch 'ab/test-lib'

Test framework clean-up.

* ab/test-lib:
  test-lib-functions: assert correct parameter count
  test-lib-functions: remove bug-inducing "diagnostics" helper param
  test libs: rename "diff-lib" to "lib-diff"
  t/.gitattributes: sort lines
  test-lib-functions: move function to lib-bitmap.sh
  test libs: rename gitweb-lib.sh to lib-gitweb.sh
  test libs: rename bundle helper to "lib-bundle.sh"
  test-lib-functions: remove generate_zero_bytes() wrapper
  test-lib-functions: move test_set_index_version() to its user
  test lib: change "error" to "BUG" as appropriate
  test-lib: remove check_var_migration

3 years agoMerge branch 'ab/diff-deferred-free'
Junio C Hamano [Tue, 23 Feb 2021 00:12:43 +0000 (16:12 -0800)] 
Merge branch 'ab/diff-deferred-free'

A small memleak in "diff -I<regexp>" has been corrected.

* ab/diff-deferred-free:
  diff: plug memory leak from regcomp() on {log,diff} -I
  diff: add an API for deferred freeing

3 years agoMerge branch 'ab/pager-exit-log'
Junio C Hamano [Tue, 23 Feb 2021 00:12:43 +0000 (16:12 -0800)] 
Merge branch 'ab/pager-exit-log'

When a pager spawned by us exited, the trace log did not record its
exit status correctly, which has been corrected.

* ab/pager-exit-log:
  pager: properly log pager exit code when signalled
  run-command: add braces for "if" block in wait_or_whine()
  pager: test for exit code with and without SIGPIPE
  pager: refactor wait_for_pager() function

3 years agoMerge branch 'ta/hash-function-transition-doc'
Junio C Hamano [Tue, 23 Feb 2021 00:12:43 +0000 (16:12 -0800)] 
Merge branch 'ta/hash-function-transition-doc'

Update formatting and grammar of the hash transition plan
documentation, plus some updates.

* ta/hash-function-transition-doc:
  doc: use https links
  doc hash-function-transition: move rationale upwards
  doc hash-function-transition: fix incomplete sentence
  doc hash-function-transition: use upper case consistently
  doc hash-function-transition: use SHA-1 and SHA-256 consistently
  doc hash-function-transition: fix asciidoc output

3 years agoMerge branch 'bc/signed-objects-with-both-hashes'
Junio C Hamano [Tue, 23 Feb 2021 00:12:42 +0000 (16:12 -0800)] 
Merge branch 'bc/signed-objects-with-both-hashes'

Signed commits and tags now allow verification of objects, whose
two object names (one in SHA-1, the other in SHA-256) are both
signed.

* bc/signed-objects-with-both-hashes:
  gpg-interface: remove other signature headers before verifying
  ref-filter: hoist signature parsing
  commit: allow parsing arbitrary buffers with headers
  gpg-interface: improve interface for parsing tags
  commit: ignore additional signatures when parsing signed commits
  ref-filter: switch some uses of unsigned long to size_t

3 years agoMerge branch 'dl/stash-cleanup'
Junio C Hamano [Tue, 23 Feb 2021 00:12:42 +0000 (16:12 -0800)] 
Merge branch 'dl/stash-cleanup'

Documentation, code and test clean-up around "git stash".

* dl/stash-cleanup:
  stash: declare ref_stash as an array
  t3905: use test_cmp() to check file contents
  t3905: replace test -s with test_file_not_empty
  t3905: remove nested git in command substitution
  t3905: move all commands into test cases
  t3905: remove spaces after redirect operators
  git-stash.txt: be explicit about subcommand options

3 years agocommit-graph: avoid leaking topo_levels slab in write_commit_graph()
Andrzej Hunt [Fri, 19 Feb 2021 20:13:10 +0000 (20:13 +0000)] 
commit-graph: avoid leaking topo_levels slab in write_commit_graph()

write_commit_graph initialises topo_levels using init_topo_level_slab(),
next it calls compute_topological_levels() which can cause the slab to
grow, we therefore need to clear the slab again using
clear_topo_level_slab() when we're done.

First introduced in 72a2bfca (commit-graph: add a slab to store
topological levels, 2021-01-16).

LeakSanitizer output:

==1026==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x498ae9 in realloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:164:3
    #1 0xafbed8 in xrealloc /src/git/wrapper.c:126:8
    #2 0x7966d1 in topo_level_slab_at_peek /src/git/commit-graph.c:71:1
    #3 0x7965e0 in topo_level_slab_at /src/git/commit-graph.c:71:1
    #4 0x78fbf5 in compute_topological_levels /src/git/commit-graph.c:1472:12
    #5 0x78c5c3 in write_commit_graph /src/git/commit-graph.c:2456:2
    #6 0x535c5f in graph_write /src/git/builtin/commit-graph.c:299:6
    #7 0x5350ca in cmd_commit_graph /src/git/builtin/commit-graph.c:337:11
    #8 0x4cddb1 in run_builtin /src/git/git.c:453:11
    #9 0x4cabe2 in handle_builtin /src/git/git.c:704:3
    #10 0x4cd084 in run_argv /src/git/git.c:771:4
    #11 0x4ca424 in cmd_main /src/git/git.c:902:19
    #12 0x707fb6 in main /src/git/common-main.c:52:11
    #13 0x7fee4249383f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)

Indirect leak of 524256 byte(s) in 1 object(s) allocated from:
    #0 0x498942 in calloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:154:3
    #1 0xafc088 in xcalloc /src/git/wrapper.c:140:8
    #2 0x796870 in topo_level_slab_at_peek /src/git/commit-graph.c:71:1
    #3 0x7965e0 in topo_level_slab_at /src/git/commit-graph.c:71:1
    #4 0x78fbf5 in compute_topological_levels /src/git/commit-graph.c:1472:12
    #5 0x78c5c3 in write_commit_graph /src/git/commit-graph.c:2456:2
    #6 0x535c5f in graph_write /src/git/builtin/commit-graph.c:299:6
    #7 0x5350ca in cmd_commit_graph /src/git/builtin/commit-graph.c:337:11
    #8 0x4cddb1 in run_builtin /src/git/git.c:453:11
    #9 0x4cabe2 in handle_builtin /src/git/git.c:704:3
    #10 0x4cd084 in run_argv /src/git/git.c:771:4
    #11 0x4ca424 in cmd_main /src/git/git.c:902:19
    #12 0x707fb6 in main /src/git/common-main.c:52:11
    #13 0x7fee4249383f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)

SUMMARY: AddressSanitizer: 524264 byte(s) leaked in 2 allocation(s).

Signed-off-by: Andrzej Hunt <ajrhunt@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodifftool.c: learn a new way start at specified file
ZheNing Hu [Fri, 19 Feb 2021 12:53:54 +0000 (12:53 +0000)] 
difftool.c: learn a new way start at specified file

`git difftool` only allow us to select file to view in turn.
If there is a commit with many files and we exit in the middle,
we will have to traverse list again to get the file diff which
we want to see. Therefore,teach the command an option
`--skip-to=<path>` to allow the user to say that diffs for earlier
paths are not interesting (because they were already seen in an
earlier session) and start this session with the named path.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-reach: stale commits may prune generation further
Derrick Stolee [Fri, 19 Feb 2021 12:34:10 +0000 (12:34 +0000)] 
commit-reach: stale commits may prune generation further

The remove_redundant_with_gen() algorithm performs a depth-first-search
to find commits in the 'array' list, starting at the parents of each
commit in 'array'. The result is that commits in 'array' are marked
STALE when they are reachable from another commit in 'array'.

This depth-first-search is fast when commits lie on or near the
first-parent history of the higher commits. The search terminates early
if all but one commit becomes marked STALE.

However, it is possible that there are two independent commits with high
generation number. In that case, the depth-first-search might languish
by searching in lower generations due to the fixed min_generation used
throughout the method.

With the expectation that commits with lower generation are expected to
become STALE more often, we can optimize further by increasing that
min_generation boundary upon discovery of the commit with minimum
generation.

We must first sort the commits in 'array' by generation. We cannot sort
'array' itself since it must preserve relative order among the returned
results (see revision.c:mark_redundant_parents() for an example).

This simplifies the initialization of min_generation, but it also allows
us to increase the new min_generation when we find the commit with
smallest generation remaining.

This requires more than two commits in order to test, so I used the
Linux kernel repository with a few commits that are slightly off of the
first-parent history. I timed the following command:

  git merge-base --independent 2ecedd756908 d2360a398f0b \
1253935ad801 160bab43419e 0e2209629fec 1d0e16ac1a9e

The first two commits have similar generation and are near the v5.10
tag. Commit 160bab43419e is off of the first-parent history behind v5.5,
while the others are scattered somewhere reachable from v5.9. This is
designed to demonstrate the optimization, as that commit within v5.5
would normally cause a lot of extra commit walking.

Since remove_redundant_with_alg() is called only when at least one of
the input commits has a finite generation number, this algorithm is
tested with a commit-graph generated starting at a number of different
tags, the earliest being v5.5.

commit-graph at v5.5:

 | Method                | Time  |
 |-----------------------+-------|
 | *_no_gen()            | 864ms |
 | *_with_gen() (before) | 858ms |
 | *_with_gen() (after)  | 810ms |

commit-graph at v5.7:

 | Method                | Time  |
 |-----------------------+-------|
 | *_no_gen()            | 625ms |
 | *_with_gen() (before) | 572ms |
 | *_with_gen() (after)  | 517ms |

commit-graph at v5.9:

 | Method                | Time  |
 |-----------------------+-------|
 | *_no_gen()            | 268ms |
 | *_with_gen() (before) | 224ms |
 | *_with_gen() (after)  | 202ms |

commit-graph at v5.10:

 | Method                | Time  |
 |-----------------------+-------|
 | *_no_gen()            |  72ms |
 | *_with_gen() (before) |  37ms |
 | *_with_gen() (after)  |   9ms |

Note that these are only modest improvements for the case where the two
independent commits are not in the commit-graph (not until v5.10). All
algorithms get faster as more commits are indexed, which is not a
surprise. However, the cost of walking extra commits is more and more
prevalent in relative terms as more commits are indexed. Finally, the
last case allows us to jump to the minimum generation between the last
two commits (that are actually independent) so we greatly reduce the
cost in that case.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-reach: use heuristic in remove_redundant()
Derrick Stolee [Fri, 19 Feb 2021 12:34:09 +0000 (12:34 +0000)] 
commit-reach: use heuristic in remove_redundant()

Reachability algorithms in commit-reach.c frequently benefit from using
the first-parent history as a heuristic for satisfying reachability
queries. The most obvious example was implemented in 4fbcca4e
(commit-reach: make can_all_from_reach... linear, 2018-07-20).

Update the walk in remove_redundant() to use this same heuristic. Here,
we are walking starting at the parents of the input commits. Sort those
parents and walk from the highest generation to lower. Each time, use
the heuristic of searching the first parent history before continuing to
expand the walk.

The order in which we explore the commits matters, so update
compare_commits_by_gen to break generation number ties with commit date.
This has no effect when the commits are in a commit-graph file with
corrected commit dates computed, but it will assist when the commits are
in the region "above" the commit-graph with "infinite" generation
number. Note that we cannot shift to use
compare_commits_by_gen_then_commit_date as the method prototype is
different. We use compare_commits_by_gen for QSORT() as opposed to as a
priority function.

The important piece is to ensure we short-circuit the walk when we find
that there is a single non-redundant commit. This happens frequently
when looking for merge-bases or comparing several tags with 'git
merge-base --independent'. Use a new count 'count_still_independent' and
if that hits 1 we can stop walking.

To update 'count_still_independent' properly, we add use of the RESULT
flag on the input commits. Then we can detect when we reach one of these
commits and decrease the count. We need to remove the RESULT flag at
that moment because we might re-visit that commit when popping the
stack.

We use the STALE flag to mark parents that have been added to the new
walk_start list, but we need to clear that flag before we start walking
so those flags don't halt our depth-first-search walk.

On my copy of the Linux kernel repository, the performance of 'git
merge-base --independent <all-tags>' goes from 1.1 seconds to 0.11
seconds.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-reach: move compare_commits_by_gen
Derrick Stolee [Fri, 19 Feb 2021 12:34:08 +0000 (12:34 +0000)] 
commit-reach: move compare_commits_by_gen

Move this earlier in the file so it can be used by more methods.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-reach: use one walk in remove_redundant()
Derrick Stolee [Fri, 19 Feb 2021 12:34:07 +0000 (12:34 +0000)] 
commit-reach: use one walk in remove_redundant()

The current implementation of remove_redundant() uses several calls to
paint_down_to_common() to determine that commits are independent of each
other. This leads to quadratic behavior when many inputs are passed to
commands such as 'git merge-base'.

For example, in the Linux kernel repository, I tested the performance
by passing all tags:

 git merge-base --independent $(git for-each-ref refs/tags --format="$(refname)")

(Note: I had to delete the tags v2.6.11-tree and v2.6.11 as they do
not point to commits.)

Here is the performance improvement introduced by this change:

 Before: 16.4s
  After:  1.1s

This performance improvement requires the commit-graph file to be
present. We keep the old algorithm around as remove_redundant_no_gen()
and use it when generation_numbers_enabled() is false. This is similar
to other algorithms within commit-reach.c. The new algorithm is
implemented in remove_redundant_with_gen().

The basic approach is to do one commit walk instead of many. First, scan
all commits in the list and mark their _parents_ with the STALE flag.
This flag will indicate commits that are reachable from one of the
inputs, except not including themselves. Then, walk commits until
covering all commits up to the minimum generation number pushing the
STALE flag throughout.

At the end, we need to clear the STALE bit from all of the commits
we walked. We move the non-stale commits in 'array' to the beginning of
the list, and this might overwrite stale commits. However, we store an
array of commits that started the walk, and use clear_commit_marks() on
each of those starting commits. That method will walk the reachable
commits with the STALE bit and clear them all. This makes the algorithm
safe for re-entry or for other uses of those commits after this walk.

This logic is covered by tests in t6600-test-reach.sh, so the behavior
does not change. This is tested both in the case with a commit-graph and
without.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: mention bigFileThreshold for packing
Christian Walther [Sun, 21 Feb 2021 13:23:57 +0000 (13:23 +0000)] 
doc: mention bigFileThreshold for packing

Knowing about the core.bigFileThreshold configuration variable is
helpful when examining pack file size differences between repositories.
Add a reference to it to the manpages a user is likely to read in this
situation.

Capitalize CONFIGURATION for consistency with other pages having such a
section.

Signed-off-by: Christian Walther <cwalther@gmx.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofetch-pack: print and use dangling .gitmodules
Jonathan Tan [Mon, 22 Feb 2021 19:20:09 +0000 (11:20 -0800)] 
fetch-pack: print and use dangling .gitmodules

Teach index-pack to print dangling .gitmodules links after its "keep" or
"pack" line instead of declaring an error, and teach fetch-pack to check
such lines printed.

This allows the tree side of the .gitmodules link to be in one packfile
and the blob side to be in another without failing the fsck check,
because it is now fetch-pack which checks such objects after all
packfiles have been downloaded and indexed (and not index-pack on an
individual packfile, as it is before this commit).

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofetch-pack: with packfile URIs, use index-pack arg
Jonathan Tan [Mon, 22 Feb 2021 19:20:08 +0000 (11:20 -0800)] 
fetch-pack: with packfile URIs, use index-pack arg

Unify the index-pack arguments used when processing the inline pack and
when downloading packfiles referenced by URIs. This is done by teaching
get_pack() to also store the index-pack arguments whenever at least one
packfile URI is given, and then when processing the packfile URI(s),
using the stored arguments.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp-fetch: allow custom index-pack args
Jonathan Tan [Mon, 22 Feb 2021 19:20:07 +0000 (11:20 -0800)] 
http-fetch: allow custom index-pack args

This is the next step in teaching fetch-pack to pass its index-pack
arguments when processing packfiles referenced by URIs.

The "--keep" in fetch-pack.c will be replaced with a full message in a
subsequent commit.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: allow custom index-pack args
Jonathan Tan [Mon, 22 Feb 2021 19:20:06 +0000 (11:20 -0800)] 
http: allow custom index-pack args

Currently, when fetching, packfiles referenced by URIs are run through
index-pack without any arguments other than --stdin and --keep, no
matter what arguments are used for the packfile that is inline in the
fetch response. As a preparation for ensuring that all packs (whether
inline or not) use the same index-pack arguments, teach the http
subsystem to allow custom index-pack arguments.

http-fetch has been updated to use the new API. For now, it passes
--keep alone instead of --keep with a process ID, but this is only
temporary because http-fetch itself will be taught to accept index-pack
parameters (instead of using a hardcoded constant) in a subsequent
commit.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'py/commit-comments'
Pratyush Yadav [Mon, 22 Feb 2021 14:49:53 +0000 (20:19 +0530)] 
Merge branch 'py/commit-comments'

Use git-stripspace to remove comment lines from the commit message. Also
use it to clean up whitespace instead of rolling our own logic.

* py/commit-comments:
  git-gui: remove lines starting with the comment character

3 years agoDocumentation: typofix --column description
Junio C Hamano [Sat, 20 Feb 2021 02:44:05 +0000 (18:44 -0800)] 
Documentation: typofix --column description

f4ed0af6 (Merge branch 'nd/columns', 2012-05-03) brought in three
cut-and-pasted copies of malformatted descriptions.  Let's fix them
all the same way by marking the configuration variable names up as
monospace just like the command line option `--column` is typeset.

While we are at it, correct a missing space after the full stop that
ends the sentence.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agochunk-format: add technical docs
Derrick Stolee [Thu, 18 Feb 2021 14:07:39 +0000 (14:07 +0000)] 
chunk-format: add technical docs

The chunk-based file format is now an API in the code, but we should
also take time to document it as a file format. Specifically, it matches
the CHUNK LOOKUP sections of the commit-graph and multi-pack-index
files, but there are some commonalities that should be grouped in this
document.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agochunk-format: restore duplicate chunk checks
Derrick Stolee [Thu, 18 Feb 2021 14:07:38 +0000 (14:07 +0000)] 
chunk-format: restore duplicate chunk checks

Before refactoring into the chunk-format API, the commit-graph parsing
logic included checks for duplicate chunks. It is unlikely that we would
desire a chunk-based file format that allows duplicate chunk IDs in the
table of contents, so add duplicate checks into
read_table_of_contents().

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: use 64-bit multiplication for chunk sizes
Derrick Stolee [Thu, 18 Feb 2021 14:07:37 +0000 (14:07 +0000)] 
midx: use 64-bit multiplication for chunk sizes

When calculating the sizes of certain chunks, we should use 64-bit
multiplication always. This allows us to properly predict the chunk
sizes without risk of overflow.

Other possible overflows were discovered by evaluating each
multiplication in midx.c and ensuring that at least one side of the
operator was of type size_t or off_t.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: use chunk-format read API
Derrick Stolee [Thu, 18 Feb 2021 14:07:36 +0000 (14:07 +0000)] 
midx: use chunk-format read API

Instead of parsing the table of contents directly, use the chunk-format
API methods read_table_of_contents() and pair_chunk(). In particular, we
can use the return value of pair_chunk() to generate an error when a
required chunk is missing.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph: use chunk-format read API
Derrick Stolee [Thu, 18 Feb 2021 14:07:35 +0000 (14:07 +0000)] 
commit-graph: use chunk-format read API

Instead of parsing the table of contents directly, use the chunk-format
API methods read_table_of_contents() and pair_chunk(). While the current
implementation loses the duplicate-chunk detection, that will be added
in a future change.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agochunk-format: create read chunk API
Derrick Stolee [Thu, 18 Feb 2021 14:07:34 +0000 (14:07 +0000)] 
chunk-format: create read chunk API

Add the capability to read the table of contents, then pair the chunks
with necessary logic using read_chunk_fn pointers. Callers will be added
in future changes, but the typical outline will be:

 1. initialize a 'struct chunkfile' with init_chunkfile(NULL).
 2. call read_table_of_contents().
 3. for each chunk to parse,
    a. call pair_chunk() to assign a pointer with the chunk position, or
    b. call read_chunk() to run a callback on the chunk start and size.
 4. call free_chunkfile() to clear the 'struct chunkfile' data.

We are re-using the anonymous 'struct chunkfile' data, as it is internal
to the chunk-format API. This gives it essentially two modes: write and
read. If the same struct instance was used for both reads and writes,
then there would be failures.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: use chunk-format API in write_midx_internal()
Derrick Stolee [Thu, 18 Feb 2021 14:07:33 +0000 (14:07 +0000)] 
midx: use chunk-format API in write_midx_internal()

The chunk-format API allows writing the table of contents and all chunks
using the anonymous 'struct chunkfile' type. We only need to convert our
local chunk logic to this API for the multi-pack-index writes to share
that logic with the commit-graph file writes.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: drop chunk progress during write
Derrick Stolee [Thu, 18 Feb 2021 14:07:32 +0000 (14:07 +0000)] 
midx: drop chunk progress during write

Most expensive operations in write_midx_internal() use the context
struct's progress member, and these indicate the process of the
expensive operations within the chunk writing methods. However, there is
a competing progress struct that counts the progress over all chunks.
This is not very helpful compared to the others, so drop it.

This also reduces our barriers to combining the chunk writing code with
chunk-format.c.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: return success/failure in chunk write methods
Derrick Stolee [Thu, 18 Feb 2021 14:07:31 +0000 (14:07 +0000)] 
midx: return success/failure in chunk write methods

Historically, the chunk-writing methods in midx.c have returned the
amount of data written so the writer method could compare this with the
table of contents. This presents with some interesting issues:

1. If a chunk writing method has a bug that miscalculates the written
   bytes, then we can satisfy the table of contents without actually
   writing the right amount of data to the hashfile. The commit-graph
   writing code checks the hashfile struct directly for a more robust
   verification.

2. There is no way for a chunk writing method to gracefully fail.
   Returning an int presents an opportunity to fail without a die().

3. The current pattern doesn't match chunk_write_fn type exactly, so we
   cannot share code with commit-graph.c

For these reasons, convert the midx chunk writer methods to return an
'int'. Since none of them fail at the moment, they all return 0.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: add num_large_offsets to write_midx_context
Derrick Stolee [Thu, 18 Feb 2021 14:07:30 +0000 (14:07 +0000)] 
midx: add num_large_offsets to write_midx_context

In an effort to align write_midx_internal() with the chunk-format API,
continue to group necessary data into "struct write_midx_context". This
change collects the "uint32_t num_large_offsets" into the context. With
this new data, write_midx_large_offsets() now matches the
chunk_write_fn type.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: add pack_perm to write_midx_context
Derrick Stolee [Thu, 18 Feb 2021 14:07:29 +0000 (14:07 +0000)] 
midx: add pack_perm to write_midx_context

In an effort to align write_midx_internal() with the chunk-format API,
continue to group necessary data into "struct write_midx_context". This
change collects the "uint32_t *pack_perm" and large_offsets_needed bit
into the context.

Update write_midx_object_offsets() to match chunk_write_fn.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: add entries to write_midx_context
Derrick Stolee [Thu, 18 Feb 2021 14:07:28 +0000 (14:07 +0000)] 
midx: add entries to write_midx_context

In an effort to align write_midx_internal() with the chunk-format API,
continue to group necessary data into "struct write_midx_context". This
change collects the "struct pack_midx_entry *entries" list and its count
into the context.

Update write_midx_oid_fanout() and write_midx_oid_lookup() to take the
context directly, as these are easy conversions with this new data.

Only the callers of write_midx_object_offsets() and
write_midx_large_offsets() are updated here, since additional data in
the context before those methods can match chunk_write_fn.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: use context in write_midx_pack_names()
Derrick Stolee [Thu, 18 Feb 2021 14:07:27 +0000 (14:07 +0000)] 
midx: use context in write_midx_pack_names()

In an effort to align the write_midx_internal() to use the chunk-format
API, start converting chunk writing methods to match chunk_write_fn. The
first case is to convert write_midx_pack_names() to take "void *data".
We already have the necessary data in "struct write_midx_context", so
this conversion is rather mechanical.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: rename pack_info to write_midx_context
Derrick Stolee [Thu, 18 Feb 2021 14:07:26 +0000 (14:07 +0000)] 
midx: rename pack_info to write_midx_context

In an effort to streamline our chunk-based file formats, align some of
the code structure in write_midx_internal() to be similar to the
patterns in write_commit_graph_file().

Specifically, let's create a "struct write_midx_context" that can be
used as a data parameter to abstract function types.

This change only renames "struct pack_info" to "struct
write_midx_context" and the names of instances from "packs" to "ctx". In
future changes, we will expand the data inside "struct
write_midx_context" and align our chunk-writing method with the
chunk-format API.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph: use chunk-format write API
Derrick Stolee [Thu, 18 Feb 2021 14:07:25 +0000 (14:07 +0000)] 
commit-graph: use chunk-format write API

The commit-graph write logic is ready to make use of the chunk-format
write API. Each chunk write method is already in the correct prototype.
We only need to use the 'struct chunkfile' pointer and the correct API
calls.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agochunk-format: create chunk format write API
Derrick Stolee [Thu, 18 Feb 2021 14:07:24 +0000 (14:07 +0000)] 
chunk-format: create chunk format write API

In anticipation of combining the logic from the commit-graph and
multi-pack-index file formats, create a new chunk-format API. Use a
'struct chunkfile' pointer to keep track of data that has been
registered for writes. This struct is anonymous outside of
chunk-format.c to ensure no user attempts to interfere with the data.

The next change will use this API in commit-graph.c, but the general
approach is:

 1. initialize the chunkfile with init_chunkfile(f).
 2. add chunks in the intended writing order with add_chunk().
 3. write any header information to the hashfile f.
 4. write the chunkfile data using write_chunkfile().
 5. free the chunkfile struct using free_chunkfile().

Helped-by: Taylor Blau <me@ttaylorr.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogitmailmap.txt: fix rendering of e-mail addresses
Martin Ågren [Wed, 17 Feb 2021 19:56:06 +0000 (20:56 +0100)] 
gitmailmap.txt: fix rendering of e-mail addresses

Both AsciiDoc and Asciidoctor are eager to pick up the e-mail addresses
in this document and turn them into references at the bottom of the
manpage / clickable links. We don't really need that for these dummy
addresses. Spell "@" as "&#64;" to make them not do this. In the open
block, we can instead avoid this by indenting the contents, similar to
the earlier blocks.

Fix a backtick which should have been a single quote mark. With all the
quoting that is going on around here, this mistake trips up the parsing
and rendering quite a bit.

Before this commit, we have the same failure mode with AsciiDoc 8.6.10
and Asciidoctor 1.5.5, and this change makes both of them happy.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit.txt: fix monospace rendering
Martin Ågren [Wed, 17 Feb 2021 19:56:05 +0000 (20:56 +0100)] 
git.txt: fix monospace rendering

When we write `<name>`s with the "s" tucked on to the closing backtick,
we end up rendering the backticks literally. Rephrase this sentence
slightly to render this as monospace.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-gui: remove lines starting with the comment character
Pratyush Yadav [Tue, 2 Feb 2021 19:58:12 +0000 (01:28 +0530)] 
git-gui: remove lines starting with the comment character

The comment character is specified by the config variable
'core.commentchar'. Any lines starting with this character is considered
a comment and should not be included in the final commit message.

Teach git-gui to filter out lines in the commit message that start with
the comment character using git-stripspace. If the config is not set,
'#' is taken as the default. Also add a message educating users about
the comment character.

Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
3 years agoThe ninth batch
Junio C Hamano [Thu, 18 Feb 2021 00:39:59 +0000 (16:39 -0800)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ak/config-bad-bool-error'
Junio C Hamano [Thu, 18 Feb 2021 01:21:43 +0000 (17:21 -0800)] 
Merge branch 'ak/config-bad-bool-error'

The error message given when a configuration variable that is
expected to have a boolean value has been improved.

* ak/config-bad-bool-error:
  config: improve error message for boolean config

3 years agoMerge branch 'js/reflog-expire-stale-fix'
Junio C Hamano [Thu, 18 Feb 2021 01:21:43 +0000 (17:21 -0800)] 
Merge branch 'js/reflog-expire-stale-fix'

"git reflog expire --stale-fix" can be used to repair the reflog by
removing entries that refer to objects that have been pruned away,
but was not careful to tolerate missing objects.

* js/reflog-expire-stale-fix:
  reflog expire --stale-fix: be generous about missing objects

3 years agoMerge branch 'js/commit-graph-warning'
Junio C Hamano [Thu, 18 Feb 2021 01:21:42 +0000 (17:21 -0800)] 
Merge branch 'js/commit-graph-warning'

When certain features (e.g. grafts) used in the repository are
incompatible with the use of the commit-graph, we used to silently
turned commit-graph off; we now tell the user what we are doing.

* js/commit-graph-warning:
  commit-graph: when incompatible with graphs, indicate why

3 years agoMerge branch 'ew/rev-parse-since-test'
Junio C Hamano [Thu, 18 Feb 2021 01:21:42 +0000 (17:21 -0800)] 
Merge branch 'ew/rev-parse-since-test'

Test to make sure "git rev-parse one-thing one-thing" gives
the same thing twice (when one-thing is --since=X).

* ew/rev-parse-since-test:
  t1500: ensure current --since= behavior remains

3 years agoMerge branch 'ds/maintenance-pack-refs'
Junio C Hamano [Thu, 18 Feb 2021 01:21:42 +0000 (17:21 -0800)] 
Merge branch 'ds/maintenance-pack-refs'

"git maintenance" tool learned a new "pack-refs" maintenance task.

* ds/maintenance-pack-refs:
  maintenance: incremental strategy runs pack-refs weekly
  maintenance: add pack-refs task

3 years agoMerge branch 'jx/t5411-unique-filenames'
Junio C Hamano [Thu, 18 Feb 2021 01:21:42 +0000 (17:21 -0800)] 
Merge branch 'jx/t5411-unique-filenames'

Avoid individual tests in t5411 from getting affected by each other
by forcing them to use separate output files during the test.

* jx/t5411-unique-filenames:
  t5411: refactor check of refs using test_cmp_refs
  t5411: use different out file to prevent overwriting

3 years agoMerge branch 'js/fsck-name-objects-fix'
Junio C Hamano [Thu, 18 Feb 2021 01:21:42 +0000 (17:21 -0800)] 
Merge branch 'js/fsck-name-objects-fix'

Fix "git fsck --name-objects" which apparently has not been used by
anybody who is motivated enough to report breakage.

* js/fsck-name-objects-fix:
  fsck --name-objects: be more careful parsing generation numbers
  t1450: robustify `remove_object()`

3 years agoMerge branch 'jk/mailmap-only-at-root'
Junio C Hamano [Thu, 18 Feb 2021 01:21:41 +0000 (17:21 -0800)] 
Merge branch 'jk/mailmap-only-at-root'

The .mailmap is documented to be read only from the root level of a
working tree, but a stray file in a bare repository also was read
by accident, which has been corrected.

* jk/mailmap-only-at-root:
  mailmap: only look for .mailmap in work tree

3 years agoMerge branch 'mt/grep-cached-untracked'
Junio C Hamano [Thu, 18 Feb 2021 01:21:41 +0000 (17:21 -0800)] 
Merge branch 'mt/grep-cached-untracked'

"git grep --untracked" is meant to be "let's ALSO find in these
files on the filesystem" when looking for matches in the working
tree files, and does not make any sense if the primary search is
done against the index, or the tree objects.  The "--cached" and
"--untracked" options have been marked as mutually incompatible.

* mt/grep-cached-untracked:
  grep: error out if --untracked is used with --cached

3 years agoMerge branch 'sh/mergetool-hideresolved'
Junio C Hamano [Thu, 18 Feb 2021 01:21:41 +0000 (17:21 -0800)] 
Merge branch 'sh/mergetool-hideresolved'

"git mergetool" feeds three versions (base, local and remote) of
a conflicted path unmodified.  The command learned to optionally
prepare these files with unconflicted parts already resolved.

* sh/mergetool-hideresolved:
  mergetool: add per-tool support and overrides for the hideResolved flag
  mergetool: break setup_tool out into separate initialization function
  mergetool: add hideResolved configuration

3 years agoMerge branch 'jt/trace2-BUG'
Junio C Hamano [Thu, 18 Feb 2021 01:21:41 +0000 (17:21 -0800)] 
Merge branch 'jt/trace2-BUG'

Even though invocations of "die()" were logged to the trace2
system, "BUG()"s were not, which has been corrected.

* jt/trace2-BUG:
  usage: trace2 BUG() invocations