aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2017-01-02 16:26:53 +0100
committerJunio C Hamano <gitster@pobox.com>2017-01-09 14:57:29 -0800
commit556907f1e1057292e5cfc1f14e68167b43ff4761 (patch)
treed67318717a4c030a7625285b16ec63fa265f8b78
parent311af5266b27523742e8be9d8297ea475137cfb5 (diff)
downloadgit-556907f1e1057292e5cfc1f14e68167b43ff4761.tar.gz
git-556907f1e1057292e5cfc1f14e68167b43ff4761.tar.xz
sequencer (rebase -i): learn about the 'verbose' mode
When calling `git rebase -i -v`, the user wants to see some statistics after the commits were rebased. Let's show some. The strbuf we use to perform that task will be used for other things in subsequent commits, hence it is declared and initialized in a wider scope than strictly needed here. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sequencer.c28
-rw-r--r--sequencer.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c
index e9c10d7fe..ddc4d144d 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -65,6 +65,8 @@ static GIT_PATH_FUNC(rebase_path_stopped_sha, "rebase-merge/stopped-sha")
* command-line (and are only consumed, not modified, by the sequencer).
*/
static GIT_PATH_FUNC(rebase_path_gpg_sign_opt, "rebase-merge/gpg_sign_opt")
+static GIT_PATH_FUNC(rebase_path_orig_head, "rebase-merge/orig-head")
+static GIT_PATH_FUNC(rebase_path_verbose, "rebase-merge/verbose")
static inline int is_rebase_i(const struct replay_opts *opts)
{
@@ -1088,6 +1090,9 @@ static int read_populate_opts(struct replay_opts *opts)
}
strbuf_release(&buf);
+ if (file_exists(rebase_path_verbose()))
+ opts->verbose = 1;
+
return 0;
}
@@ -1491,9 +1496,32 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
}
if (is_rebase_i(opts)) {
+ struct strbuf buf = STRBUF_INIT;
+
/* Stopped in the middle, as planned? */
if (todo_list->current < todo_list->nr)
return 0;
+
+ if (opts->verbose) {
+ struct rev_info log_tree_opt;
+ struct object_id orig, head;
+
+ memset(&log_tree_opt, 0, sizeof(log_tree_opt));
+ init_revisions(&log_tree_opt, NULL);
+ log_tree_opt.diff = 1;
+ log_tree_opt.diffopt.output_format =
+ DIFF_FORMAT_DIFFSTAT;
+ log_tree_opt.disable_stdin = 1;
+
+ if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
+ !get_sha1(buf.buf, orig.hash) &&
+ !get_sha1("HEAD", head.hash)) {
+ diff_tree_sha1(orig.hash, head.hash,
+ "", &log_tree_opt.diffopt);
+ log_tree_diff_flush(&log_tree_opt);
+ }
+ }
+ strbuf_release(&buf);
}
/*
diff --git a/sequencer.h b/sequencer.h
index cb21cfdde..f885b6839 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -24,6 +24,7 @@ struct replay_opts {
int allow_empty;
int allow_empty_message;
int keep_redundant_commits;
+ int verbose;
int mainline;