Skip to content

mingw: take argv[0] from command line parameters #1561

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

Closed
wants to merge 2 commits into from

Conversation

kgybels
Copy link

@kgybels kgybels commented Mar 15, 2018

Instead of basing argv[0] on the executable path, use argv[0] as
provided on the command line.

Setting argv[0] to git- is currently the only way to prevent
git from falling back to calling a helper executable. This change will
allow the git-wrapper executable, that Git for Windows uses, to signal
to git to handle the command as a builtin.

Related to #1496

@kgybels
Copy link
Author

kgybels commented Mar 15, 2018

@dscho Initially I wanted to send this to the git mailing list, however, I noticed that mingw_startup is in git/git but msc_startup is not.

Instead of basing argv[0] on the executable path, use argv[0] as
provided on the command line.

Setting argv[0] to git-<builtin> is currently the only way to prevent
git from falling back to calling a helper executable. This change will
allow the git-wrapper executable, that Git for Windows uses, to signal
to git to handle the command as a builtin.

Related to git-for-windows#1496

Signed-off-by: Kim Gybels <[email protected]>
@@ -3396,8 +3396,7 @@ int msc_startup(int argc, wchar_t **w_argv, wchar_t **w_env)
*/
ALLOC_ARRAY(my_utf8_argv, argc + 1);
ALLOC_ARRAY(save, argc + 1);
save[0] = my_utf8_argv[0] = wcstoutfdup_startup(buffer, _wpgmptr, maxlen);

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@mfriedrich74
Copy link

mfriedrich74 commented Mar 16, 2018 via email

@dscho
Copy link
Member

dscho commented Mar 16, 2018

GetModuleFileNameW is the function that I would recommend to use. That returns the path for dlls or the current executable as absolute path.

Thanks for the suggestion! We already use _wpgmptr which serves the same purpose ;-)

@danjacques
Copy link

danjacques commented Mar 16, 2018 via email

@dscho
Copy link
Member

dscho commented Mar 16, 2018

Sound good?

@danjacques very!

@kgybels
Copy link
Author

kgybels commented Mar 16, 2018

@danjacques Sounds great!

@dscho I will wait for the rebased version, then add my work on top.

@kgybels
Copy link
Author

kgybels commented May 17, 2018

@dscho and @danjacques already did all the work (6e007ce), so I'm closing this pull request.

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.

4 participants