Date: Fri, 16 Apr 2021 22:48:46 -0600 From: Warner Losh <imp@bsdimp.com> To: Dan Langille <dan@langille.org> Cc: freebsd-git <freebsd-git@freebsd.org> Subject: Re: FreshPorts - processing branches: help wanted Message-ID: <CANCZdfpSkBh4AzTLnAMP-XEidof2bPJwE-gqWWg_8otM8K03KQ@mail.gmail.com> In-Reply-To: <35888E09-CF1B-42AD-98B4-3792A0458912@langille.org> References: <35888E09-CF1B-42AD-98B4-3792A0458912@langille.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Apr 16, 2021 at 7:23 PM Dan Langille <dan@langille.org> wrote: > Back in Nov mat wrote: > > re: > https://lists.freebsd.org/pipermail/freebsd-git/2020-November/000498.html > > > From what I understood, freshports never needs to be able to access > > files on the top of a branch, it only needs to access the files on > > specific commits (the fact that a commit is at the top of the branch is > > only an artefact of the process). So, you never need to checkout any > > branches, you only need to checkout commits. So you never have a HEAD > > that points to a branch, HEAD is always in a detached state and points > > to a commit. > > Yes. This is the current state on production: > > [dan@ingress01:/var/db/freshports/ports-jail/var/db/repos/ports] $ git > status > HEAD detached at 9d5f4ef1a469 > nothing to commit, working tree clean > So something moved the tip of the main branch, or you checked out a specific version. > > So what you need to do is, git clone the repository, and then, each time > > the script runs, do (in somewhat shell script): > > > > ############################# > > NAME_OF_REMOTE=origin > > NAME_OF_HEAD=main > > > > cd /where/the/repo/is > > > > git fetch > > > > # get all references (so, branches, tags, and so one) and keep only > > # branches (named commits here) that the remote repository has > > > > If I want to follow a new remote branch, I have to first do: git checkout > <branchname> ? > Yes. > This makes some sense to me, but this late in the day, I can't follow it. > > I'm hoping someone is willing to follow up on this suggestion and proceed > with coding. > It doesn't depend upon having a FreshPorts environment at all. > Yea, I'm out of hours in the day and can just advise on how to proceed. Warner > Thank you. > > > git for-each-ref --format '%(objecttype) %(refname)' \ > > | sed -n 's/^commit refs\/remotes\///p' > > | while read -r type refname > > do > > > > # If we don't have the tag, it means we have not encountered the > > # branch yet. > > if ! git tag -l freshports/$refname > > then > > > > # get the first commit of that branch and create a tag. > > git tag -m "first known commit of $refname" -f freshports/$refname > $(git merge-base $NAME_OF_REMOTE/$NAME_OF_HEAD $refname) > > fi > > > > # Get the list of commits between the last known one and the tip of > > # the branch, list may be empty. > > git rev-list freshports/$refname..$refname | while read commithash > > do > > # checkout that commit (with -f so that if some file got changed, we > > # overwrite everything > > git checkout -f $commithash > > > > # process the commit > > done > > > > # Store the last known commit that we just processed. > > git tag -m "last known commit of $refname" -f freshports/$refname > $refname > > done > > ############################# > > > > That's all, you never need to merge or pull or whatever else. > > The current solution is doing a 'git fetch'. > > Now it's time to start doing branches. > > Thank you. > > -- > Dan Langille - BSDCan / PGCon > dan@langille.org > > > _______________________________________________ > freebsd-git@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-git > To unsubscribe, send any mail to "freebsd-git-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfpSkBh4AzTLnAMP-XEidof2bPJwE-gqWWg_8otM8K03KQ>