From owner-freebsd-git@freebsd.org Sat Apr 17 04:49:00 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 00B7B5EE118 for ; Sat, 17 Apr 2021 04:49:00 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FMgZz0dCRz3mcF for ; Sat, 17 Apr 2021 04:48:58 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x82a.google.com with SMTP id t11so13816472qtr.8 for ; Fri, 16 Apr 2021 21:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BqIIP8S5utkYYfwdnuGVOXn5HMC5J6+wC0gRS2IZKaw=; b=q2XSXxAeNLGrFr0tBqN4jnVjUKuBAO7742zC/WoB2lI0jaSTx2HwjSmfETYZQdf7G9 xwYnbvv9zTKCpc/eY/eNX7p5MXJdiz9qVcqhN4dZuUfePirEmqp6p+ArnAYzRCvuTJx8 Xv0XuhPoX9klWOOKS59R0UL8ap/hi82yeXlKAQlFxM2mszpdJIm9WFXmmFH8d2vvepC2 w/ZKraePz6x1RxkdaU8d8d3jHdhGOBbT+BcLxgM/e3zWCcztPFqYebzxF0kf5HG7jLkc AOerC2hZ0F1Ax3v5MtGpjH9LyjypsMG+FMz4Y/6s8yRyapf8JQOM8jpcjbRLYNKRDfPI SVrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BqIIP8S5utkYYfwdnuGVOXn5HMC5J6+wC0gRS2IZKaw=; b=s5Qq034wJDwLfiRxXt8qlX4O7eHTcRKS6FKpTcybgM4y7/935hY97SrNQDBhTAunXT 4LyDK7BNHPvVC5/bYfxdzj6PwJ+hggrZ2UA+dkzIrozuC8Jf8tpVy7sxuHQzmXTqW/BS 1jJ8Zt3y5t0BuSrjBEzjPHhgGmSYn/QbwJpkTCdf3/8oe5c6Rq4EYkVGMIqm9EQ8QGNx w41+nTgn4RparsBO45Pzgy20TUjrkAp18ahkFVt+2ku0nvptJTj2YbExzyl+ubj7BSKQ EmaOs8chk47F7qV21Tt0/8FurViP3km/Vs8nOEHQIOIV+blf7+2iCKeiEjke7Oly2Ykp JYPA== X-Gm-Message-State: AOAM532Ui70ula/TRxJe145XNuoKs9E7vV2KO8/WCMOCIbiYbQs2H7ov jYepxzybHFDLKuxD3Y7WWqQEDcljfpT4kjIw8ElIvVzYScpAFA== X-Google-Smtp-Source: ABdhPJznvjoaiZVEB6A62nwrF0X42n/buok5Oxg+s3fuwsvQfdzi/R2YhSX1l8LPwh10ToA/lYNkUlh5l9QNLmm/LUg= X-Received: by 2002:a05:622a:1748:: with SMTP id l8mr2287586qtk.73.1618634937754; Fri, 16 Apr 2021 21:48:57 -0700 (PDT) MIME-Version: 1.0 References: <35888E09-CF1B-42AD-98B4-3792A0458912@langille.org> In-Reply-To: <35888E09-CF1B-42AD-98B4-3792A0458912@langille.org> From: Warner Losh Date: Fri, 16 Apr 2021 22:48:46 -0600 Message-ID: Subject: Re: FreshPorts - processing branches: help wanted To: Dan Langille Cc: freebsd-git X-Rspamd-Queue-Id: 4FMgZz0dCRz3mcF X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=q2XSXxAe; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::82a) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [1.00 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; RBL_SENDERSCORE_FAIL(0.00)[2607:f8b0:4864:20::82a:server fail]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(1.00)[1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-git@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; NEURAL_SPAM_MEDIUM(1.00)[1.000]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::82a:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::82a:from]; R_SPF_NA(0.00)[no SPF record]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::82a:from]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; MAILMAN_DEST(0.00)[freebsd-git]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 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: Sat, 17 Apr 2021 04:49:00 -0000 On Fri, Apr 16, 2021 at 7:23 PM Dan Langille 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 > ? > 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" >