Skip to content

Commit 0ac7af7

Browse files
authored
Merge pull request #1 from gitkraken-jacobw/partialstashing
stash: partial stash specific files
2 parents 4c98283 + 98faa3e commit 0ac7af7

File tree

4 files changed

+317
-27
lines changed

4 files changed

+317
-27
lines changed

include/git2/stash.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ typedef enum {
4545
* the working directory
4646
*/
4747
GIT_STASH_INCLUDE_IGNORED = (1 << 2),
48+
49+
/**
50+
* All changes in the index and working directory are left intact
51+
*/
52+
GIT_STASH_KEEP_ALL = (1 << 3),
4853
} git_stash_flags;
4954

5055
/**
@@ -71,6 +76,67 @@ GIT_EXTERN(int) git_stash_save(
7176
const char *message,
7277
uint32_t flags);
7378

79+
/**
80+
* Stash save options structure
81+
*
82+
* Initialize with `GIT_STASH_SAVE_OPTIONS_INIT`. Alternatively, you can
83+
* use `git_stash_save_options_init`.
84+
*
85+
*/
86+
typedef struct git_stash_save_options {
87+
unsigned int version;
88+
89+
/** The identity of the person performing the stashing. */
90+
const git_signature *stasher;
91+
92+
/** Optional description along with the stashed state. */
93+
const char *message;
94+
95+
/** Flags to control the stashing process. (see GIT_STASH_* above) */
96+
uint32_t flags;
97+
98+
/** Optional paths that control which files are stashed. */
99+
git_strarray paths;
100+
} git_stash_save_options;
101+
102+
#define GIT_STASH_SAVE_OPTIONS_VERSION 1
103+
#define GIT_STASH_SAVE_OPTIONS_INIT { \
104+
GIT_STASH_SAVE_OPTIONS_VERSION, \
105+
NULL, \
106+
NULL, \
107+
GIT_STASH_DEFAULT }
108+
109+
/**
110+
* Initialize git_stash_save_options structure
111+
*
112+
* Initializes a `git_stash_save_options` with default values. Equivalent to
113+
* creating an instance with `GIT_STASH_SAVE_OPTIONS_INIT`.
114+
*
115+
* @param opts The `git_stash_save_options` struct to initialize.
116+
* @param version The struct version; pass `GIT_STASH_SAVE_OPTIONS_VERSION`.
117+
* @return Zero on success; -1 on failure.
118+
*/
119+
GIT_EXTERN(int) git_stash_save_options_init(
120+
git_stash_save_options *opts, unsigned int version);
121+
122+
/**
123+
* Save the local modifications to a new stash, with options.
124+
*
125+
* @param out Object id of the commit containing the stashed state.
126+
* This commit is also the target of the direct reference refs/stash.
127+
*
128+
* @param repo The owning repository.
129+
*
130+
* @param opts The stash options.
131+
*
132+
* @return 0 on success, GIT_ENOTFOUND where there's nothing to stash,
133+
* or error code.
134+
*/
135+
GIT_EXTERN(int) git_stash_save_with_opts(
136+
git_oid *out,
137+
git_repository *repo,
138+
const git_stash_save_options *opts);
139+
74140
/** Stash application flags. */
75141
typedef enum {
76142
GIT_STASH_APPLY_DEFAULT = 0,

0 commit comments

Comments
 (0)