fix(scripts): suppress git fetch stdout leak in multi-remote environments#1876
fix(scripts): suppress git fetch stdout leak in multi-remote environments#1876seiya-koji wants to merge 1 commit intogithub:mainfrom
Conversation
In multi-remote environments, `git fetch --all` outputs messages like "Fetching origin" to stdout. Since `check_existing_branches()` only redirected stderr (`2>/dev/null`), the stdout output was captured by the `$(...)` command substitution calling this function, contaminating the branch number return value and causing arithmetic errors like `$((10#Fetching...))`. Fix: redirect both stdout and stderr to /dev/null (`>/dev/null 2>&1`).
There was a problem hiding this comment.
Pull request overview
This PR fixes a bash scripting bug in create-new-feature.sh where git fetch --all --prune could emit remote “Fetching …” lines to stdout in multi-remote setups, contaminating command-substitution output used for numeric branch calculations.
Changes:
- Redirect
git fetch --all --prunestdout + stderr to/dev/nullto keepcheck_existing_branches()output purely numeric.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR fixes a bash scripting bug where git fetch --all stdout could leak into command-substitution output in multi-remote repositories, corrupting the numeric branch-prefix value used for feature branch numbering.
Changes:
- Redirect
git fetch --all --prunestdout + stderr to/dev/nullto prevent contaminatingcheck_existing_branches()output. - Preserve existing behavior of tolerating fetch failures (
|| true) while ensuring the function returns a clean numeric value.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
In multi-remote environments,
git fetch --alloutputs messages likeFetching originto stdout. Sincecheck_existing_branches()only redirected stderr (2>/dev/null), the stdout output was captured by$(check_existing_branches ...)command substitution, contaminating the branch number return value andcausing arithmetic errors like
$((10#Fetching...)).Fix: redirect both stdout and stderr to
/dev/null(>/dev/null 2>&1).Reproduction
create-new-feature.shgit fetch --alloutputsFetching origin\nFetching forkto stdoutActual error output
Before fix (
2>/dev/null— stderr only):After fix (
>/dev/null 2>&1— stdout + stderr):Testing
originand a fork remote)git fetch --all --prune >/dev/null 2>&1suppresses stdout in multi-remote setupcreate-new-feature.shafter the fix and confirmed branch numbering works correctlyAI Disclosure
The bug was discovered automatically when running Spec Kit's
specifycommand via GitHub Copilot(Claude Opus 4.6) in a downstream project with multiple git remotes. The fix was also generated by the
same agent.