install.sh: shallow clone, about 215 MB to download instead of 351 - #52
Merged
Merged
Conversation
…instead of 350 After #51 a full clone is about 550 MB on disk (351 MB to download), most of it earlier versions of the sample films kept in the history. The installer now clones with --depth 1 --single-branch: about 210 MB to download, 420 MB on disk. Re-running it on a shallow checkout fetches the newest commit with --depth 1 and moves to it with reset --keep (a depth-1 fetch can't be fast-forwarded): untracked and ignored files (LOCAL.md, projects/) and edits to untouched files stay; a file it would overwrite, or commits of your own, stop it with a hint. A full clone keeps git pull --ff-only, since a depth-1 fetch would make it shallow. READMEs (en/zh): clone and total sizes (825 MB instead of 935), the "What gets downloaded" row, a note that contributors who want the history clone normally, and "To update" says to re-run the install command.
…branch; put origin/main back when the reset is refused
Review of the shallow-clone update found two cases:
- On a branch without upstream, or a detached HEAD, the own-commits check
read a failed rev-list as "no commits", fetched anyway and then blamed
the user's edits. With an upstream configured but origin/main missing,
it exited 0 and left a commit of your own behind. It now resolves @{u}
first and stops with a message if it can't.
- When reset --keep refused, origin/main had already moved to the new
parentless commit, so after a manual git pull the next run reported
"commits of your own" that didn't exist, and git status showed
ahead 1 / behind 1. origin/main is now put back before exiting.
The hint now tells edited files (stash, re-run, stash pop) from untracked
ones (move them out of the way). Docs: "re-run with the same options" and
how to pass them to the one-line install; the download is about 215 MB
(decimal, like the 351 MB of a full clone); v3's README says to fetch
7057c74 first in the installer's clone.
…nt for a missing origin/main
- rev-parse -q --verify '@{u}' still prints "fatal: no upstream…" on Apple
Git 2.39; send it to /dev/null so only the installer's own message shows.
- After a refused reset, the fetched commit stays grafted in .git/shallow, so
a plain git pull still can't fast-forward (it couldn't before either);
the comment and CHANGELOG no longer say it can. Re-running the installer
works.
- When the branch is main but origin/main is missing, the hint now says to
git fetch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
install.shnow clones only the newest commit (git clone --depth 1 --single-branch), so a fresh install downloads about 215 MB instead of 351 MB, and the clone takes about 420 MB on disk instead of 547 MB.du -sh).git--depth 1 --single-branchThe real installer, run against GitHub with
--no-refs --no-skill, comes to 626 MB: the 419 MB clone plus 207 MB ofnode_modules. Adding the 195 MB of reference repos gives about 825 MB, down from 935 MB.Why
After #51, most of
.gitis old versions of the sample films (showcase/04-intro-film/media/final.mp4alone is 48 MB, and v3's media moved tov3/). People who only make videos don't need that history.How re-running the installer updates a checkout
Shallow checkout (
.git/shallowexists):@{u}doesn't resolve: a detached HEAD, or a branch of your own);@{u}..HEADisn't empty and HEAD isn't a shallow boundary).git fetch -q --depth 1, thengit reset -q --keep '@{u}'. The new commit's parent isn't fetched, so there is nothing to fast-forward along.reset --keepmoves the branch and leaves untracked and ignored files (LOCAL.md,projects/) and edits to untouched files alone.reset --keeprefuses because it would overwrite an edited file, or an untracked file that isn't ignored:origin/mainis put back where it was, sogit statusand the next run see the checkout unchanged;git pullwould still fail in that state, because the fetched commit stays grafted in.git/shallow; it failed before this change too. The README tells shallow installs to update by re-running the installer, and keepsgit pullfor full clones.stash popfor edited files, move untracked ones out of the way.Full clone (made by hand, or by an earlier installer): still
git pull --ff-only. I checked that a--depth 1fetch turns a full clone shallow (rev-list --count origin/mainis 1 afterwards), so full clones don't go through the shallow path.Docs
git clone https://github.com/ZLHad/OpenVideoHarness.git, about 550 MB);| bash -s -- --no-refs).showcase/04-intro-film/v3/README*: thegit checkout 7057c74 -- showcase/04-intro-filminstruction fails in a depth-1 clone. It now says to rungit fetch --depth 1 origin <full sha>first; I checked that GitHub serves this by-SHA fetch.install.shheader comment, and CHANGELOG (Unreleased).How I tested it
install.shagainst a local synthetic remote (stub engines,--no-refs --no-skill). It has 50 checks:LOCAL.md,projects/and an edit to an untouched file;origin/mainback; afterstash, the re-run succeeds;git pull, then a clash, thenstash, then a re-run succeeds, with no false "own commits";fatal:;origin/mainmissing, plus a commit of your own, stops the update;/bin/bash3.2 and bash 5, and again with the script piped on stdin, ascurl | bashruns it. They pass with git 2.43.0 and with Apple Git 2.39.5. The first commit'sinstall.shfails 12 of them; those are the cases an independent review found.git statusis clean afterwards.tools/ci.sh --committedpasses with shellcheck 0.11.0 and pyflakes, both under bash 5 and withVH_BASH=/bin/bash.git pullwording, quietingrev-parseon 2.39, and the hint for a missingorigin/main.