Commit graph

72276 commits

Author SHA1 Message Date
Patrick Steinhardt 5e01d83841 refs: always treat iterators as ordered
In the preceding commit we have converted the reflog iterator of the
"files" backend to be ordered, which was the only remaining ref iterator
that wasn't ordered. Refactor the ref iterator infrastructure so that we
always assume iterators to be ordered, thus simplifying the code.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:06 -08:00
Patrick Steinhardt 6f22780017 refs/files: sort merged worktree and common reflogs
When iterating through reflogs in a worktree we create a merged iterator
that merges reflogs from both refdbs. The resulting refs are ordered so
that instead we first return all worktree reflogs before we return all
common refs.

This is the only remaining case where a ref iterator returns entries in
a non-lexicographic order. The result would look something like the
following (listed with a command we introduce in a subsequent commit):

```
$ git reflog list
HEAD
refs/worktree/per-worktree
refs/heads/main
refs/heads/wt
```

So we first print the per-worktree reflogs in lexicographic order, then
the common reflogs in lexicographic order. This is confusing and not
consistent with how we print per-worktree refs, which are exclusively
sorted lexicographically.

Sort reflogs lexicographically in the same way as we sort normal refs.
As this is already implemented properly by the "reftable" backend via a
separate selection function, we simply pull out that logic and reuse it
for the "files" backend. As logs are properly sorted now, mark the
merged reflog iterator as sorted.

Tests will be added in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:06 -08:00
Patrick Steinhardt e69e8ffef7 refs/files: sort reflogs returned by the reflog iterator
We use a directory iterator to return reflogs via the reflog iterator.
This iterator returns entries in the same order as readdir(3P) would and
will thus yield reflogs with no discernible order.

Set the new `DIR_ITERATOR_SORTED` flag that was introduced in the
preceding commit so that the order is deterministic. While the effect of
this can only been observed in a test tool, a subsequent commit will
start to expose this functionality to users via a new `git reflog list`
subcommand.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:05 -08:00
Patrick Steinhardt de34f2651e dir-iterator: support iteration in sorted order
The `struct dir_iterator` is a helper that allows us to iterate through
directory entries. This iterator returns entries in the exact same order
as readdir(3P) does -- or in other words, it guarantees no specific
order at all.

This is about to become problematic as we are introducing a new reflog
subcommand to list reflogs. As the "files" backend uses the directory
iterator to enumerate reflogs, returning reflog names and exposing them
to the user would inherit the indeterministic ordering. Naturally, it
would make for a terrible user interface to show a list with no
discernible order.

While this could be handled at a higher level by the new subcommand
itself by collecting and ordering the reflogs, this would be inefficient
because we would first have to collect all reflogs before we can sort
them, which would introduce additional latency when there are many
reflogs.

Instead, introduce a new option into the directory iterator that asks
for its entries to be yielded in lexicographical order. If set, the
iterator will read all directory entries greedily and sort them before
we start to iterate over them.

While this will of course also incur overhead as we cannot yield the
directory entries immediately, it should at least be more efficient than
having to sort the complete list of reflogs as we only need to sort one
directory at a time.

This functionality will be used in a follow-up commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:05 -08:00
Patrick Steinhardt 0218de2bdb dir-iterator: pass name to prepare_next_entry_data() directly
When adding the next directory entry for `struct dir_iterator` we pass
the complete `struct dirent *` to `prepare_next_entry_data()` even
though we only need the entry's name.

Refactor the code to pass in the name, only. This prepares for a
subsequent commit where we introduce the ability to iterate through
dir entries in an ordered manner.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:05 -08:00
Junio C Hamano f7cdeafdd0 Merge branch 'ps/reftable-backend' into ps/reflog-list
* ps/reftable-backend:
  refs/reftable: fix leak when copying reflog fails
  ci: add jobs to test with the reftable backend
  refs: introduce reftable backend
2024-02-19 10:50:07 -08:00
Junio C Hamano edae91a4cf Git 2.44-rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-13 15:12:53 -08:00
Junio C Hamano efb050becb Git 2.43.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-13 14:44:51 -08:00
Junio C Hamano dc55772259 Merge branch 'pb/template-for-single-commit-pr' into maint-2.43
Doc update.

* pb/template-for-single-commit-pr:
  .github/PULL_REQUEST_TEMPLATE.md: add a note about single-commit PRs
2024-02-13 14:44:51 -08:00
Junio C Hamano 1e73351fef Merge branch 'jc/bisect-doc' into maint-2.43
Doc update.

* jc/bisect-doc:
  bisect: document command line arguments for "bisect start"
  bisect: document "terms" subcommand more fully
