Skip to content

Commit

Permalink
Fix repeated corruption of packed-refs
Browse files Browse the repository at this point in the history
Signed-off-by: Davanum Srinivas <[email protected]>
  • Loading branch information
dims committed Jun 12, 2024
1 parent 687744d commit 1653e41
Showing 1 changed file with 24 additions and 0 deletions.
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."
git fetch origin --no-tags --prune
echo "Cleaning up checkout."
Expand Down

0 comments on commit 1653e41

Please sign in to comment.