aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-12-01 21:41:42 +0900
committerJunio C Hamano <gitster@pobox.com>2018-12-01 21:41:42 +0900
commit881d72eff8b0d23c8edc6f8d9673f8daafaace6f (patch)
tree9858e8976d76dce70351bced3cc5edb6ea3cf1bb /builtin
parentMerge branch 'js/rebase-reflog-action-fix' (diff)
parentrebase --stat: fix when rebasing to an unrelated history (diff)
downloadgit-881d72eff8b0d23c8edc6f8d9673f8daafaace6f.tar.gz
git-881d72eff8b0d23c8edc6f8d9673f8daafaace6f.zip
Merge branch 'js/rebase-stat-unrelated-fix'
"git rebase --stat" to transplant a piece of history onto a totally unrelated history were not working before and silently showed wrong result. With the recent reimplementation in C, it started to instead die with an error message, as the original logic was not prepared to cope with this case. This has now been fixed. * js/rebase-stat-unrelated-fix: rebase --stat: fix when rebasing to an unrelated history
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rebase.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index ba0c3c954b..c87da417fb 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1503,10 +1503,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
if (options.flags & REBASE_DIFFSTAT) {
struct diff_options opts;
- if (options.flags & REBASE_VERBOSE)
- printf(_("Changes from %s to %s:\n"),
- oid_to_hex(&merge_base),
- oid_to_hex(&options.onto->object.oid));
+ if (options.flags & REBASE_VERBOSE) {
+ if (is_null_oid(&merge_base))
+ printf(_("Changes to %s:\n"),
+ oid_to_hex(&options.onto->object.oid));
+ else
+ printf(_("Changes from %s to %s:\n"),
+ oid_to_hex(&merge_base),
+ oid_to_hex(&options.onto->object.oid));
+ }
/* We want color (if set), but no pager */
diff_setup(&opts);
@@ -1516,8 +1521,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
opts.detect_rename = DIFF_DETECT_RENAME;
diff_setup_done(&opts);
- diff_tree_oid(&merge_base, &options.onto->object.oid,
- "", &opts);
+ diff_tree_oid(is_null_oid(&merge_base) ?
+ the_hash_algo->empty_tree : &merge_base,
+ &options.onto->object.oid, "", &opts);
diffcore_std(&opts);
diff_flush(&opts);
}