Skip to content

fix: use git add --sparse to handle sparse-checkout on orphan branch first run#23571

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-sparse-checkout-error
Mar 30, 2026
Merged

fix: use git add --sparse to handle sparse-checkout on orphan branch first run#23571
pelikhan merged 3 commits intomainfrom
copilot/fix-sparse-checkout-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

push_repo_memory.cjs fails on first run for a new memory branch because git checkout --orphan silently re-activates sparse-checkout, causing the subsequent git add . to reject files outside the sparse-checkout cone.

Changes

  • push_repo_memory.cjs: Replace git add . with git add --sparse . at the staging step — stages files unconditionally regardless of sparse-checkout state.
// Before
execGitSync(["add", "."], { stdio: "inherit" });

// After — --sparse bypasses sparse-checkout restrictions
execGitSync(["add", "--sparse", "."], { stdio: "inherit" });
  • push_repo_memory.test.cjs: Add regression test asserting --sparse is present and plain "add", "." is absent.

Copilot AI changed the title [WIP] Fix sparse-checkout error in push_repo_memory script fix: use git add --sparse to handle sparse-checkout on orphan branch first run Mar 30, 2026
Copilot AI requested a review from pelikhan March 30, 2026 17:50
@pelikhan pelikhan marked this pull request as ready for review March 30, 2026 18:05
Copilot AI review requested due to automatic review settings March 30, 2026 18:05
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review git add documentation

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes first-run failures of push_repo_memory.cjs when creating a new orphan “memory” branch under an active sparse-checkout by staging changes with git add --sparse ..

Changes:

  • Update staging step to use git add --sparse . to bypass sparse-checkout restrictions after orphan branch creation.
  • Add regression test asserting --sparse is present and that the prior "add", "." form is absent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/push_repo_memory.cjs Switches staging to git add --sparse . to prevent sparse-checkout reactivation from breaking first-run pushes.
actions/setup/js/push_repo_memory.test.cjs Adds a regression test that enforces the --sparse usage in the script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 30, 2026

@copilot review git add documentation

Reviewed the git add docs. The --sparse flag is officially documented (confirmed in git-add(1) locally):

--sparse: "Allow updating index entries outside of the sparse-checkout cone. Normally, git add refuses to update index entries whose paths do not fit within the sparse-checkout cone, since those files might be removed from the working tree without warning."

Updated the comment in push_repo_memory.cjs to quote that description directly (eb3b05d).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • git-scm.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions github-actions bot mentioned this pull request Mar 30, 2026
@pelikhan pelikhan merged commit e563676 into main Mar 30, 2026
56 checks passed
@pelikhan pelikhan deleted the copilot/fix-sparse-checkout-error branch March 30, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

push_repo_memory fails with sparse-checkout error on first run when creating orphan branch

3 participants