Re: [PATCH v6 4/4] git-rebase: add keep_empty flag
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:37
Neil Horman [off-list ref] writes:
Add a command line switch to git-rebase to allow a user the ability to specify that they want to keep any commits in a series that are empty. When git-rebase's type is am, then this option will automatically keep any commit that has a tree object identical to its parent. This patch changes the default behavior of interactive rebases as well. With this patch, git-rebase -i will produce a revision set passed to git-revision-editor, in which empty commits are commented out. Empty commits may be kept manually by uncommenting them. If the new --keep-empty option is used in an interactive rebase the empty commits will automatically all be uncommented in the editor. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> ---
The earlier one in the series seem to be getting solid enough. Nice.
quoted hunk ↗ jump to hunk
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 5812222..cef290b 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh@@ -167,6 +167,12 @@ has_action () { sane_grep '^[^#]' "$1" >/dev/null } +is_empty_commit() { + tree=$(git rev-parse "$1"^{tree}) + ptree=$(git rev-parse "$1"^^{tree}) + return $(test "$tree" = "$ptree") +}
Could "$1" ever be a root commit without a parent?