Skip to content

Commit 69897bc

Browse files
peffgitster
authored andcommitted
docs: clarify remote restrictions for git-upload-archive
Commits ee27ca4 and 0f544ee introduced rules by which git-upload-archive would restrict clients from accessing unreachable objects. However, we never documented those rules anywhere, nor their reason for being. Let's do so now. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f95c9f commit 69897bc

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Documentation/git-archive.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ OPTIONS
6565

6666
--remote=<repo>::
6767
Instead of making a tar archive from the local repository,
68-
retrieve a tar archive from a remote repository.
68+
retrieve a tar archive from a remote repository. Note that the
69+
remote repository may place restrictions on which sha1
70+
expressions may be allowed in `<tree-ish>`. See
71+
linkgit:git-upload-archive[1] for details.
6972

7073
--exec=<git-upload-archive>::
7174
Used with --remote to specify the path to the

Documentation/git-upload-archive.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,32 @@ This command is usually not invoked directly by the end user. The UI
2020
for the protocol is on the 'git archive' side, and the program pair
2121
is meant to be used to get an archive from a remote repository.
2222

23+
SECURITY
24+
--------
25+
26+
In order to protect the privacy of objects that have been removed from
27+
history but may not yet have been pruned, `git-upload-archive` avoids
28+
serving archives for commits and trees that are not reachable from the
29+
repository's refs. However, because calculating object reachability is
30+
computationally expensive, `git-upload-archive` implements a stricter
31+
but easier-to-check set of rules:
32+
33+
1. Clients may request a commit or tree that is pointed to directly by
34+
a ref. E.g., `git archive --remote=origin v1.0`.
35+
36+
2. Clients may request a sub-tree within a commit or tree using the
37+
`ref:path` syntax. E.g., `git archive --remote=origin v1.0:Documentation`.
38+
39+
3. Clients may _not_ use other sha1 expressions, even if the end
40+
result is reachable. E.g., neither a relative commit like `master^`
41+
nor a literal sha1 like `abcd1234` is allowed, even if the result
42+
is reachable from the refs.
43+
44+
Note that rule 3 disallows many cases that do not have any privacy
45+
implications. These rules are subject to change in future versions of
46+
git, and the server accessed by `git archive --remote` may or may not
47+
follow these exact rules.
48+
2349
OPTIONS
2450
-------
2551
<directory>::

0 commit comments

Comments
 (0)