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

Re: [PATCH v3 5/9] sequencer: run post-rewrite hook

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 6, 2013, 18:40 UTC
Message-ID
<7v7gi7yteu.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1370509144-31974-6-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 45 quoted lines
> As we should.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  sequencer.c | 42 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 76ff2ff..74480d7 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -127,6 +127,37 @@ static void add_rewritten(unsigned char *from, unsigned char *to)
>  	rewritten.nr++;
>  }
>  
> +static void run_rewrite_hook(const char *name)
> +{
> +	struct strbuf buf = STRBUF_INIT;
> +	struct child_process proc;
> +	const char *argv[3];
> +	int code, i;
> +
> +	argv[0] = find_hook("post-rewrite");
> +	if (!argv[0])
> +		return;
> +
> +	argv[1] = name;
> +	argv[2] = NULL;
> +
> +	memset(&proc, 0, sizeof(proc));
> +	proc.argv = argv;
> +	proc.in = -1;
> +	proc.stdout_to_stderr = 1;
> +
> +	code = start_command(&proc);
> +	if (code)
> +		return;
> +	for (i = 0; i < rewritten.nr; i++) {
> +		struct rewritten_list_item *item = &rewritten.items[i];
> +		strbuf_addf(&buf, "%s %s\n", sha1_to_hex(item->from), sha1_to_hex(item->to));
> +	}
> +	write_in_full(proc.in, buf.buf, buf.len);
> +	close(proc.in);
> +	finish_command(&proc);
> +}

It probably is worth inserting a commit before 4/9 that adds rewrite.[ch], and

 - introduces "struct rewritten_list[_item]";
 - moves run_rewrite_hook() in builtin/commit.c to rewrite.c;
 - changes its function signature so that it takes "char
   *action_name" and "struct rewritten *" as parameters; and
 - adjust its sole call site in cmd_commit() to feed a single-item
   rewritten_list to it.

Then 4/9 can teach cherry-pick to prepare the rewritten-list and probably this commit can be part of that to call run_rewrite_hook().

Previous: Felipe ContrerasNext: Felipe Contreras
Message 12 of 18 in “cherry-pick: improvements”
  1. 0/9 cherry-pick: improvementsFelipe Contreras, Jun 6, 2013
  2. 1/9 sequencer: remove useless indentationFelipe Contreras, Jun 6, 2013
  3. 2/9 sequencer: trivial fixFelipe Contreras, Jun 6, 2013
  4. 3/9 cherry-pick: add --skip-empty optionFelipe Contreras, Jun 6, 2013
  5. Junio C HamanoJun 6, 2013
  6. Felipe ContrerasJun 6, 2013
  7. Junio C HamanoJun 6, 2013
  8. Junio C HamanoJun 6, 2013
  9. Felipe ContrerasJun 7, 2013
  10. 4/9 cherry-pick: store rewritten commitsFelipe Contreras, Jun 6, 2013
  11. 5/9 sequencer: run post-rewrite hookFelipe Contreras, Jun 6, 2013
  12. Junio C HamanoJun 6, 2013
  13. Felipe ContrerasJun 9, 2013
  14. 6/9 cherry-pick: add support to copy notesFelipe Contreras, Jun 6, 2013
  15. Felipe ContrerasJun 6, 2013
  16. 7/9 revert/cherry-pick: add --quiet optionFelipe Contreras, Jun 6, 2013
  17. 8/9 revert/cherry-pick: add --skip optionFelipe Contreras, Jun 6, 2013
  18. 9/9 cherry-pick: don't barf when there's nothing to doFelipe Contreras, Jun 6, 2013

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.