2024-02-13 14:44:51 -08:00
Junio C Hamano 8d792dcd5a Merge branch 'js/win32-retry-pipe-write-on-enospc' into maint-2.43
Update to the code that writes to pipes on Windows.

* js/win32-retry-pipe-write-on-enospc:
  win32: special-case `ENOSPC` when writing to a pipe
2024-02-13 14:44:51 -08:00
Junio C Hamano 08b7e46bb1 Merge branch 'tb/pack-bitmap-drop-unused-struct-member' into maint-2.43
Code clean-up.

* tb/pack-bitmap-drop-unused-struct-member:
  pack-bitmap: drop unused `reuse_objects`
2024-02-13 14:44:51 -08:00
Junio C Hamano 8f1c4a7db1 Merge branch 'jt/p4-spell-re-with-raw-string' into maint-2.43
"git p4" update to squelch warnings from Python.

* jt/p4-spell-re-with-raw-string:
  git-p4: use raw string literals for regular expressions
2024-02-13 14:44:50 -08:00
Junio C Hamano b6fdf929ee Merge branch 'jc/coc-whitespace-fix' into maint-2.43
Docfix.

* jc/coc-whitespace-fix:
  CoC: whitespace fix
2024-02-13 14:44:50 -08:00
Junio C Hamano 81e3eea77c Merge branch 'sd/negotiate-trace-fix' into maint-2.43
Tracing fix.

* sd/negotiate-trace-fix:
  push: region_leave trace for negotiate_using_fetch
2024-02-13 14:44:50 -08:00
Junio C Hamano 05a961754e Merge branch 'jc/majordomo-to-subspace' into maint-2.43
Doc update.

* jc/majordomo-to-subspace:
  Docs: majordomo@vger.kernel.org has been decomissioned
2024-02-13 14:44:50 -08:00
Junio C Hamano f2e7998613 Merge branch 'nb/rebase-x-shell-docfix' into maint-2.43
Doc update.

* nb/rebase-x-shell-docfix:
  rebase: fix documentation about used shell in -x
2024-02-13 14:44:49 -08:00
Junio C Hamano 2928250218 Merge branch 'la/strvec-comment-fix' into maint-2.43
Comment fix.

* la/strvec-comment-fix:
  strvec: use correct member name in comments
2024-02-13 14:44:49 -08:00
Junio C Hamano 5193aee2a3 Merge branch 'ne/doc-filter-blob-limit-fix' into maint-2.43
Docfix.

* ne/doc-filter-blob-limit-fix:
  rev-list-options: fix off-by-one in '--filter=blob:limit=<n>' explainer
2024-02-13 14:44:49 -08:00
Junio C Hamano 7687ca5a90 Merge branch 'cp/git-flush-is-an-env-bool' into maint-2.43
Recent conversion to allow more than 0/1 in GIT_FLUSH broke the
mechanism by flipping what yes/no means by mistake, which has been
corrected.

* cp/git-flush-is-an-env-bool:
  write-or-die: fix the polarity of GIT_FLUSH environment variable
2024-02-13 14:44:49 -08:00
Junio C Hamano bd10c45672 Merge branch 'ps/report-failure-from-git-stash' into maint-2.43
"git stash" sometimes was silent even when it failed due to
unwritable index file, which has been corrected.

* ps/report-failure-from-git-stash:
  builtin/stash: report failure to write to index
2024-02-13 14:44:49 -08:00
Junio C Hamano 07fa383615 Merge branch 'jc/sign-buffer-failure-propagation-fix' into maint-2.43
A failed "git tag -s" did not necessarily result in an error
depending on the crypto backend, which has been corrected.

* jc/sign-buffer-failure-propagation-fix:
  ssh signing: signal an error with a negative return value
  tag: fix sign_buffer() call to create a signed tag
2024-02-13 14:44:48 -08:00
Junio C Hamano a1cd814f1f Merge branch 'jc/comment-style-fixes' into maint-2.43
Rewrite //-comments to /* comments */ in files whose comments
prevalently use the latter.

* jc/comment-style-fixes:
  reftable/pq_test: comment style fix
  merge-ort.c: comment style fix
  builtin/worktree: comment style fixes
2024-02-13 14:44:48 -08:00
Junio C Hamano 5071cb78a3 Merge branch 'jk/diff-external-with-no-index' into maint-2.43
"git diff --no-index file1 file2" segfaulted while invoking the
external diff driver, which has been corrected.

* jk/diff-external-with-no-index:
  diff: handle NULL meta-info when spawning external diff
