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

Re: [PATCH 3/4] status: give more information during rebase -i

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 5, 2015, 17:11 UTC
Message-ID
<xmqqpp5arsgf.fsf@gitster.dls.corp.google.com>
In-Reply-To
<261867654.193546.1433522151490.JavaMail.zimbra@ensimag.grenoble-inp.fr>
Guillaume Pages <guillaume.pages@ensimag.grenoble-inp.fr> writes:
Show 17 quoted lines
> I felt that was not the right way to do so. What do you think of a
> function like that:
>
> /*
>  * Puts nb_commands commands from filename in lines,
>  * returns the total number of commands in the file
>  * ignores comments and empty lines
>  * lines needs to be at least of size nb_commands
>  * part: 0 get last commands
>  * 	 1 get first commands
>  */
>
> int get_commands(char *filename, int nb_commands, char **lines, int part)
>
> Maybe part is not the best word to choose to take the beginning or the end
> of the file. I also hesitate about adding a parameter to ignore or not the 
> comments.

If I were doing the caller of these two functions, then instead of adding these specialized helpers, I'd probably structure that caller this way:

	struct strbuf buf = STRBUF_INIT;
	struct string_list have_done = STRING_LIST_INIT_DUP;
	struct string_list yet_to_do = STRING_LIST_INIT_DUP;
	int have_done_nr, yet_to_do_nr;
	strbuf_read_file(&buf, ".../done", 0);
	stripspace(&buf, 1);
        have_done_nr = string_list_split(&have_done, buf.buf, '\n', -1);
	strbuf_release(&buf);
	strbuf_read_file(&buf, ".../todo", 0);
	stripspace(&buf, 1);
        yet_to_do_nr = string_list_split(&yet_to_do, buf.buf, '\n', -1);
	strbuf_release(&buf);

Then have_done.items[have_done_nr - 1].string would be the last one that we have replayed, and yet_to_do.items[0].string would be the next one we are going to replay.

Previous: Guillaume PagesNext: Guillaume Pagès
Message 7 of 11 in “status: factor two rebase-related messages together”
  1. 1/4 status: factor two rebase-related messages togetherGuillaume Pagès, Jun 3, 2015
  2. 2/4 status: differentiate interactive from non-interactive rebasesGuillaume Pagès, Jun 3, 2015
  3. 3/4 status: give more information during rebase -iGuillaume Pagès, Jun 3, 2015
  4. Matthieu MoyJun 4, 2015
  5. Junio C HamanoJun 4, 2015
  6. Guillaume PagesJun 5, 2015
  7. Junio C HamanoJun 5, 2015
  8. 4/4 status: add new tests for status during rebase -iGuillaume Pagès, Jun 3, 2015
  9. Matthieu MoyJun 4, 2015
  10. Junio C HamanoJun 8, 2015
  11. Guillaume PagesJun 9, 2015

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.