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

Make git apply working in non-root-git directories #294

Closed
mvorisek opened this issue Jan 7, 2020 · 1 comment
Closed

Make git apply working in non-root-git directories #294

mvorisek opened this issue Jan 7, 2020 · 1 comment

Comments

@mvorisek
Copy link

mvorisek commented Jan 7, 2020

git is the right choise for appliing patches as it is available more than every other solution at the most dev/prod systems, espetially non-linux ones like Windows, where the patch alternative is not often installed (or at least it is not available from the PATH).

I have analysed the issue related with issue #148 ( https://stackoverflow.com/questions/24821431/git-apply-patch-fails-silently-no-errors-but-nothing-happens/#27283285 ):

Problem:
patch is not applied via git apply if outside .git directory, in this case Skipped patch '<file path>'. verbose warning is show.

Analysis:

  1. trigerred here: https://github.com/git/git/blob/b02fd2accad4d48078671adf38fe5b5976d77304/apply.c#L4696
  2. based on condition https://github.com/git/git/blob/b02fd2accad4d48078671adf38fe5b5976d77304/apply.c#L4681
  3. the condition is not matched in case of not matching state->prefix (.git directory root path) https://github.com/git/git/blob/b02fd2accad4d48078671adf38fe5b5976d77304/apply.c#L2077
  4. state->prefix is set solely here https://github.com/git/git/blob/b02fd2accad4d48078671adf38fe5b5976d77304/apply.c#L93
  5. from setup_git_directory_gently() https://github.com/git/git/blob/99c33bed562b41de6ce9bd3fd561303d39645048/git.c#L416 line as the git apply command is marked with RUN_SETUP_GENTLY option
  6. setup_git_directory_gently() function tries to find .git directory and then it tests it with is_git_directory https://github.com/git/git/blob/bc12974a897308fd3254cf0cc90319078fe45eea/setup.c#L311 , this function tests the presence of these files:
    • .git/objects/
    • .git/refs/
    • .git/HEAD

These files needs to be presented in order to make git patch working.

PR submitted.

@mvorisek mvorisek changed the title Use WSL on Windows 10 for patch executable Make git apply working in non-root-git directories Jan 7, 2020
mvorisek added a commit to mvorisek/composer-patches that referenced this issue Jan 8, 2020
mvorisek added a commit to mvorisek/composer-patches that referenced this issue Jan 8, 2020
@cweagans
Copy link
Owner

See #296 (comment)

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

No branches or pull requests

2 participants