]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
9 months agoMerge branch 'rs/incompatible-options-messages'
Junio C Hamano [Wed, 20 Dec 2023 18:14:53 +0000 (10:14 -0800)] 
Merge branch 'rs/incompatible-options-messages'

Clean-up code that handles combinations of incompatible options.

* rs/incompatible-options-messages:
  worktree: simplify incompatibility message for --orphan and commit-ish
  worktree: standardize incompatibility messages
  clean: factorize incompatibility message
  revision, rev-parse: factorize incompatibility messages about - -exclude-hidden
  revision: use die_for_incompatible_opt3() for - -graph/--reverse/--walk-reflogs
  repack: use die_for_incompatible_opt3() for -A/-k/--cruft
  push: use die_for_incompatible_opt4() for - -delete/--tags/--all/--mirror

9 months agoMerge branch 'jc/revision-parse-int'
Junio C Hamano [Wed, 20 Dec 2023 18:14:53 +0000 (10:14 -0800)] 
Merge branch 'jc/revision-parse-int'

The command line parser for the "log" family of commands was too
loose when parsing certain numbers, e.g., silently ignoring the
extra 'q' in "git log -n 1q" without complaining, which has been
tightened up.

* jc/revision-parse-int:
  revision: parse integer arguments to --max-count, --skip, etc., more carefully

9 months agoMerge branch 'mk/doc-gitfile-more'
Junio C Hamano [Wed, 20 Dec 2023 18:14:53 +0000 (10:14 -0800)] 
Merge branch 'mk/doc-gitfile-more'

Doc update.

* mk/doc-gitfile-more:
  doc: make the gitfile syntax easier to discover

9 months agoMerge branch 'ps/ref-tests-update-more'
Junio C Hamano [Wed, 20 Dec 2023 18:14:53 +0000 (10:14 -0800)] 
Merge branch 'ps/ref-tests-update-more'

Tests update.

* ps/ref-tests-update-more:
  t6301: write invalid object ID via `test-tool ref-store`
  t5551: stop writing packed-refs directly
  t5401: speed up creation of many branches
  t4013: simplify magic parsing and drop "failure"
  t3310: stop checking for reference existence via `test -f`
  t1417: make `reflog --updateref` tests backend agnostic
  t1410: use test-tool to create empty reflog
  t1401: stop treating FETCH_HEAD as real reference
  t1400: split up generic reflog tests from the reffile-specific ones
  t0410: mark tests to require the reffiles backend

9 months agoMerge branch 'jp/use-diff-index-in-pre-commit-sample'
Junio C Hamano [Wed, 20 Dec 2023 18:14:52 +0000 (10:14 -0800)] 
Merge branch 'jp/use-diff-index-in-pre-commit-sample'

The sample pre-commit hook that tries to catch introduction of new
paths that use potentially non-portable characters did not notice
an existing path getting renamed to such a problematic path, when
rename detection was enabled.

* jp/use-diff-index-in-pre-commit-sample:
  hooks--pre-commit: detect non-ASCII when renaming

9 months agoMerge branch 'en/complete-sparse-checkout'
Junio C Hamano [Wed, 20 Dec 2023 18:14:52 +0000 (10:14 -0800)] 
Merge branch 'en/complete-sparse-checkout'

Command line completion (in contrib/) learned to complete path
arguments to the "add/set" subcommands of "git sparse-checkout"
better.

* en/complete-sparse-checkout:
  completion: avoid user confusion in non-cone mode
  completion: avoid misleading completions in cone mode
  completion: fix logic for determining whether cone mode is active
  completion: squelch stray errors in sparse-checkout completion

9 months agoThe second batch
Junio C Hamano [Mon, 18 Dec 2023 20:44:19 +0000 (12:44 -0800)] 
The second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jh/trace2-redact-auth'
Junio C Hamano [Mon, 18 Dec 2023 22:10:13 +0000 (14:10 -0800)] 
Merge branch 'jh/trace2-redact-auth'

trace2 streams used to record the URLs that potentially embed
authentication material, which has been corrected.

* jh/trace2-redact-auth:
  t0212: test URL redacting in EVENT format
  t0211: test URL redacting in PERF format
  trace2: redact passwords from https:// URLs by default
  trace2: fix signature of trace2_def_param() macro

9 months agoMerge branch 'ad/merge-file-diff-algo'
Junio C Hamano [Mon, 18 Dec 2023 22:10:13 +0000 (14:10 -0800)] 
Merge branch 'ad/merge-file-diff-algo'

"git merge-file" learned to take the "--diff-algorithm" option to
use algorithm different from the default "myers" diff.

* ad/merge-file-diff-algo:
  merge-file: add --diff-algorithm option

9 months agoMerge branch 'rs/column-leakfix'
Junio C Hamano [Mon, 18 Dec 2023 22:10:13 +0000 (14:10 -0800)] 
Merge branch 'rs/column-leakfix'

Leakfix.

* rs/column-leakfix:
  column: release strbuf and string_list after use

9 months agoMerge branch 'rs/i18n-cannot-be-used-together'
Junio C Hamano [Mon, 18 Dec 2023 22:10:12 +0000 (14:10 -0800)] 
Merge branch 'rs/i18n-cannot-be-used-together'

Clean-up code that handles combinations of incompatible options.

* rs/i18n-cannot-be-used-together:
  i18n: factorize even more 'incompatible options' messages

9 months agoMerge branch 'jb/reflog-expire-delete-dry-run-options'
Junio C Hamano [Mon, 18 Dec 2023 22:10:12 +0000 (14:10 -0800)] 
Merge branch 'jb/reflog-expire-delete-dry-run-options'

Command line parsing fix for "git reflog".

* jb/reflog-expire-delete-dry-run-options:
  builtin/reflog.c: fix dry-run option short name

9 months agoMerge branch 'js/update-urls-in-doc-and-comment'
Junio C Hamano [Mon, 18 Dec 2023 22:10:12 +0000 (14:10 -0800)] 
Merge branch 'js/update-urls-in-doc-and-comment'

Stale URLs have been updated to their current counterparts (or
archive.org) and HTTP links are replaced with working HTTPS links.

* js/update-urls-in-doc-and-comment:
  doc: refer to internet archive
  doc: update links for andre-simon.de
  doc: switch links to https
  doc: update links to current pages

9 months agoMerge branch 'ps/commit-graph-less-paranoid'
Junio C Hamano [Mon, 18 Dec 2023 22:10:11 +0000 (14:10 -0800)] 
Merge branch 'ps/commit-graph-less-paranoid'

Earlier we stopped relying on commit-graph that (still) records
information about commits that are lost from the object store,
which has negative performance implications.  The default has been
flipped to disable this pessimization.

* ps/commit-graph-less-paranoid:
  commit-graph: disable GIT_COMMIT_GRAPH_PARANOIA by default

9 months agoMerge branch 'cc/git-replay'
Junio C Hamano [Mon, 18 Dec 2023 22:10:11 +0000 (14:10 -0800)] 
Merge branch 'cc/git-replay'

Introduce "git replay", a tool meant on the server side without
working tree to recreate a history.

