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

Re: [PATCH] add a pre-merge hook

From
Paolo Bonzini <bonzini@gnu.org>
Date
Aug 27, 2008, 20:05 UTC
Message-ID
<48B5B399.6090407@gnu.org>
In-Reply-To
<7v63pmqqtx.fsf@gitster.siamese.dyndns.org>
> I think we should have done something like this for post_merge, not just
> "1/0 to show if it is a squash" which was an ill-thought-out hack.  Is
> there a clean way to fix the interface without breaking existing
> post_merge hooks in people's repositories?

Well, you can add this argument as a second argument to post-merge. Shall I do it?

> Please call whatever you install from template/hooks--* a "sample", not
> "default".
Ok.
> If it is primarily a hack to support calling post-merge with an non-object
> name "0" or "1"

It is to support not appending the commit list to the arguments of post-merge.

Show 9 quoted lines
>> +static int run_pre_merge_hook(const char *kind)
>> +{
>> +	return run_hook("pre-merge", remoteheads,
>> +			squash ? "squash" : kind, "--", NULL);
>>  }
> 
> remoteheads is a commit_list, you have the name of the hook and kind, so
> this extra "--" is only for run_hook() hackery to distinguish between the
> callers to post-merge and the callers to new pre-merge?

No, absolutely. The "--" separator is for future extension, in case we want to add other arguments before the head list.

run_hook does not care about what it receives in its varargs part. It is copied verbatim until the NULL. Then it adds a "--" and the heads argument if requested (which is not the case for post-merge). The fact that I had to specify a "--" here though is fishy. Maybe I have a off-by-one somewhere that, if fixed, can simplify the code somehow.

I'll take a look tomorrow, thanks for the review.
Paolo
Previous: Junio C Hamano
Message 4 of 4 in “add a pre-merge hook”
  1. add a pre-merge hookPaolo Bonzini, Aug 21, 2008
  2. add a pre-merge hookPaolo Bonzini, Aug 27, 2008
  3. Junio C HamanoAug 27, 2008
  4. Paolo BonziniAug 27, 2008

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.