Skip to content

Conversation

@spog
Copy link

@spog spog commented Dec 6, 2025

When a shallowed repository gets deepened beyond the beginning of a merged branch, we may endup with some shallows, that are behind the reachable ones. Added test 'fetching deepen beyond merged branch' exposes that behaviour.

On the other hand, it seems that equivalent absolute depth driven fetches result in all the correct shallows. That led to this proposal, which unifies absolute and relative deepening in a way that the same get_shallow_commits() call is used in both cases. The difference is only that depth is adapted for relative deepening by measuring equivalent depth of current local shallow commits in the current remote repo. Thus a new function get_shallows_depth() has been added and the function get_reachable_list() became redundant / removed.

The get_shallows_depth() function also shares the logic of the get_shallow_commits() function, but it focuses on counting depth of each existing shallow commit. The minimum result is stored as 'data->deepen_relative', which is set not to be zero for relative deepening anyway. That way we can allways summ 'data->deepen_relative' and 'depth' values, because 'data->deepen_relative' is always 0 in absolute deepening.

Thanks for taking the time to contribute to Git! Please be advised that the
Git community does not use github.com for their contributions. Instead, we use
a mailing list ([email protected]) for code submissions, code reviews, and
bug reports. Nevertheless, you can use GitGitGadget (https://gitgitgadget.github.io/)
to conveniently send your Pull Requests commits to our mailing list.

For a single-commit pull request, please leave the pull request description
empty
: your commit message itself should describe your changes.

Please read the "guidelines for contributing" linked above!

@gitgitgadget-git
Copy link

There are issues in commit 17747ed:
shallow: handling fetch relative-deepen
Commit not signed off

@spog spog force-pushed the fix-fetch-deepen branch 11 times, most recently from 3508639 to 46dda2e Compare December 8, 2025 19:35
@xavyyrr
Copy link

xavyyrr commented Dec 8, 2025 via email

@spog spog force-pushed the fix-fetch-deepen branch 2 times, most recently from e89f7d8 to 4bef632 Compare December 8, 2025 21:53
@gitgitgadget-git
Copy link

There are issues in commit 4bef632:
shallow: free local object_array allocations
Commit not signed off

@spog spog force-pushed the fix-fetch-deepen branch from 4bef632 to 57565d8 Compare December 8, 2025 21:54
spog added 2 commits December 9, 2025 05:22
The local object_array 'stack' in get_shallow_commits() function
does not free its dynamic elements before the function returns.
As a result elements remain allocated and their reference forgotten.

Signed-off-by: Samo Pogačnik <[email protected]>
When a shallowed repository gets deepened beyond the beginning of a
merged branch, we may endup with some shallows, that are behind the
reachable ones. Added test 'fetching deepen beyond merged branch'
exposes that behaviour.

On the other hand, it seems that equivalent absolute depth driven
fetches result in all the correct shallows. That led to this proposal,
which unifies absolute and relative deepening in a way that the same
get_shallow_commits() call is used in both cases. The difference is
only that depth is adapted for relative deepening by measuring
equivalent depth of current local shallow commits in the current remote
repo. Thus a new function get_shallows_depth() has been added and the
function get_reachable_list() became redundant / removed.

The get_shallows_depth() function also shares the logic of the
get_shallow_commits() function, but it focuses on counting depth of
each existing shallow commit. The minimum result is stored as
'data->deepen_relative', which is set not to be zero for relative
deepening anyway. That way we can allways summ 'data->deepen_relative'
and 'depth' values, because 'data->deepen_relative' is always 0 in
absolute deepening.

Signed-off-by: Samo Pogačnik <[email protected]>
@spog spog force-pushed the fix-fetch-deepen branch from 57565d8 to b352a33 Compare December 9, 2025 04:22
@spog
Copy link
Author

spog commented Dec 9, 2025

/preview

@gitgitgadget-git
Copy link

Preview email sent as [email protected]

@spog
Copy link
Author

spog commented Dec 9, 2025

/submit

@gitgitgadget-git
Copy link

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2121/spog/fix-fetch-deepen-v1

To fetch this version to local tag pr-git-2121/spog/fix-fetch-deepen-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2121/spog/fix-fetch-deepen-v1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants