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 --- diff.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'diff.h') diff --git a/diff.h b/diff.h index e0c0af6286..aea0d5b96b 100644 --- a/diff.h +++ b/diff.h @@ -585,7 +585,9 @@ const char *diff_aligned_abbrev(const struct object_id *sha1, int); /* report racily-clean paths as modified */ #define DIFF_RACY_IS_MODIFIED 02 int run_diff_files(struct rev_info *revs, unsigned int option); -int run_diff_index(struct rev_info *revs, int cached); + +#define DIFF_INDEX_CACHED 01 +int run_diff_index(struct rev_info *revs, unsigned int option); int do_diff_cache(const struct object_id *, struct diff_options *); int diff_flush_patch_id(struct diff_options *, struct object_id *, int, int); -- cgit v1.2.3 From 177a8302683da62a62b5b03e8192fcfa897db750 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Sun, 20 Sep 2020 04:22:23 -0700 Subject: diff-lib: define diff_get_merge_base() In a future commit, we will be using this function to implement --merge-base functionality in various diff commands. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- diff.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'diff.h') diff --git a/diff.h b/diff.h index aea0d5b96b..fedfeab7a2 100644 --- a/diff.h +++ b/diff.h @@ -580,6 +580,8 @@ void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc); */ const char *diff_aligned_abbrev(const struct object_id *sha1, int); +void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb); + /* do not report anything on removed paths */ #define DIFF_SILENT_ON_REMOVED 01 /* report racily-clean paths as modified */ -- cgit v1.2.3 From 0f5a1d449b9538c2765de9d6683abbb83a7fb4e2 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Sun, 20 Sep 2020 04:22:25 -0700 Subject: builtin/diff-index: learn --merge-base There is currently no easy way to take the diff between the working tree or index and the merge base between an arbitrary commit and HEAD. Even diff's `...` notation doesn't allow this because it only works between commits. However, the ability to do this would be desirable to a user who would like to see all the changes they've made on a branch plus uncommitted changes without taking into account changes made in the upstream branch. Teach diff-index and diff (with one commit) the --merge-base option which allows a user to use the merge base of a commit and HEAD as the "before" side. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- diff.h | 1 + 1 file changed, 1 insertion(+) (limited to 'diff.h') diff --git a/diff.h b/diff.h index fedfeab7a2..6c2efa16fd 100644 --- a/diff.h +++ b/diff.h @@ -589,6 +589,7 @@ void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb); int run_diff_files(struct rev_info *revs, unsigned int option); #define DIFF_INDEX_CACHED 01 +#define DIFF_INDEX_MERGE_BASE 02 int run_diff_index(struct rev_info *revs, unsigned int option); int do_diff_cache(const struct object_id *, struct diff_options *); -- cgit v1.2.3