summaryrefslogtreecommitdiff
path: root/builtin/diff.c
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2020-09-20 11:22:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-21 04:30:26 (GMT)
commit4c3fe82ef17a6636c742b95cd292b83b02876e08 (patch)
tree51656928a889f2b66241301f1ea87e450f6b8bbb /builtin/diff.c
parent308d7a7dc99043c90a9eff6916cad1abe0d473aa (diff)
downloadgit-4c3fe82ef17a6636c742b95cd292b83b02876e08.zip
git-4c3fe82ef17a6636c742b95cd292b83b02876e08.tar.gz
git-4c3fe82ef17a6636c742b95cd292b83b02876e08.tar.bz2
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 <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/diff.c')
-rw-r--r--builtin/diff.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/diff.c b/builtin/diff.c
index cb98811..e45e19e 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -134,11 +134,11 @@ static int builtin_diff_blobs(struct rev_info *revs,
static int builtin_diff_index(struct rev_info *revs,
int argc, const char **argv)
{
- int cached = 0;
+ unsigned int option = 0;
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--cached") || !strcmp(arg, "--staged"))
- cached = 1;
+ option |= DIFF_INDEX_CACHED;
else
usage(builtin_diff_usage);
argv++; argc--;
@@ -151,7 +151,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 (!cached) {
+ if (!(option & DIFF_INDEX_CACHED)) {
setup_work_tree();
if (read_cache_preload(&revs->diffopt.pathspec) < 0) {
perror("read_cache_preload");
@@ -161,7 +161,7 @@ static int builtin_diff_index(struct rev_info *revs,
perror("read_cache");
return -1;
}
- return run_diff_index(revs, cached);
+ return run_diff_index(revs, option);
}
static int builtin_diff_tree(struct rev_info *revs,