Skip to content

Commit

Permalink
Merge branch 'nd/struct-pathspec'
Browse files Browse the repository at this point in the history
* nd/struct-pathspec: (22 commits)
  t6004: add pathspec globbing test for log family
  t7810: overlapping pathspecs and depth limit
  grep: drop pathspec_matches() in favor of tree_entry_interesting()
  grep: use writable strbuf from caller for grep_tree()
  grep: use match_pathspec_depth() for cache/worktree grepping
  grep: convert to use struct pathspec
  Convert ce_path_match() to use match_pathspec_depth()
  Convert ce_path_match() to use struct pathspec
  struct rev_info: convert prune_data to struct pathspec
  pathspec: add match_pathspec_depth()
  tree_entry_interesting(): optimize wildcard matching when base is matched
  tree_entry_interesting(): support wildcard matching
  tree_entry_interesting(): fix depth limit with overlapping pathspecs
  tree_entry_interesting(): support depth limit
  tree_entry_interesting(): refactor into separate smaller functions
  diff-tree: convert base+baselen to writable strbuf
  glossary: define pathspec
  Move tree_entry_interesting() to tree-walk.c and export it
  tree_entry_interesting(): remove dependency on struct diff_options
  Convert struct diff_options to use struct pathspec
  ...
  • Loading branch information
Junio C Hamano committed Feb 28, 2011
2 parents e5ea66f + f577b92 commit d5c87a8
Show file tree
Hide file tree
Showing 25 changed files with 649 additions and 444 deletions.
23 changes: 23 additions & 0 deletions Documentation/glossary-content.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,29 @@ This commit is referred to as a "merge commit", or sometimes just a
<<def_pack,pack>>, to assist in efficiently accessing the contents of a
pack.

[[def_pathspec]]pathspec::
Pattern used to specify paths.
+
Pathspecs are used on the command line of "git ls-files", "git
ls-tree", "git grep", "git checkout", and many other commands to
limit the scope of operations to some subset of the tree or
worktree. See the documentation of each command for whether
paths are relative to the current directory or toplevel. The
pathspec syntax is as follows:

* any path matches itself
* the pathspec up to the last slash represents a
directory prefix. The scope of that pathspec is
limited to that subtree.
* the rest of the pathspec is a pattern for the remainder
of the pathname. Paths relative to the directory
prefix will be matched against that pattern using fnmatch(3);
in particular, '*' and '?' _can_ match directory separators.
+
For example, Documentation/*.jpg will match all .jpg files
in the Documentation subtree,
including Documentation/chapter_1/figure_1.jpg.

[[def_parent]]parent::
A <<def_commit_object,commit object>> contains a (possibly empty) list
of the logical predecessor(s) in the line of development, i.e. its
Expand Down
2 changes: 1 addition & 1 deletion builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
struct rev_info rev;
init_revisions(&rev, prefix);
setup_revisions(0, NULL, &rev, NULL);
rev.prune_data = pathspec;
init_pathspec(&rev.prune_data, pathspec);
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = update_callback;
data.flags = flags;
Expand Down
2 changes: 1 addition & 1 deletion builtin/diff-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
(rev.diffopt.output_format & DIFF_FORMAT_PATCH))
rev.combine_merges = rev.dense_combined_merges = 1;

if (read_cache_preload(rev.diffopt.paths) < 0) {
if (read_cache_preload(rev.diffopt.pathspec.raw) < 0) {
perror("read_cache_preload");
return -1;
}
Expand Down
16 changes: 6 additions & 10 deletions builtin/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static int builtin_diff_index(struct rev_info *revs,
revs->max_count != -1 || revs->min_age != -1 ||
revs->max_age != -1)
usage(builtin_diff_usage);
if (read_cache_preload(revs->diffopt.paths) < 0) {
if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {
perror("read_cache_preload");
return -1;
}
Expand Down Expand Up @@ -237,7 +237,7 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
revs->combine_merges = revs->dense_combined_merges = 1;

setup_work_tree();
if (read_cache_preload(revs->diffopt.paths) < 0) {
if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {
perror("read_cache_preload");
return -1;
}
Expand Down Expand Up @@ -374,14 +374,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
}
die("unhandled object '%s' given.", name);
}
if (rev.prune_data) {
const char **pathspec = rev.prune_data;
while (*pathspec) {
if (!path)
path = *pathspec;
paths++;
pathspec++;
}
if (rev.prune_data.nr) {
if (!path)
path = rev.prune_data.items[0].match;
paths += rev.prune_data.nr;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (import_filename)
import_marks(import_filename);

if (import_filename && revs.prune_data)
if (import_filename && revs.prune_data.nr)
full_tree = 1;

get_tags_and_duplicates(&revs.pending, &extra_refs);
Expand Down
Loading

0 comments on commit d5c87a8

Please sign in to comment.