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 --- builtin/diff-index.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'builtin/diff-index.c') diff --git a/builtin/diff-index.c b/builtin/diff-index.c index c3878f7ad6..7f5281c461 100644 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@ -33,6 +33,8 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) if (!strcmp(arg, "--cached")) option |= DIFF_INDEX_CACHED; + else if (!strcmp(arg, "--merge-base")) + option |= DIFF_INDEX_MERGE_BASE; else usage(diff_cache_usage); } -- cgit v1.2.3