summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2020-09-20 11:22:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-21 04:30:26 (GMT)
commit0f5a1d449b9538c2765de9d6683abbb83a7fb4e2 (patch)
tree29cbd67c4138aed23542fb1030c3c718bba6ae9e /builtin
parentdf7dbab881c1aa697f0826d8d00f73d43815acf5 (diff)
downloadgit-0f5a1d449b9538c2765de9d6683abbb83a7fb4e2.zip
git-0f5a1d449b9538c2765de9d6683abbb83a7fb4e2.tar.gz
git-0f5a1d449b9538c2765de9d6683abbb83a7fb4e2.tar.bz2
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 <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/diff-index.c2
-rw-r--r--builtin/diff.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index c3878f7..7f5281c 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);
}
diff --git a/builtin/diff.c b/builtin/diff.c
index e45e19e..1baea18 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -139,6 +139,8 @@ static int builtin_diff_index(struct rev_info *revs,
const char *arg = argv[1];
if (!strcmp(arg, "--cached") || !strcmp(arg, "--staged"))
option |= DIFF_INDEX_CACHED;
+ else if (!strcmp(arg, "--merge-base"))
+ option |= DIFF_INDEX_MERGE_BASE;
else
usage(builtin_diff_usage);
argv++; argc--;