Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| gitworkflow:triangularworkflow [2015/09/14 16:47] – JulienCharbon | gitworkflow:triangularworkflow [2015/09/14 20:34] (current) – JulienCharbon | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Git Triangular Workflow ====== | ====== Git Triangular Workflow ====== | ||
| - | This git workflow | + | The main characteristics of this workflow |
| - | * Keeping in sync a %%FreeBSD%% release branch, e.g. releng/ | + | * Develop changes on top of %%FreeBSD%% release branch, e.g. '' |
| - | * Develop improvements/ | + | * Publish these changes |
| * Once these changes have been tested and have matured enough, up-port them on top of HEAD for review | * Once these changes have been tested and have matured enough, up-port them on top of HEAD for review | ||
| * Once review accepted, push them in HEAD | * Once review accepted, push them in HEAD | ||
| - | * Rebase | + | * Rebase changes |
| - | For experimented git users this is only common sense, but might help you to start %%FreeBSD%% contributions with a simple git workflow. | + | For experimented git users (i.e. users that already fell in every git pitfalls) |
| {{gitworkflow/ | {{gitworkflow/ | ||
| Line 15: | Line 15: | ||
| ====== Introduction ====== | ====== Introduction ====== | ||
| - | This workflow assumes you use multiple repositories, | + | This workflow assumes you use multiple repositories, |
| - | origin repository:: Our own personal repository with full access, e.g. '' | + | * **origin repository**: Our own personal/ |
| - | upstream repository:: The official %%FreeBSD%% repository with read-only access, e.g. '' | + | * **upstream repository**: The official %%FreeBSD%% repository with read-only access, e.g. '' |
| - | * **Main | + | * **Main |
| - | * Changes coming from '' | + | * Changes coming from '' |
| - | * Changes | + | * Changes |
| ====== Local Git Repository First Steps ====== | ====== Local Git Repository First Steps ====== | ||
| - | Clone personal %%FreeBSD%% git repository | + | Clone personal %%FreeBSD%% git repository |
| < | < | ||
| Line 41: | Line 41: | ||
| </ | </ | ||
| - | * **Note**: '' | + | * **Note**: '' |
| ====== Origin Repository Branches ====== | ====== Origin Repository Branches ====== | ||
| Line 53: | Line 53: | ||
| 10.1-next/ | 10.1-next/ | ||
| 10.2-next/ | 10.2-next/ | ||
| + | master | ||
| </ | </ | ||
| - | The '' | + | The '' |
| - | ====== Create a X.Y-next Branch ====== | + | ====== Create a X.Y-next Branch |
| Get last upstream changes | Get last upstream changes | ||
| Line 79: | Line 80: | ||
| ===== Checkout a X.Y-next Branch ===== | ===== Checkout a X.Y-next Branch ===== | ||
| - | If the '' | + | If the '' |
| < | < | ||
| Line 86: | Line 87: | ||
| </ | </ | ||
| - | ====== | + | ====== |
| - | Checkout | + | Get last upstream changes |
| + | |||
| + | < | ||
| + | $ git fetch upstream | ||
| + | </ | ||
| + | |||
| + | Create new '' | ||
| + | |||
| + | < | ||
| + | $ git checkout -t upstream/ | ||
| + | </ | ||
| + | |||
| + | Publish '' | ||
| + | |||
| + | < | ||
| + | $ git push origin HEAD | ||
| + | </ | ||
| + | |||
| + | ====== Make and Publish Custom Changes in Origin Repository ====== | ||
| + | |||
| + | Checkout | ||
| < | < | ||
| Line 95: | Line 116: | ||
| </ | </ | ||
| - | Make source code changes and locally commit them | + | Make changes and locally commit them |
| < | < | ||
| Line 101: | Line 122: | ||
| # Hack, test, hack | # Hack, test, hack | ||
| $ git add foo/bar.c | $ git add foo/bar.c | ||
| - | $ git commit -m " | + | $ git commit -m " |
| </ | </ | ||
| - | Once tested, rebase on top of last origin changes | + | Once tested, rebase on top of last origin |
| < | < | ||
| Line 113: | Line 134: | ||
| ====== Merge Errata/ | ====== Merge Errata/ | ||
| - | * **Note**: No Operating System is without sins, thus you need to merge Errata/ | + | * **Note**: No Operating System is without sins, thus you need to merge Errata/ |
| - | Checkout | + | Checkout |
| < | < | ||
| Line 122: | Line 143: | ||
| </ | </ | ||
| - | Get last upstream changes and check the log for Errata/ | + | Get last upstream changes and check the log for Errata/ |
| < | < | ||
| Line 129: | Line 150: | ||
| </ | </ | ||
| - | Merge last changes from upstream | + | Merge last upstream |
| < | < | ||
| Line 135: | Line 156: | ||
| </ | </ | ||
| - | Resolve conflicts if any, than check final result | + | Resolve conflicts if any, than check the result |
| < | < | ||
| Line 141: | Line 162: | ||
| </ | </ | ||
| - | Publish merged upstream changes in orign | + | Publish merged upstream changes in origin |
| < | < | ||
| Line 147: | Line 168: | ||
| </ | </ | ||
| - | Next you can update %%FreeBSD%% release number in '' | + | Next you can update %%FreeBSD%% release number in '' |
| - | ===== Create | + | ===== Create Tag and Publish it ===== |
| < | < | ||
| Line 156: | Line 177: | ||
| </ | </ | ||
| - | ===== Checkout a Private | + | ===== Checkout a Tag ===== |
| < | < | ||
| Line 164: | Line 185: | ||
| ====== Rebase Custom Changes onto a New Release Branch ====== | ====== Rebase Custom Changes onto a New Release Branch ====== | ||
| - | Get all origin and upstream repositories changes. | + | Get all origin and upstream repositories changes. |
| < | < | ||
| Line 175: | Line 196: | ||
| </ | </ | ||
| - | Start an interactive rebase for all changes made in X.Y to X.(Y+1) | + | Start an interactive rebase for all changes made in '' |
| < | < | ||
| Line 183: | Line 204: | ||
| * **Note**: See [[/ | * **Note**: See [[/ | ||
| - | * **Note**: Rebase is smart enough to skip all already accepted | + | * **Note**: Rebase is smart/dumb enough to skip all already accepted |
| - | * **Note**: Rebase will skip all Errata/ | + | * **Note**: Rebase will skip all Errata/ |
| During the interactive rebase you have in opportunity to: | During the interactive rebase you have in opportunity to: | ||
| * Remove now irrelevant changes | * Remove now irrelevant changes | ||
| - | * Squash | + | * Squash changes related to same fix/feature implementation in only one commit: |
| * Make things easier for future rebases | * Make things easier for future rebases | ||
| * Make history easier to read | * Make history easier to read | ||
| * Cleaner patch for upstream proposal | * Cleaner patch for upstream proposal | ||
| + | * Re-order your changes | ||
| This is different workflow than the classical SVN vendor model merge workflow, here we want to see our changes always on top of the last release branch: | This is different workflow than the classical SVN vendor model merge workflow, here we want to see our changes always on top of the last release branch: | ||
| * Custom changes will appear clearly | * Custom changes will appear clearly | ||
| - | * Custom changes will be on top the last release version, and be easier to propose them to upstream, and for future rebases | + | * Custom changes will be on top the last release version, and be easier to propose them to upstream |
| - | ====== Creating a Review for CURRENT | + | ====== Advantages/ |
| + | |||
| + | ===== Advantages ===== | ||
| + | |||
| + | * Use of last release branch for stability | ||
| + | * Custom changes/ | ||
| + | * No need to wait upstream acceptation before enjoying fixes and improvements | ||
| + | * These changes make great candidates for MFC (Merge From Current) once accepted in CURRENT | ||
| + | * Keep patches clean over new release branches | ||
| + | * The origin repository includes only the branches you are working on/you care about. | ||
| + | * Interface nicely with %%FreeBSD%% reviews (Phabricator/ | ||
| + | |||
| + | ===== Disadvantages ===== | ||
| + | |||
| + | * Development is not done in CURRENT | ||
| + | * Patches are “up-ported” to CURRENT once tested/have matured enough | ||
| + | * Patches are in two branches until accepted: | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ====== More Usages Examples ====== | ||
| + | |||
| + | ===== Creating a Review for CURRENT | ||
| - | Checkout last changes | + | Checkout last changes |
| < | < | ||
| $ git fetch upstream | $ git fetch upstream | ||
| - | $ git co -b master upstream/master | + | $ git checkout |
| $ git pull --rebase | $ git pull --rebase | ||
| </ | </ | ||
| Line 212: | Line 256: | ||
| < | < | ||
| - | TBC | + | $ git checkout -b feature-foo-review master |
| + | $ git push -u origin HEAD # It creates the base commit for the review | ||
| </ | </ | ||
| - | ====== Advantages/ | + | Cherry-pick changes related to " |
| - | ===== Advantages ===== | + | < |
| + | $ git log origin/ | ||
| + | $ git cherry-pick $SHA1 $SHA2 | ||
| + | </ | ||
| - | * Use last release branch | + | and create the review |
| - | * Custom changes/ | + | |
| - | * No need to wait upstream for fixes and improvements | + | |
| - | * These changes make great candidates for MFC (Merge From Current) once accepted in CURRENT | + | |
| - | * Keep patches clean over releases | + | |
| - | * Interface nicely with %%FreeBSD%% reviews (Phabricator) | + | |
| - | ===== Disadvantages ===== | + | < |
| + | $ arc which # Check that commit $SHA1 and $SHA2 will be part of the review | ||
| + | $ arc diff --create # Create review D1234 | ||
| + | </ | ||
| - | * Development is not done in CURRENT first | + | ==== Update your Review ==== |
| - | * Patches are “up-ported” to HEAD once tested/have matured enough | + | |
| - | * Patches are in two branches until accepted: | + | |
| - | * X.Y-next (Release Branche) | + | |
| - | * feature-review (Branch for Patch Proposed to Upstream) | + | |
| - | ====== More Usages examples ====== | + | If during review changes are required, local commit the desired changes and include them in the review |
| + | |||
| + | < | ||
| + | $ vim foo/bar.c | ||
| + | # Hack, test, hack | ||
| + | $ git add foo/bar.c | ||
| + | $ git commit -m " | ||
| + | $ arc which # Check that all desired commits are part of the review | ||
| + | $ arc diff --update D1234 | ||
| + | </ | ||
| + | |||
| + | ==== Rebase your Review on more Recent CURRENT | ||
| + | |||
| + | If the review takes a while, you can rebase your changes on top of the current master and update the review. | ||
| + | |||
| + | First get last upstream changes | ||
| + | |||
| + | < | ||
| + | $ git checkout master | ||
| + | $ git pull --rebase | ||
| + | </ | ||
| + | |||
| + | Then rebase your changes on it | ||
| + | |||
| + | < | ||
| + | $ git checkout feature-foo-review | ||
| + | $ git rebase master | ||
| + | </ | ||
| + | |||
| + | And update the review | ||
| + | |||
| + | < | ||
| + | $ git push origin master: | ||
| + | $ arc which # Check that the review includes all desired commit changes, and only them | ||
| + | $ arc diff --update D1234 | ||
| + | </ | ||
| ===== Cherry-pick Specific Commits from Upstream ===== | ===== Cherry-pick Specific Commits from Upstream ===== | ||
| - | Note: You might want sometimes | + | Note: Sometimes |
| - | Checkout | + | Checkout |
| < | < | ||
| Line 247: | Line 324: | ||
| </ | </ | ||
| - | Get last upstream changes and check the log for the SHA of the commit(s) to cherry-pick | + | Get last upstream changes and check the log for the SHA of the desired |
| < | < | ||
| Line 254: | Line 331: | ||
| </ | </ | ||
| - | * **Note**: One may select any branch from which to cherry pick specific commits. | + | Cherry-pick |
| - | + | ||
| - | Cherry-pick changes from '' | + | |
| < | < | ||
| - | $ git cherry-pick | + | $ git cherry-pick SHA |
| </ | </ | ||
| - | * **Note**: Where $SHA is the SHA string of the commit to cherry-pick | + | * **Note**: Where SHA is the SHA string of the commit to cherry-pick |
| - | Resolve conflicts and check commit merge diff | + | Resolve conflicts and check result |
| < | < | ||
| Line 270: | Line 345: | ||
| </ | </ | ||
| - | Publish cherry-picked | + | Publish cherry-picked changes to origin repository |
| < | < | ||