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

Use full path command for git cat-file command #67

Merged
merged 2 commits into from
Mar 25, 2023

Conversation

sirbrillig
Copy link
Owner

When referencing a file in the remote repository, git requires that you specify the full path to the file.

For example, if you are in the root of a repository and run the following commands:

> cd foo/bar/
> git show HEAD:file.php
> echo $?
128

This will return an error because it can't find a file with a relative path. Instead, you can run the command with the full path to the file relative to the repo root:

> cd foo/bar/
> git show HEAD:$(git ls-files --full-name file.php)
> echo $?
0

For the git show command, phpcs-changed already does this thanks to the work done in #18. However, the git cat-file command, added later in #28 does not use that strategy, which means it will not work outside of the repository root.

In this PR we alter git cat-file to also use the full path name.

Fixes #66

@sirbrillig sirbrillig merged commit 0a6a6ee into master Mar 25, 2023
@sirbrillig sirbrillig deleted the use-full-path-command-for-git-commands branch March 25, 2023 15:09
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.

git is not found in PATH on Windows
1 participant