]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
6 weeks agoMerge branch 'ps/t0610-umask-fix'
Junio C Hamano [Mon, 15 Apr 2024 21:11:43 +0000 (14:11 -0700)] 
Merge branch 'ps/t0610-umask-fix'

The "shared repository" test in the t0610 reftable test failed
under restrictive umask setting (e.g. 007), which has been
corrected.

* ps/t0610-umask-fix:
  t0610: execute git-pack-refs(1) with specified umask
  t0610: make `--shared=` tests reusable

6 weeks agoMerge branch 'gt/add-u-commit-i-pathspec-check'
Junio C Hamano [Mon, 15 Apr 2024 21:11:43 +0000 (14:11 -0700)] 
Merge branch 'gt/add-u-commit-i-pathspec-check'

"git add -u <pathspec>" and "git commit [-i] <pathspec>" did not
diagnose a pathspec element that did not match any files in certain
situations, unlike "git add <pathspec>" did.

* gt/add-u-commit-i-pathspec-check:
  builtin/add: error out when passing untracked path with -u
  builtin/commit: error out when passing untracked path with -i
  revision: optionally record matches with pathspec elements

6 weeks agoMerge branch 'ds/fetch-config-parse-microfix'
Junio C Hamano [Mon, 15 Apr 2024 21:11:43 +0000 (14:11 -0700)] 
Merge branch 'ds/fetch-config-parse-microfix'

A config parser callback function fell through instead of returning
after recognising and processing a variable, wasting cycles, which
has been corrected.

* ds/fetch-config-parse-microfix:
  fetch: return when parsing submodule.recurse

6 weeks agoMerge branch 'rs/apply-reject-fd-leakfix'
Junio C Hamano [Mon, 15 Apr 2024 21:11:42 +0000 (14:11 -0700)] 
Merge branch 'rs/apply-reject-fd-leakfix'

A file descriptor leak in an error codepath, used when "git apply
--reject" fails to create the *.rej file, has been corrected.

* rs/apply-reject-fd-leakfix:
  apply: don't leak fd on fdopen() error

6 weeks agoMerge branch 'rs/apply-lift-path-length-limit'
Junio C Hamano [Mon, 15 Apr 2024 21:11:42 +0000 (14:11 -0700)] 
Merge branch 'rs/apply-lift-path-length-limit'

"git apply" has been updated to lift the hardcoded pathname length
limit, which in turn allowed a mksnpath() function that is no
longer used.

* rs/apply-lift-path-length-limit:
  path: remove mksnpath()
  apply: avoid fixed-size buffer in create_one_file()

6 weeks agoMerge branch 'ma/win32-unix-domain-socket'
Junio C Hamano [Mon, 15 Apr 2024 21:11:42 +0000 (14:11 -0700)] 
Merge branch 'ma/win32-unix-domain-socket'

Windows binary used to decide the use of unix-domain socket at
build time, but it learned to make the decision at runtime instead.

* ma/win32-unix-domain-socket:
  Win32: detect unix socket support at runtime

7 weeks agoThe eighteenth batch
Junio C Hamano [Fri, 12 Apr 2024 17:57:45 +0000 (10:57 -0700)] 
The eighteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMerge branch 'tb/midx-write'
Junio C Hamano [Fri, 12 Apr 2024 18:31:39 +0000 (11:31 -0700)] 
Merge branch 'tb/midx-write'

Code clean-up by splitting code responsible for writing midx files
into its own file.

* tb/midx-write:
  midx-write.c: use `--stdin-packs` when repacking
  midx-write.c: check count of packs to repack after grouping
  midx-write.c: factor out common want_included_pack() routine
  midx-write: move writing-related functions from midx.c

7 weeks agoMerge branch 'rs/t-prio-queue-cleanup'
Junio C Hamano [Fri, 12 Apr 2024 18:31:39 +0000 (11:31 -0700)] 
Merge branch 'rs/t-prio-queue-cleanup'

t-prio-queue test has been cleaned up by using C99 compound
literals; this is meant to also serve as a weather-balloon to smoke
out folks with compilers who have trouble compiling code that uses
the feature.

* rs/t-prio-queue-cleanup:
  t-prio-queue: simplify using compound literals

7 weeks agoMerge branch 'ps/reftable-binsearch-updates'
Junio C Hamano [Fri, 12 Apr 2024 18:31:39 +0000 (11:31 -0700)] 
Merge branch 'ps/reftable-binsearch-updates'

Reftable code clean-up and some bugfixes.

* ps/reftable-binsearch-updates:
  reftable/block: avoid decoding keys when searching restart points
  reftable/record: extract function to decode key lengths
  reftable/block: fix error handling when searching restart points
  reftable/block: refactor binary search over restart points
  reftable/refname: refactor binary search over refnames
  reftable/basics: improve `binsearch()` test
  reftable/basics: fix return type of `binsearch()` to be `size_t`

7 weeks agoMerge branch 'jc/checkout-detach-wo-tracking-report'
Junio C Hamano [Fri, 12 Apr 2024 18:31:39 +0000 (11:31 -0700)] 
Merge branch 'jc/checkout-detach-wo-tracking-report'

"git checkout/switch --detach foo", after switching to the detached
HEAD state, gave the tracking information for the 'foo' branch,
which was pointless.

Tested-by: M Hickford <mirth.hickford@gmail.com>
cf. <CAGJzqsmE9FDEBn=u3ge4LA3ha4fDbm4OWiuUbMaztwjELBd7ug@mail.gmail.com>

* jc/checkout-detach-wo-tracking-report:
  checkout: omit "tracking" information on a detached HEAD

7 weeks agoMerge branch 'rs/imap-send-use-xsnprintf'
Junio C Hamano [Fri, 12 Apr 2024 18:31:38 +0000 (11:31 -0700)] 
Merge branch 'rs/imap-send-use-xsnprintf'

Code clean-up and duplicate reduction.

* rs/imap-send-use-xsnprintf:
  imap-send: use xsnprintf to format command

7 weeks agoMerge branch 'js/merge-tree-3-trees'
Junio C Hamano [Fri, 12 Apr 2024 18:31:38 +0000 (11:31 -0700)] 
Merge branch 'js/merge-tree-3-trees'

Match the option argument type in the help text to the correct type
updated by a recent series.

* js/merge-tree-3-trees:
  merge-tree: fix argument type of the `--merge-base` option

7 weeks agomerge-tree: fix argument type of the `--merge-base` option
Johannes Schindelin [Fri, 12 Apr 2024 12:10:40 +0000 (12:10 +0000)] 
merge-tree: fix argument type of the `--merge-base` option

In 5f43cf5b2e4 (merge-tree: accept 3 trees as arguments, 2024-01-28), I
taught `git merge-tree` to perform three-way merges on trees. This
commit even changed the manual page to state that the `--merge-base`
option takes a tree-ish rather than requiring a commit.

But I forgot to adjust the in-program help text. This patch fixes that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoThe seventeenth batch
Junio C Hamano [Wed, 10 Apr 2024 16:59:55 +0000 (09:59 -0700)] 
The seventeenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMerge branch 'jc/t2104-style-update'
Junio C Hamano [Wed, 10 Apr 2024 17:00:09 +0000 (10:00 -0700)] 
Merge branch 'jc/t2104-style-update'

Coding style fixes.

* jc/t2104-style-update:
  t2104: style fixes

7 weeks agoMerge branch 'kn/clarify-update-ref-doc'
Junio C Hamano [Wed, 10 Apr 2024 17:00:08 +0000 (10:00 -0700)] 
Merge branch 'kn/clarify-update-ref-doc'

Doc update, as a preparation to enhance "git update-ref --stdin".

* kn/clarify-update-ref-doc:
  githooks: use {old,new}-oid instead of {old,new}-value
  update-ref: use {old,new}-oid instead of {old,new}value

7 weeks agoMerge branch 'vs/complete-with-set-u-fix'
Junio C Hamano [Wed, 10 Apr 2024 17:00:08 +0000 (10:00 -0700)] 
Merge branch 'vs/complete-with-set-u-fix'

Another "set -u" fix for the bash prompt (in contrib/) script.

* vs/complete-with-set-u-fix:
  completion: protect prompt against unset SHOWUPSTREAM in nounset mode
  completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode

7 weeks agoMerge branch 'rs/mem-pool-size-t-safety'
Junio C Hamano [Wed, 10 Apr 2024 17:00:08 +0000 (10:00 -0700)] 
Merge branch 'rs/mem-pool-size-t-safety'

size_t arithmetic safety.

* rs/mem-pool-size-t-safety:
  mem-pool: use st_add() in mem_pool_strvfmt()

7 weeks agoMerge branch 'ds/typofix-core-config-doc'
Junio C Hamano [Wed, 10 Apr 2024 17:00:08 +0000 (10:00 -0700)] 
Merge branch 'ds/typofix-core-config-doc'

Typofix.

* ds/typofix-core-config-doc:
  config: fix some small capitalization issues, as spotted

7 weeks agoThe sixteenth batch
Junio C Hamano [Tue, 9 Apr 2024 21:31:31 +0000 (14:31 -0700)] 
The sixteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMerge branch 'rj/use-adv-if-enabled'
Junio C Hamano [Tue, 9 Apr 2024 21:31:45 +0000 (14:31 -0700)] 
Merge branch 'rj/use-adv-if-enabled'

Use advice_if_enabled() API to rewrite a simple pattern to
call advise() after checking advice_enabled().

* rj/use-adv-if-enabled:
  add: use advise_if_enabled for ADVICE_ADD_EMBEDDED_REPO
  add: use advise_if_enabled for ADVICE_ADD_EMPTY_PATHSPEC
  add: use advise_if_enabled for ADVICE_ADD_IGNORED_FILE

7 weeks agoMerge branch 'ps/pack-refs-auto'
Junio C Hamano [Tue, 9 Apr 2024 21:31:45 +0000 (14:31 -0700)] 
Merge branch 'ps/pack-refs-auto'

"git pack-refs" learned the "--auto" option, which is a useful
addition to be triggered from "git gc --auto".

Acked-by: Karthik Nayak <karthik.188@gmail.com>
cf. <CAOLa=ZRAEA7rSUoYL0h-2qfEELdbPHbeGpgBJRqesyhHi9Q6WQ@mail.gmail.com>

* ps/pack-refs-auto:
  builtin/gc: pack refs when using `git maintenance run --auto`
  builtin/gc: forward git-gc(1)'s `--auto` flag when packing refs
  t6500: extract objects with "17" prefix
  builtin/gc: move `struct maintenance_run_opts`
  builtin/pack-refs: introduce new "--auto" flag
  builtin/pack-refs: release allocated memory
  refs/reftable: expose auto compaction via new flag
  refs: remove `PACK_REFS_ALL` flag
  refs: move `struct pack_refs_opts` to where it's used
  t/helper: drop pack-refs wrapper
  refs/reftable: print errors on compaction failure
  reftable/stack: gracefully handle failed auto-compaction due to locks
  reftable/stack: use error codes when locking fails during compaction
  reftable/error: discern locked/outdated errors
  reftable/stack: fix error handling in `reftable_stack_init_addition()`

7 weeks agoMerge branch 'es/test-cron-safety'
Junio C Hamano [Tue, 9 Apr 2024 21:31:44 +0000 (14:31 -0700)] 
Merge branch 'es/test-cron-safety'

The test script had an incomplete and ineffective attempt to avoid
clobbering the testing user's real crontab (and its equivalents),
which has been completed.

* es/test-cron-safety:
  test-lib: fix non-functioning GIT_TEST_MAINT_SCHEDULER fallback

7 weeks agoMerge branch 'rj/add-p-explicit-reshow'
Junio C Hamano [Tue, 9 Apr 2024 21:31:44 +0000 (14:31 -0700)] 
Merge branch 'rj/add-p-explicit-reshow'

"git add -p" and other "interactive hunk selection" UI has learned to
skip showing the hunk immediately after it has already been shown, and
an additional action to explicitly ask to reshow the current hunk.

* rj/add-p-explicit-reshow:
  add-patch: do not print hunks repeatedly
  add-patch: introduce 'p' in interactive-patch

7 weeks agoMerge branch 'mg/editorconfig-makefile'
Junio C Hamano [Tue, 9 Apr 2024 21:31:44 +0000 (14:31 -0700)] 
Merge branch 'mg/editorconfig-makefile'

The .editorconfig file has been taught that a Makefile uses HT
indentation.

* mg/editorconfig-makefile:
  editorconfig: add Makefiles to "text files"

7 weeks agoMerge branch 'ja/doc-markup-updates'
Junio C Hamano [Tue, 9 Apr 2024 21:31:44 +0000 (14:31 -0700)] 
Merge branch 'ja/doc-markup-updates'

Documentation rules has been explicitly described how to mark-up
literal parts and a few manual pages have been updated as examples.

* ja/doc-markup-updates:
  doc: git-clone: do not autoreference the manpage in itself
  doc: git-clone: apply new documentation formatting guidelines
  doc: git-init: apply new documentation formatting guidelines
  doc: allow literal and emphasis format in doc vs help tests
  doc: rework CodingGuidelines with new formatting rules

7 weeks agoMerge branch 'dg/myfirstobjectwalk-updates'
Junio C Hamano [Tue, 9 Apr 2024 21:31:44 +0000 (14:31 -0700)] 
Merge branch 'dg/myfirstobjectwalk-updates'

Update a more recent tutorial doc.

* dg/myfirstobjectwalk-updates:
  MyFirstObjectWalk: add stderr to pipe processing
  MyFirstObjectWalk: fix description for counting omitted objects
  MyFirstObjectWalk: fix filtered object walk
  MyFirstObjectWalk: fix misspelled "builtins/"
  MyFirstObjectWalk: use additional arg in config_fn_t

7 weeks agoMerge branch 'jc/advice-sans-trailing-whitespace'
Junio C Hamano [Tue, 9 Apr 2024 21:31:43 +0000 (14:31 -0700)] 
Merge branch 'jc/advice-sans-trailing-whitespace'

The "hint:" messages given by the advice mechanism, when given a
message with a blank line, left a line with trailing whitespace,
which has been cleansed.

* jc/advice-sans-trailing-whitespace:
  advice: omit trailing whitespace

7 weeks agoMerge branch 'jc/apply-parse-diff-git-header-names-fix'
Junio C Hamano [Tue, 9 Apr 2024 21:31:43 +0000 (14:31 -0700)] 
Merge branch 'jc/apply-parse-diff-git-header-names-fix'

"git apply" failed to extract the filename the patch applied to,
when the change was about an empty file created in or deleted from
a directory whose name ends with a SP, which has been corrected.

