git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 0/4] Enhance git-rebases flexibiilty in handling empty commits

From
Neil Horman <nhorman@tuxdriver.com>
Date
Apr 11, 2012, 20:21 UTC
Message-ID
<1334175716-11391-1-git-send-email-nhorman@tuxdriver.com>

git's ability to handle empty commits is somewhat lacking, especially when preforming a rebase. Nominally empty commits are undesireable entries, the result of commits that are made empty by prior commits covering the same changs. But occasionally, empty commits are useful to developers (e.g. inserting notes into the development history without changing any code along the way). In these cases its desireable to easily preserve empty commits during operations like rebases.

This patch series enhances git to do just that. It adds two options to the git-cherry-pick command, --allow-empty, which allows git cherry-pick to preserve an empty commit, even if the fast forward logic isn't applicable during the operation, and --keep-redundant-commits, which allows the user to also keep commits that were made empty via conflict resolution. It also enhances git-rebase to add a --keep-empty option which enables rebases to preserve empty commits.

I've tested these operations out myself here and they work well for me
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

--- Change notes:

Based on version 1 feedback from this list, the following changes have been made
V2)
	* Changed --keep-empty to --allow-empty in the git cherry-pick command
	* Converted run_git_commit to use argv_array
	* Updated cherry-pick --allow-empty description in man page
	
	* added ignore-if-made-empty option to git-cherry-pick
	* Added test to test suite to validate the new cherry-pick options
	* Updated git-rebase man page to be less verbose and more accurate in the
	description of the keep-empty option
	* squashed the addition of the keep-empty flag in git-rebase down to one
	commit from 3
	* fixed up coding style in git-rebase script
	* Optimized detection of empty commits
	* Only augmented git-rebase-editor message if empty commits are
	possible
	
V3)
	* reversed the --ignore-if-empty-logic to by default only keep initially
	empty commits
	* replaced --ignore-if-empty with --keep-redundant-commits, to allow
	empty commits that are made empty via conflict resolution, in addition
	to commits that were created as empty
	* reworked is_original_commit_empty to be more efficient and portable
	* Misc sylistic and spelling cleanups
V4)
	* Reverted the cherry-pick advice changes in V3 based on in-thread
	discussion
	* Rewrote my changes to is_original_commit_empty and run_git_commit to
	not have to fork, making them more efficient.
Next: Neil Horman
Message 1 of 16 in “Enhance git-rebases flexibiilty in handling empty commits”
  1. 0/4 Enhance git-rebases flexibiilty in handling empty commitsNeil Horman, Apr 11, 2012
  2. 1/4 git-cherry-pick: add allow-empty optionNeil Horman, Apr 11, 2012
  3. 2/4 git-cherry-pick: Add keep-redundant-commits optionNeil Horman, Apr 11, 2012
  4. Junio C HamanoApr 11, 2012
  5. Neil HormanApr 11, 2012
  6. Junio C HamanoApr 11, 2012
  7. Neil HormanApr 11, 2012
  8. Junio C HamanoApr 12, 2012
  9. Neil HormanApr 12, 2012
  10. 3/4 git-cherry-pick: Add test to validate new optionsNeil Horman, Apr 11, 2012
  11. Junio C HamanoApr 11, 2012
  12. 4/4 git-rebase: add keep_empty flagNeil Horman, Apr 11, 2012
  13. Junio C HamanoApr 11, 2012
  14. Neil HormanApr 11, 2012
  15. Junio C HamanoApr 12, 2012
  16. Neil HormanApr 12, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.