Size: 10544
Comment: another problem popped up
|
← Revision 69 as of 2024-05-17T19:52:44+0000 ⇥
Size: 9849
Comment: Remove warning about rerolling the svn-git conversion - the conversion is done
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Introduction = | {{{#!wiki orange/solid The official FreeBSD Git repo is now at https://cgit.freebsd.org/src/ |
Line 3: | Line 4: |
There are a couple of FreeBSD git repositories that have been converted with various programs and various parameters. This page describes the "official" git-branches of the FreeBSD project that should be used as common repositories to base other work on. |
Clone TL;DR: (public-mirror) https://git.FreeBSD.org/src.git ssh://anongit@git.FreeBSD.org/src.git (developers-only) ssh://git@gitrepo.FreeBSD.org/src.git }}} |
Line 8: | Line 12: |
The repositories are provided as a read-only mirror of the state of the Subversion src, doc and, ports repositories at http://svn.FreeBSD.org/base, http://svn.FreeBSD.org/doc, and http://svn.FreeBSD.org/ports respectively. Using git to commit changes to these repositories is not officially supported (but doable), instead it is supposed to serve as a collaboration point by using additional tools like Github, Gitorious, or Gerrit, etc. |
|
Line 15: | Line 13: |
Bear in mind that git will not replace Subversion for use in FreeBSD and the repository is only offered on a best-effort basis. The steps to redo the conversion are outlined below, so that people can move the process in-house should they see the need for it. CAVEAT EMPTOR: The repositories might need to be re-done every once in a while due to bugs or improvements in the converter. This will result in changed commit IDs for the impacted branches. As the actual tree objects for a certain SVN revision will remain identical, it will always be possible to rebase or merge your work on these new branches and not run into any merge conflicts. Ask on the mailing lists if you need help with the required git commands. |
{{{#!wiki orange/solid The content of this page needs to be updated, please refer to the latest doc from git migration WG at https://github.com/bsdimp/freebsd-git-docs/ , and the discussion on https://lists.freebsd.org/mailman/listinfo/freebsd-git . }}} |
Line 30: | Line 19: |
= The Repositories = | |
Line 32: | Line 20: |
The official repository-mirrors are updated at least hourly, should they lag the svn repository by more than that, please contact <uqs@FreeBSD.org> (monitoring still needs to be put into place, help wanted btw). | {{{#!wiki orange/solid Update: 2020-12-14: These are not the repositories for the 2020/2021 svn to git conversion, please see the note above. The below is mostly historic information and will soon be entirely obsolete. }}} = Introduction = |
Line 34: | Line 25: |
* git://git.freebsd.org/freebsd.git * git://git.freebsd.org/freebsd-doc.git * git://git.freebsd.org/freebsd-ports.git (the canonical sources) * '''git://github.com/freebsd/freebsd.git''' * '''git://github.com/freebsd/freebsd-doc.git''' * '''git://github.com/freebsd/freebsd-ports.git''' (the preferred sources) * https://code.google.com/p/freebsd (stale, Google Code chokes on pushes that are too large, devs informed and aware of the issue) |
This page used to describe the inofficial git mirrors of the SVN repositories of the FreeBSD project that could be used as common repositories to base other work on. |
Line 42: | Line 28: |
The obsolete, non-compatible repositories are: | The repositories were read-only mirrors of the [[https://www.freebsd.org/doc/handbook/svn.html|src, doc and, ports FreeBSD Subversion repositories]] |
Line 44: | Line 30: |
* A git-svn clone of head and a couple of stable branches, but with truncated history. * git://gitorious.org/freebsd/freebsd.git |
Bear in mind that git does not replace use of Subversion in FreeBSD and the repository is currently offered on a best-effort basis only. The steps to recreate the conversion are outlined below, so that people can replicate the process in-house should they wish to. |
Line 47: | Line 33: |
* A git-svn clone of head, with complete history. It's what you get when doing: `git svn clone -Thead svn+ssh://svn.freebsd.org/base/` * git://git.freebsd.your.org/freebsd-head * rsync://repos.freebsd.your.org/freebsd-head.git/ * git://github.com/freebsd/freebsd-head.git * git://gitorious.org/freebsd/freebsd-head.git * https://code.google.com/p/freebsd-head |
= Repositories = |
Line 54: | Line 35: |
= Known Problems = | The repository mirrors are updated at least hourly. Should they lag the SVN repository by more than a day, please create a [[https://bugs.freebsd.org/bugzilla/enter_bug.cgi?component=Git%20Integration&product=Services|new Bugzilla Issue: Git Integration]]. Monitoring still needs to be put into place, help wanted btw. |
Line 56: | Line 37: |
* SVN merges for single revisions (that span only parts of the tree then), are not really representable as merges in git and instead are called cherry-picks there. The converter tries to be smart about whole tree merges however -- this heuristic is only activated for the head/, user/, and projects/ branches. A whole-tree merge of project/foo into head/ should thus be correctly represented in git. Merges from head/ to stable/ or from contrib/ to head/ will be plain commits, i.e. "cherry-picks". * It seems that with git v1.8.0 the commit hashes of merge commits have changed when using the exporter. It is unclear who's fault it is currently, but it means that the conversion is not repeatable for users of git v1.8.0 and that a re-roll of the whole repositories might be necessary |
As of 2020-12-14, canonical repository of doc has been migrate to git: |
Line 59: | Line 39: |
The first differing commit in the repo went from {{{ % git show --format=raw 42f0fad|head commit 42f0fadccab6eefc7ffdc1012345b42ad45e36c2 tree de2d7c6726a45428d4a310da2acd8839daf9f85f parent 5fba0401c23a594e4ad5e807bf14a5439645a358 parent 25062ba061871945759b3baa833fe64969383e40 parent 89bebeef185ed08424fc548f8569081c6add2439 parent 48231afadc40013e6bfda56b04a11ee3a602598f parent c7d5f60d3a7e2e3c4da23b157c62504667344438 parent e7bc108f0d6a394050818a4af64a59094d3c793e author rgrimes <rgrimes@FreeBSD.org> 739897097 +0000 committer rgrimes <rgrimes@FreeBSD.org> 739897097 +0000 }}} to {{{ % git show --format=raw e209a83|head commit e209a83c1e0a387c88a44f3a8f2be2670ed85eae tree de2d7c6726a45428d4a310da2acd8839daf9f85f parent 5fba0401c23a594e4ad5e807bf14a5439645a358 parent 25062ba061871945759b3baa833fe64969383e40 parent 89bebeef185ed08424fc548f8569081c6add2439 parent c7d5f60d3a7e2e3c4da23b157c62504667344438 parent e7bc108f0d6a394050818a4af64a59094d3c793e parent 48231afadc40013e6bfda56b04a11ee3a602598f author rgrimes <rgrimes@FreeBSD.org> 739897097 +0000 committer rgrimes <rgrimes@FreeBSD.org> 739897097 +0000 }}} |
* https://cgit.freebsd.org/doc/ (web repository browser) * `https://git.FreeBSD.org/doc.git` (readonly, geographically distributed mirror for cloning through https) * anongit@git.FreeBSD.org:doc.git (readonly, geographically distributed mirror for cloning through anonymous ssh) * git@gitrepo.FreeBSD.org:doc.git (read/write for committers to push) ports: * '''https://github.com/freebsd/freebsd-ports.git''' (the preferred sources for cloning and browsing) * https://cgit-beta.freebsd.org/ports/ (the canonical sources, web repository browser) * `https://cgit-beta.freebsd.org/ports.git` (the canonical sources for cloning) src: * '''https://github.com/freebsd/freebsd.git''' (the preferred sources for cloning and browsing) * https://cgit-beta.freebsd.org/src/ (the canonical sources, web repository browser) * `https://cgit-beta.freebsd.org/src.git` (the canonical sources for cloning) |
Line 90: | Line 57: |
* Fork your own copy of https://github.com/freebsd/freebsd.git: [[https://help.github.com/articles/fork-a-repo/|Fork A Repo]] * Keep your fork in sync: [[https://help.github.com/articles/syncing-a-fork/|Syncing a fork]] |
|
Line 91: | Line 62: |
$ git clone git://github.com/freebsd/freebsd.git $ cd freebsd $ hack, hack, hack |
$ git clone --config remote.origin.fetch='+refs/notes/*:refs/notes/*' https://github.com/YourGitUserName/freebsd.git $ cd freebsd && git pull # For some reason, the notes will not be fetched during the clone operation ... (hack, hack, hack) |
Line 105: | Line 76: |
A useful reference for the issue with notes is [[https://git-scm.com/book/en/v2|Pro Git book, written by Scott Chacon and Ben Straub and published by Apress]]. | |
Line 106: | Line 78: |
= Collaboration = | == Adding SVN Revision Notes to an Existing Clone == |
Line 108: | Line 80: |
There is no endorsed way yet of how users should collaborate with developers on changes they have made. Please bear in mind that git is strictly ancillary at this point and not many committers are using it. |
The git notes in the Github repositories contain useful information, and show up in `git-log` if present. `git-clone` without the `--config ...` line from above will default to '''not''' cloning `refs/notes`. You can configure the local git repo to fetch notes like so: |
Line 112: | Line 82: |
Having your patches/feature-branches published on github for a FreeBSD committer to comment on and pull from seems like the first sensible step. Sending a patch-bomb with `git send-email` might be an alternative to github or for developers that do not want to use git. |
{{{ $ cd freebsd $ git config --add remote.origin.fetch '+refs/notes/*:refs/notes/*' $ git fetch # It's many MB for src, will take some time }}} |
Line 117: | Line 88: |
Receiving and integrating these patches can be done in various ways, see below. | It will add lines to your `git log` output like this: {{{ Notes: svn path=/head/; revision=277815 }}} |
Line 121: | Line 98: |
Integrating the changes back into svn is not as trivial as using `git-svn(1)`, as the current repository doesn't have the required meta-information. Instead patches can be applied to a subversion workspace just like any other regular patch. |
== Using git-svn == |
Line 126: | Line 100: |
A more sophisticated approach would be to share the svn and the git workspaces, which can be done by putting .svn in .gitignore and vice versa. This requires subversion 1.7 and you need to know how to recover from out-of-sync workspaces in both subversion and git, or be extra careful to avoid this situation. |
[[GitWorkflow/GitSvn#Using_git-svn|Using git-svn]] |
Line 131: | Line 102: |
== Using git-svn (FreeBSD committers only) == | == Merging pull requests from GitHub using git-svn == |
Line 133: | Line 104: |
The repositories on github also have a branch that is the result of a conversion using git-svn, i.e. the necessary conversion has already been made. To use this, you simply need to: | Note: This only applies to, and works for committers |
Line 135: | Line 106: |
{{{ $ git clone git://github.com/freebsd/freebsd.git $ cd freebsd $ git svn init -Thead svn+ssh://svn.freebsd.org/base . # People w/o write access to SVN can use this instead: git svn init -Thead --rewrite-root=svn+ssh://svn.freebsd.org/base svn://svn.freebsd.org/base . $ git update-ref refs/remotes/trunk `git show-ref origin/svn_head|cut -d" " -f1` # git-svn really needs this branch $ git svn fetch # This will now reconstruct the necessary metadata and should be pretty fast $ git checkout trunk; git branch -D master # delete master $ git checkout -b master trunk # and have master hang off trunk $ git svn rebase # this will now update everything to the latest state in head }}} Now you can periodically sync to svn using `git svn rebase` and you can push small changes back to svn using `git svn dcommit`, but read on. Things to keep in mind: * Never `git merge` branches, unless you know what you're doing. * Always `git rebase` your work on top of `master`, then `git svn dcommit` can push the top commits to svn. * Always double-check with `git svn dcommit -n` to see what would happen. * While you can use `git add` for new files just fine, you won't be able to push those upstream, you can however use the patch, apply it to some subversion checkout and do the commit there. This is a shortcoming of our very own Subversion hacks, but hey, it's better than nothing! * While `git-svn` now allows you to set `svn:mergeinfo` when committing, this is so fragile that the FreeBSD projects discourages its use. Please use svn(1) for merging, sorry. |
[[GitWorkflow/GitSvn#Merging_pull_requests_from_github_using_git-svn_.28FreeBSD_committers_only.29|Merging pull requests from GitHub]] |
Line 161: | Line 111: |
Good for you, and this has been done but abandoned again for various reasons: There's no authoritative, complete and ''stable'' mapping of svn users to "Name <email>" pairs. Especially for people without access to freefall. Random contributors are more likely to have a conversion using the current parameters. | Use the .gitauthors file in the root of the ports tree. |
Line 168: | Line 118: |
= Known Problems = * SVN merges for single revisions (that span only parts of the tree then), are not really representable as merges in git and instead are called cherry-picks there. The converter tries to be smart about whole tree merges however -- this heuristic is only activated for the head/, user/, and projects/ branches. A whole-tree merge of project/foo into head/ should thus be correctly represented in git. Merges from head/ to stable/ or from contrib/ to head/ will be plain commits, i.e. "cherry-picks". == September 2019 `notes/commits` force push == Sometime around September 2019, refs/notes/commits was force-pushed, breaking fast-forward fetch. If you had a copy of notes before this, `git fetch` won't automatically update notes do to this change. To force reset your local copy to the new copy, use: {{{ $ git fetch -f <freebsd> refs/notes/commits:refs/notes/<commits_note_name> }}} Where `freebsd` is the name of your FreeBSD Git remote (if you're not sure, try `origin`). Here, `commits_note_name` is the name of your local copy of FreeBSD `refs/notes/commits` (if you followed the procedure in this wiki page, try `commits`). = Verification = == Content == Verifying that the git export is identical to the SVN tree (in content), can be done like this: {{{ $ svn export --ignore-keywords svn://svn.freebsd.org/base/head freebsd.svn ... Exported revision 243246. $ git clone --config remote.origin.fetch='+refs/notes/*:refs/notes/*' https://github.com/freebsd/freebsd.git freebsd.git $ cd freebsd.git && git pull $ git log <We see that revision 243246 is git commit f9ebae3> $ git checkout f9ebae3 $ cd ../freebsd.svn $ git --git-dir ../freebsd.git/.git diff <There should be no output, i.e. no diff> }}} == History == To verify the history and integrity of the conversion, you are advised to run such a conversion yourself and compare (and report) any discrepancies that you find. * Install the ports `devel/subversion`, `devel/git`, `devel/qt4-corelib`, `devel/qmake4` * Get an svnsync clone of the repository you want to verify, the converter can only run against a local copy * Get the converter and rules: `svn co http://svn.freebsd.org/base/user/uqs/git_conv && cd git_conv` * Remove conflicting git configs, these are not for you: `rm -rf doc-head.git freebsd-doc.git freebsd-ports.git freebsd-base.git ports-head.git src-head.git` * Build svn2git: `cd svn2git/src && make && cd ../..` * Either tweak and run the `git_conv` script, or do it manually: `svn2git/svn-all-fast-export --add-metadata-notes --identity-domain FreeBSD.org --rules freebsd-base.rules /path/to/freebsd-base.svn` * Fetch upstream commits into your repo: `cd freebsd-base.git && git remote add origin git://github.com/freebsd/freebsd.git && git fetch origin` * Find out where/if their history diverges: `git merge-base master origin/master` To redo this at a later stage, you simply need to * `svnsync sync file:///path/to/freebsd-base.svn` * `svn2git/svn-all-fast-export --add-metadata-notes --identity-domain FreeBSD.org --rules freebsd-base.rules /path/to/freebsd-base.svn` * `cd freebsd-base.git && git fetch origin` * `git merge-base master origin/master` |
|
Line 178: | Line 180: |
A good visual git reference can be found at [[http://marklodato.github.com/visual-git-guide/index-en.html|A Visual Git Reference]]. This is a decent book on getting started with Git ($16 USD for ebook) [[http://pragprog.com/book/pg_git/pragmatic-guide-to-git|Pragmatic Guide to Git]] |
|
Line 184: | Line 190: |
See the attached [[attachment:freebsd.rules]], [[attachment:freebsd-doc.rules]], and [[attachment:freebsd-ports.rules]] for the current rulesets (subject to change). The command line parameters used for the continuous conversion are: |
See the project branch at [[http://svn.freebsd.org/base/user/uqs/git_conv/]] for extra patches, rules and the scripts used to do these conversions. |
Line 187: | Line 192: |
{{{ svn2git/svn-all-fast-export --rules freebsd.rules --add-metadata-notes --identity-domain FreeBSD.org http://svn.freebsd.org/base svn2git/svn-all-fast-export --rules freebsd-doc.rules --add-metadata-notes --identity-domain FreeBSD.org http://svn.freebsd.org/doc svn2git/svn-all-fast-export --rules freebsd-ports.rules --add-metadata-notes --identity-domain FreeBSD.org http://svn.freebsd.org/ports }}} |
---- CategoryHowTo |
The official FreeBSD Git repo is now at https://cgit.freebsd.org/src/
Clone TL;DR: (public-mirror) https://git.FreeBSD.org/src.git ssh://anongit@git.FreeBSD.org/src.git (developers-only) ssh://git@gitrepo.FreeBSD.org/src.git
The content of this page needs to be updated, please refer to the latest doc from git migration WG at https://github.com/bsdimp/freebsd-git-docs/ , and the discussion on https://lists.freebsd.org/mailman/listinfo/freebsd-git .
Contents
Update: 2020-12-14: These are not the repositories for the 2020/2021 svn to git conversion, please see the note above. The below is mostly historic information and will soon be entirely obsolete.
Introduction
This page used to describe the inofficial git mirrors of the SVN repositories of the FreeBSD project that could be used as common repositories to base other work on.
The repositories were read-only mirrors of the src, doc and, ports FreeBSD Subversion repositories
Bear in mind that git does not replace use of Subversion in FreeBSD and the repository is currently offered on a best-effort basis only. The steps to recreate the conversion are outlined below, so that people can replicate the process in-house should they wish to.
Repositories
The repository mirrors are updated at least hourly. Should they lag the SVN repository by more than a day, please create a new Bugzilla Issue: Git Integration. Monitoring still needs to be put into place, help wanted btw.
As of 2020-12-14, canonical repository of doc has been migrate to git:
https://cgit.freebsd.org/doc/ (web repository browser)
https://git.FreeBSD.org/doc.git (readonly, geographically distributed mirror for cloning through https)
anongit@git.FreeBSD.org:doc.git (readonly, geographically distributed mirror for cloning through anonymous ssh)
git@gitrepo.FreeBSD.org:doc.git (read/write for committers to push)
ports:
https://github.com/freebsd/freebsd-ports.git (the preferred sources for cloning and browsing)
https://cgit-beta.freebsd.org/ports/ (the canonical sources, web repository browser)
https://cgit-beta.freebsd.org/ports.git (the canonical sources for cloning)
src:
https://github.com/freebsd/freebsd.git (the preferred sources for cloning and browsing)
https://cgit-beta.freebsd.org/src/ (the canonical sources, web repository browser)
https://cgit-beta.freebsd.org/src.git (the canonical sources for cloning)
Quick Start
Fork your own copy of https://github.com/freebsd/freebsd.git: Fork A Repo
Keep your fork in sync: Syncing a fork
$ git clone --config remote.origin.fetch='+refs/notes/*:refs/notes/*' https://github.com/YourGitUserName/freebsd.git $ cd freebsd && git pull # For some reason, the notes will not be fetched during the clone operation ... (hack, hack, hack) $ git commit
Advanced, useful examples to show the diff between a subdir of a branch, or the commits that introduced these diffs. It is basically what svn mergeinfo --show-revs=eligible does. See git-log(1) for more info.
$ git diff origin/stable/9 master -- usr.sbin/acpi $ git log --graph --format=oneline --right-only --cherry-pick --no-merges origin/stable/9...origin/master -- usr.sbin/acpi
See any other git howto or documentation if you're stuck on the basics. A useful reference for the issue with notes is Pro Git book, written by Scott Chacon and Ben Straub and published by Apress.
Adding SVN Revision Notes to an Existing Clone
The git notes in the Github repositories contain useful information, and show up in git-log if present. git-clone without the --config ... line from above will default to not cloning refs/notes. You can configure the local git repo to fetch notes like so:
$ cd freebsd $ git config --add remote.origin.fetch '+refs/notes/*:refs/notes/*' $ git fetch # It's many MB for src, will take some time
It will add lines to your git log output like this:
Notes: svn path=/head/; revision=277815
Integration
Using git-svn
Merging pull requests from GitHub using git-svn
Note: This only applies to, and works for committers
Merging pull requests from GitHub
FAQ
- I want authornames!
- Use the .gitauthors file in the root of the ports tree.
- Why the full history and not only since day X
- It would make the history incompatible with other people's repository and the space savings are simply not worth the hassle. As of Oct/2012, all revisions make up about 933MB.
Everything done is so that everybody can verify the integrity of the conversion using the tools mentioned in this article. Hence the focus on repeat-ability of the process.
Known Problems
- SVN merges for single revisions (that span only parts of the tree then), are not really representable as merges in git and instead are called cherry-picks there. The converter tries to be smart about whole tree merges however -- this heuristic is only activated for the head/, user/, and projects/ branches. A whole-tree merge of project/foo into head/ should thus be correctly represented in git. Merges from head/ to stable/ or from contrib/ to head/ will be plain commits, i.e. "cherry-picks".
September 2019 `notes/commits` force push
Sometime around September 2019, refs/notes/commits was force-pushed, breaking fast-forward fetch. If you had a copy of notes before this, git fetch won't automatically update notes do to this change. To force reset your local copy to the new copy, use:
$ git fetch -f <freebsd> refs/notes/commits:refs/notes/<commits_note_name>
Where freebsd is the name of your FreeBSD Git remote (if you're not sure, try origin). Here, commits_note_name is the name of your local copy of FreeBSD refs/notes/commits (if you followed the procedure in this wiki page, try commits).
Verification
Content
Verifying that the git export is identical to the SVN tree (in content), can be done like this:
$ svn export --ignore-keywords svn://svn.freebsd.org/base/head freebsd.svn ... Exported revision 243246. $ git clone --config remote.origin.fetch='+refs/notes/*:refs/notes/*' https://github.com/freebsd/freebsd.git freebsd.git $ cd freebsd.git && git pull $ git log <We see that revision 243246 is git commit f9ebae3> $ git checkout f9ebae3 $ cd ../freebsd.svn $ git --git-dir ../freebsd.git/.git diff <There should be no output, i.e. no diff>
History
To verify the history and integrity of the conversion, you are advised to run such a conversion yourself and compare (and report) any discrepancies that you find.
Install the ports devel/subversion, devel/git, devel/qt4-corelib, devel/qmake4
- Get an svnsync clone of the repository you want to verify, the converter can only run against a local copy
Get the converter and rules: svn co http://svn.freebsd.org/base/user/uqs/git_conv && cd git_conv
Remove conflicting git configs, these are not for you: rm -rf doc-head.git freebsd-doc.git freebsd-ports.git freebsd-base.git ports-head.git src-head.git
Build svn2git: cd svn2git/src && make && cd ../..
Either tweak and run the git_conv script, or do it manually: svn2git/svn-all-fast-export --add-metadata-notes --identity-domain FreeBSD.org --rules freebsd-base.rules /path/to/freebsd-base.svn
Fetch upstream commits into your repo: cd freebsd-base.git && git remote add origin git://github.com/freebsd/freebsd.git && git fetch origin
Find out where/if their history diverges: git merge-base master origin/master
To redo this at a later stage, you simply need to
svnsync sync file:///path/to/freebsd-base.svn
svn2git/svn-all-fast-export --add-metadata-notes --identity-domain FreeBSD.org --rules freebsd-base.rules /path/to/freebsd-base.svn
cd freebsd-base.git && git fetch origin
git merge-base master origin/master
Further Reading
It is *really* recommended, that you read Git for computer scientists and skim GitTalkDevSummit, although it's really outdated.
It really helps to understand the data structure of a git commit, because then you know how merging/rebasing works and can fix snafus easily.
A good visual git reference can be found at A Visual Git Reference.
This is a decent book on getting started with Git ($16 USD for ebook) Pragmatic Guide to Git
Implementation Details
The software used for the conversion is a slightly modified fork of svn2git, as used by the KDE project. It can be found at https://gitorious.org/~uqs/svn2git/uqs-svn2git
It requires a rules file to map svn trees and/or revisions to git branches or tags. The current rules don't make use of tags but simply store them as branches.
See the project branch at http://svn.freebsd.org/base/user/uqs/git_conv/ for extra patches, rules and the scripts used to do these conversions.