* cc/git-replay:
  replay: stop assuming replayed branches do not diverge
  replay: add --contained to rebase contained branches
  replay: add --advance or 'cherry-pick' mode
  replay: use standard revision ranges
  replay: make it a minimal server side command
  replay: remove HEAD related sanity check
  replay: remove progress and info output
  replay: add an important FIXME comment about gpg signing
  replay: change rev walking options
  replay: introduce pick_regular_commit()
  replay: die() instead of failing assert()
  replay: start using parse_options API
  replay: introduce new builtin
  t6429: remove switching aspects of fast-rebase

9 months agoMerge branch 'ac/fuzz-show-date'
Junio C Hamano [Mon, 18 Dec 2023 22:10:11 +0000 (14:10 -0800)] 
Merge branch 'ac/fuzz-show-date'

Subject approxidate() and show_date() machinery to OSS-Fuzz.

* ac/fuzz-show-date:
  fuzz: add new oss-fuzz fuzzer for date.c / date.h

9 months agoMerge branch 'ps/ref-deletion-updates'
Junio C Hamano [Mon, 18 Dec 2023 22:10:11 +0000 (14:10 -0800)] 
Merge branch 'ps/ref-deletion-updates'

Simplify API implementation to delete references by eliminating
duplication.

* ps/ref-deletion-updates:
  refs: remove `delete_refs` callback from backends
  refs: deduplicate code to delete references
  refs/files: use transactions to delete references
  t5510: ensure that the packed-refs file needs locking

9 months agoMerge branch 'js/packfile-h-typofix'
Junio C Hamano [Mon, 18 Dec 2023 22:10:10 +0000 (14:10 -0800)] 
Merge branch 'js/packfile-h-typofix'

Typofix.

* js/packfile-h-typofix:
  packfile.c: fix a typo in `each_file_in_pack_dir_fn()`'s declaration

9 months agoStart the 2.44 cycle
Junio C Hamano [Sat, 9 Dec 2023 18:34:18 +0000 (10:34 -0800)] 
Start the 2.44 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'tz/send-email-negatable-options'
Junio C Hamano [Sun, 10 Dec 2023 00:37:51 +0000 (16:37 -0800)] 
Merge branch 'tz/send-email-negatable-options'

Newer versions of Getopt::Long started giving warnings against our
(ab)use of it in "git send-email".  Bump the minimum version
requirement for Perl to 5.8.1 (from September 2002) to allow
simplifying our implementation.

* tz/send-email-negatable-options:
  send-email: avoid duplicate specification warnings
  perl: bump the required Perl version to 5.8.1 from 5.8.0

9 months agoMerge branch 'ak/rebase-autosquash'
Junio C Hamano [Sun, 10 Dec 2023 00:37:50 +0000 (16:37 -0800)] 
Merge branch 'ak/rebase-autosquash'

"git rebase --autosquash" is now enabled for non-interactive rebase,
but it is still incompatible with the apply backend.

* ak/rebase-autosquash:
  rebase: rewrite --(no-)autosquash documentation
  rebase: support --autosquash without -i
  rebase: fully ignore rebase.autoSquash without -i

9 months agoMerge branch 'vd/for-each-ref-unsorted-optimization'
Junio C Hamano [Sun, 10 Dec 2023 00:37:50 +0000 (16:37 -0800)] 
Merge branch 'vd/for-each-ref-unsorted-optimization'

"git for-each-ref --no-sort" still sorted the refs alphabetically
which paid non-trivial cost.  It has been redefined to show output
in an unspecified order, to allow certain optimizations to take
advantage of.

* vd/for-each-ref-unsorted-optimization:
  t/perf: add perf tests for for-each-ref
  ref-filter.c: use peeled tag for '*' format fields
  for-each-ref: clean up documentation of --format
  ref-filter.c: filter & format refs in the same callback
  ref-filter.c: refactor to create common helper functions
  ref-filter.c: rename 'ref_filter_handler()' to 'filter_one()'
  ref-filter.h: add functions for filter/format & format-only
  ref-filter.h: move contains caches into filter
  ref-filter.h: add max_count and omit_empty to ref_format
  ref-filter.c: really don't sort when using --no-sort

9 months agoMerge branch 'ps/ban-a-or-o-operator-with-test'
Junio C Hamano [Sun, 10 Dec 2023 00:37:50 +0000 (16:37 -0800)] 
Merge branch 'ps/ban-a-or-o-operator-with-test'

Test and shell scripts clean-up.

* ps/ban-a-or-o-operator-with-test:
  Makefile: stop using `test -o` when unlinking duplicate executables
  contrib/subtree: convert subtree type check to use case statement
  contrib/subtree: stop using `-o` to test for number of args
  global: convert trivial usages of `test <expr> -a/-o <expr>`

9 months agoMerge branch 'ss/format-patch-use-encode-headers-for-cover-letter'
Junio C Hamano [Sun, 10 Dec 2023 00:37:49 +0000 (16:37 -0800)] 
Merge branch 'ss/format-patch-use-encode-headers-for-cover-letter'

"git format-patch --encode-email-headers" ignored the option when
preparing the cover letter, which has been corrected.

* ss/format-patch-use-encode-headers-for-cover-letter:
  format-patch: fix ignored encode_email_headers for cover letter

9 months agoMerge branch 'ps/ref-tests-update'
Junio C Hamano [Sun, 10 Dec 2023 00:37:49 +0000 (16:37 -0800)] 
Merge branch 'ps/ref-tests-update'

Update ref-related tests.

* ps/ref-tests-update:
  t: mark several tests that assume the files backend with REFFILES
  t7900: assert the absence of refs via git-for-each-ref(1)
  t7300: assert exact states of repo
  t4207: delete replace references via git-update-ref(1)
  t1450: convert tests to remove worktrees via git-worktree(1)
  t: convert tests to not access reflog via the filesystem
  t: convert tests to not access symrefs via the filesystem
  t: convert tests to not write references via the filesystem
  t: allow skipping expected object ID in `ref-store update-ref`

9 months agoMerge branch 'jw/git-add-attr-pathspec'
Junio C Hamano [Sun, 10 Dec 2023 00:37:49 +0000 (16:37 -0800)] 
Merge branch 'jw/git-add-attr-pathspec'

"git add" and "git stash" learned to support the ":(attr:...)"
magic pathspec.

* jw/git-add-attr-pathspec:
  attr: enable attr pathspec magic for git-add and git-stash

9 months agoMerge branch 'jk/chunk-bounds-more'
Junio C Hamano [Sun, 10 Dec 2023 00:37:48 +0000 (16:37 -0800)] 
Merge branch 'jk/chunk-bounds-more'

Code clean-up for jk/chunk-bounds topic.

* jk/chunk-bounds-more:
  commit-graph: mark chunk error messages for translation
  commit-graph: drop verify_commit_graph_lite()
  commit-graph: check order while reading fanout chunk
  commit-graph: use fanout value for graph size
  commit-graph: abort as soon as we see a bogus chunk
  commit-graph: clarify missing-chunk error messages
  commit-graph: drop redundant call to "lite" verification
  midx: check consistency of fanout table
  commit-graph: handle overflow in chunk_size checks

9 months agoMerge branch 'js/ci-discard-prove-state'
Junio C Hamano [Sun, 10 Dec 2023 00:37:48 +0000 (16:37 -0800)] 
Merge branch 'js/ci-discard-prove-state'

The way CI testing used "prove" could lead to running the test
suite twice needlessly, which has been corrected.

