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

[PATCH v2 0/1] Let `git status` handle a not-yet-started `rebase -i` gracefully

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 26, 2017, 16:08 UTC
Message-ID
<cover.1485446899.git.johannes.schindelin@gmx.de>
In-Reply-To
<99f6de4be107044fdf01ee796f42e124ac147891.1453480067.git.johannes.schindelin@gmx.de>

When the `done` file is missing, we die()d. This is not necessary, we can do much better than that.

Changes since v1:
- When `done` is missing, we still read `git-rebase-todo` and report the
  next steps.
- We now report a missing git-rebase-todo.
- Added a test (thanks, Matthieu, for prodding me into working harder
  ;-)).
- As I changed so much, I took authorship of the patch.
Johannes Schindelin (1):
  status: be prepared for not-yet-started interactive rebase
 t/t7512-status-help.sh | 19 +++++++++++++++++++
 wt-status.c            | 14 ++++++++++----
 2 files changed, 29 insertions(+), 4 deletions(-)
base-commit: 4e59582ff70d299f5a88449891e78d15b4b3fabe
Published-As: https://github.com/dscho/git/releases/tag/wt-status-v2
Fetch-It-Via: git fetch https://github.com/dscho/git wt-status-v2
Interdiff vs v1:
 diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
 index 5c3db656df..458608cc1e 100755
 --- a/t/t7512-status-help.sh
 +++ b/t/t7512-status-help.sh
 @@ -944,4 +944,23 @@ EOF
  	test_i18ncmp expected actual
  '
  
 +test_expect_success 'status: handle not-yet-started rebase -i gracefully' '
 +	ONTO=$(git rev-parse --short HEAD^) &&
 +	COMMIT=$(git rev-parse --short HEAD) &&
 +	EDITOR="git status --untracked-files=no >actual" git rebase -i HEAD^ &&
 +	cat >expected <<EOF &&
 +On branch several_commits
 +No commands done.
 +Next command to do (1 remaining command):
 +   pick $COMMIT four_commit
 +  (use "git rebase --edit-todo" to view and edit)
 +You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
 +  (use "git commit --amend" to amend the current commit)
 +  (use "git rebase --continue" once you are satisfied with your changes)
 +
 +nothing to commit (use -u to show untracked files)
 +EOF
 +	test_i18ncmp expected actual
 +'
 +
  test_done
 diff --git a/wt-status.c b/wt-status.c
 index 13afe66649..4dff0b3e21 100644
 --- a/wt-status.c
 +++ b/wt-status.c
 @@ -1169,12 +1169,12 @@ static void show_rebase_information(struct wt_status *s,
  		struct string_list have_done = STRING_LIST_INIT_DUP;
  		struct string_list yet_to_do = STRING_LIST_INIT_DUP;
  
 -		if ((read_rebase_todolist("rebase-merge/done", &have_done)) ||
 -		    (read_rebase_todolist("rebase-merge/git-rebase-todo",
 -				  &yet_to_do)))
 +		read_rebase_todolist("rebase-merge/done", &have_done);
 +		if (read_rebase_todolist("rebase-merge/git-rebase-todo",
 +					 &yet_to_do))
  			status_printf_ln(s, color,
 -				_("rebase-i not started yet."));
 -		else if (have_done.nr == 0)
 +				_("git-rebase-todo is missing."));
 +		if (have_done.nr == 0)
  			status_printf_ln(s, color, _("No commands done."));
  		else {
  			status_printf_ln(s, color,
 @@ -1192,9 +1192,7 @@ static void show_rebase_information(struct wt_status *s,
  					_("  (see more in file %s)"), git_path("rebase-merge/done"));
  		}
  
 -		if (have_done.nr == 0)
 -			; /* do nothing */
 -		else if (yet_to_do.nr == 0)
 +		if (yet_to_do.nr == 0)
  			status_printf_ln(s, color,
  					 _("No commands remaining."));
  		else {
-- 
2.11.1.windows.prerelease.2.9.g3014b57
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 6 of 10 in “status: be prepared for not-yet-started interactive rebase”
  1. status: be prepared for not-yet-started interactive rebaseJohannes Schindelin, Jan 22, 2016
  2. Matthieu MoyJan 22, 2016
  3. Johannes SchindelinJan 22, 2016
  4. Junio C HamanoJan 22, 2016
  5. Johannes SchindelinJan 22, 2016
  6. 0/1 Let `git status` handle a not-yet-started `rebase -i` gracefullyJohannes Schindelin, Jan 26, 2017
  7. 1/1 status: be prepared for not-yet-started interactive rebaseJohannes Schindelin, Jan 26, 2017
  8. Matthieu MoyJan 26, 2017
  9. Stefan BellerJan 26, 2017
  10. Johannes SchindelinJan 27, 2017

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.