Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c3cf8e5
fetch: extract out reference committing logic
KarthikNayak Nov 21, 2025
dd8e8c7
submodule add: sanity check existing .gitmodules
gitster Nov 16, 2025
dc8a00f
completion: clarify support for short options and arguments
gitster Dec 7, 2025
8ff2eef
fetch: fix non-conflicting tags not being committed
KarthikNayak Nov 21, 2025
b7b17ec
fetch: fix failed batched updates skipping operations
KarthikNayak Nov 21, 2025
af0ed97
Merge branch 'tc/last-modified-active-paths-optimization' into tc/mem…
gitster Dec 11, 2025
a67b902
git-compat-util: introduce MEMZERO_ARRAY() macro
To1ne Dec 10, 2025
467860b
contrib/coccinelle: pass include paths to spatch(1)
To1ne Dec 10, 2025
48695fc
scalar: annotate config file with "set by scalar"
derrickstolee Dec 12, 2025
05f28e4
scalar: use index.skipHash=true for performance
derrickstolee Dec 12, 2025
be667e4
scalar: remove stale config values
derrickstolee Dec 12, 2025
e1588c2
scalar: alphabetize and simplify config
derrickstolee Dec 12, 2025
6362c9c
Merge branch 'tc/memzero-array' into jc/memzero-array
gitster Dec 13, 2025
d2e4099
coccicheck: emit the contents of cocci patch
gitster Dec 13, 2025
8ea9492
cocci: use MEMZERO_ARRAY() a bit more
gitster Dec 13, 2025
4ce170c
scalar: document config settings
derrickstolee Dec 12, 2025
c0c4dc0
Merge branch 'rs/diff-index-find-copies-harder-optim' into rs/diff-fi…
gitster Dec 16, 2025
f293bdc
diff-files: fix copy detection
rscharfe Dec 14, 2025
f0c063b
Merge branch 'ds/doc-scalar-config'
gitster Dec 23, 2025
00bf98b
Merge branch 'jc/submodule-add'
gitster Dec 23, 2025
c77ba76
Merge branch 'jc/completion-no-single-letter-options'
gitster Dec 23, 2025
396df67
Merge branch 'tc/memzero-array'
gitster Dec 23, 2025
86ebd83
Merge branch 'jc/memzero-array'
gitster Dec 23, 2025
5d2be74
Merge branch 'rs/diff-files-r-find-copies-fix'
gitster Dec 23, 2025
d800078
Merge branch 'kn/fix-fetch-backfill-tag-with-batched-ref-updates'
gitster Dec 23, 2025
66ce5f8
The 12th batch
gitster Dec 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Documentation/RelNotes/2.53.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ Performance, Internal Implementation, Development Support etc.
and Stop using the insecure "mktemp()" function.
(merge 10bba537c4 rs/ban-mktemp later to maint).

* In-code comment update to clarify that single-letter options are
outside of the scope of command line completion script.
(merge dc8a00fafe jc/completion-no-single-letter-options later to maint).

* MEMZERO_ARRAY() helper is introduced to avoid clearing only the
first N bytes of an N-element array whose elements are larger than
a byte.

* "git diff-files -R --find-copies-harder" has been taught to use
the potential copy sources from the index correctly.


Fixes since v2.52
-----------------
Expand Down Expand Up @@ -177,6 +188,17 @@ Fixes since v2.52
* Emulation code clean-up.
(merge 42aa7603aa gf/win32-pthread-cond-init later to maint).

* "git submodule add" to add a submodule under <name> segfaulted,
when a submodule.<name>.something is already in .gitmodules file
without defining where its submodule.<name>.path is, which has been
corrected.
(merge dd8e8c786e jc/submodule-add later to maint).

