Re: Getting /usr/src to match specific git hash?

From: Mark Millard <marklmi_at_yahoo.com>
Date: Sun, 24 Jan 2021 23:46:38 -0800
On 2021-Jan-24, at 23:37, Mark Millard <marklmi at yahoo.com> wrote:
> 
>> How cat one track multiple branches with git without keeping entirely 
>> separate trees?
> 
> There are multiple possibilities here and it is not
> clear which you are hoping for.
> 
> A) You could be trying to avoid having two separate .git
>   copies around, each also with checked-out material.
> 
>   (2 separate deep clones.)
> 
> B) You could be trying to avoid having 1 .git with
>   two directories trees for checkouts.
> 
>   (One deep clone with an added worktree, for example.)
> 
> C) You could be trying to have one .git copy and only
>   one directory tree with only one checkout at a time.
>   (In some contexts, this sort of thing might involve
>   considerable time and I/O for switching the content
>   of the directory tree to be the checkout of a
>   different branch. main vs. stable/13 now vs.
>   3 years from now might be different.)
> 
>   (One deep clone and no additional worktrees.)
> 
> D) Sort of like (A) but using 2 Shallow Clones, one per
>   branch. (This uses somewhat more space than (C),
>   but not a lot more.)
> 
>   (2 separate shallow clones in separate directories,
>   one for each branch.)
> 
> My guess from your wording is that you are after (C).
> 
> I presume no local modifications/patches and do not
> cover how to handle having such. The command sequences
> shown would destroy local changes. It is not clear if
> such matches what you are after or not.
> 
> I presume below /usr/src/ use for where the clone was
> put. It also presumes the fetch status is recent enough
> to contain the commit that you want to use.
> 
> For building main :
> 
> # cd /usr/src
> # git switch --discard-changes main
> # git fetch freebsd                # if advancing
> # git merge --ff-only freebsd/main # if advancing
> # . . .
> 
> vs. for building stable/13 :
> 
> # cd /usr/src
> # git switch --discard-changes stable/13
> # git fetch freebsd                     # if advancing
> # git merge --ff-only freebsd/stable/13 # if advancing
> # . . .
> 
> In the above the commit is implicit as the
> HEAD for the branch named.
> 
> There is also being more explicit about the
> commit that you want (branch implicit):
> 
> # cd /usr/src
> # git fetch freebsd # if advancing
> # git reset --hard 08b8197a74 # use appropriate hashid
> # . . .

On review, I forgot that git reset --hard can create
untracked files and such. So I add a git clean -f -d
to the sequence:

# cd /usr/src
# git fetch freebsd # if advancing
# git reset --hard 08b8197a74 # use appropriate hashid
# git clean -f -d
# . . .

> This "reset --hard" command produces a "detached HEAD"
> notice that you can either ignore --or you can then
> create a local branch that uses that HEAD:
> 
> # git checkout -b NEW_BRANCH_NAME
> 
> 
> For reference, from my context:
> 
> # du -sAm /usr/fbsd/main-src/ /usr/fbsd/main-src/.git
> 2487	/usr/fbsd/main-src/
> 1379	/usr/fbsd/main-src/.git
> 
> So 2487 would estimate (C) as things
> are now for main or stable/13 .
> 
> 2487-1379==1108 for the implicit, primary
> worktree that goes with the clone.
> 
> A additional worktree tied to the above:
> 
> # du -sAm /usr/fbsd/mm-src/
> 1108	/usr/fbsd/mm-src/
> 
> So 2487+1108 == 3595 total using the additional
> worktree, i.e., (B).
> 
> Just for reference for how much space (D) takes:
> 
> # git clone -o freebsd --depth 1 -b main https://git.freebsd.org/src.git /usr/fbsd/main-shallow
> Cloning into '/usr/fbsd/main-shallow'...
> remote: Enumerating objects: 88695, done.
> remote: Counting objects: 100% (88695/88695), done.
> remote: Compressing objects: 100% (76042/76042), done.
> remote: Total 88695 (delta 18867), reused 51008 (delta 9483), pack-reused 0
> Receiving objects: 100% (88695/88695), 258.57 MiB | 9.14 MiB/s, done.
> Resolving deltas: 100% (18867/18867), done.
> Updating files: 100% (85161/85161), done.
> 
> # du -sAm /usr/fbsd/main-shallow/ /usr/fbsd/main-shallow/.git
> 1378	/usr/fbsd/main-shallow/
> 271	/usr/fbsd/main-shallow/.git
> 
> (The .git is branch specific only.)
> 
> So about 2*1378 == 2756 total to also have a separate one for
> stable/13 in, say, /usr/fbsd/stable-13-shallow/ .




===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
Received on Mon Jan 25 2021 - 06:46:44 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:26 UTC