blob: 8a58093e25a99a1842383f17e678f56ff6aa4ea7 [file] [log] [blame]
'\" t
.\" Title: gitnamespaces
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 11/18/2018
.\" Manual: Git Manual
.\" Source: Git 2.20.0.rc0
.\" Language: English
.\"
.TH "GITNAMESPACES" "7" "11/18/2018" "Git 2\&.20\&.0\&.rc0" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
gitnamespaces \- Git namespaces
.SH "SYNOPSIS"
.sp
.nf
GIT_NAMESPACE=<namespace> \fIgit upload\-pack\fR
GIT_NAMESPACE=<namespace> \fIgit receive\-pack\fR
.fi
.sp
.SH "DESCRIPTION"
.sp
Git supports dividing the refs of a single repository into multiple namespaces, each of which has its own branches, tags, and HEAD\&. Git can expose each namespace as an independent repository to pull from and push to, while sharing the object store, and exposing all the refs to operations such as \fBgit-gc\fR(1)\&.
.sp
Storing multiple repositories as namespaces of a single repository avoids storing duplicate copies of the same objects, such as when storing multiple branches of the same source\&. The alternates mechanism provides similar support for avoiding duplicates, but alternates do not prevent duplication between new objects added to the repositories without ongoing maintenance, while namespaces do\&.
.sp
To specify a namespace, set the \fBGIT_NAMESPACE\fR environment variable to the namespace\&. For each ref namespace, Git stores the corresponding refs in a directory under \fBrefs/namespaces/\fR\&. For example, \fBGIT_NAMESPACE=foo\fR will store refs under \fBrefs/namespaces/foo/\fR\&. You can also specify namespaces via the \fB\-\-namespace\fR option to \fBgit\fR(1)\&.
.sp
Note that namespaces which include a \fB/\fR will expand to a hierarchy of namespaces; for example, \fBGIT_NAMESPACE=foo/bar\fR will store refs under \fBrefs/namespaces/foo/refs/namespaces/bar/\fR\&. This makes paths in \fBGIT_NAMESPACE\fR behave hierarchically, so that cloning with \fBGIT_NAMESPACE=foo/bar\fR produces the same result as cloning with \fBGIT_NAMESPACE=foo\fR and cloning from that repo with \fBGIT_NAMESPACE=bar\fR\&. It also avoids ambiguity with strange namespace paths such as \fBfoo/refs/heads/\fR, which could otherwise generate directory/file conflicts within the \fBrefs\fR directory\&.
.sp
\fBgit-upload-pack\fR(1) and \fBgit-receive-pack\fR(1) rewrite the names of refs as specified by \fBGIT_NAMESPACE\fR\&. git\-upload\-pack and git\-receive\-pack will ignore all references outside the specified namespace\&.
.sp
The smart HTTP server, \fBgit-http-backend\fR(1), will pass GIT_NAMESPACE through to the backend programs; see \fBgit-http-backend\fR(1) for sample configuration to expose repository namespaces as repositories\&.
.sp
For a simple local test, you can use \fBgit-remote-ext\fR(1):
.sp
.if n \{\
.RS 4
.\}
.nf
git clone ext::\(aqgit \-\-namespace=foo %s /tmp/prefixed\&.git\(aq
.fi
.if n \{\
.RE
.\}
.sp
.SH "SECURITY"
.sp
The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared\&. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository\&. This applies to both clients and servers\&. In particular, namespaces on a server are not effective for read access control; you should only grant read access to a namespace to clients that you would trust with read access to the entire repository\&.
.sp
The known attack vectors are as follows:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 1." 4.2
.\}
The victim sends "have" lines advertising the IDs of objects it has that are not explicitly intended to be shared but can be used to optimize the transfer if the peer also has them\&. The attacker chooses an object ID X to steal and sends a ref to X, but isn\(cqt required to send the content of X because the victim already has it\&. Now the victim believes that the attacker has X, and it sends the content of X back to the attacker later\&. (This attack is most straightforward for a client to perform on a server, by creating a ref to X in the namespace the client has access to and then fetching it\&. The most likely way for a server to perform it on a client is to "merge" X into a public branch and hope that the user does additional work on this branch and pushes it back to the server without noticing the merge\&.)
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 2." 4.2
.\}
As in #1, the attacker chooses an object ID X to steal\&. The victim sends an object Y that the attacker already has, and the attacker falsely claims to have X and not Y, so the victim sends Y as a delta against X\&. The delta reveals regions of X that are similar to Y to the attacker\&.
.RE