Managing Xen Patches with StGit: Difference between revisions
m (moved Submitting Xen Patches with Git to Submitting Xen Patches with StGit: This tutorial is using StGit, not bare git) |
Lars.kurth (talk | contribs) (→Sending a Patch or Patch Series to xen-devel@: Add a section on outbound branches) |
||
(19 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This document assumes that you are familiar with the following documents |
|||
== How To Generate and Submit a Patch to Xen using StGit == |
|||
* [[Xen Project Repositories]] |
|||
* [[Submitting Xen Project Patches]] - the document explains conventions related to cover letters, *-by tags, etc. as well as the tooling involved in sending patches and patch series |
|||
This document lays out basic examples and best practice of how to use StGit to manage Xen patches as part of the patch submission process. To be able to manage the patch contribution more easily, we [http://www.procode.org/stgit/ StGit], which is an application that runs on top of git and provides a functionality similar to Mercurial PatchQueue extension. This tutorial will show how to manage branches with git and StGit, so before proceeding please make sure that StGit is installed. |
|||
Xen uses [http://git-scm.com/ Git] for its source code management. The current Xen development tree is at http://xenbits.xen.org/gitweb/?p=xen.git;a=summary. Git provides excellent [http://git-scm.com/documentation documentation], please read it if this is your first time using Git. Download and install git to your system. |
|||
Similar documents exist for |
|||
=== Recommended git extensions === |
|||
* '''Git''': see [[Managing Xen Patches with Git]]. |
|||
* '''git-series''' is a tool on top of Git that tracks changes to a patch series over time, including cover letter for the patch series, formats the series for email, and prepares patch submission. You can find instructions at [[Managing Xen Patches with Git-series]]. |
|||
== StGit Basics == |
|||
To be able to manage patches better I recommend [http://www.procode.org/stgit/ StGit], which is an application that runs on top of git and provides a functionality similar to Mercurial PatchQueue extension. This tutorial will show how to manage branches with git and StGit, so before proceeding please make sure that StGit is installed. |
|||
StGit is a tool that runs on top of Git which allows you to manage patches in a stack on top of an existing git baseline. The stack of patches that have been created on top of your baseline maps to the patch series you are working on. To get started you have to initialise StGit on your working baseline (e.g. your current development branch of your repository using <code>stg init</code>). |
|||
=== Generating a patch === |
|||
---- |
|||
The, you add a new patch to your stack, with the following the basic workflow |
|||
Here's a recommendation on how to send patches, as suggested by the Xen maintainers. |
|||
<syntaxhighlight lang="sh" highlight="1,4,6"> |
|||
stg new <new-patch-id> |
|||
...edit patch description |
|||
...develop in the tree |
|||
stg refresh |
|||
...develop some more |
|||
stg refresh |
|||
</syntaxhighlight> |
|||
You can add several patches this way and then use <code>stg series</code> to list them. This shows your current stack of patches, where patches preceded by '''minus signs''' are not applied, patches preceded by '''plus signs''' are applied, while your '''current working patch''' is highlighted by a <code>></code> character in the <code>stg series</code> output. The current working patch is always also the current top of your stack of patches. |
|||
At any point you can edit the current tree to update your current working patch : Simply edit the files and use the <code>stg refresh</code> command to record your changes. You can use <code>stg refresh -e</code> to update the patch description as well. <code>stg show</code> will show the current (or any) patch. |
|||
You can manipulate the stack of patches using the <code>[http://procode.org/stgit/doc/stg-push.html push]</code>, <code>[http://procode.org/stgit/doc/stg-pop.html pop]</code>, <code>[http://procode.org/stgit/doc/stg-goto.html goto]</code>, <code>[http://procode.org/stgit/doc/stg-sink.html sink]</code> and <code>[http://procode.org/stgit/doc/stg-float.html float]</code> StGit commands. The most basic option to control the stack - and thus the current working patch - is a sequence of <code>pop</code> commands, followed by an edit-refresh cycle and a matching sequence of <code>push</code> commands. This works very well in a review cycle, where typically you move from one patch of a series to another. The <code>goto</code> command can be used if you need to move the current working patch by more than a few positions in the stack. |
|||
Before running any command the first time, we recommended that you at least quickly skim through its [http://procode.org/stgit/doc/stg.html man pages]. Many of the commands have very useful and interesting features that are not listed here: sometimes there are some extra notes which are very useful. Quick usage help is available for the StGit command using <code>stg help <command></code>. |
|||
If you want to rebase your series of patches against a different baseline, or just rebase an existing one you can use the <code>stg pull</code> command. It will pop all the patches, then update your current branch to the upstream revision using <code>git pull</code>, then push your patches back on top of the new base. If conflicts occur you need to resolve them and tell StGit using the <code>stg resolved</code> command and then update the patch using <code>stg refresh</code> and resume by performing a <code>stg push -a</code>. |
|||
== Generating an initial Patch or Patch Series == |
|||
Here's a recommendation on how to manage patches with StGit, as suggested by the Xen maintainers. Before you follow the instructions, you may want to read the following short discussion about whether to develop against [[Managing_Xen_Patches_with_Git#staging-master|<code>staging</code> or <code>master</code>]] branches. Unlike the [[Managing Xen Patches with Git|git guide]], this document assumes you are developing against <code>master</code>. |
|||
The first thing to do is cloning the xen git repository: |
The first thing to do is cloning the xen git repository: |
||
<syntaxhighlight lang="sh" highlight="1,3"> |
|||
<pre> |
|||
git clone git://xenbits.xen.org/xen.git |
$ git clone git://xenbits.xen.org/xen.git |
||
$ cd xen |
|||
</pre> |
|||
$ stg init |
|||
</syntaxhighlight> |
|||
This will create a new folder, called xen, and initialises StGit where you will work on your patches. |
|||
This will create a new folder, called xen, where you will work on your patches. We are going to create a branch for each series of patches that we are going to work on. This will allow a developer to work on several patch series at the same time, keeping the patches contained and well classified. Now we will create a new branch on top of the default branch, which is called "master". |
|||
=== Create a branch for your changes === |
|||
<pre> |
|||
We are going to create a branch for each series of patches that we are going to work on. This will allow a developer to work on several patch series at the same time, keeping the patches contained and well classified. Now we will create a new branch on top of the default branch, which is called <code>master</code> |
|||
stg branch -c my_new_feature |
|||
</pre> |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
You are now working on a different branch, you can switch back to the "master" branch at any time by using: |
|||
$ stg branch -c my_new_feature |
|||
</syntaxhighlight> |
|||
You are now working on a different branch, you can switch back to the <code>master</code> branch at any time by using: |
|||
<pre> |
|||
stg branch master |
|||
</pre> |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
Now that we are on the branch we wish to use to develop feature X we will start creating patches. The first thing to do is creating a new patch, StGit will ask for a description of the patch, but if unsure you can leave it blank and fill it later. |
|||
$ stg branch master |
|||
</syntaxhighlight> |
|||
==== Set up a patch (this happens before you develop it) ==== |
|||
<pre> |
|||
Now that we are on the branch we wish to use to develop feature X we will start creating patches. The first thing to do is creating a new patch, StGit will ask for a description of the patch, but if unsure you can leave it blank and fill it later. The conventions related to what should be in commit messages are described in [[Submitting Xen Project Patches]]. The example below is merely intended to explain the necessary StGit commands: when you submit patches you will likely need more detail than shown in this document. |
|||
stg new first_patch_in_the_series |
|||
</pre> |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
$ stg new first.patch |
|||
</syntaxhighlight> |
|||
Here is an example of a simple description: |
Here is an example of a simple description: |
||
<syntaxhighlight lang="sh" highlight="1"> |
|||
<pre> |
|||
foobar: Add a new trondle calls |
foobar: Add a new trondle calls |
||
Line 44: | Line 76: | ||
Signed-off-by: Joe Smith <joe.smith@citrix.com> |
Signed-off-by: Joe Smith <joe.smith@citrix.com> |
||
</syntaxhighlight> |
|||
</pre> |
|||
The first line in the description will be used as the subject when the patch is sent to the mailing list, so please make sure it contains an accurate description about what the patch is expected to introduce. It should be followed by a more accurate description and finally a "Signed-off-by". |
The first line in the description will be used as the subject when the patch is sent to the mailing list, so please make sure it contains an accurate description about what the patch is expected to introduce. It should be followed by a more accurate description and finally a "Signed-off-by". |
||
==== Develop and Test your patch ==== |
|||
Now you can starting modifying the code, all your changes will be contained inside this patch. When finished, you will have to refresh the patch, and create a new one on top if desired. |
|||
Now you can starting modifying the code, all your changes will be contained inside this patch. |
|||
==== Modify the commit message ==== |
|||
<pre> |
|||
If you want to modify the description of a patch, you should use the [http://procode.org/stgit/doc/stg-edit.html edit] command |
|||
stg refresh |
|||
stg new second_patch_in_the_series |
|||
</pre> |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
If you want to modify the description of a patch, you should use the [http://procode.org/stgit/doc/stg-edit.html edit] command: |
|||
$ stg edit first.patch |
|||
</syntaxhighlight> |
|||
==== Refresh (commit) your patch ==== |
|||
<pre> |
|||
When finished, you will have to refresh the patch. |
|||
stg edit first_patch_in_the_series |
|||
</pre> |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
Also, if you want to move between the series, you can use the following StGit commands, [http://procode.org/stgit/doc/stg-push.html push], [http://procode.org/stgit/doc/stg-pop.html pop] and [http://procode.org/stgit/doc/stg-goto.html goto]. |
|||
$ stg refresh |
|||
</syntaxhighlight> |
|||
If you also want to edit the commit message, you can use |
|||
==== Git format-patch and send-email ==== |
|||
The most robust way to send files is by using the git [http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html format-patch] and [http://www.kernel.org/pub/software/scm/git/docs/git-send-email.html send-email] commands. |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
First, we will set up the configuration git send-email will use to send the patches. Edit your ~/.gitconfig file and add the following lines: |
|||
$ stg refresh -e |
|||
</syntaxhighlight> |
|||
=== Develop a second patch in the patch series and commit it === |
|||
<pre> |
|||
For further patches, you follow the same protocol as outlined in the previous section using a different name for your patch, starting with |
|||
[user] |
|||
name = John Smith |
|||
email = john.smith@example.com |
|||
[sendemail] |
|||
smtpserver = mail.example.com |
|||
smtpserverport = 25 |
|||
smtpuser = johnsmith |
|||
</pre> |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
Now we can proceed to generate the patches and send them. We will use format-patch to generate the patches and send-email to send them to the mailing list. |
|||
$ stg new second.patch |
|||
</syntaxhighlight> |
|||
=== Working on patches in a Patch Series === |
|||
<pre> |
|||
At this point, we currently have a two patch series consisting of <code>first.patch</code> and <code>second.patch</code>. We are going to add a <code>third.patch</code> as described before, which we can see using |
|||
git format-patch --subject-prefix="PATCH RFC" -o outgoing/ HEAD~2 |
|||
</pre> |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
The format-patch command allows us to set a prefix to our patch series, in this case I want them to be marked as "RFC", if you don't need to include any specific prefix in the subject you don't need to specify "subject-prefix", and git will use the default one "PATCH X/Y". I've also used the "-o" option so format patch outputs the patches to the "outgoing" folder. Lastly you have to specify the first commit ID that will be used to generate your series. This can either be something like HEAD~3 if your series has 3 patches, and HEAD is the last patch in the series. Alternatively you can also use a commit ID instead of HEAD, and all commits on top of commit ID will be outputted. |
|||
$ stg series --description |
|||
+ first.patch # My first patch |
|||
+ second.patch # My second patch |
|||
> third.patch # My third patch |
|||
</syntaxhighlight> |
|||
StGit shows patches chronologically ordered from top to bottom. Note that this is the opposite from git log, which by default uses reverse chronological ordering. In the example, <code>third.patch</code> is your current working patch. |
|||
Before sending the patches it is recommended that you review them yourself, this can avoid sending patches that contain mistakes that could be avoided, and will allow you to send less revisions. After you have checked that the patches are fine, you can send them using the send-email git command. |
|||
If for example you want to work on the first patch, you can choose to perform |
|||
<pre> |
|||
git send-email --compose outgoing/* |
|||
</pre> |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
The "compose" option will allow you to write an introductory email to the series. This is recommended, so the reviewer can understand easily what you are trying to accomplish with this series. Finally git will ask you the mail address where patches should be sent, which the user will have to fill with xen-devel@lists.xen.org. |
|||
$ stg pop |
|||
$ stg pop |
|||
</syntaxhighlight> |
|||
or |
|||
=== Common tasks === |
|||
---- |
|||
If you are working on a big or controversial patch series, it is very likely that you will have to submit several versions of them, and you will need to rebase your code to match the changes that will be committed to the repository between each revision of your series. You can do that easily with [http://www.procode.org/stgit/doc/stg-rebase.html stg rebase]. The first step is to update the "master" branch of your repository. |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
<pre> |
|||
stg |
$ stg goto first.patch |
||
</syntaxhighlight> |
|||
git pull |
|||
</pre> |
|||
showing the following |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
$ stg series --description |
|||
> first.patch # My first patch |
|||
- second.patch # My second patch |
|||
- third.patch # My third patch |
|||
</syntaxhighlight> |
|||
The command |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
$ stg show |
|||
</syntaxhighlight> |
|||
shows you the current patch you are working on. |
|||
== Sending a Patch or Patch Series to xen-devel@ == |
|||
You can find instructions on how to send patches in our [[Submitting_Xen_Project_Patches#send|Patch Submission Guide]]. It is important though, that the current working patch is the last patch in the series, otherwise you will submit only a subset of your series. |
|||
In the example above, you want to perform |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
$ stg goto third.patch |
|||
</syntaxhighlight> |
|||
before executing the commands outlined in our [[Submitting_Xen_Project_Patches#send|Patch Submission Guide]]. |
|||
=== Creating outbound version branches === |
|||
As as the case with a git workflow, you should create an outbound version branch after you sent a patch for review. This allows you to go back to previous versions easily. If you share a branch of a complex series in your cover letter as suggested here, it is important to do this, such that the branch remains static and code reviewers do not get confused by unexpected changes in the shared git branch. |
|||
With stgit, you can do this with [http://procode.org/stgit/doc/stg-publish.html stg publish <outbound-branch-name>], which creates a new branch with the patches to publish. In other words, if used consistently you end you end up with a git branch that allows you to save your changes for each revision in a separate git branch. |
|||
You can also use the normal git workflow and push the changes to a remote branch, via <code>git push ... <stgit branch>:<remote branch name></code>. |
|||
== Addressing Review Comments == |
|||
Addressing review comments in StGit is much easier than with git, as you can simply move between patches of your series as outlined below |
|||
<syntaxhighlight lang="sh" highlight="1,4,6"> |
|||
stg goto <patch-id> |
|||
...modify the patch |
|||
stg refresh -e |
|||
</syntaxhighlight> |
|||
and then update the commit message including the change log. This may look something like: |
|||
<syntaxhighlight lang="diff" highlight="9-11" line> |
|||
xen/x86: Added trondle feature |
|||
Because, ... |
|||
Signed-off-by: Joe Blogs <joe...@citrix.com> |
|||
--- |
|||
CC: Another Colleague <ano...@citrix.com> |
|||
Changes in v3: |
|||
- s/nGRE/nGnRE/g |
|||
- move security support clarification to a separate patch |
|||
Changes in v2: |
|||
- add #define LIBXL_HAVE_MEMORY_POLICY |
|||
- ability to part the memory policy parameter even if gfn is not passed |
|||
- rename cache_policy to memory policy |
|||
</syntaxhighlight> |
|||
== Common tasks == |
|||
=== Rebasing a series === |
|||
If you are working on a big or controversial patch series, it is very likely that you will have to submit several versions of them, and you will need to rebase your code to match the changes that will be committed to the repository between each revision of your series. You can do that easily with [http://www.procode.org/stgit/doc/stg-rebase.html stg rebase]. The first step is to update the <code>master</code> branch of your repository. |
|||
<syntaxhighlight lang="sh" highlight="1"> |
|||
$ stg branch master |
|||
$ git pull |
|||
</syntaxhighlight> |
|||
After that you will need to find the commit ID you want to rebase your series on top of, this can be done using git log. Once you have the commit ID, switch to the branch with your patches and execute: |
After that you will need to find the commit ID you want to rebase your series on top of, this can be done using git log. Once you have the commit ID, switch to the branch with your patches and execute: |
||
<syntaxhighlight lang="sh" highlight="1"> |
|||
<pre> |
|||
stg rebase <commit-id> |
$ stg rebase <commit-id> |
||
</syntaxhighlight> |
|||
</pre> |
|||
This will pop all your patches, move the branch to the commit specified and then push your patches again. There's a chance that your patches don't apply cleanly on top of this commit, if this is the case stg will complain loudly, and you will have to manually edit the conflicting file. After editing the file, you can add it to your repository again and continue with the rebase: |
This will pop all your patches, move the branch to the commit specified and then push your patches again. There's a chance that your patches don't apply cleanly on top of this commit, if this is the case stg will complain loudly, and you will have to manually edit the conflicting file. After editing the file, you can add it to your repository again and continue with the rebase: |
||
<syntaxhighlight lang="sh" highlight="1"> |
|||
<pre> |
|||
git add <conflicting/file> |
$ git add <conflicting/file> |
||
stg refresh |
$ stg refresh |
||
stg push |
$ stg push |
||
</syntaxhighlight> |
|||
</pre> |
|||
stg rebase is really useful, because it allows you to rebase your series on top of any commit, as an example, you can rebase one of your series on top of another, or rebase a series on top of staging changes. |
stg rebase is really useful, because it allows you to rebase your series on top of any commit, as an example, you can rebase one of your series on top of another, or rebase a series on top of staging changes. |
||
== StGit Tutorials == |
|||
* [http://procode.org/stgit/doc/stg.html StGit Man Pages] |
|||
* [https://events.linuxfoundation.org/sites/events/files/slides/An%20Introduction%20to%20Stacked%20Git.pdf An introduction to Stacked Git] |
|||
* [http://procode.org/stgit/doc/tutorial.html StGit Tutorial] |
|||
[[Category:Developers]] |
[[Category:Developers]] |
Latest revision as of 11:14, 8 August 2019
This document assumes that you are familiar with the following documents
- Xen Project Repositories
- Submitting Xen Project Patches - the document explains conventions related to cover letters, *-by tags, etc. as well as the tooling involved in sending patches and patch series
This document lays out basic examples and best practice of how to use StGit to manage Xen patches as part of the patch submission process. To be able to manage the patch contribution more easily, we StGit, which is an application that runs on top of git and provides a functionality similar to Mercurial PatchQueue extension. This tutorial will show how to manage branches with git and StGit, so before proceeding please make sure that StGit is installed.
Similar documents exist for
- Git: see Managing Xen Patches with Git.
- git-series is a tool on top of Git that tracks changes to a patch series over time, including cover letter for the patch series, formats the series for email, and prepares patch submission. You can find instructions at Managing Xen Patches with Git-series.
StGit Basics
StGit is a tool that runs on top of Git which allows you to manage patches in a stack on top of an existing git baseline. The stack of patches that have been created on top of your baseline maps to the patch series you are working on. To get started you have to initialise StGit on your working baseline (e.g. your current development branch of your repository using stg init
).
The, you add a new patch to your stack, with the following the basic workflow
stg new <new-patch-id>
...edit patch description
...develop in the tree
stg refresh
...develop some more
stg refresh
You can add several patches this way and then use stg series
to list them. This shows your current stack of patches, where patches preceded by minus signs are not applied, patches preceded by plus signs are applied, while your current working patch is highlighted by a >
character in the stg series
output. The current working patch is always also the current top of your stack of patches.
At any point you can edit the current tree to update your current working patch : Simply edit the files and use the stg refresh
command to record your changes. You can use stg refresh -e
to update the patch description as well. stg show
will show the current (or any) patch.
You can manipulate the stack of patches using the push
, pop
, goto
, sink
and float
StGit commands. The most basic option to control the stack - and thus the current working patch - is a sequence of pop
commands, followed by an edit-refresh cycle and a matching sequence of push
commands. This works very well in a review cycle, where typically you move from one patch of a series to another. The goto
command can be used if you need to move the current working patch by more than a few positions in the stack.
Before running any command the first time, we recommended that you at least quickly skim through its man pages. Many of the commands have very useful and interesting features that are not listed here: sometimes there are some extra notes which are very useful. Quick usage help is available for the StGit command using stg help <command>
.
If you want to rebase your series of patches against a different baseline, or just rebase an existing one you can use the stg pull
command. It will pop all the patches, then update your current branch to the upstream revision using git pull
, then push your patches back on top of the new base. If conflicts occur you need to resolve them and tell StGit using the stg resolved
command and then update the patch using stg refresh
and resume by performing a stg push -a
.
Generating an initial Patch or Patch Series
Here's a recommendation on how to manage patches with StGit, as suggested by the Xen maintainers. Before you follow the instructions, you may want to read the following short discussion about whether to develop against staging
or master
branches. Unlike the git guide, this document assumes you are developing against master
.
The first thing to do is cloning the xen git repository:
$ git clone git://xenbits.xen.org/xen.git
$ cd xen
$ stg init
This will create a new folder, called xen, and initialises StGit where you will work on your patches.
Create a branch for your changes
We are going to create a branch for each series of patches that we are going to work on. This will allow a developer to work on several patch series at the same time, keeping the patches contained and well classified. Now we will create a new branch on top of the default branch, which is called master
$ stg branch -c my_new_feature
You are now working on a different branch, you can switch back to the master
branch at any time by using:
$ stg branch master
Set up a patch (this happens before you develop it)
Now that we are on the branch we wish to use to develop feature X we will start creating patches. The first thing to do is creating a new patch, StGit will ask for a description of the patch, but if unsure you can leave it blank and fill it later. The conventions related to what should be in commit messages are described in Submitting Xen Project Patches. The example below is merely intended to explain the necessary StGit commands: when you submit patches you will likely need more detail than shown in this document.
$ stg new first.patch
Here is an example of a simple description:
foobar: Add a new trondle calls
Add a some new trondle calls to the foobar interface to support
the new zot feature.
Signed-off-by: Joe Smith <joe.smith@citrix.com>
The first line in the description will be used as the subject when the patch is sent to the mailing list, so please make sure it contains an accurate description about what the patch is expected to introduce. It should be followed by a more accurate description and finally a "Signed-off-by".
Develop and Test your patch
Now you can starting modifying the code, all your changes will be contained inside this patch.
Modify the commit message
If you want to modify the description of a patch, you should use the edit command
$ stg edit first.patch
Refresh (commit) your patch
When finished, you will have to refresh the patch.
$ stg refresh
If you also want to edit the commit message, you can use
$ stg refresh -e
Develop a second patch in the patch series and commit it
For further patches, you follow the same protocol as outlined in the previous section using a different name for your patch, starting with
$ stg new second.patch
Working on patches in a Patch Series
At this point, we currently have a two patch series consisting of first.patch
and second.patch
. We are going to add a third.patch
as described before, which we can see using
$ stg series --description
+ first.patch # My first patch
+ second.patch # My second patch
> third.patch # My third patch
StGit shows patches chronologically ordered from top to bottom. Note that this is the opposite from git log, which by default uses reverse chronological ordering. In the example, third.patch
is your current working patch.
If for example you want to work on the first patch, you can choose to perform
$ stg pop
$ stg pop
or
$ stg goto first.patch
showing the following
$ stg series --description
> first.patch # My first patch
- second.patch # My second patch
- third.patch # My third patch
The command
$ stg show
shows you the current patch you are working on.
Sending a Patch or Patch Series to xen-devel@
You can find instructions on how to send patches in our Patch Submission Guide. It is important though, that the current working patch is the last patch in the series, otherwise you will submit only a subset of your series.
In the example above, you want to perform
$ stg goto third.patch
before executing the commands outlined in our Patch Submission Guide.
Creating outbound version branches
As as the case with a git workflow, you should create an outbound version branch after you sent a patch for review. This allows you to go back to previous versions easily. If you share a branch of a complex series in your cover letter as suggested here, it is important to do this, such that the branch remains static and code reviewers do not get confused by unexpected changes in the shared git branch.
With stgit, you can do this with stg publish <outbound-branch-name>, which creates a new branch with the patches to publish. In other words, if used consistently you end you end up with a git branch that allows you to save your changes for each revision in a separate git branch.
You can also use the normal git workflow and push the changes to a remote branch, via git push ... <stgit branch>:<remote branch name>
.
Addressing Review Comments
Addressing review comments in StGit is much easier than with git, as you can simply move between patches of your series as outlined below
stg goto <patch-id>
...modify the patch
stg refresh -e
and then update the commit message including the change log. This may look something like:
xen/x86: Added trondle feature
Because, ...
Signed-off-by: Joe Blogs <joe...@citrix.com>
---
CC: Another Colleague <ano...@citrix.com>
Changes in v3:
- s/nGRE/nGnRE/g
- move security support clarification to a separate patch
Changes in v2:
- add #define LIBXL_HAVE_MEMORY_POLICY
- ability to part the memory policy parameter even if gfn is not passed
- rename cache_policy to memory policy
Common tasks
Rebasing a series
If you are working on a big or controversial patch series, it is very likely that you will have to submit several versions of them, and you will need to rebase your code to match the changes that will be committed to the repository between each revision of your series. You can do that easily with stg rebase. The first step is to update the master
branch of your repository.
$ stg branch master
$ git pull
After that you will need to find the commit ID you want to rebase your series on top of, this can be done using git log. Once you have the commit ID, switch to the branch with your patches and execute:
$ stg rebase <commit-id>
This will pop all your patches, move the branch to the commit specified and then push your patches again. There's a chance that your patches don't apply cleanly on top of this commit, if this is the case stg will complain loudly, and you will have to manually edit the conflicting file. After editing the file, you can add it to your repository again and continue with the rebase:
$ git add <conflicting/file>
$ stg refresh
$ stg push
stg rebase is really useful, because it allows you to rebase your series on top of any commit, as an example, you can rebase one of your series on top of another, or rebase a series on top of staging changes.