Skip to content

Commit b94f22d

Browse files
committed
fix: avoid git 2.56's crash in drift's move
1 parent c3c0b4b commit b94f22d

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎.github/workflows/drift.yml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,17 @@ jobs:
329329
# on it with the App token. The build job moved to main's tip after the event, so before the
330330
# switch the commit must be in main's history and descend from GITHUB_SHA, the event's commit,
331331
# which the runner sets. The shallow checkout reaches back to the event's commit only, so the
332-
# history is fetched whole, commits without their trees, and the switch fetches the trees it
333-
# needs.
332+
# history is fetched whole, commits and trees without their files, and the switch fetches the
333+
# files it needs. The trees are small here, since index.db is a file. Not tree:0, which leaves
334+
# the trees out too: git 2.56.0 crashes repacking that fetch once main has moved past the
335+
# checkout's commit, which is the case this move is for.
334336
- name: Move to the build job's commit
335337
id: move
336338
env:
337339
SHA: ${{ needs.build.outputs.sha }}
338340
run: |
339341
[[ $SHA =~ ^[0-9a-f]{40}$ ]] || { echo 'the build job handed on no full commit SHA' >&2; exit 1; }
340-
git fetch --filter=tree:0 --unshallow origin +refs/heads/main:refs/remotes/origin/main
342+
git fetch --filter=blob:none --unshallow origin +refs/heads/main:refs/remotes/origin/main
341343
git merge-base --is-ancestor "$SHA" refs/remotes/origin/main || { echo 'not a commit of main' >&2; exit 1; }
342344
git merge-base --is-ancestor "$GITHUB_SHA" "$SHA" || { echo "older than the event's commit" >&2; exit 1; }
343345
git fetch origin "$SHA" && git switch --detach "$SHA"

‎test/drift-workflow.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ const PR_NO_CACHE = '.pr-job-restores-no-cache';
4343
* event, so the build job fetches main's tip and builds on it, and the pr job moves to the commit the build job
4444
* handed on once it is a commit of main no older than the event's. The build move is three lines: under bash -e a
4545
* failed fetch in a `fetch && switch` line would not end the script, which would then hand on the event's commit, and
46-
* the pr move accepts that one. A change to either has to change this test on purpose.
46+
* the pr move accepts that one. The pr move fetches main's history with blob:none, not tree:0: git 2.56.0 crashes
47+
* repacking a tree:0 unshallow fetch once main has moved past the checkout's commit, and the fixture tests of the pr
48+
* move, which run real git, catch that on the git CI has. A change to either has to change this test on purpose.
4749
*/
4850
const BUILD_MOVE_RUN = String.raw`git fetch --depth=1 origin main
4951
git switch --detach FETCH_HEAD
5052
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
5153
`;
5254
const PR_MOVE_RUN = String.raw`[[ $SHA =~ ^[0-9a-f]{40}$ ]] || { echo 'the build job handed on no full commit SHA' >&2; exit 1; }
53-
git fetch --filter=tree:0 --unshallow origin +refs/heads/main:refs/remotes/origin/main
55+
git fetch --filter=blob:none --unshallow origin +refs/heads/main:refs/remotes/origin/main
5456
git merge-base --is-ancestor "$SHA" refs/remotes/origin/main || { echo 'not a commit of main' >&2; exit 1; }
5557
git merge-base --is-ancestor "$GITHUB_SHA" "$SHA" || { echo "older than the event's commit" >&2; exit 1; }
5658
git fetch origin "$SHA" && git switch --detach "$SHA"

0 commit comments

Comments
 (0)