Managing Xen Patches with Git: Difference between revisions

From Xen
Jump to navigationJump to search
No edit summary
(→‎Generating a patch: Give the document more structure such that it can be expanded easily later)
Line 8: Line 8:
* '''StGit''', a Python application providing similar functionality to Quilt (i.e. pushing/popping patches to/from a stack) on top of Git. You can find instructions at [[Managing Xen Patches with StGit]].
* '''StGit''', a Python application providing similar functionality to Quilt (i.e. pushing/popping patches to/from a stack) on top of Git. You can find instructions at [[Managing Xen Patches with StGit]].


== Generating a patch ==
== Generating an initial Patch or Patch Series ==
Begin by cloning the git repo from XenProject.org:
Begin by cloning the git repo from XenProject.org:
<syntaxhighlight lang="sh" highlight="1">
<syntaxhighlight lang="sh" highlight="1">
Line 33: Line 33:
The branch called <code>staging</code> is the bleeding-edge of commits; this is tested regularly with the <code>xen.org</code> build and regression testing system, and when it pases, is pushed to the <code>master</code> branch. It is suggested to develop patches based on the <code>master</code> branch.
The branch called <code>staging</code> is the bleeding-edge of commits; this is tested regularly with the <code>xen.org</code> build and regression testing system, and when it pases, is pushed to the <code>master</code> branch. It is suggested to develop patches based on the <code>master</code> branch.


=== Create a branch for your changes ===
'''Important:''' When you want to introduce a change, start by making a new branch based on the most recent change in the <code>master</code> branch:
When you want to introduce a change, start by making a new branch based on the most recent change in the <code>master</code> branch.


<syntaxhighlight lang="sh" highlight="1">
<syntaxhighlight lang="sh" highlight="1">
Line 40: Line 41:
</syntaxhighlight>
</syntaxhighlight>


=== Develop and Test your change ===
Then edit the source files you want to change. You can see which files have changed by using <code>git status</code>.
Then edit the source files you want to change. You can see which files have changed by using <code>git status</code>.


=== Commit your change to your branch ===
When you're done editing, use <code>git add</code> to specify which file changes you want included in the changeset, and then use <code>git commit</code> to make a commit. You will be prompted to make a changset description:
When you're done editing, use <code>git add</code> to specify which file changes you want included in the changeset, and then use <code>git commit</code> to make a commit. You will be prompted to make a changset description. 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 git commands: when you submit patches you will likely need more detail than shown in this document.
<syntaxhighlight lang="sh" highlight="1, 11, 12">
<syntaxhighlight lang="sh" highlight="1, 11, 12">
Line 58: Line 61:
$ git commit
$ git commit
</syntaxhighlight>
</syntaxhighlight>

'''Important:''' The conventions related to what should be in commit messages are described in [[Submitting Xen Project Patches]].


Alternatively, you can commit all changes using "git commit -a":
Alternatively, you can commit all changes using "git commit -a":
Line 76: Line 77:
</syntaxhighlight>
</syntaxhighlight>


=== Patches vs. Patch Series ===
Make as many commits on your new branch as are necessary.
Every single commit you make on your branch becomes a patch when you submit it. If your change consists of multiple commits, you will be committing a patch series. Information related to Xen Project conventions around patches and patch series can be found [[Submitting_Xen_Project_Patches#What_is_in_a_patch_and_a_patch_series.3F|here]].

=== Changes based on staging ===
If you want to make a local branch based on <code>staging</code> rather than <code>master</code> (for example, to fix a changeset which has caused the XenProject.org nightly testing to fail), you can do the following:
If you want to make a local branch based on <code>staging</code> rather than <code>master</code> (for example, to fix a changeset which has caused the XenProject.org nightly testing to fail), you can do the following:
<syntaxhighlight lang="sh" highlight="1">
<syntaxhighlight lang="sh" highlight="1">

Revision as of 12:59, 7 August 2019

This document assumes that you are familiar with the following documents

It lays out basic examples and best practice of how to use Git to manage Xen patches as part of the submission process.

Similar documents exist for

  • StGit, a Python application providing similar functionality to Quilt (i.e. pushing/popping patches to/from a stack) on top of Git. You can find instructions at Managing Xen Patches with StGit.

Generating an initial Patch or Patch Series

Begin by cloning the git repo from XenProject.org:

$ git clone git://xenbits.xenproject.org/xen.git xen.git

At this point you should have xenbits set up as the remote repostiory called "origin":

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/stable-4.0
  remotes/origin/stable-4.1
  remotes/origin/stable-4.2
  remotes/origin/staging
  remotes/origin/staging-4.0
  remotes/origin/staging-4.1
  remotes/origin/staging-4.2

This process automatically creates a local branch called master that will track the XenProject.org branch called master.

The branch called staging is the bleeding-edge of commits; this is tested regularly with the xen.org build and regression testing system, and when it pases, is pushed to the master branch. It is suggested to develop patches based on the master branch.

Create a branch for your changes

When you want to introduce a change, start by making a new branch based on the most recent change in the master branch.

$ git checkout -b out/trondle-calls master
Switched to a new branch 'out/trondle-calls'

Develop and Test your change

Then edit the source files you want to change. You can see which files have changed by using git status.

Commit your change to your branch

When you're done editing, use git add to specify which file changes you want included in the changeset, and then use git commit to make a commit. You will be prompted to make a changset description. 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 git commands: when you submit patches you will likely need more detail than shown in this document.

$ git status
# On branch out/trondle-calls
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   foobar/zot.c
#	modified:   foobar/zot.h
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git add foobar/zot.c foobar/zot.h
$ git commit

Alternatively, you can commit all changes using "git commit -a":

$ git commit -a
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>

Patches vs. Patch Series

Every single commit you make on your branch becomes a patch when you submit it. If your change consists of multiple commits, you will be committing a patch series. Information related to Xen Project conventions around patches and patch series can be found here.

Changes based on staging

If you want to make a local branch based on staging rather than master (for example, to fix a changeset which has caused the XenProject.org nightly testing to fail), you can do the following:

$ git checkout -b staging remotes/origin/staging
Branch staging set up to track remote branch staging from origin.
Switched to a new branch 'staging'

Then in the commands above, you would use "staging" instead of "master" as the base branch. ...

Sending a patch to xen-devel@

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