|
|
__Problem:__
|
|
|
|
|
|
- To build for Z5 Compact (suzuran), we need proprietary files from an [upstream repo `proprietary_vendor_sony`][1]. This has three device-specific directories `suzuran`, `sumire`, `satsuki`, and one shared directory `kitakami-common`. My existing manifest puts this in the `vendor/sony/` tree with `path="vendor/sony"`.
|
|
|
- We only need the files from `suzuran` and `kitakami-common`, which will end up in `vendor/sony/suzuran` and `vendor/sony/kitakami-common`.
|
|
|
- We need the files to be in two separate repos, to avoid namespace problems when building other Sony devices, which also have vendor files in the `vendor/sony/` tree.
|
|
|
- We need to be able to easily (automatically in gitlab) mirror changes in the upstream repo
|
|
|
- We use two of the same branches as upstream. These branches diverged in October 2020. The last common commit before they diverged was commit `084827d`
|
|
|
- We are not interested in history **before** the branches diverged
|
|
|
|
|
|
__The problem in pictures__ (with less confusing names)
|
|
|
|
|
|
This is the structure in the upstream repo
|
|
|
```
|
|
|
`upstream-repo`
|
|
|
- Device-1\
|
|
|
-- File-1
|
|
|
-- File-2
|
|
|
-- ...
|
|
|
-- Sub-Dir-1
|
|
|
---- File-3
|
|
|
---- ...
|
|
|
- Device-2\
|
|
|
-- ...
|
|
|
-- File-3
|
|
|
-- ...
|
|
|
- Device-3\
|
|
|
-- Files...
|
|
|
- Shared Files\
|
|
|
-- File-4
|
|
|
-- ...
|
|
|
```
|
|
|
|
|
|
This is the structure I want in the two new repos
|
|
|
```
|
|
|
`new-device-1-repo`
|
|
|
- File-1
|
|
|
- File-2
|
|
|
- ...
|
|
|
- Sub-Dir-1
|
|
|
-- File-3
|
|
|
-- ...
|
|
|
|
|
|
`new-shared-files-repo`
|
|
|
- File-4
|
|
|
- ...
|
|
|
```
|
|
|
|
|
|
__Solution__
|
|
|
(Based on ideas from [here][2])
|
|
|
|
|
|
1. Clone upstream locally to a new local repo `new-device-1-repo`
|
|
|
2. [Create an `orphan`branch][3] from our starting commit `084827d`, containing all the files in the repo at that point, but not staged or commited.
|
|
|
```
|
|
|
git reset --hard 084827d
|
|
|
git checkout --orphan new-device-root
|
|
|
```
|
|
|
3. Stage and commit all the files
|
|
|
```
|
|
|
git commit -am "Initial Commit from upstream commit 084827d"
|
|
|
```
|
|
|
4. Make and commit the changes that we want in **both** of our new repositories: removing the devices we are not interested in
|
|
|
```
|
|
|
git rm -r device-3
|
|
|
git rm -r device-4
|
|
|
git commit -am "Remove devices 3 & 4"
|
|
|
```
|
|
|
5. This is the point at which our new repos will diverge, so we will make a new copy of this repo for the other device
|
|
|
```
|
|
|
cd ..
|
|
|
cp new-device-1-repo/ new-device-2-repo/
|
|
|
cd new-device-1-repo
|
|
|
```
|
|
|
6. Remove Device 2 directory
|
|
|
```
|
|
|
git rm -r device-2
|
|
|
git rm -r device-4
|
|
|
git commit -am "Remove device 2"
|
|
|
```
|
|
|
7. Move Device 1 files to the top level
|
|
|
```
|
|
|
git mv device-1/ .
|
|
|
git commit -am "Move device 1 files to top level"
|
|
|
```
|
|
|
8. Delete our local copies of all the upstream branches
|
|
|
9. Create empty local branches (with the same name) for the upstream changes we are interested in
|
|
|
10. Pull / merge the upstream changes in each branch
|
|
|
11. Repeat steps 6-10 in the `new-device-2-repo`
|
|
|
|
|
|
I have done a dry-run through this and it seems to work. There was one conflict one one of the branches which I was able to resolve. IRL, I will import the new repos into gitlab after step 8, to test out gitlab's mirroring functionality. I'll start with the branch without conflicts :)
|
|
|
|
|
|
|
|
|
|
|
|
[1]: <https://github.com/Professor-Berni/proprietary_vendor_sony>
|
|
|
|
|
|
[2]: <https://medium.com/@debshish.pal/delete-entire-commit-history-of-a-git-repository-86e25602e4ef>
|
|
|
|
|
|
[3]: <https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt---orphanltnewbranchgt>
|
|
|
|