]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
7 months agoThe thirteenth batch
Junio C Hamano [Fri, 2 Feb 2024 18:33:01 +0000 (10:33 -0800)] 
The thirteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoMerge branch 'zf/subtree-split-fix'
Junio C Hamano [Fri, 2 Feb 2024 19:31:51 +0000 (11:31 -0800)] 
Merge branch 'zf/subtree-split-fix'

"git subtree" (in contrib/) update.

* zf/subtree-split-fix:
  subtree: fix split processing with multiple subtrees present

7 months agoMerge branch 'jc/ls-files-doc-update'
Junio C Hamano [Fri, 2 Feb 2024 19:31:51 +0000 (11:31 -0800)] 
Merge branch 'jc/ls-files-doc-update'

The documentation for the --exclude-per-directory option marked it
as deprecated, which confused readers into thinking there may be a
plan to remove it in the future, which was not our intention.

* jc/ls-files-doc-update:
  ls-files: avoid the verb "deprecate" for individual options

7 months agoMerge branch 'jk/fetch-auto-tag-following-fix'
Junio C Hamano [Fri, 2 Feb 2024 19:31:51 +0000 (11:31 -0800)] 
Merge branch 'jk/fetch-auto-tag-following-fix'

Fetching via protocol v0 over Smart HTTP transport sometimes failed
to correctly auto-follow tags.

* jk/fetch-auto-tag-following-fix:
  transport-helper: re-examine object dir after fetching

7 months agoMerge branch 'jc/coc-whitespace-fix'
Junio C Hamano [Fri, 2 Feb 2024 19:31:51 +0000 (11:31 -0800)] 
Merge branch 'jc/coc-whitespace-fix'

Docfix.

* jc/coc-whitespace-fix:
  CoC: whitespace fix

7 months agoMerge branch 'ad/custom-merge-placeholder-for-symbolic-pathnames'
Junio C Hamano [Fri, 2 Feb 2024 19:31:50 +0000 (11:31 -0800)] 
Merge branch 'ad/custom-merge-placeholder-for-symbolic-pathnames'

The labels on conflict markers for the common ancestor, our version,
and the other version are available to custom 3-way merge driver
via %S, %X, and %Y placeholders.

* ad/custom-merge-placeholder-for-symbolic-pathnames:
  merge-ll: expose revision names to custom drivers

7 months agoMerge branch 'jc/reffiles-tests'
Junio C Hamano [Fri, 2 Feb 2024 19:31:50 +0000 (11:31 -0800)] 
Merge branch 'jc/reffiles-tests'

Tests on ref API are moved around to prepare for reftable.

* jc/reffiles-tests:
  t5312: move reffiles specific tests to t0601
  t4202: move reffiles specific tests to t0600
  t3903: make drop stash test ref backend agnostic
  t1503: move reffiles specific tests to t0600
  t1415: move reffiles specific tests to t0601
  t1410: move reffiles specific tests to t0600
  t1406: move reffiles specific tests to t0600
  t1405: move reffiles specific tests to t0601
  t1404: move reffiles specific tests to t0600
  t1414: convert test to use Git commands instead of writing refs manually
  remove REFFILES prerequisite for some tests in t1405 and t2017
  t3210: move to t0601

7 months agoMerge branch 'pb/complete-log-more'
Junio C Hamano [Fri, 2 Feb 2024 19:31:50 +0000 (11:31 -0800)] 
Merge branch 'pb/complete-log-more'

The completion script (in contrib/) learned more options that can
be used with "git log".

* pb/complete-log-more:
  completion: complete missing 'git log' options
  completion: complete --encoding
  completion: complete --patch-with-raw
  completion: complete missing rev-list options

