builtin-http-fetch.con commit contrib/hooks/post-receive-email: fix typo (b5786c8)
   1#include "cache.h"
   2#include "walker.h"
   3
   4int cmd_http_fetch(int argc, const char **argv, const char *prefix)
   5{
   6        struct walker *walker;
   7        int commits_on_stdin = 0;
   8        int commits;
   9        const char **write_ref = NULL;
  10        char **commit_id;
  11        const char *url;
  12        int arg = 1;
  13        int rc = 0;
  14        int get_tree = 0;
  15        int get_history = 0;
  16        int get_all = 0;
  17        int get_verbosely = 0;
  18        int get_recover = 0;
  19
  20        git_config(git_default_config);
  21
  22        while (arg < argc && argv[arg][0] == '-') {
  23                if (argv[arg][1] == 't') {
  24                        get_tree = 1;
  25                } else if (argv[arg][1] == 'c') {
  26                        get_history = 1;
  27                } else if (argv[arg][1] == 'a') {
  28                        get_all = 1;
  29                        get_tree = 1;
  30                        get_history = 1;
  31                } else if (argv[arg][1] == 'v') {
  32                        get_verbosely = 1;
  33                } else if (argv[arg][1] == 'w') {
  34                        write_ref = &argv[arg + 1];
  35                        arg++;
  36                } else if (!strcmp(argv[arg], "--recover")) {
  37                        get_recover = 1;
  38                } else if (!strcmp(argv[arg], "--stdin")) {
  39                        commits_on_stdin = 1;
  40                }
  41                arg++;
  42        }
  43        if (argc < arg + 2 - commits_on_stdin) {
  44                usage("git-http-fetch [-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url");
  45                return 1;
  46        }
  47        if (commits_on_stdin) {
  48                commits = walker_targets_stdin(&commit_id, &write_ref);
  49        } else {
  50                commit_id = (char **) &argv[arg++];
  51                commits = 1;
  52        }
  53        url = argv[arg];
  54
  55        walker = get_http_walker(url);
  56        walker->get_tree = get_tree;
  57        walker->get_history = get_history;
  58        walker->get_all = get_all;
  59        walker->get_verbosely = get_verbosely;
  60        walker->get_recover = get_recover;
  61
  62        rc = walker_fetch(walker, commits, commit_id, write_ref, url);
  63
  64        if (commits_on_stdin)
  65                walker_targets_free(commits, commit_id, write_ref);
  66
  67        if (walker->corrupt_object_found) {
  68                fprintf(stderr,
  69"Some loose object were found to be corrupt, but they might be just\n"
  70"a false '404 Not Found' error message sent with incorrect HTTP\n"
  71"status code.  Suggest running git-fsck.\n");
  72        }
  73
  74        walker_free(walker);
  75
  76        return rc;
  77}