Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50ebd99

Browse files
committed
Added git_stash_apply() and git_stash_pop() APIs
1 parent e06b104 commit 50ebd99

4 files changed

Lines changed: 481 additions & 4 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Microsoft Corporation
4949
Olivier Ramonat
5050
Peter Drahoš
5151
Pierre Habouzit
52+
Pierre-Olivier Latour
5253
Przemyslaw Pawelczyk
5354
Ramsay Jones
5455
Robert G. Jakabosky

include/git2/stash.h

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ GIT_EXTERN(int) git_stash_save(
6161
const char *message,
6262
unsigned int flags);
6363

64+
/**
65+
* Apply a single stashed state from the stash list.
66+
*
67+
* @param repo The owning repository.
68+
*
69+
* @param index The position within the stash list. 0 points to the
70+
* most recent stashed state.
71+
*
72+
* @param reinstate_index Try to reinstate not only the working tree's changes,
73+
* but also the index's ones.
74+
*
75+
* @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
76+
* index, GIT_EMERGECONFLICT on merge conflict in the workdir, GIT_EUNMERGED on
77+
* merge conflict in the index (if reinstating the index), or error code.
78+
*/
79+
GIT_EXTERN(int) git_stash_apply(
80+
git_repository *repo,
81+
size_t index,
82+
int reinstate_index);
83+
6484
/**
6585
* This is a callback function you can provide to iterate over all the
6686
* stashed states that will be invoked per entry.
@@ -70,7 +90,7 @@ GIT_EXTERN(int) git_stash_save(
7090
* @param message The stash message.
7191
* @param stash_id The commit oid of the stashed state.
7292
* @param payload Extra parameter to callback function.
73-
* @return 0 to continue iterating or non-zero to stop
93+
* @return 0 to continue iterating or non-zero to stop.
7494
*/
7595
typedef int (*git_stash_cb)(
7696
size_t index,
@@ -90,7 +110,7 @@ typedef int (*git_stash_cb)(
90110
*
91111
* @param payload Extra parameter to callback function.
92112
*
93-
* @return 0 on success, non-zero callback return value, or error code
113+
* @return 0 on success, non-zero callback return value, or error code.
94114
*/
95115
GIT_EXTERN(int) git_stash_foreach(
96116
git_repository *repo,
@@ -105,13 +125,34 @@ GIT_EXTERN(int) git_stash_foreach(
105125
* @param index The position within the stash list. 0 points to the
106126
* most recent stashed state.
107127
*
108-
* @return 0 on success, or error code
128+
* @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
129+
* index, or error code.
109130
*/
110-
111131
GIT_EXTERN(int) git_stash_drop(
112132
git_repository *repo,
113133
size_t index);
114134

135+
/**
136+
* Apply a single stashed state from the stash list and remove it from the list
137+
* if successful.
138+
*
139+
* @param repo The owning repository.
140+
*
141+
* @param index The position within the stash list. 0 points to the
142+
* most recent stashed state.
143+
*
144+
* @param reinstate_index Try to reinstate not only the working tree's changes,
145+
* but also the index's ones.
146+
*
147+
* @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given
148+
* index, GIT_EMERGECONFLICT on merge conflict in the workdir, GIT_EUNMERGED on
149+
* merge conflict in the index (if reinstating the index), or error code.
150+
*/
151+
GIT_EXTERN(int) git_stash_pop(
152+
git_repository *repo,
153+
size_t index,
154+
int reinstate_index);
155+
115156
/** @} */
116157
GIT_END_DECL
117158
#endif

0 commit comments

Comments
 (0)