@@ -61,6 +61,47 @@ GIT_EXTERN(int) git_stash_save(
6161 const char * message ,
6262 unsigned int flags );
6363
64+ typedef enum {
65+ GIT_APPLY_DEFAULT = 0 ,
66+
67+ /* Try to reinstate not only the working tree's changes,
68+ * but also the index's ones.
69+ */
70+ GIT_APPLY_REINSTATE_INDEX = (1 << 0 ),
71+ } git_apply_flags ;
72+
73+ /**
74+ * Apply a single stashed state from the stash list.
75+ *
76+ * If any untracked or ignored file saved in the stash already exist in the
77+ * workdir, the function will return GIT_EEXISTS and both the workdir and index
78+ * will be left untouched.
79+ *
80+ * If local changes in the workdir would be overwritten when applying
81+ * modifications saved in the stash, the function will return GIT_EMERGECONFLICT
82+ * and the index will be left untouched. The workdir files will be left
83+ * unmodified as well but restored untracked or ignored files that were saved
84+ * in the stash will be left around in the workdir.
85+ *
86+ * If passing the GIT_APPLY_REINSTATE_INDEX flag and there would be conflicts
87+ * when reinstating the index, the function will return GIT_EUNMERGED and both
88+ * the workdir and index will be left untouched.
89+ *
90+ * @param repo The owning repository.
91+ *
92+ * @param index The position within the stash list. 0 points to the
93+ * most recent stashed state.
94+ *
95+ * @param flags Flags to control the applying process. (see GIT_APPLY_* above)
96+ *
97+ * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
98+ * index, or error code. (see details above)
99+ */
100+ GIT_EXTERN (int ) git_stash_apply (
101+ git_repository * repo ,
102+ size_t index ,
103+ unsigned int flags );
104+
64105/**
65106 * This is a callback function you can provide to iterate over all the
66107 * stashed states that will be invoked per entry.
@@ -70,7 +111,7 @@ GIT_EXTERN(int) git_stash_save(
70111 * @param message The stash message.
71112 * @param stash_id The commit oid of the stashed state.
72113 * @param payload Extra parameter to callback function.
73- * @return 0 to continue iterating or non-zero to stop
114+ * @return 0 to continue iterating or non-zero to stop.
74115 */
75116typedef int (* git_stash_cb )(
76117 size_t index ,
@@ -90,7 +131,7 @@ typedef int (*git_stash_cb)(
90131 *
91132 * @param payload Extra parameter to callback function.
92133 *
93- * @return 0 on success, non-zero callback return value, or error code
134+ * @return 0 on success, non-zero callback return value, or error code.
94135 */
95136GIT_EXTERN (int ) git_stash_foreach (
96137 git_repository * repo ,
@@ -105,13 +146,32 @@ GIT_EXTERN(int) git_stash_foreach(
105146 * @param index The position within the stash list. 0 points to the
106147 * most recent stashed state.
107148 *
108- * @return 0 on success, or error code
149+ * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
150+ * index, or error code.
109151 */
110-
111152GIT_EXTERN (int ) git_stash_drop (
112153 git_repository * repo ,
113154 size_t index );
114155
156+ /**
157+ * Apply a single stashed state from the stash list and remove it from the list
158+ * if successful.
159+ *
160+ * @param repo The owning repository.
161+ *
162+ * @param index The position within the stash list. 0 points to the
163+ * most recent stashed state.
164+ *
165+ * @param flags Flags to control the applying process. (see GIT_APPLY_* above)
166+ *
167+ * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
168+ * index, or error code. (see git_stash_apply() above for details)
169+ */
170+ GIT_EXTERN (int ) git_stash_pop (
171+ git_repository * repo ,
172+ size_t index ,
173+ unsigned int flags );
174+
115175/** @} */
116176GIT_END_DECL
117177#endif
0 commit comments