http-fetch.con commit xdiff: PATIENCE/HISTOGRAM are not independent option bits (307ab20)
   1#include "cache.h"
   2#include "exec_cmd.h"
   3#include "http.h"
   4#include "walker.h"
   5
   6static const char http_fetch_usage[] = "git http-fetch "
   7"[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url";
   8
   9int main(int argc, const char **argv)
  10{
  11        struct walker *walker;
  12        int commits_on_stdin = 0;
  13        int commits;
  14        const char **write_ref = NULL;
  15        char **commit_id;
  16        char *url = NULL;
  17        int arg = 1;
  18        int rc = 0;
  19        int get_tree = 0;
  20        int get_history = 0;
  21        int get_all = 0;
  22        int get_verbosely = 0;
  23        int get_recover = 0;
  24
  25        git_extract_argv0_path(argv[0]);
  26
  27        while (arg < argc && argv[arg][0] == '-') {
  28                if (argv[arg][1] == 't') {
  29                        get_tree = 1;
  30                } else if (argv[arg][1] == 'c') {
  31                        get_history = 1;
  32                } else if (argv[arg][1] == 'a') {
  33                        get_all = 1;
  34                        get_tree = 1;
  35                        get_history = 1;
  36                } else if (argv[arg][1] == 'v') {
  37                        get_verbosely = 1;
  38                } else if (argv[arg][1] == 'w') {
  39                        write_ref = &argv[arg + 1];
  40                        arg++;
  41                } else if (argv[arg][1] == 'h') {
  42                        usage(http_fetch_usage);
  43                } else if (!strcmp(argv[arg], "--recover")) {
  44                        get_recover = 1;
  45                } else if (!strcmp(argv[arg], "--stdin")) {
  46                        commits_on_stdin = 1;
  47                }
  48                arg++;
  49        }
  50        if (argc != arg + 2 - commits_on_stdin)
  51                usage(http_fetch_usage);
  52        if (commits_on_stdin) {
  53                commits = walker_targets_stdin(&commit_id, &write_ref);
  54        } else {
  55                commit_id = (char **) &argv[arg++];
  56                commits = 1;
  57        }
  58
  59        if (get_all == 0)
  60                warning("http-fetch: use without -a is deprecated.\n"
  61                        "In a future release, -a will become the default.");
  62
  63        if (argv[arg])
  64                str_end_url_with_slash(argv[arg], &url);
  65
  66        setup_git_directory();
  67
  68        git_config(git_default_config, NULL);
  69
  70        http_init(NULL, url);
  71        walker = get_http_walker(url);
  72        walker->get_tree = get_tree;
  73        walker->get_history = get_history;
  74        walker->get_all = get_all;
  75        walker->get_verbosely = get_verbosely;
  76        walker->get_recover = get_recover;
  77
  78        rc = walker_fetch(walker, commits, commit_id, write_ref, url);
  79
  80        if (commits_on_stdin)
  81                walker_targets_free(commits, commit_id, write_ref);
  82
  83        if (walker->corrupt_object_found) {
  84                fprintf(stderr,
  85"Some loose object were found to be corrupt, but they might be just\n"
  86"a false '404 Not Found' error message sent with incorrect HTTP\n"
  87"status code.  Suggest running 'git fsck'.\n");
  88        }
  89
  90        walker_free(walker);
  91        http_cleanup();
  92
  93        free(url);
  94
  95        return rc;
  96}