Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Jan 2021 23:46:38 -0800
From:      Mark Millard <marklmi@yahoo.com>
To:        mueller6722@twc.com, Current FreeBSD <freebsd-current@freebsd.org>
Subject:   Re: Getting /usr/src to match specific git hash?
Message-ID:  <F5690272-6F40-454E-B753-34C430E56463@yahoo.com>
In-Reply-To: <14BEA6ED-564D-46AD-857D-F9117D60F76E@yahoo.com>
References:  <14BEA6ED-564D-46AD-857D-F9117D60F76E.ref@yahoo.com> <14BEA6ED-564D-46AD-857D-F9117D60F76E@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On 2021-Jan-24, at 23:37, Mark Millard <marklmi at yahoo.com> wrote:
>=20
>> How cat one track multiple branches with git without keeping entirely=20=

>> separate trees?
>=20
> There are multiple possibilities here and it is not
> clear which you are hoping for.
>=20
> A) You could be trying to avoid having two separate .git
>   copies around, each also with checked-out material.
>=20
>   (2 separate deep clones.)
>=20
> B) You could be trying to avoid having 1 .git with
>   two directories trees for checkouts.
>=20
>   (One deep clone with an added worktree, for example.)
>=20
> 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.)
>=20
>   (One deep clone and no additional worktrees.)
>=20
> 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.)
>=20
>   (2 separate shallow clones in separate directories,
>   one for each branch.)
>=20
> My guess from your wording is that you are after (C).
>=20
> 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.
>=20
> 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.
>=20
> For building main :
>=20
> # cd /usr/src
> # git switch --discard-changes main
> # git fetch freebsd                # if advancing
> # git merge --ff-only freebsd/main # if advancing
> # . . .
>=20
> vs. for building stable/13 :
>=20
> # cd /usr/src
> # git switch --discard-changes stable/13
> # git fetch freebsd                     # if advancing
> # git merge --ff-only freebsd/stable/13 # if advancing
> # . . .
>=20
> In the above the commit is implicit as the
> HEAD for the branch named.
>=20
> There is also being more explicit about the
> commit that you want (branch implicit):
>=20
> # 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:
>=20
> # git checkout -b NEW_BRANCH_NAME
>=20
>=20
> For reference, from my context:
>=20
> # du -sAm /usr/fbsd/main-src/ /usr/fbsd/main-src/.git
> 2487	/usr/fbsd/main-src/
> 1379	/usr/fbsd/main-src/.git
>=20
> So 2487 would estimate (C) as things
> are now for main or stable/13 .
>=20
> 2487-1379=3D=3D1108 for the implicit, primary
> worktree that goes with the clone.
>=20
> A additional worktree tied to the above:
>=20
> # du -sAm /usr/fbsd/mm-src/
> 1108	/usr/fbsd/mm-src/
>=20
> So 2487+1108 =3D=3D 3595 total using the additional
> worktree, i.e., (B).
>=20
> Just for reference for how much space (D) takes:
>=20
> # 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.
>=20
> # du -sAm /usr/fbsd/main-shallow/ /usr/fbsd/main-shallow/.git
> 1378	/usr/fbsd/main-shallow/
> 271	/usr/fbsd/main-shallow/.git
>=20
> (The .git is branch specific only.)
>=20
> So about 2*1378 =3D=3D 2756 total to also have a separate one for
> stable/13 in, say, /usr/fbsd/stable-13-shallow/ .




=3D=3D=3D
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F5690272-6F40-454E-B753-34C430E56463>