Skip to content

Conversation

@waych
Copy link
Contributor

@waych waych commented Jun 22, 2021

This PR fixes various issues affecting execution of git-branchless commands and tests on Windows.

  • Fixes handling of PATH environment variable (separator)
  • Calls "echo" from PATH on Windows, as git-bash actually keeps it at /usr/bin/echo
  • Strips EL VT sequence from test output (injected by git.exe or ConPTY?)
  • Use ":" for GIT_EDITOR to have git skip commit editing (during test invocations)
  • Provide a default git.exe path (for when use_system_git == true)
  • Call hooks via execution of sh, using git-bash on Windows when found.

With these changes all tests pass and commands appear to work as intended.

@waych waych mentioned this pull request Jun 22, 2021
@waych waych force-pushed the master branch 2 times, most recently from 69e760f to d8f41d0 Compare June 23, 2021 01:00
Copy link
Owner

@arxanas arxanas left a comment

Choose a reason for hiding this comment

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

@waych Thanks for working on this! One question, would you be able to get Github Actions to run CI for Windows as well? I'm almost certain to break the Windows build later if I don't have something to test on...

waych added 5 commits June 22, 2021 21:24
This way the test can pass on Windows as well
This seems to show up in Window git.exe output.
Replace guessing at paths for `true` when setting GIT_EDITOR and use ':'
instead.

':' is normally an equivalent to `true`, and git treats GIT_EDITOR=":"
especially to skip the editor invocation (see strcmp() against ":" in
`git/editor.c:launch_specified_editor()`.  Using it allows us to remove
the dependency on `true`, making this code simpler and portable to
Windows.
In tests, when the "system git" is desired, PATH_TO_GIT is ignored and a
hardcoded path to the system git is used (typically /usr/bin/git).

"system git" is only used in two places, and it is unclear how important
those locations be handled by "system git" rather than "git under test",
so just do the conservative thing and add a path to the default location
of git.exe on Windows.
@waych waych force-pushed the master branch 4 times, most recently from 67d8a3b to 77d541d Compare June 23, 2021 05:35
waych added 2 commits June 22, 2021 22:37
To run correctly on Windows, all invocations of hooks need to be
executed as an argument to bash.  This changes the code to build
commands using get_bash() with the `-c` flag.

When discovering which bash to use, we are careful on Windows to pick
"git-bash" aka the bash.exe that comes with git.  This is neccesary as
git-bash uses different path translations than regular bash.exe, and
using the wrong one would result in git.exe not being able to discover
the git-branchless.exe binary correctly (when invoked in hook).

If the target_os isn't windows, `sh` is for executing hooks instead.
@waych
Copy link
Contributor Author

waych commented Jun 23, 2021

PTAL

Rebased and addressed feedback.

@arxanas arxanas merged commit d4f74dd into arxanas:master Jun 23, 2021
@arxanas
Copy link
Owner

arxanas commented Jun 23, 2021

LGTM, thanks again!

@arxanas
Copy link
Owner

arxanas commented Jun 23, 2021

@waych Do you think there's anything else which should be done to say that it supports Windows? If not, I can tag a new release and announce support.

@waych
Copy link
Contributor Author

waych commented Jun 23, 2021

@arxanas Can't think of anything else that needs to be done at this point other than updates to the changelog. 😃

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.

3 participants