예제 #1
0
static void update_remote_refs(const struct ref *refs,
			       const struct ref *mapped_refs,
			       const struct ref *remote_head_points_at,
			       const char *branch_top,
			       const char *msg)
{
	const struct ref *rm = mapped_refs;

	if (0 <= option_verbosity)
		printf(_("Checking connectivity... "));
	if (check_everything_connected(iterate_ref_map, 0, &rm))
		die(_("remote did not send all necessary objects"));
	if (0 <= option_verbosity)
		printf(_("done\n"));

	if (refs) {
		write_remote_refs(mapped_refs);
		if (option_single_branch)
			write_followtags(refs, msg);
	}

	if (remote_head_points_at && !option_bare) {
		struct strbuf head_ref = STRBUF_INIT;
		strbuf_addstr(&head_ref, branch_top);
		strbuf_addstr(&head_ref, "HEAD");
		create_symref(head_ref.buf,
			      remote_head_points_at->peer_ref->name,
			      msg);
	}
}
예제 #2
0
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);
}
예제 #3
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");
}
예제 #4
0
static void set_connectivity_errors(struct command *commands)
{
	struct command *cmd;

	for (cmd = commands; cmd; cmd = cmd->next) {
		struct command *singleton = cmd;
		if (!check_everything_connected(command_singleton_iterator,
						0, &singleton))
			continue;
		cmd->error_string = "missing necessary objects";
	}
}
예제 #5
0
static void set_connectivity_errors(struct command *commands,
				    struct shallow_info *si)
{
	struct command *cmd;

	for (cmd = commands; cmd; cmd = cmd->next) {
		struct command *singleton = cmd;
		if (shallow_update && si->shallow_ref[cmd->index])
			/* to be checked in update_shallow_ref() */
			continue;
		if (!check_everything_connected(command_singleton_iterator,
						0, &singleton))
			continue;
		cmd->error_string = "missing necessary objects";
	}
}
예제 #6
0
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);
}