Comments
-
Greg Hurrell
For both trees (this ticket) and blobs (ticket #1698) need to think about URL design.
While the objects in question are identified by their SHA-1 hashes, for human users it would be nice to display the actual path names in the URL somehow.
Likewise, it is useful to be able to link directly to specific blobs/trees as they appear in a particular branch or tag; eg:
-
/repos/command-t/blobs/023cc318952347fa689f082d44020ae4ba3949bc
(not very human-friendly)
versus:
-
/repos/command-t/branches/master/blobs/README.txt
or:
-
/repos/command-t/blobs/branches/master/README.txt
etc. This would be straightforward if it weren't for the fact that Git is extremely liberal about what characters it allows in branch names. That is, branch names like
foo/bar
are not only allowed but are actually quite common in some projects (like git.git itself), so we can't just separate the URL on forward slashes.GitHub does it like this (no idea if it blows up with branch names that contain slashes):
I'm kind of leaning towards using a colon as a separator here too, provided I can get confirmation somewhere that a colon is not a legal character in either a branch or tag name.
Note that it is probably not necessary to directly support displaying blob contents via their hash IDs, as humans interacting with the repo only ever access blobs by a combination of commit and path name.
This would give us URLs like the following for blobs:
-
/repos/command-t/blobs/master:README.txt
And the same idea for trees:
-
/repos/command-t/trees/master
(no path would just show the top-level tree) -
/repos/command-t/trees/master:ruby
(ruby
subdirectory)
Presumably we can get the contents of the blobs via a simple
git cat-file blob ref:path
, obviously after checking thatref
refers to a reachable commit.Should also have no problems handling SHA-1 hashes or ref names with slashes in them:
-
/repos/command-t/trees/195dedcca4726a5d61289e617447ccb415587f6a:ruby
/repos/command-t/trees/HEAD:ruby
-
/repos/command-t/trees/foo/bar/branch:ruby
-
-
Greg Hurrell
Found this on legal branch names. Not sure how it was derived yet, but going to make a Legal Git branch names page on the wiki in any case.
-
Greg Hurrell
Note that it is probably not necessary to directly support displaying blob contents via their hash IDs, as humans interacting with the repo only ever access blobs by a combination of commit and path name.
Not only that, but we don't want to provide arbitrary access to blobs that might only be referenced by unreachable commits. So, must only allow access via a commit-ish.
Add a comment
Comments are now closed for this issue.