git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Øystein Walle" <oystwa@gmail.com>
Cc: avarab@gmail.com, git@vger.kernel.org
Subject: Re: [PATCH v2] clone: Allow combining --bare and --origin
Date: Tue, 03 Aug 2021 14:28:52 -0700	[thread overview]
Message-ID: <xmqqv94mtdyj.fsf@gitster.g> (raw)
In-Reply-To: <20210802174944.53745-1-oystwa@gmail.com> ("Øystein Walle"'s message of "Mon, 2 Aug 2021 19:49:44 +0200")

Øystein Walle <oystwa@gmail.com> writes:

> The constraint on passing both these options simultaneously has been
> present since long before clone was ported to C. At the time no
> configuration referencing the remote repository was written at all in
> bare clones.
>
> Since df61c88979 (clone: also configure url for bare clones, 2010-03-29)
> the remote repository is mentioned in the configuration file also for
> bare repos, so it makes sense to allow the user to rename it if they
> wish.

Sounds sensible.

> Ævar, I was a bit melodramatic when I wrote "especially useful". I have
> toned the commit message down a bit :-) In truth, I don't personally
> have a use-case for this (I did reach out to the person who asked about
> it in #git but did't get a reply) and have no problems with seeing this
> patch ultimately rejected. It's just a result of me seeing it asked
> about and getting an itch from it. But in my humble opinion this is now
> an "artificial" constraint (for lack of a better term) and should be
> removed on the grounds that there is no reason for it to be there in the
> first place.

Yup, that is exactly my thought when I responded to your v1.

> +test_expect_success '--bare works with -o/--origin' '
> +	git clone --bare --origin=somewhere parent clone-bare &&
> +	url="$(git -C clone-bare config --local remote.somewhere.url)" &&
> +	test -n "$url" &&
> +	test_must_fail git -C clone-bare config --local remote.origin.url
>  '

It is somewhat unfortunate that we do not say what the name of the
"origin" is anywhere in the resulting configuration file.  The only
way to tell that "--origin somewhere" was used is to notice that
there is only one remote and its name is "somewhere".  Instead of
"usually the thing is called 'origin', so let's make sure it does
not exist", we may want to say "there is only one remote and it is
called somewhere because that is how we named it", i.e.

	git -C clone-bare config --name-only \
		--get-regexp "remote\..*\.url" >actual &&
	echo remote.somewhere.url >expect &&
	test_cmp actual expect

But stepping back a bit, I think this shows another reason why use
of '--origin' with '--bare' as-is may not be so pleasant to use.

In a repository _with_ working tree, this lack of "what is 'origin'
called in this repository?" is not a problem because you'd get these
after cloning:

    [remote "somewhere"]
	url = ...
	fetch = ...
    [branch "master"]
	remote = "somewhere"
	merge = refs/heads/master

You can say "git fetch" or "git pull" without the remote name and we
will know which remote to interact with, because our branch knows
which remote to fetch from.

In a bare repository, however, you only get this:

    [remote "somewhere"]
	url = ...

I do not think "git fetch" in such a repository knows that it needs
to fetch from 'somewhere', even whe it is the only remote repository
available to us.

We may need a bit _more_ work (e.g. leave an optional configuration
remote.originName = "somewhere" when "--bare --origin somewhere" is
used, and teach "git fetch" to pay attention to it, instead of
assuming 'origin') before "--bare --origin somewhere" becomes truly
usable.  And I suspect that "git fetch" is not the only one that
needs such "fix".

  reply	other threads:[~2021-08-03 21:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-01  8:25 [PATCH] clone: Remove constraint on --bare and --origin Øystein Walle
2021-08-02  2:18 ` Junio C Hamano
2021-08-02  8:53 ` Ævar Arnfjörð Bjarmason
2021-08-02 17:49   ` [PATCH v2] clone: Allow combining " Øystein Walle
2021-08-03 21:28     ` Junio C Hamano [this message]
2021-08-04 13:30       ` Øystein Walle
2021-08-04 17:06         ` Junio C Hamano
2021-08-06 20:23           ` Roman Neuhauser
2021-08-06 22:13             ` Junio C Hamano
2021-08-07 11:18               ` Roman Neuhauser
2021-08-07 22:08           ` Re* " Junio C Hamano
2021-08-08  2:03             ` Roman Neuhauser
2021-08-04  1:16     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqv94mtdyj.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=oystwa@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).