]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 years agounpack-trees: resolve sparse-directory/file conflicts
Derrick Stolee [Tue, 20 Jul 2021 20:14:41 +0000 (20:14 +0000)] 
unpack-trees: resolve sparse-directory/file conflicts

When running unpack_trees() with a sparse index, we attempt to operate
on the index without expanding the sparse directory entries. Thus, we
operate by manipulating entire directories and passing them to the
unpack function. In the case of the 'git checkout' command, this is the
twoway_merge() function.

There are several cases in twoway_merge() that handle different
situations. One new one to add is the case of a directory/file conflict
where the directory is sparse. Before the sparse index, such a conflict
would appear as a list of file additions and deletions. Now,
twoway_merge() initializes 'current', 'oldtree', and 'newtree' from
src[0], src[1], and src[2], then sets 'oldtree' to NULL because it is
equal to the df_conflict_entry. The way to determine that we have a
directory/file conflict is to test that 'current' and 'newtree' disagree
on being sparse directory entries.

When we are in this case, we want to resolve the situation by calling
merged_entry(). This allows replacing the 'current' entry with the
'newtree' entry. This is important for cases where we want to run 'git
checkout' across the conflict and have the new HEAD represent the new
file type at that path. The first NEEDSWORK comment dropped in t1092
demonstrates this necessary behavior.

However, we still are in a confusing state when 'current' corresponds to
a staged change within a sparse directory that is not present at HEAD.
This should be atypical, because it requires adding a change outside of
the sparse-checkout cone, but it is possible. Since we are unable to
determine that this is a staged change within twoway_merge(), we cannot
add a case to reject the merge at this point. I believe this is due to
the use of df_conflict_entry in the place of 'oldtree' instead of using
the valud at HEAD, which would provide some perspective to this
decision. Any change that would allow this differentiation for staged
entries would need to involve information further up in unpack_trees().

That work should be done, sometime, because we are further confusing the
behavior of a directory/file conflict when staging a change in the
directory. The two cases 'checkout behaves oddly with df-conflict-?' in
t1092 demonstrate that even without a sparse-checkout, Git is not
consistent in its behavior. Neither of the two options seems correct,
either. This change makes the sparse-index behave differently than the
typcial sparse-checkout case, but it does match the full checkout
behavior in the df-conflict-2 case.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot1092: document bad 'git checkout' behavior
Derrick Stolee [Tue, 20 Jul 2021 20:14:40 +0000 (20:14 +0000)] 
t1092: document bad 'git checkout' behavior

Add new branches to the test repo that demonstrate directory/file
conflicts in different ways. Since the directory 'folder1/' has
adjacent files 'folder1-', 'folder1.txt', and 'folder10' it causes
searches for 'folder1/' to land in a different place in the index than a
search for 'folder1'. This causes a change in behavior when working with
the df-conflict-1 and df-conflict-2 branches, whose only difference is
that the first uses 'folder1' as the conflict and the other uses
'folder2' which does not have these adjacent files.

We can extend two tests that compare the behavior across different 'git
checkout' commands, and we see already that the behavior will be
different in some cases and not in others. The difference between the
two test loops is that one uses 'git reset --hard' between iterations.

Further, we isolate the behavior of creating a staged change within a
directory and then checking out a branch where that directory is
replaced with a file. A full checkout behaves differently across these
two cases, while a sparse-checkout cone behaves consistently. In both
cases, the behavior is wrong. In one case, the staged change is dropped
entirely. The other case the staged change is kept, replacing the file
at that location, but none of the other files in the directory are kept.

Likely, the correct behavior in this case is to reject the checkout and
report the conflict, leaving HEAD in its previous location. None of the
cases behave this way currently. Use comments to demonstrate that the
tested behavior is only a documentation of the current, incorrect
behavior to ensure we do not _accidentally_ change it. Instead, we would
prefer to change it on purpose with a future change.

At this point, the sparse-index does not handle these 'git checkout'
commands correctly. Or rather, it _does_ reject the 'git checkout' when
we have the staged change, but for the wrong reason. It also rejects the
'git checkout' commands when there is no staged change and we want to
replace a directory with a file. A fix for that unstaged case will
follow in the next change, but that will make the sparse-index agree
with the full checkout case in these documented incorrect behaviors.

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocheckout: stop expanding sparse indexes
Derrick Stolee [Tue, 29 Jun 2021 02:13:06 +0000 (02:13 +0000)] 
checkout: stop expanding sparse indexes

Previous changes did the necessary improvements to unpack-trees.c and
diff-lib.c in order to modify a sparse index based on its comparision
with a tree. The only remaining work is to remove some
ensure_full_index() calls and add tests that verify that the index is
not expanded in our interesting cases. Include 'switch' and 'restore' in
these tests, as they share a base implementation with 'checkout'.

Here are the relevant performance results from
p2000-sparse-operations.sh:

Test                                     HEAD~1           HEAD
--------------------------------------------------------------------------------
2000.18: git checkout -f - (full-v3)     0.49(0.43+0.03)  0.47(0.39+0.05) -4.1%
2000.19: git checkout -f - (full-v4)     0.45(0.37+0.06)  0.42(0.37+0.05) -6.7%
2000.20: git checkout -f - (sparse-v3)   0.76(0.71+0.07)  0.04(0.03+0.04) -94.7%
2000.21: git checkout -f - (sparse-v4)   0.75(0.72+0.04)  0.05(0.06+0.04) -93.3%

It is important to compare the full index case to the sparse index case,
as the previous results for the sparse index were inflated by the index
expansion. For index v4, this is an 88% improvement.

On an internal repository with over two million paths at HEAD and a
sparse-checkout definition containing ~60,000 of those paths, 'git
checkout' went from 3.5s to 297ms with this change. The theoretical
optimum where only those ~60,000 paths exist was 275ms, so the extra
sparse directory entries contribute a 22ms overhead.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agosparse-index: recompute cache-tree
Derrick Stolee [Tue, 29 Jun 2021 02:13:05 +0000 (02:13 +0000)] 
sparse-index: recompute cache-tree

When some commands run with command_requires_full_index=1, then the
index can get in a state where the in-memory cache tree is actually
equal to the sparse index's cache tree instead of the full one.

This results in incorrect entry_count values. By clearing the cache
tree before converting to sparse, we avoid this issue.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocommit: integrate with sparse-index
Derrick Stolee [Tue, 29 Jun 2021 02:13:04 +0000 (02:13 +0000)] 
commit: integrate with sparse-index

Update 'git commit' to allow using the sparse-index in memory without
expanding to a full one. The only place that had an ensure_full_index()
call was in cache_tree_update(). The recursive algorithm for
update_one() was already updated in 2de37c536 (cache-tree: integrate
with sparse directory entries, 2021-03-03) to handle sparse directory
entries in the index.

Most of this change involves testing different command-line options that
allow specifying which on-disk changes should be included in the commit.
This includes no options (only take currently-staged changes), -a (take
all tracked changes), and --include (take a list of specific changes).
To simplify testing that these options do not expand the index, update
the test that previously verified that 'git status' does not expand the
index with a helper method, ensure_not_expanded().

This allows 'git commit' to operate much faster when the sparse-checkout
cone is much smaller than the full list of files at HEAD.

Here are the relevant lines from p2000-sparse-operations.sh:

Test                                      HEAD~1           HEAD
----------------------------------------------------------------------------------
2000.14: git commit -a -m A (full-v3)     0.35(0.26+0.06)  0.36(0.28+0.07) +2.9%
2000.15: git commit -a -m A (full-v4)     0.32(0.26+0.05)  0.34(0.28+0.06) +6.3%
2000.16: git commit -a -m A (sparse-v3)   0.63(0.59+0.06)  0.04(0.05+0.05) -93.7%
2000.17: git commit -a -m A (sparse-v4)   0.64(0.59+0.08)  0.04(0.04+0.04) -93.8%

