Skip to content

Commit efb92bc

Browse files
committed
constants for unixStdout and unixStderr
1 parent 05e42ea commit efb92bc

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

status.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,25 @@ var (
116116

117117
func setupStatus() {
118118
_setupStatus.Do(func() {
119-
if *statusFdOpt > 0 {
120-
switch *statusFdOpt {
121-
case 1:
122-
statusFile = os.Stdout
123-
case 2:
124-
statusFile = os.Stderr
125-
default:
126-
// TODO: debugging output if this fails
127-
statusFile = os.NewFile(uintptr(*statusFdOpt), "status")
128-
}
119+
if *statusFdOpt <= 0 {
120+
return
121+
}
122+
123+
const (
124+
unixStdout = 1
125+
unixStderr = 2
126+
)
127+
128+
// Even though Windows uses different numbers, we always equate 1/2 with
129+
// stdout/stderr because Git always passes `--status-fd=1`.
130+
switch *statusFdOpt {
131+
case unixStdout:
132+
statusFile = os.Stdout
133+
case unixStderr:
134+
statusFile = os.Stderr
135+
default:
136+
// TODO: debugging output if this fails
137+
statusFile = os.NewFile(uintptr(*statusFdOpt), "status")
129138
}
130139
})
131140
}

0 commit comments

Comments
 (0)