Managing Xen Patches with StGit: Difference between revisions

From Xen
Jump to navigationJump to search
(Brought the document structure and formatting into line with Managing_Xen_Patches_with_Git)
(Add a link to the similar git-series document)
Line 7: Line 7:
Similar documents exist for
Similar documents exist for
* '''Git''': see [[Managing Xen Patches with Git]].
* '''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]].


== Generating an initial Patch or Patch Series ==
== Generating an initial Patch or Patch Series ==

Revision as of 19:27, 7 August 2019

This document assumes that you are familiar with the following documents

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

Generating an initial Patch or Patch Series

Here's a recommendation on how to send patches, 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

This will create a new folder, called xen, 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

Develop a patch in the patch series and commit it

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_in_the_series

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_in_the_series

Refresh (commit) your patch

When finished, you will have to refresh the patch.

$ stg refresh

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_in_the_series

Moving between patches

If you want to move on to a different patch in the series, you can use the following StGit commands, push, pop and goto.

Sending a Patch or Patch Series to xen-devel@

You can find instructions on how to send patches in our Patch Submission Guide.

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.

StGit Tutorials