{"thread":{"id":"63193","subject":"[PATCH] meson: disable coccinelle configuration when building from a tarball","startedAt":"2025-03-25T20:06:10Z","lastAt":"2025-03-26T08:29:03Z","messageCount":5,"participants":["Eli Schwartz","Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"515037","messageId":"20250325200542.197687-1-eschwartz@gentoo.org","threadId":"63193","inReplyTo":null,"subject":"[PATCH] meson: disable coccinelle configuration when building from a tarball","fromName":"Eli Schwartz","fromEmail":"eschwartz@gentoo.org","sentAt":"2025-03-25T20:05:40Z","receivedAt":"2025-03-25T20:06:10Z","isPatch":true,"sender":{"key":"eschwartz@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/6551424?v=4"},"body":"Wiring up coccinelle in the build, depends on running git commands to\nget the list of files to operate on. Reasonable, for a feature mainly\nused by people developing on git. If building git itself from a tarball\ndistribution of git's own source code, one likely does not need to run\ncoccinelle.\n\nBut running those git commands failed, and caused the build to error\nout, if `spatch` was installed -- because the build assumed that its\npresence indicated a desire to use it on this source tree. Instead, we\ncan expand the conditional to check for both `spatch` and the `.git`\nfile or directory.\n\nMeson's `opt.require()` method allows us to add a prerequisite for the\nfeature option. If the prerequisite fails, then the option either:\n- converts autodetection to disabled\n- emits an informative error\n\nSigned-off-by: Eli Schwartz <eschwartz@gentoo.org>\n---\n contrib/coccinelle/meson.build | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build\nindex 5d76a7fee6..ea054c924f 100644\n--- a/contrib/coccinelle/meson.build\n+++ b/contrib/coccinelle/meson.build\n@@ -1,4 +1,9 @@\n-spatch = find_program('spatch', required: get_option('coccinelle'))\n+coccinelle_opt = get_option('coccinelle').require(\n+  fs.exists(meson.project_source_root() / '.git'),\n+  error_message: 'coccinelle can only be run from a git checkout',\n+)\n+\n+spatch = find_program('spatch', required: coccinelle_opt)\n if not spatch.found()\n   subdir_done()\n endif\n\nbase-commit: c1d6628c9433c09ff62f916f2b933ee12995e9d8\n-- \n2.48.1\n\n"},{"id":"515038","messageId":"20250325200920.198057-1-eschwartz@gentoo.org","threadId":"63193","inReplyTo":"20250325200542.197687-1-eschwartz@gentoo.org","subject":"[PATCH v2] meson: disable coccinelle configuration when building from a tarball","fromName":"Eli Schwartz","fromEmail":"eschwartz@gentoo.org","sentAt":"2025-03-25T20:08:48Z","receivedAt":"2025-03-25T20:09:25Z","isPatch":true,"sender":{"key":"eschwartz@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/6551424?v=4"},"body":"Wiring up coccinelle in the build, depends on running git commands to\nget the list of files to operate on. Reasonable, for a feature mainly\nused by people developing on git. If building git itself from a tarball\ndistribution of git's own source code, one likely does not need to run\ncoccinelle.\n\nBut running those git commands failed, and caused the build to error\nout, if `spatch` was installed -- because the build assumed that its\npresence indicated a desire to use it on this source tree. Instead, we\ncan expand the conditional to check for both `spatch` and the `.git`\nfile or directory.\n\nMeson's `opt.require()` method allows us to add a prerequisite for the\nfeature option. If the prerequisite fails, then the option either:\n\n- converts autodetection to disabled\n\n- emits an informative error if the feature was set to enabled:\n  ```\n  ERROR: Feature coccinelle cannot be enabled: coccinelle can only be run from a git checkout\n  ```\n\nSigned-off-by: Eli Schwartz <eschwartz@gentoo.org>\n---\n\nv2: accidentally chopped off part of the commit message, sorry...\n\n contrib/coccinelle/meson.build | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build\nindex 5d76a7fee6..ea054c924f 100644\n--- a/contrib/coccinelle/meson.build\n+++ b/contrib/coccinelle/meson.build\n@@ -1,4 +1,9 @@\n-spatch = find_program('spatch', required: get_option('coccinelle'))\n+coccinelle_opt = get_option('coccinelle').require(\n+  fs.exists(meson.project_source_root() / '.git'),\n+  error_message: 'coccinelle can only be run from a git checkout',\n+)\n+\n+spatch = find_program('spatch', required: coccinelle_opt)\n if not spatch.found()\n   subdir_done()\n endif\n\nbase-commit: c1d6628c9433c09ff62f916f2b933ee12995e9d8\n-- \n2.48.1\n\n"},{"id":"515050","messageId":"xmqqpli4lmsi.fsf@gitster.g","threadId":"63193","inReplyTo":"20250325200920.198057-1-eschwartz@gentoo.org","subject":"Re: [PATCH v2] meson: disable coccinelle configuration when building from a tarball","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-03-25T23:21:01Z","receivedAt":"2025-03-25T23:21:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eli Schwartz <eschwartz@gentoo.org> writes:\n\n> presence indicated a desire to use it on this source tree. Instead, we\n> can expand the conditional to check for both `spatch` and the `.git`\n> file or directory.\n\nGood thinking.  I very much appreciate that you allowed .git to be a\nregular file, as well as a directory.\n\nWill queue.  Thanks.\n"},{"id":"515051","messageId":"68d381cd-3803-47a7-b7b1-8ef09b73a48a@gentoo.org","threadId":"63193","inReplyTo":"xmqqpli4lmsi.fsf@gitster.g","subject":"Re: [PATCH v2] meson: disable coccinelle configuration when building from a tarball","fromName":"Eli Schwartz","fromEmail":"eschwartz@gentoo.org","sentAt":"2025-03-25T23:29:17Z","receivedAt":"2025-03-25T23:29:20Z","isPatch":true,"sender":{"key":"eschwartz@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/6551424?v=4"},"body":"On 3/25/25 7:21 PM, Junio C Hamano wrote:\n> Eli Schwartz <eschwartz@gentoo.org> writes:\n> \n>> presence indicated a desire to use it on this source tree. Instead, we\n>> can expand the conditional to check for both `spatch` and the `.git`\n>> file or directory.\n> \n> Good thinking.  I very much appreciate that you allowed .git to be a\n> regular file, as well as a directory.\n> \n> Will queue.  Thanks.\n\n\nAs a heavy user of worktrees this topic is certainly on my mind. :D\n\n\n-- \nEli Schwartz\n"},{"id":"515086","messageId":"Z-O6xqjGmASjTZ9U@pks.im","threadId":"63193","inReplyTo":"20250325200920.198057-1-eschwartz@gentoo.org","subject":"Re: [PATCH v2] meson: disable coccinelle configuration when building from a tarball","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-26T08:28:54Z","receivedAt":"2025-03-26T08:29:03Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Mar 25, 2025 at 04:08:48PM -0400, Eli Schwartz wrote:\n> Wiring up coccinelle in the build, depends on running git commands to\n> get the list of files to operate on. Reasonable, for a feature mainly\n> used by people developing on git. If building git itself from a tarball\n> distribution of git's own source code, one likely does not need to run\n> coccinelle.\n> \n> But running those git commands failed, and caused the build to error\n> out, if `spatch` was installed -- because the build assumed that its\n> presence indicated a desire to use it on this source tree. Instead, we\n> can expand the conditional to check for both `spatch` and the `.git`\n> file or directory.\n> \n> Meson's `opt.require()` method allows us to add a prerequisite for the\n> feature option. If the prerequisite fails, then the option either:\n> \n> - converts autodetection to disabled\n> \n> - emits an informative error if the feature was set to enabled:\n>   ```\n>   ERROR: Feature coccinelle cannot be enabled: coccinelle can only be run from a git checkout\n>   ```\n\nMakes sense.\n\n> Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>\n> ---\n> \n> v2: accidentally chopped off part of the commit message, sorry...\n> \n>  contrib/coccinelle/meson.build | 7 ++++++-\n>  1 file changed, 6 insertions(+), 1 deletion(-)\n> \n> diff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build\n> index 5d76a7fee6..ea054c924f 100644\n> --- a/contrib/coccinelle/meson.build\n> +++ b/contrib/coccinelle/meson.build\n> @@ -1,4 +1,9 @@\n> -spatch = find_program('spatch', required: get_option('coccinelle'))\n> +coccinelle_opt = get_option('coccinelle').require(\n> +  fs.exists(meson.project_source_root() / '.git'),\n> +  error_message: 'coccinelle can only be run from a git checkout',\n> +)\n> +\n> +spatch = find_program('spatch', required: coccinelle_opt)\n>  if not spatch.found()\n>    subdir_done()\n>  endif\n> \n> base-commit: c1d6628c9433c09ff62f916f2b933ee12995e9d8\n\nYup, makes sense, as well.\n\nThank you for the patch, looks good!\n\nPatrick\n"}]}