Skip to content

Fix order of branches in git diff when preparing sparse checkout rebase

With !1611 (merged) we started using sparse checkouts when rebasing to improve performance. To prevent an empty checkout, git diff --name-only branch...remote_branch is used to add a list of changed files to <REPO_PATH>.git/worktrees/rebase-2/info/sparse-checkout.

In cases where all changes on the remote branch were to files not present in the source branch, git checkout --detach branch will fail with error: Sparse checkout leaves no entry on working directory because none of the files listed in sparse-checkout are present in the worktree.

The order used in git diff is incorrect - git uses the branch of the second commit. We want a list of files that changed in the source branch, not the remote. Per the git docs:

This form is to view the changes on the branch containing and up to the second, starting at a common ancestor of both

Fixes gitlab#118737 (closed)

Merge request reports

Loading