* jc/apply-parse-diff-git-header-names-fix:
  t4126: fix "funny directory name" test on Windows (again)
  t4126: make sure a directory with SP at the end is usable
  apply: parse names out of "diff --git" more carefully

7 weeks agot0610: execute git-pack-refs(1) with specified umask
Patrick Steinhardt [Tue, 9 Apr 2024 09:57:32 +0000 (11:57 +0200)] 
t0610: execute git-pack-refs(1) with specified umask

The tests for git-pack-refs(1) with the `core.sharedRepository` config
execute git-pack-refs(1) outside of the shell that has the expected
umask set. This is wrong because we want to test the behaviour of that
command with different umasks. The issue went unnoticed because most
distributions have a default umask of 0022, and we only ever test with
`--shared=true`, which re-adds the group write bit.

Fix the issue by moving git-pack-refs(1) into the umask'd shell and add
a bunch of test cases that exercise behaviour more thoroughly.

Note that we drop the check for whether `core.sharedRepository` was set
to the correct value to make the test setup a bit easier. We should be
able to rely on git-init(1) doing its thing correctly. Furthermore, to
help readability, we convert tests that pass `--shared=true` to instead
pass the equivalent `--shared=group`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agot0610: make `--shared=` tests reusable
Patrick Steinhardt [Tue, 9 Apr 2024 09:57:27 +0000 (11:57 +0200)] 
t0610: make `--shared=` tests reusable

We have two kinds of `--shared=` tests, one for git-init(1) and one for
git-pack-refs(1). Merge them into a reusable function such that we can
easily add additional testcases with different umasks and flags for the
`--shared=` switch.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoThe fifteenth batch
Junio C Hamano [Fri, 5 Apr 2024 17:49:37 +0000 (10:49 -0700)] 
The fifteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoMerge branch 'jk/core-comment-string'
Junio C Hamano [Fri, 5 Apr 2024 17:49:49 +0000 (10:49 -0700)] 
Merge branch 'jk/core-comment-string'

core.commentChar used to be limited to a single byte, but has been
updated to allow an arbitrary multi-byte sequence.

* jk/core-comment-string:
  config: add core.commentString
  config: allow multi-byte core.commentChar
  environment: drop comment_line_char compatibility macro
  wt-status: drop custom comment-char stringification
  sequencer: handle multi-byte comment characters when writing todo list
  find multi-byte comment chars in unterminated buffers
  find multi-byte comment chars in NUL-terminated strings
  prefer comment_line_str to comment_line_char for printing
  strbuf: accept a comment string for strbuf_add_commented_lines()
  strbuf: accept a comment string for strbuf_commented_addf()
  strbuf: accept a comment string for strbuf_stripspace()
  environment: store comment_line_char as a string
  strbuf: avoid shadowing global comment_line_char name
  commit: refactor base-case of adjust_comment_line_char()
  strbuf: avoid static variables in strbuf_add_commented_lines()
  strbuf: simplify comment-handling in add_lines() helper
  config: forbid newline as core.commentChar

8 weeks agoMerge branch 'rs/config-comment'
Junio C Hamano [Fri, 5 Apr 2024 17:49:49 +0000 (10:49 -0700)] 
Merge branch 'rs/config-comment'

"git config" learned "--comment=<message>" option to leave a
comment immediately after the "variable = value" on the same line
in the configuration file.

* rs/config-comment:
  config: allow tweaking whitespace between value and comment
  config: fix --comment formatting
  config: add --comment option to add a comment

8 weeks agoapply: don't leak fd on fdopen() error
René Scharfe [Fri, 5 Apr 2024 10:58:16 +0000 (12:58 +0200)] 
apply: don't leak fd on fdopen() error

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agofetch: return when parsing submodule.recurse
Derrick Stolee [Fri, 5 Apr 2024 02:52:22 +0000 (02:52 +0000)] 
fetch: return when parsing submodule.recurse

When parsing config keys, the normal pattern is to return 0 after
completing the logic for a specific config key, since no other key will
match. One instance, for "submodule.recurse", was missing this case in
builtin/fetch.c.

This is a very minor change, and will have minimal impact to
performance. This particular block was edited recently in 56e8bb4fb4
(fetch: use `fetch_config` to store "fetch.recurseSubmodules" value,
2023-05-17), which led to some hesitation that perhaps this omission was
on purpose.

However, no later cases within git_fetch_config() will match the key if
equal to "submodule.recurse" and neither will any key matches within the
catch-all git_default_config().

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agopath: remove mksnpath()
René Scharfe [Fri, 5 Apr 2024 10:56:48 +0000 (12:56 +0200)] 
path: remove mksnpath()

Remove the function mksnpath(), which has become unused.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoapply: avoid fixed-size buffer in create_one_file()
René Scharfe [Fri, 5 Apr 2024 10:53:23 +0000 (12:53 +0200)] 
apply: avoid fixed-size buffer in create_one_file()

PATH_MAX is not always a hard limit and 'path' in create_one_file()
could be longer -- it's taken from the patch file and allocated
dynamically.  Allocate the name of the temporary file on the heap as
well instead of using a fixed-size buffer to avoid that arbitrary limit.

Resist the temptation of using the more convenient mkpath() to avoid
introducing a dependency on a static variable deep inside the apply
machinery.

Take care to work around (arguably buggy) implementations of free(3)
that modify errno, by calling it only after using the errno value.

Suggested-by: Jeff King <peff@peff.net>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agobuiltin/add: error out when passing untracked path with -u
Ghanshyam Thakkar [Wed, 3 Apr 2024 18:14:52 +0000 (23:44 +0530)] 
builtin/add: error out when passing untracked path with -u

When passing untracked path with -u option, it silently succeeds.
There is no error message and the exit code is zero. This is
inconsistent with other instances of git commands where the expected
argument is a known path. In those other instances, we error out when
the path is not known.

Fix this by passing a character array to add_files_to_cache() to
collect the pathspec matching information and report the error if a
pathspec does not match any cache entry. Also add a testcase to cover
this scenario.

Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agobuiltin/commit: error out when passing untracked path with -i
Ghanshyam Thakkar [Wed, 3 Apr 2024 18:14:50 +0000 (23:44 +0530)] 
builtin/commit: error out when passing untracked path with -i

When we provide a pathspec which does not match any tracked path
alongside --include, we do not error like without --include. If there
is something staged, it will commit the staged changes and ignore the
pathspec which does not match any tracked path. And if nothing is
staged, it will print the status. Exit code is 0 in both cases (unlike
without --include). This is also described in the TODO comment before
the relevant testcase.

Fix this by passing a character array to add_files_to_cache() to
collect the pathspec matching information and error out if the given
path is untracked. Also, amend the testcase to check for the error
message and remove the TODO comment.

Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agorevision: optionally record matches with pathspec elements
Junio C Hamano [Wed, 3 Apr 2024 18:14:48 +0000 (23:44 +0530)] 
revision: optionally record matches with pathspec elements

Unlike "git add" and other end-user facing commands, where it is
diagnosed as an error to give a pathspec with an element that does
not match any path, the diff machinery does not care if some
elements of the pathspec do not match.  Given that the diff
machinery is heavily used in pathspec-limited "git log" machinery,
and it is common for a path to come and go while traversing the
project history, this is usually a good thing.