* "git fetch" that involves fetching tags, when a tag being fetched
needs to overwrite existing one, failed to fetch other tags, which
has been corrected.
(merge b7b17ec8a6 kn/fix-fetch-backfill-tag-with-batched-ref-updates later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge 46207a54cc qj/doc-http-bad-want-response later to maint).
(merge df90eccd93 kh/doc-commit-extra-references later to maint).
Expand All @@ -191,3 +213,4 @@ Fixes since v2.52
(merge d4b732899e jc/macports-darwinports later to maint).
(merge bab391761d kj/pull-options-decl-cleanup later to maint).
(merge 007b8994d4 rs/t4014-git-version-string-fix later to maint).
(merge 4ce170c522 ds/doc-scalar-config later to maint).
164 changes: 164 additions & 0 deletions Documentation/scalar.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,170 @@ delete <enlistment>::
This subcommand lets you delete an existing Scalar enlistment from your
local file system, unregistering the repository.

RECOMMENDED CONFIG VALUES
-------------------------

As part of both `scalar clone` and `scalar register`, certain Git config
values are set to optimize for large repositories or cross-platform support.
These options are updated in new Git versions according to the best known
advice for large repositories, and users can get the latest recommendations
by running `scalar reconfigure [--all]`.

This section lists justifications for the config values that are set in the
latest version.

am.keepCR=true::
This setting is important for cross-platform development across Windows
and non-Windows platforms and keeping carriage return (`\r`) characters
in certain workflows.

commitGraph.changedPaths=true::
This setting helps the background maintenance steps that compute the
serialized commit-graph to also store changed-path Bloom filters. This
accelerates file history commands and allows users to automatically
benefit without running a foreground command.

commitGraph.generationVersion=1::
While the preferred version is 2 for performance reasons, existing users
that had version 1 by default will need special care in upgrading to
version 2. This is likely to change in the future as the upgrade story
solidifies.

core.autoCRLF=false::
This removes the transformation of worktree files to add CRLF line
endings when only LF line endings exist. This is removed for performance
reasons. Repositories that use tools that care about CRLF line endings
should commit the necessary files with those line endings instead.

core.logAllRefUpdates=true::
This enables the reflog on all branches. While this is a performance
cost for large repositories, it is frequently an important data source
for users to get out of bad situations or to seek support from experts.

core.safeCRLF=false::
Similar to `core.autoCRLF=false`, this disables checks around whether
the CRLF conversion is reversible. This is a performance improvement,
but can be dangerous if `core.autoCRLF` is reenabled by the user.

credential.https://dev.azure.com.useHttpPath=true::
This setting enables the `credential.useHttpPath` feature only for web
URLs for Azure DevOps. This is important for users interacting with that
service using multiple organizations and thus multiple credential
tokens.

feature.experimental=false::
This disables the "experimental" optimizations grouped under this
feature config. The expectation is that all valuable optimizations are
also set explicitly by Scalar config, and any differences are
intentional. Notable differences include several bitmap-related config
options which are disabled for client-focused Scalar repos.

feature.manyFiles=false::
This disables the "many files" optimizations grouped under this feature
config. The expectation is that all valuable optimizations are also set
explicitly by Scalar config, and any differences are intentional.

fetch.showForcedUpdates=false::
This disables the check at the end of `git fetch` that notifies the user
if the ref update was a forced update (one where the previous position
is not reachable from the latest position). This check can be very
expensive in large repositories, so is disabled and replaced with an
advice message. Set `advice.fetchShowForcedUpdates=false` to disable
this advice message.

fetch.unpackLimit=1::
This setting prevents Git from unpacking packfiles into loose objects
as they are downloaded from the server. The default limit of 100 was
intended as a way to prevent performance issues from too many packfiles,
but Scalar uses background maintenance to group packfiles and cover them
with a multi-pack-index, removing this issue.

fetch.writeCommitGraph=false::
This config setting was created to help users automatically update their
commit-graph files as they perform fetches. However, this takes time
from foreground fetches and pulls and Scalar uses background maintenance
for this function instead.

gc.auto=0::
This disables automatic garbage collection, since Scalar uses background
maintenance to keep the repository data in good shape.

gui.GCWarning=false::
Since Scalar disables garbage collection by setting `gc.auto=0`, the
`git-gui` tool may start to warn about this setting. Disable this
warning as Scalar's background maintenance configuration makes the
warning irrelevant.

index.skipHash=true::
Disable computing the hash of the index contents as it is being written.
This assists with performance, especially for large index files.

index.threads=true::
This tells Git to automatically detect how many threads it should use
when reading the index due to the default value of `core.preloadIndex`,
which enables parallel index reads. This explicit setting also enables
`index.recordOffsetTable=true` to speed up parallel index reads.

