@@ -31,17 +31,11 @@ GIT_BEGIN_DECL
31
31
* check out, the "baseline" tree of what was checked out previously, the
32
32
* working directory for actual files, and the index for staged changes.
33
33
*
34
- * You give checkout one of three strategies for update:
34
+ * You give checkout one of two strategies for update:
35
35
*
36
- * - `GIT_CHECKOUT_NONE` is a dry-run strategy that checks for conflicts,
37
- * etc., but doesn't make any actual changes.
38
- *
39
- * - `GIT_CHECKOUT_FORCE` is at the opposite extreme, taking any action to
40
- * make the working directory match the target (including potentially
41
- * discarding modified files).
42
- *
43
- * - `GIT_CHECKOUT_SAFE` is between these two options, it will only make
44
- * modifications that will not lose changes.
36
+ * - `GIT_CHECKOUT_SAFE` is the default, and similar to git's default,
37
+ * which will make modifications that will not lose changes in the
38
+ * working directory.
45
39
*
46
40
* | target == baseline | target != baseline |
47
41
* ---------------------|-----------------------|----------------------|
@@ -55,6 +49,10 @@ GIT_BEGIN_DECL
55
49
* baseline present | | |
56
50
* ---------------------|-----------------------|----------------------|
57
51
*
52
+ * - `GIT_CHECKOUT_FORCE` will take any action to make the working
53
+ * directory match the target (including potentially discarding
54
+ * modified files).
55
+ *
58
56
* To emulate `git checkout`, use `GIT_CHECKOUT_SAFE` with a checkout
59
57
* notification callback (see below) that displays information about dirty
60
58
* files. The default behavior will cancel checkout on conflicts.
@@ -69,6 +67,9 @@ GIT_BEGIN_DECL
69
67
*
70
68
* There are some additional flags to modify the behavior of checkout:
71
69
*
70
+ * - `GIT_CHECKOUT_DRY_RUN` is a dry-run strategy that checks for conflicts,
71
+ * etc., but doesn't make any actual changes.
72
+ *
72
73
* - GIT_CHECKOUT_ALLOW_CONFLICTS makes SAFE mode apply safe file updates
73
74
* even if there are conflicts (instead of cancelling the checkout).
74
75
*
@@ -104,27 +105,20 @@ GIT_BEGIN_DECL
104
105
* and write through existing symbolic links.
105
106
*/
106
107
typedef enum {
107
- GIT_CHECKOUT_NONE = 0 , /**< default is a dry run, no actual updates */
108
-
109
108
/**
110
109
* Allow safe updates that cannot overwrite uncommitted data.
111
- * If the uncommitted changes don't conflict with the checked out files,
112
- * the checkout will still proceed, leaving the changes intact.
113
- *
114
- * Mutually exclusive with GIT_CHECKOUT_FORCE.
115
- * GIT_CHECKOUT_FORCE takes precedence over GIT_CHECKOUT_SAFE.
110
+ * If the uncommitted changes don't conflict with the checked
111
+ * out files, the checkout will still proceed, leaving the
112
+ * changes intact.
116
113
*/
117
- GIT_CHECKOUT_SAFE = ( 1u << 0 ) ,
114
+ GIT_CHECKOUT_SAFE = 0 ,
118
115
119
116
/**
120
- * Allow all updates to force working directory to look like index.
121
- *
122
- * Mutually exclusive with GIT_CHECKOUT_SAFE.
123
- * GIT_CHECKOUT_FORCE takes precedence over GIT_CHECKOUT_SAFE.
117
+ * Allow all updates to force working directory to look like
118
+ * the index, potentially losing data in the process.
124
119
*/
125
120
GIT_CHECKOUT_FORCE = (1u << 1 ),
126
121
127
-
128
122
/** Allow checkout to recreate missing files */
129
123
GIT_CHECKOUT_RECREATE_MISSING = (1u << 2 ),
130
124
@@ -178,14 +172,23 @@ typedef enum {
178
172
GIT_CHECKOUT_DONT_WRITE_INDEX = (1u << 23 ),
179
173
180
174
/**
181
- * Show what would be done by a checkout. Stop after sending
182
- * notifications; don't update the working directory or index.
175
+ * Perform a "dry run", reporting what _would_ be done but
176
+ * without actually making changes in the working directory
177
+ * or the index.
183
178
*/
184
179
GIT_CHECKOUT_DRY_RUN = (1u << 24 ),
185
180
186
181
/** Include common ancestor data in zdiff3 format for conflicts */
187
182
GIT_CHECKOUT_CONFLICT_STYLE_ZDIFF3 = (1u << 25 ),
188
183
184
+ /**
185
+ * Do not do a checkout and do not fire callbacks; this is primarily
186
+ * useful only for internal functions that will perform the
187
+ * checkout themselves but need to pass checkout options into
188
+ * another function, for example, `git_clone`.
189
+ */
190
+ GIT_CHECKOUT_NONE = (1u << 30 ),
191
+
189
192
/**
190
193
* THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
191
194
*/
@@ -194,7 +197,6 @@ typedef enum {
194
197
GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16 ),
195
198
/** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */
196
199
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17 )
197
-
198
200
} git_checkout_strategy_t ;
199
201
200
202
/**
@@ -345,7 +347,7 @@ typedef struct git_checkout_options {
345
347
} git_checkout_options ;
346
348
347
349
#define GIT_CHECKOUT_OPTIONS_VERSION 1
348
- #define GIT_CHECKOUT_OPTIONS_INIT {GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE }
350
+ #define GIT_CHECKOUT_OPTIONS_INIT {GIT_CHECKOUT_OPTIONS_VERSION}
349
351
350
352
/**
351
353
* Initialize git_checkout_options structure
0 commit comments