However, in some cases we would want to know if all the pathspec
elements matched.  For example, "git add -u <pathspec>" internally
uses the machinery used by "git diff-files" to decide contents from
what paths to add to the index, and as an end-user facing command,
"git add -u" would want to report an unmatched pathspec element.

Add a new .ps_matched member next to the .prune_data member in
"struct rev_info" so that we can optionally keep track of the use of
.prune_data pathspec elements that can be inspected by the caller.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoWin32: detect unix socket support at runtime
Matthias Aßhauer [Wed, 3 Apr 2024 15:42:02 +0000 (15:42 +0000)] 
Win32: detect unix socket support at runtime

Windows 10 build 17063 introduced support for unix sockets to Windows.
bb390b1 (git-compat-util: include declaration for unix sockets in
windows, 2021-09-14) introduced a way to build git with unix socket
support on Windows, but you still had to decide at build time which
Windows version the compiled executable was supposed to run on.

We can detect at runtime wether the operating system supports unix
sockets and act accordingly for all supported Windows versions.

This fixes https://github.com/git-for-windows/git/issues/3892

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoThe fourteenth batch
Junio C Hamano [Wed, 3 Apr 2024 17:55:20 +0000 (10:55 -0700)] 
The fourteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoMerge branch 'bl/cherry-pick-empty'
Junio C Hamano [Wed, 3 Apr 2024 17:56:20 +0000 (10:56 -0700)] 
Merge branch 'bl/cherry-pick-empty'

Allow git-cherry-pick(1) to automatically drop redundant commits via
a new `--empty` option, similar to the `--empty` options for
git-rebase(1) and git-am(1). Includes a soft deprecation of
`--keep-redundant-commits` as well as some related docs changes and
sequencer code cleanup.

* bl/cherry-pick-empty:
  cherry-pick: add `--empty` for more robust redundant commit handling
  cherry-pick: enforce `--keep-redundant-commits` incompatibility
  sequencer: do not require `allow_empty` for redundant commit options
  sequencer: handle unborn branch with `--allow-empty`
  rebase: update `--empty=ask` to `--empty=stop`
  docs: clean up `--empty` formatting in git-rebase(1) and git-am(1)
  docs: address inaccurate `--empty` default with `--exec`

8 weeks agoMerge branch 'bl/pretty-shorthand-config-fix'
Junio C Hamano [Wed, 3 Apr 2024 17:56:20 +0000 (10:56 -0700)] 
Merge branch 'bl/pretty-shorthand-config-fix'

The "--pretty=<shortHand>" option of the commands in the "git log"
family, defined as "[pretty] shortHand = <expansion>" should have
been looked up case insensitively, but was not, which has been
corrected.

* bl/pretty-shorthand-config-fix:
  pretty: find pretty formats case-insensitively
  pretty: update tests to use `test_config`

8 weeks agoMerge branch 'rs/strbuf-expand-bad-format'
Junio C Hamano [Wed, 3 Apr 2024 17:56:20 +0000 (10:56 -0700)] 
Merge branch 'rs/strbuf-expand-bad-format'

Code clean-up.

* rs/strbuf-expand-bad-format:
  cat-file: use strbuf_expand_bad_format()
  factor out strbuf_expand_bad_format()

8 weeks agoMerge branch 'rs/midx-use-strvec-pushf'
Junio C Hamano [Wed, 3 Apr 2024 17:56:19 +0000 (10:56 -0700)] 
Merge branch 'rs/midx-use-strvec-pushf'

Code clean-up.

* rs/midx-use-strvec-pushf:
  midx: use strvec_pushf() for pack-objects base name

8 weeks agoMerge branch 'pb/test-scripts-are-build-targets'
Junio C Hamano [Wed, 3 Apr 2024 17:56:19 +0000 (10:56 -0700)] 
Merge branch 'pb/test-scripts-are-build-targets'

The t/README file now gives a hint on running individual tests in
the "t/" directory with "make t<num>-*.sh t<num>-*.sh".

* pb/test-scripts-are-build-targets:
  t/README: mention test files are make targets

8 weeks agoMerge branch 'ds/grep-doc-updates'
Junio C Hamano [Wed, 3 Apr 2024 17:56:19 +0000 (10:56 -0700)] 
Merge branch 'ds/grep-doc-updates'

Documentation updates.

* ds/grep-doc-updates:
  grep docs: describe --no-index further and improve formatting a bit
  grep docs: describe --recurse-submodules further and improve formatting a bit

8 weeks agoMerge branch 'az/grep-group-error-message-update'
Junio C Hamano [Wed, 3 Apr 2024 17:56:19 +0000 (10:56 -0700)] 
Merge branch 'az/grep-group-error-message-update'

Error message clarification.

* az/grep-group-error-message-update:
  grep: improve errors for unmatched ( and )

8 weeks agoMerge branch 'jc/release-notes-entry-experiment'
Junio C Hamano [Wed, 3 Apr 2024 17:56:19 +0000 (10:56 -0700)] 
Merge branch 'jc/release-notes-entry-experiment'

Introduce an experimental protocol for contributors to propose the
topic description to be used in the "What's cooking" report, the
merge commit message for the topic, and in the release notes and
document it in the SubmittingPatches document.

* jc/release-notes-entry-experiment:
  SubmittingPatches: release-notes entry experiment

8 weeks agoMerge branch 'jk/remote-helper-object-format-option-fix'
Junio C Hamano [Wed, 3 Apr 2024 17:56:18 +0000 (10:56 -0700)] 
Merge branch 'jk/remote-helper-object-format-option-fix'

The implementation and documentation of "object-format" option
exchange between the Git itself and its remote helpers did not
quite match, which has been corrected.

* jk/remote-helper-object-format-option-fix:
  transport-helper: send "true" value for object-format option
  transport-helper: drop "object-format <algo>" option
  transport-helper: use write helpers more consistently

8 weeks agoreftable/block: avoid decoding keys when searching restart points
Patrick Steinhardt [Wed, 3 Apr 2024 06:04:29 +0000 (08:04 +0200)] 
reftable/block: avoid decoding keys when searching restart points

When searching over restart points in a block we decode the key of each
of the records, which results in a memory allocation. This is quite
pointless though given that records it restart points will never use
prefix compression and thus store their keys verbatim in the block.

Refactor the code so that we can avoid decoding the keys, which saves us
some allocations.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoreftable/record: extract function to decode key lengths
Patrick Steinhardt [Wed, 3 Apr 2024 06:04:22 +0000 (08:04 +0200)] 
reftable/record: extract function to decode key lengths

We're about to refactor the binary search over restart points so that it
does not need to fully decode the record keys anymore. To do so we will
need to decode the record key lengths, which is non-trivial logic.

Extract the logic to decode these lengths from `refatble_decode_key()`
so that we can reuse it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoreftable/block: fix error handling when searching restart points
Patrick Steinhardt [Wed, 3 Apr 2024 06:04:18 +0000 (08:04 +0200)] 
reftable/block: fix error handling when searching restart points

When doing the binary search over restart points in a block we need to
decode the record keys. This decoding step can result in an error when
the block is corrupted, which we indicate to the caller of the binary
search by setting `args.error = 1`. But the only caller that exists
mishandles this because it in fact performs the error check before
calling `binsearch()`.