* js/ci-discard-prove-state:
  ci: avoid running the test suite _twice_

9 months agoMerge branch 'ps/ci-gitlab'
Junio C Hamano [Sun, 10 Dec 2023 00:37:48 +0000 (16:37 -0800)] 
Merge branch 'ps/ci-gitlab'

Add support for GitLab CI.

* ps/ci-gitlab:
  ci: add support for GitLab CI
  ci: install test dependencies for linux-musl
  ci: squelch warnings when testing with unusable Git repo
  ci: unify setup of some environment variables
  ci: split out logic to set up failed test artifacts
  ci: group installation of Docker dependencies
  ci: make grouping setup more generic
  ci: reorder definitions for grouping functions

9 months agoMerge branch 'js/doc-unit-tests-with-cmake'
Junio C Hamano [Sun, 10 Dec 2023 00:37:47 +0000 (16:37 -0800)] 
Merge branch 'js/doc-unit-tests-with-cmake'

Update the base topic to work with CMake builds.

* js/doc-unit-tests-with-cmake:
  cmake: handle also unit tests
  cmake: use test names instead of full paths
  cmake: fix typo in variable name
  artifacts-tar: when including `.dll` files, don't forget the unit-tests
  unit-tests: do show relative file paths
  unit-tests: do not mistake `.pdb` files for being executable
  cmake: also build unit tests

9 months agoMerge branch 'js/doc-unit-tests'
Junio C Hamano [Sun, 10 Dec 2023 00:37:47 +0000 (16:37 -0800)] 
Merge branch 'js/doc-unit-tests'

Process to add some form of low-level unit tests has started.

* js/doc-unit-tests:
  ci: run unit tests in CI
  unit tests: add TAP unit test framework
  unit tests: add a project plan document

9 months agoMerge branch 'ps/httpd-tests-on-nixos'
Junio C Hamano [Sun, 10 Dec 2023 00:37:46 +0000 (16:37 -0800)] 
Merge branch 'ps/httpd-tests-on-nixos'

Portability tweak.

* ps/httpd-tests-on-nixos:
  t9164: fix inability to find basename(1) in Subversion hooks
  t/lib-httpd: stop using legacy crypt(3) for authentication
  t/lib-httpd: dynamically detect httpd and modules path

9 months agorevision: parse integer arguments to --max-count, --skip, etc., more carefully
Junio C Hamano [Fri, 8 Dec 2023 22:35:23 +0000 (07:35 +0900)] 
revision: parse integer arguments to --max-count, --skip, etc., more carefully

The "rev-list" and other commands in the "log" family, being the
oldest part of the system, use their own custom argument parsers,
and integer values of some options are parsed with atoi(), which
allows a non-digit after the number (e.g., "1q") to be silently
ignored.  As a natural consequence, an argument that does not begin
with a digit (e.g., "q") silently becomes zero, too.

Switch to use strtol_i() and parse_timestamp() appropriately to
catch bogus input.

Note that one may naïvely expect that --max-count, --skip, etc., to
only take non-negative values, but we must allow them to also take
negative values, as an escape hatch to countermand a limit set by an
earlier option on the command line; the underlying variables are
initialized to (-1) and "--max-count=-1", for example, is a
legitimate way to reinitialize the limit.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoworktree: simplify incompatibility message for --orphan and commit-ish
René Scharfe [Wed, 6 Dec 2023 11:52:01 +0000 (12:52 +0100)] 
worktree: simplify incompatibility message for --orphan and commit-ish

Use a single translatable string to report that the worktree add option
--orphan is incompatible with a commit-ish instead of having the
commit-ish in a separate translatable string.  This reduces the number
of strings to translate and gives translators the full context.

A similar message is used in builtin/describe.c, but with the plural of
commit-ish, and here we need the singular form.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoworktree: standardize incompatibility messages
René Scharfe [Wed, 6 Dec 2023 11:52:00 +0000 (12:52 +0100)] 
worktree: standardize incompatibility messages

Use the standard parameterized message for reporting incompatible
options for worktree add.  This reduces the number of strings to
translate and makes the UI slightly more consistent.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoclean: factorize incompatibility message
René Scharfe [Wed, 6 Dec 2023 11:51:59 +0000 (12:51 +0100)] 
clean: factorize incompatibility message

Use the standard parameterized message for reporting incompatible
options to inform users that they can't use -x and -X together.  This
reduces the number of strings to translate and makes the UI slightly
more consistent.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorevision, rev-parse: factorize incompatibility messages about - -exclude-hidden
René Scharfe [Wed, 6 Dec 2023 11:51:58 +0000 (12:51 +0100)] 
revision, rev-parse: factorize incompatibility messages about - -exclude-hidden

Use the standard parameterized message for reporting incompatible
options to report options that are not accepted in combination with
--exclude-hidden.  This reduces the number of strings to translate and
makes the UI a bit more consistent.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorevision: use die_for_incompatible_opt3() for - -graph/--reverse/--walk-reflogs
René Scharfe [Wed, 6 Dec 2023 11:51:57 +0000 (12:51 +0100)] 
revision: use die_for_incompatible_opt3() for - -graph/--reverse/--walk-reflogs

The revision option --reverse is incompatible with --walk-reflogs and
--graph is incompatible with both --reverse and --walk-reflogs.  So they
are all incompatible with each other.

Use the function for checking three mutually incompatible options,
die_for_incompatible_opt3(), to perform this check in one place and
without repetition.  This is shorter and clearer.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorepack: use die_for_incompatible_opt3() for -A/-k/--cruft
René Scharfe [Wed, 6 Dec 2023 11:51:56 +0000 (12:51 +0100)] 
repack: use die_for_incompatible_opt3() for -A/-k/--cruft

The repack option --keep-unreachable is incompatible with -A, --cruft is
incompatible with -A and -k, and -k is short for --keep-unreachable.  So
they are all incompatible with each other.

Use the function for checking three mutually incompatible options,
die_for_incompatible_opt3(), to perform this check in one place and
without repetition.  This is shorter and clearer.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agopush: use die_for_incompatible_opt4() for - -delete/--tags/--all/--mirror
René Scharfe [Wed, 6 Dec 2023 11:51:55 +0000 (12:51 +0100)] 
push: use die_for_incompatible_opt4() for - -delete/--tags/--all/--mirror

The push option --delete is incompatible with --all, --mirror, and
--tags; --tags is incompatible with --all and --mirror; --all is
incompatible with --mirror.  This means they are all incompatible with
each other.  And --branches is an alias for --all.

Use the function for checking four mutually incompatible options,
die_for_incompatible_opt4(), to perform this check in one place and
without repetition.  This is shorter and clearer.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompletion: avoid user confusion in non-cone mode
Elijah Newren [Sun, 3 Dec 2023 05:57:04 +0000 (05:57 +0000)] 
completion: avoid user confusion in non-cone mode

It is tempting to think of "files and directories" of the current
directory as valid inputs to the add and set subcommands of git
sparse-checkout.  However, in non-cone mode, they often aren't and using
them as potential completions leads to *many* forms of confusion:

Issue #1. It provides the *wrong* files and directories.

For
    git sparse-checkout add
we always want to add files and directories not currently in our sparse
checkout, which means we want file and directories not currently present
in the current working tree.  Providing the files and directories
currently present is thus always wrong.

