On Sat, Mar 08, 2014 at 08:43:26AM -0400, David Bremner wrote:
> W. Trevor King writes:
> > +sub do_clone {
> > +  my $repository = shift;
> > +  system ('git', 'clone', '--bare', $repository, $NMBGIT) == 0
> > +    or die "'git clone' exited with nonzero value\n";
> > +  my $branch = git ('symbolic-ref', 'HEAD');
> > +  $branch =~ s|^refs/heads/||;
> > +  git ('config', 'remote.origin.fetch', 
> > '+refs/heads/*:refs/remotes/origin/*');
> > +  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.

> > +}
> 
> I think doing a fetch immediately after a clone deserves a comment.

I commented in the commit message.  Basically everything from ?One
tricky bit is that bare repositories don't set upstream tracking
branches by default? down through ?gives us the master-branch commit.?
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=$(mktemp -d)
  $ git clone --no-checkout --separate-git-dir=~/.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 ?, tweak configs, and git fetch
2. git clone --nocheckout ?
3. git clone --nocheckout --separate-git-dir ?

I prefer the third, but I'm happy with any of them.

> > @@ -473,7 +487,7 @@ sub diff_index {
> >  sub diff_refs {
> >    my $filter = shift;
> >    my $ref1 = shift || 'HEAD';
> > -  my $ref2 = shift || 'FETCH_HEAD';
> > +  my $ref2 = shift || '@{upstream}';
> 
> 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

-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140308/0edcfb5a/attachment.pgp>

Reply via email to