It is important to compare the full-index case to the sparse-index case,
so the improvement for index version v4 is actually an 88% improvement in
this synthetic example.

In a real repository with over two million files at HEAD and 60,000
files in the sparse-checkout definition, the time for 'git commit -a'
went from 2.61 seconds to 134ms. I compared this to the result if the
index only contained the paths in the sparse-checkout definition and
found the theoretical optimum to be 120ms, so the out-of-cone paths only
add a 12% overhead.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agop2000: compress repo names
Derrick Stolee [Tue, 29 Jun 2021 02:13:03 +0000 (02:13 +0000)] 
p2000: compress repo names

By using shorter names for the test repos, we will get a slightly more
compressed performance summary without comprimising clarity.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agop2000: add 'git checkout -' test and decrease depth
Derrick Stolee [Tue, 29 Jun 2021 02:13:02 +0000 (02:13 +0000)] 
p2000: add 'git checkout -' test and decrease depth

As we increase our list of commands to test in
p2000-sparse-operations.sh, we will want to have a slightly smaller test
repository. Reduce the size by a factor of four by reducing the depth of
the step that creates a big index around a moderately-sized repository.

Also add a step to run 'git checkout -' on repeat. This requires having
a previous location in the reflog, so add that to the initialization
steps.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot1092: document bad sparse-checkout behavior
Derrick Stolee [Wed, 14 Jul 2021 13:12:40 +0000 (13:12 +0000)] 
t1092: document bad sparse-checkout behavior

There are several situations where a repository with sparse-checkout
enabled will act differently than a normal repository, and in ways that
are not intentional. The test t1092-sparse-checkout-compatibility.sh
documents some of these deviations, but a casual reader might think
these are intentional behavior changes.

Add comments on these tests that make it clear that these behaviors
should be updated. Using 'NEEDSWORK' helps contributors find that these
are potential areas for improvement.

Helped-by: Elijah Newren <newren@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agofsmonitor: integrate with sparse index
Derrick Stolee [Wed, 14 Jul 2021 13:12:39 +0000 (13:12 +0000)] 
fsmonitor: integrate with sparse index

If we need to expand a sparse-index into a full one, then the FS Monitor
bitmap is going to be incorrect. Ensure that we start fresh at such an
event.

While this is currently a performance drawback, the eventual hope of the
sparse-index feature is that these expansions will be rare and hence we
will be able to keep the FS Monitor data accurate across multiple Git
commands.

These tests are added to demonstrate that the behavior is the same
across a full index and a sparse index, but also that file modifications
to a tracked directory outside of the sparse cone will trigger
ensure_full_index().

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agowt-status: expand added sparse directory entries
Derrick Stolee [Wed, 14 Jul 2021 13:12:38 +0000 (13:12 +0000)] 
wt-status: expand added sparse directory entries

It is difficult, but possible, to get into a state where we intend to
add a directory that is outside of the sparse-checkout definition. Add a
test to t1092-sparse-checkout-compatibility.sh that demonstrates this
using a combination of 'git reset --mixed' and 'git checkout --orphan'.

This test failed before because the output of 'git status
--porcelain=v2' would not match on the lines for folder1/:

* The sparse-checkout repo (with a full index) would output each path
  name that is intended to be added.

* The sparse-index repo would only output that "folder1/" is staged for
  addition.

The status should report the full list of files to be added, and so this
sparse-directory entry should be expanded to a full list when reaching
it inside the wt_status_collect_changes_initial() method. Use
read_tree_at() to assist.

Somehow, this loop over the cache entries was not guarded by
ensure_full_index() as intended.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agostatus: use sparse-index throughout
Derrick Stolee [Wed, 14 Jul 2021 13:12:37 +0000 (13:12 +0000)] 
status: use sparse-index throughout

By testing 'git -c core.fsmonitor= status -uno', we can check for the
simplest index operations that can be made sparse-aware. The necessary
implementation details are already integrated with sparse-checkout, so
modify command_requires_full_index to be zero for cmd_status().

In refresh_index(), we loop through the index entries to refresh their
stat() information. However, sparse directories have no stat()
information to populate. Ignore these entries.

This allows 'git status' to no longer expand a sparse index to a full
one. This is further tested by dropping the "-uno" option and adding an
untracked file into the worktree.

The performance test p2000-sparse-checkout-operations.sh demonstrates
these improvements:

Test                                  HEAD~1           HEAD
-----------------------------------------------------------------------------
2000.2: git status (full-index-v3)    0.31(0.30+0.05)  0.31(0.29+0.06) +0.0%
2000.3: git status (full-index-v4)    0.31(0.29+0.07)  0.34(0.30+0.08) +9.7%
2000.4: git status (sparse-index-v3)  2.35(2.28+0.10)  0.04(0.04+0.05) -98.3%
2000.5: git status (sparse-index-v4)  2.35(2.24+0.15)  0.05(0.04+0.06) -97.9%

Note that since HEAD~1 was expanding the sparse index by parsing trees,
it was artificially slower than the full index case. Thus, the 98%
improvement is misleading, and instead we should celebrate the 0.34s to
0.05s improvement of 85%. This is more indicative of the peformance
gains we are expecting by using a sparse index.

Note: we are dropping the assignment of core.fsmonitor here. This is not
necessary for the test script as we are not altering the config any
other way. Correct integration with FS Monitor will be validated in
later changes.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agostatus: skip sparse-checkout percentage with sparse-index
Derrick Stolee [Wed, 14 Jul 2021 13:12:36 +0000 (13:12 +0000)] 
status: skip sparse-checkout percentage with sparse-index

'git status' began reporting a percentage of populated paths when
sparse-checkout is enabled in 051df3cf (wt-status: show sparse
checkout status as well, 2020-07-18). This percentage is incorrect when
the index has sparse directories. It would also be expensive to
calculate as we would need to parse trees to count the total number of
possible paths.

Avoid the expensive computation by simplifying the output to only report
that a sparse checkout exists, without the percentage.

This change is the reason we use 'git status --porcelain=v2' in
t1092-sparse-checkout-compatibility.sh. We don't want to ensure that
this message is equal across both modes, but instead just the important
information about staged, modified, and untracked files are compared.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodiff-lib: handle index diffs with sparse dirs
Derrick Stolee [Wed, 14 Jul 2021 13:12:35 +0000 (13:12 +0000)] 
diff-lib: handle index diffs with sparse dirs

While comparing an index to a tree, we may see a sparse directory entry.
In this case, we should compare that portion of the tree to the tree
represented by that entry. This could include a new tree which needs to
be expanded to a full list of added files. It could also include an
existing tree, in which case all of the changes inside are important to
describe, including the modifications, additions, and deletions. Note
that the case where the tree has a path and the index does not remains
identical to before: the lack of a cache entry is the same with a sparse
index.

Use diff_tree_oid() appropriately to compute the diff.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodir.c: accept a directory as part of cone-mode patterns
Derrick Stolee [Wed, 14 Jul 2021 13:12:34 +0000 (13:12 +0000)] 
dir.c: accept a directory as part of cone-mode patterns

When we have sparse directory entries in the index, we want to compare
that directory against sparse-checkout patterns. Those pattern matching
algorithms are built expecting a file path, not a directory path. This
is especially important in the "cone mode" patterns which will match
files that exist within the "parent directories" as well as the
recursive directory matches.

If path_matches_pattern_list() is given a directory, we can add a fake
filename ("-") to the directory and get the same results as before,
assuming we are in cone mode. Since sparse index requires cone mode
patterns, this is an acceptable assumption.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agounpack-trees: unpack sparse directory entries
Derrick Stolee [Wed, 14 Jul 2021 13:12:33 +0000 (13:12 +0000)] 
unpack-trees: unpack sparse directory entries