For
    git sparse-checkout set
we have a similar problem except in the subset of cases where we are
trying to narrow our checkout to a strict subset of what we already
have.  That is not a very common scenario, especially since it often
does not even happen to be true for the first use of the command; for
years we required users to create a sparse-checkout via
    git sparse-checkout init
    git sparse-checkout set <args...>
(or use a clone option that did the init step for you at clone time).
The init command creates a minimal sparse-checkout with just the
top-level directory present, meaning the set command has to be used to
expand the checkout.  Thus, only in a special and perhaps unusual cases
would any of the suggestions from normal file and directory completion
be appropriate.

Issue #2: Suggesting patterns that lead to warnings is unfriendly.

If the user specifies any regular file and omits the leading '/', then
the sparse-checkout command will warn the user that their command is
problematic and suggest they use a leading slash instead.

Issue #3: Completion gets confused by leading '/', and provides wrong paths.

Users often want to anchor their patterns to the toplevel of the
repository, especially when listing individual files.  There are a
number of reasons for this, but notably even sparse-checkout encourages
them to do so (as noted above).  However, if users do so (via adding a
leading '/' to their pattern), then bash completion will interpret the
leading slash not as a request for a path at the toplevel of the
repository, but as a request for a path at the root of the filesytem.
That means at best that completion cannot help with such paths, and if
it does find any completions, they are almost guaranteed to be wrong.

Issue #4: Suggesting invalid patterns from subdirectories is unfriendly.

There is no per-directory equivalent to .gitignore with
sparse-checkouts.  There is only a single worktree-global
$GIT_DIR/info/sparse-checkout file.  As such, paths to files must be
specified relative to the toplevel of a repository.  Providing
suggestions of paths that are relative to the current working directory,
as bash completion defaults to, is wrong when the current working
directory is not the worktree toplevel directory.

Issue #5: Paths with special characters will be interpreted incorrectly

The entries in the sparse-checkout file are patterns, not paths.  While
most paths also qualify as patterns (though even in such cases it would
be better for users to not use them directly but prefix them with a
leading '/'), there are a variety of special characters that would need
special escaping beyond the normal shell escaping: '*', '?', '\', '[',
']', and any leading '#' or '!'.  If completion suggests any such paths,
users will likely expect them to be treated as an exact path rather than
as a pattern that might match some number of files other than 1.

However, despite the first four issues, we can note that _if_ users are
using tab completion, then they are probably trying to specify a path in
the index.  As such, we transform their argument into a top-level-rooted
pattern that matches such a file.  For example, if they type:
   git sparse-checkout add Make<TAB>
we could "complete" to
   git sparse-checkout add /Makefile
or, if they ran from the Documentation/technical/ subdirectory:
   git sparse-checkout add m<TAB>
we could "complete" it to:
   git sparse-checkout add /Documentation/technical/multi-pack-index.txt
Note in both cases I use "complete" in quotes, because we actually add
characters both before and after the argument in question, so we are
kind of abusing "bash completions" to be "bash completions AND
beginnings".

The fifth issue is a bit stickier, especially when you consider that we
not only need to deal with escaping issues because of special meanings
of patterns in sparse-checkout & gitignore files, but also that we need
to consider escaping issues due to ls-files needing to sometimes quote
or escape characters, and because the shell needs to escape some
characters.  The multiple interacting forms of escaping could get ugly;
this patch makes no attempt to do so and simply documents that we
decided to not deal with those corner cases for now but at least get the
common cases right.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompletion: avoid misleading completions in cone mode
Elijah Newren [Sun, 3 Dec 2023 05:57:03 +0000 (05:57 +0000)] 
completion: avoid misleading completions in cone mode

The "set" and "add" subcommands of "sparse-checkout", when in cone mode,
should only complete on directories.  For bash_completion in general,
when no completions are returned for any subcommands, it will often fall
back to standard completion of files and directories as a substitute.
That is not helpful here.  Since we have already looked for all valid
completions, if none are found then falling back to standard bash file
and directory completion is at best actively misleading.  In fact, there
are three different ways it can be actively misleading.  Add a long
comment in the code about how that fallback behavior can deceive, and
disable the fallback by returning a fake result as the sole completion.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompletion: fix logic for determining whether cone mode is active
Elijah Newren [Sun, 3 Dec 2023 05:57:02 +0000 (05:57 +0000)] 
completion: fix logic for determining whether cone mode is active

_git_sparse_checkout() was checking whether we were in cone mode by
checking whether either:

    A) core.sparseCheckoutCone was "true"
    B) "--cone" was specified on the command line

This code has 2 bugs I didn't catch in my review at the time

    1) core.sparseCheckout must be "true" for core.sparseCheckoutCone to
       be relevant (which matters since "git sparse-checkout disable"
       only unsets core.sparseCheckout, not core.sparseCheckoutCone)
    2) The presence of "--no-cone" should override any config setting

Further, I forgot to update this logic as part of 2d95707a02
("sparse-checkout: make --cone the default", 2022-04-22) for the new
default.

Update the code for the new default and make it be more careful in
determining whether to complete based on cone mode or non-cone mode.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompletion: squelch stray errors in sparse-checkout completion
Elijah Newren [Sun, 3 Dec 2023 05:57:01 +0000 (05:57 +0000)] 
completion: squelch stray errors in sparse-checkout completion

If, in the root of a project, one types

    git sparse-checkout set --cone ../<TAB>

then an error message of the form

    fatal: ../: '../' is outside repository at '/home/newren/floss/git'

is written to stderr, which munges the users view of their own command.
Squelch such messages by using the __git() wrapper, designed for this
purpose; see commit e15098a314 (completion: consolidate silencing errors
from git commands, 2017-02-03) for more on the wrapper.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agohooks--pre-commit: detect non-ASCII when renaming
Julian Prein [Thu, 30 Nov 2023 16:13:56 +0000 (16:13 +0000)] 
hooks--pre-commit: detect non-ASCII when renaming

When diff.renames is turned on, the diff-filter will not return renamed
files (or copied ones with diff.renames=copy) and potential non-ASCII
characters would not be caught by this hook.

Use the plumbing command diff-index instead of the porcelain one to not
be affected by diff.rename.

Signed-off-by: Julian Prein <druckdev@protonmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot6301: write invalid object ID via `test-tool ref-store`
Patrick Steinhardt [Wed, 29 Nov 2023 07:25:18 +0000 (08:25 +0100)] 
t6301: write invalid object ID via `test-tool ref-store`

One of the tests in t6301 verifies that the reference backend correctly
warns about the case where a reference points to a non-existent object.
This is done by writing the object ID into the loose reference directly,
which is quite intimate with how the files backend works.

Refactor the code to instead use `test-tool ref-store` to write the
reference, which is backend-agnostic.

There are two more tests in this file which write loose files directly,
as well. But both of them are indeed quite specific to the loose files
backend and cannot be easily ported to other backends. We thus mark them
as requiring the REFFILES prerequisite.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot5551: stop writing packed-refs directly
Patrick Steinhardt [Wed, 29 Nov 2023 07:25:14 +0000 (08:25 +0100)] 
t5551: stop writing packed-refs directly

