summaryrefslogtreecommitdiffstats
path: root/subtree.md
blob: b366fa467dcb0a1f1a65983bd97e6e3d22a704fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Subtree Architecture

All of these directories are subtrees and may not be contributed to by pushing
directly to the openbmc/openbmc top level repository

Subtrees are a way to nest repositories inside another as a sub-directory. This
allows us to contain all of the Yocto meta-data in individual repositories
(useful for developers who don't want the phosphor-distro), as well as one top
level directory - making it easy to get started.

To find a list of all current subtrees in the openbmc project, navigate to:
https://github.com/openbmc?utf8=✓&q=meta

Instead, please follow this workflow:
```
$ git clone https://gerrit.openbmc-project.xyz/openbmc/openbmc
# Make changes
$ bitbake obmc-phosphor-image # Test out your changes
$ git commit
$ git remote add <repo_name> ssh://openbmc.gerrit/openbmc/<repo_name>/
$ git fetch <repo_name>
$ git checkout -b featureBranch <repo_name>/master
$ git cherry-pick --strategy=subtree <SHA> # My commit from master
$ git push ssh://openbmc.gerrit/openbmc/<repo_name> HEAD:refs/for/master

$ git checkout master # To continue work on something unrelated
```

If you have lost the commit from the parent repo and need to do work on your
subtree code review:
```
$ git checkout featureBranch
$ git log -n1 --oneline # capture the SHA
$ git checkout master
$ git cherry-pick --strategy=subtree <SHA you just captured>
```

If for some reason you have lost the featureBranch:
```
$ git checkout -b featureBranch
$ git fetch ssh://openbmc.gerrit/openbmc/<repo_name> refs/changes/XX/XXXX/X
$ git checkout FETCH_HEAD
$ git log -n1 --oneline # Capture the SHA
$ git checkout master
$ git cherry-pick --strategy=subtree <SHA you just captured>
```

### Automation to test the ref
Where $1 is the repo name, and $2 is a ref to a pointer
```
git clone https://gerrit.openbmc-project.xyz/openbmc/openbmc
cd openbmc
git remote add subtree-remote https://gerrit.openbmc-project.xyz/openbmc/$1
git fetch ssh://openbmc.gerrit/openbmc/$1 refs/changes/$2
git cherry-pick --strategy=subtree FETCH_HEAD
```

### Automation to merge the subtree into openbmc/openbmc
Once +2 is given, this script will run where $1 is the repo name, and $2 is a
full path to subtree from top level
```
git clone ssh://<user>@gerrit.openbmc-project.xyz:29418/openbmc/openbmc
cd openbmc
git remote add subtree-remote https://gerrit.openbmc-project.xyz/openbmc/$1

git subtree pull --prefix=$2 subtree-remote master
git push
```

To keep yourself up to date with the latest as changes are submitted, you can
simply rebase again the openbmc master, and you will automatically get the
changes made in the sub-directories.
```
git checkout master
git pull --rebase origin master
```
OpenPOWER on IntegriCloud