-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
safe.directory
handling broken when using Cygwin Git
#767
Comments
Per actions/checkout#767, the latest version of actions/checkout overrides any existing global Git configuration, and instead uses its own global configuration with safe.directory configured. Unfortunately, it configures a Windows path for safe.directory, which Cygwin Git doesn't handle. As a (hopefully) temporary workaround, pin that action to the known-working version, and continue to set safe.directory manually.
Hey @me-and , thanks for the report!
I'd love to avoid this if we can I don't fully understand how Cygwin works, but we copy the existing git global config from
The So i'm curious, what is breaking this part:
Do we need to find the path to the default global config from git itself, rather than trying to |
There's a run at https://github.com/me-and/Cygwin-Git/runs/6029980215 that shows this behaviour, although I had the impression that you wouldn't be able to view the logs even though it's a public repository. I can spin up a much simpler test case if that'd be useful, too. IIRC, Windows systems typically don't have a
(I've not actually tested the above, but it seems to make sense to me at least, and does explain the symptoms.) This has pointed me at a couple of other possible workarounds, though:
I'm not sure that getting Git to give you the correct path to the config file to use will actually help here, unfortunately, at least without a lot more care: if you ask Cygwin Git where it thinks the global config file lives, it'll output something like That said, rather than getting Git to tell you the path to the config file, you could just get it to dump out the contents of the config file, which should be much less fragile. It's a bit hacky, but you could use |
This is a useful trick, thanks! (Note that whatever solution you all go for, it should handle submodules gracefully; see also #766 (comment)) |
Try *, as per actions/checkout#767 (comment)
Unfortunately, there's a window of git versions that have the new Maybe both |
That definitely works for anything using current Cygwin releases, doesn't sound like it'd break anything for anyone else, and while I can contrive Cygwin-based edge cases where it wouldn't work, they're very contrived – either someone self-building one of the Git releases that has There's a purist part of me that doesn't like the idea of having redundant configuration lines for Git versions that support both options, and therefore either wants to test what option should be used every time or to make it something that users of this action could toggle with a |
Try *, as per actions/checkout#767 (comment)
To work around actions/checkout#767, where the checkout action tries to use the wrong Git config file as the basis for its temporary config file, set HOME explicitly to be the Cygwin home directory.
What about we change |
@TingluoHuang I think that depends on how you check. Running For now, per cygporter/git@08056b4, I'm working around this by just defining |
* fix: Config git to fix issue with checkout action with safe.directory and disable shellcheck - actions/checkout#760 - feat: disable SC on GH action workflows - SC2006:style:2:21: Use $(...) notation instead of legacy backticks `...` - SC2086:info:2:48: Double quote to prevent globbing and word splitting * fix: remove SC disble but add .github/workflows into FILTER_REGEX_EXCLUDE - dont think .github/linters/.jscpd.json works * fix: linter * Revert "fix: remove SC disble but add .github/workflows into" This reverts commit 3545f3f. * fix: more linter * fix: change to use linux path than windows path in ubuntu container * fix: upgrade to v3 fixed is in v3.0.2 - https://github.com/actions/checkout/blob/2541b1294d2704b0964813337f33b291d3f8596b/CHANGELOG.md#v302 * fix: trying with a solution for cygwin - ref: actions/checkout#767 - ref2: https://github.com/me-and/Cygwin-Git/actions/runs/2307847122/workflow * fix: Config git to fix issue with checkout action with safe.directory and disable shellcheck - actions/checkout#760 - feat: disable SC on GH action workflows - SC2006:style:2:21: Use $(...) notation instead of legacy backticks `...` - SC2086:info:2:48: Double quote to prevent globbing and word splitting * fix: remove SC disble but add .github/workflows into FILTER_REGEX_EXCLUDE - dont think .github/linters/.jscpd.json works * fix: linter * Revert "fix: remove SC disble but add .github/workflows into" This reverts commit 3545f3f. * fix: more linter * fix: change to use linux path than windows path in ubuntu container * fix: upgrade to v3 fixed is in v3.0.2 - https://github.com/actions/checkout/blob/2541b1294d2704b0964813337f33b291d3f8596b/CHANGELOG.md#v302 * fix: trying with a solution for cygwin - ref: actions/checkout#767 - ref2: https://github.com/me-and/Cygwin-Git/actions/runs/2307847122/workflow * fix: syntax for pwsh * fix: mark run to use pwsh
The fix at f25a3a9 is great for the vast majority of folk, but the way
safe.directory
is set and handled breaks my use case: I'm using Cygwin Git on Windows runners (I'm the maintainer of a number of Cygwin packages, including the Cygwin Git package). I'm installing Cygwin Git on the runner and adding it to the PATH before calling actions/checkout, which means actions/checkout uses Cygwin Git rather than the default Git that's present on the runner.Prior to Git v2.35.1, this worked perfectly. Using Git v2.35.1 or v2.35.2 with actions/checkout@v2.4.0, I needed to configure
safe.directory
before calling actions/checkout, but that makes sense and worked. However, with actions/checkout@v2.4.1,safe.directory
gets overridden to (say)D:\a\Cygwin-Git\Cygwin-Git
, and that doesn't work, because that's not the sort of path Cygwin Git expects. Even settingsafe.directory
to/cygdrive/d/a/Cygwin-Git/Cygwin-Git
in an earlier step doesn't work, because whengit
gets called as part of actions/checkout, it doesn't look at the default global .gitconfig at all.I'm not sure what the best solution is here; I'm aware my use case is fairly niche. Options I can see:
git init
works at all – but that layer is bypassed after the initial executable call.safe.directory
to*
rather than a specific path in this action. I think that's safe – certainly I can't immediately come up with something that would break, given the config would only exist for the duration of the action run – but it might not be in the spirit of that configuration option.For reference, the output I'm getting right now when trying to use actions/checkout looks like this:
The text was updated successfully, but these errors were encountered: