Skip to content
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

Associate with .sh files no longer works properly #396

Closed
b9chris opened this issue Sep 16, 2015 · 22 comments
Closed

Associate with .sh files no longer works properly #396

b9chris opened this issue Sep 16, 2015 · 22 comments
Assignees

Comments

@b9chris
Copy link

b9chris commented Sep 16, 2015

We've updated from msysgit/Git for Windows 32-bit to 64-bit on 3 machines now. We're late to switch so 2.5.2.2 is our first 64-bit version. Beforehand we had the .sh file associate working properly - double-click a .sh file, runs in Git Bash.

Now, there is a .sh association in the Registry, but what it fires off fails. Double-clicking a .sh file, you simply see a command prompt window flash. Nothing more occurs and the script does not run.

The .sh extension points to the sh_auto_file file type in HKEY_CLASSES_ROOT. That then holds the command,

"(msysgit)\git-bash.exe" --no-cd "%L" %*

Where (msysgit) is the Msysgit install path. It would seem there's something wrong with this command.

We can however run these same .sh scripts by typing them out - for example open Git Bash from the context menu and type ./scriptname.sh - runs fine.

Because we're late to switch it isn't clear when exactly this regression occurred.

@dscho
Copy link
Member

dscho commented Sep 16, 2015

The .sh extension points to the sh_auto_file file type in HKEY_CLASSES_ROOT. That then holds the command,

"\git-bash.exe" --no-cd "%L" %*

A little more precision would not hurt: HKEY_CLASSES_ROOT\sh_auto_file\shell\open\command is the key and the (Default) value should point to the complete path and the arguments, i.e. "C:\Program Files\Git\git-bash.exe" --no-cd "%L" %*.

And that is indeed what it does here, after a regular installation.

And that is indeed what the installer is told to do.

So feel free to rebuild the installer, possibly after fiddling with the install.iss.in file, to find out what the heck is going on.

@dscho dscho added the unclear label Sep 16, 2015
@b9chris
Copy link
Author

b9chris commented Sep 16, 2015

