diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-04-22 23:43:00 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-04-22 23:43:00 +0300 |
commit | c7d8f69da5443788950b823bd6b9b663e1e686a3 (patch) | |
tree | 3be858fe8fbafd1871eb49ff3de45c90568d82f0 /sequencer.c | |
parent | 8b39dfdf47ee2d7a2afd1ff9932c09ad5b00076b (diff) | |
parent | 50ed76148a96d6cf37549c0492e6da1ff85b9bd0 (diff) |
Merge branch 'en/rebase-no-keep-empty'
"git rebase" (again) learns to honor "--no-keep-empty", which lets
the user to discard commits that are empty from the beginning (as
opposed to the ones that become empty because of rebasing). The
interactive rebase also marks commits that are empty in the todo.
* en/rebase-no-keep-empty:
rebase: fix an incompatible-options error message
rebase: reinstate --no-keep-empty
rebase -i: mark commits that begin empty in todo editor
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c index 51b00bc136..ce28cad60a 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4615,6 +4615,7 @@ static int make_script_with_merges(struct pretty_print_context *pp, struct rev_info *revs, struct strbuf *out, unsigned flags) { + int keep_empty = flags & TODO_LIST_KEEP_EMPTY; int rebase_cousins = flags & TODO_LIST_REBASE_COUSINS; int root_with_onto = flags & TODO_LIST_ROOT_WITH_ONTO; struct strbuf buf = STRBUF_INIT, oneline = STRBUF_INIT; @@ -4669,6 +4670,8 @@ static int make_script_with_merges(struct pretty_print_context *pp, is_empty = is_original_commit_empty(commit); if (!is_empty && (commit->object.flags & PATCHSAME)) continue; + if (is_empty && !keep_empty) + continue; strbuf_reset(&oneline); pretty_print_commit(pp, commit, &oneline); @@ -4680,6 +4683,9 @@ static int make_script_with_merges(struct pretty_print_context *pp, strbuf_addf(&buf, "%s %s %s", cmd_pick, oid_to_hex(&commit->object.oid), oneline.buf); + if (is_empty) + strbuf_addf(&buf, " %c empty", + comment_line_char); FLEX_ALLOC_STR(entry, string, buf.buf); oidcpy(&entry->entry.oid, &commit->object.oid); @@ -4843,6 +4849,7 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc, struct pretty_print_context pp = {0}; struct rev_info revs; struct commit *commit; + int keep_empty = flags & TODO_LIST_KEEP_EMPTY; const char *insn = flags & TODO_LIST_ABBREVIATE_CMDS ? "p" : "pick"; int rebase_merges = flags & TODO_LIST_REBASE_MERGES; @@ -4882,9 +4889,13 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc, if (!is_empty && (commit->object.flags & PATCHSAME)) continue; + if (is_empty && !keep_empty) + continue; strbuf_addf(out, "%s %s ", insn, oid_to_hex(&commit->object.oid)); pretty_print_commit(&pp, commit, out); + if (is_empty) + strbuf_addf(out, " %c empty", comment_line_char); strbuf_addch(out, '\n'); } return 0; |