Skip to content

Commit 556907f

Browse files
dschogitster
authored andcommitted
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>
1 parent 311af52 commit 556907f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

sequencer.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ static GIT_PATH_FUNC(rebase_path_stopped_sha, "rebase-merge/stopped-sha")
6565
* command-line (and are only consumed, not modified, by the sequencer).
6666
*/
6767
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")
6870

6971
static inline int is_rebase_i(const struct replay_opts *opts)
7072
{
@@ -1088,6 +1090,9 @@ static int read_populate_opts(struct replay_opts *opts)
10881090
}
10891091
strbuf_release(&buf);
10901092

1093+
if (file_exists(rebase_path_verbose()))
1094+
opts->verbose = 1;
1095+
10911096
return 0;
10921097
}
10931098

@@ -1491,9 +1496,32 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
14911496
}
14921497

14931498
if (is_rebase_i(opts)) {
1499+
struct strbuf buf = STRBUF_INIT;
1500+
14941501
/* Stopped in the middle, as planned? */
14951502
if (todo_list->current < todo_list->nr)
14961503
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);
14971525
}
14981526

14991527
/*

sequencer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct replay_opts {
2424
int allow_empty;
2525
int allow_empty_message;
2626
int keep_redundant_commits;
27+
int verbose;
2728

2829
int mainline;
2930

0 commit comments

Comments
 (0)