Tweak t3102-ls-tree-wildcards to run on Windows
[gitweb.git] / http-fetch.c
index ffd0ad7e295d7341776bb7b6407602cdb2997ef3..923904f97f9274d09a0a0b08543492f78a141f79 100644 (file)
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "exec_cmd.h"
+#include "http.h"
 #include "walker.h"
 
 static const char http_fetch_usage[] = "git http-fetch "
@@ -13,8 +14,7 @@ int main(int argc, const char **argv)
        int commits;
        const char **write_ref = NULL;
        char **commit_id;
-       const char *url;
-       char *rewritten_url = NULL;
+       char *url = NULL;
        int arg = 1;
        int rc = 0;
        int get_tree = 0;
@@ -56,20 +56,16 @@ int main(int argc, const char **argv)
                commit_id = (char **) &argv[arg++];
                commits = 1;
        }
-       url = argv[arg];
+
+       if (argv[arg])
+               str_end_url_with_slash(argv[arg], &url);
 
        prefix = setup_git_directory();
 
        git_config(git_default_config, NULL);
 
-       if (url && url[strlen(url)-1] != '/') {
-               rewritten_url = xmalloc(strlen(url)+2);
-               strcpy(rewritten_url, url);
-               strcat(rewritten_url, "/");
-               url = rewritten_url;
-       }
-
-       walker = get_http_walker(url, NULL);
+       http_init(NULL);
+       walker = get_http_walker(url);
        walker->get_tree = get_tree;
        walker->get_history = get_history;
        walker->get_all = get_all;
@@ -89,8 +85,9 @@ int main(int argc, const char **argv)
        }
 
        walker_free(walker);
+       http_cleanup();
 
-       free(rewritten_url);
+       free(url);
 
        return rc;
 }