<div>Dev list:</div><div><br></div>Yeah I've definitely learned that you might be much better off using the 'create branches for features and delete them when done, or make them public to allow people to help' method rather than the old CVS 'make changes and then a patch' method of development. It's a transition, but I think it works really well once you get used to it. And I'm one of the biggest CVS curmudgeons in Drupal.<div>
<br clear="all">Dave Reid<br><a href="mailto:dave@davereid.net">dave@davereid.net</a><br>
<br><br><div class="gmail_quote">On Mon, Apr 11, 2011 at 4:42 PM, Bob Hutchinson <span dir="ltr"><<a href="mailto:hutchlists@midwales.com">hutchlists@midwales.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Monday 11 April 2011, Dave Cohen wrote:<br>
> I'm trying, and failing, to create a patch that adds new files to a module.<br>
<br>
</div>Here is a simple way to pull together a patch on a drupal project.<br>
<br>
Create a new directory, let's call it 'git-sandbox'<br>
cd into it and run something like this:<br>
<br>
git clone --branch 6.x-3.x <a href="http://git.drupal.org/project/mymodule.git" target="_blank">http://git.drupal.org/project/mymodule.git</a><br>
<br>
This will create a directory 'mymodule' (or whatever you fetched)<br>
<br>
copy your changed files into it and run<br>
<br>
git diff > mymodule.patch<br>
<br>
if you are adding new files copy them in and run 'add .'<br>
<br>
cd in and run<br>
<br>
git diff --staged > mymodule.patch<br>
<br>
To do both at the same time<br>
<br>
git diff HEAD > mymodule.patch<br>
<br>
As Sam Boyer explains earlier in this thread.<br>
<br>
open the patchfile in your editor and eyeball to see if it makes any sense<br>
<br>
If that's OK copy the patchfile away somewhere and delete<br>
the whole mymodule directory and run the git clone command again, copy the<br>
patchfile back in and run<br>
<br>
git apply mymodule.patch<br>
or<br>
patch -p1 < mymodule.patch<br>
<br>
if it applies cleanly you are ready to upload the patch to the issue queue<br>
or wherever.<br>
<br>
Of course a git clone run using http cannot be used for commits so it is<br>
'safer' as it were.<br>
<br>
You can also do all this and a lot more using a tool like Smartgit though<br>
many would argue that learning it on the command line is better for<br>
understanding it, true enough.<br>
<br>
Another *big* help is to install the git docs (as well as php, mysql etc)<br>
on your devbox.<br>
<br>
Hope this helps.<br>
<div><div></div><div class="h5"><br>
><br>
> According to <a href="http://drupal.org/node/707484" target="_blank">http://drupal.org/node/707484</a>, I should simply run `git add<br>
> ...` then "Next time you run git diff, these new files will be included as<br>
> well." In my experience, this statement is false.<br>
><br>
> When I run `git status`, I see something like this:<br>
><br>
> [dave@starbuck fb-3]$ git status<br>
> # On branch 6.x-3.x<br>
> # Changes to be committed:<br>
> # (use "git reset HEAD <file>..." to unstage)<br>
> #<br>
> # new file: fb.process.inc<br>
> # new file: fb_tab.js<br>
> #<br>
> # Changes not staged for commit:<br>
> # (use "git add <file>..." to update what will be committed)<br>
> # (use "git checkout -- <file>..." to discard changes in working<br>
> directory) #<br>
> # modified: README.txt<br>
> # modified: contrib/fb_example.module<br>
> # modified: fb.module<br>
> # modified: fb_canvas.admin.inc<br>
> # modified: fb_canvas.module<br>
> # modified: fb_devel.module<br>
> # modified: fb_settings.inc<br>
> # modified: fb_tab.admin.inc<br>
> # modified: <a href="http://fb_tab.info" target="_blank">fb_tab.info</a><br>
> # modified: fb_tab.module<br>
> # modified: fb_url_rewrite.inc<br>
><br>
><br>
> When I run `git diff`, I see changes to all the modified files, but I do<br>
> not see the new files.<br>
><br>
> What am I missing? Thanks,<br>
><br>
> -Dave<br>
<br>
<br>
</div></div><font color="#888888">--<br>
-----------------<br>
Bob Hutchinson<br>
Midwales dot com<br>
-----------------<br>
</font></blockquote></div><br></div>