7
7
#define USE_THE_INDEX_COMPATIBILITY_MACROS
8
8
#include "builtin.h"
9
9
#include "config.h"
10
+ #include "dir.h"
10
11
#include "lockfile.h"
11
12
#include "quote.h"
12
13
#include "cache-tree.h"
@@ -116,7 +117,7 @@ static int checkout_file(const char *name, const char *prefix)
116
117
return -1 ;
117
118
}
118
119
119
- static int checkout_all (const char * prefix , int prefix_length )
120
+ static int checkout_all (const char * prefix , int prefix_length , int include_sparse )
120
121
{
121
122
int i , errs = 0 ;
122
123
struct cache_entry * last_ce = NULL ;
@@ -125,6 +126,8 @@ static int checkout_all(const char *prefix, int prefix_length)
125
126
ensure_full_index (& the_index );
126
127
for (i = 0 ; i < active_nr ; i ++ ) {
127
128
struct cache_entry * ce = active_cache [i ];
129
+ if (!include_sparse && !path_in_sparse_checkout (ce -> name , & the_index ))
130
+ continue ;
128
131
if (ce_stage (ce ) != checkout_stage
129
132
&& (CHECKOUT_ALL != checkout_stage || !ce_stage (ce )))
130
133
continue ;
@@ -176,6 +179,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
176
179
int i ;
177
180
struct lock_file lock_file = LOCK_INIT ;
178
181
int all = 0 ;
182
+ int include_sparse = 0 ;
179
183
int read_from_stdin = 0 ;
180
184
int prefix_length ;
181
185
int force = 0 , quiet = 0 , not_new = 0 ;
@@ -185,6 +189,8 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
185
189
struct option builtin_checkout_index_options [] = {
186
190
OPT_BOOL ('a' , "all" , & all ,
187
191
N_ ("check out all files in the index" )),
192
+ OPT_BOOL (0 , "sparse" , & include_sparse ,
193
+ N_ ("do not skip files outside the sparse checkout boundary" )),
188
194
OPT__FORCE (& force , N_ ("force overwrite of existing files" ), 0 ),
189
195
OPT__QUIET (& quiet ,
190
196
N_ ("no warning for existing files and files not in index" )),
@@ -247,6 +253,8 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
247
253
248
254
if (all )
249
255
die ("git checkout-index: don't mix '--all' and explicit filenames" );
256
+ if (include_sparse )
257
+ die ("git checkout-index: don't mix '--sparse' and explicit filenames" );
250
258
if (read_from_stdin )
251
259
die ("git checkout-index: don't mix '--stdin' and explicit filenames" );
252
260
p = prefix_path (prefix , prefix_length , arg );
@@ -280,7 +288,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
280
288
}
281
289
282
290
if (all )
283
- err |= checkout_all (prefix , prefix_length );
291
+ err |= checkout_all (prefix , prefix_length , include_sparse );
284
292
285
293
if (pc_workers > 1 )
286
294
err |= run_parallel_checkout (& state , pc_workers , pc_threshold ,
0 commit comments