static void execute_commands(const char *unpacker_error) { struct command *cmd = commands; unsigned char sha1[20]; if (unpacker_error) { while (cmd) { cmd->error_string = "n/a (unpacker error)"; cmd = cmd->next; } return; } if (run_receive_hook(pre_receive_hook)) { while (cmd) { cmd->error_string = "pre-receive hook declined"; cmd = cmd->next; } return; } head_name = resolve_ref("HEAD", sha1, 0, NULL); while (cmd) { cmd->error_string = update(cmd); cmd = cmd->next; } }
static void execute_commands(struct command *commands, const char *unpacker_error, struct shallow_info *si, const struct string_list *push_options) { struct check_connected_options opt = CHECK_CONNECTED_INIT; struct command *cmd; unsigned char sha1[20]; struct iterate_data data; struct async muxer; int err_fd = 0; if (unpacker_error) { for (cmd = commands; cmd; cmd = cmd->next) cmd->error_string = "unpacker error"; return; } if (use_sideband) { memset(&muxer, 0, sizeof(muxer)); muxer.proc = copy_to_sideband; muxer.in = -1; if (!start_async(&muxer)) err_fd = muxer.in; /* ...else, continue without relaying sideband */ } data.cmds = commands; data.si = si; opt.err_fd = err_fd; opt.progress = err_fd && !quiet; if (check_connected(iterate_receive_command_list, &data, &opt)) set_connectivity_errors(commands, si); if (use_sideband) finish_async(&muxer); reject_updates_to_hidden(commands); if (run_receive_hook(commands, "pre-receive", 0, push_options)) { for (cmd = commands; cmd; cmd = cmd->next) { if (!cmd->error_string) cmd->error_string = "pre-receive hook declined"; } return; } check_aliased_updates(commands); free(head_name_to_free); head_name = head_name_to_free = resolve_refdup("HEAD", 0, sha1, NULL); if (use_atomic) execute_commands_atomic(commands, si); else execute_commands_non_atomic(commands, si); if (shallow_update) warn_if_skipped_connectivity_check(commands, si); }
static void execute_commands(struct command *commands, const char *unpacker_error) { struct command *cmd; unsigned char sha1[20]; if (unpacker_error) { for (cmd = commands; cmd; cmd = cmd->next) cmd->error_string = "n/a (unpacker error)"; return; } cmd = commands; if (check_everything_connected(iterate_receive_command_list, 0, &cmd)) set_connectivity_errors(commands); if (run_receive_hook(commands, pre_receive_hook, 0)) { for (cmd = commands; cmd; cmd = cmd->next) cmd->error_string = "pre-receive hook declined"; return; } check_aliased_updates(commands); free(head_name_to_free); head_name = head_name_to_free = resolve_refdup("HEAD", sha1, 0, NULL); for (cmd = commands; cmd; cmd = cmd->next) if (!cmd->skip_update) cmd->error_string = update(cmd); }
static void execute_commands(const char *unpacker_error) { struct command *cmd = commands; if (unpacker_error) { while (cmd) { cmd->error_string = "n/a (unpacker error)"; cmd = cmd->next; } return; } if (run_receive_hook(pre_receive_hook)) { while (cmd) { cmd->error_string = "pre-receive hook declined"; cmd = cmd->next; } return; } while (cmd) { cmd->error_string = update(cmd); cmd = cmd->next; } }
int cmd_receive_pack(int argc, const char **argv, const char *prefix) { int i; char *dir = NULL; argv++; for (i = 1; i < argc; i++) { const char *arg = *argv++; if (*arg == '-') { /* Do flag handling here */ usage(receive_pack_usage); } if (dir) usage(receive_pack_usage); dir = xstrdup(arg); } if (!dir) usage(receive_pack_usage); setup_path(); if (!enter_repo(dir, 0)) die("'%s': unable to chdir or not a git archive", dir); if (is_repository_shallow()) die("attempt to push into a shallow repository"); git_config(receive_pack_config, NULL); if (0 <= transfer_unpack_limit) unpack_limit = transfer_unpack_limit; else if (0 <= receive_unpack_limit) unpack_limit = receive_unpack_limit; add_alternate_refs(); write_head_info(); clear_extra_refs(); /* EOF */ packet_flush(1); read_head_info(); if (commands) { const char *unpack_status = NULL; if (!delete_only(commands)) unpack_status = unpack(); execute_commands(unpack_status); if (pack_lockfile) unlink(pack_lockfile); if (report_status) report(unpack_status); run_receive_hook(post_receive_hook); run_update_post_hook(commands); } return 0; }
static void execute_commands(struct command *commands, const char *unpacker_error, struct shallow_info *si) { int checked_connectivity; struct command *cmd; unsigned char sha1[20]; struct iterate_data data; if (unpacker_error) { for (cmd = commands; cmd; cmd = cmd->next) cmd->error_string = "unpacker error"; return; } data.cmds = commands; data.si = si; if (check_everything_connected(iterate_receive_command_list, 0, &data)) set_connectivity_errors(commands, si); reject_updates_to_hidden(commands); if (run_receive_hook(commands, "pre-receive", 0)) { for (cmd = commands; cmd; cmd = cmd->next) { if (!cmd->error_string) cmd->error_string = "pre-receive hook declined"; } return; } check_aliased_updates(commands); free(head_name_to_free); head_name = head_name_to_free = resolve_refdup("HEAD", 0, sha1, NULL); checked_connectivity = 1; for (cmd = commands; cmd; cmd = cmd->next) { if (cmd->error_string) continue; if (cmd->skip_update) continue; cmd->error_string = update(cmd, si); if (shallow_update && !cmd->error_string && si->shallow_ref[cmd->index]) { error("BUG: connectivity check has not been run on ref %s", cmd->ref_name); checked_connectivity = 0; } } if (shallow_update && !checked_connectivity) error("BUG: run 'git fsck' for safety.\n" "If there are errors, try to remove " "the reported refs above"); }
static void execute_commands(struct command *commands, const char *unpacker_error, struct shallow_info *si) { struct command *cmd; unsigned char sha1[20]; struct iterate_data data; if (unpacker_error) { for (cmd = commands; cmd; cmd = cmd->next) cmd->error_string = "unpacker error"; return; } data.cmds = commands; data.si = si; if (check_everything_connected(iterate_receive_command_list, 0, &data)) set_connectivity_errors(commands, si); reject_updates_to_hidden(commands); if (run_receive_hook(commands, "pre-receive", 0)) { for (cmd = commands; cmd; cmd = cmd->next) { if (!cmd->error_string) cmd->error_string = "pre-receive hook declined"; } return; } check_aliased_updates(commands); free(head_name_to_free); head_name = head_name_to_free = resolve_refdup("HEAD", 0, sha1, NULL); if (use_atomic) execute_commands_atomic(commands, si); else execute_commands_non_atomic(commands, si); if (shallow_update) warn_if_skipped_connectivity_check(commands, si); }
int cmd_receive_pack(int argc, const char **argv, const char *prefix) { int advertise_refs = 0; int stateless_rpc = 0; int i; char *dir = NULL; struct command *commands; packet_trace_identity("receive-pack"); argv++; for (i = 1; i < argc; i++) { const char *arg = *argv++; if (*arg == '-') { if (!strcmp(arg, "--advertise-refs")) { advertise_refs = 1; continue; } if (!strcmp(arg, "--stateless-rpc")) { stateless_rpc = 1; continue; } usage(receive_pack_usage); } if (dir) usage(receive_pack_usage); dir = xstrdup(arg); } if (!dir) usage(receive_pack_usage); setup_path(); if (!enter_repo(dir, 0)) die("'%s' does not appear to be a git repository", dir); if (is_repository_shallow()) die("attempt to push into a shallow repository"); git_config(receive_pack_config, NULL); if (0 <= transfer_unpack_limit) unpack_limit = transfer_unpack_limit; else if (0 <= receive_unpack_limit) unpack_limit = receive_unpack_limit; if (advertise_refs || !stateless_rpc) { write_head_info(); } if (advertise_refs) return 0; if ((commands = read_head_info()) != NULL) { const char *unpack_status = NULL; if (!delete_only(commands)) unpack_status = unpack(); execute_commands(commands, unpack_status); if (pack_lockfile) unlink_or_warn(pack_lockfile); if (report_status) report(commands, unpack_status); run_receive_hook(commands, post_receive_hook, 1); run_update_post_hook(commands); if (auto_gc) { const char *argv_gc_auto[] = { "gc", "--auto", "--quiet", NULL, }; run_command_v_opt(argv_gc_auto, RUN_GIT_CMD); } if (auto_update_server_info) update_server_info(0); } if (use_sideband) packet_flush(1); return 0; }
int cmd_receive_pack(int argc, const char **argv, const char *prefix) { int advertise_refs = 0; struct command *commands; struct sha1_array shallow = SHA1_ARRAY_INIT; struct sha1_array ref = SHA1_ARRAY_INIT; struct shallow_info si; struct option options[] = { OPT__QUIET(&quiet, N_("quiet")), OPT_HIDDEN_BOOL(0, "stateless-rpc", &stateless_rpc, NULL), OPT_HIDDEN_BOOL(0, "advertise-refs", &advertise_refs, NULL), OPT_HIDDEN_BOOL(0, "reject-thin-pack-for-testing", &reject_thin, NULL), OPT_END() }; packet_trace_identity("receive-pack"); argc = parse_options(argc, argv, prefix, options, receive_pack_usage, 0); if (argc > 1) usage_msg_opt(_("Too many arguments."), receive_pack_usage, options); if (argc == 0) usage_msg_opt(_("You must specify a directory."), receive_pack_usage, options); service_dir = argv[0]; setup_path(); if (!enter_repo(service_dir, 0)) die("'%s' does not appear to be a git repository", service_dir); git_config(receive_pack_config, NULL); if (cert_nonce_seed) push_cert_nonce = prepare_push_cert_nonce(service_dir, time(NULL)); if (0 <= transfer_unpack_limit) unpack_limit = transfer_unpack_limit; else if (0 <= receive_unpack_limit) unpack_limit = receive_unpack_limit; if (advertise_refs || !stateless_rpc) { write_head_info(); } if (advertise_refs) return 0; if ((commands = read_head_info(&shallow)) != NULL) { const char *unpack_status = NULL; struct string_list push_options = STRING_LIST_INIT_DUP; if (use_push_options) read_push_options(&push_options); prepare_shallow_info(&si, &shallow); if (!si.nr_ours && !si.nr_theirs) shallow_update = 0; if (!delete_only(commands)) { unpack_status = unpack_with_sideband(&si); update_shallow_info(commands, &si, &ref); } use_keepalive = KEEPALIVE_ALWAYS; execute_commands(commands, unpack_status, &si, &push_options); if (pack_lockfile) unlink_or_warn(pack_lockfile); if (report_status) report(commands, unpack_status); run_receive_hook(commands, "post-receive", 1, &push_options); run_update_post_hook(commands); if (push_options.nr) string_list_clear(&push_options, 0); if (auto_gc) { const char *argv_gc_auto[] = { "gc", "--auto", "--quiet", NULL, }; struct child_process proc = CHILD_PROCESS_INIT; proc.no_stdin = 1; proc.stdout_to_stderr = 1; proc.err = use_sideband ? -1 : 0; proc.git_cmd = 1; proc.argv = argv_gc_auto; close_all_packs(); if (!start_command(&proc)) { if (use_sideband) copy_to_sideband(proc.err, -1, NULL); finish_command(&proc); } } if (auto_update_server_info) update_server_info(0); clear_shallow_info(&si); } if (use_sideband) packet_flush(1); sha1_array_clear(&shallow); sha1_array_clear(&ref); free((void *)push_cert_nonce); return 0; }
int cmd_receive_pack(int argc, const char **argv, const char *prefix) { int advertise_refs = 0; int i; struct command *commands; struct sha1_array shallow = SHA1_ARRAY_INIT; struct sha1_array ref = SHA1_ARRAY_INIT; struct shallow_info si; packet_trace_identity("receive-pack"); argv++; for (i = 1; i < argc; i++) { const char *arg = *argv++; if (*arg == '-') { if (!strcmp(arg, "--quiet")) { quiet = 1; continue; } if (!strcmp(arg, "--advertise-refs")) { advertise_refs = 1; continue; } if (!strcmp(arg, "--stateless-rpc")) { stateless_rpc = 1; continue; } if (!strcmp(arg, "--reject-thin-pack-for-testing")) { fix_thin = 0; continue; } usage(receive_pack_usage); } if (service_dir) usage(receive_pack_usage); service_dir = arg; } if (!service_dir) usage(receive_pack_usage); setup_path(); if (!enter_repo(service_dir, 0)) die("'%s' does not appear to be a git repository", service_dir); git_config(receive_pack_config, NULL); if (cert_nonce_seed) push_cert_nonce = prepare_push_cert_nonce(service_dir, time(NULL)); if (0 <= transfer_unpack_limit) unpack_limit = transfer_unpack_limit; else if (0 <= receive_unpack_limit) unpack_limit = receive_unpack_limit; if (advertise_refs || !stateless_rpc) { write_head_info(); } if (advertise_refs) return 0; if ((commands = read_head_info(&shallow)) != NULL) { const char *unpack_status = NULL; prepare_shallow_info(&si, &shallow); if (!si.nr_ours && !si.nr_theirs) shallow_update = 0; if (!delete_only(commands)) { unpack_status = unpack_with_sideband(&si); update_shallow_info(commands, &si, &ref); } execute_commands(commands, unpack_status, &si); if (pack_lockfile) unlink_or_warn(pack_lockfile); if (report_status) report(commands, unpack_status); run_receive_hook(commands, "post-receive", 1); run_update_post_hook(commands); if (auto_gc) { const char *argv_gc_auto[] = { "gc", "--auto", "--quiet", NULL, }; int opt = RUN_GIT_CMD | RUN_COMMAND_STDOUT_TO_STDERR; run_command_v_opt(argv_gc_auto, opt); } if (auto_update_server_info) update_server_info(0); clear_shallow_info(&si); } if (use_sideband) packet_flush(1); sha1_array_clear(&shallow); sha1_array_clear(&ref); free((void *)push_cert_nonce); return 0; }