From 74284accc69789a02e2c9ca7c169439a8facf446 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 9 Mar 2014 08:26:33 +1600 Subject: [PATCH] Re: [PATCH] nmbug: Add 'clone' and replace FETCH_HEAD with @{upstream} --- f7/6f14c12e819ef2b46e23d8aa3f8cfeece4053e | 187 ++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 f7/6f14c12e819ef2b46e23d8aa3f8cfeece4053e diff --git a/f7/6f14c12e819ef2b46e23d8aa3f8cfeece4053e b/f7/6f14c12e819ef2b46e23d8aa3f8cfeece4053e new file mode 100644 index 000000000..0387e8e64 --- /dev/null +++ b/f7/6f14c12e819ef2b46e23d8aa3f8cfeece4053e @@ -0,0 +1,187 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1251A431FBD + for ; Sat, 8 Mar 2014 08:26:41 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.1 +X-Spam-Level: +X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id F6OI3rUsabkn for ; + Sat, 8 Mar 2014 08:26:37 -0800 (PST) +Received: from qmta10.westchester.pa.mail.comcast.net + (qmta10.westchester.pa.mail.comcast.net [76.96.62.17]) + by olra.theworths.org (Postfix) with ESMTP id 694E7431FB6 + for ; Sat, 8 Mar 2014 08:26:37 -0800 (PST) +Received: from omta22.westchester.pa.mail.comcast.net ([76.96.62.73]) + by qmta10.westchester.pa.mail.comcast.net with comcast + id b3qX1n0031ap0As5A4Sd3F; Sat, 08 Mar 2014 16:26:37 +0000 +Received: from odin.tremily.us ([24.18.63.50]) + by omta22.westchester.pa.mail.comcast.net with comcast + id b4Sb1n00Q152l3L3i4Sc38; Sat, 08 Mar 2014 16:26:36 +0000 +Received: by odin.tremily.us (Postfix, from userid 1000) + id 046D6106C13B; Sat, 8 Mar 2014 08:26:33 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin; + t=1394295994; bh=nmXB2/JbhnASZIqNIrx31WEBxQcF10q7oRBIS+yChb8=; + h=Date:From:To:Cc:Subject:References:In-Reply-To; + b=n+ZRmQqgRk7A65jn3K1LAkbpBI6uh6o1eA9RGI+cb/3a9lixCI1F97c9VAoOvIbMB + dfQgRp26vuLNKh6sOTD3utORWHzWA9KibZqiwwVyXSM8xmKHEIMQHKcZ6DQyuvR0K3 + P8AnN72M+SNjV3obivGyzQdFtyv4S6MCea9hDJl8= +Date: Sat, 8 Mar 2014 08:26:33 -0800 +From: "W. Trevor King" +To: David Bremner +Subject: Re: [PATCH] nmbug: Add 'clone' and replace FETCH_HEAD with + @{upstream} +Message-ID: <20140308162633.GM16433@odin.tremily.us> +References: + <80db13662a0313711ca3a91e338a63d35e64a83c.1391898002.git.wking@tremily.us> + <87siqsrhch.fsf@zancas.localnet> +MIME-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="dp9QYJgVRVEW2bsm" +Content-Disposition: inline +In-Reply-To: <87siqsrhch.fsf@zancas.localnet> +OpenPGP: id=39A2F3FA2AB17E5D8764F388FC29BDCDF15F5BE8; + url=http://tremily.us/pubkey.txt +User-Agent: Mutt/1.5.22 (2013-10-16) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; + s=q20121106; t=1394295997; + bh=NqZRVi0pfJjp+0Bs8qtPjbOVzrMEm97OajCLGjXRrZ4=; + h=Received:Received:Received:Date:From:To:Subject:Message-ID: + MIME-Version:Content-Type; + b=BD8cdWuqViy+zrKveEYieurl9KmBfymSqVw1tbE7OhYMdw5HO47CYyGnsgCwmr9Ek + blcwXbjgEzG891fG5IhN3ArOEH3Vp7PCVg1m+pqkR/ymeJ75Ce0UIBou4ne/nXpeO6 + pxMeeQvyHK3vJ11wqc74LEbxIczipRhgntuKmtZKaJwyYHugqYteMjO8gGoXLG8ANq + UZYgc3TN9s8mrsMWT/RW/+1DrXUU9KcvQ/uiLImJu1JupigBiXHUDhHLuS+YB/FLVF + qA6LGHBHQV29rK/8kk9YIS7kiFFvCa+uLGC53oxsy3Xyf/D1xW/QI/AYdORfjVHs73 + Usc88vgM9LjZA== +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 08 Mar 2014 16:26:41 -0000 + + +--dp9QYJgVRVEW2bsm +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Sat, Mar 08, 2014 at 08:43:26AM -0400, David Bremner wrote: +> W. Trevor King writes: +> > +sub do_clone { +> > + my $repository =3D shift; +> > + system ('git', 'clone', '--bare', $repository, $NMBGIT) =3D=3D 0 +> > + or die "'git clone' exited with nonzero value\n"; +> > + my $branch =3D git ('symbolic-ref', 'HEAD'); +> > + $branch =3D~ s|^refs/heads/||; +> > + git ('config', 'remote.origin.fetch', '+refs/heads/*:refs/remotes/or= +igin/*'); +> > + git ('config', "branch.$branch.remote", 'origin'); +> > + git ('config', "branch.$branch.merge", 'refs/heads/$branch'); +> > + do_fetch(); + +Oops, it looks like I used a tab instead of two spaces to indent +do_fetch. I'll fix that in v2. + +> > +} +>=20 +> I think doing a fetch immediately after a clone deserves a comment. + +I commented in the commit message. Basically everything from =E2=80=9COne +tricky bit is that bare repositories don't set upstream tracking +branches by default=E2=80=9D down through =E2=80=9Cgives us the master-bran= +ch commit.=E2=80=9D +is describing what's going on here, and why I made these changes. + +On the other hand, perhaps this is too many hoops to jump through to +get upstreams without a working directory. As an alternative +approach, we could drop --bare and use --no-checkout on the clone. +That would also let us avoid the bare-recovery config adjustments and +follow-up fetch. With do_clone reduced to just wrapping the 'git +clone' command, we could remove it and just recommend folks run: + + $ git clone --no-checkout http://nmbug.tethera.net/git/nmbug-tags.git ~/.= +nmbug + +That's going to create ~/.nmbug/.git though, if we want to preserve +the current bare-style ~/.nmbug/ layout, we'd need something like: + + $ TEMPDIR=3D$(mktemp -d) + $ git clone --no-checkout --separate-git-dir=3D~/.nmbug \ + > http://nmbug.tethera.net/git/nmbug-tags.git "${TEMPDIR}/nmbug" + $ rm -rf "${TEMPDIR}" + +If we go the --separate-git-dir route, I think we're better off hiding +that in Perl ;). + +Of the three approaches: + +1. git clone --bare =E2=80=A6, tweak configs, and git fetch +2. git clone --nocheckout =E2=80=A6 +3. git clone --nocheckout --separate-git-dir =E2=80=A6 + +I prefer the third, but I'm happy with any of them. + +> > @@ -473,7 +487,7 @@ sub diff_index { +> > sub diff_refs { +> > my $filter =3D shift; +> > my $ref1 =3D shift || 'HEAD'; +> > - my $ref2 =3D shift || 'FETCH_HEAD'; +> > + my $ref2 =3D shift || '@{upstream}'; +>=20 +> I wonder about hard-coding '@{upstream}' in several places. What do +> you think about a global "constant"? OF course it was hard-coded +> FETCH_HEAD before, but I think not in quite as many places. + +In the three non-comment places where I've hard-coded it, it's just a +default in the case that the caller left that argument empty. In the +two comment places where I've hard-coded it, one is just mentioning +that it is the default, and the other is giving it as a useful +example. I don't think that calls for another layer of indirection. + +Cheers, +Trevor + +--=20 +This email may be signed or encrypted with GnuPG (http://www.gnupg.org). +For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy + +--dp9QYJgVRVEW2bsm +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2.0.22 (GNU/Linux) + +iQIcBAEBAgAGBQJTG0S3AAoJEKKfehoaNkbt4bYP/3vMIr+4d7pfdJzyfuz5Ezcp +jiWeY6PD/O5XDIBxu4FfxsW7czMO/PZ1Om334M6VgmeE24Xl/y+a6FMf2f6FcQ7z +/8g1vhzQJBo8iqcBJ72LPH+97suNK72tywEWt9Mzvyjwk5kl/ngn+zeD3fwCrBKD +/4Z+cy42p84TkD69QJefOCAWeStHWIzJPFPPwxworY9rOigADklhoVsoZU55J1EM +ySFsSW72N8wsf65qbjnuhwihOG9Hs6fcpHiqvgssEKwpEqtyvCO9Ide4YcqMfd17 +9i/iA4VqDaSEfFZqd4Yx3g192MCvft7g8AVQJw5VTWr9oodos2NYHeaNYdmPh+Y5 +gGqF/3YRPjXzFMyySljYjDO08jZrKMUHESAJ1SMbzDALnLgIA0+KMYkZBza7o05q +/dkYpfBF1h4Zuj7cTHU/Cg/LmqpPtQiP4EPRkGa2Y7NnLcEb8jfdlHqpNx/PmFfG +q3HAILQsJnGTg2I4s9wDRFuKIvEQL8uI0Ygl8LLS85wWN7f2nagNs9MExQs7otrs +MFcAvN6m8SztBqAWRZ/ZkUx3LphQfhRy3qrnpHeT6wJQLfhXl7qhyTceadFBDvGQ +Q8/tWV3q7tMtuwIQE7J9YtX2DbcQeT9Vf/NnaK2H0EMrSvr5eLNbvppe4WigqZ4P +EXDgc9+5HWv1/35EFe4L +=GZ0q +-----END PGP SIGNATURE----- + +--dp9QYJgVRVEW2bsm-- -- 2.26.2