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

Re: git status during interactive rebase

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 21, 2016, 22:35 UTC
Message-ID
<xmqqtwm6woh1.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAGZ79ka7MVuHyTrjuR7BhBAxxJ-PuMCSDnRVWCbeeRSq9rGdWQ@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
>> So the proper fix might be to test for the presence of the "done" file and
>> otherwise tell the user that this rebase has not even started yet.
>
> So what Matthieu said?
Yup, I think that is the right thing to do.

Perhaps something along this line (not tested and done on 'pu', so I am not committing it to anywhere myself)?

 wt-status.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index ab4f80d..90b2474 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1068,14 +1068,17 @@ static void abbrev_sha1_in_line(struct strbuf *line)
 
 }
 
-static void read_rebase_todolist(const char *fname, struct string_list *lines)
+static int read_rebase_todolist(const char *fname, struct string_list *lines)
 {
 	struct strbuf line = STRBUF_INIT;
 	FILE *f = fopen(git_path("%s", fname), "r");
 
-	if (!f)
+	if (!f) {
+		if (errno == ENOENT)
+			return -1;
 		die_errno("Could not open file %s for reading",
 			  git_path("%s", fname));
+	}
 	while (!strbuf_getline_lf(&line, f)) {
 		if (line.len && line.buf[0] == comment_line_char)
 			continue;
@@ -1085,6 +1088,7 @@ static void read_rebase_todolist(const char *fname, struct string_list *lines)
 		abbrev_sha1_in_line(&line);
 		string_list_append(lines, line.buf);
 	}
+	return 0;
 }
 
 static void show_rebase_information(struct wt_status *s,
@@ -1098,12 +1102,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;
 
-		read_rebase_todolist("rebase-merge/done", &have_done);
-		read_rebase_todolist("rebase-merge/git-rebase-todo", &yet_to_do);
-
-		if (have_done.nr == 0)
+		if ((read_rebase_todolist("rebase-merge/done", &have_done) < 0) ||
+		    (read_rebase_todolist("rebase-merge/git-rebase-todo", &yet_to_do) < 0)) {
+			status_printf_ln(s, color, _("rebase-i not started yet."));
+		} else if (have_done.nr == 0) {
 			status_printf_ln(s, color, _("No commands done."));
-		else {
+		} else {
 			status_printf_ln(s, color,
 				Q_("Last command done (%d command done):",
 					"Last commands done (%d commands done):",
Previous: Stefan BellerNext: Johannes Schindelin
Message 4 of 6 in “git status during interactive rebase”
  1. Stefan BellerJan 20, 2016
  2. Matthieu MoyJan 21, 2016
  3. Stefan BellerJan 21, 2016
  4. Junio C HamanoJan 21, 2016
  5. Johannes SchindelinJan 22, 2016
  6. Johannes SchindelinJan 21, 2016

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.