]> git.proxmox.com Git - libgit2.git/blame - include/git2/checkout.h
checkout: introduce git_checkout_index()
[libgit2.git] / include / git2 / checkout.h
CommitLineData
14741d62
BS
1/*
2 * Copyright (C) 2012 the libgit2 contributors
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7#ifndef INCLUDE_git_checkout_h__
8#define INCLUDE_git_checkout_h__
9
10#include "common.h"
11#include "types.h"
12#include "indexer.h"
13
14
15/**
16 * @file git2/checkout.h
17 * @brief Git checkout routines
18 * @defgroup git_checkout Git checkout routines
19 * @ingroup Git
20 * @{
21 */
22GIT_BEGIN_DECL
23
ef9905c9 24
b401bace 25#define GIT_CHECKOUT_OVERWRITE_EXISTING 0 /* default */
ef9905c9
BS
26#define GIT_CHECKOUT_SKIP_EXISTING 1
27
b401bace 28/* Use zeros to indicate default settings */
ef9905c9 29typedef struct git_checkout_opts {
b401bace
BS
30 int existing_file_action; /* default: GIT_CHECKOUT_OVERWRITE_EXISTING */
31 int disable_filters;
32 int dir_mode; /* default is 0755 */
095ccc01
BS
33 int file_mode; /* default is 0644 */
34 int file_open_flags; /* default is O_CREAT | O_TRUNC | O_WRONLY */
3aa443a9 35
36 /* when not NULL, arrays of fnmatch pattern specifying
37 * which paths should be taken into account
38 */
39 git_strarray *paths;
ef9905c9
BS
40} git_checkout_opts;
41
ef9905c9 42/**
3aa443a9 43 * Updates files in the index and the working tree to match the content of the
44 * commit pointed at by HEAD.
ef9905c9
BS
45 *
46 * @param repo repository to check out (must be non-bare)
47 * @param opts specifies checkout options (may be NULL)
b31667fb 48 * @param stats structure through which progress information is reported
746642a6 49 * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
50 * about the error)
ef9905c9 51 */
746642a6 52GIT_EXTERN(int) git_checkout_head(
53 git_repository *repo,
54 git_checkout_opts *opts,
55 git_indexer_stats *stats);
ef9905c9 56
14741d62 57/**
3aa443a9 58 * Updates files in the index and the working tree to match the content of the
59 * commit pointed at by the reference.
60 *
14741d62 61 *
b31667fb 62 * @param ref reference to follow to a commit
ef9905c9 63 * @param opts specifies checkout options (may be NULL)
b31667fb 64 * @param stats structure through which progress information is reported
746642a6 65 * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
66 * about the error)
14741d62 67 */
746642a6 68GIT_EXTERN(int) git_checkout_reference(
69 git_reference *ref,
70 git_checkout_opts *opts,
71 git_indexer_stats *stats);
b31667fb 72
e93af304 73/**
74 * Updates files in the working tree to match the content of the index.
75 *
76 * @param repo repository to check out (must be non-bare)
77 * @param opts specifies checkout options (may be NULL)
78 * @param stats structure through which progress information is reported
79 * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
80 * about the error)
81 */
82GIT_EXTERN(int) git_checkout_index(
83 git_repository *repo,
84 git_checkout_opts *opts,
85 git_indexer_stats *stats);
86
3aa443a9 87/**
88 * Updates files in the index and working tree to match the content of the
89 * tree pointed at by the treeish.
90 *
91 * @param repo repository to check out (must be non-bare)
92 * @param treeish a commit, tag or tree which content will be used to update
93 * the working directory
94 * @param opts specifies checkout options (may be NULL)
95 * @param stats structure through which progress information is reported
96 * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
97 * about the error)
98 */
99GIT_EXTERN(int) git_checkout_tree(
100 git_repository *repo,
101 git_object *treeish,
102 git_checkout_opts *opts,
103 git_indexer_stats *stats);
14741d62
BS
104
105/** @} */
106GIT_END_DECL
107#endif