git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Roman Neuhauser <rn+git@sigpipe.cz>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Øystein Walle" <oystwa@gmail.com>, git@vger.kernel.org
Subject: Re: Re* [PATCH v2] clone: Allow combining --bare and --origin
Date: Sun, 8 Aug 2021 04:03:36 +0200	[thread overview]
Message-ID: <YQ87eMDaZmeUTmyN@isis.sigpipe.cz> (raw)
In-Reply-To: <xmqq4kc0j4cd.fsf_-_@gitster.g>

# gitster@pobox.com / 2021-08-07 15:08:02 -0700:
> Subject: [PATCH] remote: fall back on the sole remote when unspecified
> 
> Historically, we used hardcoded "origin" as the fallback default for
> commands that take a remote (e.g. "git fetch") when the user did not
> tell us otherwise.  Since the "--origin=name" option was taught to
> "git clone", however, we may not have a remote whose name is
> "origin" at all.
> 
> Which means that the name given to "git clone --origin" does not
> truly replace the hardcoded "origin". An example of such limitation
> is that "git fetch" (no other parameters) would fetch happily from
> the "origin" repository, but in a repository cloned with the custom
> name using "--origin=name", "git fetch" would not fetch from anywhere
> and instead fail.

hey, i'm all for all this pre-existing lossage getting fixed if you
can do it.  all i'm saying is that since this combination of options
wasn't possible before there won't be any pre-existing uses of git
suddenly breaking.

> This matters for automation for those who want to use --origin
> option.  Imagine you have multiple bare clones and you wanted to use
> custom names for 'origin'.  And you want a cron job that goes over
> these repositories and run "git fetch" from their upstream before
> you come in for work, so that these bare clones can be used as
> close-by mirrors of their upstream projects.

imagine that you wanted to use git clone --bare --origin with
any git version released so far.  this is not snark, i'm pointing
out that git git has a history of things not working where one
would expect them to.
 
> Unfortunately, that would not work.  If these repositories use
> their own nicknames for their upstream that are not "origin",
> 
> 	for repo in a b c
> 	do
> 		git -C $repo fetch
> 	done

  for repo in a b c; do
    git -C $repo fetch --all # or git -C remote update
  done

all it takes to mitigate this is to point this out in the release
notes and man page.  what you sketched out above is analogous to my
initial encounter with git clone --bare --origin not working:
where were you when the half-assed implementation was landing?  :)
why was there no one to champion for people who'd want to use those
two together? :)) (j/k)
 
> would just fail.  Of course, you can somehow out-of-band know the
> origin's name for each repo, e.g.

even if i accept the premise that git fetch --all can't be used
and the explicit name is necessary, isn't that magical out-of-band
wand called git-config?

  origin=$(
    git config --file $repo \
    --name-only --get-regexp \
    '^remote\.[^.]*.url' |
    sed -E 's/^remote\.([^.]+).url$/\1/'
  )
  git -C $repo fetch $origin
 
i'm not skilled enough in git-config to simplify that.


i think it'd be prudent to pause this thread for now because it's
only distracting you from fixing the --origin fallout, and as long
as you talk about how it *should* be while i bring up available
workarounds, it's just noise.

> but that is solving a problem that arises only because we are not
> treating the name given to "git clone --origin=name" as a true
> replacement for the default "origin".

and i'm really grateful that you're tying the loose ends, as long
as this whole thing doesn't fizzle out on account of being too much,
and the partial improvement doesn't get swept with it!
 
i think i said in earlier that i'm a big fan of stripping "origin"
of its special standing.  huge kudos if you can see this through.

-- 
roman

  reply	other threads:[~2021-08-08  2:03 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
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 [this message]
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=YQ87eMDaZmeUTmyN@isis.sigpipe.cz \
    --to=rn+git@sigpipe.cz \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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).