User login

git apply does not work from within the local checkout of an unrelated git repository

As freshly documented at

git apply will fail to do anything when used within a local checkout of a git repository (other than the one for the project the patch is made for), such as if you are patching a module that is within a site that is in Git version control. Use patch -p1 < path/file.patch instead.

Here's a fun one. A patch that i apply with git apply has no effect whatsoever. When i use patch -p1 it works just fine
17:19 mlncn: History: this is a patch that i rolled at one point.
17:20 mlncn: i haven't noticed yet anywhere in the documentation of git apply that it will ignore anything it thinks you already have-- because i don't have it, views has been updated twice since i applied the patch.
17:27 mlncn: ... or maybe git apply just doesn't like the patch for some reason-- third one on this comment, if anyone has the latest views to try it on:
17:27 Druplicon: => Sort by Book Hierarchy does not exactly repeat book hierarchy => Views, book data, normal, reviewed & tested by the community, 14 comments, 4 IRC mentions

extremely weird. Running it gave me no output at all, and patch -p1 < worked fine
git apply does not have the < right? (Answer: works either way, with or without)
17:34 mlncn: hmm- i have this in a larger repository. I'll try some other random patch
17:34 mlncn: i have git version 1.7.1 btw
is there no output or no patched file? git apply doesn't report anything on success
17:36 mlncn: no output and the file is not patched
17:36 mlncn: it's all in version control (a site) and no change
17:36 mlncn: in the diff
17:36 mlncn: nor in the file, i checked that way too
17:37 mlncn: that patch majorly changes the file, not like i could miss it
git apply does not patch anything at all when it detects a conflict but in that case, it reports that

git apply works- it applies in a freshly downloaded views not in a repository
also applies in a separate git clone of views

it is supposed to work when it's in a random other repository, right?

git apply is not working when used from within my local checkout of the dgd7 site

i think it's official: git apply doesn't even try if it's already in a repository (other than the one for the project the patch is for)

18:07 mlncn: git apply --apply --verbose ../1113624-use-views-cache-loader-in-export-ui.patch
18:07 mlncn: no output
18:07 mlncn: rm -rf ../.git/
18:07 mlncn: git apply --apply --verbose ../1113624-use-views-cache-loader-in-export-ui.patch
18:07 mlncn: Checking patch plugins/export_ui/views_ui.class.php...
18:07 mlncn: Applied patch plugins/export_ui/views_ui.class.php cleanly.
18:08 mlncn: I'm documenting this. Not that i understand it, and i've read the git apply man file, but giving the next me a warning.

Searched words: 
git apply does nothing git-apply ignores existing doesn't work on something that's been version controlled


Lordy, thanks for FINALLY

Lordy, thanks for FINALLY clearing this up for me. Until reading your bolded "git apply will fail..." section I've been completely confused by this. Sheesh...

I just ran into this myself -

I just ran into this myself - someone had moved a .git directory to /tmp/.git ... ("it's like a trashcan, right?") ...

Net result was that all drush make runs would happily check the patch applied, then not apply the patch, then generate PATCHES.txt to document what it had been asked to do ...

Very frustrating to track down. Glad at least I'm not the only one who's run across this!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.