Yes, the installer did indeed place that command there for us as well. The problem is the command itself doesn't work - it results in that brief flash of a command window. So it's not the installer (and rebuilding the installer wouldn't help), so much as the command being added here.

It does appear this command has changed over time, so it would seem one of these changes resulted in this regression; for example when it was originally introduced it used:

"(msysgit)\bin\sh.exe" "--login" "%1" %*

And in fact if I replace the command the Installer placed here with the above, the .sh association works.

@dscho
Copy link
Member

dscho commented Sep 16, 2015

Yes, the installer did indeed place that command there for us as well.

But you reported that it places "\git-bash.exe" ... there, not "C:\Program Files\Git\git-bash.exe" ...! So what is it, does the installer place the same command there as for me or not?

@b9chris
Copy link
Author

b9chris commented Sep 16, 2015

Neither, on some machines we use a custom install path. Wherever we installed git is reflected in the path in the command. Take another look at my comment above - I edited it to clarify this.

The install path isn't the issue - the command is the problem. It's pointing to git-bash.exe in the right location, but the way it's calling git-bash.exe is failing. Rolling it back to the old command, that calls bin\sh.exe, fixes it, as I mention above.

@dscho
Copy link
Member

dscho commented Sep 16, 2015

I edited it to clarify this.

Why not clarify in a new comment? That way I can follow you easier.

The install path isn't the issue - the command is the problem

Then you did a good job leading me astray from the issue by putting something different than the verbatim value in your initial comment. Not so nice.

Where (msysgit) is the Msysgit install path

And this is positively wrong. There is no Msysgit, and not even an msysGit (the latter was the correct spelling). The project called msysGit was retired.

In any case, I re-tested the .sh file association with a file containing these commands:

echo "Test" $1

(cd / && pwd -W)

read x

then double-clicked that file in the Windows Explorer and it does exactly what I think it should do: open a window, print a line reading "Test", printing another line corresponding to the installation path and then waiting for my input. When I hit the Return key, the script exits and the window closes.

Our guide lines indicate pretty clearly that complete examples are preferred to incomplete ones. May I suggest to provide that? Maybe a complete, minimal Shell script, together with a description that says what you expected to happen and what happened instead? By now we spent so much time hashing things out, and we are still not done yet, that it is unfortunately so late that my answer will have to wait until tomorrow.

@b9chris
Copy link
Author

b9chris commented Sep 16, 2015

Sounds like maybe you were just reading the first version of the comment in email. You focused in on the path and that lead you astray. So, path: irrelevant. I don't think the name of this project matters much as it's also irrelevant, but as a reminder this code is in fact a fork of msysgit.

"git-for-windows/git
forked from msysgit/git"

We have 3 machines with this same issue so while your 1 machine has it working, I think you've still got a problem on your hands here.

The idea that the scripts are the problem doesn't fit because as mentioned 1) The scripts work if you call them from Git Bash 2) They work if we roll back the command to the old format.

For now we've resolved this across these machines by manually replacing the Registry command. When we have to attack it again on a 4th machine, I'll include a nonsense script for testing. But I suspect you'll have other users with this same issue in the meantime.

@nalla
Copy link

nalla commented Sep 17, 2015

My HKEY_CLASSES_ROOT\sh_auto_file\shell\open\command contains "C:\Program Files\Git\git-bash.exe" --no-cd "%L" %* after a fresh install - and everything is working as intended.

The git-bash call forwards the double click into a /usr/bin/bash --login -i C:\Users\dev\test.sh call.

@dscho
Copy link
Member

dscho commented Sep 17, 2015

Sounds like maybe you were just reading the first version of the comment in email [...]

Do you want to solve your problems or do you want to turn this into a mud fight?

We have 3 machines with this same issue

So what is the issue? Instead of rambling on and on and confusing me even more, why don't you just come up with that simple example. Just like I did. My example works. I am still waiting for some example that demonstrates that it does, in fact, not work, as the title of this ticket claims.

Seriously, if you really want to solve your problem, let's focus on that problem. Like, really focus on it.

So: MCVE, please. Or close the ticket if you are no longer interested in solving this problem.

@Lunatrius
Copy link

I can confirm the issue. Using the following test.sh file:

#!/usr/bin/env bash
echo "Test" $1
(cd / && pwd -W)
read x

I get a console window popping up (and closing almost immediately) saying:

The filename, directory name, or volume label syntax is incorrect.

Registry entry:

[HKEY_CLASSES_ROOT\sh_auto_file\shell\open\command]
@="\"C:\\Development\\Git\\git-bash.exe\" --no-cd \"%L\" %*"

Replacing git-bash.exe with a simple batch script printing %* yields the following:

--no-cd "C:\Users\Lunatrius\Desktop\test.sh"

@dscho
Copy link
Member

dscho commented Sep 20, 2015

@Lunatrius thanks for bringing some sanity back into this conversation.

However, when I try the same thing as you, it does work correctly. FWIW I saved the test.sh file onto the Desktop and then ran explorer . in the Git Bash after changing directory to the Desktop. It worked correctly, the error message you mentioned does not occur.

I also tried with a fresh Explorer window (not started from Git Bash). Same thing.

I even ran unix2dos test.sh and then double-clicked it again. Another succeeded run.

So something must be different between your setup and mine.

FWIW when I export the same registry, it looks different:

[HKEY_CLASSES_ROOT\sh_auto_file\shell\open\command]
@="\"C:\\Program Files\\Git\\git-bash.exe\" --no-cd \"%L\" %*"

In other words, my Git is installed into Program Files while yours is in Development. Now, this might not make any difference, but it reminds me that you did not specify anything about your setup, and you obviously have a non-standard setup (most users never change the install path, on Windows 10 I do not even know how you would change it because that page is not shown in the installer.)

So: may I get more details, please? Ideally precise enough that I can replicate as similar a setup as possible so I have a prayer of reproducing the issue.

@Lunatrius
Copy link

I upgraded from 1.9.4-preview, no idea about the exact version. Previous versions allowed the installation path to be changed and updating to the latest (2.5.3) seemed to have preserved that setting. I'm on Windows 8.1 x64, installed the 32-bit version of git-for-windows.

The options picked during the install/update were:

  • bash shell (default)
  • cmd instead of mintty
  • check-out windows, check-in unix

I get the same error message, even if I run the following via the run dialog WIN+R:

"C:\Development\Git\git-bash.exe" --no-cd "C:\Users\Lunatrius\Desktop\test.sh"

@Lunatrius
Copy link

I performed a few tests in a Win7 x64 VM using the 32 bit installer.

Error 1: The filename, directory name, or volume label syntax is incorrect.
Error 2: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

Test 1: double click
Test 2: "$INSTALL_LOC\git-bash.exe" --no-cd C:\User\VM\Desktop\test.sh
Test 3: "$INSTALL_LOC\git-bash.exe" --no-cd "C:\User\VM\Desktop\test.sh"

Install Location Terminal Test 1 Test 2 Test 3
C:\Development\Git cmd Error 1 works Error 1
C:\Development\Git mintty works works works
C:\Program Files (x86)\Git cmd Error 2 works Error 2
C:\Program Files (x86)\Git mintty works works works

I also tested using the syntax from test 2 on my normal install (the one previously mentioned) and it worked. Looks like a double quotes issue with the windows command prompt?

@dscho
Copy link
Member

dscho commented Sep 20, 2015

Thanks for the detailed analysis! I will have a look tomorrow trying to reproduce the error. Right now I cannot because I am on a phone... ☺

@Lunatrius
Copy link

Just used ProcessMonitor to check how exactly the process is created. These were generated by double clicking the batch/bash files:

C:\WINDOWS\system32\cmd.exe /c ""C:\Users\Lunatrius\Desktop\test.bat" "
C:\WINDOWS\system32\cmd.exe /C "C:\Development\Git\usr\bin\bash.exe" --login -i "C:\Users\Lunatrius\Desktop\test.sh" 

Running the following command from the run dialog started up the bash script as expected (added the "missing" double quotes):

C:\WINDOWS\system32\cmd.exe /C ""C:\Development\Git\usr\bin\bash.exe" --login -i "C:\Users\Lunatrius\Desktop\test.sh" "

@dscho
Copy link
Member

dscho commented Sep 21, 2015

I think I completely forgot to ask whether the script actually ran, the flashing window notwithstanding? I could actually understand if it did that; the current idea is that shell scripts might want to interact with the user, so they have to have a console window, but if they do not interact -- and finish fast -- the user would only see a flashing glimpse of the console window...

@dscho
Copy link
Member

dscho commented Sep 21, 2015

BTW I can finally reproduce, thanks to the crucial information that this bug affects only the ConHost option. Thanks @Lunatrius for bringing this to my attention.

@b9chris
Copy link
Author

b9chris commented Sep 21, 2015

The script doesn't run when this bug occurs - you just get the error message in a flash of a window and it's gone.

In our case the scripts were files that do basic things like pull git submodules:

#!/bin/bash -v
git submodule foreach git pull origin master

If it ran we'd see the effects of this running - pulled submodules. No dice.

dscho added a commit to dscho/git that referenced this issue Sep 21, 2015
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix git-for-windows#396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/MINGW-packages that referenced this issue Sep 21, 2015
Due to `cmd.exe`'s quirky quoting rules, we need to make use of the `/S`
option -- and use the `APPEND_QUOTE` option introduced into the Git
wrapper for this very purpose.

This is (2/3) to fix git-for-windows/git#396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/build-extra that referenced this issue Sep 21, 2015
In order for `Git Bash` to accept parameters correctly -- as is the case
with `.sh` file associations -- we need to adjust the way `cmd.exe`'s
arguments are quoted. Because the previous way simply was not working.

This is (3/3) to fix git-for-windows/git#396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member

dscho commented Sep 21, 2015

@b9chris hopefully you understand that my comment:

Our guide lines indicate pretty clearly that complete examples are preferred to incomplete ones.

was intended to elicit crucial information such as your decision to deviate from the default options in the installer by choosing the Windows console instead of the mintty one?

That omission cost both of us quite a bit of time.

Happily, @Lunatrius filled in the missing link and everything is groovy now.

Well, not everything. Every bug report is concluded successfully only when the original poster can confirm that the proposed fix is actually working for her.

So here is your chance to bring this ticket to a successful conclusion: install the tentatively-fixed version from this temporary installer:

https://github.com/dscho/build-extra/releases/download/tmp-conhost-git-bash/Git-2.5.3-sh-assoc-64-bit.exe

and test again, then report back whether it fixes the bug or not.

@dscho dscho self-assigned this Sep 21, 2015
@dscho
Copy link
Member

dscho commented Sep 22, 2015

I really hate it when I spend hours and hours to fix problems that are not even mine and then those whose problem it is cannot even be bothered to test my fix.

So I have to merge it untested. Grmbl. No brownies from me.

@dscho dscho closed this as completed Sep 22, 2015
dscho added a commit that referenced this issue Aug 13, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 13, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 15, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 15, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 15, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 15, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 20, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 20, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 22, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 22, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 22, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 25, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 25, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 25, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 26, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 26, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 27, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Aug 28, 2016
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@comspec@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix #396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
jeffhostetler pushed a commit to jeffhostetler/git that referenced this issue Sep 30, 2021
…ions

```
6e74958 p2000: add 'git checkout -' test and decrease depth
3e1d03c p2000: compress repo names
cd94f82 commit: integrate with sparse-index
65e79b8 sparse-index: recompute cache-tree
e9a9981 checkout: stop expanding sparse indexes
4b801c8 t1092: document bad 'git checkout' behavior
71e3015 unpack-trees: resolve sparse-directory/file conflicts
5e96df4 t1092: test merge conflicts outside cone
defab1b add: allow operating on a sparse-only index
9fc4313 pathspec: stop calling ensure_full_index
0ec03ab add: ignore outside the sparse-checkout in refresh()
adf5b15 add: remove ensure_full_index() with --renormalize
```

These commits are equivalent to those already in `next` via gitgitgadget#999.

```
80b8d6c Merge branch 'sparse-index/add' into stolee/sparse-index/add
```

This merge resolves conflicts with some work that happened in parallel, but is already in upstream `master`.

```
c407b2c t7519: rewrite sparse index test
9dad0d2 sparse-index: silently return when not using cone-mode patterns
2974920 sparse-index: silently return when cache tree fails
e7cdaa0 unpack-trees: fix nested sparse-dir search
347410c sparse-checkout: create helper methods
4537233 attr: be careful about sparse directories
5282a86 sparse-index: add SPARSE_INDEX_MEMORY_ONLY flag
3a2f316 sparse-checkout: clear tracked sparse dirs
fb47b56 sparse-checkout: add config to disable deleting dirs
```

These commits are the ones under review as of gitgitgadget#1009. Recent review made this less stable. It's a slightly different and more robust version of git-for-windows#396.

> Note: I'm still not done with the feedback for upstream, but the remaining feedback is "can we add tests that cover these tricky technical bits?" and in `microsoft/git` these are already covered by the Scalar functional tests (since that's how they were found).

