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

From: Dave Cottlehuber <dch_at_skunkwerks.at>
Date: Wed, 22 Jan 2025 08:23:08 UTC
On Tue, 21 Jan 2025, at 21:29, Warner Losh wrote:
>> Do you mean have the "install src" checkbox invoke git clone?
>> That seems like a better idea, at least to me. 

This wouldn't be ideal for small systems or any area with lousy
internet.

> I think we should replace the populate /usr/src from a tarball with.... 
> populate it
> with a tarball that represents a 1-deep checkout tree at the rev we 
> built the release
> from. This lets users have the source, has minimal overhead and also 
> lets users update
> or turn the shallow checkout into a deep one, etc. A shallow checkout 
> is quite a bit
> less than a full tree, though still more than just the raw files. I've 
> not done poking to
> see size comparisons.

Can we ship a working gitup config? I've not used this yet, but this
would be a good option.

Another option is to ship src.txz as we do today, but include a minimal
git config, such that `git fetch origin releng/14.2` would work. I like
this because we're not really reliant on a specific version of git 
packfiles, and it's still just src as usual.

Another option, IIRC Kyle mentioned this last year, is to use `git bundle`
https://git-scm.com/book/en/v2/Git-Tools-Bundling but I don't really know
enough about that. Perhaps that would be a reasonable option to fetch over
network, in the installer?

For the former, this seems to be sufficient:

```
# /usr/src/
.git/
.git/branches/
.git/objects/
.git/refs/
.git/HEAD               ref: refs/heads/releng/14.2
.git/description        FreeBSD 14.2-RELEASE
.git/config             see below
```

```
# .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true

[remote "origin"]
        url = https://git.freebsd.org/src.git
        pushurl = git@gitrepo.freebsd.org:src.git
        fetch = +refs/heads/releng/14.2:refs/remotes/origin/releng/14.2

[branch "releng/14.2"]
        remote = origin
        merge = refs/heads/releng/14.2
```

this yields ~ 350MiB raw, as txz its still 325MiB.

```
$ git fetch --depth 1  --no-tags --jobs 32 --set-upstream origin releng/14.2
remote: Enumerating objects: 103451, done.
remote: Counting objects: 100% (103451/103451), done.
remote: Compressing objects: 100% (89088/89088), done.
remote: Total 103451 (delta 21659), reused 41475 (delta 10515), pack-reused 0 (from 0)
Receiving objects: 100% (103451/103451), 344.67 MiB | 9.13 MiB/s, done.
Resolving deltas: 100% (21659/21659), done.
From https://git.freebsd.org/src
 * branch                releng/14.2 -> FETCH_HEAD

$ du -chs .git
348M    .git
348M    total
```

this isn't quite right, git switch / git reset --hard or similar might be needed,
but its pretty close.

A+
Dave