git-commit-vandalism/Documentation
Elijah Newren e98c4269c8 rebase (interactive-backend): fix handling of commits that become empty
As established in the previous commit and commit b00bf1c9a8
(git-rebase: make --allow-empty-message the default, 2018-06-27), the
behavior for rebase with different backends in various edge or corner
cases is often more happenstance than design.  This commit addresses
another such corner case: commits which "become empty".

A careful reader may note that there are two types of commits which would
become empty due to a rebase:

  * [clean cherry-pick] Commits which are clean cherry-picks of upstream
    commits, as determined by `git log --cherry-mark ...`.  Re-applying
    these commits would result in an empty set of changes and a
    duplicative commit message; i.e. these are commits that have
    "already been applied" upstream.

  * [become empty] Commits which are not empty to start, are not clean
    cherry-picks of upstream commits, but which still become empty after
    being rebased.  This happens e.g. when a commit has changes which
    are a strict subset of the changes in an upstream commit, or when
    the changes of a commit can be found spread across or among several
    upstream commits.

Clearly, in both cases the changes in the commit in question are found
upstream already, but the commit message may not be in the latter case.

When cherry-mark can determine a commit is already upstream, then
because of how cherry-mark works this means the upstream commit message
was about the *exact* same set of changes.  Thus, the commit messages
can be assumed to be fully interchangeable (and are in fact likely to be
completely identical).  As such, the clean cherry-pick case represents a
case when there is no information to be gained by keeping the extra
commit around.  All rebase types have always dropped these commits, and
no one to my knowledge has ever requested that we do otherwise.

For many of the become empty cases (and likely even most), we will also
be able to drop the commit without loss of information -- but this isn't
quite always the case.  Since these commits represent cases that were
not clean cherry-picks, there is no upstream commit message explaining
the same set of changes.  Projects with good commit message hygiene will
likely have the explanation from our commit message contained within or
spread among the relevant upstream commits, but not all projects run
that way.  As such, the commit message of the commit being rebased may
have reasoning that suggests additional changes that should be made to
adapt to the new base, or it may have information that someone wants to
add as a note to another commit, or perhaps someone even wants to create
an empty commit with the commit message as-is.

