Skip to content

Don't use deprecated git sparse-checkout init

Craig Andrews requested to merge candrews/gitlab:git-sparse-no-init into master

What does this MR do and why?

Don't use deprecated git sparse-checkout init

Per https://git-scm.com/docs/git-sparse-checkout#Documentation/git-sparse-checkout.txt-eminitem

init

Deprecated command that behaves like set with no specified paths. May be removed in the future.

Historically, set did not handle all the necessary config settings, which meant that both init and set had to be called. Invoking both meant the init step would first remove nearly all tracked files (and in cone mode, ignored files too), then the set step would add many of the tracked files (but not ignored files) back. In addition to the lost files, the performance and UI of this combination was poor.

Also, historically, init would not actually initialize the sparse-checkout file if it already existed. This meant it was possible to return to a sparse-checkout without remembering which paths to pass to a subsequent set or add command. However, --cone and --sparse-index options would not be remembered across the disable command, so the easy restore of calling a plain init decreased in utility.

Screenshots or screen recordings

n/a

How to set up and validate locally

n/a

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports