Exemple #1
0
static void *
merge_job (void *data)
{
    MergeAux *aux = data;
    CloneTask *task = aux->task;
    SeafRepo *repo = aux->repo;
    SeafBranch *local = NULL;
    SeafCommit *head = NULL;

    /* If we haven't indexed files in the worktree, index them now. */
    if (task->root_id[0] == 0) {
        if (seaf_repo_index_worktree_files (task->repo_id,
                                            task->worktree,
                                            task->passwd,
                                            task->root_id) < 0)
            return aux;
    }

    local = seaf_branch_manager_get_branch (seaf->branch_mgr, repo->id, "local");
    if (!local) {
        aux->success = FALSE;
        goto out;
    }

    head = seaf_commit_manager_get_commit (seaf->commit_mgr, local->commit_id);
    if (!head) {
        aux->success = FALSE;
        goto out;
    }

    if (check_fast_forward (head, task->root_id)) {
        seaf_debug ("[clone mgr] Fast forward.\n");
        if (fast_forward_checkout (repo, head, task) < 0)
            goto out;
    } else {
        if (real_merge (repo, head, task) < 0)
            goto out;

        /* Commit the result of merge. */
        GError *error = NULL;
        /* XXX: the commit code assumes repo->head is set. */
        repo->head = local;
        seaf_repo_index_commit (repo, "", &error);
        if (error) {
            seaf_warning ("Failed to commit after merge.\n");
            goto out;
        }
        repo->head = NULL;
    }

    /* Set repo head to mark checkout done. */
    seaf_repo_set_head (repo, local);

    aux->success = TRUE;

out:
    seaf_branch_unref (local);
    seaf_commit_unref (head);
    return aux;
}
Exemple #2
0
static void *
index_files_job (void *data)
{
    IndexAux *aux = data;
    CloneTask *task = aux->task;

    if (seaf_repo_index_worktree_files (task->repo_id, task->worktree,
                                        task->passwd, task->root_id) == 0)
        aux->success = TRUE;

    return data;
}