From 4c3fe82ef17a6636c742b95cd292b83b02876e08 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Sun, 20 Sep 2020 04:22:22 -0700 Subject: diff-lib: accept option flags in run_diff_index() In a future commit, we will teach run_diff_index() to accept more options via flag bits. For now, change `cached` into a flag in the `option` bitfield. The behaviour should remain exactly the same. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- builtin/diff-index.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'builtin/diff-index.c') diff --git a/builtin/diff-index.c b/builtin/diff-index.c index 93ec642423..c3878f7ad6 100644 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@ -15,7 +15,7 @@ COMMON_DIFF_OPTIONS_HELP; int cmd_diff_index(int argc, const char **argv, const char *prefix) { struct rev_info rev; - int cached = 0; + unsigned int option = 0; int i; int result; @@ -32,7 +32,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) const char *arg = argv[i]; if (!strcmp(arg, "--cached")) - cached = 1; + option |= DIFF_INDEX_CACHED; else usage(diff_cache_usage); } @@ -46,7 +46,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) if (rev.pending.nr != 1 || rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1) usage(diff_cache_usage); - if (!cached) { + if (!(option & DIFF_INDEX_CACHED)) { setup_work_tree(); if (read_cache_preload(&rev.diffopt.pathspec) < 0) { perror("read_cache_preload"); @@ -56,7 +56,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) perror("read_cache"); return -1; } - result = run_diff_index(&rev, cached); + result = run_diff_index(&rev, option); UNLEAK(rev); return diff_result_code(&rev.diffopt, result); } -- cgit v1.2.3