diff options
Diffstat (limited to 'archive.c')
-rw-r--r-- | archive.c | 23 |
1 files changed, 21 insertions, 2 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,6 +257,24 @@ static void parse_treeish_arg(const char **argv, const struct commit *commit; unsigned char sha1[20]; + /* Remotes are only allowed to fetch actual refs */ + if (remote) { + char *ref = NULL; + const char *refname, *colon = NULL; + + colon = strchr(name, ':'); + if (colon) + refname = xstrndup(name, colon - name); + else + refname = name; + + if (!dwim_ref(refname, strlen(refname), sha1, &ref)) + die("no such ref: %s", refname); + if (refname != name) + free((void *)refname); + free(ref); + } + if (get_sha1(name, sha1)) die("Not a valid object name"); @@ -414,7 +433,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); |