@@ -70,6 +70,47 @@ GIT_EXTERN(int) git_stash_save(
70
70
const char * message ,
71
71
unsigned int flags );
72
72
73
+ typedef enum {
74
+ GIT_APPLY_DEFAULT = 0 ,
75
+
76
+ /* Try to reinstate not only the working tree's changes,
77
+ * but also the index's ones.
78
+ */
79
+ GIT_APPLY_REINSTATE_INDEX = (1 << 0 ),
80
+ } git_apply_flags ;
81
+
82
+ /**
83
+ * Apply a single stashed state from the stash list.
84
+ *
85
+ * If any untracked or ignored file saved in the stash already exist in the
86
+ * workdir, the function will return GIT_EEXISTS and both the workdir and index
87
+ * will be left untouched.
88
+ *
89
+ * If local changes in the workdir would be overwritten when applying
90
+ * modifications saved in the stash, the function will return GIT_EMERGECONFLICT
91
+ * and the index will be left untouched. The workdir files will be left
92
+ * unmodified as well but restored untracked or ignored files that were saved
93
+ * in the stash will be left around in the workdir.
94
+ *
95
+ * If passing the GIT_APPLY_REINSTATE_INDEX flag and there would be conflicts
96
+ * when reinstating the index, the function will return GIT_EUNMERGED and both
97
+ * the workdir and index will be left untouched.
98
+ *
99
+ * @param repo The owning repository.
100
+ *
101
+ * @param index The position within the stash list. 0 points to the
102
+ * most recent stashed state.
103
+ *
104
+ * @param flags Flags to control the applying process. (see GIT_APPLY_* above)
105
+ *
106
+ * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
107
+ * index, or error code. (see details above)
108
+ */
109
+ GIT_EXTERN (int ) git_stash_apply (
110
+ git_repository * repo ,
111
+ size_t index ,
112
+ unsigned int flags );
113
+
73
114
/**
74
115
* This is a callback function you can provide to iterate over all the
75
116
* stashed states that will be invoked per entry.
@@ -79,7 +120,7 @@ GIT_EXTERN(int) git_stash_save(
79
120
* @param message The stash message.
80
121
* @param stash_id The commit oid of the stashed state.
81
122
* @param payload Extra parameter to callback function.
82
- * @return 0 to continue iterating or non-zero to stop
123
+ * @return 0 to continue iterating or non-zero to stop.
83
124
*/
84
125
typedef int (* git_stash_cb )(
85
126
size_t index ,
@@ -99,7 +140,7 @@ typedef int (*git_stash_cb)(
99
140
*
100
141
* @param payload Extra parameter to callback function.
101
142
*
102
- * @return 0 on success, non-zero callback return value, or error code
143
+ * @return 0 on success, non-zero callback return value, or error code.
103
144
*/
104
145
GIT_EXTERN (int ) git_stash_foreach (
105
146
git_repository * repo ,
@@ -114,13 +155,32 @@ GIT_EXTERN(int) git_stash_foreach(
114
155
* @param index The position within the stash list. 0 points to the
115
156
* most recent stashed state.
116
157
*
117
- * @return 0 on success, or error code
158
+ * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
159
+ * index, or error code.
118
160
*/
119
-
120
161
GIT_EXTERN (int ) git_stash_drop (
121
162
git_repository * repo ,
122
163
size_t index );
123
164
165
+ /**
166
+ * Apply a single stashed state from the stash list and remove it from the list
167
+ * if successful.
168
+ *
169
+ * @param repo The owning repository.
170
+ *
171
+ * @param index The position within the stash list. 0 points to the
172
+ * most recent stashed state.
173
+ *
174
+ * @param flags Flags to control the applying process. (see GIT_APPLY_* above)
175
+ *
176
+ * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
177
+ * index, or error code. (see git_stash_apply() above for details)
178
+ */
179
+ GIT_EXTERN (int ) git_stash_pop (
180
+ git_repository * repo ,
181
+ size_t index ,
182
+ unsigned int flags );
183
+
124
184
/** @} */
125
185
GIT_END_DECL
126
186
#endif
0 commit comments