-
-
Notifications
You must be signed in to change notification settings - Fork 300
Fix submodule deepening #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eed4443
fix test of restoring submodule.*.update
norbertbuchmueller 25b090b
fix inversion in restoring submodule.*.update
norbertbuchmueller af87a76
fix c&p error in it_preserves_the_submodule_update_method test
norbertbuchmueller 3fcaef6
rename some vars in a test to prepare for adding more tests
norbertbuchmueller 49aeff5
add tests for checking out submodules with depth=0
norbertbuchmueller 97b56be
do not set custom submodule.*.update script if depth=0
norbertbuchmueller 52ac479
check depth in assets/in and not the shallow clone deepening script
norbertbuchmueller 82ef5a3
submodule deepening test: test for the commit hash in submodule
norbertbuchmueller e31d5ce
submodule deepening test: test for failure if the ref cannot be found
norbertbuchmueller ad553ec
submodule deepening: actually check the ref out
norbertbuchmueller 6f01304
pass depth as arg not envvar when deepening shallow clone
norbertbuchmueller 8d1487a
fix typo in test name
norbertbuchmueller 6709829
Merge branch 'master' into fix-submodule-deepening
norbertbuchmueller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
assets/deepen_shallow_clone_until_ref_is_found_then_check_out
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/bin/bash | ||
| # vim: set ft=sh | ||
|
|
||
| set -e | ||
|
|
||
| readonly max_depth=128 | ||
|
|
||
| declare depth="$1" | ||
| readonly ref="$2" | ||
| readonly tagflag="$3" | ||
|
|
||
| # A shallow clone may not contain the Git commit $ref: | ||
| # 1. The depth of the shallow clone is measured backwards from the latest | ||
| # commit on the given head (master or branch), and in the meantime there may | ||
| # have been more than $depth commits pushed on top of our $ref. | ||
| # 2. If there's a path filter (`paths`/`ignore_paths`), then there may be more | ||
| # than $depth such commits pushed to the head (master or branch) on top of | ||
| # $ref that are not affecting the filtered paths. | ||
| # | ||
| # In either case we try to deepen the shallow clone until we find $ref, reach | ||
| # the max depth of the repo, or give up after a given depth and resort to deep | ||
| # clone. | ||
|
|
||
| git_dir="$(git rev-parse --git-dir)" | ||
| readonly git_dir | ||
|
|
||
| while ! git checkout -q "$ref" &>/dev/null; do | ||
| # once the depth of a shallow clone reaches the max depth of the origin | ||
| # repo, Git silenty turns it into a deep clone | ||
| if [ ! -e "$git_dir"/shallow ]; then | ||
| echo "Reached max depth of the origin repo while deepening the shallow clone, it's a deep clone now" | ||
| break | ||
| fi | ||
|
|
||
| echo "Could not find ref ${ref} in a shallow clone of depth ${depth}" | ||
|
|
||
| (( depth *= 2 )) | ||
|
|
||
| if [ "$depth" -gt "$max_depth" ]; then | ||
| echo "Reached depth threshold ${max_depth}, falling back to deep clone..." | ||
| git fetch --unshallow origin $tagflag | ||
|
|
||
| break | ||
| fi | ||
|
|
||
| echo "Deepening the shallow clone to depth ${depth}..." | ||
| git fetch --depth "$depth" origin $tagflag | ||
| done | ||
|
|
||
| git checkout -q "$ref" | ||
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
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
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
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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.