During unpack_callback(), index entries are compared against tree
entries. These are matched according to names and types. One goal is to
decide if we should recurse into subtrees or simply operate on one index
entry.

In the case of a sparse-directory entry, we do not want to recurse into
that subtree and instead simply compare the trees. In some cases, we
might want to perform a merge operation on the entry, such as during
'git checkout <commit>' which wants to replace a sparse tree entry with
the tree for that path at the target commit. We extend the logic within
unpack_single_entry() to create a sparse-directory entry in this case,
and then that is sent to call_unpack_fn().

There are some subtleties in this process. For instance, we need to
update find_cache_entry() to allow finding a sparse-directory entry that
exactly matches a given path. Use the new helper method
sparse_dir_matches_path() for this. We also need to ignore conflict
markers in the case that the entries correspond to directories and we
already have a sparse directory entry.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agounpack-trees: rename unpack_nondirectories()
Derrick Stolee [Wed, 14 Jul 2021 13:12:32 +0000 (13:12 +0000)] 
unpack-trees: rename unpack_nondirectories()

In the next change, we will use this method to unpack a sparse directory
entry, so change the name to unpack_single_entry() so these entries
apply. The new name reflects that we will not recurse into trees in
order to resolve the conflicts.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agounpack-trees: compare sparse directories correctly
Derrick Stolee [Wed, 14 Jul 2021 13:12:31 +0000 (13:12 +0000)] 
unpack-trees: compare sparse directories correctly

As we further integrate the sparse-index into unpack-trees, we need to
ensure that we compare sparse directory entries correctly with other
entries. This affects searching for an exact path as well as sorting
index entries.

Sparse directory entries contain the trailing directory separator. This
is important for the sorting, in particular. Thus, within
do_compare_entry() we stop using S_IFREG in all cases, since sparse
directories should use S_IFDIR to indicate that the comparison should
treat the entry name as a dirctory.

Within compare_entry(), it first calls do_compare_entry() to check the
leading portion of the name. When the input path is a directory name, we
could match exactly already. Thus, we should return 0 if we have an
exact string match on a sparse directory entry. The final check is a
length comparison between the strings.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agounpack-trees: preserve cache_bottom
Derrick Stolee [Wed, 14 Jul 2021 13:12:30 +0000 (13:12 +0000)] 
unpack-trees: preserve cache_bottom

The cache_bottom member of 'struct unpack_trees_options' is used to
track the range of index entries corresponding to a node of the cache
tree. While recursing with traverse_by_cache_tree(), this value is
preserved on the call stack using a local and then restored as that
method returns.

The mark_ce_used() method normally modifies the cache_bottom member when
it refers to the marked cache entry. However, sparse directory entries
are stored as nodes in the cache-tree data structure as of 2de37c53
(cache-tree: integrate with sparse directory entries, 2021-03-30). Thus,
the cache_bottom will be modified as the cache-tree walk advances. Do
not update it as well within mark_ce_used().

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot1092: add tests for status/add and sparse files
Derrick Stolee [Wed, 14 Jul 2021 13:12:29 +0000 (13:12 +0000)] 
t1092: add tests for status/add and sparse files

Before moving to update 'git status' and 'git add' to work with sparse
indexes, add an explicit test that ensures the sparse-index works the
same as a normal sparse-checkout when the worktree contains directories
and files outside of the sparse cone.

Specifically, 'folder1/a' is a file in our test repo, but 'folder1' is
not in the sparse cone. When 'folder1/a' is modified, the file is not
shown as modified and adding it will fail. This is new behavior as of
a20f704 (add: warn when asked to update SKIP_WORKTREE entries,
2021-04-08). Before that change, these adds would be silently ignored.

Untracked files are fine: adding new files both with 'git add .' and
'git add folder1/' works just as in a full checkout. This may not be
entirely desirable, but we are not intending to change behavior at the
moment, only document it. A future change could alter the behavior to
be more sensible, and this test could be modified to satisfy the new
expected behavior.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot1092: expand repository data shape
Derrick Stolee [Wed, 14 Jul 2021 13:12:28 +0000 (13:12 +0000)] 
t1092: expand repository data shape

As more features integrate with the sparse-index feature, more and more
special cases arise that require different data shapes within the tree
structure of the repository in order to demonstrate those cases.

Add several interesting special cases all at once instead of sprinkling
them across several commits. The interesting cases being added here are:

* Add sparse-directory entries on both sides of directories within the
  sparse-checkout definition.

* Add directories outside the sparse-checkout definition who have only
  one entry and are the first entry of a directory with multiple
  entries.

* Add filenames adjacent to a sparse directory entry that sort before
  and after the trailing slash.

Later tests will take advantage of these shapes, but they also deepen
the tests that already exist.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot1092: replace incorrect 'echo' with 'cat'
Derrick Stolee [Wed, 14 Jul 2021 13:12:27 +0000 (13:12 +0000)] 
t1092: replace incorrect 'echo' with 'cat'

This fixes the test data shape to be as expected, allowing rename
detection to work properly now that the 'larger-content' file actually
has meaningful lines.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agosparse-index: include EXTENDED flag when expanding
Derrick Stolee [Wed, 14 Jul 2021 13:12:26 +0000 (13:12 +0000)] 
sparse-index: include EXTENDED flag when expanding

When creating a full index from a sparse one, we create cache entries
for every blob within a given sparse directory entry. These are
correctly marked with the CE_SKIP_WORKTREE flag, but the CE_EXTENDED
flag is not included. The CE_EXTENDED flag would exist if we loaded a
full index from disk with these entries marked with CE_SKIP_WORKTREE, so
we can add the flag here to be consistent. This allows us to directly
compare the flags present in cache entries when testing the sparse-index
feature, but has no significance to its correctness in the user-facing
functionality.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agosparse-index: skip indexes with unmerged entries
Derrick Stolee [Wed, 14 Jul 2021 13:12:25 +0000 (13:12 +0000)] 
sparse-index: skip indexes with unmerged entries

The sparse-index format is designed to be compatible with merge
conflicts, even those outside the sparse-checkout definition. The reason
is that when converting a full index to a sparse one, a cache entry with
nonzero stage will not be collapsed into a sparse directory entry.

However, this behavior was not tested, and a different behavior within
convert_to_sparse() fails in this scenario. Specifically,
cache_tree_update() will fail when unmerged entries exist.
convert_to_sparse_rec() uses the cache-tree data to recursively walk the
tree structure, but also to compute the OIDs used in the
sparse-directory entries.

Add an index scan to convert_to_sparse() that will detect if these merge
conflict entries exist and skip the conversion before trying to update
the cache-tree. This is marked as NEEDSWORK because this can be removed
with a suitable update to cache_tree_update() or a similar method that
can construct a cache-tree with invalid nodes, but still allow creating
the nodes necessary for creating sparse directory entries.

It is possible that in the future we will not need to make such an
update, since if we do not expand a sparse-index into a full one, this
conversion does not need to happen. Thus, this can be deferred until the
merge machinery is made to integrate with the sparse-index.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe second batch
Junio C Hamano [Mon, 14 Jun 2021 04:23:28 +0000 (13:23 +0900)] 
The second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'fc/doc-build-cleanup'
Junio C Hamano [Mon, 14 Jun 2021 04:33:29 +0000 (13:33 +0900)] 
Merge branch 'fc/doc-build-cleanup'

Preparatory build procedure clean-up for documentation.

* fc/doc-build-cleanup:
  doc: avoid using rm directly
  doc: simplify Makefile using .DELETE_ON_ERROR
  doc: remove unnecessary rm instances
  doc: improve asciidoc dependencies
  doc: refactor common asciidoc dependencies

3 years agoMerge branch 'ab/test-lib-updates'
Junio C Hamano [Mon, 14 Jun 2021 04:33:29 +0000 (13:33 +0900)] 
Merge branch 'ab/test-lib-updates'

Test clean-up.

* ab/test-lib-updates:
  test-lib: split up and deprecate test_create_repo()
  test-lib: do not show advice about init.defaultBranch under --verbose
  test-lib: reformat argument list in test_create_repo()
  submodule tests: use symbolic-ref --short to discover branch name
  test-lib functions: add --printf option to test_commit
  describe tests: convert setup to use test_commit
  test-lib functions: add an --annotated option to "test_commit"
  test-lib-functions: document test_commit --no-tag
  test-lib-functions: reword "test_commit --append" docs
  test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable
  test-lib: bring $remove_trash out of retirement

3 years agoMerge branch 'dd/honor-users-tar-in-tests'
Junio C Hamano [Mon, 14 Jun 2021 04:33:28 +0000 (13:33 +0900)] 
Merge branch 'dd/honor-users-tar-in-tests'

Test portability fix.

* dd/honor-users-tar-in-tests:
  t: use configured TAR instead of tar

3 years agoMerge branch 'ps/rev-list-object-type-filter'
Junio C Hamano [Mon, 14 Jun 2021 04:33:28 +0000 (13:33 +0900)] 
Merge branch 'ps/rev-list-object-type-filter'

Message update.

* ps/rev-list-object-type-filter:
  help: fix small typo in error message

3 years agoMerge branch 'ab/trace2-squelch-gcc-warning'
Junio C Hamano [Mon, 14 Jun 2021 04:33:28 +0000 (13:33 +0900)] 
Merge branch 'ab/trace2-squelch-gcc-warning'

Workaround compiler warnings.

* ab/trace2-squelch-gcc-warning:
  trace2: refactor to avoid gcc warning under -O3

3 years agoMerge branch 'so/log-m-implies-p'
Junio C Hamano [Mon, 14 Jun 2021 04:33:27 +0000 (13:33 +0900)] 
Merge branch 'so/log-m-implies-p'

The "-m" option in "git log -m" that does not specify which format,
if any, of diff is desired did not have any visible effect; it now
implies some form of diff (by default "--patch") is produced.

* so/log-m-implies-p:
  diff-merges: let "-m" imply "-p"
  diff-merges: rename "combined_imply_patch" to "merges_imply_patch"
  stash list: stop passing "-m" to "git log"
  git-svn: stop passing "-m" to "git rev-list"
  diff-merges: move specific diff-index "-m" handling to diff-index
  t4013: test "git diff-index -m"
  t4013: test "git diff-tree -m"
  t4013: test "git log -m --stat"
  t4013: test "git log -m --raw"
  t4013: test that "-m" alone has no effect in "git log"

3 years agoMerge branch 'en/ort-perf-batch-11'
Junio C Hamano [Mon, 14 Jun 2021 04:33:26 +0000 (13:33 +0900)] 
Merge branch 'en/ort-perf-batch-11'

Optimize out repeated rename detection in a sequence of mergy
operations.

* en/ort-perf-batch-11:
  merge-ort, diffcore-rename: employ cached renames when possible
  merge-ort: handle interactions of caching and rename/rename(1to1) cases
  merge-ort: add helper functions for using cached renames
  merge-ort: preserve cached renames for the appropriate side
  merge-ort: avoid accidental API mis-use
  merge-ort: add code to check for whether cached renames can be reused
  merge-ort: populate caches of rename detection results
  merge-ort: add data structures for in-memory caching of rename detection
  t6429: testcases for remembering renames
  fast-rebase: write conflict state to working tree, index, and HEAD
  fast-rebase: change assert() to BUG()
  Documentation/technical: describe remembering renames optimization
  t6423: rename file within directory that other side renamed

3 years agoMerge branch 'jk/fetch-pack-v2-half-close-early'
Junio C Hamano [Mon, 14 Jun 2021 04:33:26 +0000 (13:33 +0900)] 
Merge branch 'jk/fetch-pack-v2-half-close-early'

"git fetch" over protocol v2 left its side of the socket open after
it finished speaking, which unnecessarily wasted the resource on
the other side.

* jk/fetch-pack-v2-half-close-early:
  fetch-pack: signal v2 server that we are done making requests

3 years agoMerge branch 'ds/write-index-with-hashfile-api'
Junio C Hamano [Mon, 14 Jun 2021 04:33:26 +0000 (13:33 +0900)] 
Merge branch 'ds/write-index-with-hashfile-api'

Use the hashfile API in the codepath that writes the index file to
reduce code duplication.

* ds/write-index-with-hashfile-api:
  read-cache: delete unused hashing methods
  read-cache: use hashfile instead of git_hash_ctx
  csum-file.h: increase hashfile buffer size
  hashfile: use write_in_full()

3 years agoMerge branch 'jk/clone-clean-upon-transport-error'
Junio C Hamano [Mon, 14 Jun 2021 04:33:26 +0000 (13:33 +0900)] 
Merge branch 'jk/clone-clean-upon-transport-error'

Recent "git clone" left a temporary directory behind when the
transport layer returned an failure.

* jk/clone-clean-upon-transport-error:
  clone: clean up directory after transport_fetch_refs() failure

3 years agoMerge branch 'ga/send-email-sendmail-cmd'
Junio C Hamano [Mon, 14 Jun 2021 04:33:26 +0000 (13:33 +0900)] 
Merge branch 'ga/send-email-sendmail-cmd'

"git send-email" learned the "--sendmail-cmd" command line option
and the "sendemail.sendmailCmd" configuration variable, which is a
more sensible approach than the current way of repurposing the
"smtp-server" that is meant to name the server to instead name the
command to talk to the server.

* ga/send-email-sendmail-cmd:
  git-send-email: add option to specify sendmail command

3 years agoMerge branch 'zh/ref-filter-atom-type'
Junio C Hamano [Mon, 14 Jun 2021 04:33:25 +0000 (13:33 +0900)] 
Merge branch 'zh/ref-filter-atom-type'

The code to handle the "--format" option in "for-each-ref" and
friends made too many string comparisons on %(atom)s used in the
format string, which has been corrected by converting them into
enum when the format string is parsed.

* zh/ref-filter-atom-type:
  ref-filter: introduce enum atom_type
  ref-filter: add objectsize to used_atom

3 years agoThe first batch post Git 2.32
Junio C Hamano [Thu, 10 Jun 2021 02:37:04 +0000 (11:37 +0900)] 
The first batch post Git 2.32

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ah/setup-extensions-message-i18n-fix'
Junio C Hamano [Thu, 10 Jun 2021 03:04:27 +0000 (12:04 +0900)] 
Merge branch 'ah/setup-extensions-message-i18n-fix'

Message update.

* ah/setup-extensions-message-i18n-fix:
  setup: split "extensions found" messages into singular and plural

3 years agoMerge branch 'ah/fetch-reject-warning-grammofix'
Junio C Hamano [Thu, 10 Jun 2021 03:04:27 +0000 (12:04 +0900)] 
Merge branch 'ah/fetch-reject-warning-grammofix'

Message update.

* ah/fetch-reject-warning-grammofix:
  fetch: improve grammar of "shallow roots" message

3 years agoMerge branch 'jk/doc-color-pager'
Junio C Hamano [Thu, 10 Jun 2021 03:04:26 +0000 (12:04 +0900)] 
Merge branch 'jk/doc-color-pager'

The documentation for "color.pager" configuration variable has been
updated.

* jk/doc-color-pager:
  doc: explain the use of color.pager

3 years agoMerge branch 'tl/fix-packfile-uri-doc'
Junio C Hamano [Thu, 10 Jun 2021 03:04:26 +0000 (12:04 +0900)] 
Merge branch 'tl/fix-packfile-uri-doc'

Doc fix.

* tl/fix-packfile-uri-doc:
  packfile-uri.txt: fix blobPackfileUri description