We have multiple tests in t5551 that write thousands of tags. To do so
efficiently we generate the tags by writing the `packed-refs` file
directly, which of course assumes that the reference database is backed
by the files backend.

Refactor the code to instead use a single `git update-ref --stdin`
command to write the tags. While the on-disk end result is not the same
as we now have a bunch of loose refs instead of a single packed-refs
file, the distinction shouldn't really matter for any of the tests that
use this helper.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot5401: speed up creation of many branches
Patrick Steinhardt [Wed, 29 Nov 2023 07:25:09 +0000 (08:25 +0100)] 
t5401: speed up creation of many branches

One of the tests in t5401 creates a bunch of branches by calling
git-branch(1) for every one of them. This is quite inefficient and takes
a comparatively long time even on Unix systems where spawning processes
is comparatively fast. Refactor it to instead use git-update-ref(1),
which leads to an almost 10-fold speedup:

```
Benchmark 1: ./t5401-update-hooks.sh (rev = HEAD)
  Time (mean ± σ):     983.2 ms ±  97.6 ms    [User: 328.8 ms, System: 679.2 ms]
  Range (min … max):   882.9 ms … 1078.0 ms    3 runs

Benchmark 2: ./t5401-update-hooks.sh (rev = HEAD~)
  Time (mean ± σ):      9.312 s ±  0.398 s    [User: 2.766 s, System: 6.617 s]
  Range (min … max):    8.885 s …  9.674 s    3 runs

Summary
  ./t5401-update-hooks.sh (rev = HEAD) ran
    9.47 ± 1.02 times faster than ./t5401-update-hooks.sh (rev = HEAD~)
```

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot4013: simplify magic parsing and drop "failure"
Patrick Steinhardt [Wed, 29 Nov 2023 07:25:05 +0000 (08:25 +0100)] 
t4013: simplify magic parsing and drop "failure"

In t14013, we have various different tests that verify whether certain
diffs are generated as expected. As much of the logic is the same across
many of the tests we some common code in there that generates the actual
test cases for us.

As some diffs are more special than others depending on the command line
parameters passed to git-diff(1), these tests need to adapt behaviour to
the specific test case sometimes. This is done via colon-prefixed magic
commands, of which we currently know "failure" and "noellipses". The
logic to parse this magic is a bit convoluted though and hard to grasp,
also due to the rather unnecessary nesting.

Un-nest the cases so that it becomes a bit more straightfoward. The
logic is further simplified by removing support for the "failure" magic,
which is not actually used anymore.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot3310: stop checking for reference existence via `test -f`
Patrick Steinhardt [Wed, 29 Nov 2023 07:25:01 +0000 (08:25 +0100)] 
t3310: stop checking for reference existence via `test -f`

One of the tests in t3310 exercises whether the special references
`NOTES_MERGE_PARTIAL` and `NOTES_MERGE_REF` exist as expected when the
notes subsystem runs into a merge conflict. This is done by checking
on-disk data structures directly though instead of asking the reference
backend.

Refactor the test to use git-rev-parse(1) instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot1417: make `reflog --updateref` tests backend agnostic
Patrick Steinhardt [Wed, 29 Nov 2023 07:24:57 +0000 (08:24 +0100)] 
t1417: make `reflog --updateref` tests backend agnostic

The tests for `git reflog delete --updateref` are currently marked to
only run with the reffiles backend. There is no inherent reason that
this should be the case other than the fact that the setup messes with
the on-disk reflogs directly.

Refactor the test to stop doing so and drop the REFFILES prerequisite.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot1410: use test-tool to create empty reflog
Patrick Steinhardt [Wed, 29 Nov 2023 07:24:53 +0000 (08:24 +0100)] 
t1410: use test-tool to create empty reflog

One of the tests in t1410 is marked to be specific to the files
reference backend, which is because we create a reflog manually by
creating the respective file. Refactor the test to instead use our
`test-tool ref-store` helper to create the reflog so that it works with
other reference backends, as well.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot1401: stop treating FETCH_HEAD as real reference
Patrick Steinhardt [Wed, 29 Nov 2023 07:24:49 +0000 (08:24 +0100)] 
t1401: stop treating FETCH_HEAD as real reference

One of the tests in t1401 asserts that we can create a symref from a
symbolic reference to a top-level reference, which is done by linking
from `refs/heads/top-level` to `FETCH_HEAD`. But `FETCH_HEAD` is not a
proper reference and doesn't even follow the loose reference format, so
it is not a good candidate for the logic under test.

Refactor the test to use `ORIG_HEAD` instead of `FETCH_HEAD`. This also
works with other backends than the reffiles one.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot1400: split up generic reflog tests from the reffile-specific ones
Patrick Steinhardt [Wed, 29 Nov 2023 07:24:44 +0000 (08:24 +0100)] 
t1400: split up generic reflog tests from the reffile-specific ones

We have a bunch of tests in t1400 that check whether we correctly read
reflog entries. These tests create the reflog by manually writing to the
respective loose file, which makes them specific to the files backend.
But while some of them do indeed exercise very specific edge cases in
the reffiles backend, most of the tests exercise generic functionality
that should be common to all backends.

Unfortunately, we can't easily adapt all of the tests to work with all
backends. Instead, split out the reffile-specific tests from the ones
that should work with all backends and refactor the generic ones to not
write to the on-disk files directly anymore.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot0410: mark tests to require the reffiles backend
Patrick Steinhardt [Wed, 29 Nov 2023 07:24:40 +0000 (08:24 +0100)] 
t0410: mark tests to require the reffiles backend

Two of our tests in t0410 verify whether partial clones end up with the
correct repository format version and extensions. These checks require
the reffiles backend because every other backend would by necessity bump
the repository format version to be at least 1.

Mark the tests accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agodoc: make the gitfile syntax easier to discover
Marcel Krause [Tue, 28 Nov 2023 06:55:58 +0000 (07:55 +0100)] 
doc: make the gitfile syntax easier to discover

Signed-off-by: Marcel Krause <mk+copyleft@pimpmybyte.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoi18n: factorize even more 'incompatible options' messages
René Scharfe [Sun, 26 Nov 2023 11:57:43 +0000 (12:57 +0100)] 
i18n: factorize even more 'incompatible options' messages

Continue the work of 12909b6b8a (i18n: turn "options are incompatible"
into "cannot be used together", 2022-01-05) and a699367bb8 (i18n:
factorize more 'incompatible options' messages, 2022-01-31) to use the
same parameterized error message for reporting incompatible command line
options.  This reduces the number of strings to translate and makes the
UI slightly more consistent.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocolumn: release strbuf and string_list after use
René Scharfe [Sun, 26 Nov 2023 11:57:36 +0000 (12:57 +0100)] 
column: release strbuf and string_list after use

Releasing strbuf and string_list just before exiting is not strictly
necessary, but it gets rid of false positives reported by leak checkers,
which can then be more easily used to show that the column-printing
machinery behind print_columns() are free of leaks.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: stop assuming replayed branches do not diverge
Elijah Newren [Fri, 24 Nov 2023 11:10:43 +0000 (12:10 +0100)] 
replay: stop assuming replayed branches do not diverge

The replay command is able to replay multiple branches but when some of
them are based on other replayed branches, their commit should be
replayed onto already replayed commits.

