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

Failing to get staged files on 15.2.6 #1437

Closed
dereklowlind opened this issue Jun 11, 2024 · 11 comments · Fixed by #1440
Closed

Failing to get staged files on 15.2.6 #1437

dereklowlind opened this issue Jun 11, 2024 · 11 comments · Fixed by #1440

Comments

@dereklowlind
Copy link

Description

Latest version 15.2.6 fails to get staged files. Rolling back to 15.2.5 fixes this issue. Please let me know how I can help

Steps to reproduce

image

Environment

  • OS: WSL Ubuntu 20.04
  • Node.js: v20.9.0
  • lint-staged: 15.2.6
  • Using git submodules, not sure if this makes a difference
@sHoskens
Copy link

Same issue here, also fixed through using version 15.2.6.

Debug output with npx lint-staged -d:

  lint-staged:bin Running `lint-staged@15.2.6` on Node.js v18.19.0 (linux) +0ms
  lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  cwd: undefined,
  debug: true,
  diff: undefined,
  diffFilter: undefined,
  maxArgLength: undefined,
  quiet: false,
  relative: false,
  shell: false,
  stash: true,
  hidePartiallyStaged: true,
  verbose: false
} +2ms
  lint-staged:validateOptions Validating options... +0ms
  lint-staged:validateOptions Validated options! +0ms
  lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +0ms
  lint-staged:runAll Running all linter scripts... +0ms
  lint-staged:runAll Using working directory `/PROJECT/PATH` +0ms
  lint-staged:resolveGitRepo Resolving git repo from `/PROJECT/PATH` +0ms
  lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
  lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +1ms
  lint-staged:execGit Running git command [ 'rev-parse', '--path-format=absolute', '--show-toplevel' ] +0ms
  lint-staged:resolveGitRepo Resolved git directory to be `--path-format=absolute
/PROJECT/PATH` +24ms
  lint-staged:execGit Running git command [ 'rev-parse', '--path-format=absolute', '--absolute-git-dir' ] +24ms
  lint-staged:resolveGitRepo Resolved git config directory to be `--path-format=absolute
/PROJECT/PATH/.git` +6ms
  lint-staged:execGit Running git command [ 'log', '-1' ] +7ms
⚠ Skipping backup because there’s no initial commit yet.

  lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +7ms
✖ Failed to get staged files!

@iiroj
Copy link
Member

iiroj commented Jun 12, 2024

Thanks, what is your git version? Can you try upgrading it to latest?

If that doesn't help, can you edit the node_modules/lint-staged/resolveGitRepo.js file in your repo to remove the flag --path-format=absolute from the commands, does it help?

@bennor-akqa
Copy link

bennor-akqa commented Jun 12, 2024

This was happening to just one team member on a project, and updating Git solved it.

@iiroj
Copy link
Member

iiroj commented Jun 12, 2024

We don't really have an explicitly set version requirements for Git, but the features taken into use in 15.2.6 have been around since 2017 so maybe good to update, if only for the security issues.

Feel free to re-open this issue if updating Git doesn't help.

@iiroj iiroj closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2024
@iiroj iiroj pinned this issue Jun 12, 2024
@SamuelTrew
Copy link

I also faced this issue and had to pin to 15.2.5 to get it to work.

My git version is 2.18.0 and I'm not in a position to be able to update it. It was released on June 21st 2018 so should have the features you mentioned.

This seems like it might not just be git version related.

@rproserpio
Copy link

rproserpio commented Jun 12, 2024

I believe the --path-format option was introduced in 2.31.
See https://github.com/git/git/blob/master/Documentation/RelNotes/2.31.0.txt

@iiroj
Copy link
Member

iiroj commented Jun 12, 2024

I can probably remove the --path-format option since it should default to absolute paths anyway, just wanted to be sure.

@iiroj iiroj reopened this Jun 12, 2024
@shreythakkar11
Copy link

I just updated the git version and now its working fine. ( Was using 2.25.1 and updated to 2.45.2 )

@JE-lee
Copy link

JE-lee commented Jun 12, 2024

I face the same problem in my git version of 2.24.3。After some debugging, I am sure that the problem is the --path-format=absolute, which results in the wrong git repository path of --path-format=absolut\n/usr/xxxx/xxxx.

@dereklowlind
Copy link
Author

updating git from 2.25.1 -> 2.45.2 worked for me

@iiroj
Copy link
Member

iiroj commented Jun 12, 2024

I hope 15.2.7 works better: https://github.com/lint-staged/lint-staged/releases/tag/v15.2.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

8 participants