Skip to content

Commit 4d4d4ea

Browse files
dschogitster
authored andcommitted
diff.c: move the diff filter bits definitions up a bit
This prepares for a more careful handling of the `--diff-filter` options over the next few commits. This commit is best viewed with `--color-moved`. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d843e31 commit 4d4d4ea

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

diff.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4570,6 +4570,43 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)
45704570
prep_parse_options(options);
45714571
}
45724572

4573+
static const char diff_status_letters[] = {
4574+
DIFF_STATUS_ADDED,
4575+
DIFF_STATUS_COPIED,
4576+
DIFF_STATUS_DELETED,
4577+
DIFF_STATUS_MODIFIED,
4578+
DIFF_STATUS_RENAMED,
4579+
DIFF_STATUS_TYPE_CHANGED,
4580+
DIFF_STATUS_UNKNOWN,
4581+
DIFF_STATUS_UNMERGED,
4582+
DIFF_STATUS_FILTER_AON,
4583+
DIFF_STATUS_FILTER_BROKEN,
4584+
'\0',
4585+
};
4586+
4587+
static unsigned int filter_bit['Z' + 1];
4588+
4589+
static void prepare_filter_bits(void)
4590+
{
4591+
int i;
4592+
4593+
if (!filter_bit[DIFF_STATUS_ADDED]) {
4594+
for (i = 0; diff_status_letters[i]; i++)
4595+
filter_bit[(int) diff_status_letters[i]] = (1 << i);
4596+
}
4597+
}
4598+
4599+
static unsigned filter_bit_tst(char status, const struct diff_options *opt)
4600+
{
4601+
return opt->filter & filter_bit[(int) status];
4602+
}
4603+
4604+
unsigned diff_filter_bit(char status)
4605+
{
4606+
prepare_filter_bits();
4607+
return filter_bit[(int) status];
4608+
}
4609+
45734610
void diff_setup_done(struct diff_options *options)
45744611
{
45754612
unsigned check_mask = DIFF_FORMAT_NAME |
@@ -4774,43 +4811,6 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params)
47744811
return 1;
47754812
}
47764813

4777-
static const char diff_status_letters[] = {
4778-
DIFF_STATUS_ADDED,
4779-
DIFF_STATUS_COPIED,
4780-
DIFF_STATUS_DELETED,
4781-
DIFF_STATUS_MODIFIED,
4782-
DIFF_STATUS_RENAMED,
4783-
DIFF_STATUS_TYPE_CHANGED,
4784-
DIFF_STATUS_UNKNOWN,
4785-
DIFF_STATUS_UNMERGED,
4786-
DIFF_STATUS_FILTER_AON,
4787-
DIFF_STATUS_FILTER_BROKEN,
4788-
'\0',
4789-
};
4790-
4791-
static unsigned int filter_bit['Z' + 1];
4792-
4793-
static void prepare_filter_bits(void)
4794-
{
4795-
int i;
4796-
4797-
if (!filter_bit[DIFF_STATUS_ADDED]) {
4798-
for (i = 0; diff_status_letters[i]; i++)
4799-
filter_bit[(int) diff_status_letters[i]] = (1 << i);
4800-
}
4801-
}
4802-
4803-
static unsigned filter_bit_tst(char status, const struct diff_options *opt)
4804-
{
4805-
return opt->filter & filter_bit[(int) status];
4806-
}
4807-
4808-
unsigned diff_filter_bit(char status)
4809-
{
4810-
prepare_filter_bits();
4811-
return filter_bit[(int) status];
4812-
}
4813-
48144814
static int diff_opt_diff_filter(const struct option *option,
48154815
const char *optarg, int unset)
48164816
{

0 commit comments

Comments
 (0)