Junio commented on the "become-empty" types of commits as follows[1]:

    WRT a change that ends up being empty (as opposed to a change that
    is empty from the beginning), I'd think that the current behaviour
    is desireable one.  "am" based rebase is solely to transplant an
    existing history and want to stop much less than "interactive" one
    whose purpose is to polish a series before making it publishable,
    and asking for confirmation ("this has become empty--do you want to
    drop it?") is more appropriate from the workflow point of view.

[1] https://lore.kernel.org/git/xmqqfu1fswdh.fsf@gitster-ct.c.googlers.com/

I would simply add that his arguments for "am"-based rebases actually
apply to all non-explicitly-interactive rebases.  Also, since we are
stating that different cases should have different defaults, it may be
worth providing a flag to allow users to select which behavior they want
for these commits.

Introduce a new command line flag for selecting the desired behavior:
    --empty={drop,keep,ask}
with the definitions:
    drop: drop commits which become empty
    keep: keep commits which become empty
    ask:  provide the user a chance to interact and pick what to do with
          commits which become empty on a case-by-case basis

In line with Junio's suggestion, if the --empty flag is not specified,
pick defaults as follows:
    explicitly interactive: ask
    otherwise: drop

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-02-16 15:40:42 -08:00
..
config Merge branch 'ma/config-advice-markup-fix' 2020-01-10 14:45:26 -08:00
howto Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
RelNotes Revert "Merge branch 'ra/rebase-i-more-options'" 2020-01-12 13:25:18 -08:00
technical Merge branch 'jb/doc-multi-pack-idx-fix' 2020-01-08 12:44:12 -08:00
.gitattributes
.gitignore Merge branch 'js/misc-doc-fixes' 2019-05-09 00:37:27 +09:00
asciidoc.conf Doc/Makefile: give mansource/-version/-manual attributes 2019-09-16 12:27:34 -07:00
asciidoctor-extensions.rb Merge branch 'ma/user-manual-markup-update' 2019-10-06 12:25:16 +09:00
blame-options.txt blame: add config options for the output of ignored or unblamable lines 2019-05-16 11:36:23 +09:00
build-docdep.perl
cat-texi.perl
cmd-list.perl
CodingGuidelines Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
config.txt Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
date-formats.txt
diff-format.txt doc: indent multi-line items in list 2019-12-13 12:18:07 -08:00
diff-generate-patch.txt diff, log doc: small grammer, format, and language fixes 2019-09-17 12:14:06 -07:00
diff-options.txt Merge branch 'nd/diff-parseopt-3' 2019-04-16 19:28:03 +09:00
doc-diff doc-diff: replace --cut-header-footer with --cut-footer 2019-09-16 12:27:38 -07:00
docbook-xsl.css
docbook.xsl
everyday.txto
fetch-options.txt fetch: add the command-line option --write-commit-graph 2019-11-06 10:59:36 +09:00
fix-texi.perl
git-add.txt add: support the --pathspec-from-file option 2019-12-04 10:10:37 -08:00
git-am.txt Merge branch 'pm/am-in-body-header-doc-update' 2020-01-08 12:44:12 -08:00
git-annotate.txt
git-apply.txt
git-archimport.txt
git-archive.txt
git-bisect-lk2009.txt Merge branch 'dl/lore-is-the-archive' 2019-12-06 15:09:24 -08:00
git-bisect.txt Documentation/git-bisect.txt: add --no-ff to merge command 2019-10-29 11:53:56 +09:00
git-blame.txt blame: add the ability to ignore commits and their changes 2019-05-16 11:36:23 +09:00
git-branch.txt Merge branch 'po/doc-branch' into maint 2019-07-29 12:38:16 -07:00
git-bundle.txt Merge branch 'po/bundle-doc-clonable' 2019-12-10 13:11:41 -08:00
git-cat-file.txt
git-check-attr.txt Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
git-check-ignore.txt Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
git-check-mailmap.txt
git-check-ref-format.txt
git-checkout-index.txt
git-checkout.txt checkout, restore: support the --pathspec-from-file option 2019-12-04 10:10:37 -08:00
git-cherry-pick.txt cherry-pick/revert: add --skip option 2019-07-02 12:08:08 -07:00
git-cherry.txt
git-citool.txt
git-clean.txt Merge branch 'en/clean-nested-with-ignored' 2019-10-11 14:24:46 +09:00
git-clone.txt Merge branch 'ja/doc-markup-cleanup' 2019-12-25 11:22:00 -08:00
git-column.txt
git-commit-graph.txt test-tool: use 'read-graph' helper 2019-11-13 11:14:16 +09:00
git-commit-tree.txt
git-commit.txt commit: support the --pathspec-from-file option 2019-11-20 13:01:53 +09:00
git-config.txt Documentation: wrap config listings in "----" 2019-09-09 11:05:51 -07:00
git-count-objects.txt
git-credential-cache--daemon.txt
git-credential-cache.txt
git-credential-store.txt
git-credential.txt credential: move doc to credential.h 2019-11-18 15:21:29 +09:00
git-cvsexportcommit.txt
git-cvsimport.txt
git-cvsserver.txt Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
git-daemon.txt
git-describe.txt
git-diff-files.txt
git-diff-index.txt
git-diff-tree.txt
git-diff.txt git-diff.txt: document return code of --no-index 2019-11-02 13:16:41 +09:00
git-difftool.txt difftool: fallback on merge.guitool 2019-05-13 23:11:59 +09:00
git-fast-export.txt Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
git-fast-import.txt Sync with 2.23.1 2019-12-06 16:31:39 +01:00
git-fetch-pack.txt
git-fetch.txt doc: typo: s/can not/cannot/ and s/is does/does/ 2019-08-05 10:05:24 -07:00
git-filter-branch.txt Merge branch 'ja/doc-markup-cleanup' 2019-12-25 11:22:00 -08:00
git-fmt-merge-msg.txt
git-for-each-ref.txt ref-filter: add worktreepath atom 2019-05-07 13:45:53 +09:00
git-format-patch.txt format-patch: teach --no-base 2019-12-05 06:06:18 -08:00
git-fsck-objects.txt
git-fsck.txt Documentation/git-fsck.txt: include fsck.* config variables 2019-07-29 10:41:18 -07:00
git-gc.txt Recommend git-filter-repo instead of git-filter-branch 2019-09-05 13:01:48 -07:00
git-get-tar-commit-id.txt
git-grep.txt grep: make the behavior for NUL-byte in patterns sane 2019-07-01 14:33:14 -07:00
git-gui.txt Documentation: update the location of the git-gui repo 2019-10-06 09:45:02 +09:00
git-hash-object.txt hash-object doc: stop mentioning git-cvsimport 2019-05-28 10:47:42 -07:00
git-help.txt
git-http-backend.txt
git-http-fetch.txt
git-http-push.txt
git-imap-send.txt
git-index-pack.txt
git-init-db.txt
git-init.txt
git-instaweb.txt
git-interpret-trailers.txt
git-log.txt Merge branch 'pb/clarify-line-log-doc' 2020-01-06 14:17:50 -08:00
git-ls-files.txt doc/ls-files: put nested list for "-t" option into block 2019-04-23 10:25:04 +09:00
git-ls-remote.txt git-ls-remote.txt: wrap shell listing in "----" 2019-09-09 11:05:52 -07:00
git-ls-tree.txt
git-mailinfo.txt
git-mailsplit.txt
git-merge-base.txt git-merge-base.txt: render indentations correctly under Asciidoctor 2019-09-09 11:05:51 -07:00
git-merge-file.txt
git-merge-index.txt git-merge-index.txt: wrap shell listing in "----" 2019-09-09 11:05:52 -07:00
git-merge-one-file.txt
git-merge-tree.txt
git-merge.txt merge: do no-verify like commit 2019-08-07 12:37:33 -07:00
git-mergetool--lib.txt mergetool: use get_merge_tool function 2019-05-13 23:11:59 +09:00
git-mergetool.txt mergetool: fallback to tool when guitool unavailable 2019-05-13 23:11:59 +09:00
git-mktag.txt
git-mktree.txt
git-multi-pack-index.txt multi-pack-index: add [--[no-]progress] option. 2019-10-23 12:05:06 +09:00
git-mv.txt
git-name-rev.txt
git-notes.txt notes: fix minimum number of parameters to "copy" subcommand 2019-10-18 09:43:10 +09:00
git-p4.txt
git-pack-objects.txt doc: fix repeated words 2019-08-11 17:40:07 -07:00
git-pack-redundant.txt
git-pack-refs.txt
git-parse-remote.txt
git-patch-id.txt
git-prune-packed.txt
git-prune.txt
git-pull.txt doc: typo: s/can not/cannot/ and s/is does/does/ 2019-08-05 10:05:24 -07:00
git-push.txt doc: fix repeated words 2019-08-11 17:40:07 -07:00
git-quiltimport.txt
git-range-diff.txt Merge branch 'dl/range-diff-with-notes' 2019-12-05 12:52:44 -08:00
git-read-tree.txt sparse-checkout: create builtin with 'list' subcommand 2019-11-22 16:11:43 +09:00
git-rebase.txt rebase (interactive-backend): fix handling of commits that become empty 2020-02-16 15:40:42 -08:00
git-receive-pack.txt git-receive-pack.txt: wrap shell [script] listing in "----" 2019-09-09 11:05:52 -07:00
git-reflog.txt
git-remote-ext.txt Merge branch 'js/check-docs-exe' 2019-04-22 11:14:46 +09:00
git-remote-fd.txt
git-remote-helpers.txto
git-remote.txt
git-repack.txt doc: fix repeated words 2019-08-11 17:40:07 -07:00
git-replace.txt Recommend git-filter-repo instead of git-filter-branch 2019-09-05 13:01:48 -07:00
git-request-pull.txt
git-rerere.txt Merge branch 'nd/switch-and-restore' 2019-07-09 15:25:44 -07:00
git-reset.txt reset: support the --pathspec-from-file option 2019-11-20 13:01:53 +09:00
git-restore.txt checkout, restore: support the --pathspec-from-file option 2019-12-04 10:10:37 -08:00
git-rev-list.txt git-rev-list.txt: prune options in synopsis 2019-10-06 09:45:19 +09:00
git-rev-parse.txt rev-parse: make --show-toplevel without a worktree an error 2019-11-20 10:19:58 +09:00
git-revert.txt Merge branch 'ra/cherry-pick-revert-skip' 2019-07-19 11:30:21 -07:00
git-rm.txt
git-send-email.txt Documentation: wrap config listings in "----" 2019-09-09 11:05:51 -07:00
git-send-pack.txt
git-sh-i18n--envsubst.txt
git-sh-i18n.txt
git-sh-setup.txt
git-shell.txt
git-shortlog.txt git-shortlog.txt: include commit limiting options 2019-11-10 15:13:23 +09:00
git-show-branch.txt
git-show-index.txt
git-show-ref.txt
git-show.txt
git-sparse-checkout.txt Merge branch 'ds/sparse-cone' 2020-01-06 14:17:51 -08:00
git-stage.txt
git-stash.txt doc(stash): clarify the description of save 2019-10-11 14:28:04 +09:00
git-status.txt Documentation: wrap blocks with "--" 2019-09-09 11:05:51 -07:00
git-stripspace.txt
git-submodule.txt Merge branch 'tm/doc-submodule-absorb-fix' 2020-01-08 12:44:12 -08:00
git-svn.txt git svn: stop using rebase --preserve-merges 2019-11-23 09:49:23 +09:00
git-switch.txt Declare both git-switch and git-restore experimental 2019-05-07 13:04:48 +09:00
git-symbolic-ref.txt
git-tag.txt Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
git-tools.txt
git-unpack-file.txt
git-unpack-objects.txt
git-update-index.txt Merge branch 'en/doc-typofix' 2019-12-01 09:04:35 -08:00
git-update-ref.txt
git-update-server-info.txt update-server-info: avoid needless overwrites 2019-05-15 14:07:37 +09:00
git-upload-archive.txt
git-upload-pack.txt
git-var.txt
git-verify-commit.txt
git-verify-pack.txt
git-verify-tag.txt
git-web--browse.txt
git-whatchanged.txt
git-worktree.txt
git-write-tree.txt
git.txt Merge branch 'ds/commit-graph-delay-gen-progress' 2019-12-10 13:11:43 -08:00
gitattributes.txt Merge branch 'ln/userdiff-elixir' 2019-12-01 09:04:36 -08:00
gitcli.txt Merge branch 'dl/lore-is-the-archive' 2019-12-06 15:09:24 -08:00
gitcore-tutorial.txt
gitcredentials.txt credential: move doc to credential.h 2019-11-18 15:21:29 +09:00
gitcvs-migration.txt
gitdiffcore.txt
giteveryday.txt doc: promote "git restore" 2019-05-07 13:04:48 +09:00
gitglossary.txt
githooks.txt Merge branch 'en/filter-branch-deprecation' 2019-09-30 13:19:29 +09:00
gitignore.txt Merge branch 'an/ignore-doc-update' into maint 2019-07-25 14:27:13 -07:00
gitk.txt doc: log, gitk: line-log arguments must exist in starting revision 2019-12-26 11:00:15 -08:00
gitmodules.txt Merge branch 'pb/submodule-doc-xref' 2019-12-25 11:21:59 -08:00
gitnamespaces.txt
gitremote-helpers.txt Merge branch 'bc/smart-http-atomic-push' 2019-10-23 14:43:11 +09:00
gitrepository-layout.txt Merge branch 'sg/dir-trie-fixes' 2019-11-10 18:02:14 +09:00
gitrevisions.txt
gitsubmodules.txt help: add gitsubmodules to the list of guides 2019-10-29 12:41:05 +09:00
gittutorial-2.txt doc: promote "git restore" 2019-05-07 13:04:48 +09:00
gittutorial.txt doc: promote "git restore" 2019-05-07 13:04:48 +09:00
gitweb.conf.txt gitweb.conf.txt: switch pluses to backticks to help Asciidoctor 2019-09-09 11:05:52 -07:00
gitweb.txt doc: don't use git.kernel.org as example gitweb URL 2019-06-24 12:37:21 -07:00
gitworkflows.txt
glossary-content.txt doc: typo: s/can not/cannot/ and s/is does/does/ 2019-08-05 10:05:24 -07:00
howto-index.sh
i18n.txt
install-doc-quick.sh
install-webdoc.sh
line-range-format.txt
lint-gitlink.perl
mailmap.txt
Makefile Merge branch 'es/walken-tutorial' 2019-11-10 18:02:11 +09:00
manpage-1.72.xsl
manpage-base-url.xsl.in
manpage-base.xsl
manpage-bold-literal.xsl manpage-bold-literal.xsl: match for namespaced "d:literal" in template 2019-11-02 14:46:42 +09:00
manpage-normal.xsl
manpage-quote-apos.xsl
manpage-suppress-sp.xsl
manpage.xsl Documentation: fix build with Asciidoctor 2 2019-09-16 12:20:39 -07:00
merge-options.txt Documentation: fix a bunch of typos, both old and new 2019-11-07 13:42:00 +09:00
merge-strategies.txt merge-strategies: fix typo "reflected to" to "reflected in" 2019-11-11 11:04:46 +09:00
MyFirstContribution.txt Merge branch 'jk/lore-is-the-archive' 2019-12-06 15:09:23 -08:00
MyFirstObjectWalk.txt cache: move doc to cache.h 2019-11-18 15:21:29 +09:00
pretty-formats.txt Merge branch 'dl/pretty-reference' 2019-12-10 13:11:43 -08:00
pretty-options.txt Merge branch 'dl/pretty-reference' 2019-12-10 13:11:43 -08:00
pull-fetch-param.txt
rev-list-options.txt Merge branch 'dl/pretty-reference' 2019-12-10 13:11:43 -08:00
revisions.txt Merge branch 'nd/switch-and-restore' 2019-07-09 15:25:44 -07:00
sequencer.txt cherry-pick/revert: add --skip option 2019-07-02 12:08:08 -07:00
SubmittingPatches Merge branch 'dl/pretty-reference' 2019-12-10 13:11:43 -08:00
texi.xsl
trace2-target-values.txt docs: mention trace2 target-dir mode in git-config 2019-10-04 09:26:42 +09:00
transfer-data-leaks.txt
urls-remotes.txt
urls.txt Doc: Bundle file usage 2019-10-21 12:02:39 +09:00
user-manual.conf
user-manual.txt Merge branch 'dl/lore-is-the-archive' 2019-12-06 15:09:24 -08:00