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>
Johannes Schindelin committed
Jan 2, 2017 at 16:26 UTC
556907f1e1057292e5cfc1f14e68167b43ff4761
2 files changed
+29
sequencer.c
+28
@@ -65,6 +65,8 @@ static GIT_PATH_FUNC(rebase_path_stopped_sha, "rebase-merge/stopped-sha")
65
* command-line (and are only consumed, not modified, by the sequencer).
66
*/
67
static GIT_PATH_FUNC(rebase_path_gpg_sign_opt, "rebase-merge/gpg_sign_opt")
68
+static GIT_PATH_FUNC(rebase_path_orig_head, "rebase-merge/orig-head")
69
+static GIT_PATH_FUNC(rebase_path_verbose, "rebase-merge/verbose")
70
71
static inline int is_rebase_i(const struct replay_opts *opts)
72
{
@@ -1088,6 +1090,9 @@ static int read_populate_opts(struct replay_opts *opts)
1090
}
1091
strbuf_release(&buf);
1092
1093
+ if (file_exists(rebase_path_verbose()))
1094
+ opts->verbose = 1;
1095
+
1096
return 0;
1097
}
1098
@@ -1491,9 +1496,32 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
1496
}
1497
1498
if (is_rebase_i(opts)) {
1499
+ struct strbuf buf = STRBUF_INIT;
1500
+
1501
/* Stopped in the middle, as planned? */
1502
if (todo_list->current < todo_list->nr)
1503
return 0;
1504
+
1505
+ if (opts->verbose) {
1506
+ struct rev_info log_tree_opt;
1507
+ struct object_id orig, head;
1508
+
1509
+ memset(&log_tree_opt, 0, sizeof(log_tree_opt));
1510
+ init_revisions(&log_tree_opt, NULL);
1511
+ log_tree_opt.diff = 1;
1512
+ log_tree_opt.diffopt.output_format =
1513
+ DIFF_FORMAT_DIFFSTAT;
1514
+ log_tree_opt.disable_stdin = 1;
1515
+
1516
+ if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
1517
+ !get_sha1(buf.buf, orig.hash) &&
1518
+ !get_sha1("HEAD", head.hash)) {
1519
+ diff_tree_sha1(orig.hash, head.hash,
1520
+ "", &log_tree_opt.diffopt);
1521
+ log_tree_diff_flush(&log_tree_opt);
1522
+ }
1523
+ }
1524
+ strbuf_release(&buf);
1525
}
1526
1527
/*
sequencer.h
+1
@@ -24,6 +24,7 @@ struct replay_opts {
24
int allow_empty;
25
int allow_empty_message;
26
int keep_redundant_commits;
27
+ int verbose;
28
29
int mainline;
30