Esempio n. 1
0
int gitfo_mv_force(const char *from, const char *to)
{
	const int mode = 0755; /* or 0777 ? */
	int error = GIT_SUCCESS;
	char target_folder_path[GIT_PATH_MAX];

	error = git__dirname_r(target_folder_path, sizeof(target_folder_path), to);
	if (error < GIT_SUCCESS)
		return error;

	/* Does the containing folder exist? */
	if (gitfo_isdir(target_folder_path)) {
		git__joinpath(target_folder_path, target_folder_path, ""); /* Ensure there's a trailing slash */

		/* Let's create the tree structure */
		error = gitfo_mkdir_recurs(target_folder_path, mode);
		if (error < GIT_SUCCESS)
			return error;
	}

	return gitfo_mv(from, to);
}
Esempio n. 2
0
int git_filebuf_commit(git_filebuf *file)
{
    int error;

    /* temporary files cannot be committed */
    assert(file && file->path_original);

    file->flush_mode = Z_FINISH;
    if ((error = flush_buffer(file)) < GIT_SUCCESS)
        goto cleanup;

    gitfo_close(file->fd);
    file->fd = -1;

    error = gitfo_mv(file->path_lock, file->path_original);

cleanup:
    git_filebuf_cleanup(file);
    if (error < GIT_SUCCESS)
        return git__rethrow(error, "Failed to commit locked file from buffer");
    return GIT_SUCCESS;
}