2024-02-13 14:44:48 -08:00
Junio C Hamano d982de5d32 Merge branch 'rs/parse-options-with-keep-unknown-abbrev-fix' into maint-2.43
"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
2024-02-13 14:44:48 -08:00
Junio C Hamano 904ca69428 Merge branch 'en/diffcore-delta-final-line-fix' into maint-2.43
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
2024-02-13 14:44:48 -08:00
Junio C Hamano 908fde12b0 Merge branch 'tc/show-ref-exists-fix' into maint-2.43
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
2024-02-13 14:44:47 -08:00
Junio C Hamano 4cde9f0726 A few more fixes before -rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-13 14:31:12 -08:00
Junio C Hamano 4abab9e51a Merge branch 'cp/git-flush-is-an-env-bool'
Recent conversion to allow more than 0/1 in GIT_FLUSH broke the
mechanism by flipping what yes/no means by mistake, which has been
corrected.

* cp/git-flush-is-an-env-bool:
  write-or-die: fix the polarity of GIT_FLUSH environment variable
2024-02-13 14:31:12 -08:00
Junio C Hamano 9115864cb5 Merge branch 'jc/unit-tests-make-relative-fix'
The mechanism to report the filename in the source code, used by
the unit-test machinery, assumed that the compiler expanded __FILE__
to the path to the source given to the $(CC), but some compilers
give full path, breaking the output.  This has been corrected.

* jc/unit-tests-make-relative-fix:
  unit-tests: do show relative file paths on non-Windows, too
2024-02-13 14:31:11 -08:00
Junio C Hamano c2914d4677 Merge branch 'js/github-actions-update'
Update remaining GitHub Actions jobs to avoid warnings against
using deprecated version of Node.js.

* js/github-actions-update:
  ci(linux32): add a note about Actions that must not be updated
  ci: bump remaining outdated Actions versions
2024-02-13 14:31:11 -08:00
Junio C Hamano 133a7b08dc Merge branch 'jc/github-actions-update'
Squelch node.js 16 deprecation warnings from GitHub Actions CI
by updating actions/github-script and actions/checkout that use
node.js 20.

* jc/github-actions-update:
  GitHub Actions: update to github-script@v7
  GitHub Actions: update to checkout@v4
2024-02-13 14:31:11 -08:00
Junio C Hamano b40ba17e44 write-or-die: fix the polarity of GIT_FLUSH environment variable
When GIT_FLUSH is set to 1, true, on, yes, then we should disable
skip_stdout_flush, but the conversion somehow did the opposite.

With the understanding of the original motivation behind "skip" in
06f59e9f (Don't fflush(stdout) when it's not helpful, 2007-06-29),
we can sympathize with the current naming (we wanted to avoid
useless flushing of stdout by default, with an escape hatch to
always flush), but it is still not a good excuse.

Retire the "skip_stdout_flush" variable and replace it with "flush_stdout"
that tells if we do or do not want to run fflush().

Reported-by: Xiaoguang WANG <wxiaoguang@gmail.com>
Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-13 11:57:28 -08:00
Junio C Hamano 2996f11c1d Sync with 'maint' 2024-02-12 13:17:06 -08:00
Junio C Hamano ad1a669545 A few more topics before -rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-12 13:16:12 -08:00
Junio C Hamano 3b89ff16aa Merge branch 'tb/multi-pack-reuse-experiment'
Setting `feature.experimental` opts the user into multi-pack reuse
experiment

* tb/multi-pack-reuse-experiment:
  pack-objects: enable multi-pack reuse via `feature.experimental`
  t5332-multi-pack-reuse.sh: extract pack-objects helper functions
2024-02-12 13:16:11 -08:00
Junio C Hamano d4833b22ab Merge branch 'vd/for-each-ref-sort-with-formatted-timestamp'
"git branch" and friends learned to use the formatted text as
sorting key, not the underlying timestamp value, when the --sort
option is used with author or committer timestamp with a format
specifier (e.g., "--sort=creatordate:format:%H:%M:%S").

* vd/for-each-ref-sort-with-formatted-timestamp:
  ref-filter.c: sort formatted dates by byte value
2024-02-12 13:16:11 -08:00
Junio C Hamano b3370dd51e Merge branch 'pw/show-ref-pseudorefs'
"git show-ref --verify" did not show things like "CHERRY_PICK_HEAD",
which has been corrected.

* pw/show-ref-pseudorefs:
  t1400: use show-ref to check pseudorefs
  show-ref --verify: accept pseudorefs
2024-02-12 13:16:11 -08:00
Junio C Hamano 70550a2242 Merge branch 'ps/report-failure-from-git-stash'
"git stash" sometimes was silent even when it failed due to
unwritable index file, which has been corrected.

* ps/report-failure-from-git-stash:
  builtin/stash: report failure to write to index
2024-02-12 13:16:11 -08:00
Junio C Hamano 32c5ab6ee4 Merge branch 'pb/template-for-single-commit-pr'
Doc update.