3 years agoMerge branch 'ry/clarify-fast-forward-in-glossary'
Junio C Hamano [Thu, 10 Jun 2021 03:04:25 +0000 (12:04 +0900)] 
Merge branch 'ry/clarify-fast-forward-in-glossary'

The description of "fast-forward" in the glossary has been updated.

* ry/clarify-fast-forward-in-glossary:
  docs: improve fast-forward in glossary content

3 years agoMerge branch 'wm/rev-parse-die-i18n'
Junio C Hamano [Thu, 10 Jun 2021 03:04:25 +0000 (12:04 +0900)] 
Merge branch 'wm/rev-parse-die-i18n'

Quite a many die() messages in rev-parse haven't been marked for
translation.

* wm/rev-parse-die-i18n:
  rev-parse: mark die() messages for translation

3 years agoMerge branch 'jc/clarify-revision-range'
Junio C Hamano [Thu, 10 Jun 2021 03:04:25 +0000 (12:04 +0900)] 
Merge branch 'jc/clarify-revision-range'

Doc update.

* jc/clarify-revision-range:
  revisions(7): clarify that most commands take a single revision range

3 years agoMerge branch 'ah/doc-describe'
Junio C Hamano [Thu, 10 Jun 2021 03:04:24 +0000 (12:04 +0900)] 
Merge branch 'ah/doc-describe'

Doc update.

* ah/doc-describe:
  describe-doc: clarify default length of abbreviation

3 years agoMerge branch 'ah/submodule-helper-module-summary-parseopt'
Junio C Hamano [Thu, 10 Jun 2021 03:04:24 +0000 (12:04 +0900)] 
Merge branch 'ah/submodule-helper-module-summary-parseopt'

Message update.

* ah/submodule-helper-module-summary-parseopt:
  submodule: use the imperative mood to describe the --files option

3 years agoMerge branch 'ah/stash-usage-i18n-fix'
Junio C Hamano [Thu, 10 Jun 2021 03:04:23 +0000 (12:04 +0900)] 
Merge branch 'ah/stash-usage-i18n-fix'

i18n update.

* ah/stash-usage-i18n-fix:
  stash: don't translate literal commands

3 years agoMerge branch 'ah/merge-usage-i18n-fix'
Junio C Hamano [Thu, 10 Jun 2021 03:04:23 +0000 (12:04 +0900)] 
Merge branch 'ah/merge-usage-i18n-fix'

i18n update.

* ah/merge-usage-i18n-fix:
  merge: don't translate literal commands

3 years agoMerge branch 'jn/size-t-casted-to-off-t-fix'
Junio C Hamano [Thu, 10 Jun 2021 03:04:23 +0000 (12:04 +0900)] 
Merge branch 'jn/size-t-casted-to-off-t-fix'

Rewrite code that triggers undefined behaiour warning.

* jn/size-t-casted-to-off-t-fix:
  xsize_t: avoid implementation defined behavior when len < 0

3 years agoMerge branch 'mt/parallel-checkout-with-padded-oidcpy'
Junio C Hamano [Thu, 10 Jun 2021 03:04:22 +0000 (12:04 +0900)] 
Merge branch 'mt/parallel-checkout-with-padded-oidcpy'

The parallel checkout codepath did not initialize object ID field
used to talk to the worker processes in a futureproof way.

* mt/parallel-checkout-with-padded-oidcpy:
  parallel-checkout: send the new object_id algo field to the workers

3 years agoMerge branch 'ef/mailinfo-short-name'
Junio C Hamano [Thu, 10 Jun 2021 03:04:22 +0000 (12:04 +0900)] 
Merge branch 'ef/mailinfo-short-name'

We historically rejected a very short string as an author name
while accepting a patch e-mail, which has been loosened.

* ef/mailinfo-short-name:
  mailinfo: don't discard names under 3 characters

3 years agoGit 2.32 v2.32.0
Junio C Hamano [Sun, 6 Jun 2021 06:40:01 +0000 (15:40 +0900)] 
Git 2.32

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge tag 'l10n-2.32.0-rnd1.1' of git://github.com/git-l10n/git-po
Junio C Hamano [Sun, 6 Jun 2021 06:39:21 +0000 (15:39 +0900)] 
Merge tag 'l10n-2.32.0-rnd1.1' of git://github.com/git-l10n/git-po

l10n-2.32.0-rnd1.1

* tag 'l10n-2.32.0-rnd1.1' of git://github.com/git-l10n/git-po: (25 commits)
  l10n: es: 2.32.0 round 1
  l10n: zh_CN: for git v2.32.0 l10n round 1
  l10n: Update Catalan translation
  l10n: de.po: Update German translation for Git v2.32.0
  l10n: README: note on fuzzy translations
  l10n: README: document l10n conventions
  l10n: README: document "core translation"
  l10n: README: document git-po-helper
  l10n: README: add file extention ".md"
  l10n: pt_PT: add Portuguese translations part 3
  l10n: bg.po: Updated Bulgarian translation (5204t)
  l10n: id: po-id for 2.32.0 (round 1)
  l10n: vi.po(5204t): Updated Vietnamese translation for v2.32.0
  l10n: zh_TW.po: localized
  l10n: zh_TW.po: v2.32.0 round 1 (11 untranslated)
  l10n: sv.po: Update Swedish translation (5204t0f0u)
  l10n: fix typos in po/TEAMS
  l10n: fr: v2.32.0 round 1
  l10n: tr: v2.32.0-r1
  l10n: fr: fixed inconsistencies
  ...

3 years agoMerge branch 'rs/parallel-checkout-test-fix'
Junio C Hamano [Sun, 6 Jun 2021 06:39:10 +0000 (15:39 +0900)] 
Merge branch 'rs/parallel-checkout-test-fix'

Test fix.

* rs/parallel-checkout-test-fix:
  parallel-checkout: avoid dash local bug in tests

3 years agoMerge branch 'jc/fsync-can-fail-with-eintr'
Junio C Hamano [Sun, 6 Jun 2021 06:39:09 +0000 (15:39 +0900)] 
Merge branch 'jc/fsync-can-fail-with-eintr'

Last minute portability fix.

* jc/fsync-can-fail-with-eintr:
  fsync(): be prepared to see EINTR

3 years agoparallel-checkout: avoid dash local bug in tests
René Scharfe [Sun, 6 Jun 2021 01:01:57 +0000 (03:01 +0200)] 
parallel-checkout: avoid dash local bug in tests

Dash bug https://bugs.launchpad.net/ubuntu/+source/dash/+bug/139097
lets the shell erroneously perform field splitting on the expansion of a
command substitution during declaration of a local variable.  It causes
the parallel-checkout tests to fail e.g. when running them with
/bin/dash on MacOS 11.4, where they error out like this:

   ./t2080-parallel-checkout-basics.sh: 33: local: 0: bad variable name

That's because the output of wc -l contains leading spaces and the
returned number of lines is treated as another variable to declare, i.e.
as in "local workers= 0".

Work around it by enclosing the command substitution in quotes.

Helped-by: Matheus Tavares Bernardino <matheus.bernardino@usp.br>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agol10n: es: 2.32.0 round 1
Christopher Diaz Riveros [Sun, 6 Jun 2021 01:06:23 +0000 (20:06 -0500)] 
l10n: es: 2.32.0 round 1

Signed-off-by: Christopher Diaz Riveros <christopher.diaz.riv@gmail.com>
3 years agol10n: zh_CN: for git v2.32.0 l10n round 1
Jiang Xin [Sat, 5 Jun 2021 09:54:23 +0000 (17:54 +0800)] 
l10n: zh_CN: for git v2.32.0 l10n round 1

Translate 126 new messages (5204t0f0u) for git 2.32.0.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
3 years agoMerge branch 'fix_typo' of github.com:e-yes/git
Jiang Xin [Sat, 5 Jun 2021 13:30:30 +0000 (21:30 +0800)] 
Merge branch 'fix_typo' of github.com:e-yes/git

* 'fix_typo' of github.com:e-yes/git:
  l10n: ru.po: fix typo in Russian translation

3 years agofsync(): be prepared to see EINTR
Junio C Hamano [Fri, 4 Jun 2021 01:36:11 +0000 (10:36 +0900)] 
fsync(): be prepared to see EINTR

Some platforms, like NonStop do not automatically restart fsync()
when interrupted by a signal, even when that signal is setup with
SA_RESTART.

This can lead to test breakage, e.g., where "--progress" is used,
thus SIGALRM is sent often, and can interrupt an fsync() syscall.

Make sure we deal with such a case by retrying the syscall
ourselves.  Luckily, we call fsync() fron a single wrapper,
fsync_or_die(), so the fix is fairly isolated.

Reported-by: Randall S. Becker <randall.becker@nexbridge.ca>
Helped-by: Jeff King <peff@peff.net>
Helped-by: Taylor Blau <me@ttaylorr.com>
[jc: the above two did most of the work---I just tied the loose end]
Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'pt-PT' of github.com:git-l10n-pt-PT/git-po
Jiang Xin [Fri, 4 Jun 2021 10:59:17 +0000 (18:59 +0800)] 
Merge branch 'pt-PT' of github.com:git-l10n-pt-PT/git-po

* 'pt-PT' of github.com:git-l10n-pt-PT/git-po:
  l10n: pt_PT: add Portuguese translations part 3
  l10n: pt_PT: add Portuguese translations part 2