```
080b02c diff: ignore sparse paths in diffstat
d91a647 merge: make sparse-aware with ORT
df49b5f merge-ort: expand only for out-of-cone conflicts
cdecb85 t1092: add cherry-pick, rebase tests
0c1ecfb sequencer: ensure full index if not ORT strategy
406dfbe sparse-index: integrate with cherry-pick and rebase
```

These commits integrate with `git merge`, `git cherry-pick`, `git revert`, and `git rebase` as of gitgitgadget#1019. This got some feedback that changed how the tests were working so they are more robust. This led to a new commit (0c1ecfb).

```
cbb0ab3 Merge branch 'sparse-index/merge' into vfs-2.33.0
acb8623 t7524: test no longer fails
```

Finally, the commits are merged into `vfs-2.33.0` and also we include a fix to a `microsoft/git` test that is no longer broken.

Cc: @vdye and @ldennington to get a (possibly overwhelming?) taste of sparse-index stuff. If you focus solely on the `git merge` commits you'll get a feel for what a sparse index integration looks like.
mjcheetham pushed a commit to mjcheetham/git that referenced this issue Jul 23, 2024
…ions

```
6e74958 p2000: add 'git checkout -' test and decrease depth
3e1d03c p2000: compress repo names
cd94f82 commit: integrate with sparse-index
65e79b8 sparse-index: recompute cache-tree
e9a9981 checkout: stop expanding sparse indexes
4b801c8 t1092: document bad 'git checkout' behavior
71e3015 unpack-trees: resolve sparse-directory/file conflicts
5e96df4 t1092: test merge conflicts outside cone
defab1b add: allow operating on a sparse-only index
9fc4313 pathspec: stop calling ensure_full_index
0ec03ab add: ignore outside the sparse-checkout in refresh()
adf5b15 add: remove ensure_full_index() with --renormalize
```