Fix this bug by checking for errors at the right point in time.
Furthermore, refactor `binsearch()` so that it aborts the search in case
the callback function returns a negative value so that we don't
needlessly continue to search the block.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoreftable/block: refactor binary search over restart points
Patrick Steinhardt [Wed, 3 Apr 2024 06:04:09 +0000 (08:04 +0200)] 
reftable/block: refactor binary search over restart points

When seeking a record in our block reader we perform a binary search
over the block's restart points so that we don't have to do a linear
scan over the whole block. The logic to do so is quite intricate though,
which makes it hard to understand.

Improve documentation and rename some of the functions and variables so
that the code becomes easier to understand overall. This refactoring
should not result in any change in behaviour.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoreftable/refname: refactor binary search over refnames
Patrick Steinhardt [Wed, 3 Apr 2024 06:04:05 +0000 (08:04 +0200)] 
reftable/refname: refactor binary search over refnames

It is comparatively hard to understand how exactly the binary search
over refnames works given that the function and variable names are not
exactly easy to grasp. Rename them to make this more obvious. This
should not result in any change in behaviour.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoreftable/basics: improve `binsearch()` test
Patrick Steinhardt [Wed, 3 Apr 2024 06:04:00 +0000 (08:04 +0200)] 
reftable/basics: improve `binsearch()` test

The `binsearch()` test is somewhat weird in that it doesn't explicitly
spell out its expectations. Instead it does so in a rather ad-hoc way
with some hard-to-understand computations.

Refactor the test to spell out the needle as well as expected index for
all testcases. This refactoring highlights that the `binsearch_func()`
is written somewhat weirdly to find the first integer smaller than the
needle, not smaller or equal to it. Adjust the function accordingly.

While at it, rename the callback function to better convey its meaning.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoreftable/basics: fix return type of `binsearch()` to be `size_t`
Patrick Steinhardt [Wed, 3 Apr 2024 06:03:56 +0000 (08:03 +0200)] 
reftable/basics: fix return type of `binsearch()` to be `size_t`

The `binsearch()` function can be used to find the first element for
which a callback functions returns a truish value. But while the array
size is of type `size_t`, the function in fact returns an `int` that is
supposed to index into that array.

Fix the function signature to return a `size_t`. This conversion does
not change any semantics given that the function would only ever return
a value in the range `[0, sz]` anyway.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot-prio-queue: simplify using compound literals
René Scharfe [Tue, 2 Apr 2024 18:30:31 +0000 (20:30 +0200)] 
t-prio-queue: simplify using compound literals

Test names like "basic" are mentioned seven times in the code (ignoring
case): Twice when defining the input and result macros, thrice when
defining the test function, and twice again when calling it.  Reduce
that to a single time by using compound literals to pass the input and
result arrays via TEST_INPUT to test_prio_queue().

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot2104: style fixes
Junio C Hamano [Tue, 2 Apr 2024 18:41:03 +0000 (11:41 -0700)] 
t2104: style fixes

We use tabs to indent, not two or four spaces.

These days, even the test fixture preparation should be done inside
test_expect_success block.

Address these two style violations in this test.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoimap-send: use xsnprintf to format command
René Scharfe [Tue, 2 Apr 2024 14:51:05 +0000 (16:51 +0200)] 
imap-send: use xsnprintf to format command

nfsnprintf() wraps vsnprintf(3) and reports attempts to use too small a
buffer using BUG(), just like xsnprintf().

It has an extra check that makes sure the buffer size (converted to int)
is positive.  vsnprintf(3) is supposed to handle a buffer size of zero
or bigger than INT_MAX just fine, so this extra comparison doesn't make
us any safer.  If a platform has a broken implementation, we'd need to
work around it in our compat code.

Call xsnprintf() instead to reduce code duplication and make the caller
slightly more readable by using this more common helper.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agogithooks: use {old,new}-oid instead of {old,new}-value
Karthik Nayak [Tue, 2 Apr 2024 06:49:15 +0000 (08:49 +0200)] 
githooks: use {old,new}-oid instead of {old,new}-value

Similar to the previous commit, rename {old,new}-value in the 'githooks'
documentation to {old,new}-oid. This improves clarity and also ensures
consistency within the document.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoupdate-ref: use {old,new}-oid instead of {old,new}value
Karthik Nayak [Tue, 2 Apr 2024 06:49:14 +0000 (08:49 +0200)] 
update-ref: use {old,new}-oid instead of {old,new}value

The `git-update-ref` command is used to modify references. The usage of
{old,new}value in the documentation refers to the OIDs. This is fine
since the command only works with regular references which hold OIDs.
But if the command is updated to support symrefs, we'd also be dealing
with {old,new}-refs.

To improve clarity around what exactly {old,new}value mean, let's rename
it to {old,new}-oid.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomidx-write.c: use `--stdin-packs` when repacking
Taylor Blau [Mon, 1 Apr 2024 21:16:44 +0000 (17:16 -0400)] 
midx-write.c: use `--stdin-packs` when repacking

When constructing a new pack `git multi-pack-index repack` provides a
list of objects which is the union of objects in all MIDX'd packs which
were "included" in the repack.

Though correct, this typically yields a poorly structured pack, since
providing the objects list over stdin does not give pack-objects a
chance to discover the namehash values for each object, leading to
sub-optimal delta selection.

We can use `--stdin-packs` instead, which has a couple of benefits:

  - it does a supplemental walk over objects in the supplied list of
    packs to discover their namehash, leading to higher-quality delta
    selection

  - it requires us to list far less data over stdin; instead of listing
    each object in the resulting pack, we need only list the
    constituent packs from which those objects were selected in the MIDX

Of course, this comes at a slight cost: though we save time on listing
packs versus objects over stdin[^1] (around ~650 milliseconds), we add a
non-trivial amount of time walking over the given objects in order to
find better deltas.

In general, this is likely to more closely match the user's expectations
(i.e. that packs generated via `git multi-pack-index repack` are written
with high-quality deltas). But if not, we can always introduce a new
option in pack-objects to disable the supplemental object walk, which
would yield a pure CPU-time savings, at the cost of the on-disk size of
the resulting pack.

[^1]: In a patched version of Git that doesn't perform the supplemental
  object walk in `pack-objects --stdin-packs`, we save around ~650ms
  (from 5.968 to 5.325 seconds) when running `git multi-pack-index
  repack --batch-size=0` on git.git with all objects packed, and all
  packs in a MIDX.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomidx-write.c: check count of packs to repack after grouping
Taylor Blau [Mon, 1 Apr 2024 21:16:41 +0000 (17:16 -0400)] 
midx-write.c: check count of packs to repack after grouping

In both fill_included_packs_all() and fill_included_packs_batch(), we
accumulate a list of packs whose contents we want to repack together,
and then use that information to feed a list of objects as input to
pack-objects.

In both cases, the `fill_included_packs_` functions keep track of how
many packs they want to repack together, and only execute pack-objects
if there are at least two packs that need repacking.

Having both of these functions keep track of this information themselves
is not strictly necessary, since they also log which packs to repack via
the `include_pack` array, so we can simply count the non-zero entries in
that array after either function is done executing, reducing the overall
amount of code necessary.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomidx-write.c: factor out common want_included_pack() routine
Taylor Blau [Mon, 1 Apr 2024 21:16:38 +0000 (17:16 -0400)] 
midx-write.c: factor out common want_included_pack() routine

When performing a 'git multi-pack-index repack', the MIDX machinery
tries to aggregate MIDX'd packs together either to (a) fill the given
`--batch-size` argument, or (b) combine all packs together.

