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

Git clean on a specific file does nothing #2499

Closed
1 task done
joaomoreno opened this issue Jan 30, 2020 · 10 comments
Closed
1 task done

Git clean on a specific file does nothing #2499

joaomoreno opened this issue Jan 30, 2020 · 10 comments

Comments

@joaomoreno
Copy link

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.25.0.windows.1
cpu: x86_64
built from commit: 7c71c859c97853ed057da5cbab12f3c13b5554df
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.18363.592]
  • What options did you set as part of the installation? Or did you choose the
    defaults?

Portable Git

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

CMD

First, let's create a repo with a file inside a folder:

mkdir repro
cd repro
git init
mkdir folder
touch folder\file

Then, place the following bug.js node.js script at the root of the repo:

const cp = require('child_process');
const path = require('path');
const filePath = path.join(__dirname, 'folder', 'file');

// replace this with wherever you have git 2.25
const git = 'C:\\Users\\joao\\Downloads\\PortableGit-2.25\\bin\\git.exe';

cp.spawnSync(git, ['clean', '-f', '-q', '--', filePath], { cwd: __dirname });

Then simply run it:

node bug.js

Just like @eamodio in #2478, I am shelling out to git via spawn. This works on 2.24. Doesn't work any more on 2.25.

Can't repro if the target file is at the root of the repository.

  • What did you expect to occur after running these commands?

I expect the file to be deleted from disk.

  • What actually happened instead?

Nothing happens.

@dscho
Copy link
Member

dscho commented Jan 30, 2020

This sounds like it might be fixed by https://github.com/git/git/pull/692/commits, in particular it looks very similar to the bug demonstrated in
git@9efed58

As this patch series already made it into the next branch of upstream Git, you can verify that it fixes things by building your own Git for Windows from the shears/pu branch:

  1. install Git for Windows' SDK,
  2. sdk cd git,
  3. git pull --ff-only origin shears/next
  4. build Git via make -j$(nproc)
  5. test in-place via ./git --exec-path="$PWD" -C <directory> <command>?
  6. reply here to report your results

@joaomoreno
Copy link
Author

@dscho Thanks for the steps, though they seem not to work as instructed:

image

Any help?

@dscho
Copy link
Member

dscho commented Feb 4, 2020

Please call sdk cd git first (step 2. above). It won't work otherwise.

@joaomoreno
Copy link
Author

Got it. Missed that I had to launch the SDK bash.

shears/next still has it broken. I can still reproduce the issue.

@dscho
Copy link
Member

dscho commented Feb 5, 2020

I just tried the very same repro with https://wingit.blob.core.windows.net/files/PortableGit-prerelease-2.25.0.windows.1.17.g89a5bbfd1e-64-bit.7z.exe and reproduced it. Then, I built shears/next in a Git for Windows SDK, updated the git variable in bug.js to update the location to point to the just-built git.exe, and it fixed the issue.

To make sure that you are using the correct git.exe, insert this line into bug.js:

cp.spawnSync(git, ['version'], { stdio: ['inherit', 'inherit', 'inherit'] });

and make sure that it displays this:

git version 2.25.0.windows.1.471.g3fce0d41a9f

@dscho
Copy link
Member

dscho commented Feb 5, 2020

(By the way, I do not think that node.js needs to be involved, so a more minimal repro would have used git clean -f -q -- folder\file directly, without detouring into a script.)

@joaomoreno
Copy link
Author

Hmm this didn't appear when spawning from Node, but if I try to execute that git outside of the SDK environment, I get a bunch of missing DLL errors:

image

@dscho
Copy link
Member

dscho commented Feb 5, 2020

Hmm this didn't appear when spawning from Node, but if I try to execute that git outside of the SDK environment, I get a bunch of missing DLL errors:

I don't know what exactly Node does, but those DLLs live in the mingw64\bin directory. The bin\git.exe you executed in your Node before was not actually the real git.exe, but the Git wrapper, i.e. a small executable that adjusts the PATH and then runs the real git.exe, waiting for it to exit.

@dscho
Copy link
Member

dscho commented Feb 5, 2020

(To fix those warnings, you will have to add C:\git-sdk-64\mingw64\bin to your PATH (or another path if you did not install your SDK to C:\git-sdk-64.)

@dscho
Copy link
Member

dscho commented Feb 6, 2020

Okay, I'll just assume that your testing confirms my testing.

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

2 participants