These commits are equivalent to those already in `next` via gitgitgadget#999.

```
80b8d6c Merge branch 'sparse-index/add' into stolee/sparse-index/add
```

This merge resolves conflicts with some work that happened in parallel, but is already in upstream `master`.

```
c407b2c t7519: rewrite sparse index test
9dad0d2 sparse-index: silently return when not using cone-mode patterns
2974920 sparse-index: silently return when cache tree fails
e7cdaa0 unpack-trees: fix nested sparse-dir search
347410c sparse-checkout: create helper methods
4537233 attr: be careful about sparse directories
5282a86 sparse-index: add SPARSE_INDEX_MEMORY_ONLY flag
3a2f316 sparse-checkout: clear tracked sparse dirs
fb47b56 sparse-checkout: add config to disable deleting dirs
```

These commits are the ones under review as of gitgitgadget#1009. Recent review made this less stable. It's a slightly different and more robust version of git-for-windows#396.

> Note: I'm still not done with the feedback for upstream, but the remaining feedback is "can we add tests that cover these tricky technical bits?" and in `microsoft/git` these are already covered by the Scalar functional tests (since that's how they were found).

```
080b02c diff: ignore sparse paths in diffstat
d91a647 merge: make sparse-aware with ORT
df49b5f merge-ort: expand only for out-of-cone conflicts
cdecb85 t1092: add cherry-pick, rebase tests
0c1ecfb sequencer: ensure full index if not ORT strategy
406dfbe sparse-index: integrate with cherry-pick and rebase
```

These commits integrate with `git merge`, `git cherry-pick`, `git revert`, and `git rebase` as of gitgitgadget#1019. This got some feedback that changed how the tests were working so they are more robust. This led to a new commit (0c1ecfb).

```
cbb0ab3 Merge branch 'sparse-index/merge' into vfs-2.33.0
acb8623 t7524: test no longer fails
```

Finally, the commits are merged into `vfs-2.33.0` and also we include a fix to a `microsoft/git` test that is no longer broken.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants