Re: [PATCH RFC v2 02/19] rebase -i: reword complains about empty commit despite --keep-empty

2014-07-09 Thread Fabian Ruch
Junio C Hamano writes:
 Fabian Ruch baf...@gmail.com writes:
 Subject: rebase -i: reword complains about empty commit despite --keep-empty
 
 I had to read the title and then the log twice before understanding
 that the above is not change the complaint message (i.e. reword
 complaints spelled incorrectly) but is a description of the current
 behaviour (i.e. the command complains when 'reword' is used on an
 empty commit) that is not accompanied by an evaluation (ok, it
 complains; are you saying it is a good thing or a bad thing?) or an
 action (if it is a bad thing, what are you doing about it?).
 
 Perhaps
 
   rebase -i: allow rewording an empty commit
 
 or something?

I thought ...despite --keep-empty would already imply that reword
complains about empty commit is not supposed to happen, the action
would have been obvious. However, I understand that --keep-empty is
first of all concerned with which commits of $upstream...$orig_head end
up on the initial to-do list and the git-rebase manual page doesn't
mention that it picks commits using the --allow-empty option. It is
simply a necessity of a script not to complain about something it put on
the to-do list itself.

The subject reads now

rebase -i: allow rewording an empty commit without complaints

trying to convey that this is not a new feature but a bug fix.

   Fabian
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RFC v2 02/19] rebase -i: reword complains about empty commit despite --keep-empty

2014-07-08 Thread Junio C Hamano
Fabian Ruch baf...@gmail.com writes:

 Subject: rebase -i: reword complains about empty commit despite --keep-empty

I had to read the title and then the log twice before understanding
that the above is not change the complaint message (i.e. reword
complaints spelled incorrectly) but is a description of the current
behaviour (i.e. the command complains when 'reword' is used on an
empty commit) that is not accompanied by an evaluation (ok, it
complains; are you saying it is a good thing or a bad thing?) or an
action (if it is a bad thing, what are you doing about it?).

Perhaps

rebase -i: allow rewording an empty commit

or something?

 The to-do list command `reword` replays a commit like `pick` but lets
 the user also edit the commit's log message. If `--keep-empty` is
 passed as option to git-rebase--interactive, empty commits ought to
 be replayed without complaints. However, if the users chooses to
 reword an empty commit by changing the respective to-do list entry
 from

 pick fa1afe1 Empty commit

 to

 reword fa1afe1 Empty commit

 , then git-rebase--interactive suddenly fails to replay the empty
 commit. This is especially counterintuitive because `reword` is
 thought of as a `pick` that alters the log message in some way but
 nothing more and the unchanged to-do list entry would not fail.

 Handle `reword` by cherry-picking the named commit and editing the
 log message using

 git commit --allow-empty --amend

 instead of

 git commit --amend.

 Add test.

 Signed-off-by: Fabian Ruch baf...@gmail.com
 ---
  git-rebase--interactive.sh| 2 +-
  t/t3404-rebase-interactive.sh | 8 
  2 files changed, 9 insertions(+), 1 deletion(-)

 diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
 index e733d7f..689400e 100644
 --- a/git-rebase--interactive.sh
 +++ b/git-rebase--interactive.sh
 @@ -504,7 +504,7 @@ do_next () {
  
   mark_action_done
   do_pick $sha1 $rest
 - git commit --amend --no-post-rewrite 
 ${gpg_sign_opt:+$gpg_sign_opt} || {
 + git commit --allow-empty --amend --no-post-rewrite 
 ${gpg_sign_opt:+$gpg_sign_opt} || {
   warn Could not amend commit after successfully picking 
 $sha1... $rest
   exit_with_patch $sha1 1
   }
 diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
 index 8197ed2..9931143 100755
 --- a/t/t3404-rebase-interactive.sh
 +++ b/t/t3404-rebase-interactive.sh
 @@ -75,6 +75,14 @@ test_expect_success 'rebase --keep-empty' '
   test_line_count = 6 actual
  '
  
 +test_expect_success 'rebase --keep-empty' '
 + git checkout emptybranch 
 + set_fake_editor 
 + FAKE_LINES=1 reword 2 git rebase --keep-empty -i HEAD~2 
 + git log --oneline actual 
 + test_line_count = 6 actual
 +'
 +
  test_expect_success 'rebase -i with the exec command' '
   git checkout master 
   (
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC v2 02/19] rebase -i: reword complains about empty commit despite --keep-empty

2014-07-02 Thread Fabian Ruch
The to-do list command `reword` replays a commit like `pick` but lets
the user also edit the commit's log message. If `--keep-empty` is
passed as option to git-rebase--interactive, empty commits ought to
be replayed without complaints. However, if the users chooses to
reword an empty commit by changing the respective to-do list entry
from

pick fa1afe1 Empty commit

to

reword fa1afe1 Empty commit

, then git-rebase--interactive suddenly fails to replay the empty
commit. This is especially counterintuitive because `reword` is
thought of as a `pick` that alters the log message in some way but
nothing more and the unchanged to-do list entry would not fail.

Handle `reword` by cherry-picking the named commit and editing the
log message using

git commit --allow-empty --amend

instead of

git commit --amend.

Add test.

Signed-off-by: Fabian Ruch baf...@gmail.com
---
 git-rebase--interactive.sh| 2 +-
 t/t3404-rebase-interactive.sh | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index e733d7f..689400e 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -504,7 +504,7 @@ do_next () {
 
mark_action_done
do_pick $sha1 $rest
-   git commit --amend --no-post-rewrite 
${gpg_sign_opt:+$gpg_sign_opt} || {
+   git commit --allow-empty --amend --no-post-rewrite 
${gpg_sign_opt:+$gpg_sign_opt} || {
warn Could not amend commit after successfully picking 
$sha1... $rest
exit_with_patch $sha1 1
}
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 8197ed2..9931143 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -75,6 +75,14 @@ test_expect_success 'rebase --keep-empty' '
test_line_count = 6 actual
 '
 
+test_expect_success 'rebase --keep-empty' '
+   git checkout emptybranch 
+   set_fake_editor 
+   FAKE_LINES=1 reword 2 git rebase --keep-empty -i HEAD~2 
+   git log --oneline actual 
+   test_line_count = 6 actual
+'
+
 test_expect_success 'rebase -i with the exec command' '
git checkout master 
(
-- 
2.0.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html