summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 81d3fe9)
raw | patch | inline | side by side (parent: 81d3fe9)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Mon, 16 Feb 2009 12:20:25 +0000 (13:20 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 18 Feb 2009 19:04:19 +0000 (11:04 -0800) |
By having flags represented as bits in the new member variable 'flags',
it will be easier to use parse_options when dir_struct is involved.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
it will be easier to use parse_options when dir_struct is involved.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-add.c | patch | blob | history | |
builtin-checkout.c | patch | blob | history | |
builtin-clean.c | patch | blob | history | |
builtin-ls-files.c | patch | blob | history | |
builtin-merge.c | patch | blob | history | |
builtin-read-tree.c | patch | blob | history | |
dir.c | patch | blob | history | |
dir.h | patch | blob | history | |
wt-status.c | patch | blob | history |
diff --git a/builtin-add.c b/builtin-add.c
index ac98c8354d84a7f556c22c53fbe9007832ac4346..c986a3ada1ad09f653b734e770ee871a255c5086 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
/* Set up the default git porcelain excludes */
memset(dir, 0, sizeof(*dir));
if (!ignored_too) {
- dir->collect_ignored = 1;
+ dir->flags |= DIR_COLLECT_IGNORED;
setup_standard_excludes(dir);
}
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 20b34ce6e10d9b863226b501cf5a35178b898995..5b4921d48c43359624c4232ba971f0167c439317 100644 (file)
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
topts.verbose_update = !opts->quiet;
topts.fn = twoway_merge;
topts.dir = xcalloc(1, sizeof(*topts.dir));
- topts.dir->show_ignored = 1;
+ topts.dir->flags |= DIR_SHOW_IGNORED;
topts.dir->exclude_per_dir = ".gitignore";
tree = parse_tree_indirect(old->commit->object.sha1);
init_tree_desc(&trees[0], tree->buffer, tree->size);
diff --git a/builtin-clean.c b/builtin-clean.c
index f78c2fb108bc667079290f9b2fa82f47da5eb34c..c5ad33d3e665f6d1613df2dfba235b03765565ac 100644 (file)
--- a/builtin-clean.c
+++ b/builtin-clean.c
memset(&dir, 0, sizeof(dir));
if (ignored_only)
- dir.show_ignored = 1;
+ dir.flags |= DIR_SHOW_IGNORED;
if (ignored && ignored_only)
die("-x and -X cannot be used together");
die("clean.requireForce%s set and -n or -f not given; "
"refusing to clean", config_set ? "" : " not");
- dir.show_other_directories = 1;
+ dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
if (!ignored)
setup_standard_excludes(&dir);
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 9dec282fba6ba22e37d13bdc5e35fa4a031433b5..d36f80b3de96c43cfc131f336850486c04444080 100644 (file)
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
int dtype = ce_to_dtype(ce);
- if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
+ if (excluded(dir, ce->name, &dtype) !=
+ !!(dir->flags & DIR_SHOW_IGNORED))
continue;
if (show_unmerged && !ce_stage(ce))
continue;
struct stat st;
int err;
int dtype = ce_to_dtype(ce);
- if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
+ if (excluded(dir, ce->name, &dtype) !=
+ !!(dir->flags & DIR_SHOW_IGNORED))
continue;
if (ce->ce_flags & CE_UPDATE)
continue;
continue;
}
if (!strcmp(arg, "-i") || !strcmp(arg, "--ignored")) {
- dir.show_ignored = 1;
+ dir.flags |= DIR_SHOW_IGNORED;
require_work_tree = 1;
continue;
}
continue;
}
if (!strcmp(arg, "--directory")) {
- dir.show_other_directories = 1;
+ dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
continue;
}
if (!strcmp(arg, "--no-empty-directory")) {
- dir.hide_empty_directories = 1;
+ dir.flags |= DIR_HIDE_EMPTY_DIRECTORIES;
continue;
}
if (!strcmp(arg, "-u") || !strcmp(arg, "--unmerged")) {
ps_matched = xcalloc(1, num);
}
- if (dir.show_ignored && !exc_given) {
+ if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given) {
fprintf(stderr, "%s: --ignored needs some exclude pattern\n",
argv[0]);
exit(1);
diff --git a/builtin-merge.c b/builtin-merge.c
index 6d2160d0a3db1705d1372029dfa24752d453c8ec..4c119359e74cc483c47a6031f6057ac2eb06ca76 100644 (file)
--- a/builtin-merge.c
+++ b/builtin-merge.c
memset(&opts, 0, sizeof(opts));
memset(&t, 0, sizeof(t));
memset(&dir, 0, sizeof(dir));
- dir.show_ignored = 1;
+ dir.flags |= DIR_SHOW_IGNORED;
dir.exclude_per_dir = ".gitignore";
opts.dir = &dir;
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 38fef34d3fb6c24ab89043951f1ecf6c96e9bf51..8e0273864d6af8de2a31868dcfbeda29cd36c2fc 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
die("more than one --exclude-per-directory are given.");
dir = xcalloc(1, sizeof(*opts.dir));
- dir->show_ignored = 1;
+ dir->flags |= DIR_SHOW_IGNORED;
dir->exclude_per_dir = arg + 24;
opts.dir = dir;
/* We do not need to nor want to do read-directory
index cfd1ea587d9cce825e238ca81ea99b752543dada..5011cb4dd47a98bf5f91c3a5dc4682cfe1352601 100644 (file)
--- a/dir.c
+++ b/dir.c
return recurse_into_directory;
case index_gitdir:
- if (dir->show_other_directories)
+ if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
return ignore_directory;
return show_directory;
case index_nonexistent:
- if (dir->show_other_directories)
+ if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
break;
- if (!dir->no_gitlinks) {
+ if (!(dir->flags & DIR_NO_GITLINKS)) {
unsigned char sha1[20];
if (resolve_gitlink_ref(dirname, "HEAD", sha1) == 0)
return show_directory;
}
/* This is the "show_other_directories" case */
- if (!dir->hide_empty_directories)
+ if (!(dir->flags & DIR_HIDE_EMPTY_DIRECTORIES))
return show_directory;
if (!read_directory_recursive(dir, dirname, dirname, len, 1, simplify))
return ignore_directory;
@@ -601,7 +601,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
dtype = DTYPE(de);
exclude = excluded(dir, fullname, &dtype);
- if (exclude && dir->collect_ignored
+ if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
&& in_pathspec(fullname, baselen + len, simplify))
dir_add_ignored(dir, fullname, baselen + len);
@@ -609,7 +609,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
* Excluded? If we don't explicitly want to show
* ignored files, ignore it
*/
- if (exclude && !dir->show_ignored)
+ if (exclude && !(dir->flags & DIR_SHOW_IGNORED))
continue;
if (dtype == DT_UNKNOWN)
@@ -621,7 +621,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
* even if we don't ignore them, since the
* directory may contain files that we do..
*/
- if (!exclude && dir->show_ignored) {
+ if (!exclude && (dir->flags & DIR_SHOW_IGNORED)) {
if (dtype != DT_DIR)
continue;
}
@@ -634,7 +634,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
len++;
switch (treat_directory(dir, fullname, baselen + len, simplify)) {
case show_directory:
- if (exclude != dir->show_ignored)
+ if (exclude != !!(dir->flags
+ & DIR_SHOW_IGNORED))
continue;
break;
case recurse_into_directory:
index bdc2d47447c2ca406aac41d7a8382bf5928fbda8..541286ad1daeb66a9963288d275534ee963bd5cd 100644 (file)
--- a/dir.h
+++ b/dir.h
struct dir_struct {
int nr, alloc;
int ignored_nr, ignored_alloc;
- unsigned int show_ignored:1,
- show_other_directories:1,
- hide_empty_directories:1,
- no_gitlinks:1,
- collect_ignored:1;
+ enum {
+ DIR_SHOW_IGNORED = 1<<0,
+ DIR_SHOW_OTHER_DIRECTORIES = 1<<1,
+ DIR_HIDE_EMPTY_DIRECTORIES = 1<<2,
+ DIR_NO_GITLINKS = 1<<3,
+ DIR_COLLECT_IGNORED = 1<<4
+ } flags;
struct dir_entry **entries;
struct dir_entry **ignored;
diff --git a/wt-status.c b/wt-status.c
index 96ff2f8f564b907b9ef77bd2ea41b5e854a13085..f2eae20d89b71f384f727e72a1c520a3f1330df6 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
memset(&dir, 0, sizeof(dir));
- if (!s->untracked) {
- dir.show_other_directories = 1;
- dir.hide_empty_directories = 1;
- }
+ if (!s->untracked)
+ dir.flags |=
+ DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
setup_standard_excludes(&dir);
read_directory(&dir, ".", "", 0, NULL);