Development using git:Creating patches: Difference between revisions

From Alpine Linux
m (Reverted edits by 212.142.143.116 (Talk); changed back to last version by Macbrody)
mNo edit summary
Line 1: Line 1:
= Creating patches for aports =
= Creating patches =


After you did a checkout of the svn-sources you might want to add your changes to the '''apk-packages''' you build. ''(note: this applies to packages only to apk packages in aports directory)''
== Only the last commit with 'git send-email' ==


The easiest way is the following:
To submit the last commit as a patch to alpine-devel mailing list:


# Go to the package you want to edit, for example dhcp:
{{Cmd|git send-email --to alpine-devel@lists.alpinelinux.org HEAD^}}
% cd ~/SVN/alpine-builder/trunk/packages/aports/dhcp


The first line in commit message will be ''subject'' and the long description (separated with empty line) will be the body in the email. The example below shows


Make sure you have the upstream precompiled binary package:
<pre>
  % aports/dhcp% scp username@deva:/var/www/localhost/htdocs/alpine/v1.3/binpkgs/dhcp-3.0.3-r9.bin.tar.bz2 ~/SVN/alpine-builder/trunk/packages/binpkgs
Initial APKBUILD file of packagename <- Subject line


Enter some details about your package <- Mail body
here if you like.
</pre>


Clean up unpack the binary package as .orig copy.
{{Note|The git send-email command is provided by the '''git-perl''' package. }}
% make clean && make orig


Make your chages
== Multiple commits with 'git send-email' ==
% vim work/data/etc/init.d/dhcp


Now make sure you have no stale files lying around like ''work/data/etc/init.d/dhcp~''.
If you have many commits you can create a directory with patches and send them with <tt>git send-email</tt>.
Check that everything looks ok
% make diff


Create the patch directory if it does not exist:
{{Cmd|<nowiki>rm -Rf patches
% mkdir -p patches
mkdir patches
git format-patch -o patches origin
git send-email --to alpine-devel@lists.alpinelinux.org patches</nowiki>}}


Create the patch. It must has the .patch extension. Try to give it a meaningful name.
If you have multiple patch consider using:
% make diff > patches/10-mypatch.patch
{{Cmd|git send-email --compose --no-chain-reply-to --to alpine-devel@lists.alpinelinux.org patches}}
This will produce the patches for each local commit in the directory "patches" and send them.
Use --no-chain-reply-to make sure it doesn't reply.


Rebuild the package with the patch.
<!-- what does the following mean? -->
% make clean && make
Don't do:
* [PATCH 0/m]
** [PATCH 1/m]
*** [PATCH 2/m]
**** ...
But do:
* [PATCH 0/m]
** [PATCH 1/m]
** [PATCH 2/m]
** ..


Test your package and verify it works as expected.
== Multiple patches with 'email' ==


Add it to svn:
{{Cmd|git format-patch -1}}
% svn add patches/10-mypatch.patch


You can send the patch(es) to the [http://lists.alpinelinux.org/mailman/listinfo/alpine-devel alpine-devel] mailing list if you dont have svn commit access,
Where -1 sets how many commits you want to go back (mostly this is 1). This should create a patch called 0001......patch.
 
An easy way to send this patch to the list is with an program called 'email'.
 
{{Cmd|apk add email}}
 
to send to the mailing list you would do:  
 
{{Cmd|email -a 0001...patch alpine-devel@lists.alpinelinux.org}}
 
And provide a subject and body after you execute the above cmd.

Revision as of 13:14, 4 July 2011

Creating patches

Only the last commit with 'git send-email'

To submit the last commit as a patch to alpine-devel mailing list:

git send-email --to alpine-devel@lists.alpinelinux.org HEAD^

The first line in commit message will be subject and the long description (separated with empty line) will be the body in the email. The example below shows

Initial APKBUILD file of packagename  <- Subject line

Enter some details about your package <- Mail body
here if you like. 
Note: The git send-email command is provided by the git-perl package.

Multiple commits with 'git send-email'

If you have many commits you can create a directory with patches and send them with git send-email.

rm -Rf patches mkdir patches git format-patch -o patches origin git send-email --to alpine-devel@lists.alpinelinux.org patches

If you have multiple patch consider using:

git send-email --compose --no-chain-reply-to --to alpine-devel@lists.alpinelinux.org patches

This will produce the patches for each local commit in the directory "patches" and send them. Use --no-chain-reply-to make sure it doesn't reply.

Don't do:

  • [PATCH 0/m]
    • [PATCH 1/m]
      • [PATCH 2/m]
        • ...

But do:

  • [PATCH 0/m]
    • [PATCH 1/m]
    • [PATCH 2/m]
    • ..

Multiple patches with 'email'

git format-patch -1

Where -1 sets how many commits you want to go back (mostly this is 1). This should create a patch called 0001......patch.

An easy way to send this patch to the list is with an program called 'email'.

apk add email

to send to the mailing list you would do:

email -a 0001...patch alpine-devel@lists.alpinelinux.org

And provide a subject and body after you execute the above cmd.