]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
5 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()

5 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

5 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>
5 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

5 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()`

5 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

5 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

5 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"

5 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

5 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

5 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

5 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

5 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>
5 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

5 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

6 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>
6 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`

6 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`

6 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()

6 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

6 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

6 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

6 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 )

6 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

6 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

6 weeks 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>
6 weeks 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"

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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

6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks agoMerge branch 'jk/drop-hg-to-git'
Junio C Hamano [Thu, 28 Mar 2024 21:13:51 +0000 (14:13 -0700)] 
Merge branch 'jk/drop-hg-to-git'

Remove an ancient and not well maintained Hg-to-git migration
script from contrib/.

Acked-by: Stelian Pop <stelian@popies.net>
cf. <37e4cd61-b370-437e-bd42-f98f47d3ad32@popies.net>

* jk/drop-hg-to-git:
  contrib: drop hg-to-git script

7 weeks agoMerge branch 'rs/t-prio-queue-fixes'
Junio C Hamano [Thu, 28 Mar 2024 21:13:51 +0000 (14:13 -0700)] 
Merge branch 'rs/t-prio-queue-fixes'

Test clean-up.

* rs/t-prio-queue-fixes:
  t-prio-queue: check result array bounds
  t-prio-queue: shorten array index message

7 weeks agoMerge branch 'bt/fuzz-config-parse'
Junio C Hamano [Thu, 28 Mar 2024 21:13:51 +0000 (14:13 -0700)] 
Merge branch 'bt/fuzz-config-parse'

A new fuzz target that exercises config parsing code has been
added.

* bt/fuzz-config-parse:
  fuzz: add fuzzer for config parsing

7 weeks agoMerge branch 'jc/show-untracked-false'
Junio C Hamano [Thu, 28 Mar 2024 21:13:50 +0000 (14:13 -0700)] 
Merge branch 'jc/show-untracked-false'

The status.showUntrackedFiles configuration variable had a name
that tempts users to set a Boolean value expressed in our usual
"false", "off", and "0", but it only took "no".  This has been
corrected so "true" and its synonyms are taken as "normal", while
"false" and its synonyms are taken as "no".

* jc/show-untracked-false:
  status: allow --untracked=false and friends
  status: unify parsing of --untracked= and status.showUntrackedFiles

7 weeks agoMerge branch 'ph/diff-src-dst-prefix-config'
Junio C Hamano [Thu, 28 Mar 2024 21:13:50 +0000 (14:13 -0700)] 
Merge branch 'ph/diff-src-dst-prefix-config'

"git diff" and friends learned two extra configuration variables,
diff.srcPrefix and diff.dstPrefix.

* ph/diff-src-dst-prefix-config:
  diff.*Prefix: use camelCase in the doc and test titles
  diff: add diff.srcPrefix and diff.dstPrefix configuration variables

7 weeks agoMerge branch 'eb/hash-transition'
Junio C Hamano [Thu, 28 Mar 2024 21:13:50 +0000 (14:13 -0700)] 
Merge branch 'eb/hash-transition'

Work to support a repository that work with both SHA-1 and SHA-256
hash algorithms has started.

* eb/hash-transition: (30 commits)
  t1016-compatObjectFormat: add tests to verify the conversion between objects
  t1006: test oid compatibility with cat-file
  t1006: rename sha1 to oid
  test-lib: compute the compatibility hash so tests may use it
  builtin/ls-tree: let the oid determine the output algorithm
  object-file: handle compat objects in check_object_signature
  tree-walk: init_tree_desc take an oid to get the hash algorithm
  builtin/cat-file: let the oid determine the output algorithm
  rev-parse: add an --output-object-format parameter
  repository: implement extensions.compatObjectFormat
  object-file: update object_info_extended to reencode objects
  object-file-convert: convert commits that embed signed tags
  object-file-convert: convert commit objects when writing
  object-file-convert: don't leak when converting tag objects
  object-file-convert: convert tag objects when writing
  object-file-convert: add a function to convert trees between algorithms
  object: factor out parse_mode out of fast-import and tree-walk into in object.h
  cache: add a function to read an OID of a specific algorithm
  tag: sign both hashes
  commit: export add_header_signature to support handling signatures on tags
  ...

7 weeks agoMyFirstObjectWalk: add stderr to pipe processing
Dirk Gouders [Wed, 27 Mar 2024 11:22:16 +0000 (12:22 +0100)] 
MyFirstObjectWalk: add stderr to pipe processing

In the last chapter of this document, pipes are used in commands to
filter out the first/last trace messages.  But according to git(1),
trace messages are sent to stderr if GIT_TRACE is set to '1', so those
commands do not produce the described results.

Fix this by redirecting stderr to stdout prior to the pipe operator
to additionally connect stderr to stdin of the latter command.

Further, while reviewing the above fix, Kyle Lippincott noticed
a second issue with the second of the examples: a missing slash in the
executable path "./bin-wrappers git".

Add the missing slash.

Helped-by: Kyle Lippincott <spectral@google.com>
Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMyFirstObjectWalk: fix description for counting omitted objects
Dirk Gouders [Wed, 27 Mar 2024 11:22:15 +0000 (12:22 +0100)] 
MyFirstObjectWalk: fix description for counting omitted objects

Before the changes to count omitted objects, the function
traverse_commit_list() was used and its call cannot be changed to pass
a pointer to an oidset to record omitted objects.

Fix the text to clarify that we now use another traversal function to
be able to pass the pointer to the introduced oidset.

Helped-by: Kyle Lippincott <spectral@google.com>
Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMyFirstObjectWalk: fix filtered object walk
Dirk Gouders [Wed, 27 Mar 2024 11:22:14 +0000 (12:22 +0100)] 
MyFirstObjectWalk: fix filtered object walk

Commit f0d2f84919 (MyFirstObjectWalk: update recommended usage,
2022-03-09) changed a call of parse_list_objects_filter() in a way
that probably never worked: parse_list_objects_filter() always needed
a pointer as its first argument.

Fix this by removing the CALLOC_ARRAY and passing the address of
rev->filter to parse_list_objects_filter() in accordance to
such a call in revisions.c, for example.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMyFirstObjectWalk: fix misspelled "builtins/"
Dirk Gouders [Wed, 27 Mar 2024 11:22:13 +0000 (12:22 +0100)] 
MyFirstObjectWalk: fix misspelled "builtins/"

pack-objects.c resides in builtin/ (not builtins/).

Fix the misspelled directory name.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMyFirstObjectWalk: use additional arg in config_fn_t
Dirk Gouders [Wed, 27 Mar 2024 11:22:12 +0000 (12:22 +0100)] 
MyFirstObjectWalk: use additional arg in config_fn_t

Commit a4e7e317f8 (config: add ctx arg to config_fn_t, 2023-06-28)
added a fourth argument to config_fn_t but did not change relevant
function calls in Documentation/MyFirstObjectWalk.txt.

Fix those calls and the example git_walken_config() to use
that additional argument.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoconfig: add core.commentString
Jeff King [Wed, 27 Mar 2024 08:19:22 +0000 (04:19 -0400)] 
config: add core.commentString

The core.commentChar code recently learned to accept more than a
single ASCII character. But using it is annoying with multiple versions
of Git, since older ones will reject it outright:

    $ git.v2.44.0 -c core.commentchar=foo stripspace -s
    error: core.commentChar should only be one ASCII character
    fatal: unable to parse 'core.commentchar' from command-line config

Let's add an alias core.commentString. That's arguably a better name
anyway, since we now can handle strings, and it makes it possible to
have a config that works reasonably with both old and new versions of
Git (see the example in the documentation).

This is strictly an alias, so there's not much point in adding duplicate
tests; I added a single one to t0030 that exercises the alias code.

Note also that the error messages for invalid values will now show the
variable the config parser handed us, and thus will be normalized to
lowercase (rather than camelcase). A few tests in t0030 are adjusted to
match.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoSubmittingPatches: release-notes entry experiment
Junio C Hamano [Mon, 25 Mar 2024 22:21:45 +0000 (15:21 -0700)] 
SubmittingPatches: release-notes entry experiment

The "What's cooking" report lists the topics in flight, with a short
paragraph descibing what they are about.

Once written, the description is automatically picked up from the
"What's cooking" report and used in the commit log message of the
merge commit when the topic is merged into integration branches.
These commit log messges of the merge commits are then propagated to
the release notes.

It has been the maintainer's task to prepare these entries in the
"What's cooking" report.  Even though the original author of a topic
may be in the best position to write the initial description of a
topic, we so far lacked a formal channel for the author to suggest
what description to use.  The usual procedure has been for the
author to see the topic described in "What's cooking" report, and
then either complain about inaccurate explanation and/or offer a
rewrite.

Let's try an experiment to optionally let the author propose the one
paragraph description when the topic is submitted.  Pick the cover
letter as the logical place to do so, and describe an experimental
workflow in the SubmittingPatches document.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agocherry-pick: add `--empty` for more robust redundant commit handling
Brian Lyles [Mon, 25 Mar 2024 23:16:54 +0000 (18:16 -0500)] 
cherry-pick: add `--empty` for more robust redundant commit handling

As with git-rebase(1) and git-am(1), git-cherry-pick(1) can result in a
commit being made redundant if the content from the picked commit is
already present in the target history. However, git-cherry-pick(1) does
not have the same options available that git-rebase(1) and git-am(1) have.

There are three things that can be done with these redundant commits:
drop them, keep them, or have the cherry-pick stop and wait for the user
to take an action. git-rebase(1) has the `--empty` option added in commit
e98c4269c8 (rebase (interactive-backend): fix handling of commits that
become empty, 2020-02-15), which handles all three of these scenarios.
Similarly, git-am(1) got its own `--empty` in 7c096b8d61 (am: support
--empty=<option> to handle empty patches, 2021-12-09).

git-cherry-pick(1), on the other hand, only supports two of the three
possiblities: Keep the redundant commits via `--keep-redundant-commits`,
or have the cherry-pick fail by not specifying that option. There is no
way to automatically drop redundant commits.

In order to bring git-cherry-pick(1) more in-line with git-rebase(1) and
git-am(1), this commit adds an `--empty` option to git-cherry-pick(1). It
has the same three options (keep, drop, and stop), and largely behaves
the same. The notable difference is that for git-cherry-pick(1), the
default will be `stop`, which maintains the current behavior when the
option is not specified.

Like the existing `--keep-redundant-commits`, `--empty=keep` will imply
`--allow-empty`.

The `--keep-redundant-commits` option will be documented as a deprecated
synonym of `--empty=keep`, and will be supported for backwards
compatibility for the time being.

Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agocherry-pick: enforce `--keep-redundant-commits` incompatibility
Brian Lyles [Mon, 25 Mar 2024 23:16:53 +0000 (18:16 -0500)] 
cherry-pick: enforce `--keep-redundant-commits` incompatibility

When `--keep-redundant-commits` was added in  b27cfb0d8d
(git-cherry-pick: Add keep-redundant-commits option, 2012-04-20), it was
not marked as incompatible with the various operations needed to
continue or exit a cherry-pick (`--continue`, `--skip`, `--abort`, and
`--quit`).

Enforce this incompatibility via `verify_opt_compatible` like we do for
the other various options.

Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agosequencer: do not require `allow_empty` for redundant commit options
Brian Lyles [Mon, 25 Mar 2024 23:16:52 +0000 (18:16 -0500)] 
sequencer: do not require `allow_empty` for redundant commit options

A consumer of the sequencer that wishes to take advantage of either the
`keep_redundant_commits` or `drop_redundant_commits` feature must also
specify `allow_empty`. However, these refer to two distinct types of
empty commits:

- `allow_empty` refers specifically to commits which start empty
- `keep_redundant_commits` refers specifically to commits that do not
  start empty, but become empty due to the content already existing in
  the target history

Conceptually, there is no reason that the behavior for handling one of
these should be entangled with the other. It is particularly unintuitive
to require `allow_empty` in order for `drop_redundant_commits` to have
an effect: in order to prevent redundant commits automatically,
initially-empty commits would need to be kept automatically as well.

Instead, rewrite the `allow_empty()` logic to remove the over-arching
requirement that `allow_empty` be specified in order to reach any of the
keep/drop behaviors. Only if the commit was originally empty will
`allow_empty` have an effect.

Note that no behavioral changes should result from this commit -- it
merely sets the stage for future commits. In one such future commit, an
`--empty` option will be added to git-cherry-pick(1), meaning that
`drop_redundant_commits` will be used by that command.

Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agosequencer: handle unborn branch with `--allow-empty`
Brian Lyles [Mon, 25 Mar 2024 23:16:51 +0000 (18:16 -0500)] 
sequencer: handle unborn branch with `--allow-empty`

When using git-cherry-pick(1) with `--allow-empty` while on an unborn
branch, an error is thrown. This is inconsistent with the same
cherry-pick when `--allow-empty` is not specified.

Detect unborn branches in `is_index_unchanged`. When on an unborn
branch, use the `empty_tree` as the tree to compare against.

Add a new test to cover this scenario. While modelled off of the
existing 'cherry-pick on unborn branch' test, some improvements can be
made:

- Use `git switch --orphan unborn` instead of `git checkout --orphan
  unborn` to avoid the need for a separate `rm -rf *` call
- Avoid using `--quiet` in the `git diff` call to make debugging easier
  in the event of a failure. Use simply `--exit-code` instead.

Make these improvements to the existing test as well as the new test.

Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agorebase: update `--empty=ask` to `--empty=stop`
Brian Lyles [Mon, 25 Mar 2024 23:16:50 +0000 (18:16 -0500)] 
rebase: update `--empty=ask` to `--empty=stop`

When git-am(1) got its own `--empty` option in 7c096b8d61 (am: support
--empty=<option> to handle empty patches, 2021-12-09), `stop` was used
instead of `ask`. `stop` is a more accurate term for describing what
really happens, and consistency is good.

Update git-rebase(1) to also use `stop`, while keeping `ask` as a
deprecated synonym. Update the tests to primarily use `stop`, but also
ensure that `ask` is still allowed.

In a future commit, we'll be adding a new `--empty` option for
git-cherry-pick(1) as well, making the consistency even more relevant.

Reported-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agodocs: clean up `--empty` formatting in git-rebase(1) and git-am(1)
Brian Lyles [Mon, 25 Mar 2024 23:16:49 +0000 (18:16 -0500)] 
docs: clean up `--empty` formatting in git-rebase(1) and git-am(1)

Both of these pages document very similar `--empty` options, but with
different styles. The exact behavior of these `--empty` options differs
somewhat, but consistent styling in the docs is still beneficial. This
commit aims to make them more consistent.

Break the possible values for `--empty` into separate sections for
readability. Alphabetical order is chosen for consistency.

In a future commit, we'll be documenting a new `--empty` option for
git-cherry-pick(1), making the consistency even more relevant.

Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agodocs: address inaccurate `--empty` default with `--exec`
Brian Lyles [Mon, 25 Mar 2024 23:16:48 +0000 (18:16 -0500)] 
docs: address inaccurate `--empty` default with `--exec`

The documentation for git-rebase(1) indicates that using the `--exec`
option will use `--empty=drop`. This is inaccurate: when `--interactive`
is not explicitly provided, `--exec` results in `--empty=keep`
behaviors.

Correctly indicate the behavior of `--exec` using `--empty=keep` when
`--interactive` is not specified.

Reported-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoThe eleventh batch
Junio C Hamano [Mon, 25 Mar 2024 23:16:20 +0000 (16:16 -0700)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMerge branch 'bl/doc-key-val-sep-fix'
Junio C Hamano [Mon, 25 Mar 2024 23:16:35 +0000 (16:16 -0700)] 
Merge branch 'bl/doc-key-val-sep-fix'

The documentation for "%(trailers[:options])" placeholder in the
"--pretty" option of commands in the "git log" family has been
updated.

* bl/doc-key-val-sep-fix:
  docs: adjust trailer `separator` and `key_value_separator` language
  docs: correct trailer `key_value_separator` description

7 weeks agoMerge branch 'bl/doc-config-fixes'
Junio C Hamano [Mon, 25 Mar 2024 23:16:35 +0000 (16:16 -0700)] 
Merge branch 'bl/doc-config-fixes'

A few typoes in "git config --help" have been corrected.

* bl/doc-config-fixes:
  docs: fix typo in git-config `--default`
  docs: clarify file options in git-config `--edit`

7 weeks agoMerge branch 'ja/doc-formatting-fix'
Junio C Hamano [Mon, 25 Mar 2024 23:16:34 +0000 (16:16 -0700)] 
Merge branch 'ja/doc-formatting-fix'

Documentation mark-up fix.

* ja/doc-formatting-fix:
  doc: fix some placeholders formating
  doc: format alternatives in synopsis

7 weeks agoMerge branch 'bb/sh-scripts-cleanup'
Junio C Hamano [Mon, 25 Mar 2024 23:16:34 +0000 (16:16 -0700)] 
Merge branch 'bb/sh-scripts-cleanup'

Shell scripts clean-up.

* bb/sh-scripts-cleanup: (22 commits)
  git-quiltimport: avoid an unnecessary subshell
  contrib/coverage-diff: avoid redundant pipelines
  t/t9*: merge "grep | sed" pipelines
  t/t8*: merge "grep | sed" pipelines
  t/t5*: merge a "grep | sed" pipeline
  t/t4*: merge a "grep | sed" pipeline
  t/t3*: merge a "grep | awk" pipeline
  t/t1*: merge a "grep | sed" pipeline
  t/t9*: avoid redundant uses of cat
  t/t8*: avoid redundant use of cat
  t/t7*: avoid redundant use of cat
  t/t6*: avoid redundant uses of cat
  t/t5*: avoid redundant uses of cat
  t/t4*: avoid redundant uses of cat
  t/t3*: avoid redundant uses of cat
  t/t1*: avoid redundant uses of cat
  t/t0*: avoid redundant uses of cat
  t/perf: avoid redundant use of cat
  t/annotate-tests.sh: avoid redundant use of cat
  t/lib-cvs.sh: avoid redundant use of cat
  ...

7 weeks agoMerge branch 'jc/index-pack-fsck-levels'
Junio C Hamano [Mon, 25 Mar 2024 23:16:34 +0000 (16:16 -0700)] 
Merge branch 'jc/index-pack-fsck-levels'

Test fix.

* jc/index-pack-fsck-levels:
  t5300: fix test_with_bad_commit()

7 weeks agoMerge branch 'js/bugreport-no-suffix-fix'
Junio C Hamano [Mon, 25 Mar 2024 23:16:34 +0000 (16:16 -0700)] 
Merge branch 'js/bugreport-no-suffix-fix'

"git bugreport --no-suffix" was not supported and instead
segfaulted, which has been corrected.

* js/bugreport-no-suffix-fix:
  bugreport.c: fix a crash in `git bugreport` with `--no-suffix` option

7 weeks agoMerge branch 'rj/restore-plug-leaks'
Junio C Hamano [Mon, 25 Mar 2024 23:16:33 +0000 (16:16 -0700)] 
Merge branch 'rj/restore-plug-leaks'

Leaks from "git restore" have been plugged.

* rj/restore-plug-leaks:
  checkout: plug some leaks in git-restore

7 weeks agogrep docs: describe --no-index further and improve formatting a bit
Dragan Simic [Mon, 25 Mar 2024 20:34:53 +0000 (21:34 +0100)] 
grep docs: describe --no-index further and improve formatting a bit

Improve the description of --no-index, to make it more clear to the users
what this option actually does under the hood, and what's its purpose.
Describe the dependency between --no-index and either of the --cached and
--untracked options, which cannot be used together.

As part of that, shuffle a couple of the options, to make the documentation
flow a bit better, because it makes more sense to describe first the options
that have something in common, and to after that describe an option that does
something differently.  In more detail, --cached and --untracked both leave
git-grep(1) in the usual state, in which it treats the directory as a local
git repository, unlike --no-index that makes git-grep(1) treat the directory
not as a git repository.

While there, improve the descriptions of grep worker threads a bit, to give
them better context.  Adjust the language a bit, to avoid addressing the
reader directly, which is in general preferred in technical documentation,
because it eliminates the possible element of persuading the user to do
something.  In other words, we should be telling the user what our software
can do, instead of telling the user what to do.

Also perform some minor formatting improvements, to make it clear it's the
git commands, command parameters, and configuration option names.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agogrep docs: describe --recurse-submodules further and improve formatting a bit
Dragan Simic [Mon, 25 Mar 2024 20:34:52 +0000 (21:34 +0100)] 
grep docs: describe --recurse-submodules further and improve formatting a bit

Clarify that --recurse-submodules cannot be used together with --untracked,
and improve the formatting in a couple of places, to make it visually clear
that those are the commands or the names of configuration options.

While there, change a couple of "<tree>" placeholders to "_<tree>_", to help
with an ongoing translation improvement effort. [1]

[1] https://lore.kernel.org/git/CAPig+cQc8W4JOpB+TMP=czketU1U7wcY_x9bsP5T=3-XjGLhRQ@mail.gmail.com/

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agopretty: find pretty formats case-insensitively
Brian Lyles [Mon, 25 Mar 2024 07:25:13 +0000 (02:25 -0500)] 
pretty: find pretty formats case-insensitively

User-defined pretty formats are stored in config, which is meant to use
case-insensitive matching for names as noted in config.txt's 'Syntax'
section:

    All the other lines [...] are recognized as setting variables, in
    the form 'name = value' [...]. The variable names are
    case-insensitive, [...].

When a user specifies one of their format aliases with an uppercase in
it, however, it is not found.

    $ git config pretty.testAlias %h
    $ git config --list | grep pretty
    pretty.testalias=%h
    $ git log --format=testAlias -1
    fatal: invalid --pretty format: testAlias
    $ git log --format=testalias -1
    3c2a3fdc38

This is true whether the name in the config file uses any uppercase
characters or not.

Use case-insensitive comparisons when identifying format aliases.

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agopretty: update tests to use `test_config`
Brian Lyles [Mon, 25 Mar 2024 07:25:12 +0000 (02:25 -0500)] 
pretty: update tests to use `test_config`

These tests use raw `git config` calls, which is an older style that can
cause config to bleed between tests if not manually unset. `test_config`
ensures that config is unset at the end of each test automatically.

`test_config` is chosen over `git -c` since `test_config` still ends up
calling `git config` which seems slightly more realistic to how pretty
formats would be defined normally.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agomidx: use strvec_pushf() for pack-objects base name
René Scharfe [Sun, 24 Mar 2024 16:40:00 +0000 (17:40 +0100)] 
midx: use strvec_pushf() for pack-objects base name

Build the pack base name argument directly using strvec_pushf() instead
of with an intermediate strbuf.  This is shorter, simpler and avoids the
need for explicit cleanup.

Signed-off-by: René Scharfe <l.s.r@web.de>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agot/README: mention test files are make targets
Philippe Blain [Sun, 24 Mar 2024 15:14:05 +0000 (15:14 +0000)] 
t/README: mention test files are make targets

Since 23fc63bf8f (make tests ignorable with "make -i", 2005-11-08), each
test file defines a target in the test Makefile, such that one can
invoke:

make *checkout*

to run all tests with 'checkout' in their filename. This is useful to
run a subset of tests when you have a good idea of what part of the code
is touched by the changes your are testing.

Document that in t/README to help new (or more seasoned) contributors
that might not be aware.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agocat-file: use strbuf_expand_bad_format()
René Scharfe [Sun, 24 Mar 2024 11:21:15 +0000 (12:21 +0100)] 
cat-file: use strbuf_expand_bad_format()

Report unknown format elements and missing closing parentheses with
consistent and translated messages by calling strbuf_expand_bad_format()
at the very end of the combined if/else chain of expand_format() and
expand_atom().

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agofactor out strbuf_expand_bad_format()
René Scharfe [Sun, 24 Mar 2024 11:19:40 +0000 (12:19 +0100)] 
factor out strbuf_expand_bad_format()

Extract a function for reporting placeholders that are not enclosed in a
parenthesis or are unknown.  This reduces the number of strings to
translate and improves consistency across commands.  Call it at the end
of the if/else chain, after exhausting all accepted possibilities.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agogrep: improve errors for unmatched ( and )
Ahelenia Ziemiańska [Sat, 23 Mar 2024 13:18:08 +0000 (14:18 +0100)] 
grep: improve errors for unmatched ( and )

Imagine you want to grep for (. Easy:

  $ git grep '('
  fatal: unmatched parenthesis

uhoh. This is plainly wrong. Unless you know specifically that

 (a) git grep has expression groups and '(' ... ')' are used for them.
 (b) you can use -e '(' to explicitly say '(' is what you are looking
     for, not the beginning of a group.

Similarly,

  $ git grep ')'
  fatal: incomplete pattern expression: )

is somehow worse. ")" is a complete regular expression pattern.
Of course, the error wants to say "group" here.
In this case it is also not "incomplete", it is unmatched.

Make them say

  $ ./git grep '('
  fatal: unmatched ( for expression group
  $ ./git grep ')'
  fatal: incomplete pattern expression group: )

which are clearer in indicating that it is not the expression that
is wrong (since no pattern had been parsed at all), but rather that
it is been misconstrued as a grouping operator.

Link: https://bugs.debian.org/1051205
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agobuiltin/gc: pack refs when using `git maintenance run --auto`
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:36 +0000 (11:03 +0100)] 
builtin/gc: pack refs when using `git maintenance run --auto`

When running `git maintenance run --auto`, then the various subtasks
will only run as needed. Thus, we for example end up only packing loose
objects if we hit a certain threshold.

Interestingly enough, the "pack-refs" task is actually _never_ executed
when the auto-flag is set because it does not have a condition at all.
As 41abfe15d9 (maintenance: add pack-refs task, 2021-02-09) mentions:

    The 'auto_condition' function pointer is left NULL for now. We could
    extend this in the future to have a condition check if pack-refs
    should be run during 'git maintenance run --auto'.

It is not quite clear from that quote whether it is actually intended
that the task doesn't run at all in this mode. Also, no test was added
to verify this behaviour. Ultimately though, it feels quite surprising
that `git maintenance run --auto --task=pack-refs` would quietly never
do anything at all.

In any case, now that we do have the logic in place to let ref backends
decide whether or not to repack refs, it does make sense to wire it up
accordingly. With the "reftable" backend we will thus now perform
auto-compaction, which optimizes the refdb as needed.

But for the "files" backend we now unconditionally pack refs as it does
not yet know to handle the "auto" flag. Arguably, this can be seen as a
bug fix given that previously the task never did anything at all.
Eventually though we should amend the "files" backend to use some
heuristics for auto compaction, as well.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agobuiltin/gc: forward git-gc(1)'s `--auto` flag when packing refs
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:32 +0000 (11:03 +0100)] 
builtin/gc: forward git-gc(1)'s `--auto` flag when packing refs

Forward the `--auto` flag to git-pack-refs(1) when it has been invoked
with this flag itself. This does not change anything for the "files"
backend, which will continue to eagerly pack refs. But it does ensure
that the "reftable" backend only compacts refs as required.

This change does not impact git-maintenance(1) because this command will
in fact never run the pack-refs task when run with `--auto`. This issue
will be addressed in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agot6500: extract objects with "17" prefix
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:28 +0000 (11:03 +0100)] 
t6500: extract objects with "17" prefix

The ".git/obects/17/" shard is somewhat special because it is used by
git-gc(1) to estimate how many objects there are by extrapolating the
number of objects in that shard, only. In t6500 we thus have a hard
coded set of data that, when written to the object database, result in
blobs starting with that prefix.

We are about to need such "17"-prefixed objects in another test suite.
Extract them into "t/oid-info/hash-info" so that they can be reused by
other tests.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agobuiltin/gc: move `struct maintenance_run_opts`
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:24 +0000 (11:03 +0100)] 
builtin/gc: move `struct maintenance_run_opts`

We're about to start using `struct maintenance_run_opts` in
`maintenance_task_pack_refs()`. Move its definition up to prepare for
this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agobuiltin/pack-refs: introduce new "--auto" flag
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:20 +0000 (11:03 +0100)] 
builtin/pack-refs: introduce new "--auto" flag

Calling git-pack-refs(1) will unconditionally cause it to pack all
requested refs regardless of the current state of the ref database. For
example:

  - With the "files" backend we will end up rewriting the complete
    "packed-refs" file even if only a single ref would require
    compaction.

  - With the "reftable" backend we will end up always compacting all
    tables into a single table.

This behaviour can be completely unnecessary depending on the backend
and is thus wasteful.

With the introduction of the `PACK_REFS_AUTO` flag in the preceding
commit we can improve this and let the backends decide for themselves
whether to pack refs in the first place. Expose this functionality via a
new "--auto" flag in git-pack-refs(1), which mirrors the same flag in
both git-gc(1) and git-maintenance(1).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agobuiltin/pack-refs: release allocated memory
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:15 +0000 (11:03 +0100)] 
builtin/pack-refs: release allocated memory

Some of the command line options in `cmd_pack_refs()` require us to
allocate memory. This memory is never released and thus leaking, but we
paper over this leak by declaring the respective variables as `static`
function-level variables, which is somewhat awkward.

Refactor the code to release the allocated memory and drop the `static`
declaration. While at it, remove the useless `flags` variable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agorefs/reftable: expose auto compaction via new flag
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:11 +0000 (11:03 +0100)] 
refs/reftable: expose auto compaction via new flag

Under normal circumstances, the "reftable" backend will automatically
perform compaction after appending to the stack. It is thus not
necessary and may even be considered wasteful to run git-pack-refs(1) in
"reftable"-backed repositories as it will cause the backend to compact
all tables into a single one. We do exactly that though when running
`git maintenance run --auto` or `git gc --auto`, which gets spawned by
Git after running some specific commands.

The `--auto` mode is typically only executing optimizations as needed.
To do so, we already use several heuristics for the various different
data structures in Git to determine whether to optimize them or not.
We do not use any heuristics for refs though and instead always optimize
them.

Introduce a new `PACK_REFS_AUTO` flag that can be passed to the backend.
When not handled by the backend we will continue to behave the exact
same as we do right now, that is we optimize refs unconditionally. This
is done for the "files" backend for now to retain current behaviour,
even though we may eventually also want to introduce heuristics here.
For the "reftable" backend though we already do have auto-compaction, so
we can easily reuse that logic to implement the new auto-packing flag.

Note that under normal circumstances, this should always end up being a
no-op. After all, we already invoke the code for every single addition
to the stack. But there are special cases where it can still be helpful
to execute the auto-compaction code explicitly:

  - Concurrent writers may cause compaction to not run due to locks.

  - Callers may decide to disable compaction altogether and then pack
    refs at a later point due to various reasons.

  - Other implementations of the reftable format may do compaction
    differently or even not at all.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agorefs: remove `PACK_REFS_ALL` flag
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:07 +0000 (11:03 +0100)] 
refs: remove `PACK_REFS_ALL` flag

The intent of the `PACK_REFS_ALL` flag is to ask the backend to compact
all refs instead of only a subset of them. Thus, this flag gets passed
down to `refs_pack_refs()` via `struct pack_refs_opts::flags`.

But starting with 4fe42f326e (pack-refs: teach pack-refs --include
option, 2023-05-12), the flag's semantics have changed. Instead of being
handled by the respective backends, this flag is now getting handled by
the callers of `refs_pack_refs()` which will add a single glob ("*") to
the list of refs-to-be-packed. Thus, the flag serves no purpose to the
ref backends anymore.

Remove the flag and replace it with a local variable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agorefs: move `struct pack_refs_opts` to where it's used
Patrick Steinhardt [Mon, 25 Mar 2024 10:03:03 +0000 (11:03 +0100)] 
refs: move `struct pack_refs_opts` to where it's used

The declaration of `struct pack_refs_opts` is in a seemingly random
place. Move it so that it's located right next to its flags and
functions that use it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agot/helper: drop pack-refs wrapper
Patrick Steinhardt [Mon, 25 Mar 2024 10:02:59 +0000 (11:02 +0100)] 
t/helper: drop pack-refs wrapper

The test helper provides a "ref-store <store> pack-refs" wrapper that
more or less directly invokes `refs_pack_refs()`. This helper is only
used in a single test with the "PACK_REFS_PRUNE" and "PACK_REFS_ALL"
flags. Both of these flags can directly be accessed via git-pack-refs(1)
though via the `--all` and `--prune` flags, which makes the helper
superfluous.

Refactor the test to use git-pack-refs(1) instead of the test helper.
Drop the now-unused test helper command.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agorefs/reftable: print errors on compaction failure
Patrick Steinhardt [Mon, 25 Mar 2024 10:02:54 +0000 (11:02 +0100)] 
refs/reftable: print errors on compaction failure

When git-pack-refs(1) fails in the reftable backend we end up printing
no error message at all, leaving the caller puzzled as to why compaction
has failed. Fix this.

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