For this purpose, let's store the replayed commit and its original
commit in a key value store, so that we can easily find and reuse a
replayed commit instead of the original one.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: add --contained to rebase contained branches
Elijah Newren [Fri, 24 Nov 2023 11:10:42 +0000 (12:10 +0100)] 
replay: add --contained to rebase contained branches

Let's add a `--contained` option that can be used along with
`--onto` to rebase all the branches contained in the <revision-range>
argument.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: add --advance or 'cherry-pick' mode
Elijah Newren [Fri, 24 Nov 2023 11:10:41 +0000 (12:10 +0100)] 
replay: add --advance or 'cherry-pick' mode

There is already a 'rebase' mode with `--onto`. Let's add an 'advance' or
'cherry-pick' mode with `--advance`. This new mode will make the target
branch advance as we replay commits onto it.

The replayed commits should have a single tip, so that it's clear where
the target branch should be advanced. If they have more than one tip,
this new mode will error out.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: use standard revision ranges
Elijah Newren [Fri, 24 Nov 2023 11:10:40 +0000 (12:10 +0100)] 
replay: use standard revision ranges

Instead of the fixed "<oldbase> <branch>" arguments, the replay
command now accepts "<revision-range>..." arguments in a similar
way as many other Git commands. This makes its interface more
standard and more flexible.

This also enables many revision related options accepted and
eaten by setup_revisions(). If the replay command was a high level
one or had a high level mode, it would make sense to restrict some
of the possible options, like those generating non-contiguous
history, as they could be confusing for most users.

Also as the interface of the command is now mostly finalized,
we can add more documentation and more testcases to make sure
the command will continue to work as designed in the future.

We only document the rev-list related options among all the
revision related options that are now accepted, as the rev-list
related ones are probably the most useful for now.

Helped-by: Dragan Simic <dsimic@manjaro.org>
Helped-by: Linus Arver <linusa@google.com>
Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: make it a minimal server side command
Elijah Newren [Fri, 24 Nov 2023 11:10:39 +0000 (12:10 +0100)] 
replay: make it a minimal server side command

We want this command to be a minimal command that just does server side
picking of commits, displaying the results on stdout for higher level
scripts to consume.

So let's simplify it:
  * remove the worktree and index reading/writing,
  * remove the ref (and reflog) updating,
  * remove the assumptions tying us to HEAD, since (a) this is not a
    rebase and (b) we want to be able to pick commits in a bare repo,
    i.e. to/from branches that are not checked out and not the main
    branch,
  * remove unneeded includes,
  * handle rebasing multiple branches by printing on stdout the update
    ref commands that should be performed.

The output can be piped into `git update-ref --stdin` for the ref
updates to happen.

In the future to make it easier for users to use this command
directly maybe an option can be added to automatically pipe its output
into `git update-ref`.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: remove HEAD related sanity check
Elijah Newren [Fri, 24 Nov 2023 11:10:38 +0000 (12:10 +0100)] 
replay: remove HEAD related sanity check

We want replay to be a command that can be used on the server side on
any branch, not just the current one, so we are going to stop updating
HEAD in a future commit.

A "sanity check" that makes sure we are replaying the current branch
doesn't make sense anymore. Let's remove it.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: remove progress and info output
Elijah Newren [Fri, 24 Nov 2023 11:10:37 +0000 (12:10 +0100)] 
replay: remove progress and info output

The replay command will be changed in a follow up commit, so that it
will not update refs directly, but instead it will print on stdout a
list of commands that can be consumed by `git update-ref --stdin`.

We don't want this output to be polluted by its current low value
output, so let's just remove the latter.

In the future, when the command gets an option to update refs by
itself, it will make a lot of sense to display a progress meter, but
we are not there yet.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: add an important FIXME comment about gpg signing
Elijah Newren [Fri, 24 Nov 2023 11:10:36 +0000 (12:10 +0100)] 
replay: add an important FIXME comment about gpg signing

We want to be able to handle signed commits in some way in the future,
but we are not ready to do it now. So for the time being let's just add
a FIXME comment to remind us about it.

These are different ways we could handle them:

  - in case of a cli user and if there was an interactive mode, we could
    perhaps ask if the user wants to sign again
  - we could add an option to just fail if there are signed commits

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: change rev walking options
Elijah Newren [Fri, 24 Nov 2023 11:10:35 +0000 (12:10 +0100)] 
replay: change rev walking options

Let's force the rev walking options we need after calling
setup_revisions() instead of before.

This might override some user supplied rev walking command line options
though. So let's detect that and warn users by:

  a) setting the desired values, before setup_revisions(),
  b) checking after setup_revisions() whether these values differ from
     the desired values,
  c) if so throwing a warning and setting the desired values again.

We want the command to work from older commits to newer ones by default.
Also we don't want history simplification, as we want to deal with all
the commits in the affected range.

Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: introduce pick_regular_commit()
Elijah Newren [Fri, 24 Nov 2023 11:10:34 +0000 (12:10 +0100)] 
replay: introduce pick_regular_commit()

Let's refactor the code to handle a regular commit (a commit that is
neither a root commit nor a merge commit) into a single function instead
of keeping it inside cmd_replay().

This is good for separation of concerns, and this will help further work
in the future to replay merge commits.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: die() instead of failing assert()
Elijah Newren [Fri, 24 Nov 2023 11:10:33 +0000 (12:10 +0100)] 
replay: die() instead of failing assert()

It's not a good idea for regular Git commands to use an assert() to
check for things that could happen but are not supported.

Let's die() with an explanation of the issue instead.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: start using parse_options API
Elijah Newren [Fri, 24 Nov 2023 11:10:32 +0000 (12:10 +0100)] 
replay: start using parse_options API

Instead of manually parsing arguments, let's start using the parse_options
API. This way this new builtin will look more standard, and in some
upcoming commits will more easily be able to handle more command line
options.

Note that we plan to later use standard revision ranges instead of
hardcoded "<oldbase> <branch>" arguments. When we will use standard
revision ranges, it will be easier to check if there are no spurious
arguments if we keep ARGV[0], so let's call parse_options() with
PARSE_OPT_KEEP_ARGV0 even if we don't need ARGV[0] right now to avoid
some useless code churn.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreplay: introduce new builtin
Elijah Newren [Fri, 24 Nov 2023 11:10:31 +0000 (12:10 +0100)] 
replay: introduce new builtin

For now, this is just a rename from `t/helper/test-fast-rebase.c` into
`builtin/replay.c` with minimal changes to make it build appropriately.

Let's add a stub documentation and a stub test script though.

Subsequent commits will flesh out the capabilities of the new command
and make it a more standard regular builtin.

Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot6429: remove switching aspects of fast-rebase
Elijah Newren [Fri, 24 Nov 2023 11:10:30 +0000 (12:10 +0100)] 
t6429: remove switching aspects of fast-rebase

At the time t6429 was written, merge-ort was still under development,
did not have quite as many tests, and certainly was not widely deployed.
Since t6429 was exercising some codepaths just a little differently, we
thought having them also test the "merge_switch_to_result()" bits of
merge-ort was useful even though they weren't intrinsic to the real
point of these tests.