* pb/template-for-single-commit-pr:
  .github/PULL_REQUEST_TEMPLATE.md: add a note about single-commit PRs
2024-02-12 13:16:11 -08:00
Junio C Hamano 05c5a6db80 Merge branch 'jc/sign-buffer-failure-propagation-fix'
A failed "git tag -s" did not necessarily result in an error
depending on the crypto backend, which has been corrected.

* jc/sign-buffer-failure-propagation-fix:
  ssh signing: signal an error with a negative return value
  tag: fix sign_buffer() call to create a signed tag
2024-02-12 13:16:11 -08:00
Junio C Hamano 13fdf82e09 Merge branch 'jc/bisect-doc'
Doc update.

* jc/bisect-doc:
  bisect: document command line arguments for "bisect start"
  bisect: document "terms" subcommand more fully
2024-02-12 13:16:10 -08:00
Junio C Hamano 46761378c3 Merge branch 'bk/complete-bisect'
Command line completion support (in contrib/) has been
updated for "git bisect".

* bk/complete-bisect:
  completion: bisect: recognize but do not complete view subcommand
  completion: bisect: complete log opts for visualize subcommand
  completion: new function __git_complete_log_opts
  completion: bisect: complete missing --first-parent and - -no-checkout options
  completion: bisect: complete custom terms and related options
  completion: bisect: complete bad, new, old, and help subcommands
  completion: tests: always use 'master' for default initial branch name
2024-02-12 13:16:10 -08:00
Junio C Hamano f424d7c33d Merge branch 'ps/reftable-styles'
Code clean-up in various reftable code paths.

* ps/reftable-styles:
  reftable/record: improve semantics when initializing records
  reftable/merged: refactor initialization of iterators
  reftable/merged: refactor seeking of records
  reftable/stack: use `size_t` to track stack length
  reftable/stack: use `size_t` to track stack slices during compaction
  reftable/stack: index segments with `size_t`
  reftable/stack: fix parameter validation when compacting range
  reftable: introduce macros to allocate arrays
  reftable: introduce macros to grow arrays
2024-02-12 13:16:10 -08:00
Junio C Hamano cf4a3bd8f1 Merge branch 'ps/reftable-multi-level-indices-fix'
Write multi-level indices for reftable has been corrected.

* ps/reftable-multi-level-indices-fix:
  reftable: document reading and writing indices
  reftable/writer: fix writing multi-level indices
  reftable/writer: simplify writing index records
  reftable/writer: use correct type to iterate through index entries
  reftable/reader: be more careful about errors in indexed seeks
2024-02-12 13:16:10 -08:00
Junio C Hamano 7adf215fed Merge branch 'pb/imap-send-wo-curl-build-fix' into maint-2.43
* pb/imap-send-wo-curl-build-fix:
  imap-send: add missing "strbuf.h" include under NO_CURL
2024-02-12 09:57:59 -08:00
Johannes Schindelin 20e0ff8835 ci(linux32): add a note about Actions that must not be updated
The Docker container used by the `linux32` job comes without Node.js,
and therefore the `actions/checkout` and `actions/upload-artifact`
Actions cannot be upgraded to the latest versions (because they use
Node.js).

One time too many, I accidentally tried to update them, where
`actions/checkout` at least fails immediately, but the
`actions/upload-artifact` step is only used when any test fails, and
therefore the CI run usually passes even though that Action was updated
to a version that is incompatible with the Docker container in which
this job runs.

So let's add a big fat warning, mainly for my own benefit, to avoid
running into the very same issue over and over again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-12 08:48:22 -08:00
Johannes Schindelin 820a340085 ci: bump remaining outdated Actions versions
After activating automatic Dependabot updates in the
git-for-windows/git repository, Dependabot noticed a couple
of yet-unaddressed updates.  They avoid "Node.js 16 Actions"
deprecation messages by bumping the following Actions'
versions:

- actions/upload-artifact from 3 to 4
- actions/download-artifact from 3 to 4
- actions/cache from 3 to 4

Helped-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-12 08:47:38 -08:00
Junio C Hamano f66286364f unit-tests: do show relative file paths on non-Windows, too
There are compilers other than Visual C that want to show absolute
paths.  Generalize the helper introduced by a2c5e294 (unit-tests: do
show relative file paths, 2023-09-25) so that it can also work with
a path that uses slash as the directory separator, and becomes
almost no-op once one-time preparation finds out that we are using a
compiler that already gives relative paths.  Incidentally, this also
should do the right thing on Windows with a compiler that shows
relative paths but with backslash as the directory separator (if
such a thing exists and is used to build git).

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-12 08:44:22 -08:00
Junio C Hamano c875e0b8e0 Git 2.44-rc0
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-08 16:35:07 -08:00