xref: /haiku/docs/develop/build/sourcecode.rst (revision 4a55cc230cf7566cadcbb23b1928eefff8aea9a2)
1Haiku Git Repositories
2======================
3
4Haiku uses Git for source control, combined with Gerrit for review of code changes.
5
6All the sources for the operating system are stored in a single repository at http://cgit.haiku-os.org/haiku .
7
8Another repository contains the build tools, that is, gcc, binutils, and Jam, which are maintained
9by Haiku developers.
10
11Managing GCC and binutils updates using vendor branches
12-------------------------------------------------------
13
14The buidtools repository uses vendor branches. This concept originates from `the SVN Book <https://svnbook.red-bean.com/en/1.8/svn.advanced.vendorbr.html>`_
15but applies just as well to Git. This organization allows to clearly separate the imported code
16from upstream, and the changes we have made to it.
17
18The idea is to import all upstream changes in a dedicated branch (there are currently two, called
19vendor-gcc and vendor-binutils). These branches contains the sources of gcc and binutils as
20distributed by the GNU project, without any Haiku changes.
21
22The master branch can then merge new versions from the vendor branches. This allows to use Git
23conflict resolution to make sure our patches are correctly ported from one version to the next.
24
25It also makes it easy to compare the current state of our sourcecode with the upstream code, for
26example to extract patches that could be upstreamed.
27
28How to import upstream changes
29..............................
30
31Here is an example of the process used to update to a new version of binutils:
32
33.. code-block:: bash
34
35    git checkout vendor-binutils          # Move to the branch containing binutils
36    git rm -rf binutils ; rm -rf binutils # Delete the existing version of binutils
37    wget http://.../binutils-2.36.tar.xz  # Download the latest version
38    tar xf binutils-2.36.tar.xz           # Extract the new binutils version
39    mv binutils-2.36 binutils             # Move the extracted files to the right place
40    git add -f binutils                   # Add the new files to git
41    git commit -m "import binutils 2.36"  # Commit the files in the vendor branch
42    git push origin vendor-binutils       # You can push this directly to the branch
43
44Now this can easily be merged into the master branch:
45
46.. code-block:: bash
47
48    git checkout master
49    git merge vendor-binutils
50
51Review and fix the conflicts, if any, then push the changes for review on Gerrit.
52
53Comparing our code with upstream
54................................
55
56Comparing the two versions is easy because you can refer to them by branch names:
57
58.. code-block:: bash
59
60    git diff vendor-binutils master -- binutils
61