From owner-freebsd-git@freebsd.org Wed Jan 27 20:55:48 2021 Return-Path: Delivered-To: freebsd-git@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1AF2D4E9DCE for ; Wed, 27 Jan 2021 20:55:48 +0000 (UTC) (envelope-from uqs@freebsd.org) Received: from acme.spoerlein.net (acme.spoerlein.net [IPv6:2a05:fc87:1:5::15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "www.spoerlein.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DQwqR5J7lz3N69 for ; Wed, 27 Jan 2021 20:55:47 +0000 (UTC) (envelope-from uqs@freebsd.org) Received: from localhost (acme.spoerlein.net [IPv6:2a05:fc87:1:5:0:0:0:15]) by acme.spoerlein.net (8.16.1/8.15.2) with ESMTPS id 10RKtgOc070058 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 27 Jan 2021 21:55:42 +0100 (CET) (envelope-from uqs@freebsd.org) Date: Wed, 27 Jan 2021 21:55:42 +0100 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: Milan Obuch Cc: freebsd-git@freebsd.org Subject: Re: git setup/usage question Message-ID: References: <20210126151017.4a9dd711@zeta.dino.sk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210126151017.4a9dd711@zeta.dino.sk> User-Agent: Mutt/2.0.3 (2020-12-04) X-Rspamd-Queue-Id: 4DQwqR5J7lz3N69 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; ASN(0.00)[asn:39540, ipnet:2a05:fc87::/32, country:CH] X-BeenThere: freebsd-git@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussion of git use in the FreeBSD project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jan 2021 20:55:48 -0000 On Tue, 2021-01-26 at 15:10:17 +0100, Milan Obuch wrote: >Hi, > >I am working on new workflow setup after svn->git move. I did some >tests, starting with Warner's Hacking Blog at >http://bsdimp.blogspot.com/2020/10/freebsd-git-primer-for-users.html >and trying some suggestion and ideas taken from both this and current >mailing lists. > >After gaining some bits of knowledge I am going to create something >more elaborate... for me. > >What I would like to achieve: > >- use one repository for all branches of interest and as working area > too > >- use separate working directory for each branch and working area > (possibly multiple for multiple projects) > >- track remote repository periodically and update working tree as > needed (immediatelly after repository update or delayed when other > work on a tree is being done at the moment). > >I do not see in this anything special, just the primer mentioned above >handles basically just single working area case, which makes necessary >some switching (via checkout of different branch or somesuch). > >So what I did: > ># git clone --config remote.freebsd.fetch='+refs/notes/*:refs/notes/*' --bare https://git.freebsd.org/src.git /mnt/src/.git ># git -C /mnt/src/.git worktree add /mnt/src/main main ># git -C /mnt/src/.git worktree add /mnt/src/13 stable/13 ># git -C /mnt/src/.git worktree add /mnt/src/12 stable/12 ># git -C /mnt/src/.git worktree add /mnt/src/11 stable/11 > >This way I have nice directory structure in /mnt/src, I can use >individual trees for either local null mount (for jails and similar >usage) or remote mount via nfs. > >Look for status: > ># git -C /mnt/src/.git worktree list >/mnt/src (bare) >/mnt/src/11 09bdde595dd [stable/11] >/mnt/src/12 70cdab054c8 [stable/12] >/mnt/src/13 da2dfec8f75 [stable/13] >/mnt/src/main 25cdacf79b0 [main] > >Nice! Clear, easy to understand. With some scripting, this could be >used to create id string for uname use (there is a thread about this on >arch list, this is something I need to think about especially for >remote building with sources mounted over nfs). > >Now for updating, trying to fetch... > ># git -C /mnt/src/.git fetch >From https://git.freebsd.org/src > * branch HEAD -> FETCH_HEAD > >This looks like there is nothing new to fetch at the moment. So waiting >a bit for new commit... waiting a bit more... trying again... > ># git -C /mnt/src/.git fetch >remote: Enumerating objects: 5, done. >remote: Counting objects: 100% (5/5), done. >remote: Compressing objects: 100% (5/5), done. >remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0 >Unpacking objects: 100% (5/5), 42.60 KiB | 484.00 KiB/s, done. >From https://git.freebsd.org/src > * branch HEAD -> FETCH_HEAD > >This time there is something new... I need a merge now. > ># git -C /mnt/src/.git merge >fatal: this operation must be run in a work tree No, you don't want to merge. Why would you merge? You want to run `git pull`, that will pull the updates from the remote refs into your local refs. > >I am a bit stuck now. What does it mean 'being in a work tree'? Doing >'cd /mnt/src/main' or similar before git command does not change >anything. I read 'man git-merge' but still no clue. It must be >something simple, I just do not see it. > >Also, > ># git -C /mnt/src/.git log > >does not show new commit yet. If I do 'git pull --ff-only' command >(with another git repository, created exactly the way mentioned in >primer) at the same time, I see new commit in log output. It looks like >log is updated on merge, not fetch, judging from my previous litlle bit >of experience with git, so this maybe should be expected, I just do not >know. No, the log isn't updated on `merge` (probably just sloppy wording), what your log does is show the log of the local ref and you haven't pulled anything into it yet. If you had done git log refs/remotes/freebsd/main (or whatever that is on a bare repo), then you'd have seen the updates. >So the big question - did I the right steps to achieve what I want, >descibed in the beginning of this mail? Is this way OK to use, or >should I use some other way to achieve this? Yep, all looks perfectly fine, except you need to run git pull to bring in remote changes. So usually `git fetch` to update your copy of the remote refs, then `git pull --rebase` to bring in the changes into your local copy of the ref _and_ update the checked out copy. You might have to tweak all that a bit though for the bare repo case with worktrees. hth Uli