index.version=4::
This index version adds compression to the path names, reducing the size
of the index in a significant way for large repos. This is an important
performance boost.

log.excludeDecoration=refs/prefetch/*::
Since Scalar enables background maintenance with the `incremental`
strategy, this setting avoids polluting `git log` output with refs
stored by the background prefetch operations.

merge.renames=true::
When computing merges in large repos, it is particularly important to
detect renames to maximize the potential for a result that will validate
correctly. Users performing merges locally are more likely to be doing
so because a server-side merge (via pull request or similar) resulted in
conflicts. While this is the default setting, it is set specifically to
override a potential change to `diff.renames` which a user may set for
performance reasons.

merge.stat=false::
This disables a diff output after computing a merge. This improves
performance of `git merge` for large repos while reducing noisy output.

pack.useBitmaps=false::
This disables the use of `.bitmap` files attached to packfiles. Bitmap
files are optimized for server-side use, not client-side use. Scalar
disables this to avoid some performance issues that can occur if a user
accidentally creates `.bitmap` files.

pack.usePathWalk=true::
This enables the `--path-walk` option to `git pack-objects` by default.
This can accelerate the computation and compression of packfiles created
by `git push` and other repack operations.

receive.autoGC=false::
Similar to `gc.auto`, this setting is disabled in preference of
background maintenance.

status.aheadBehind=false::
This disables the ahead/behind calculation that would normally happen
during a `git status` command. This information is frequently ignored by
users but can be expensive to calculate in large repos that receive
thousands of commits per day. The calculation is replaced with an advice
message that can be disabled by disabling the `advice.statusAheadBehind`
config.

The following settings are different based on which platform is in use:

core.untrackedCache=(true|false)::
The untracked cache feature is important for performance benefits on
large repositories, but has demonstrated some bugs on Windows
filesystems. Thus, this is set for other platforms but disabled on
Windows.

http.sslBackend=schannel::
On Windows, the `openssl` backend has some issues with certain types of
remote providers and certificate types. Override the default setting to
avoid these common problems.


SEE ALSO
--------
linkgit:git-clone[1], linkgit:git-maintenance[1].
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ SANITIZE_LEAK =
SANITIZE_ADDRESS =

# For the 'coccicheck' target
SPATCH_INCLUDE_FLAGS = --all-includes
SPATCH_INCLUDE_FLAGS = --all-includes $(addprefix -I ,compat ewah refs sha256 trace2 win32 xdiff)
SPATCH_FLAGS =
SPATCH_TEST_FLAGS =

Expand Down Expand Up @@ -3523,7 +3523,7 @@ else
COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = $(COCCICHECK_PATCHES_INTREE)
endif
coccicheck: $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES)
! grep -q ^ $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES) /dev/null
! grep ^ $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES) /dev/null

# See contrib/coccinelle/README
coccicheck-pending: coccicheck-test
Expand Down
71 changes: 45 additions & 26 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,36 @@ static void ref_transaction_rejection_handler(const char *refname,
*data->retcode = 1;
}

/*
* Commit the reference transaction. If it isn't an atomic transaction, handle
* rejected updates as part of using batched updates.
*/
static int commit_ref_transaction(struct ref_transaction **transaction,
bool is_atomic, const char *remote_name,
struct strbuf *err)
{
int retcode = ref_transaction_commit(*transaction, err);
if (retcode)
goto out;

if (!is_atomic) {
struct ref_rejection_data data = {
.conflict_msg_shown = 0,
.remote_name = remote_name,
.retcode = &retcode,
};

ref_transaction_for_each_rejected_update(*transaction,
ref_transaction_rejection_handler,
&data);
}

out:
ref_transaction_free(*transaction);
*transaction = NULL;
return retcode;
}

