Subject: git-rebase eats empty commits

From: Michael J Gruber <[email-masked]>
Date: Tue, 08 Jul 2008 15:59:16 +0200

"git commit" allows empty commits with the "--allow-empty" option, i.e. 
commits which introduce no change at all. This is sometimes useful for 
keeping a log of untracked work related to tracked content.

"git rebase" removes empty commits, for the good reason that rebasing 
may make certain commits obsolete; but I don't want that in the case 
mentioned above. Is there any way to specify "--preserve-empty" or similar?

The attached script and log show the effect: a series A B C D of commits 
is rebased onto A'; the result is A' C', with the empty commits B and D 
disappearing.

grafts and filter-branch helped me solve a particular case of that 
effect, but I think it will show up again, so an option for rebase would 
be useful.

Michael

P.S.: I also noticed that 'Switched to a new branch "temp"' is written 
to stderr, everything else to stdout. Is that as intended?
Initialized empty Git repository in /tmp/mjg/t/empty/.git/
Created initial commit b3104c1: 1
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
Created commit 7265e0c: empty 1
Created commit 9b67221: 2
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 b
Created commit 0778af2: empty 2
0778af2a5003df310cb9dc3c4fff1f8992619610 empty 2
9b67221a363103ebc78fc052c382637a87ef04e6 2
7265e0c1a35c95bd6fcf739a9f815b300ba9d9cc empty 1
b3104c148e1dd6ce8fd23cddb71734e45e7d9132 1
Switched to a new branch "temp"
Created commit d9ad4bc: rewritten 1
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
First, rewinding head to replay your work on top of it...
Applying 2
d81ec616edd3ed600a60dbd63d4d0f4a7263387f 2
d9ad4bcd2fb5e78f2f430733f2dc36453a653221 rewritten 1