However, the value provided by doing extra testing of the
"merge_switch_to_result()" bits has decreased a bit over time, and it's
actively making it harder to refactor `test-tool fast-rebase` into `git
replay`, which we are going to do in following commits.  Dispense with
these bits.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agocommit-graph: disable GIT_COMMIT_GRAPH_PARANOIA by default
Patrick Steinhardt [Fri, 24 Nov 2023 11:08:21 +0000 (12:08 +0100)] 
commit-graph: disable GIT_COMMIT_GRAPH_PARANOIA by default

In 7a5d604443 (commit: detect commits that exist in commit-graph but not
in the ODB, 2023-10-31), we have introduced a new object existence check
into `repo_parse_commit_internal()` so that we do not parse commits via
the commit-graph that don't have a corresponding object in the object
database. This new check of course comes with a performance penalty,
which the commit put at around 30% for `git rev-list --topo-order`. But
there are in fact scenarios where the performance regression is even
higher. The following benchmark against linux.git with a fully-build
commit-graph:

  Benchmark 1: git.v2.42.1 rev-list --count HEAD
    Time (mean ± σ):     658.0 ms ±   5.2 ms    [User: 613.5 ms, System: 44.4 ms]
    Range (min … max):   650.2 ms … 666.0 ms    10 runs

  Benchmark 2: git.v2.43.0-rc1 rev-list --count HEAD
    Time (mean ± σ):      1.333 s ±  0.019 s    [User: 1.263 s, System: 0.069 s]
    Range (min … max):    1.302 s …  1.361 s    10 runs

  Summary
    git.v2.42.1 rev-list --count HEAD ran
      2.03 ± 0.03 times faster than git.v2.43.0-rc1 rev-list --count HEAD

While it's a noble goal to ensure that results are the same regardless
of whether or not we have a potentially stale commit-graph, taking twice
as much time is a tough sell. Furthermore, we can generally assume that
the commit-graph will be updated by git-gc(1) or git-maintenance(1) as
required so that the case where the commit-graph is stale should not at
all be common.

With that in mind, default-disable GIT_COMMIT_GRAPH_PARANOIA and restore
the behaviour and thus performance previous to the mentioned commit. In
order to not be inconsistent, also disable this behaviour by default in
`lookup_commit_in_graph()`, where the object existence check has been
introduced right at its inception via f559d6d45e (revision: avoid
hitting packfiles when commits are in commit-graph, 2021-08-09).

This results in another speedup in commands that end up calling this
function, even though it's less pronounced compared to the above
benchmark. The following has been executed in linux.git with ~1.2
million references:

  Benchmark 1: GIT_COMMIT_GRAPH_PARANOIA=true git rev-list --all --no-walk=unsorted
    Time (mean ± σ):      2.947 s ±  0.003 s    [User: 2.412 s, System: 0.534 s]
    Range (min … max):    2.943 s …  2.949 s    3 runs

  Benchmark 2: GIT_COMMIT_GRAPH_PARANOIA=false git rev-list --all --no-walk=unsorted
    Time (mean ± σ):      2.724 s ±  0.030 s    [User: 2.207 s, System: 0.514 s]
    Range (min … max):    2.704 s …  2.759 s    3 runs

  Summary
    GIT_COMMIT_GRAPH_PARANOIA=false git rev-list --all --no-walk=unsorted ran
      1.08 ± 0.01 times faster than GIT_COMMIT_GRAPH_PARANOIA=true git rev-list --all --no-walk=unsorted

So whereas 7a5d604443 initially introduced the logic to start doing an
object existence check in `repo_parse_commit_internal()` by default, the
updated logic will now instead cause `lookup_commit_in_graph()` to stop
doing the check by default. This behaviour continues to be tweakable by
the user via the GIT_COMMIT_GRAPH_PARANOIA environment variable.

Note that this requires us to amend some tests to manually turn on the
paranoid checks again. This is because we cause repository corruption by
manually deleting objects which are part of the commit graph already.
These circumstances shouldn't usually happen in repositories.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agodoc: refer to internet archive
Josh Soref [Fri, 24 Nov 2023 03:35:15 +0000 (03:35 +0000)] 
doc: refer to internet archive

These pages are no longer reachable from their original locations,
which makes things difficult for readers. Instead, switch to linking to
the Internet Archive for the content.

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agodoc: update links for andre-simon.de
Josh Soref [Fri, 24 Nov 2023 03:35:14 +0000 (03:35 +0000)] 
doc: update links for andre-simon.de

Beyond the fact that it's somewhat traditional to respect sites'
self-identification, it's helpful for links to point to the things
that people expect them to reference. Here that means linking to
specific pages instead of a domain.

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agodoc: switch links to https
Josh Soref [Fri, 24 Nov 2023 03:35:13 +0000 (03:35 +0000)] 
doc: switch links to https

These sites offer https versions of their content.
Using the https versions provides some protection for users.

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agodoc: update links to current pages
Josh Soref [Fri, 24 Nov 2023 03:35:12 +0000 (03:35 +0000)] 
doc: update links to current pages

It's somewhat traditional to respect sites' self-identification.

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agobuiltin/reflog.c: fix dry-run option short name
Josh Brobst [Sun, 26 Nov 2023 00:05:14 +0000 (19:05 -0500)] 
builtin/reflog.c: fix dry-run option short name

The documentation for reflog states that the --dry-run option of the
expire and delete subcommands has a corresponding short name, -n.
However, 33d7bdd645 (builtin/reflog.c: use parse-options api for expire,
delete subcommands, 2022-01-06) did not include this short name in the
new options parsing.

Re-add the short name in the new dry-run option definitions.

Signed-off-by: Josh Brobst <josh@brob.st>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot0212: test URL redacting in EVENT format
Jeff Hostetler [Wed, 22 Nov 2023 19:18:37 +0000 (19:18 +0000)] 
t0212: test URL redacting in EVENT format

In the added tests cases, skip testing the `GIT_TRACE2_REDACT=0` case
because we would need to exactly model the full JSON event stream like
we did in the preceding basic tests and I do not think it is worth it.

Furthermore, the Trace2 routines print the same content in normal, perf,
or event format, and in t0210 and t0211 we already tested the basic
functionality, so no need to repeat it here.

In this test, we use the test-helper to unit test each of the event
messages where URLs can appear and confirm that they are redacted in
each event.

Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot0211: test URL redacting in PERF format
Jeff Hostetler [Wed, 22 Nov 2023 19:18:36 +0000 (19:18 +0000)] 
t0211: test URL redacting in PERF format

This transmogrifies the test case that was just added to t0210, to also
cover the `GIT_TRACE2_PERF` backend.

Just like t0211, we now have to toggle the `TEST_PASSES_SANITIZE_LEAK`
annotation.

Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agotrace2: redact passwords from https:// URLs by default
Johannes Schindelin [Wed, 22 Nov 2023 19:18:35 +0000 (19:18 +0000)] 
trace2: redact passwords from https:// URLs by default

It is an unsafe practice to call something like

git clone https://user:password@example.com/

This not only risks leaking the password "over the shoulder" or into the
readline history of the current Unix shell, it also gets logged via
Trace2 if enabled.

Let's at least avoid logging such secrets via Trace2, much like we avoid
logging secrets in `http.c`. Much like the code in `http.c` is guarded
via `GIT_TRACE_REDACT` (defaulting to `true`), we guard the new code via
`GIT_TRACE2_REDACT` (also defaulting to `true`).

