Springe zum Hauptinhalt

In need for an enhanced git URL scheme

Which al­lows spe­cify­ing heads/­bran­ches and paths wi­thin the re­po­si­to­ry.

I'm current­ly tes­ting pro­jec­t­-­buil­der, to tool for ea­si­ly buil­ding soft­ware for dif­fe­rent Li­nux dis­tri­bu­ti­ons. One of the fea­tu­res of this tool is to check out the con­fi­gu­ra­ti­on from a sour­ce code ma­nage­ment sys­tem. Well, with git this be­co­mes qui­te a pro­blem, as one can not spe­cify the branch nor a path wi­thin the re­po when clo­ning.

So I'm pro­po­sing an ex­ten­ded git URL sche­ma:

Ex­am­ple:

git://<host>/path/to/git/repo?h=devel&p=src/Makefile

Which means:

  • The re­­po­­si­to­ry itself is pas­­sed as URL as usu­al

  • The head (a­­ka bran­ch) is pas­­sed as que­ry pa­ra­­me­ter "h"

  • The file or di­rec­to­ry is pas­­sed as que­ry pa­ra­­me­ter "p"

Reasoning

For clo­ning the re­po­si­to­ry, git needs to know the re­po­si­to­ry UR­L. When pas­sing a URL li­ke cgit uses, git can not de­ci­de which part of the path be­longs to the re­po and which part is be­low. Git would need to walk the UR­L­-­path up un­til it is ab­le to find ac­cess a va­lid re­po­si­to­ry. This be­ha­viour is not de­si­red as it may ha­ve un­ex­pec­ted si­de­-­ef­fects, es­p. when ac­ces­sing a a htt­p-­ba­sed re­po­si­to­ry.

This means: The par­t­-­part of the URL must on­ly con­tain the path to the re­po­si­to­ry!

So ob­vious­ly the­re is a need for spe­cify­ing the hea­d/­branch to ac­cess. This is gi­ven as a que­ry pa­ra­me­ter. I de­ci­ded to use "h" li­ke "hea­d" li­ke cgit does.

If one wants to spe­cify a cer­tain file or di­rec­to­ry wi­thin the re­po­si­to­ry, this is as a que­ry pa­ra­me­ter, too. I de­ci­ded to use "p" li­ke "pa­th".

FAQ

Why not using the notation /BRANCH/path?

See above: When cloning, git would need to walk the URL-path up until it is able to access a valid repository. This behaviour is not desired as it may have unexpected side-effects, esp. when accessing a a http-based repository. Additionally git does not support this when cloning local repositories. (Try something like git clone /path/to/repo/master/Makefile.) So this would implement an asymmetry.

Why not using the notation /path@BRANCH?

This would inhibit using an @-sign in any path. Plus it does not solve the problem described in the /BRANCH/path-case.

Why not using the notation /tree/BRANCH/path?

Sa­me pro­blem her­e: git could de­ci­de which part of the path be­longs to the re­po.

Portrait von Hartmut Goebel

Hartmut Goebel

Diplom-Informatiker, CISSP, CSSLP, ISO 27001 Lead Implementer

Haben Sie noch Fragen?
Anruf oder Mail genügt:
  +49 871 6606-318
  +49 175 29 78 072
  h.goebel@goebel-consult.de