From: Stefan Sperling Subject: Re: git config: url insteadOf To: Evan Silberman Cc: gameoftrees@openbsd.org Date: Thu, 10 Mar 2022 10:21:29 +0100 On Wed, Mar 09, 2022 at 12:16:08PM -0800, Evan Silberman wrote: > Hi there, > > I use the git config option url..insteadOf to be able to do things > like "git clone gh:repo" instead of "git clone git@github.com:org/repo". > The remotes are then spelled thusly in the .git/config file's remote > section, i.e. url = gh:repo. A "got fetch" in the Git checkout or a Got > worktree then fails with "Could not resolve hostname gh" because Got > doesn't know about insteadOf. > > I haven't spent the required time in the code to be able to propose a > patch, and the privsep architecture makes it feel a little bit daunting, > beyond having to rely on entirely pattern-matching-based level of C > knowledge. Supporting insteadOf anywhere a URL is accepted in Got's UI > might be too much even if supporting it when parsing remotes is added. > Got currently appears to support a very limited subset of git config, > and this is a somewhat random knob to ask for support for. So for now > consider this just a friendly mention of a case where Got doesn't work > right with an otherwise-ordinary Git repository. Yes, we support a subset of Git's configuration in a read-only fashion. I don't have a problem with expanding support for this, as long as use of Git's config file remains optional. Our parser is limited indeed. It was derived from isakmpd which also uses .ini style syntax. The parser returns URLs to the main process, which means it could construct URLs internally in whatever way it pleases. A useful alternative might be to add similar functionality to got.conf. To provide shorthands for remote URLs inside the config file we could allow use of macros, such as below. Tweaking parse.y should be sufficient to implement this. codeberg_url = ssh://git@codeberg.org remote "codeberg" { server $codeberg_url protocol ssh repository "/stsp/got.git" } To make short names for repositories available to 'got clone' we may need to introduce a global configuration file in the user's home directory. This does not currently exist. Each got.conf file is currently tied to a particular repository. If this gets changed we need to be careful and avoid situations where people would accidentally fetch data from repositories that are unrelated to the repository they are working with.