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

Re: [PATCH] git-apply - Add --include=PATH

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 24, 2008, 00:54 UTC
Message-ID
<7viqtrw7up.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1219523869.18365.106.camel@localhost>
Joe Perches <joe@perches.com> writes:
Show 6 quoted lines
> Add similar capability to --exclude=
>
> Allows selection of files to patch from a
> large patchset.
>
> Signed-off-by: Joe Perches <joe@perches.com>

Thanks; I don't see anything fundamentally wrong with what this patch tries to achieve.

Show 8 quoted lines
> @@ -2996,10 +2996,16 @@ static struct excludes {
>  	const char *path;
>  } *excludes;
>  
> +static struct includes {
> +	struct includes *next;
> +	const char *path;
> +} *includes;

Now this is ugly. You can just add a new variable "*includes" that is of exactly the same type as existing "*excludes" without introducing a new type.

You should then find it disturbing that the shared type is still called "struct excludes" even though it is now used for things you would want to include. You are right. You can then either rename it to a more neutral name, or (even better) use an existing type, such as "string_list".

Which would mean that this patch should be done as two patches:
 [1/2] builtin-apply.c: Use "string_list" for "--excludes".
 [2/2] builtin-apply.c: Add "--includes" option.

The first will be a preparatory step that does not change any externally visible behaviour. The only thing it will do is to change the type of "excludes" to "struct string_list", to update the option parser to use string_list_append() to add to it, and to update the way "use_patch()" to iterate over the items in the exclude list.

The second will add a new "includes" variable, and do the moral equivalent of what your patch did.

The first patch most likely should introduce a new helper function:
  int string_list_has_match(struct string_list *s, const char *path);

so that the update to "use_patch()" that needs to be done in the second patch can just pass a different string_list to implement the additional check.

Previous: Joe PerchesNext: Joe Perches
Message 2 of 4 in “git-apply - Add --include=PATH”
  1. git-apply - Add --include=PATHJoe Perches, Aug 23, 2008
  2. Junio C HamanoAug 24, 2008
  3. Joe PerchesAug 24, 2008
  4. Junio C HamanoAug 25, 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.