]> git.proxmox.com Git - libgit2.git/blame - include/git2/stash.h
API updates for signature.h
[libgit2.git] / include / git2 / stash.h
CommitLineData
590fb68b 1/*
2 * Copyright (C) 2009-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_stash_h__
8#define INCLUDE_git_stash_h__
9
10#include "common.h"
11#include "types.h"
12
13/**
14 * @file git2/stash.h
15 * @brief Git stash management routines
16 * @ingroup Git
17 * @{
18 */
19GIT_BEGIN_DECL
20
21enum {
22 GIT_STASH_DEFAULT = 0,
23
24 /* All changes already added to the index
25 * are left intact in the working directory
26 */
27 GIT_STASH_KEEP_INDEX = (1 << 0),
28
29 /* All untracked files are also stashed and then
30 * cleaned up from the working directory
31 */
32 GIT_STASH_INCLUDE_UNTRACKED = (1 << 1),
33
34 /* All ignored files are also stashed and then
35 * cleaned up from the working directory
36 */
37 GIT_STASH_INCLUDE_IGNORED = (1 << 2),
38};
39
40/**
41 * Save the local modifications to a new stash.
42 *
43 * @param out Object id of the commit containing the stashed state.
44 * This commit is also the target of the direct reference refs/stash.
45 *
46 * @param repo The owning repository.
47 *
48 * @param stasher The identity of the person performing the stashing.
49 *
50 * @param message Optional description along with the stashed state.
51 *
52 * @param flags Flags to control the stashing process.
53 *
54 * @return 0 on success, GIT_ENOTFOUND where there's nothing to stash,
55 * or error code.
56 */
57
58GIT_EXTERN(int) git_stash_save(
59 git_oid *out,
60 git_repository *repo,
61 git_signature *stasher,
62 const char *message,
63 uint32_t flags);
64
23388413 65/**
66 * When iterating over all the stashed states, callback that will be
67 * issued per entry.
68 *
69 * @param index The position within the stash list. 0 points to the
70 * most recent stashed state.
71 *
72 * @param message The stash message.
73 *
74 * @param stash_oid The commit oid of the stashed state.
75 *
76 * @param payload Extra parameter to callback function.
77 *
78 * @return 0 on success, GIT_EUSER on non-zero callback, or error code
79 */
80typedef int (*stash_cb)(
81 size_t index,
82 const char* message,
83 const git_oid *stash_oid,
84 void *payload);
85
86/**
87 * Loop over all the stashed states and issue a callback for each one.
88 *
89 * If the callback returns a non-zero value, this will stop looping.
90 *
91 * @param repo Repository where to find the stash.
92 *
93 * @param callabck Callback to invoke per found stashed state. The most recent
94 * stash state will be enumerated first.
95 *
96 * @param payload Extra parameter to callback function.
97 *
98 * @return 0 on success, GIT_EUSER on non-zero callback, or error code
99 */
100GIT_EXTERN(int) git_stash_foreach(
101 git_repository *repo,
102 stash_cb callback,
103 void *payload);
104
e4c64cf2 105/**
106 * Remove a single stashed state from the stash list.
107 *
108 * @param repo The owning repository.
109 *
110 * @param index The position within the stash list. 0 points to the
111 * most recent stashed state.
112 *
113 * @return 0 on success, or error code
114 */
115
116GIT_EXTERN(int) git_stash_drop(
117 git_repository *repo,
118 size_t index);
119
590fb68b 120/** @} */
121GIT_END_DECL
122#endif