]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
8 months agoThe sixth batch
Junio C Hamano [Mon, 8 Jan 2024 22:05:24 +0000 (14:05 -0800)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'rs/mem-pool-improvements'
Junio C Hamano [Mon, 8 Jan 2024 22:05:16 +0000 (14:05 -0800)] 
Merge branch 'rs/mem-pool-improvements'

MemPool allocator fixes.

* rs/mem-pool-improvements:
  mem-pool: simplify alignment calculation
  mem-pool: fix big allocations

8 months agoMerge branch 'rs/fast-import-simplify-mempool-allocation'
Junio C Hamano [Mon, 8 Jan 2024 22:05:16 +0000 (14:05 -0800)] 
Merge branch 'rs/fast-import-simplify-mempool-allocation'

Code simplification.

* rs/fast-import-simplify-mempool-allocation:
  fast-import: use mem_pool_calloc()

8 months agoMerge branch 'en/sparse-checkout-eoo'
Junio C Hamano [Mon, 8 Jan 2024 22:05:16 +0000 (14:05 -0800)] 
Merge branch 'en/sparse-checkout-eoo'

"git sparse-checkout (add|set) --[no-]cone --end-of-options" did
not handle "--end-of-options" correctly after a recent update.

* en/sparse-checkout-eoo:
  sparse-checkout: be consistent with end of options markers

8 months agoMerge branch 'jc/sparse-checkout-set-default-fix'
Junio C Hamano [Mon, 8 Jan 2024 22:05:16 +0000 (14:05 -0800)] 
Merge branch 'jc/sparse-checkout-set-default-fix'

"git sparse-checkout set" added default patterns even when the
patterns are being fed from the standard input, which has been
corrected.

* jc/sparse-checkout-set-default-fix:
  sparse-checkout: use default patterns for 'set' only !stdin

8 months agoMerge branch 'en/header-cleanup'
Junio C Hamano [Mon, 8 Jan 2024 22:05:15 +0000 (14:05 -0800)] 
Merge branch 'en/header-cleanup'

Remove unused header "#include".

* en/header-cleanup:
  treewide: remove unnecessary includes in source files
  treewide: add direct includes currently only pulled in transitively
  trace2/tr2_tls.h: remove unnecessary include
  submodule-config.h: remove unnecessary include
  pkt-line.h: remove unnecessary include
  line-log.h: remove unnecessary include
  http.h: remove unnecessary include
  fsmonitor--daemon.h: remove unnecessary includes
  blame.h: remove unnecessary includes
  archive.h: remove unnecessary include
  treewide: remove unnecessary includes in source files
  treewide: remove unnecessary includes from header files

8 months agoMerge branch 'ml/doc-merge-updates'
Junio C Hamano [Mon, 8 Jan 2024 22:05:15 +0000 (14:05 -0800)] 
Merge branch 'ml/doc-merge-updates'

Doc update.

* ml/doc-merge-updates:
  Documentation/git-merge.txt: use backticks for command wrapping
  Documentation/git-merge.txt: fix reference to synopsis

8 months agoMerge branch 'jc/archive-list-with-extra-args'
Junio C Hamano [Mon, 8 Jan 2024 22:05:14 +0000 (14:05 -0800)] 
Merge branch 'jc/archive-list-with-extra-args'

"git archive --list extra garbage" silently ignored excess command
line parameters, which has been corrected.

* jc/archive-list-with-extra-args:
  archive: "--list" does not take further options

8 months agoThe fifth batch
Junio C Hamano [Tue, 2 Jan 2024 21:50:46 +0000 (13:50 -0800)] 
The fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'ps/pseudo-refs'
Junio C Hamano [Tue, 2 Jan 2024 21:51:30 +0000 (13:51 -0800)] 
Merge branch 'ps/pseudo-refs'

Assorted changes around pseudoref handling.

* ps/pseudo-refs:
  bisect: consistently write BISECT_EXPECTED_REV via the refdb
  refs: complete list of special refs
  refs: propagate errno when reading special refs fails
  wt-status: read HEAD and ORIG_HEAD via the refdb

8 months agoMerge branch 'jc/orphan-unborn'
Junio C Hamano [Tue, 2 Jan 2024 21:51:30 +0000 (13:51 -0800)] 
Merge branch 'jc/orphan-unborn'

Doc updates to clarify what an "unborn branch" means.

* jc/orphan-unborn:
  orphan/unborn: fix use of 'orphan' in end-user facing messages
  orphan/unborn: add to the glossary and use them consistently

8 months agoMerge branch 'rj/status-bisect-while-rebase'
Junio C Hamano [Tue, 2 Jan 2024 21:51:29 +0000 (13:51 -0800)] 
Merge branch 'rj/status-bisect-while-rebase'

"git status" is taught to show both the branch being bisected and
being rebased when both are in effect at the same time.

* rj/status-bisect-while-rebase:
  status: fix branch shown when not only bisecting

8 months agoMerge branch 'la/trailer-cleanups'
Junio C Hamano [Tue, 2 Jan 2024 21:51:29 +0000 (13:51 -0800)] 
Merge branch 'la/trailer-cleanups'

Code clean-up.

* la/trailer-cleanups:
  trailer: use offsets for trailer_start/trailer_end
  trailer: find the end of the log message
  commit: ignore_non_trailer computes number of bytes to ignore

8 months agoMerge branch 'jc/retire-cas-opt-name-constant'
Junio C Hamano [Tue, 2 Jan 2024 21:51:29 +0000 (13:51 -0800)] 
Merge branch 'jc/retire-cas-opt-name-constant'

Code clean-up.

* jc/retire-cas-opt-name-constant:
  remote.h: retire CAS_OPT_NAME

8 months agoMerge branch 'rs/rebase-use-strvec-pushf'
Junio C Hamano [Tue, 2 Jan 2024 21:51:29 +0000 (13:51 -0800)] 
Merge branch 'rs/rebase-use-strvec-pushf'

Code clean-up.

* rs/rebase-use-strvec-pushf:
  rebase: use strvec_pushf() for format-patch revisions

8 months agoMerge branch 'sh/completion-with-reftable'
Junio C Hamano [Tue, 2 Jan 2024 21:51:28 +0000 (13:51 -0800)] 
Merge branch 'sh/completion-with-reftable'

Command line completion script (in contrib/) learned to work better
with the reftable backend.

* sh/completion-with-reftable:
  completion: support pseudoref existence checks for reftables
  completion: refactor existence checks for pseudorefs

8 months agomem-pool: simplify alignment calculation
René Scharfe [Sun, 24 Dec 2023 17:02:04 +0000 (18:02 +0100)] 
mem-pool: simplify alignment calculation

Use DIV_ROUND_UP in mem_pool_alloc() to round the allocation length to
the next multiple of GIT_MAX_ALIGNMENT instead of twiddling bits
explicitly.  This is shorter and clearer, to the point that we no longer
need the comment that explains what's being calculated.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agomem-pool: fix big allocations
René Scharfe [Thu, 28 Dec 2023 19:19:06 +0000 (20:19 +0100)] 
mem-pool: fix big allocations

Memory pool allocations that require a new block and would fill at
least half of it are handled specially.  Before 158dfeff3d (mem-pool:
add life cycle management functions, 2018-07-02) they used to be
allocated outside of the pool.  This patch made mem_pool_alloc() create
a bespoke block instead, to allow releasing it when the pool gets
discarded.

Unfortunately mem_pool_alloc() returns a pointer to the start of such a
bespoke block, i.e. to the struct mp_block at its top.  When the caller
writes to it, the management information gets corrupted.  This affects
mem_pool_discard() and -- if there are no other blocks in the pool --
also mem_pool_alloc().

Return the payload pointer of bespoke blocks, just like for smaller
allocations, to protect the management struct.

Also update next_free to mark the block as full.  This is only strictly
necessary for the first allocated block, because subsequent ones are
inserted after the current block and never considered for further
allocations, but it's easier to just do it in all cases.

Add a basic unit test to demonstrate the issue by using
mem_pool_calloc() with a tiny block size, which forces the creation of a
bespoke block.

Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoThe fourth batch
Junio C Hamano [Wed, 27 Dec 2023 22:51:46 +0000 (14:51 -0800)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'ps/clone-into-reftable-repository'
Junio C Hamano [Wed, 27 Dec 2023 22:52:28 +0000 (14:52 -0800)] 
Merge branch 'ps/clone-into-reftable-repository'

"git clone" has been prepared to allow cloning a repository with
non-default hash function into a repository that uses the reftable
backend.

* ps/clone-into-reftable-repository:
  builtin/clone: create the refdb with the correct object format
  builtin/clone: skip reading HEAD when retrieving remote
  builtin/clone: set up sparse checkout later
  builtin/clone: fix bundle URIs with mismatching object formats
  remote-curl: rediscover repository when fetching refs
  setup: allow skipping creation of the refdb
  setup: extract function to create the refdb

8 months agoMerge branch 'rs/t6300-compressed-size-fix'
Junio C Hamano [Wed, 27 Dec 2023 22:52:27 +0000 (14:52 -0800)] 
Merge branch 'rs/t6300-compressed-size-fix'

Test fix.

* rs/t6300-compressed-size-fix:
  t6300: avoid hard-coding object sizes

8 months agoMerge branch 'jx/fetch-atomic-error-message-fix'
Junio C Hamano [Wed, 27 Dec 2023 22:52:27 +0000 (14:52 -0800)] 
Merge branch 'jx/fetch-atomic-error-message-fix'

"git fetch --atomic" issued an unnecessary empty error message,
which has been corrected.

* jx/fetch-atomic-error-message-fix:
  fetch: no redundant error message for atomic fetch
  t5574: test porcelain output of atomic fetch

8 months agoMerge branch 'rs/c99-stdbool-test-balloon'
Junio C Hamano [Wed, 27 Dec 2023 22:52:27 +0000 (14:52 -0800)] 
Merge branch 'rs/c99-stdbool-test-balloon'

Test balloon to use C99 "bool" type from <stdbool.h>.

* rs/c99-stdbool-test-balloon:
  git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool

8 months agoMerge branch 'sp/test-i18ngrep'
Junio C Hamano [Wed, 27 Dec 2023 22:52:27 +0000 (14:52 -0800)] 
Merge branch 'sp/test-i18ngrep'

Error message fix in the test framework.

* sp/test-i18ngrep:
  test-lib-functions.sh: fix test_grep fail message wording

8 months agoMerge branch 'jc/doc-misspelt-refs-fix'
Junio C Hamano [Wed, 27 Dec 2023 22:52:26 +0000 (14:52 -0800)] 
Merge branch 'jc/doc-misspelt-refs-fix'

Doc update.

* jc/doc-misspelt-refs-fix:
  doc: format.notes specify a ref under refs/notes/ hierarchy

8 months agoMerge branch 'jc/doc-most-refs-are-not-that-special'
Junio C Hamano [Wed, 27 Dec 2023 22:52:26 +0000 (14:52 -0800)] 
Merge branch 'jc/doc-most-refs-are-not-that-special'

Doc updates.

* jc/doc-most-refs-are-not-that-special:
  docs: MERGE_AUTOSTASH is not that special
  docs: AUTO_MERGE is not that special
  refs.h: HEAD is not that special
  git-bisect.txt: BISECT_HEAD is not that special
  git.txt: HEAD is not that special

8 months agoMerge branch 'es/add-doc-list-short-form-of-all-in-synopsis'
Junio C Hamano [Wed, 27 Dec 2023 22:52:26 +0000 (14:52 -0800)] 
Merge branch 'es/add-doc-list-short-form-of-all-in-synopsis'

Doc update.

* es/add-doc-list-short-form-of-all-in-synopsis:
  git-add.txt: add missing short option -A to synopsis

8 months agoMerge branch 'jk/mailinfo-iterative-unquote-comment'
Junio C Hamano [Wed, 27 Dec 2023 22:52:26 +0000 (14:52 -0800)] 
Merge branch 'jk/mailinfo-iterative-unquote-comment'

The code to parse the From e-mail header has been updated to avoid
recursion.

* jk/mailinfo-iterative-unquote-comment:
  mailinfo: avoid recursion when unquoting From headers
  t5100: make rfc822 comment test more careful

8 months agoMerge branch 'ps/chainlint-self-check-update'
Junio C Hamano [Wed, 27 Dec 2023 22:52:25 +0000 (14:52 -0800)] 
Merge branch 'ps/chainlint-self-check-update'

Test framework update.

* ps/chainlint-self-check-update:
  tests: adjust whitespace in chainlint expectations

8 months agoMerge branch 'rs/show-ref-incompatible-options'
Junio C Hamano [Wed, 27 Dec 2023 22:52:25 +0000 (14:52 -0800)] 
Merge branch 'rs/show-ref-incompatible-options'

Code clean-up for sanity checking of command line options for "git
show-ref".

* rs/show-ref-incompatible-options:
  show-ref: use die_for_incompatible_opt3()

8 months agoMerge branch 'ps/reftable-fixes'
Junio C Hamano [Wed, 27 Dec 2023 22:52:25 +0000 (14:52 -0800)] 
Merge branch 'ps/reftable-fixes'

Bunch of small fix-ups to the reftable code.

* ps/reftable-fixes:
  reftable/block: reuse buffer to compute record keys
  reftable/block: introduce macro to initialize `struct block_iter`
  reftable/merged: reuse buffer to compute record keys
  reftable/stack: fix use of unseeded randomness
  reftable/stack: fix stale lock when dying
  reftable/stack: reuse buffers when reloading stack
  reftable/stack: perform auto-compaction with transactional interface
  reftable/stack: verify that `reftable_stack_add()` uses auto-compaction
  reftable: handle interrupted writes
  reftable: handle interrupted reads
  reftable: wrap EXPECT macros in do/while

8 months agoMerge branch 'jc/diff-cached-fsmonitor-fix'
Junio C Hamano [Wed, 27 Dec 2023 22:52:25 +0000 (14:52 -0800)] 
Merge branch 'jc/diff-cached-fsmonitor-fix'

The optimization based on fsmonitor in the "diff --cached"
codepath is resurrected with the "fake-lstat" introduced earlier.

* jc/diff-cached-fsmonitor-fix:
  diff-lib: fix check_removed() when fsmonitor is active

8 months agoMerge branch 'jc/fake-lstat'
Junio C Hamano [Wed, 27 Dec 2023 22:52:24 +0000 (14:52 -0800)] 
Merge branch 'jc/fake-lstat'

A new helper to let us pretend that we called lstat() when we know
our cache_entry is up-to-date via fsmonitor.

* jc/fake-lstat:
  cache: add fake_lstat()

8 months agoMerge branch 'jk/mailinfo-oob-read-fix'
Junio C Hamano [Wed, 27 Dec 2023 22:52:24 +0000 (14:52 -0800)] 
Merge branch 'jk/mailinfo-oob-read-fix'

OOB read fix.

* jk/mailinfo-oob-read-fix:
  mailinfo: fix out-of-bounds memory reads in unquote_quoted_pair()

8 months agoMerge branch 'jc/checkout-B-branch-in-use'
Junio C Hamano [Wed, 27 Dec 2023 22:52:24 +0000 (14:52 -0800)] 
Merge branch 'jc/checkout-B-branch-in-use'

"git checkout -B <branch> [<start-point>]" allowed a branch that is
in use in another worktree to be updated and checked out, which
might be a bit unexpected.  The rule has been tightened, which is a
breaking change.  "--ignore-other-worktrees" option is required to
unbreak you, if you are used to the current behaviour that "-B"
overrides the safety.

* jc/checkout-B-branch-in-use:
  checkout: forbid "-B <branch>" from touching a branch used elsewhere
  checkout: refactor die_if_checked_out() caller

8 months agosparse-checkout: use default patterns for 'set' only !stdin
Junio C Hamano [Thu, 21 Dec 2023 06:59:24 +0000 (22:59 -0800)] 
sparse-checkout: use default patterns for 'set' only !stdin

"git sparse-checkout set ---no-cone" uses default patterns when none
is given from the command line, but it should do so ONLY when
--stdin is not being used.  Right now, add_patterns_from_input()
called when reading from the standard input is sloppy and does not
check if there are extra command line parameters that the command
will silently ignore, but that will change soon and not setting this
unnecessary and unused default patterns start to matter when it gets
fixed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosparse-checkout: be consistent with end of options markers
Elijah Newren [Tue, 26 Dec 2023 19:39:22 +0000 (19:39 +0000)] 
sparse-checkout: be consistent with end of options markers

93851746 (parse-options: decouple "--end-of-options" and "--",
2023-12-06) updated the world order to make callers of parse-options
that set PARSE_OPT_KEEP_UNKNOWN_OPT responsible for deciding what to
do with "--end-of-options" they may see after parse_options() returns.

This made a previous bug in sparse-checkout more visible; namely,
that

  git sparse-checkout [add|set] --[no-]cone --end-of-options ...

would simply treat "--end-of-options" as one of the paths to include in
the sparse-checkout.  But this was already problematic before; namely,

  git sparse-checkout [add|set| --[no-]cone --sikp-checks ...

would not give an error on the mis-typed "--skip-checks" but instead
simply treat "--sikp-checks" as a path or pattern to include in the
sparse-checkout, which is highly unfriendly.

This behavior began when the command was converted to parse-options in
7bffca95ea (sparse-checkout: add '--stdin' option to set subcommand,
2019-11-21).  Back then it was just called KEEP_UNKNOWN. Later it was
renamed to KEEP_UNKNOWN_OPT in 99d86d60e5 (parse-options:
PARSE_OPT_KEEP_UNKNOWN only applies to --options, 2022-08-19) to clarify
that it was only about dashed options; we always keep non-option
arguments.  Looking at that original patch, both Peff and I think that
the author was simply confused about the mis-named option, and really
just wanted to keep the non-option arguments.  We never should have used
the flag all along (and the other cases were cargo-culted within the
file).

Remove the erroneous PARSE_OPT_KEEP_UNKNOWN_OPT flag now to fix this
bug.  Note that this does mean that anyone who might have been using

  git sparse-checkout [add|set] [--[no-]cone] --foo --bar

to request paths or patterns '--foo' and '--bar' will now have to use

  git sparse-checkout [add|set] [--[no-]cone] -- --foo --bar

That makes sparse-checkout more consistent with other git commands,
provides users much friendlier error messages and behavior, and is
consistent with the all-caps warning in git-sparse-checkout.txt that
this command "is experimental...its behavior...will likely change".  :-)

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotreewide: remove unnecessary includes in source files
Elijah Newren [Sat, 23 Dec 2023 17:15:00 +0000 (17:15 +0000)] 
treewide: remove unnecessary includes in source files

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotreewide: add direct includes currently only pulled in transitively
Elijah Newren [Sat, 23 Dec 2023 17:14:59 +0000 (17:14 +0000)] 
treewide: add direct includes currently only pulled in transitively

The next commit will remove a bunch of unnecessary includes, but to do
so, we need some of the lower level direct includes that files rely on
to be explicitly specified.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotrace2/tr2_tls.h: remove unnecessary include
Elijah Newren [Sat, 23 Dec 2023 17:14:58 +0000 (17:14 +0000)] 
trace2/tr2_tls.h: remove unnecessary include

The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosubmodule-config.h: remove unnecessary include
Elijah Newren [Sat, 23 Dec 2023 17:14:57 +0000 (17:14 +0000)] 
submodule-config.h: remove unnecessary include

The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agopkt-line.h: remove unnecessary include
Elijah Newren [Sat, 23 Dec 2023 17:14:56 +0000 (17:14 +0000)] 
pkt-line.h: remove unnecessary include

The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoline-log.h: remove unnecessary include
Elijah Newren [Sat, 23 Dec 2023 17:14:55 +0000 (17:14 +0000)] 
line-log.h: remove unnecessary include

The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agohttp.h: remove unnecessary include
Elijah Newren [Sat, 23 Dec 2023 17:14:54 +0000 (17:14 +0000)] 
http.h: remove unnecessary include

The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofsmonitor--daemon.h: remove unnecessary includes
Elijah Newren [Sat, 23 Dec 2023 17:14:53 +0000 (17:14 +0000)] 
fsmonitor--daemon.h: remove unnecessary includes

The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoblame.h: remove unnecessary includes
Elijah Newren [Sat, 23 Dec 2023 17:14:52 +0000 (17:14 +0000)] 
blame.h: remove unnecessary includes

The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoarchive.h: remove unnecessary include
Elijah Newren [Sat, 23 Dec 2023 17:14:51 +0000 (17:14 +0000)] 
archive.h: remove unnecessary include

The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotreewide: remove unnecessary includes in source files
Elijah Newren [Sat, 23 Dec 2023 17:14:50 +0000 (17:14 +0000)] 
treewide: remove unnecessary includes in source files

Each of these were checked with
   gcc -E -I. ${SOURCE_FILE} | grep ${HEADER_FILE}
to ensure that removing the direct inclusion of the header actually
resulted in that header no longer being included at all (i.e. that
no other header pulled it in transitively).

...except for a few cases where we verified that although the header
was brought in transitively, nothing from it was directly used in
that source file.  These cases were:
  * builtin/credential-cache.c
  * builtin/pull.c
  * builtin/send-pack.c

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotreewide: remove unnecessary includes from header files
Elijah Newren [Sat, 23 Dec 2023 17:14:49 +0000 (17:14 +0000)] 
treewide: remove unnecessary includes from header files

There are three kinds of unnecessary includes:
  * includes which aren't directly needed, but which include some other
    forgotten include
  * includes which could be replaced by a simple forward declaration of
    some structs
  * includes which aren't needed at all

Remove the third kind of include.  Subsequent commits (and a subsequent
series) will work on removing some of the other kinds of includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofast-import: use mem_pool_calloc()
René Scharfe [Tue, 26 Dec 2023 08:17:45 +0000 (09:17 +0100)] 
fast-import: use mem_pool_calloc()

Use mem_pool_calloc() to get a zeroed buffer instead of zeroing it
ourselves.  This makes the code clearer and less repetitive.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoarchive: "--list" does not take further options
Junio C Hamano [Thu, 21 Dec 2023 18:13:58 +0000 (10:13 -0800)] 
archive: "--list" does not take further options

"git archive --list blah" should notice an extra command line
parameter that goes unused.  Make it so.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jk/end-of-options' into jc/sparse-checkout-set-add-end-of-options
Junio C Hamano [Thu, 21 Dec 2023 05:49:33 +0000 (21:49 -0800)] 
Merge branch 'jk/end-of-options' into jc/sparse-checkout-set-add-end-of-options

* jk/end-of-options:
  parse-options: decouple "--end-of-options" and "--"

9 months agoDocumentation/git-merge.txt: use backticks for command wrapping
Michael Lohmann [Wed, 20 Dec 2023 19:53:42 +0000 (20:53 +0100)] 
Documentation/git-merge.txt: use backticks for command wrapping

As René found in the guidance from CodingGuidelines:

   Literal examples (e.g. use of command-line options, command names,
   branch names, URLs, pathnames (files and directories), configuration
   and environment variables) must be typeset in monospace (i.e. wrapped
   with backticks)

So all instances of single and double quotes for wraping said examples
were replaced with simple backticks.

Suggested-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Michael Lohmann <mi.al.lohmann@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoDocumentation/git-merge.txt: fix reference to synopsis
Michael Lohmann [Wed, 20 Dec 2023 21:35:34 +0000 (22:35 +0100)] 
Documentation/git-merge.txt: fix reference to synopsis

437591a9d738 combined the synopsis of "The second syntax" (meaning `git
merge --abort`) and "The third syntax" (for `git merge --continue`) into
this single line:

       git merge (--continue | --abort | --quit)

but it was still referred to when describing the preconditions that have
to be fulfilled to run the respective actions. In other words:
References by number are no longer valid after a merge of some of the
synopses.

Also the previous version of the documentation did not acknowledge that
`--no-commit` would result in the precondition being fulfilled (thanks
to Elijah Newren and Junio C Hamano for pointing that out).

This change also groups `--abort` and `--continue` together when
explaining the prerequisites in order to avoid duplication.

Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Michael Lohmann <mi.al.lohmann@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agotrailer: use offsets for trailer_start/trailer_end
Linus Arver [Fri, 20 Oct 2023 19:01:35 +0000 (19:01 +0000)] 
trailer: use offsets for trailer_start/trailer_end

Previously these fields in the trailer_info struct were of type "const
char *" and pointed to positions in the input string directly (to the
start and end positions of the trailer block).

Use offsets to make the intended usage less ambiguous. We only need to
reference the input string in format_trailer_info(), so update that
function to take a pointer to the input.

While we're at it, rename trailer_start to trailer_block_start to be
more explicit about these offsets (that they are for the entire trailer
block including other trailers). Ditto for trailer_end.

Reported-by: Glen Choo <glencbz@gmail.com>
Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agotrailer: find the end of the log message
Linus Arver [Fri, 20 Oct 2023 19:01:34 +0000 (19:01 +0000)] 
trailer: find the end of the log message

Previously, trailer_info_get() computed the trailer block end position
by

(1) checking for the opts->no_divider flag and optionally calling
    find_patch_start() to find the "patch start" location (patch_start), and
(2) calling find_trailer_end() to find the end of the trailer block
    using patch_start as a guide, saving the return value into
    "trailer_end".

The logic in (1) was awkward because the variable "patch_start" is
misleading if there is no patch in the input. The logic in (2) was
misleading because it could be the case that no trailers are in the
input (yet we are setting a "trailer_end" variable before even searching
for trailers, which happens later in find_trailer_start()). The name
"find_trailer_end" was misleading because that function did not look for
any trailer block itself --- instead it just computed the end position
of the log message in the input where the end of the trailer block (if
it exists) would be (because trailer blocks must always come after the
end of the log message).

Combine the logic in (1) and (2) together into find_patch_start() by
renaming it to find_end_of_log_message(). The end of the log message is
the starting point which find_trailer_start() needs to start searching
backward to parse individual trailers (if any).

Helped-by: Jonathan Tan <jonathantanmy@google.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoThe third batch
Junio C Hamano [Wed, 20 Dec 2023 18:15:09 +0000 (10:15 -0800)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jk/config-cleanup'
Junio C Hamano [Wed, 20 Dec 2023 18:14:54 +0000 (10:14 -0800)] 
Merge branch 'jk/config-cleanup'

Code clean-up around use of configuration variables.

* jk/config-cleanup:
  sequencer: simplify away extra git_config_string() call
  gpg-interface: drop pointless config_error_nonbool() checks
  push: drop confusing configset/callback redundancy
  config: use git_config_string() for core.checkRoundTripEncoding
  diff: give more detailed messages for bogus diff.* config
  config: use config_error_nonbool() instead of custom messages
  imap-send: don't use git_die_config() inside callback
  git_xmerge_config(): prefer error() to die()
  config: reject bogus values for core.checkstat

9 months agoMerge branch 'jk/implicit-true'
Junio C Hamano [Wed, 20 Dec 2023 18:14:54 +0000 (10:14 -0800)] 
Merge branch 'jk/implicit-true'

Some codepaths did not correctly parse configuration variables
specified with valueless "true", which has been corrected.

* jk/implicit-true:
  fsck: handle NULL value when parsing message config
  trailer: handle NULL value when parsing trailer-specific config
  submodule: handle NULL value when parsing submodule.*.branch
  help: handle NULL value for alias.* config
  trace2: handle NULL values in tr2_sysenv config callback
  setup: handle NULL value when parsing extensions
  config: handle NULL value when parsing non-bools

9 months agoMerge branch 'jk/bisect-reset-fix'
Junio C Hamano [Wed, 20 Dec 2023 18:14:54 +0000 (10:14 -0800)] 
Merge branch 'jk/bisect-reset-fix'

"git bisect reset" has been taught to clean up state files and refs
even when BISECT_START file is gone.

* jk/bisect-reset-fix:
  bisect: always clean on reset

9 months agoMerge branch 'jk/end-of-options'
Junio C Hamano [Wed, 20 Dec 2023 18:14:54 +0000 (10:14 -0800)] 
Merge branch 'jk/end-of-options'

"git $cmd --end-of-options --rev -- --path" for some $cmd failed
to interpret "--rev" as a rev, and "--path" as a path.  This was
fixed for many programs like "reset" and "checkout".

* jk/end-of-options:
  parse-options: decouple "--end-of-options" and "--"

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 agorebase: use strvec_pushf() for format-patch revisions
René Scharfe [Tue, 19 Dec 2023 07:42:18 +0000 (08:42 +0100)] 
rebase: use strvec_pushf() for format-patch revisions

In run_am(), a strbuf is used to create a revision argument that is then
added to the argument list for git format-patch using strvec_push().
Use strvec_pushf() to add it directly instead, simplifying the code
and plugging a small leak on the error code path.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompletion: support pseudoref existence checks for reftables
Stan Hu [Tue, 19 Dec 2023 22:14:18 +0000 (14:14 -0800)] 
completion: support pseudoref existence checks for reftables

In contrib/completion/git-completion.bash, there are a bunch of
instances where we read pseudorefs, such as HEAD, MERGE_HEAD,
REVERT_HEAD, and others via the filesystem. However, the upcoming
reftable refs backend won't use '.git/HEAD' at all but instead will
write an invalid refname as placeholder for backwards compatibility,
which will break the git-completion script.

Update the '__git_pseudoref_exists' function to:

1. Recognize the placeholder '.git/HEAD' written by the reftable
   backend (its content is specified in the reftable specs).
2. If reftable is in use, use 'git rev-parse' to determine whether the
    given ref exists.
3. Otherwise, continue to use 'test -f' to check for the ref's filename.

Signed-off-by: Stan Hu <stanhu@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompletion: refactor existence checks for pseudorefs
Stan Hu [Tue, 19 Dec 2023 22:14:17 +0000 (14:14 -0800)] 
completion: refactor existence checks for pseudorefs

In preparation for the reftable backend, this commit introduces a
'__git_pseudoref_exists' function that continues to use 'test -f' to
determine whether a given pseudoref exists in the local filesystem.

Signed-off-by: Stan Hu <stanhu@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoremote.h: retire CAS_OPT_NAME
Junio C Hamano [Tue, 19 Dec 2023 19:26:25 +0000 (11:26 -0800)] 
remote.h: retire CAS_OPT_NAME

When the "--force-with-lease" option was introduced in 28f5d176
(remote.c: add command line option parser for "--force-with-lease",
2013-07-08), the design discussion revolved around the concept of
"compare-and-swap", and it can still be seen in the name used for
variables and helper functions.  The end-user facing option name
ended up to be a bit different, so during the development iteration
of the feature, we used this C preprocessor macro to make it easier
to rename it later.

All of that happened more than 10 years ago, and the flexibility
afforded by the CAS_OPT_NAME macro outlived its usefulness.  Inline
the constant string for the option name, like all other option names
in the code.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 agodoc: format.notes specify a ref under refs/notes/ hierarchy
Junio C Hamano [Fri, 15 Dec 2023 22:28:00 +0000 (14:28 -0800)] 
doc: format.notes specify a ref under refs/notes/ hierarchy

There is no 'ref/notes/' hierarchy.  '[format] notes = foo' uses notes
that are found in 'refs/notes/foo'.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agotest-lib-functions.sh: fix test_grep fail message wording
Shreyansh Paliwal [Sun, 3 Dec 2023 17:17:59 +0000 (22:47 +0530)] 
test-lib-functions.sh: fix test_grep fail message wording

In the recent commit 2e87fca189 (test framework: further deprecate
test_i18ngrep, 2023-10-31), the test_i18ngrep function was
deprecated, and all the callers were updated to call the test_grep
function instead.  But test_grep inherited an error message that
still refers to test_i18ngrep by mistake.  Correct it so that a
broken call to the test_grep will identify itself as such.

Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogit-compat-util: convert skip_{prefix,suffix}{,_mem} to bool
René Scharfe [Sat, 16 Dec 2023 10:47:21 +0000 (11:47 +0100)] 
git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool

Use the data type bool and its values true and false to document the
binary return value of skip_prefix() and friends more explicitly.

This first use of stdbool.h, introduced with C99, is meant to check
whether there are platforms that claim support for C99, as tested by
7bc341e21b (git-compat-util: add a test balloon for C99 support,
2021-12-01), but still lack that header for some reason.

A fallback based on a wider type, e.g. int, would have to deal with
comparisons somehow to emulate that any non-zero value is true:

   bool b1 = 1;
   bool b2 = 2;
   if (b1 == b2) puts("This is true.");

   int i1 = 1;
   int i2 = 2;
   if (i1 == i2) puts("Not printed.");
   #define BOOLEQ(a, b) (!(a) == !(b))
   if (BOOLEQ(i1, i2)) puts("This is true.");

So we'd be better off using bool everywhere without a fallback, if
possible.  That's why this patch doesn't include any.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agofetch: no redundant error message for atomic fetch
Jiang Xin [Sun, 17 Dec 2023 14:11:34 +0000 (22:11 +0800)] 
fetch: no redundant error message for atomic fetch

If an error occurs during an atomic fetch, a redundant error message
will appear at the end of do_fetch(). It was introduced in b3a804663c
(fetch: make `--atomic` flag cover backfilling of tags, 2022-02-17).

Because a failure message is displayed before setting retcode in the
function do_fetch(), calling error() on the err message at the end of
this function may result in redundant or empty error message to be
displayed.

We can remove the redundant error() function, because we know that
the function ref_transaction_abort() never fails. While we can find a
common pattern for calling ref_transaction_abort() by running command
"git grep -A1 ref_transaction_abort", e.g.:

    if (ref_transaction_abort(transaction, &error))
        error("abort: %s", error.buf);

Following this pattern, we can tolerate the return value of the function
ref_transaction_abort() being changed in the future. We also delay the
output of the err message to the end of do_fetch() to reduce redundant
code. With these changes, the test case "fetch porcelain output
(atomic)" in t5574 will also be fixed.

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot5574: test porcelain output of atomic fetch
Jiang Xin [Sun, 17 Dec 2023 14:11:33 +0000 (22:11 +0800)] 
t5574: test porcelain output of atomic fetch

The test case "fetch porcelain output" checks output of the fetch
command. The error output must be empty with the follow assertion:

    test_must_be_empty stderr

But this assertion fails if using atomic fetch. Refactor this test case
to use different fetch options by splitting it into three test cases.

  1. "setup for fetch porcelain output".

  2. "fetch porcelain output": for non-atomic fetch.

  3. "fetch porcelain output (atomic)": for atomic fetch.

Add new command "test_commit ..." in the first test case, so that if we
run these test cases individually (--run=4-6), "git rev-parse HEAD~"
command will work properly. Run the above test cases, we can find that
one test case has a known breakage, as shown below:

    ok 4 - setup for fetch porcelain output
    ok 5 - fetch porcelain output  # TODO known breakage vanished
    not ok 6 - fetch porcelain output (atomic) # TODO known breakage

The failed test case has an error message with only the error prompt but
no message body, as follows:

    'stderr' is not empty, it contains:
    error:

In a later commit, we will fix this issue.

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agodocs: MERGE_AUTOSTASH is not that special
Junio C Hamano [Fri, 15 Dec 2023 20:32:45 +0000 (12:32 -0800)] 
docs: MERGE_AUTOSTASH is not that special

A handful of manual pages called MERGE_AUTOSTASH a "special ref",
but there is nothing special about it.  It merely is yet another
pseudoref.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agodocs: AUTO_MERGE is not that special
Junio C Hamano [Fri, 15 Dec 2023 20:32:44 +0000 (12:32 -0800)] 
docs: AUTO_MERGE is not that special

A handful of manual pages called AUTO_MERGE a "special ref", but
there is nothing special about it.  It merely is yet another
pseudoref.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorefs.h: HEAD is not that special
Junio C Hamano [Fri, 15 Dec 2023 20:32:43 +0000 (12:32 -0800)] 
refs.h: HEAD is not that special

In-code comment explains pseudorefs but used a wrong nomenclature
"special ref".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogit-bisect.txt: BISECT_HEAD is not that special
Junio C Hamano [Fri, 15 Dec 2023 20:32:42 +0000 (12:32 -0800)] 
git-bisect.txt: BISECT_HEAD is not that special

The description of "git bisect --no-checkout" called BISECT_HEAD a
"special ref", but there is nothing special about it.  It merely is
yet another pseudoref.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogit.txt: HEAD is not that special
Junio C Hamano [Fri, 15 Dec 2023 20:32:41 +0000 (12:32 -0800)] 
git.txt: HEAD is not that special

The introductory text in "git help git" that describes HEAD called
it "a special ref".  It is special compared to the more regular refs
like refs/heads/master and refs/tags/v1.0.0, but not that special,
unlike truly special ones like FETCH_HEAD.

Rewrite a few sentences to also introduce the distinction between a
regular ref that contain the object name and a symbolic ref that
contain the name of another ref.  Update the description of HEAD
that point at the current branch to use the more correct term, a
"symbolic ref".

This was found as part of auditing the documentation and in-code
comments for uses of "special ref" that refer merely a "pseudo ref".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogit-add.txt: add missing short option -A to synopsis
Eric Sunshine [Fri, 15 Dec 2023 20:43:33 +0000 (15:43 -0500)] 
git-add.txt: add missing short option -A to synopsis

With one exception, the synopsis for `git add` consistently lists the
short counterpart alongside the long-form of each option (for instance,
"[--edit | -e]"). The exception is that -A is not mentioned alongside
--all. Fix this inconsistency

Reported-by: Benjamin Lehmann <ben.lehmann@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agotests: adjust whitespace in chainlint expectations
Patrick Steinhardt [Fri, 15 Dec 2023 06:42:47 +0000 (07:42 +0100)] 
tests: adjust whitespace in chainlint expectations

The "check-chainlint" target runs automatically when running tests and
performs self-checks to verify that the chainlinter itself produces the
expected output. Originally, the chainlinter was implemented via sed,
but the infrastructure has been rewritten in fb41727b7e (t: retire
unused chainlint.sed, 2022-09-01) to use a Perl script instead.

The rewrite caused some slight whitespace changes in the output that are
ultimately not of much importance. In order to be able to assert that
the actual chainlinter errors match our expectations we thus have to
ignore whitespace characters when diffing them. As the `-w` flag is not
in POSIX we try to use `git diff -w --no-index` before we fall back to
`diff -w -u`.

To accomodate for cases where the host system has no Git installation we
use the locally-compiled version of Git. This can result in problems
though when the Git project's repository is using extensions that the
locally-compiled version of Git doesn't understand. It will refuse to
run and thus cause the checks to fail.

Instead of improving the detection logic, fix our ".expect" files so
that we do not need any post-processing at all anymore. This allows us
to drop the `-w` flag when diffing so that we can always use diff(1)
now.

Note that we keep some of the post-processing of `chainlint.pl` output
intact to strip leading line numbers generated by the script. Having
these would cause a rippling effect whenever we add a new test that
sorts into the middle of existing tests and would require us to
renumerate all subsequent lines, which seems rather pointless.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agomailinfo: avoid recursion when unquoting From headers
Jeff King [Thu, 14 Dec 2023 21:48:59 +0000 (16:48 -0500)] 
mailinfo: avoid recursion when unquoting From headers

Our unquote_comment() function is recursive; when it sees a comment
within a comment, like:

  (this is an (embedded) comment)

it recurses to handle the inner comment. This is fine for practical use,
but it does mean that you can easily run out of stack space with a
malicious header. For example:

  perl -e 'print "From: ", "(" x 2**18;' |
  git mailinfo /dev/null /dev/null

segfaults on my system. And since mailinfo is likely to be fed untrusted
input from the Internet (if not by human users, who might recognize a
garbage header, but certainly there are automated systems that apply
patches from a list) it may be possible for an attacker to trigger the
problem.

That said, I don't think there's an interesting security vulnerability
here. All an attacker can do is make it impossible to parse their email
and apply their patch, and there are lots of ways to generate bogus
emails. So it's more of an annoyance than anything.

But it's pretty easy to fix it. The recursion is not helping us preserve
any particular state from each level. The only flag in our parsing is
take_next_literally, and we can never recurse when it is set (since the
start of a new comment implies it was not backslash-escaped). So it is
really only useful for finding the end of the matched pair of
parentheses. We can do that easily with a simple depth counter.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot5100: make rfc822 comment test more careful
Jeff King [Thu, 14 Dec 2023 21:47:46 +0000 (16:47 -0500)] 
t5100: make rfc822 comment test more careful

When processing "From" headers in an email, mailinfo "unquotes" quoted
strings and rfc822 parenthesized comments. For quoted strings, we
actually remove the double-quotes, so:

  From: "A U Thor" <someone@example.com>

become:

  Author: A U Thor
  Email: someone@example.com

But for comments, we leave the outer parentheses in place, so:

  From: A U (this is a comment) Thor <someone@example.com>

becomes:

  Author: A U (this is a comment) Thor
  Email: someone@example.com

So what is the comment "unquoting" actually doing? In our code, being in
a comment section has exactly two effects:

  1. We'll unquote backslash-escaped characters inside a comment
     section.

  2. We _won't_ unquote double-quoted strings inside a comment section.

Our test for comments in t5100 checks this:

  From: "A U Thor" <somebody@example.com> (this is \(really\) a comment (honestly))

So it is covering (1), but not (2). Let's add in a quoted string to
cover this.

Moreover, because the comment appears at the end of the From header,
there's nothing to confirm that we correctly found the end of the
comment section (and not just the end-of-string). Let's instead move it
to the beginning of the header, which means we can confirm that the
existing quoted string is detected (which will only happen if we know
we've left the comment block).

As expected, the test continues to pass, but this will give us more
confidence as we refactor the code in the next patch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agobisect: consistently write BISECT_EXPECTED_REV via the refdb
Patrick Steinhardt [Thu, 14 Dec 2023 13:37:13 +0000 (14:37 +0100)] 
bisect: consistently write BISECT_EXPECTED_REV via the refdb

We're inconsistently writing BISECT_EXPECTED_REV both via the filesystem
and via the refdb, which violates the newly established rules for how
special refs must be treated. This works alright in practice with the
reffiles reference backend, but will cause bugs once we gain additional
backends.

Fix this issue and consistently write BISECT_EXPECTED_REV via the refdb
so that it is no longer a special ref.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorefs: complete list of special refs
Patrick Steinhardt [Thu, 14 Dec 2023 13:37:06 +0000 (14:37 +0100)] 
refs: complete list of special refs

We have some references that are more special than others. The reason
for them being special is that they either do not follow the usual
format of references, or that they are written to the filesystem
directly by the respective owning subsystem and thus circumvent the
reference backend.

This works perfectly fine right now because the reffiles backend will
know how to read those refs just fine. But with the prospect of gaining
a new reference backend implementation we need to be a lot more careful
here:

  - We need to make sure that we are consistent about how those refs are
    written. They must either always be written via the filesystem, or
    they must always be written via the reference backend. Any mixture
    will lead to inconsistent state.

  - We need to make sure that such special refs are always handled
    specially when reading them.

We're already mostly good with regard to the first item, except for
`BISECT_EXPECTED_REV` which will be addressed in a subsequent commit.
But the current list of special refs is missing some refs that really
should be treated specially. Right now, we only treat `FETCH_HEAD` and
`MERGE_HEAD` specially here.

Introduce a new function `is_special_ref()` that contains all current
instances of special refs to fix the reading path.

Note that this is only a temporary measure where we record and rectify
the current state. Ideally, the list of special refs should in the end
only contain `FETCH_HEAD` and `MERGE_HEAD` again because they both may
reference multiple objects and can contain annotations, so they indeed
are special.

Based-on-patch-by: Han-Wen Nienhuys <hanwenn@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorefs: propagate errno when reading special refs fails
Patrick Steinhardt [Thu, 14 Dec 2023 13:37:02 +0000 (14:37 +0100)] 
refs: propagate errno when reading special refs fails

Some refs in Git are more special than others due to reasons explained
in the next commit. These refs are read via `refs_read_special_head()`,
but this function doesn't behave the same as when we try to read a
normal ref. Most importantly, we do not propagate `failure_errno` in the
case where the reference does not exist, which is behaviour that we rely
on in many parts of Git.

Fix this bug by propagating errno when `strbuf_read_file()` fails.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>