In either case (using the `midx-write.c::fill_included_packs_batch()` or
`midx-write.c::fill_included_packs_all()` function, respectively), we
evaluate whether or not we want to repack each MIDX'd pack, according to
whether or it is loadable, kept, cruft, or non-empty.

Between the two `fill_included_packs_` callers, they both care about the
same conditions, except for `fill_included_packs_batch()` which also
cares that the pack is non-empty.

We could extract two functions (say, `want_included_pack()` and a
`_nonempty()` variant), but this is not necessary. For the case in
`fill_included_packs_all()` which does not check the pack size, we add
all of the pack's objects assuming that the pack meets all other
criteria. But if the pack is empty in the first place, we add all of its
zero objects, so whether or not we "accept" or "reject" it in the first
place is irrelevant.

This change improves the readability in both `fill_included_packs_`
functions.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomidx-write: move writing-related functions from midx.c
Taylor Blau [Mon, 1 Apr 2024 21:16:34 +0000 (17:16 -0400)] 
midx-write: move writing-related functions from midx.c

Introduce a new midx-write.c source file, which holds all of the
functionality from the MIDX sub-system related to writing new MIDX files.

Similar to the relationship between "pack-bitmap.c" and
"pack-bitmap-write.c", this source file will hold code that is specific
to writing MIDX files as opposed to reading them (the latter will remain
in midx.c).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'rs/midx-use-strvec-pushf' into tb/midx-write
Junio C Hamano [Mon, 1 Apr 2024 21:18:05 +0000 (14:18 -0700)] 
Merge branch 'rs/midx-use-strvec-pushf' into tb/midx-write

* rs/midx-use-strvec-pushf:
  midx: use strvec_pushf() for pack-objects base name

2 months agoThe thirteenth batch
Junio C Hamano [Mon, 1 Apr 2024 20:21:22 +0000 (13:21 -0700)] 
The thirteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'ps/clone-with-includeif-onbranch'
Junio C Hamano [Mon, 1 Apr 2024 20:21:35 +0000 (13:21 -0700)] 
Merge branch 'ps/clone-with-includeif-onbranch'

An additional test to demonstrate that clone would not choke on a
global configuration file that uses includeIf.onbranch:*.path.

* ps/clone-with-includeif-onbranch:
  t5601: exercise clones with "includeIf.*.onbranch"

2 months agoMerge branch 'jk/rebase-apply-leakfix'
Junio C Hamano [Mon, 1 Apr 2024 20:21:35 +0000 (13:21 -0700)] 
Merge branch 'jk/rebase-apply-leakfix'

Leakfix.

* jk/rebase-apply-leakfix:
  rebase: use child_process_clear() to clean

2 months agoMerge branch 'ps/t7800-variable-interpolation-fix'
Junio C Hamano [Mon, 1 Apr 2024 20:21:35 +0000 (13:21 -0700)] 
Merge branch 'ps/t7800-variable-interpolation-fix'

Fix the way recently added tests interpolate variables defined
outside them, and document the best practice to help future
developers.

* ps/t7800-variable-interpolation-fix:
  t/README: document how to loop around test cases
  t7800: use single quotes for test bodies
  t7800: improve test descriptions with empty arguments

2 months agoMerge branch 'ps/reftable-unit-test-nfs-workaround'
Junio C Hamano [Mon, 1 Apr 2024 20:21:35 +0000 (13:21 -0700)] 
Merge branch 'ps/reftable-unit-test-nfs-workaround'

A unit test for reftable code tried to enumerate all files in a
directory after reftable operations and expected to see nothing but
the files it wanted to leave there, but was fooled by .nfs* cruft
files left, which has been corrected.

* ps/reftable-unit-test-nfs-workaround:
  reftable: fix tests being broken by NFS' delete-after-close semantics

2 months agoMerge branch 'jk/doc-remote-helpers-markup-fix'
Junio C Hamano [Mon, 1 Apr 2024 20:21:34 +0000 (13:21 -0700)] 
Merge branch 'jk/doc-remote-helpers-markup-fix'

Documentation mark-up fix.

* jk/doc-remote-helpers-markup-fix:
  doc/gitremote-helpers: fix more missing single-quotes

2 months agoMerge branch 'pb/advice-merge-conflict'
Junio C Hamano [Mon, 1 Apr 2024 20:21:34 +0000 (13:21 -0700)] 
Merge branch 'pb/advice-merge-conflict'

Hints that suggest what to do after resolving conflicts can now be
squelched by disabling advice.mergeConflict.

Acked-by: Phillip Wood <phillip.wood123@gmail.com>
cf. <e040c631-42d9-4501-a7b8-046f8dac6309@gmail.com>

* pb/advice-merge-conflict:
  builtin/am: allow disabling conflict advice
  sequencer: allow disabling conflict advice

2 months agoMerge branch 'ds/config-internal-whitespace-fix'
Junio C Hamano [Mon, 1 Apr 2024 20:21:34 +0000 (13:21 -0700)] 
Merge branch 'ds/config-internal-whitespace-fix'

"git config" corrupted literal HT characters written in the
configuration file as part of a value, which has been corrected.

* ds/config-internal-whitespace-fix:
  config.txt: describe handling of whitespace further
  t1300: add more tests for whitespace and inline comments
  config: really keep value-internal whitespace verbatim
  config: minor addition of whitespace

2 months agoMerge branch 'jk/pretty-subject-cleanup'
Junio C Hamano [Mon, 1 Apr 2024 20:21:33 +0000 (13:21 -0700)] 
Merge branch 'jk/pretty-subject-cleanup'

Code clean-up in the "git log" machinery that implements custom log
message formatting.

* jk/pretty-subject-cleanup:
  format-patch: fix leak of empty header string
  format-patch: simplify after-subject MIME header handling
  format-patch: return an allocated string from log_write_email_headers()
  log: do not set up extra_headers for non-email formats
  pretty: drop print_email_subject flag
  pretty: split oneline and email subject printing
  shortlog: stop setting pp.print_email_subject

2 months agoMerge branch 'pw/checkout-conflict-errorfix'
Junio C Hamano [Mon, 1 Apr 2024 20:21:33 +0000 (13:21 -0700)] 
Merge branch 'pw/checkout-conflict-errorfix'

"git checkout --conflict=bad" reported a bad conflictStyle as if it
were given to a configuration variable; it has been corrected to
report that the command line option is bad.

* pw/checkout-conflict-errorfix:
  checkout: fix interaction between --conflict and --merge
  checkout: cleanup --conflict=<style> parsing
  merge options: add a conflict style member
  merge-ll: introduce LL_MERGE_OPTIONS_INIT
  xdiff-interface: refactor parsing of merge.conflictstyle

2 months agocompletion: protect prompt against unset SHOWUPSTREAM in nounset mode
Ville Skyttä [Mon, 1 Apr 2024 19:07:51 +0000 (19:07 +0000)] 
completion: protect prompt against unset SHOWUPSTREAM in nounset mode

As it stands, the only call site of `__git_ps1_show_upstream` checks
that the `GIT_PS1_SHOWUPSTREAM` variable is set, so this is effectively
a no-op. However, that might change, and chances of noticing the
unprotected use might not be that high when it does.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocompletion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode
Ville Skyttä [Mon, 1 Apr 2024 11:30:33 +0000 (11:30 +0000)] 
completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode

`GIT_PS1_SHOWCONFLICTSTATE` is a user variable that might not be set,
causing errors when the shell is in `nounset` mode.

Take into account on access by falling back to an empty string.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoconfig: fix some small capitalization issues, as spotted
Dragan Simic [Sun, 31 Mar 2024 20:49:30 +0000 (22:49 +0200)] 
config: fix some small capitalization issues, as spotted

Fix some small capitalization issues, as spotted while going through the
documentation.  In general, a semicolon doesn't start a new sentence, and
"this" has no meaning of a proper noun in this context.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomem-pool: use st_add() in mem_pool_strvfmt()
René Scharfe [Sun, 31 Mar 2024 18:53:07 +0000 (20:53 +0200)] 
mem-pool: use st_add() in mem_pool_strvfmt()

If len is INT_MAX in mem_pool_strvfmt(), then len + 1 overflows.
Casting it to size_t would prevent that.  Use st_add() to go a step
further and make the addition *obviously* safe.  The compiler can
optimize the check away on platforms where SIZE_MAX > INT_MAX, i.e.
basically everywhere.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agotest-lib: fix non-functioning GIT_TEST_MAINT_SCHEDULER fallback
Eric Sunshine [Fri, 29 Mar 2024 22:27:03 +0000 (18:27 -0400)] 
test-lib: fix non-functioning GIT_TEST_MAINT_SCHEDULER fallback

When environment variable GIT_TEST_MAINT_SCHEDULER is set, `git
maintenance` invokes the command specified as the variable's value
rather than invoking the actual underlying platform-specific scheduler
management command. By setting GIT_TEST_MAINT_SCHEDULER to some suitable
value, test authors can therefore validate behavior of "destructive"
`git maintenance` commands without having to worry about clobbering the
user's own local scheduler configuration.

In order to protect an absent-minded test author from forgetting to set
GIT_TEST_MAINT_SCHEDULER in the local test script (and thus clobbering
his or her own scheduler configuration), t/test-lib.sh assigns an
"immediately error-out" value to GIT_TEST_MAINT_SCHEDULER by default
which should ensure that the problem will be caught and reported before
any damage can be done to the configuration of the person running the
tests.

Unfortunately, however, t/test-lib.sh neglects to export
GIT_TEST_MAINT_SCHEDULER, which renders the default "error-out"
assignment worthless. Fix this by exporting the variable as
originally intended.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-of-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoadd: use advise_if_enabled for ADVICE_ADD_EMBEDDED_REPO
Rubén Justo [Sat, 30 Mar 2024 14:09:29 +0000 (15:09 +0100)] 
add: use advise_if_enabled for ADVICE_ADD_EMBEDDED_REPO

By following a similar reasoning as in previous commits, there are no
reason why we should not use the advise_if_enabled() API to display the
ADVICE_ADD_EMBEDDED_REPO advice.

This advice was introduced in 532139940c (add: warn when adding an
embedded repository, 2017-06-14).  Some tests were included in the
commit, but none is testing this advice.  Which, note, we only want to
display once per run.

So, use the advise_if_enabled() machinery to show the
ADVICE_ADD_EMBEDDED_REPO advice and include a test to notice any
possible breakage.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoadd: use advise_if_enabled for ADVICE_ADD_EMPTY_PATHSPEC
Rubén Justo [Sat, 30 Mar 2024 14:08:59 +0000 (15:08 +0100)] 
add: use advise_if_enabled for ADVICE_ADD_EMPTY_PATHSPEC

Since 93b0d86aaf (git-add: error out when given no arguments.,
2006-12-20) we display a message when no arguments are given to "git
add".

Part of that message was converted to advice in bf66db37f1 (add: use
advise function to display hints, 2020-01-07).

Following the same line of reasoning as in the previous commit, it is
sensible to use advise_if_enabled() here.

Therefore, use advise_if_enabled() in builtin/add.c to show the
ADVICE_ADD_EMPTY_PATHSPEC advice, and don't bother checking there the
visibility of the advice or displaying the instruction on how to disable
it.

Also add a test for these messages, in order to detect a possible
change in them.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoadd: use advise_if_enabled for ADVICE_ADD_IGNORED_FILE
Rubén Justo [Sat, 30 Mar 2024 14:07:27 +0000 (15:07 +0100)] 
add: use advise_if_enabled for ADVICE_ADD_IGNORED_FILE

Since b3b18d1621 (advice: revamp advise API, 2020-03-02), we can use
advise_if_enabled() to display an advice.  This API encapsulates three
actions:
1.- checking the visibility of the advice

2.- displaying the advice when appropriate

3.- displaying instructions on how to disable the advice, when
    appropriate

The code we have in builtin/add.c to display the ADVICE_ADD_IGNORED_FILE
advice, is doing these three things.  However, the instructions
displayed on how to disable the hint are not shown in the normalized way
that advise_if_enabled() introduced.  This may cause distraction.

There is no reason not to use the new API here.  On the contrary, by
using it we gain simplicity in the code and avoid possible distractions.

For these reasons, use the newer advise_if_enabled() machinery to show
the ADVICE_ADD_IGNORED_FILE advice, and don't bother checking the
visibility or displaying the instruction on how to disable the advice.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocheckout: omit "tracking" information on a detached HEAD
Junio C Hamano [Sat, 30 Mar 2024 21:37:14 +0000 (14:37 -0700)] 
checkout: omit "tracking" information on a detached HEAD

By definition, a detached HEAD state is tentative and there is no
configured "upstream" that it always wants to integrate with.  But
if you detach from a branch that is behind its upstream, e.g.,

    $ git checkout -t -b main origin/main
    $ git checkout main
    $ git reset --hard HEAD^
    $ git checkout --detach main

you'd see "you are behind your upstream origin/main".  This does not
happen when you replace the last step in the above with any of these

    $ git checkout HEAD^0
    $ git checkout --detach HEAD
    $ git checkout --detach origin/main

Before 32669671 (checkout: introduce --detach synonym for "git
checkout foo^{commit}", 2011-02-08) introduced the "--detach"
option, the rule to decide if we show the tracking information
used to be:

    If --quiet is not given, and if the given branch name is a real
    local branch (i.e. the one we can compute the file path under
    .git/, like 'refs/heads/master' or "HEAD" which stand for the
    name of the current branch", then give the tracking information.

to exclude things like "git checkout master^0" (which was the
official way to detach HEAD at the commit before that commit) and
"git checkout origin/master^0" from showing tracking information,
but still do show the tracking information for the current branch
for "git checkout HEAD".  The introduction of an explicit option
"--detach" broke this subtley.  The new rule should have been

    If --quiet is given, do not bother with tracking info.
    If --detach is given, do not bother with tracking info.

    Otherwise, if we know that the branch name given is a real local
    branch, or if we were given "HEAD" and "HEAD" is not detached,
    then attempt to show the tracking info.

but it allowed "git checkout --detach master" to also show the
tracking info by mistake.  Let's tighten the rule to fix this.

Reported-by: mirth hickford <mirth.hickford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoadvice: omit trailing whitespace
Junio C Hamano [Fri, 29 Mar 2024 22:57:06 +0000 (15:57 -0700)] 
advice: omit trailing whitespace

Git tools all consistently encourage users to avoid whitespaces at
the end of line by giving them features like "git diff --check" and
"git am --whitespace=fix".  Make sure that the advice messages we
give users avoid trailing whitespaces.  We shouldn't be wasting
vertical screen real estate by adding blank lines in advice messages
that are supposed to be concise hints, but as long as we write such
blank line in our "hints", we should do it right.

A test that expects the current behaviour of leaving trailing
whitespaces has been adjusted.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: git-clone: do not autoreference the manpage in itself
Jean-Noël Avila [Fri, 29 Mar 2024 11:19:41 +0000 (11:19 +0000)] 
doc: git-clone: do not autoreference the manpage in itself

Auto-reference in man pages is a confusion factor.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: git-clone: apply new documentation formatting guidelines
Jean-Noël Avila [Fri, 29 Mar 2024 11:19:40 +0000 (11:19 +0000)] 
doc: git-clone: apply new documentation formatting guidelines

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: git-init: apply new documentation formatting guidelines
Jean-Noël Avila [Fri, 29 Mar 2024 11:19:39 +0000 (11:19 +0000)] 
doc: git-init: apply new documentation formatting guidelines

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: allow literal and emphasis format in doc vs help tests
Jean-Noël Avila [Fri, 29 Mar 2024 11:19:38 +0000 (11:19 +0000)] 
doc: allow literal and emphasis format in doc vs help tests

As the new formatting of literal and placeholders is introduced,
the synopsis in the man pages can now hold additional markup with
respect to the command help.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: rework CodingGuidelines with new formatting rules
Jean-Noël Avila [Fri, 29 Mar 2024 11:19:37 +0000 (11:19 +0000)] 
doc: rework CodingGuidelines with new formatting rules

Literal and placeholder formatting is more heavily enforced, with some
asciidoc magic. Basically, the markup is preserved everywhere.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot4126: fix "funny directory name" test on Windows (again)
Junio C Hamano [Fri, 29 Mar 2024 17:21:58 +0000 (10:21 -0700)] 
t4126: fix "funny directory name" test on Windows (again)

Even though "git update-index --cacheinfo" ought to be filesystem
agnostic,

    $ git update-index --add --cacheinfo "100644,$empty_blob,funny /empty"

fails only on Windows, and this unfortunately makes the approach of
the previous step unworkable.

Resurrect the earlier approach to give up on running the test on
known-bad platforms.  Instead of computing a custom prerequisite,
just use !MINGW we have used elsewhere.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoadd-patch: do not print hunks repeatedly
Rubén Justo [Fri, 29 Mar 2024 03:58:52 +0000 (04:58 +0100)] 
add-patch: do not print hunks repeatedly

The interactive-patch is a sequential process where, on each step, we
print one hunk from a patch and then ask the user how to proceed.

There is a possibility of repeating a step, for example if the user
enters a non-applicable option, i.e: "s"

    $ git add -p
    diff --git a/add-patch.c b/add-patch.c
    index 52be1ddb15..8fb75e82e2 100644
    --- a/add-patch.c
    +++ b/add-patch.c
    @@ -1394,7 +1394,7 @@ N_("j - leave this hunk undecided, see next undecided hunk\n"
     static int patch_update_file(struct add_p_state *s,
           struct file_diff *file_diff)
     {
    - size_t hunk_index = 0;
    + size_t hunk_index = 0, prev_hunk_index = -1;
      ssize_t i, undecided_previous, undecided_next;
      struct hunk *hunk;
      char ch;
    (1/4) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? s
    Sorry, cannot split this hunk
    @@ -1394,7 +1394,7 @@ N_("j - leave this hunk undecided, see next undecided hunk\n"
     static int patch_update_file(struct add_p_state *s,
           struct file_diff *file_diff)
     {
    - size_t hunk_index = 0;
    + size_t hunk_index = 0, prev_hunk_index = -1;
      ssize_t i, undecided_previous, undecided_next;
      struct hunk *hunk;
      char ch;
    (1/4) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?

... or an invalid option, i.e: "U"

    $ git add -p
    diff --git a/add-patch.c b/add-patch.c
    index 52be1ddb15..8fb75e82e2 100644
    --- a/add-patch.c
    +++ b/add-patch.c
    @@ -1394,7 +1394,7 @@ N_("j - leave this hunk undecided, see next undecided hunk\n"
     static int patch_update_file(struct add_p_state *s,
           struct file_diff *file_diff)
     {
    - size_t hunk_index = 0;
    + size_t hunk_index = 0, prev_hunk_index = -1;
      ssize_t i, undecided_previous, undecided_next;
      struct hunk *hunk;
      char ch;
    (1/4) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? U
    y - stage this hunk
    n - do not stage this hunk
    q - quit; do not stage this hunk or any of the remaining ones
    a - stage this hunk and all later hunks in the file
    d - do not stage this hunk or any of the later hunks in the file
    j - leave this hunk undecided, see next undecided hunk
    J - leave this hunk undecided, see next hunk
    g - select a hunk to go to
    / - search for a hunk matching the given regex
    e - manually edit the current hunk
    p - print again the current hunk
    ? - print help
    @@ -1394,7 +1394,7 @@ N_("j - leave this hunk undecided, see next undecided hunk\n"
     static int patch_update_file(struct add_p_state *s,
           struct file_diff *file_diff)
     {
    - size_t hunk_index = 0;
    + size_t hunk_index = 0, prev_hunk_index = -1;
      ssize_t i, undecided_previous, undecided_next;
      struct hunk *hunk;
      char ch;
    (1/4) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?

Printing the chunk again followed by the question can be confusing as
the user has to pay special attention to notice that the same chunk is
being reconsidered.

It can also be problematic if the chunk is longer than one screen height
because the result of the previous iteration is lost off the screen (the
help guide in the previous example).

To avoid such problems, stop printing the chunk if the iteration does
not advance to a different chunk.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoadd-patch: introduce 'p' in interactive-patch
Rubén Justo [Fri, 29 Mar 2024 03:58:28 +0000 (04:58 +0100)] 
add-patch: introduce 'p' in interactive-patch

Shortly we're going make interactive-patch stop printing automatically
the hunk under certain circumstances.

Let's introduce a new option to allow the user to explicitly request
the printing.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot4126: make sure a directory with SP at the end is usable
Junio C Hamano [Thu, 28 Mar 2024 21:08:47 +0000 (14:08 -0700)] 
t4126: make sure a directory with SP at the end is usable

As afb31ad9 (t1010: fix unnoticed failure on Windows, 2021-12-11)
said:

    On Microsoft Windows, a directory name should never end with a period.
    Quoting from Microsoft documentation[1]:

Do not end a file or directory name with a space or a period.
Although the underlying file system may support such names, the
Windows shell and user interface does not.

    [1]: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

and the condition addressed by this change is exactly that.  If the
platform is unable to properly create these sample patches about a
file that lives in a directory whose name ends with a SP, there is
no point testing how "git apply" behaves there on the filesystem.

Even though the ultimate purpose of "git apply" is to apply a patch
and to update the filesystem entities, this particular test is
mainly about parsing a patch on a funny pathname correctly, and even
on a system that is incapable of checking out the resulting state
correctly on its filesystem, at least the parsing can and should work
fine.  Rewrite the test to work inside the index without touching the
filesystem.

Helped-by: Jeff King <peff@peff.net>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoThe twelfth batch
Junio C Hamano [Thu, 28 Mar 2024 21:13:37 +0000 (14:13 -0700)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>