7 months agoThe twelfth batch
Junio C Hamano [Tue, 30 Jan 2024 20:33:02 +0000 (12:33 -0800)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoMerge branch 'sd/negotiate-trace-fix'
Junio C Hamano [Tue, 30 Jan 2024 21:34:12 +0000 (13:34 -0800)] 
Merge branch 'sd/negotiate-trace-fix'

Tracing fix.

* sd/negotiate-trace-fix:
  push: region_leave trace for negotiate_using_fetch

7 months agoMerge branch 'kl/allow-working-in-dot-git-in-non-bare-repository'
Junio C Hamano [Tue, 30 Jan 2024 21:34:12 +0000 (13:34 -0800)] 
Merge branch 'kl/allow-working-in-dot-git-in-non-bare-repository'

The "disable repository discovery of a bare repository" check,
triggered by setting safe.bareRepository configuration variable to
'explicit', has been loosened to exclude the ".git/" directory inside
a non-bare repository from the check.  So you can do "cd .git &&
git cmd" to run a Git command that works on a bare repository without
explicitly specifying $GIT_DIR now.

* kl/allow-working-in-dot-git-in-non-bare-repository:
  setup: allow cwd=.git w/ bareRepository=explicit

7 months agoMerge branch 'jx/remote-archive-over-smart-http'
Junio C Hamano [Tue, 30 Jan 2024 21:34:12 +0000 (13:34 -0800)] 
Merge branch 'jx/remote-archive-over-smart-http'

"git archive --remote=<remote>" learned to talk over the smart
http (aka stateless) transport.

* jx/remote-archive-over-smart-http:
  transport-helper: call do_take_over() in process_connect
  transport-helper: call do_take_over() in connect_helper
  http-backend: new rpc-service for git-upload-archive
  transport-helper: protocol v2 supports upload-archive
  remote-curl: supports git-upload-archive service
  transport-helper: no connection restriction in connect_helper

7 months agoMerge branch 'rj/advice-disable-how-to-disable'
Junio C Hamano [Tue, 30 Jan 2024 21:34:12 +0000 (13:34 -0800)] 
Merge branch 'rj/advice-disable-how-to-disable'

All conditional "advice" messages show how to turn them off, which
becomes repetitive.  Setting advice.* configuration explicitly on
now omits the instruction part.

* rj/advice-disable-how-to-disable:
  advice: allow disabling the automatic hint in advise_if_enabled()

7 months agoMerge branch 'rs/parse-options-with-keep-unknown-abbrev-fix'
Junio C Hamano [Tue, 30 Jan 2024 21:34:12 +0000 (13:34 -0800)] 
Merge branch 'rs/parse-options-with-keep-unknown-abbrev-fix'

"git diff --no-rename A B" did not disable rename detection but did
not trigger an error from the command line parser.

* rs/parse-options-with-keep-unknown-abbrev-fix:
  parse-options: simplify positivation handling
  parse-options: fully disable option abbreviation with PARSE_OPT_KEEP_UNKNOWN

7 months agoMerge branch 'pb/ci-github-skip-logs-for-broken-tests'
Junio C Hamano [Tue, 30 Jan 2024 21:34:11 +0000 (13:34 -0800)] 
Merge branch 'pb/ci-github-skip-logs-for-broken-tests'

GitHub CI update.

* pb/ci-github-skip-logs-for-broken-tests:
  ci(github): also skip logs of broken test cases

7 months agoThe eleventh batch
Junio C Hamano [Mon, 29 Jan 2024 23:26:05 +0000 (15:26 -0800)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoMerge branch 'al/t2400-depipe'
Junio C Hamano [Tue, 30 Jan 2024 00:03:00 +0000 (16:03 -0800)] 
Merge branch 'al/t2400-depipe'

Coding style fix.

* al/t2400-depipe:
  t2400: avoid losing exit status to pipes

7 months agoMerge branch 'gt/t0024-style-fixes'
Junio C Hamano [Tue, 30 Jan 2024 00:03:00 +0000 (16:03 -0800)] 
Merge branch 'gt/t0024-style-fixes'

Coding style fix.

* gt/t0024-style-fixes:
  t0024: style fix
  t0024: avoid losing exit status to pipes

7 months agoMerge branch 'en/diffcore-delta-final-line-fix'
Junio C Hamano [Tue, 30 Jan 2024 00:03:00 +0000 (16:03 -0800)] 
Merge branch 'en/diffcore-delta-final-line-fix'

Rename detection logic ignored the final line of a file if it is an
incomplete line.

* en/diffcore-delta-final-line-fix:
  diffcore-delta: avoid ignoring final 'line' of file

7 months agoMerge branch 'ps/not-so-many-refs-are-special'
Junio C Hamano [Tue, 30 Jan 2024 00:03:00 +0000 (16:03 -0800)] 
Merge branch 'ps/not-so-many-refs-are-special'

Define "special ref" as a very narrow set that consists of
FETCH_HEAD and MERGE_HEAD, and clarify everything else that used to
be classified as such are actually just pseudorefs.

* ps/not-so-many-refs-are-special:
  Documentation: add "special refs" to the glossary
  refs: redefine special refs
  refs: convert MERGE_AUTOSTASH to become a normal pseudo-ref
  sequencer: introduce functions to handle autostashes via refs
  refs: convert AUTO_MERGE to become a normal pseudo-ref
  sequencer: delete REBASE_HEAD in correct repo when picking commits
  sequencer: clean up pseudo refs with REF_NO_DEREF

7 months agoMerge branch 'js/oss-fuzz-build-in-ci'
Junio C Hamano [Tue, 30 Jan 2024 00:03:00 +0000 (16:03 -0800)] 
Merge branch 'js/oss-fuzz-build-in-ci'

oss-fuzz tests are built and run in CI.

* js/oss-fuzz-build-in-ci:
  ci: build and run minimal fuzzers in GitHub CI
  fuzz: fix fuzz test build rules

7 months agoMerge branch 'jc/majordomo-to-subspace'
Junio C Hamano [Tue, 30 Jan 2024 00:03:00 +0000 (16:03 -0800)] 
Merge branch 'jc/majordomo-to-subspace'

Doc update.

* jc/majordomo-to-subspace:
  Docs: majordomo@vger.kernel.org has been decomissioned

7 months agoMerge branch 'nb/rebase-x-shell-docfix'
Junio C Hamano [Tue, 30 Jan 2024 00:02:59 +0000 (16:02 -0800)] 
Merge branch 'nb/rebase-x-shell-docfix'

Doc update.

* nb/rebase-x-shell-docfix:
  rebase: fix documentation about used shell in -x

7 months agoMerge branch 'tc/show-ref-exists-fix'
Junio C Hamano [Tue, 30 Jan 2024 00:02:59 +0000 (16:02 -0800)] 
Merge branch 'tc/show-ref-exists-fix'

Update to a new feature recently added, "git show-ref --exists".

* tc/show-ref-exists-fix:
  builtin/show-ref: treat directory as non-existing in --exists

7 months agoMerge branch 'ps/reftable-optimize-io'
Junio C Hamano [Tue, 30 Jan 2024 00:02:59 +0000 (16:02 -0800)] 
Merge branch 'ps/reftable-optimize-io'

Low-level I/O optimization for reftable.

* ps/reftable-optimize-io:
  reftable/stack: fix race in up-to-date check
  reftable/stack: unconditionally reload stack after commit
  reftable/blocksource: use mmap to read tables
  reftable/blocksource: refactor code to match our coding style
  reftable/stack: use stat info to avoid re-reading stack list
  reftable/stack: refactor reloading to use file descriptor
  reftable/stack: refactor stack reloading to have common exit path

7 months agoThe tenth batch
Junio C Hamano [Fri, 26 Jan 2024 16:54:31 +0000 (08:54 -0800)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoMerge branch 'vd/fsck-submodule-url-test'
Junio C Hamano [Fri, 26 Jan 2024 16:54:47 +0000 (08:54 -0800)] 
Merge branch 'vd/fsck-submodule-url-test'

Tighten URL checks fsck makes in a URL recorded for submodules.

* vd/fsck-submodule-url-test:
  submodule-config.c: strengthen URL fsck check
  t7450: test submodule urls
  test-submodule: remove command line handling for check-name
  submodule-config.h: move check_submodule_url

7 months agoMerge branch 'kh/maintenance-use-xdg-when-it-should'
Junio C Hamano [Fri, 26 Jan 2024 16:54:47 +0000 (08:54 -0800)] 
Merge branch 'kh/maintenance-use-xdg-when-it-should'

When $HOME/.gitignore is missing but XDG config file available, we
should write into the latter, not former.  "git gc" and "git
maintenance" wrote into a wrong "global config" file, which have
been corrected.

* kh/maintenance-use-xdg-when-it-should:
  maintenance: use XDG config if it exists
  config: factor out global config file retrieval
  config: rename global config function
  config: format newlines

7 months agoMerge branch 'gt/test-commit-o-i-options'
Junio C Hamano [Fri, 26 Jan 2024 16:54:47 +0000 (08:54 -0800)] 
Merge branch 'gt/test-commit-o-i-options'

A few tests to "git commit -o <pathspec>" and "git commit -i
<pathspec>" has been added.

* gt/test-commit-o-i-options:
  t7501: add tests for --amend --signoff
  t7501: add tests for --include and --only

7 months agoMerge branch 'ps/gitlab-ci-macos'
Junio C Hamano [Fri, 26 Jan 2024 16:54:47 +0000 (08:54 -0800)] 
Merge branch 'ps/gitlab-ci-macos'

CI for GitLab learned to drive macOS jobs.

* ps/gitlab-ci-macos:
  ci: add macOS jobs to GitLab CI
  ci: make p4 setup on macOS more robust
  ci: handle TEST_OUTPUT_DIRECTORY when printing test failures
  Makefile: detect new Homebrew location for ARM-based Macs
  t7527: decrease likelihood of racing with fsmonitor daemon

7 months agoMerge branch 'ps/completion-with-reftable-fix'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'ps/completion-with-reftable-fix'

Completion update to prepare for reftable

* ps/completion-with-reftable-fix:
  completion: treat dangling symrefs as existing pseudorefs
  completion: silence pseudoref existence check
  completion: improve existence check for pseudo-refs
  t9902: verify that completion does not print anything
  completion: discover repo path in `__git_pseudoref_exists ()`

7 months agoMerge branch 'jt/tests-with-reftable'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'jt/tests-with-reftable'

Tweak a few tests not to manually modify the reference database
(hence easier to work with other backends like reftable).

* jt/tests-with-reftable:
  t5541: remove lockfile creation
  t1401: remove lockfile creation

7 months agoMerge branch 'la/strvec-comment-fix'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'la/strvec-comment-fix'

Comment fix.

* la/strvec-comment-fix:
  strvec: use correct member name in comments

7 months agoMerge branch 'mj/gitweb-unreadable-config-error'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'mj/gitweb-unreadable-config-error'

When given an existing but unreadable file as a configuration file,
gitweb behaved as if the file did not exist at all, but now it
errors out.  This is a change that may break backward compatibility.

* mj/gitweb-unreadable-config-error:
  gitweb: die when a configuration file cannot be read

7 months agoMerge branch 'ps/worktree-refdb-initialization'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'ps/worktree-refdb-initialization'

Instead of manually creating refs/ hierarchy on disk upon a
creation of a secondary worktree, which is only usable via the
files backend, use the refs API to populate it.

* ps/worktree-refdb-initialization:
  builtin/worktree: create refdb via ref backend
  worktree: expose interface to look up worktree by name
  builtin/worktree: move setup of commondir file earlier
  refs/files: skip creation of "refs/{heads,tags}" for worktrees
  setup: move creation of "refs/" into the files backend
  refs: prepare `refs_init_db()` for initializing worktree refs

7 months agoMerge branch 'ps/commit-graph-write-leakfix'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'ps/commit-graph-write-leakfix'

Leakfix.

* ps/commit-graph-write-leakfix:
  commit-graph: fix memory leak when not writing graph

7 months agoMerge branch 'al/unit-test-ctype'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'al/unit-test-ctype'

Move test-ctype helper to the unit-test framework.

* al/unit-test-ctype:
  unit-tests: rewrite t/helper/test-ctype.c as a unit test

7 months agoMerge branch 'ne/doc-filter-blob-limit-fix'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'ne/doc-filter-blob-limit-fix'

Docfix.

* ne/doc-filter-blob-limit-fix:
  rev-list-options: fix off-by-one in '--filter=blob:limit=<n>' explainer

7 months agoMerge branch 'rj/advice-delete-branch-not-fully-merged'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'rj/advice-delete-branch-not-fully-merged'

The error message given when "git branch -d branch" fails due to
commits unique to the branch has been split into an error and a new
conditional advice message.

* rj/advice-delete-branch-not-fully-merged:
  branch: make the advice to force-deleting a conditional one
  advice: fix an unexpected leading space
  advice: sort the advice related lists

7 months agoMerge branch 'es/some-up-to-date-messages-must-stay'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'es/some-up-to-date-messages-must-stay'

Comment updates to help developers not to attempt to modify
messages from plumbing commands that must stay constant.

It might make sense to reassess the plumbing needs every few years,
but that should be done as a separate effort.

* es/some-up-to-date-messages-must-stay:
  messages: mark some strings with "up-to-date" not to touch

7 months agosubtree: fix split processing with multiple subtrees present
Zach FettersMoore [Fri, 1 Dec 2023 14:54:54 +0000 (14:54 +0000)] 
subtree: fix split processing with multiple subtrees present

When there are multiple subtrees present in a repository and they are
all using 'git subtree split', the 'split' command can take a
significant (and constantly growing) amount of time to run even when
using the '--rejoin' flag. This is due to the fact that when processing
commits to determine the last known split to start from when looking
for changes, if there has been a split/merge done from another subtree
there will be 2 split commits, one mainline and one subtree, for the
second subtree that are part of the processing. The non-mainline
subtree split commit will cause the processing to always need to search
the entire history of the given subtree as part of its processing even
though those commits are totally irrelevant to the current subtree
split being run.

To see this in practice you can use the open source GitHub repo
'apollo-ios-dev' and do the following in order:

-Make a changes to a file in 'apollo-ios' and 'apollo-ios-codegen'
 directories
-Create a commit containing these changes
-Do a split on apollo-ios-codegen
   - Do a fetch on the subtree repo
      - git fetch git@github.com:apollographql/apollo-ios-codegen.git
   - git subtree split --prefix=apollo-ios-codegen --squash --rejoin
   - Depending on the current state of the 'apollo-ios-dev' repo
     you may see the issue at this point if the last split was on
     apollo-ios
-Do a split on apollo-ios
   - Do a fetch on the subtree repo
      - git fetch git@github.com:apollographql/apollo-ios.git
   - git subtree split --prefix=apollo-ios --squash --rejoin
-Make changes to a file in apollo-ios-codegen
-Create a commit containing the change(s)
-Do a split on apollo-ios-codegen
   - git subtree split --prefix=apollo-ios-codegen --squash --rejoin
-To see that the patch fixes the issue you can use the custom subtree
 script in the repo so following the same steps as above, except
 instead of using 'git subtree ...' for the commands use
 'git-subtree.sh ...' for the commands

You will see that the final split is looking for the last split
on apollo-ios-codegen to use as it's starting point to process
commits. Since there is a split commit from apollo-ios in between the
2 splits run on apollo-ios-codegen, the processing ends up traversing
the entire history of apollo-ios which increases the time it takes to
do a split based on how long of a history apollo-ios has, while none
of these commits are relevant to the split being done on
apollo-ios-codegen.

So this commit makes a change to the processing of commits for the
split command in order to ignore non-mainline commits from other
subtrees such as apollo-ios in the above breakdown by adding a new
function 'should_ignore_subtree_commit' which is called during
'process_split_commit'. This allows the split/rejoin processing to
still function as expected but removes all of the unnecessary
processing that takes place currently which greatly inflates the
processing time. In the above example, previously the final split
would take ~10-12 minutes, while after this fix it takes seconds.

Added a test to validate that the proposed fix
solves the issue.

The test accomplishes this by checking the output
of the split command to ensure the output from
the progress of 'process_split_commit' function
that represents the 'extracount' of commits
processed remains at 0, meaning none of the commits
from the second subtree were processed.

This was tested against the original functionality
to show the test failed, and then with this fix
to show the test passes.

This illustrated that when using multiple subtrees,
A and B, when doing a split on subtree B, the
processing does not traverse the entire history
of subtree A which is unnecessary and would cause
the 'extracount' of processed commits to climb
based on the number of commits in the history of
subtree A.

Signed-off-by: Zach FettersMoore <zach.fetters@apollographql.com>
Reviewed-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agols-files: avoid the verb "deprecate" for individual options
Junio C Hamano [Wed, 24 Jan 2024 21:10:31 +0000 (13:10 -0800)] 
ls-files: avoid the verb "deprecate" for individual options

When e750951e (ls-files: guide folks to --exclude-standard over
other --exclude* options, 2023-01-13) updated the documentation to
give greater visibility to the `--exclude-standard` option, it marked
the `--exclude-per-directory` option as "deprecated".

While it is technically correct that being deprecated does not
necessarily mean it is planned to be removed later, it seems to
cause confusion to readers, especially when we merely mean

    The option Y can be used to achieve the same thing as the option
    X much simpler. To those of you who aren't familiar with either
    X or Y, we would recommend to use Y when appropriate.

This is especially true for `--exclude-standard` vs the combination
of more granular `--exclude-from` and `--exclude-per-directory`
options.  It is true that one common combination of the granular
options can be obtained by just giving the former, but that does not
necessarily mean a more granular control is not necessary.

State the reason why we recommend readers `--exclude-standard` in
the description of `--exclude-per-directory`, instead of saying that
the option is deprecated.  Also, spell out the recipe to emulate
what `--exclude-standard` does, so that the users can give it minute
tweaks (like "do the same as Git Porcelain, except I do not want to
read the global exclusion file from core.excludes").

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agomerge-ll: expose revision names to custom drivers
Antonin Delpeuch [Wed, 24 Jan 2024 20:09:11 +0000 (20:09 +0000)] 
merge-ll: expose revision names to custom drivers

Custom merge drivers need access to the names of the revisions they
are working on, so that the merge conflict markers they introduce
can refer to those revisions. The placeholders '%S', '%X' and '%Y'
are introduced to this end.

Signed-off-by: Antonin Delpeuch <antonin@delpeuch.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agotransport-helper: re-examine object dir after fetching
Jeff King [Wed, 24 Jan 2024 01:00:56 +0000 (20:00 -0500)] 
transport-helper: re-examine object dir after fetching

This patch fixes a bug where fetch over http (or any helper) using the
v0 protocol may sometimes fail to auto-follow tags. The bug comes from
61c7711cfe (sha1-file: use loose object cache for quick existence check,
2018-11-12). But to explain why (and why this is the right fix), let's
take a step back.

After fetching a pack, the object database has changed, but we may still
hold in-memory caches that are now out of date. Traditionally this was
just the packed_git list, but 61c7711cfe started using a loose-object
cache, as well.

Usually these caches are invalidated automatically. When an expected
object cannot be found, the low-level object lookup routines call
reprepare_packed_git(), which re-scans the set of packs (and thanks to
some preparatory patches ahead of 61c7711cfe, throws away the loose
object cache). But not all calls do this! In some cases we expect that
the object might not exist, and pass OBJECT_INFO_QUICK to tell the
low-level routines not to bother re-scanning. And the tag auto-following
code is one such caller, since we are asking about oids that the other
side has (but we might not have locally).

To deal with this, we explicitly call reprepare_packed_git() ourselves
after fetching a pack; this goes all the way back to 48ec3e5c07
(Incorporate fetched packs in future object traversal, 2008-06-15). But
that only helps if we call fetch_pack() in the main fetch process. When
we're using a transport helper, it happens in a separate sub-process,
and the parent process is left with old values. So this is only a
problem with protocols which require a separate helper process (like
http).

This patch fixes it by teaching the parent process in the transport
helper relationship to make that same reprepare call after the helper
finishes fetching.

You might be left with some lingering questions, like:

  1. Why only the v0 protocol, and not v2? It's because in v2 the child
     helper doesn't actually run fetch_pack(); it merely establishes a
     tunnel over which the main process can talk to the remote side (so
     the fetch_pack() and reprepare happen in the main process).

  2. Wouldn't we have the same bug even before the 61c7711cfe added
     the loose object cache? For example, when we store the fetch as a
     pack locally, wouldn't our packed_git list still be out of date?

     If we store a pack, everything works because other parts of the
     fetch process happen to trigger a call to reprepare_packed_git().
     In particular, before storing whatever ref was originally
     requested, we'll make sure we have the pointed-to object, and that
     call happens without the QUICK flag. So in that case we'll see that
     we don't know about it, reprepare, and then repeat our lookup. And
     now we _do_ know about the pack, and further calls with QUICK will
     find its contents.

     Whereas when we unpack the result into loose objects, we never get
     that same invalidation trigger. We didn't have packs before, and we
     don't after. But when we do the loose object lookup, we find the
     object. There's no way to realize that we didn't have the object
     before the pack, and that having it now means things have changed
     (in theory we could do a superfluous cache lookup to see that it
     was missing from the old cache; but depending on the tags the other
     side showed us, we might not even have filled in that part of the
     cache earlier).

  3. Why does the included test use "--depth 1"? This is important
     because without it, we happen to invalidate the cache as a side
     effect of other parts of the fetch process. What happens in a
     non-shallow fetch is something like this:

        1. we call find_non_local_tags() once before actually getting the
           pack, to see if there are any tags we can fill in from what we
           already have. This fills in the cache (which is obviously
           missing objects we're about to fetch).

        2. before fetching the actual pack, fetch_and_consume_refs()
           calls check_exist_and_connected(), to see if we even need to
           fetch a pack at all. This doesn't use QUICK (though arguably
           it could, as it's purely an optimization). And since it sees
           there are objects we are indeed missing, that triggers a
           reprepare_packed_git() call, which throws out the loose object
           cache.

        3. after fetching, now we call find_non_local_tags() again. And
           since step (2) invalidated our loose object cache, we find
           the new objects and create the tags.

     So everything works, but mostly due to luck. Whereas in a fetch
     with --depth, we skip step 2 entirely, and thus the out-of-date
     cache is still in place for step 3, giving us the wrong answer.

So the test works with a small "--depth 1" fetch, which makes sure that
we don't store the pack from the other side, and that we don't trigger
the accidental cache invalidation. And of course it forces the use of
v0 along with using the http protocol.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoCoC: whitespace fix
Junio C Hamano [Tue, 23 Jan 2024 18:40:10 +0000 (10:40 -0800)] 
CoC: whitespace fix

Fix two lines with trailing whitespaces.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot5312: move reffiles specific tests to t0601
John Cai [Fri, 19 Jan 2024 20:19:00 +0000 (20:19 +0000)] 
t5312: move reffiles specific tests to t0601

Move a few tests into t0601 since they specifically test the packed-refs
file and thus are specific to the reffiles backend.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot4202: move reffiles specific tests to t0600
John Cai [Fri, 19 Jan 2024 20:18:59 +0000 (20:18 +0000)] 
t4202: move reffiles specific tests to t0600

Move two tests into t0600 since they write loose reflog refs manually
and thus are specific to the reffiles backend.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot3903: make drop stash test ref backend agnostic
John Cai [Fri, 19 Jan 2024 20:18:58 +0000 (20:18 +0000)] 
t3903: make drop stash test ref backend agnostic

In this test, the calls to cut(1) are only used to verify that the
contents of the reflog entry look as expected. By replacing these with
git-reflog(1) calls, we can make this test ref-backend agnostic.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot1503: move reffiles specific tests to t0600
John Cai [Fri, 19 Jan 2024 20:18:57 +0000 (20:18 +0000)] 
t1503: move reffiles specific tests to t0600

Move this test to t0600 with other reffiles specific tests since it
checks for loose refs and is specific to the reffiles backend.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot1415: move reffiles specific tests to t0601
John Cai [Fri, 19 Jan 2024 20:18:56 +0000 (20:18 +0000)] 
t1415: move reffiles specific tests to t0601

Move this test into t0601 with other reffiles pack-refs specific tests
since it checks for individual loose refs and thus is specific to the
reffiles backend.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot1410: move reffiles specific tests to t0600
John Cai [Fri, 19 Jan 2024 20:18:55 +0000 (20:18 +0000)] 
t1410: move reffiles specific tests to t0600

Move these tests to t0600 with other reffiles specific tests since they
do things like take a lock on an individual ref, and write directly into
the reflog refs.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot1406: move reffiles specific tests to t0600
John Cai [Fri, 19 Jan 2024 20:18:54 +0000 (20:18 +0000)] 
t1406: move reffiles specific tests to t0600

Move this test to t0600 with the rest of the tests that are specific to
reffiles. This test reaches into reflog directories manually, and so are
specific to reffiles.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot1405: move reffiles specific tests to t0601
John Cai [Fri, 19 Jan 2024 20:18:53 +0000 (20:18 +0000)] 
t1405: move reffiles specific tests to t0601

Move this test to t0601 with other reffiles specific pack-refs tests
since it is reffiles specific in that it looks into the loose refs
directory for an assertion.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot1404: move reffiles specific tests to t0600
John Cai [Fri, 19 Jan 2024 20:18:52 +0000 (20:18 +0000)] 
t1404: move reffiles specific tests to t0600

These tests modify loose refs manually and are specific to the reffiles
backend. Move these to t0600 to be part of a test suite of reffiles
specific tests.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot1414: convert test to use Git commands instead of writing refs manually
John Cai [Fri, 19 Jan 2024 20:18:51 +0000 (20:18 +0000)] 
t1414: convert test to use Git commands instead of writing refs manually

This test can be re-written to use Git commands rather than writing a
manual ref in the reflog. This way this test no longer needs the
REFFILES prerequisite.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoremove REFFILES prerequisite for some tests in t1405 and t2017
John Cai [Fri, 19 Jan 2024 20:18:50 +0000 (20:18 +0000)] 
remove REFFILES prerequisite for some tests in t1405 and t2017

These tests are compatible with the reftable backend and thus do not
need the REFFILES prerequisite. Even though 53af25e4
(t1405: mark test that checks existence as REFFILES, 2022-01-31) and
53af25e4 (t1405: mark test that checks existence as REFFILES,
2022-01-31) marked these tests to require REFFILES, the reftable backend
in its current state does indeed work with these tests.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot3210: move to t0601
John Cai [Fri, 19 Jan 2024 20:18:49 +0000 (20:18 +0000)] 
t3210: move to t0601

Move t3210 to t0601, since these tests are reffiles specific in that
they modify loose refs manually. This is part of the effort to
categorize these tests together based on the ref backend they test. When
we upstream the reftable backend, we can add more tests to t06xx. This
way, all tests that test specific ref backend behavior will be grouped
together.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoci(github): also skip logs of broken test cases
Philippe Blain [Sun, 21 Jan 2024 03:38:33 +0000 (03:38 +0000)] 
ci(github): also skip logs of broken test cases

When a test fails in the GitHub Actions CI pipeline, we mark it up using
special GitHub syntax so it stands out when looking at the run log. We
also mark up "fixed" test cases, and skip passing tests since we want to
concentrate on the failures.

The finalize_test_case_output function in
test-lib-github-workflow-markup.sh which performs this markup is however
missing a fourth case: "broken" tests, i.e. tests using
'test_expect_failure' to document a known bug. This leads to these
"broken" tests appearing along with any failed tests, potentially
confusing the reader who might not be aware that "broken" is the status
for 'test_expect_failure' tests that indeed failed, and wondering what
their commits "broke".

Also skip these "broken" tests so that only failures and fixed tests
stand out.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Acked-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agocompletion: complete missing 'git log' options
Philippe Blain [Sun, 21 Jan 2024 04:07:51 +0000 (04:07 +0000)] 
completion: complete missing 'git log' options

Some options specific to 'git log' are missing from the Bash completion
script. Add them to _git_log.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agocompletion: complete --encoding
Philippe Blain [Sun, 21 Jan 2024 04:07:50 +0000 (04:07 +0000)] 
completion: complete --encoding

The option --encoding is supported by 'git log' and 'git show', so add
it to __git_log_show_options.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agocompletion: complete --patch-with-raw
Philippe Blain [Sun, 21 Jan 2024 04:07:49 +0000 (04:07 +0000)] 
completion: complete --patch-with-raw

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agocompletion: complete missing rev-list options
Philippe Blain [Sun, 21 Jan 2024 04:07:48 +0000 (04:07 +0000)] 
completion: complete missing rev-list options

Some options listed in rev-list-options.txt, and thus accepted by 'git
log' and friends, are missing from the Bash completion script.

Add them to __git_log_common_options.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotransport-helper: call do_take_over() in process_connect
Jiang Xin [Sun, 21 Jan 2024 13:15:38 +0000 (21:15 +0800)] 
transport-helper: call do_take_over() in process_connect

The existing pattern among all callers of process_connect() seems to be

        if (process_connect(...)) {
                do_take_over();
                ... dispatch to the underlying method ...
        }
        ... otherwise implement the fallback ...

where the return value from process_connect() is the return value of the
call it makes to process_connect_service().

Move the call of do_take_over() inside process_connect(), so that
calling the process_connect() function is more concise and will not
miss do_take_over().

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotransport-helper: call do_take_over() in connect_helper
Jiang Xin [Sun, 21 Jan 2024 13:15:37 +0000 (21:15 +0800)] 
transport-helper: call do_take_over() in connect_helper

After successfully connecting to the smart transport by calling
process_connect_service() in connect_helper(), run do_take_over() to
replace the old vtable with a new one which has methods ready for the
smart transport connection. This fixes the exit code of git-archive
in test case "archive remote http repository" of t5003.

The connect_helper() function is used as the connect method of the
vtable in "transport-helper.c", and it is called by transport_connect()
in "transport.c" to setup a connection. The only place that we call
transport_connect() so far is in "builtin/archive.c". Without running
do_take_over(), it may fail to call transport_disconnect() in
run_remote_archiver() of "builtin/archive.c". This is because for a
stateless connection and a service like "git-upload-archive", the
remote helper may receive a SIGPIPE signal and exit early. Call
do_take_over() to have a graceful disconnect method, so that we still
call transport_disconnect() even if the remote helper exits early.

Helped-by: Linus Arver <linusa@google.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agohttp-backend: new rpc-service for git-upload-archive
Jiang Xin [Sun, 21 Jan 2024 13:15:36 +0000 (21:15 +0800)] 
http-backend: new rpc-service for git-upload-archive

Add new rpc-service "upload-archive" in http-backend to add server side
support for remote archive over HTTP/HTTPS protocols.

Also add new test cases in t5003. In the test case "archive remote http
repository", git-archive exits with a non-0 exit code even though we
create the archive correctly. It will be fixed in a later commit.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotransport-helper: protocol v2 supports upload-archive
Jiang Xin [Sun, 21 Jan 2024 13:15:35 +0000 (21:15 +0800)] 
transport-helper: protocol v2 supports upload-archive

We used to support only git-upload-pack service for protocol v2. In
order to support remote archive over HTTP/HTTPS protocols, add new
service support for git-upload-archive in protocol v2.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoremote-curl: supports git-upload-archive service
Jiang Xin [Sun, 21 Jan 2024 13:15:34 +0000 (21:15 +0800)] 
remote-curl: supports git-upload-archive service

Add new service (git-upload-archive) support in remote-curl, so we can
support remote archive over HTTP/HTTPS protocols. Differences between
git-upload-archive and other services:

 1. The git-archive program does not expect to see protocol version and
    capabilities when connecting to remote-helper, so do not send them
    in remote-curl for the git-upload-archive service.

 2. We need to detect protocol version by calling discover_refs().
    Fallback to use the git-upload-pack service (which, like
    git-upload-archive, is a read-only operation) to discover protocol
    version.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotransport-helper: no connection restriction in connect_helper
Jiang Xin [Sun, 21 Jan 2024 13:15:33 +0000 (21:15 +0800)] 
transport-helper: no connection restriction in connect_helper

When commit b236752a (Support remote archive from all smart transports,
2009-12-09) added "remote archive" support for "smart transports", it
was for transport that supports the ".connect" method. The
"connect_helper()" function protected itself from getting called for a
transport without the method before calling process_connect_service(),
which only worked with the ".connect" method.

Later, commit edc9caf7 (transport-helper: introduce stateless-connect,
2018-03-15) added a way for a transport without the ".connect" method
to establish a "stateless" connection in protocol v2, where
process_connect_service() was taught to handle the ".stateless_connect"
method, making the old protection too strict. But commit edc9caf7 forgot
to adjust this protection accordingly. Even at the time of commit
b236752a, this protection seemed redundant, since
process_connect_service() would return 0 if the connection could not be
established, and connect_helper() would still die() early.

Remove the restriction in connect_helper() and give the function
process_connect_service() the opportunity to establish a connection
using ".connect" or ".stateless_connect" for protocol v2. So we can
connect with a stateless-rpc and do something useful. E.g., in a later
commit, implements remote archive for a repository over HTTP protocol.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Linus Arver <linusa@google.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoparse-options: simplify positivation handling
René Scharfe [Sun, 21 Jan 2024 17:56:39 +0000 (18:56 +0100)] 
parse-options: simplify positivation handling

We accept the positive version of options whose long name starts with
"no-" and are defined without the flag PARSE_OPT_NONEG.  E.g. git clone
has an explicitly defined --no-checkout option and also implicitly
accepts --checkout to override it.

parse_long_opt() handles that by restarting the option matching with the
positive version when it finds that only the current option definition
starts with "no-", but not the user-supplied argument.  This code is
located almost at the end of the matching logic.

Avoid the need for a restart by moving the code up.  We don't have to
check the positive arg against the negative long_name at all -- the
"no-" prefix of the latter makes a match impossible.  Skip it and toggle
OPT_UNSET right away to simplify the control flow.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosetup: allow cwd=.git w/ bareRepository=explicit
Kyle Lippincott [Sat, 20 Jan 2024 00:08:22 +0000 (00:08 +0000)] 
setup: allow cwd=.git w/ bareRepository=explicit

The safe.bareRepository setting can be set to 'explicit' to disallow
implicit uses of bare repositories, preventing an attack [1] where an
artificial and malicious bare repository is embedded in another git
repository. Unfortunately, some tooling uses myrepo/.git/ as the cwd
when executing commands, and this is blocked when
safe.bareRepository=explicit. Blocking is unnecessary, as git already
prevents nested .git directories.

Teach git to not reject uses of git inside of the .git directory: check
if cwd is .git (or a subdirectory of it) and allow it even if
safe.bareRepository=explicit.

[1] https://github.com/justinsteven/advisories/blob/main/2022_git_buried_bare_repos_and_fsmonitor_various_abuses.md

Signed-off-by: Kyle Lippincott <spectral@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot2400: avoid losing exit status to pipes
Achu Luma [Sat, 20 Jan 2024 02:15:47 +0000 (03:15 +0100)] 
t2400: avoid losing exit status to pipes

The exit code of the preceding command in a pipe is disregarded. So
if that preceding command is a Git command that fails, the test would
not fail. Instead, by saving the output of that Git command to a file,
and removing the pipe, we make sure the test will fail if that Git
command fails.

Signed-off-by: Achu Luma <ach.lumap@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoDocs: majordomo@vger.kernel.org has been decomissioned
Junio C Hamano [Fri, 19 Jan 2024 22:26:45 +0000 (14:26 -0800)] 
Docs: majordomo@vger.kernel.org has been decomissioned

Update the instruction for subscribing to the Git mailing list
we have on a few documentation pages.

Reported-by: Kyle Lippincott <spectral@google.com>
Helped-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoparse-options: fully disable option abbreviation with PARSE_OPT_KEEP_UNKNOWN
René Scharfe [Sat, 20 Jan 2024 14:39:38 +0000 (15:39 +0100)] 
parse-options: fully disable option abbreviation with PARSE_OPT_KEEP_UNKNOWN

baa4adc66a (parse-options: disable option abbreviation with
PARSE_OPT_KEEP_UNKNOWN, 2019-01-27) turned off support for abbreviated
options when the flag PARSE_OPT_KEEP_UNKNOWN is given, as any shortened
option could also be an abbreviation for one of the unknown options.

The code for handling abbreviated options is guarded by an if, but it
can also be reached via goto.  baa4adc66a only blocked the first way.
Add the condition to the other ones as well.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot0024: style fix
Ghanshyam Thakkar [Fri, 19 Jan 2024 03:33:35 +0000 (09:03 +0530)] 
t0024: style fix

t0024 has multiple command invocations on a single line, which
goes against the style described in CodingGuidelines, thus fix
that.

Also, use the -C flag to give the destination when using $TAR,
therefore, not requiring a subshell.

Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot0024: avoid losing exit status to pipes
Ghanshyam Thakkar [Fri, 19 Jan 2024 03:33:34 +0000 (09:03 +0530)] 
t0024: avoid losing exit status to pipes

Replace pipe with redirection operator '>' to store the output
to a temporary file after 'git archive' command since the pipe
will swallow the command's exit code and a crash won't
necessarily be noticed.

Also fix an unwanted space after redirection '>' to match the
style described in CodingGuidelines.

Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoThe ninth batch
Junio C Hamano [Fri, 19 Jan 2024 22:57:34 +0000 (14:57 -0800)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'ps/p4-use-ref-api'
Junio C Hamano [Fri, 19 Jan 2024 23:04:46 +0000 (15:04 -0800)] 
Merge branch 'ps/p4-use-ref-api'

"git p4" update to prepare for reftable

* ps/p4-use-ref-api:
  git-p4: stop reaching into the refdb

8 months agoMerge branch 'cp/t4129-pipefix'
Junio C Hamano [Fri, 19 Jan 2024 23:04:46 +0000 (15:04 -0800)] 
Merge branch 'cp/t4129-pipefix'

Test update.

* cp/t4129-pipefix:
  t4129: prevent loss of exit code due to the use of pipes

8 months agoMerge branch 'sk/mingw-owner-check-error-message-improvement'
Junio C Hamano [Fri, 19 Jan 2024 23:04:46 +0000 (15:04 -0800)] 
Merge branch 'sk/mingw-owner-check-error-message-improvement'

In addition to (rather cryptic) Security Identifiers, show username
and domain in the error message when we barf on mismatch between
the Git directory and the current user on Windows.

* sk/mingw-owner-check-error-message-improvement:
  mingw: give more details about unsafe directory's ownership

8 months agoMerge branch 'bk/bisect-doc-fix'
Junio C Hamano [Fri, 19 Jan 2024 23:04:46 +0000 (15:04 -0800)] 
Merge branch 'bk/bisect-doc-fix'

Synopsis fix.

* bk/bisect-doc-fix:
  doc: refer to pathspec instead of path
  doc: use singular form of repeatable path arg

8 months agoMerge branch 'tb/fetch-all-configuration'
Junio C Hamano [Fri, 19 Jan 2024 23:04:45 +0000 (15:04 -0800)] 
Merge branch 'tb/fetch-all-configuration'

"git fetch" learned to pay attention to "fetch.all" configuration
variable, which pretends as if "--all" was passed from the command
line when no remote parameter was given.

* tb/fetch-all-configuration:
  fetch: add new config option fetch.all

8 months agoMerge branch 'rj/clarify-branch-doc-m'
Junio C Hamano [Fri, 19 Jan 2024 23:04:45 +0000 (15:04 -0800)] 
Merge branch 'rj/clarify-branch-doc-m'

Doc update.

* rj/clarify-branch-doc-m:
  branch: clarify <oldbranch> term

8 months agoMerge branch 'ps/gitlab-ci-static-analysis'
Junio C Hamano [Fri, 19 Jan 2024 23:04:45 +0000 (15:04 -0800)] 
Merge branch 'ps/gitlab-ci-static-analysis'

GitLab CI update.

* ps/gitlab-ci-static-analysis:
  ci: add job performing static analysis on GitLab CI

8 months agoMerge branch 'ps/prompt-parse-HEAD-futureproof'
Junio C Hamano [Fri, 19 Jan 2024 23:04:45 +0000 (15:04 -0800)] 
Merge branch 'ps/prompt-parse-HEAD-futureproof'

Futureproof command line prompt support (in contrib/).

* ps/prompt-parse-HEAD-futureproof:
  git-prompt: stop manually parsing HEAD with unknown ref formats

8 months agoci: build and run minimal fuzzers in GitHub CI
Josh Steadmon [Fri, 19 Jan 2024 21:38:13 +0000 (13:38 -0800)] 
ci: build and run minimal fuzzers in GitHub CI

To prevent bitrot, we would like to regularly exercise the fuzz tests in
order to make sure they still link & run properly. We already compile
the fuzz test objects as part of the default `make` target, but we do
not link the executables due to the fuzz tests needing specific
compilers and compiler features. This has lead to frequent build
breakages for the fuzz tests.

To remedy this, we can add a CI step to actually link the fuzz
executables, and run them (with finite input rather than the default
infinite random input mode) to verify that they execute properly.

Since the main use of the fuzz tests is via OSS-Fuzz [1], and OSS-Fuzz
only runs tests on Linux [2], we only set up a CI test for the fuzzers
on Linux.

[1] https://github.com/google/oss-fuzz
[2] https://google.github.io/oss-fuzz/further-reading/fuzzer-environment/

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofuzz: fix fuzz test build rules
Josh Steadmon [Fri, 19 Jan 2024 21:38:12 +0000 (13:38 -0800)] 
fuzz: fix fuzz test build rules

When we originally added the fuzz tests in 5e47215080 (fuzz: add basic
fuzz testing target., 2018-10-12), we went to some trouble to create a
Makefile rule that allowed linking the fuzz executables without pulling
in common-main.o. This was necessary to prevent the
fuzzing-engine-provided main() from clashing with Git's main().

However, since 19d75948ef (common-main.c: move non-trace2 exit()
behavior out of trace2.c, 2022-06-02), it has been necessary to link
common-main.o due to moving the common_exit() function to that file.
Ævar suggested a set of compiler flags to allow this in [1], but this
was never reflected in the Makefile.

Since we now must include common-main.o, there's no reason to pick and
choose a subset of object files to link, so simplify the Makefile rule
for the fuzzer executables to just use libgit.a. While we're at it,
include the necessary linker flag to allow multiple definitions
directly in the Makefile rule, rather than requiring it to be passed on
the command-line each time. This means the Makefile rule as written is
now more compiler-specific, but this was already the case for the
fuzzers themselves anyway.

[1] https://lore.kernel.org/git/220607.8635ggupws.gmgdl@evledraar.gmail.com/

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoDocumentation: add "special refs" to the glossary
Patrick Steinhardt [Fri, 19 Jan 2024 10:40:29 +0000 (11:40 +0100)] 
Documentation: add "special refs" to the glossary

Add the "special refs" term to our glossary.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agorefs: redefine special refs
Patrick Steinhardt [Fri, 19 Jan 2024 10:40:24 +0000 (11:40 +0100)] 
refs: redefine special refs

Now that our list of special refs really only contains refs which have
actually-special semantics, let's redefine what makes a special ref.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agorefs: convert MERGE_AUTOSTASH to become a normal pseudo-ref
Patrick Steinhardt [Fri, 19 Jan 2024 10:40:19 +0000 (11:40 +0100)] 
refs: convert MERGE_AUTOSTASH to become a normal pseudo-ref

Similar to the preceding conversion of the AUTO_MERGE pseudo-ref, let's
convert the MERGE_AUTOSTASH ref to become a normal pseudo-ref as well.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosequencer: introduce functions to handle autostashes via refs
Patrick Steinhardt [Fri, 19 Jan 2024 10:40:15 +0000 (11:40 +0100)] 
sequencer: introduce functions to handle autostashes via refs

We're about to convert the MERGE_AUTOSTASH ref to become non-special,
using the refs API instead of direct filesystem access to both read and
write the ref. The current interfaces to write autostashes is entirely
path-based though, so we need to extend them to also support writes via
the refs API instead.

Ideally, we would be able to fully replace the old set of path-based
interfaces. But the sequencer will continue to write state into
"rebase-merge/autostash". This path is not considered to be a ref at all
and will thus stay is-is for now, which requires us to keep both path-
and refs-based interfaces to handle autostashes.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agorefs: convert AUTO_MERGE to become a normal pseudo-ref
Patrick Steinhardt [Fri, 19 Jan 2024 10:40:09 +0000 (11:40 +0100)] 
refs: convert AUTO_MERGE to become a normal pseudo-ref

In 70c70de616 (refs: complete list of special refs, 2023-12-14) we have
inrtoduced a new `is_special_ref()` function that classifies some refs
as being special. The rule is that special refs are exclusively read and
written via the filesystem directly, whereas normal refs exclucsively go
via the refs API.

The intent of that commit was to record the status quo so that we know
to route reads of such special refs consistently. Eventually, the list
should be reduced to its bare minimum of refs which really are special,
namely FETCH_HEAD and MERGE_HEAD.

Follow up on this promise and convert the AUTO_MERGE ref to become a
normal pseudo-ref by using the refs API to both read and write it
instead of accessing the filesystem directly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosequencer: delete REBASE_HEAD in correct repo when picking commits
Patrick Steinhardt [Fri, 19 Jan 2024 10:40:04 +0000 (11:40 +0100)] 
sequencer: delete REBASE_HEAD in correct repo when picking commits

When picking commits, we delete some state before executing the next
sequencer action on interactive rebases. But while we use the correct
repository to calculate paths to state files that need deletion, we use
the repo-less `delete_ref()` function to delete REBASE_HEAD. Thus, if
the sequencer ran in a different repository than `the_repository`, we
would end up deleting the ref in the wrong repository.

Fix this by using `refs_delete_ref()` instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosequencer: clean up pseudo refs with REF_NO_DEREF
Patrick Steinhardt [Fri, 19 Jan 2024 10:39:59 +0000 (11:39 +0100)] 
sequencer: clean up pseudo refs with REF_NO_DEREF

When cleaning up the state-tracking pseudorefs CHERRY_PICK_HEAD or
REVERT_HEAD we do not set REF_NO_DEREF. In the unlikely case where those
refs are a symref we would thus end up deleting the symref targets, and
not the symrefs themselves.

Harden the code to use REF_NO_DEREF to fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosubmodule-config.c: strengthen URL fsck check
Victoria Dye [Thu, 18 Jan 2024 01:55:18 +0000 (01:55 +0000)] 
submodule-config.c: strengthen URL fsck check

Update the validation of "curl URL" submodule URLs (i.e. those that specify
an "http[s]" or "ftp[s]" protocol) in 'check_submodule_url()' to catch more
invalid URLs. The existing validation using 'credential_from_url_gently()'
parses certain URLs incorrectly, leading to invalid submodule URLs passing
'git fsck' checks. Conversely, 'url_normalize()' - used to validate remote
URLs in 'remote_get()' - correctly identifies the invalid URLs missed by
'credential_from_url_gently()'.

To catch more invalid cases, replace 'credential_from_url_gently()' with
'url_normalize()' followed by a 'url_decode()' and a check for newlines
(mirroring 'check_url_component()' in the 'credential_from_url_gently()'
validation).

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot7450: test submodule urls
Victoria Dye [Thu, 18 Jan 2024 01:55:17 +0000 (01:55 +0000)] 
t7450: test submodule urls

Add tests to 't7450-bad-git-dotfiles.sh' to check the validity of different
submodule URLs. To verify this directly (without setting up test
repositories & submodules), add a 'check-url' subcommand to 'test-tool
submodule' that calls 'check_submodule_url' in the same way that
'check-name' calls 'check_submodule_name'.

Add two tests to separately address cases where the URL check correctly
filters out invalid URLs and cases where the check misses invalid URLs. Mark
the latter ("url check misses invalid cases") with 'test_expect_failure' to
indicate that this is currently broken, which will be fixed in the next step.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodiffcore-delta: avoid ignoring final 'line' of file
Elijah Newren [Sat, 13 Jan 2024 04:26:13 +0000 (04:26 +0000)] 
diffcore-delta: avoid ignoring final 'line' of file

hash_chars() would hash lines to integers, and store them in a spanhash,
but cut lines at 64 characters.  Thus, whenever it reached 64 characters
or a newline, it would create a new spanhash.  The problem is, the final
part of the file might not end 64 characters after the previous 'line'
and might not end with a newline.  This could, for example, cause an
85-byte file with 12 lines and only the first character in the file
differing to appear merely 23% similar rather than the expected 97%.
Ensure the last line is included, and add a testcase that would have
caught this problem.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agomaintenance: use XDG config if it exists
Kristoffer Haugsbakk [Thu, 18 Jan 2024 16:12:52 +0000 (17:12 +0100)] 
maintenance: use XDG config if it exists

`git maintenance register` registers the repository in the user's global
config. `$XDG_CONFIG_HOME/git/config` is supposed to be used if
`~/.gitconfig` does not exist. However, this command creates a
`~/.gitconfig` file and writes to that one even though the XDG variant
exists.

This used to work correctly until 50a044f1e4 (gc: replace config
subprocesses with API calls, 2022-09-27), when the command started calling
the config API instead of git-config(1).

Also change `unregister` accordingly.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoconfig: factor out global config file retrieval
Kristoffer Haugsbakk [Thu, 18 Jan 2024 16:12:51 +0000 (17:12 +0100)] 
config: factor out global config file retrieval

Factor out code that retrieves the global config file so that we can use
it in `gc.c` as well.

Use the old name from the previous commit since this function acts
functionally the same as `git_system_config` but for “global”.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoconfig: rename global config function
Kristoffer Haugsbakk [Thu, 18 Jan 2024 16:12:50 +0000 (17:12 +0100)] 
config: rename global config function

Rename this function to a more descriptive name since we want to use the
existing name for a new function.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoconfig: format newlines
Kristoffer Haugsbakk [Thu, 18 Jan 2024 16:12:49 +0000 (17:12 +0100)] 
config: format newlines

Remove unneeded newlines according to `clang-format`.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>