fix(scripts): Show git checkout error output on branch creation failure#2082
fix(scripts): Show git checkout error output on branch creation failure#2082grafvonb wants to merge 1 commit intogithub:mainfrom
Conversation
mnriem
left a comment
There was a problem hiding this comment.
You will also have to deliver the Powershell variant
There was a problem hiding this comment.
Pull request overview
Improves diagnostics in scripts/bash/create-new-feature.sh so users can see the underlying git checkout error output when branch creation/switching fails, aiding troubleshooting during feature branch setup.
Changes:
- Captures
git checkoutstderr into a variable instead of discarding it. - Prints the captured stderr when branch creation/switching fails, while keeping existing branching logic and exit behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $checkoutStderr = '' | ||
| try { | ||
| git checkout -q -b $branchName 2>$null | Out-Null | ||
| $checkoutStderr = git checkout -q -b $branchName 2>&1 | Out-String | ||
| if ($LASTEXITCODE -eq 0) { |
There was a problem hiding this comment.
$checkoutStderr = git checkout ... 2>&1 | Out-String captures both stdout and stderr (it merges streams), so the variable name is a bit misleading and future changes to the git flags could accidentally include non-error output in the “stderr” blob. Consider either redirecting stdout away (while preserving stderr capture) or renaming the variable to reflect that it’s combined output.
Previously, stderr from git checkout was discarded (2>/dev/null), leaving users without diagnostic information when branch operations failed. Now captures and displays the actual git error message to help troubleshoot issues like conflicts or dirty working trees.
|
Please address Copilot feedback. Probably should reflect it is both |
Summary
Improves error reporting in
create-new-feature.shby displaying actual git error messages instead of silently discarding them.Problem
When
git checkout -borgit checkoutfailed, stderr was discarded with2>/dev/null. This left users without diagnostic information to troubleshoot issues like:Solution
Testing
Tested by attempting branch operations with:
--allow-existing-branchflag