Re: /usr/src and /usr/ports not git directories ?

From: Tomoaki AOKI <junchoon_at_dec.sakura.ne.jp>
Date: Sun, 19 Jan 2025 00:02:47 UTC
On Sat, 18 Jan 2025 09:29:03 -0800
bob prohaska <fbsd@www.zefox.net> wrote:

> A fresh install of 
> FreeBSD-15.0-CURRENT-amd64-20250102-3d0a0dda3a7d-274510-memstick.img
> set up without much difficulty and Xorg seems to work out of the box
> on my Lenovo t400s. Both src and ports directories were installed by
> bsdinstall, but an attempt to run git pull in the src directory failed
> with "not a git repository", even though .git entries are present.
> 
> The most visible problem is lack of a /usr/src/.git directory. Can
> the existing src and ports directories be salvaged?
> 
> Thanks for reading,
> 
> bob prohaska

AFAIK, src and ports packages included in the installation media is
just "snapshots" of working directories of both. They don't
include .git (yet older subversion era, .svn) directories.

They are just for convenience and don't be intended to switch to any
VCS used at the moment (currently, git), and usually any kind of recent
"co-operational" VCS doesn't like existing working tree on creating its
local repo by mirroring (cloning) official repo.

And src and ports packages would be (IIRC, as I don't use
freebsd-update for quite a long time) updated via freebsd-update or
installer of newer releases, not via VCS.

You'd better considering them as "convenience packages for any user who
don't want local builds except it's actually mandated (for i.e.) kmod
ports) or just want to read codes.


If you want to switch to git from src and/or ports packages but already
have some local changes you don't want to be lost, you need to
"move" /usr/src and/or /usr/ports to different place
(i.e., renaming to /usr/src.local and/or /usr/ports.local), clone
official repo and apply changes to checked out /usr/src
and/or /usr/ports and applying local changes (you need to choose how to
apply changes, simply to the branch you chose or creating your own
branch and apply there).

If you don't create your own branch, you need to `git stash` before
pulling updates and `git stash pop` (or `git stash apply`) after
pulling updates. I chose this way as no one can assure that collision
of branch name with official repo (i.e., by vendor-importing any
project with accidentally named same), with the cost of hand-fixing on
mis-(auto)merges on `git stash pop` and this kind of merging issue
also happenes on rebasing local branches. I don't intend to force you
this way, just my way.


And why src and ports packages exists.
At past, when Internet was quite sloooooow, or even unavailable for
personal users, FreeBSD was distributed by CD-ROMs, Floppy Disks or
even tapes. In these cases, updating via VCS was not realistic for end
users, thus, these were mandatory, and no need to consider VCS for them.

IMHO, once any in-base tool corresponding with csup for CVS and svnlite
for Subversion (svn) is introduced for current Git, it would be the
good timing to stop providing src and ports packages until next VCS
switch happenes.

Another way would be, when switching to pkgbase-based installer,
maintaining them as pkg format and keep them in complete sync with
pkgpase and ports rebuilds. This should be much better.
Not sure it can be achieved on 15.0-Release or later releases.

-- 
Tomoaki AOKI    <junchoon@dec.sakura.ne.jp>