5
5
#include "archive.h"
6
6
#include "parse-options.h"
7
7
#include "unpack-trees.h"
8
- #include "pathspec.h"
9
8
10
9
static char const * const archive_usage [] = {
11
10
N_ ("git archive [options] <tree-ish> [<path>...]" ),
@@ -152,7 +151,6 @@ int write_archive_entries(struct archiver_args *args,
152
151
struct archiver_context context ;
153
152
struct unpack_trees_options opts ;
154
153
struct tree_desc t ;
155
- struct pathspec pathspec ;
156
154
int err ;
157
155
158
156
if (args -> baselen > 0 && args -> base [args -> baselen - 1 ] == '/' ) {
@@ -187,10 +185,8 @@ int write_archive_entries(struct archiver_args *args,
187
185
git_attr_set_direction (GIT_ATTR_INDEX , & the_index );
188
186
}
189
187
190
- init_pathspec (& pathspec , args -> pathspec );
191
- err = read_tree_recursive (args -> tree , "" , 0 , 0 , & pathspec ,
188
+ err = read_tree_recursive (args -> tree , "" , 0 , 0 , & args -> pathspec ,
192
189
write_archive_entry , & context );
193
- free_pathspec (& pathspec );
194
190
if (err == READ_TREE_RECURSIVE )
195
191
err = 0 ;
196
192
return err ;
@@ -223,7 +219,7 @@ static int path_exists(struct tree *tree, const char *path)
223
219
struct pathspec pathspec ;
224
220
int ret ;
225
221
226
- init_pathspec (& pathspec , paths );
222
+ parse_pathspec (& pathspec , 0 , 0 , "" , paths );
227
223
ret = read_tree_recursive (tree , "" , 0 , 0 , & pathspec , reject_entry , NULL );
228
224
free_pathspec (& pathspec );
229
225
return ret != 0 ;
@@ -232,11 +228,18 @@ static int path_exists(struct tree *tree, const char *path)
232
228
static void parse_pathspec_arg (const char * * pathspec ,
233
229
struct archiver_args * ar_args )
234
230
{
235
- ar_args -> pathspec = pathspec = get_pathspec ("" , pathspec );
231
+ /*
232
+ * must be consistent with parse_pathspec in path_exists()
233
+ * Also if pathspec patterns are dependent, we're in big
234
+ * trouble as we test each one separately
235
+ */
236
+ parse_pathspec (& ar_args -> pathspec , 0 ,
237
+ PATHSPEC_PREFER_FULL ,
238
+ "" , pathspec );
236
239
if (pathspec ) {
237
240
while (* pathspec ) {
238
241
if (* * pathspec && !path_exists (ar_args -> tree , * pathspec ))
239
- die ("path not found: %s" , * pathspec );
242
+ die (_ ( "pathspec '%s' did not match any files" ) , * pathspec );
240
243
pathspec ++ ;
241
244
}
242
245
}
0 commit comments