The new tests added in this commit uncover leaks in `builtin/clone.c`
and `remote.c`. Therefore we need to turn off
`TEST_PASSES_SANITIZE_LEAK`. The reasons:

- We observed that `the_repository->remote_status` is not released
  properly.

- We are using `url...insteadOf` and that runs into a code path where an
  allocated URL is replaced with another URL, and the original URL is
  never released.

- `remote_states` contains plenty of `struct remote`s whose refspecs
  seem to be usually allocated by never released.

More investigation is needed here to identify the exact cause and
proper fixes for these leaks/bugs.

Co-authored-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agotrace2: fix signature of trace2_def_param() macro
Jeff Hostetler [Wed, 22 Nov 2023 19:18:34 +0000 (19:18 +0000)] 
trace2: fix signature of trace2_def_param() macro

Add `struct key_value_info` argument to `trace2_def_param()`.

In dc90208497 (trace2: plumb config kvi, 2023-06-28) a `kvi`
argument was added to `trace2_def_param_fl()` but the macro
was not up updated. Let's fix that.

Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agomerge-file: add --diff-algorithm option
Antonin Delpeuch [Mon, 20 Nov 2023 19:18:52 +0000 (19:18 +0000)] 
merge-file: add --diff-algorithm option

Make it possible to use other diff algorithms than the 'myers'
default algorithm, when using the 'git merge-file' command, to help
avoid spurious conflicts by selecting a more recent algorithm such
as 'histogram', for instance when using 'git merge-file' as part of
a custom merge driver.

Signed-off-by: Antonin Delpeuch <antonin@delpeuch.eu>
Reviewed-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoGit 2.43 v2.43.0
Junio C Hamano [Sun, 19 Nov 2023 23:47:38 +0000 (08:47 +0900)] 
Git 2.43

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMerge tag 'l10n-2.43.0-rnd2' of https://github.com/git-l10n/git-po
Junio C Hamano [Mon, 20 Nov 2023 01:27:33 +0000 (10:27 +0900)] 
Merge tag 'l10n-2.43.0-rnd2' of https://github.com/git-l10n/git-po

l10n-2.43.0-rnd2

* tag 'l10n-2.43.0-rnd2' of https://github.com/git-l10n/git-po:
  l10n: zh-TW: Git 2.43.0-rc1
  l10n: Update German translation
  l10n: bg.po: Updated Bulgarian translation (5579t)
  l10n: zh_CN: for git 2.43.0-rc1
  l10n: Update Catalan translation
  l10n: po-id for 2.43 (round 1)
  l10n: fr: v2.43.0 rnd 2
  l10n: update uk localization for v2.43
  l10n: sv.po: Update Swedish translation (5579t)
  l10n: tr: v2.43.0

10 months agoMerge branch 'vd/glossary-dereference-peel'
Junio C Hamano [Mon, 20 Nov 2023 00:57:23 +0000 (09:57 +0900)] 
Merge branch 'vd/glossary-dereference-peel'

"To dereference" and "to peel" were sometimes used in in-code
comments and documentation but without description in the glossary.

* vd/glossary-dereference-peel:
  glossary: add definitions for dereference & peel

10 months agoMerge branch 'tz/send-email-helpfix'
Junio C Hamano [Mon, 20 Nov 2023 00:57:22 +0000 (09:57 +0900)] 
Merge branch 'tz/send-email-helpfix'

Typoes in "git send-email -h" have been corrected.

* tz/send-email-helpfix:
  send-email: remove stray characters from usage

10 months agoMerge branch 'l10n/zh-TW/2023-11-19' of github.com:l10n-tw/git-po
Jiang Xin [Sun, 19 Nov 2023 23:57:09 +0000 (07:57 +0800)] 
Merge branch 'l10n/zh-TW/2023-11-19' of github.com:l10n-tw/git-po

* 'l10n/zh-TW/2023-11-19' of github.com:l10n-tw/git-po:
  l10n: zh-TW: Git 2.43.0-rc1

10 months agofuzz: add new oss-fuzz fuzzer for date.c / date.h
Arthur Chan [Fri, 17 Nov 2023 17:47:47 +0000 (17:47 +0000)] 
fuzz: add new oss-fuzz fuzzer for date.c / date.h

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agopackfile.c: fix a typo in `each_file_in_pack_dir_fn()`'s declaration
Johannes Schindelin [Fri, 17 Nov 2023 13:15:15 +0000 (13:15 +0000)] 
packfile.c: fix a typo in `each_file_in_pack_dir_fn()`'s declaration

One parameter is called `file_pach`. On the face of it, this looks as if
it was supposed to talk about a `path` instead of a `pach`.

However, looking at the way this callback is called, it gets fed the
`d_name` from a directory entry, which provides just the file name, not
the full path. Therefore, let's fix this by calling the parameter
`file_name` instead.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agol10n: zh-TW: Git 2.43.0-rc1
Yi-Jyun Pan [Sun, 19 Nov 2023 15:35:21 +0000 (23:35 +0800)] 
l10n: zh-TW: Git 2.43.0-rc1

Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
10 months agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Sun, 19 Nov 2023 12:56:21 +0000 (20:56 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (5579t)

10 months agol10n: Update German translation
Ralf Thielow [Thu, 9 Nov 2023 10:31:01 +0000 (11:31 +0100)] 
l10n: Update German translation

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
10 months agol10n: bg.po: Updated Bulgarian translation (5579t)
Alexander Shopov [Sat, 5 Aug 2023 16:10:45 +0000 (19:10 +0300)] 
l10n: bg.po: Updated Bulgarian translation (5579t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
10 months agol10n: zh_CN: for git 2.43.0-rc1
Teng Long [Fri, 10 Nov 2023 09:17:29 +0000 (17:17 +0800)] 
l10n: zh_CN: for git 2.43.0-rc1

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
10 months agoMerge branch '2.43-uk-update' of github.com:arkid15r
Jiang Xin [Sat, 18 Nov 2023 02:51:56 +0000 (10:51 +0800)] 
Merge branch '2.43-uk-update' of github.com:arkid15r

* '2.43-uk-update' of github.com:arkid15r/git-ukrainian-l10n:
  l10n: update uk localization for v2.43

10 months agoMerge branch 'catalan' of github.com:Softcatala/git-po
Jiang Xin [Sat, 18 Nov 2023 02:48:39 +0000 (10:48 +0800)] 
Merge branch 'catalan' of github.com:Softcatala/git-po

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

10 months agoMerge branch 'tr-l10n' of github.com:bitigchi/git-po
Jiang Xin [Sat, 18 Nov 2023 02:45:56 +0000 (10:45 +0800)] 
Merge branch 'tr-l10n' of github.com:bitigchi/git-po

* 'tr-l10n' of github.com:bitigchi/git-po:
  l10n: tr: v2.43.0

10 months agoMerge branch 'fr_v2.43.0' of github.com:jnavila/git
Jiang Xin [Sat, 18 Nov 2023 02:43:22 +0000 (10:43 +0800)] 
Merge branch 'fr_v2.43.0' of github.com:jnavila/git

* 'fr_v2.43.0' of github.com:jnavila/git:
  l10n: fr: v2.43.0 rnd 2

10 months agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Sat, 18 Nov 2023 02:42:48 +0000 (10:42 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: po-id for 2.43 (round 1)