THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.9KB

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