3 years agol10n: Update Catalan translation
Jordi Mas [Fri, 4 Jun 2021 04:58:05 +0000 (06:58 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
3 years agol10n: de.po: Update German translation for Git v2.32.0
Matthias Rüster [Sun, 23 May 2021 09:33:21 +0000 (11:33 +0200)] 
l10n: de.po: Update German translation for Git v2.32.0

Reviewed-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com>
3 years agoGit 2.32-rc3 v2.32.0-rc3
Junio C Hamano [Wed, 2 Jun 2021 03:51:09 +0000 (12:51 +0900)] 
Git 2.32-rc3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocontrib/completion: fix zsh completion regression from 59d85a2a05
David Aguilar [Tue, 1 Jun 2021 20:52:29 +0000 (13:52 -0700)] 
contrib/completion: fix zsh completion regression from 59d85a2a05

A recent change to make git-completion.bash use $__git_cmd_idx
in more places broke a number of completions on zsh because it
modified __git_main but did not update __git_zsh_main.

Notably, completions for "add", "branch", "mv" and "push" were
broken as a result of this change.

In addition to the undefined variable usage, "git mv <tab>" also
prints the following error:

__git_count_arguments:7: bad math expression:
operand expected at `"1"'

_git_mv:[:7: unknown condition: -gt

Remove the quotes around $__git_cmd_idx in __git_count_arguments
and set __git_cmd_idx=1 early in __git_zsh_main to fix the
regressions from 59d85a2a05.

This was tested on zsh 5.7.1 (x86_64-apple-darwin19.0).

Suggested-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Acked-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agol10n: README: note on fuzzy translations
Bagas Sanjaya [Mon, 17 May 2021 12:40:38 +0000 (19:40 +0700)] 
l10n: README: note on fuzzy translations

Fuzzy translation problem can occur when updating translations.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
3 years agol10n: README: document l10n conventions
Bagas Sanjaya [Thu, 11 Mar 2021 11:36:57 +0000 (18:36 +0700)] 
l10n: README: document l10n conventions

Document the conventions that l10n contributors must follow.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
3 years agol10n: README: document "core translation"
Bagas Sanjaya [Thu, 11 Mar 2021 11:01:34 +0000 (18:01 +0700)] 
l10n: README: document "core translation"

Contributor for a new language must complete translations of a small set
of l10n messages.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
3 years agol10n: README: document git-po-helper
Bagas Sanjaya [Thu, 11 Mar 2021 10:57:15 +0000 (17:57 +0700)] 
l10n: README: document git-po-helper

Document the PO helper program (git-po-helper) with installation and
basic usage.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
3 years agol10n: README: add file extention ".md"
Jiang Xin [Wed, 26 May 2021 09:38:56 +0000 (17:38 +0800)] 
l10n: README: add file extention ".md"

Add file extension ".md" to "po/README" to help to display this markdown
file properly.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
3 years agoMerge branch 'ab/fsck-api-cleanup'
Junio C Hamano [Tue, 1 Jun 2021 22:34:27 +0000 (07:34 +0900)] 
Merge branch 'ab/fsck-api-cleanup'

Last minute compilation fix.

* ab/fsck-api-cleanup:
  builtin/fsck.c: don't conflate "int" and "enum" in callback

3 years agobuiltin/fsck.c: don't conflate "int" and "enum" in callback
Ævar Arnfjörð Bjarmason [Tue, 1 Jun 2021 00:05:59 +0000 (02:05 +0200)] 
builtin/fsck.c: don't conflate "int" and "enum" in callback

Fix a warning on AIX's xlc compiler that's been emitted since my
a1aad71601a (fsck.h: use "enum object_type" instead of "int",
2021-03-28):

    "builtin/fsck.c", line 805.32: 1506-068 (W) Operation between
    types "int(*)(struct object*,enum object_type,void*,struct
    fsck_options*)" and "int(*)(struct object*,int,void*,struct
    fsck_options*)" is not allowed.

I.e. it complains about us assigning a function with a prototype "int"
where we're expecting "enum object_type".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agol10n: pt_PT: add Portuguese translations part 3
Daniel Santos [Mon, 17 May 2021 09:19:06 +0000 (10:19 +0100)] 
l10n: pt_PT: add Portuguese translations part 3

* Correct malformed strings
* Transforming 'não' (no) into affirmative

Signed-off-by: Daniel Santos <hello@brighterdan.com>
3 years agoMerge branch 'l10n/zh_TW/21-05-20' of github.com:l10n-tw/git-po
Jiang Xin [Sun, 30 May 2021 13:40:59 +0000 (21:40 +0800)] 
Merge branch 'l10n/zh_TW/21-05-20' of github.com:l10n-tw/git-po

* 'l10n/zh_TW/21-05-20' of github.com:l10n-tw/git-po:
  l10n: zh_TW.po: localized
  l10n: zh_TW.po: v2.32.0 round 1 (11 untranslated)

3 years agoMerge branch 'master' of github.com:Softcatala/git-po
Jiang Xin [Sun, 30 May 2021 12:45:10 +0000 (20:45 +0800)] 
Merge branch 'master' of github.com:Softcatala/git-po

* 'master' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

3 years agol10n: bg.po: Updated Bulgarian translation (5204t)
Alexander Shopov [Mon, 17 May 2021 09:13:37 +0000 (11:13 +0200)] 
l10n: bg.po: Updated Bulgarian translation (5204t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
3 years agoGit 2.32-rc2 v2.32.0-rc2
Junio C Hamano [Fri, 28 May 2021 04:05:29 +0000 (13:05 +0900)] 
Git 2.32-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'en/dir-traversal'
Junio C Hamano [Fri, 28 May 2021 04:03:00 +0000 (13:03 +0900)] 
Merge branch 'en/dir-traversal'

Fix-up to a topic that is already in 'master'.

* en/dir-traversal:
  dir: introduce readdir_skip_dot_and_dotdot() helper
  dir: update stale description of treat_directory()
  Revert "dir: update stale description of treat_directory()"
  Revert "dir: introduce readdir_skip_dot_and_dotdot() helper"

3 years agodir: introduce readdir_skip_dot_and_dotdot() helper
Elijah Newren [Thu, 27 May 2021 04:53:56 +0000 (04:53 +0000)] 
dir: introduce readdir_skip_dot_and_dotdot() helper

Many places in the code were doing
    while ((d = readdir(dir)) != NULL) {
        if (is_dot_or_dotdot(d->d_name))
            continue;
        ...process d...
    }
Introduce a readdir_skip_dot_and_dotdot() helper to make that a one-liner:
    while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) {
        ...process d...
    }

This helper particularly simplifies checks for empty directories.

Also use this helper in read_cached_dir() so that our statistics are
consistent across platforms.  (In other words, read_cached_dir() should
have been using is_dot_or_dotdot() and skipping such entries, but did
not and left it to treat_path() to detect and mark such entries as
path_none.)

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodir: update stale description of treat_directory()
Derrick Stolee [Thu, 27 May 2021 04:53:55 +0000 (04:53 +0000)] 
dir: update stale description of treat_directory()

The documentation comment for treat_directory() was originally written
in 095952 (Teach directory traversal about subprojects, 2007-04-11)
which was before the 'struct dir_struct' split its bitfield of named
options into a 'flags' enum in 7c4c97c0 (Turn the flags in struct
dir_struct into a single variable, 2009-02-16). When those flags
changed, the comment became stale, since members like
'show_other_directories' transitioned into flags like
DIR_SHOW_OTHER_DIRECTORIES.

Update the comments for treat_directory() to use these flag names rather
than the old member names.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoRevert "dir: update stale description of treat_directory()"
Junio C Hamano [Thu, 27 May 2021 05:00:00 +0000 (14:00 +0900)] 
Revert "dir: update stale description of treat_directory()"

This reverts commit 4e689d81718eb6e939cace317ea3e33cb994dcbb,
to be replaced with a reworked version.

3 years agoRevert "dir: introduce readdir_skip_dot_and_dotdot() helper"
Junio C Hamano [Thu, 27 May 2021 04:59:39 +0000 (13:59 +0900)] 
Revert "dir: introduce readdir_skip_dot_and_dotdot() helper"

This reverts commit b548f0f1568f6b01e55ca69c24d3cb19489f92aa,
to be replaced with a reworked version.

3 years agoMerge branch 'ab/pack-linkage-fix'
Junio C Hamano [Thu, 27 May 2021 03:36:58 +0000 (12:36 +0900)] 
Merge branch 'ab/pack-linkage-fix'

"ld" on Solaris fails to link some test helpers, which has been
worked around by reshuffling the inline function definitions from a
header file to a source file that is the only user of them.

* ab/pack-linkage-fix:
  pack-objects: move static inline from a header to the sole consumer

3 years agoMerge branch 'mt/t2080-cp-symlink-fix'
Junio C Hamano [Thu, 27 May 2021 03:36:57 +0000 (12:36 +0900)] 
Merge branch 'mt/t2080-cp-symlink-fix'

Test portability fix.

* mt/t2080-cp-symlink-fix:
  t2080: fix cp invocation to copy symlinks instead of following them

3 years agoMerge branch 'ab/send-email-inline-hooks-path'
Junio C Hamano [Thu, 27 May 2021 03:36:57 +0000 (12:36 +0900)] 
Merge branch 'ab/send-email-inline-hooks-path'

Code simplification.

* ab/send-email-inline-hooks-path:
  send-email: move "hooks_path" invocation to git-send-email.perl
  send-email: don't needlessly abs_path() the core.hooksPath

3 years agoMerge branch 'ds/t1092-fix-flake-from-progress'
Junio C Hamano [Thu, 27 May 2021 03:36:57 +0000 (12:36 +0900)] 
Merge branch 'ds/t1092-fix-flake-from-progress'

Workaround flaky tests introduced recently.

* ds/t1092-fix-flake-from-progress:
  t1092: revert the "-1" hack for emulating "no progress meter"
  t1092: use GIT_PROGRESS_DELAY for consistent results

3 years agopack-objects: move static inline from a header to the sole consumer
Ævar Arnfjörð Bjarmason [Thu, 27 May 2021 00:52:51 +0000 (02:52 +0200)] 
pack-objects: move static inline from a header to the sole consumer

Move the code that is only used in builtin/pack-objects.c out of
pack-objects.h.

This fixes an issue where Solaris's SunCC hasn't been able to compile
git since 483fa7f42d9 (t/helper/test-bitmap.c: initial commit,
2021-03-31).

The real origin of that issue is that in 898eba5e630 (pack-objects:
refer to delta objects by index instead of pointer, 2018-04-14)
utility functions only needed by builtin/pack-objects.c were added to
pack-objects.h. Since then the header has been used in a few other
places, but 483fa7f42d9 was the first time it was used by test helper.

Since Solaris is stricter about linking and the oe_get_size_slow()
function lives in builtin/pack-objects.c the build started failing
with:

    Undefined                       first referenced
     symbol                             in file
    oe_get_size_slow                    t/helper/test-bitmap.o
    ld: fatal: symbol referencing errors. No output written to t/helper/test-tool

On other platforms this is presumably OK because the compiler and/or
linker detects that the "static inline" functions that reference
oe_get_size_slow() aren't used.

Let's solve this by moving the relevant code from pack-objects.h to
builtin/pack-objects.c. This is almost entirely a code-only move, but
because of the early macro definitions in that file referencing some
of these inline functions we need to move the definition of "static
struct packing_data to_pack" earlier, and declare these inline
functions above the macros.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'fr_next' of github.com:jnavila/git
Jiang Xin [Thu, 27 May 2021 02:28:50 +0000 (10:28 +0800)] 
Merge branch 'fr_next' of github.com:jnavila/git

* 'fr_next' of github.com:jnavila/git:
  l10n: fr: v2.32.0 round 1
  l10n: fr: fixed inconsistencies
  l10n: fr.po fixed inconsistencies

3 years agot2080: fix cp invocation to copy symlinks instead of following them
Matheus Tavares [Wed, 26 May 2021 23:58:56 +0000 (20:58 -0300)] 
t2080: fix cp invocation to copy symlinks instead of following them

t2080 makes a few copies of a test repository and later performs a
branch switch on each one of the copies to verify that parallel checkout
and sequential checkout produce the same results. However, the
repository is copied with `cp -R` which, on some systems, defaults to
following symlinks on the directory hierarchy and copying their target
files instead of copying the symlinks themselves. AIX is one example of
system where this happens. Because the symlinks are not preserved, the
copied repositories have paths that do not match what is in the index,
causing git to abort the checkout operation that we want to test. This
makes the test fail on these systems.

Fix this by copying the repository with the POSIX flag '-P', which
forces cp to copy the symlinks instead of following them. Note that we
already use this flag for other cp invocations in our test suite (see
t7001). With this change, t2080 now passes on AIX.

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosend-email: move "hooks_path" invocation to git-send-email.perl
Ævar Arnfjörð Bjarmason [Wed, 26 May 2021 11:21:07 +0000 (13:21 +0200)] 
send-email: move "hooks_path" invocation to git-send-email.perl

Move the newly added "hooks_path" API in Git.pm to its only user in
git-send-email.perl. This was added in c8243933c74 (git-send-email:
Respect core.hooksPath setting, 2021-03-23), meaning that it hasn't
yet made it into a non-rc release of git.

The consensus with Git.pm is that we need to be considerate of
out-of-tree users who treat it as a public documented interface. We
should therefore be less willing to add new functionality to it, least
we be stuck supporting it after our own uses for it disappear.

In this case the git-send-email.perl hook invocation will probably be
replaced by a future "git hook run" command, and in the commit
preceding this one the "hooks_path" become nothing but a trivial
wrapper for "rev-parse --git-path hooks" anyway (with no
Cwd::abs_path() call), so let's just inline this command in
git-send-email.perl itself.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosend-email: don't needlessly abs_path() the core.hooksPath
Ævar Arnfjörð Bjarmason [Wed, 26 May 2021 11:21:06 +0000 (13:21 +0200)] 
send-email: don't needlessly abs_path() the core.hooksPath

In c8243933c74 (git-send-email: Respect core.hooksPath setting,
2021-03-23) we started supporting core.hooksPath in "send-email". It's
been reported that on Windows[1] doing this by calling abs_path()
results in different canonicalizations of the absolute path.

This wasn't an issue in c8243933c74 itself, but was revealed by my
ea7811b37e0 (git-send-email: improve --validate error output,
2021-04-06) when we started emitting the path to the hook, which was
previously only internal to git-send-email.perl.

The just-landed 53753a37d09 (t9001-send-email.sh: fix expected
absolute paths on Windows, 2021-05-24) narrowly fixed this issue, but
I believe we can do better here. We should not be relying on whatever
changes Perl's abs_path() makes to the path "rev-parse --git-path
hooks" hands to us. Let's instead trust it, and hand it to Perl's
system() in git-send-email.perl. It will handle either a relative or
absolute path.

So let's revert most of 53753a37d09 and just have "hooks_path" return
what we get from "rev-parse" directly without modification. This has
the added benefit of making the error message friendlier in the common
case, we'll no longer print an absolute path for repository-local hook
errors.

1. http://lore.kernel.org/git/bb30fe2b-cd75-4782-24a6-08bb002a0367@kdbg.org

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot1092: revert the "-1" hack for emulating "no progress meter"
Junio C Hamano [Tue, 25 May 2021 20:52:34 +0000 (05:52 +0900)] 
t1092: revert the "-1" hack for emulating "no progress meter"

This looked like a good idea, but it seems to break tests on 32-bit
builds rather badly.  Revert to just use "100 thousands must be big
enough" for now.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agol10n: id: po-id for 2.32.0 (round 1)
Bagas Sanjaya [Sat, 17 Apr 2021 10:53:41 +0000 (17:53 +0700)] 
l10n: id: po-id for 2.32.0 (round 1)

Translate following components:

  * builtin/add.c
  * worktree.c
  * builtin/branch.c
  * builtin/commit.c
  * builtin/merge.c
  * builtin/rebase.c
  * builtin/pull.c
  * diff.c
  * add-interactive.c
  * builtin/log.c
  * builtin/stash.c
  * builtin/tag.c
  * config.c
  * builtin/config.c
  * reset.c
  * builtin/remote.c
  * builtin/rm.c
  * builtin/mv.c
  * builtin/clean.c
  * builtin/help.c
  * archive.c
  * submodule.c
  * builtin/submodule--helper.c
  * submodule-config.c

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
3 years agoMerge branch 'mt/init-template-userpath-fix'
Junio C Hamano [Tue, 25 May 2021 07:21:19 +0000 (16:21 +0900)] 
Merge branch 'mt/init-template-userpath-fix'

Regression fix.

* mt/init-template-userpath-fix:
  init: fix bug regarding ~/ expansion in init.templateDir

3 years agoMerge branch 'jt/send-email-validate-errors-fix'
Junio C Hamano [Tue, 25 May 2021 07:21:19 +0000 (16:21 +0900)] 
Merge branch 'jt/send-email-validate-errors-fix'

Fix a test breakage.

* jt/send-email-validate-errors-fix:
  t9001-send-email.sh: fix expected absolute paths on Windows

3 years agoMerge branch 'ab/send-email-validate-errors-fix'
Junio C Hamano [Tue, 25 May 2021 07:21:19 +0000 (16:21 +0900)] 
Merge branch 'ab/send-email-validate-errors-fix'

* ab/send-email-validate-errors-fix:
  send-email: fix missing error message regression

3 years agot1092: use GIT_PROGRESS_DELAY for consistent results
Derrick Stolee [Mon, 24 May 2021 19:55:07 +0000 (19:55 +0000)] 
t1092: use GIT_PROGRESS_DELAY for consistent results

The t1092-sparse-checkout-compatibility.sh tests compare the stdout and
stderr for several Git commands across both full checkouts, sparse
checkouts with a full index, and sparse checkouts with a sparse index.
Since these are direct comparisons, sometimes a progress indicator can
flush at unpredictable points, especially on slower machines. This
causes the tests to be flaky.

One standard way to avoid this is to add GIT_PROGRESS_DELAY=0 to the Git
commands that are run, as this will force every progress indicator
created with start_progress_delay() to be created immediately. However,
there are some progress indicators that are created in the case of a
full index that are not created with a sparse index. Moreover, their
values may be different as those indexes have a different number of
entries.

Instead, use GIT_PROGRESS_DELAY=-1 (which will turn into UINT_MAX)
to ensure that any reasonable machine running these tests would
never display delayed progress indicators.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoinit: fix bug regarding ~/ expansion in init.templateDir
Matheus Tavares [Tue, 25 May 2021 03:41:01 +0000 (00:41 -0300)] 
init: fix bug regarding ~/ expansion in init.templateDir

We used to read the init.templateDir setting at builtin/init-db.c using
a git_config() callback that, in turn, called git_config_pathname(). To
simplify the config reading logic at this file and plug a memory leak,
this was replaced by a direct call to git_config_get_value() at
e4de4502e6 ("init: remove git_init_db_config() while fixing leaks",
2021-03-14). However, this function doesn't provide path expanding
semantics, like git_config_pathname() does, so paths with '~/' and
'~user/' are treated literally. This makes 'git init' fail to handle
init.templateDir paths using these constructs:

$ git config init.templateDir '~/templates_dir'
$ git init
'warning: templates not found in ~/templates_dir'

Replace the git_config_get_value() call by git_config_get_pathname(),
which does the '~/' and '~user/' expansions. Also add a regression test.
Note that unlike git_config_get_value(), the config cache does not own
the memory for the path returned by git_config_get_pathname(), so we
must free() it.

Reported on IRC by rkta.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosend-email: fix missing error message regression
Ævar Arnfjörð Bjarmason [Mon, 24 May 2021 23:14:24 +0000 (01:14 +0200)] 
send-email: fix missing error message regression

Fix a regression with the "the editor exited uncleanly, aborting
everything" error message going missing after my
d21616c0394 (git-send-email: refactor duplicate $? checks into a
function, 2021-04-06).

I introduced a $msg variable, but did not actually use it. This caused
us to miss the optional error message supplied by the "do_edit"
codepath. Fix that, and add tests to check that this works.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot9001-send-email.sh: fix expected absolute paths on Windows
Johannes Sixt [Mon, 24 May 2021 19:38:09 +0000 (21:38 +0200)] 
t9001-send-email.sh: fix expected absolute paths on Windows

Git for Windows is a native Windows program that works with native
absolute paths in the drive letter style C:\dir. The auxiliary
infrastructure is based on MSYS2, which uses POSIX style /C/dir.

When we test for output of absolute paths produced by git.exe, we
usally have to expect C:\dir style paths. To produce such expected
paths, we have to use $(pwd) in the test scripts; the alternative,
$PWD, produces a POSIX style path. ($PWD is a shell variable, and the
shell is bash, an MSYS2 program, and operates in the POSIX realm.)

There are two recently added tests that were written to expect C:\dir
paths. The output that is tested is produced by `git send-email`, but
behind the scenes, this is a Perl script, which also works in the
POSIX realm and produces /C/dir style output.

In the first test case that is changed here, replace $(pwd) by $PWD
so that the expected path is constructed using /C/dir style.

The second test case sets core.hooksPath to an absolute path. Since
the test script talks to native git.exe, it is supposed to place a
C:/dir style path into the configuration; therefore, keep $(pwd).
When this configuration value is consumed by the Perl script, it is
transformed to /C/dir style by the MSYS2 layer and echoed back in
this form in the error message. Hence, do use $PWD for the expected
value.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>