static int do_fetch(struct transport *transport,
struct refspec *rs,
const struct fetch_config *config)
Expand Down Expand Up @@ -1853,33 +1883,14 @@ static int do_fetch(struct transport *transport,
if (retcode)
goto cleanup;

retcode = ref_transaction_commit(transaction, &err);
if (retcode) {
/*
* Explicitly handle transaction cleanup to avoid
* aborting an already closed transaction.
*/
ref_transaction_free(transaction);
transaction = NULL;
retcode = commit_ref_transaction(&transaction, atomic_fetch,
transport->remote->name, &err);
/*
* With '--atomic', bail out if the transaction fails. Without '--atomic',
* continue to fetch head and perform other post-fetch operations.
*/
if (retcode && atomic_fetch)
goto cleanup;
}

if (!atomic_fetch) {
struct ref_rejection_data data = {
.retcode = &retcode,
.conflict_msg_shown = 0,
.remote_name = transport->remote->name,
};

ref_transaction_for_each_rejected_update(transaction,
ref_transaction_rejection_handler,
&data);
if (retcode) {
ref_transaction_free(transaction);
transaction = NULL;
goto cleanup;
}
}

commit_fetch_head(&fetch_head);

Expand Down Expand Up @@ -1945,6 +1956,14 @@ static int do_fetch(struct transport *transport,
}

cleanup:
/*
* When using batched updates, we want to commit the non-rejected
* updates and also handle the rejections.
*/
if (retcode && !atomic_fetch && transaction)
commit_ref_transaction(&transaction, false,
transport->remote->name, &err);

if (retcode) {
if (err.len) {
error("%s", err.buf);
Expand Down
2 changes: 1 addition & 1 deletion builtin/last-modified.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static void process_parent(struct last_modified *lm,
if (!(parent->object.flags & PARENT1))
active_paths_free(lm, parent);

memset(lm->scratch->words, 0x0, lm->scratch->word_alloc * sizeof(eword_t));
MEMZERO_ARRAY(lm->scratch->words, lm->scratch->word_alloc);
diff_queue_clear(&diff_queued_diff);
}

Expand Down
12 changes: 10 additions & 2 deletions builtin/submodule--helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,13 @@ static int determine_submodule_update_strategy(struct repository *r,
const char *val;
int ret;

/*
* NEEDSWORK: audit and ensure that update_submodule() has right
* to assume that submodule_from_path() above will always succeed.
*/
if (!sub)
BUG("update_submodule assumes a submodule exists at path (%s)",
path);
key = xstrfmt("submodule.%s.update", sub->name);

if (update) {
Expand Down Expand Up @@ -3527,14 +3534,15 @@ static int module_add(int argc, const char **argv, const char *prefix,
}
}

if(!add_data.sm_name)
if (!add_data.sm_name)
add_data.sm_name = add_data.sm_path;

existing = submodule_from_name(the_repository,
null_oid(the_hash_algo),
add_data.sm_name);

if (existing && strcmp(existing->path, add_data.sm_path)) {
if (existing && existing->path &&
strcmp(existing->path, add_data.sm_path)) {
if (!force) {
die(_("submodule name '%s' already used for path '%s'"),
add_data.sm_name, existing->path);
Expand Down
2 changes: 1 addition & 1 deletion compat/simple-ipc/ipc-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ static LPSECURITY_ATTRIBUTES get_sa(struct my_sa_data *d)
goto fail;
}

memset(ea, 0, NR_EA * sizeof(EXPLICIT_ACCESS));
MEMZERO_ARRAY(ea, NR_EA);

ea[0].grfAccessPermissions = GENERIC_READ | GENERIC_WRITE;
ea[0].grfAccessMode = SET_ACCESS;
Expand Down
20 changes: 20 additions & 0 deletions contrib/coccinelle/array.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,23 @@ expression dst, src, n;
-ALLOC_ARRAY(dst, n);
-COPY_ARRAY(dst, src, n);
+DUP_ARRAY(dst, src, n);

@@
type T;
T *ptr;
expression n;
@@
- memset(ptr, \( 0x0 \| 0 \), n * \( sizeof(T)
- \| sizeof(*ptr)
- \) )
+ MEMZERO_ARRAY(ptr, n)

@@
type T;
T[] ptr;
expression n;
@@
- memset(ptr, \( 0x0 \| 0 \), n * \( sizeof(T)
- \| sizeof(*ptr)
- \) )
+ MEMZERO_ARRAY(ptr, n)
Loading