diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-12-21 23:42:44 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-21 23:42:44 +0400 |
commit | 1a7bd4fcfa0c57617828dfc1b6b525af674f6d49 (patch) | |
tree | 25c1079078e4d4626799de524537de40ea98e7d7 /archive.c | |
parent | a31275d6ffd35bc1c269b7136f4031abe2abee70 (diff) | |
parent | 7b51c33b376d22195dba1c4e067180164fd35dbf (diff) |
Merge branch 'jk/maint-upload-archive' into maint
* jk/maint-upload-archive:
archive: don't let remote clients get unreachable commits
Diffstat (limited to 'archive.c')
-rw-r--r-- | archive.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -247,7 +247,8 @@ static void parse_pathspec_arg(const char **pathspec, } static void parse_treeish_arg(const char **argv, - struct archiver_args *ar_args, const char *prefix) + struct archiver_args *ar_args, const char *prefix, + int remote) { const char *name = argv[0]; const unsigned char *commit_sha1; @@ -256,8 +257,17 @@ static void parse_treeish_arg(const char **argv, const struct commit *commit; unsigned char sha1[20]; - if (get_sha1(name, sha1)) - die("Not a valid object name"); + /* Remotes are only allowed to fetch actual refs */ + if (remote) { + char *ref = NULL; + if (!dwim_ref(name, strlen(name), sha1, &ref)) + die("no such ref: %s", name); + free(ref); + } + else { + if (get_sha1(name, sha1)) + die("Not a valid object name"); + } commit = lookup_commit_reference_gently(sha1, 1); if (commit) { @@ -414,7 +424,7 @@ int write_archive(int argc, const char **argv, const char *prefix, setup_git_directory(); } - parse_treeish_arg(argv, &args, prefix); + parse_treeish_arg(argv, &args, prefix, remote); parse_pathspec_arg(argv + 1, &args); return ar->write_archive(ar, &args); |