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

[PATCH] rebase -i: fix has_action

From
NRNoe Rubinstein <nrubinstein@proformatique.com>
Date
Aug 4, 2011, 09:39 UTC
Message-ID
<1312450780-5021-1-git-send-email-nrubinstein@proformatique.com>

When doing git rebase -i, removing all actions in the todo list is supposed to result in aborting the rebase. However, if there are spaces at the beginning of an empty line, has_action returns true and the rebase therefore removes all commits. This is probably not what a user leaving a space on an empty line expects.

This patch fixes the bug by changing has_action to grep any line containing anything that is not a space nor a #.

Signed-off-by: Noe Rubinstein <nrubinstein@proformatique.com>
---
 git-rebase--interactive.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c6ba7c1..bed79af 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -149,7 +149,7 @@ die_abort () {
 }
 
 has_action () {
-	sane_grep '^[^#]' "$1" >/dev/null
+	sane_grep '^[^#[:space:]]' "$1" >/dev/null
 }
 
 # Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
-- 
Noé Rubinstein
Avencall - XiVO IPBX OpenHardware
10 bis, rue Lucien VOILIN - 92800 Puteaux
Tél. : +33 (0)1 41 38 99 60 ext 123
Fax. : +33 (0)1 41 38 99 70
Next: Sverre Rabbelier
Message 1 of 9 in “rebase -i: fix has_action”
  1. rebase -i: fix has_actionNoe Rubinstein, Aug 4, 2011
  2. Sverre RabbelierAug 4, 2011
  3. Junio C HamanoAug 4, 2011
  4. Sverre RabbelierAug 5, 2011
  5. Johannes SixtAug 5, 2011
  6. Junio C HamanoAug 5, 2011
  7. Andrew WongAug 5, 2011
  8. Junio C HamanoAug 5, 2011
  9. What you can throw (on a Friday)Steffen Daode Nurpmeso, Aug 5, 2011

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.