Skip to content
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

Fix repeated corruption of packed-refs #438

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions artifacts/scripts/construct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ git config user.name "$GIT_COMMITTER_NAME"
echo "Running garbage collection."
git config gc.pruneExpire 3.days.ago
git gc --auto

# Remove corrupted lines in .git/packed-refs
# Lines not starting with '^' caret are printed as-is. Lines
# that do not start with a caret are printed ONLY if the previous
# line did not start with a caret
echo "Cleaning .git/packed-refs"
cp .git/packed-refs .git/packed-refs.bak
awk '
NR == 1 {
prev_line_start_with_caret = 0
}
/^[^^]/ {
prev_line_start_with_caret = 0
print
}
/^\^/ {
if (!prev_line_start_with_caret) {
print
}
prev_line_start_with_caret = 1
}
' .git/packed-refs.bak > .git/packed-refs
rm .git/packed-refs.bak

echo "Fetching from origin."
dims marked this conversation as resolved.
Show resolved Hide resolved
git fetch origin --no-tags --prune
echo "Cleaning up checkout."
Expand Down