Merge branch 'rs/maint-config-use-labs' into maint
[gitweb.git] / archive.c
index 5bdab7b1480f122397264c405f751c2f3547a6af..94a9981adf72c437f8660c66b67506b50ed8d3a9 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -18,6 +18,7 @@ static char const * const archive_usage[] = {
 static const struct archiver **archivers;
 static int nr_archivers;
 static int alloc_archivers;
+static int remote_allow_unreachable;
 
 void register_archiver(struct archiver *ar)
 {
@@ -348,10 +349,10 @@ static void parse_treeish_arg(const char **argv,
        unsigned char sha1[20];
 
        /* Remotes are only allowed to fetch actual refs */
-       if (remote) {
+       if (remote && !remote_allow_unreachable) {
                char *ref = NULL;
-               const char *colon = strchr(name, ':');
-               int refnamelen = colon ? colon - name : strlen(name);
+               const char *colon = strchrnul(name, ':');
+               int refnamelen = colon - name;
 
                if (!dwim_ref(name, refnamelen, sha1, &ref))
                        die("no such ref: %.*s", refnamelen, name);
@@ -502,7 +503,9 @@ int write_archive(int argc, const char **argv, const char *prefix,
        if (setup_prefix && prefix == NULL)
                prefix = setup_git_directory_gently(&nongit);
 
+       git_config_get_bool("uploadarchive.allowunreachable", &remote_allow_unreachable);
        git_config(git_default_config, NULL);
+
        init_tar_archiver();
        init_zip_archiver();