55#include "archive.h"
66#include "parse-options.h"
77#include "unpack-trees.h"
8- #include "pathspec.h"
98
109static char const * const archive_usage [] = {
1110 N_ ("git archive [options] <tree-ish> [<path>...]" ),
@@ -152,7 +151,6 @@ int write_archive_entries(struct archiver_args *args,
152151 struct archiver_context context ;
153152 struct unpack_trees_options opts ;
154153 struct tree_desc t ;
155- struct pathspec pathspec ;
156154 int err ;
157155
158156 if (args -> baselen > 0 && args -> base [args -> baselen - 1 ] == '/' ) {
@@ -187,10 +185,8 @@ int write_archive_entries(struct archiver_args *args,
187185 git_attr_set_direction (GIT_ATTR_INDEX , & the_index );
188186 }
189187
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 ,
192189 write_archive_entry , & context );
193- free_pathspec (& pathspec );
194190 if (err == READ_TREE_RECURSIVE )
195191 err = 0 ;
196192 return err ;
@@ -223,7 +219,7 @@ static int path_exists(struct tree *tree, const char *path)
223219 struct pathspec pathspec ;
224220 int ret ;
225221
226- init_pathspec (& pathspec , paths );
222+ parse_pathspec (& pathspec , 0 , 0 , "" , paths );
227223 ret = read_tree_recursive (tree , "" , 0 , 0 , & pathspec , reject_entry , NULL );
228224 free_pathspec (& pathspec );
229225 return ret != 0 ;
@@ -232,11 +228,18 @@ static int path_exists(struct tree *tree, const char *path)
232228static void parse_pathspec_arg (const char * * pathspec ,
233229 struct archiver_args * ar_args )
234230{
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 );
236239 if (pathspec ) {
237240 while (* pathspec ) {
238241 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 );
240243 pathspec ++ ;
241244 }
242245 }
0 commit comments