Skip to content

Don't set ghPath in git client under Cygwin#7021

Closed
samcoe wants to merge 1 commit intotrunkfrom
git-client-cygwin
Closed

Don't set ghPath in git client under Cygwin#7021
samcoe wants to merge 1 commit intotrunkfrom
git-client-cygwin

Conversation

@samcoe
Copy link
Contributor

@samcoe samcoe commented Feb 19, 2023

Fixes #6950

@samcoe samcoe self-assigned this Feb 19, 2023
@samcoe samcoe requested a review from a team as a code owner February 19, 2023 08:38
@samcoe samcoe requested review from mislav and vilmibm and removed request for a team February 19, 2023 08:38
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

This workaround has merit but also some edge-cases where it doesn't work, which makes me doubt whether we are on the right track.

Could an alternate solution be to provide an escape hatch for gh injecting itself as a credential helper for every git invocation? Then we could tell Cygwin users to manually use the escape hatch, i.e. to shift the responsibility on them. The plus side would be that someone in the future who also has trouble with our credential helper could use that same mechanism too.

}

func isCygwinTerminal(fd uintptr) bool {
func IsCygwinTerminal(fd uintptr) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're exporting a new function, maybe it's better to add it as a method to IOStreams? That way an IOStreams instance can just figure out the file descriptor bit without the caller having to pass it in.

io := f.IOStreams
ghPath := f.Executable()
stdout, ok := io.Out.(*os.File)
if ok && iostreams.IsCygwinTerminal(stdout.Fd()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If stdout was redirected, then I think this would result in a false negative. So an invocation in cygwin like gh repo clone ... >/dev/null could start erroring out again due to the original bug.

The go-gh term package has an approach of inspecting the commanding terminal even when inputs and outputs were redirected: https://github.com/cli/go-gh/blob/86f3a6e29984a9cbbef8f8d8ce031a6d43739e3d/pkg/term/env.go#L122-L125

@samcoe
Copy link
Contributor Author

samcoe commented Feb 21, 2023

@mislav I agree. I think I have an alternative approach. Will close this PR and open up another.

@samcoe samcoe closed this Feb 21, 2023
@samcoe samcoe deleted the git-client-cygwin branch February 21, 2023 04:13
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.

Cannot authenticate using cygwin Bash

2 participants