From patchwork Sun Sep 26 19:03:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12518397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E60AEC433F5 for ; Sun, 26 Sep 2021 19:03:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCF9A60EE4 for ; Sun, 26 Sep 2021 19:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229764AbhIZTFM (ORCPT ); Sun, 26 Sep 2021 15:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbhIZTFL (ORCPT ); Sun, 26 Sep 2021 15:05:11 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7FCC061570 for ; Sun, 26 Sep 2021 12:03:34 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id i23so45508266wrb.2 for ; Sun, 26 Sep 2021 12:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gb+f/BJ51xtw2n/dWvdWWTto5tqw0aSHjIr8Kl07ff4=; b=mFZUi3IeKdMT1Clk4P6+0KRsn3jTBto2Rma7N9xPofnxJPkuJ9H3NITtk/HxhScaQR iCHDn6XScE7sVhm7H91s9DOP6amjfOKtVUThkT2VJuMJjG+3eXiKOrlle/u7vF6qBHaO hvbVfqesSRfRFmpwXRlNgREiTVw3wCEeWXRV9uvIc8RlTMENt+mxs/wPPIrTNF3aTqI3 fg809DlcT3KLo7R7/rY8wryGQilRjreziVP2Wp56k2dleQTb04ghgkdAJgXTzfdqvlO9 OTyVKnCrf0ctKAXwItolgmDYlqXObk5To2FDgGWlgvAqLp4KCSxB1dRLqJ0RU1LRojgO Vyfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gb+f/BJ51xtw2n/dWvdWWTto5tqw0aSHjIr8Kl07ff4=; b=n71Y/AmQtBChfoS/bY0FRF0AkQQeiOstFdhMzUxMjAbh+hfkKuC6dF0fkvyFlitE+L tCTyI+knjCKg/cgaeIuxUZxWi2qutpFdfImEjnJS26MyNrLRt4PKzmEBEZafYeTGmRTf k3x/RKWL3cZ6cNnGT6/3y4qwDkDLIHuEHQBvu/J/iwRm1DmdYS/5TesulpIOzrqDkwEO +i0ggoT0dIQp/HqZ0YWedtoXnJcvfjD3TsKcAJhlM+0uOIGR+/syrfz/5QlARsu7LUjQ L7lLQegr3pMC5rpmcSVYIp15umX3iKLBQDPhC6Q4kfXHRclNv67qLwLHod/H2u/lVRz3 27bA== X-Gm-Message-State: AOAM530uwZsd62fmMGMN/gOGvxo6ps2UDJ6SKMXWcYooaDnHg1efxuQ4 ytgcTlyMfX7+omrjH7hJeNs4tJD2lr8qPQ== X-Google-Smtp-Source: ABdhPJwxHKyX7HAmgszXB9j2N2DSG8YSzWfYz73Z9D8irqqdZqlRzkN2P2rVRQPlClmm2o3XVb2gIw== X-Received: by 2002:a05:600c:354f:: with SMTP id i15mr12465450wmq.146.1632683013012; Sun, 26 Sep 2021 12:03:33 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v20sm14691523wra.73.2021.09.26.12.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:03:32 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Jeff King , Phillip Wood , =?utf-8?q?Ren=C3=A9_Scharfe?= , =?utf-8?b?w4Z2YXIgQXJuZmo=?= =?utf-8?b?w7Zyw7AgQmphcm1hc29u?= Subject: [PATCH v2 1/8] Makefile: mark "check" target as .PHONY Date: Sun, 26 Sep 2021 21:03:22 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1291.g8857a6a91ac In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a bug in 44c9e8594e (Fix up header file dependencies and add sparse checking rules, 2005-07-03), we never marked the phony "check" target as such. Perhaps we should just remove it, since as of a combination of 912f9980d2 (Makefile: help people who run 'make check' by mistake, 2008-11-11) 0bcd9ae85d (sparse: Fix errors due to missing target-specific variables, 2011-04-21) we've been suggesting the user run "make sparse" directly. But under that mode it still does something, as well as directing the user to run "make test" under non-sparse. So let's punt that and narrowly fix the PHONY bug. Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index a9f9b689f0c..2777284b0f1 100644 --- a/Makefile +++ b/Makefile @@ -2925,6 +2925,7 @@ hdr-check: $(HCO) style: git clang-format --style file --diff --extensions c,h +.PHONY: check check: config-list.h command-list.h @if sparse; \ then \ From patchwork Sun Sep 26 19:03:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12518399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A99A3C433FE for ; Sun, 26 Sep 2021 19:03:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A50460EE4 for ; Sun, 26 Sep 2021 19:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbhIZTFQ (ORCPT ); Sun, 26 Sep 2021 15:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229761AbhIZTFM (ORCPT ); Sun, 26 Sep 2021 15:05:12 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86463C061570 for ; Sun, 26 Sep 2021 12:03:35 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id t8so45547618wri.1 for ; Sun, 26 Sep 2021 12:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uz/++S0IIB/2z6nJJoD+oLBniQ/Q5hoIp6dizk0aWMU=; b=GkYHgnlcpaCaT937cq7kgIkejTjmIbPgY54tohVU3yG9ms3CTJtambpCf/VEK7OmdB sDaP802V1bpZXP7O/AiQ9SHV0nzjfc/Qor+UtxpHzPgdp8035sHDileppGsDptpXuLYS 0OFxHhkGHyRvpnWPlzb8WITjN4HroqAGpck6C+h1ypD0pcYidcTXRy/2QVHDlOMoCA3l qd1M1NzqcpQQfNyYGEnYICbGMQz6Xg/1ToIujFcjQ9vnEJXxm4OEOgHsDU+bWAOAcMsR 8nLY0EKUZl8JbDIYUSPpK7Xat8d2dSgEsgvRXMSRq4EcOIv3mKEW3XjAuI97QGIGaTaq mP+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uz/++S0IIB/2z6nJJoD+oLBniQ/Q5hoIp6dizk0aWMU=; b=6NIBM/4YdBgNxavYXrLZ/9ge0ikOgsghCLBH8sAN9Fe6Ty0WP2+szKwAU+ZPm2g2jY 3Wu0ZAW0aS1XSyoVL5IakZgwy8rRuTXVA4SXiDzd2sB35DjDN1OD8i5W+ZuMOXTfrmTn lKUvdDzox/lU7QjLSBodl5TIVcgScZ3e0FMZww9kzP8lAlC4aRn7gL3VGAqV/4DXJGdR SwBG3/EzZRFTqvZYs0xbgoJS7jRK77KKIxHYhGIibcmchcAOrEQxW8UPe12HXSsR4pbF J3SOFa8hZxzENwJK07S79IIWj0thh2d1jQIjQB1LRgrh9QmNZBEwXW+VUrR8T36cZOv4 0UPA== X-Gm-Message-State: AOAM531pAnDcp7hI4yThP52Q6FuIse5MQ6LMLkNNqIG7Z8WlUv4u/pHs 9cezUozUTERxIuesobiHTko+1CeBhSMQhw== X-Google-Smtp-Source: ABdhPJxMmZzTVsHjheQIssBd0diPC++/5YDEG3UTYM4Nl22DbnQI+J+jVxBgzASsVu81/kSVgnvQBQ== X-Received: by 2002:a05:6000:1866:: with SMTP id d6mr23914454wri.141.1632683013859; Sun, 26 Sep 2021 12:03:33 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v20sm14691523wra.73.2021.09.26.12.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:03:33 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Jeff King , Phillip Wood , =?utf-8?q?Ren=C3=A9_Scharfe?= , =?utf-8?b?w4Z2YXIgQXJuZmo=?= =?utf-8?b?w7Zyw7AgQmphcm1hc29u?= Subject: [PATCH v2 2/8] Makefile: stop hardcoding {command,config}-list.h Date: Sun, 26 Sep 2021 21:03:23 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1291.g8857a6a91ac In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change various places that hardcode the names of these two files to refer to either $(GENERATED_H), or to a new generated-hdrs target. That target is consistent with the *-objs targets I recently added in 029bac01a8 (Makefile: add {program,xdiff,test,git,fuzz}-objs & objects targets, 2021-02-23). A subsequent commit will add a new generated hook-list.h. By doing this refactoring we'll only need to add the new file to the GENERATED_H variable, not EXCEPT_HDRS, the vcbuild/README etc. Hardcoding command-list.h there seems to have been a case of copy/paste programming in 976aaedca0 (msvc: add a Makefile target to pre-generate the Visual Studio solution, 2019-07-29). The config-list.h was added later in 709df95b78 (help: move list_config_help to builtin/help, 2020-04-16). Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 6 ++++-- compat/vcbuild/README | 2 +- config.mak.uname | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2777284b0f1..47e79a6252a 100644 --- a/Makefile +++ b/Makefile @@ -817,6 +817,8 @@ XDIFF_LIB = xdiff/lib.a GENERATED_H += command-list.h GENERATED_H += config-list.h +.PHONY: generated-hdrs +generated-hdrs: $(GENERATED_H) LIB_H := $(sort $(patsubst ./%,%,$(shell git ls-files '*.h' ':!t/' ':!Documentation/' 2>/dev/null || \ $(FIND) . \ @@ -2903,7 +2905,7 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) -EXCEPT_HDRS := command-list.h config-list.h unicode-width.h compat/% xdiff/% +EXCEPT_HDRS := $(GENERATED_H) unicode-width.h compat/% xdiff/% ifndef GCRYPT_SHA256 EXCEPT_HDRS += sha256/gcrypt.h endif @@ -2926,7 +2928,7 @@ style: git clang-format --style file --diff --extensions c,h .PHONY: check -check: config-list.h command-list.h +check: $(GENERATED_H) @if sparse; \ then \ echo >&2 "Use 'make sparse' instead"; \ diff --git a/compat/vcbuild/README b/compat/vcbuild/README index 51fb083dbbe..29ec1d0f104 100644 --- a/compat/vcbuild/README +++ b/compat/vcbuild/README @@ -92,7 +92,7 @@ The Steps of Build Git with VS2008 the git operations. 3. Inside Git's directory run the command: - make command-list.h config-list.h + make generated-hdrs to generate the header file needed to compile git. 4. Then either build Git with the GNU Make Makefile in the Git projects diff --git a/config.mak.uname b/config.mak.uname index 76516aaa9a5..8aac06eb094 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -735,9 +735,9 @@ vcxproj: echo '') >git-remote-http/LinkOrCopyRemoteHttp.targets git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets - # Add command-list.h and config-list.h - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 config-list.h command-list.h - git add -f config-list.h command-list.h + # Add generated headers + $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(GENERATED_H) + git add -f $(GENERATED_H) # Add scripts rm -f perl/perl.mak From patchwork Sun Sep 26 19:03:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12518401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFEE3C433EF for ; Sun, 26 Sep 2021 19:03:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8B2C60EE5 for ; Sun, 26 Sep 2021 19:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbhIZTFS (ORCPT ); Sun, 26 Sep 2021 15:05:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbhIZTFN (ORCPT ); Sun, 26 Sep 2021 15:05:13 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CEA2C061570 for ; Sun, 26 Sep 2021 12:03:36 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id i23so45508411wrb.2 for ; Sun, 26 Sep 2021 12:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q/XInnjGS8dWPoo6MBuw9o7czB/X+NGrNH22i+GMByw=; b=NUBjzmcv/OuatvvISKTTn6OsmUKwejidNfknhXRUTGvKViSmwqH2wcfYN3VhX7bvmN f39K56eZmSmPRRG7wnkMdmo/4ZATCQ11N88zZmSID4N7h3cxm7ZM1oYynhhb1vtENk5B Bq9BHdAXcqZy39MGhxLnAblUGzCtdtIcK1r17KGPFUjF/5c7EZFx+KQ9Y+RXpbGb6XzQ yeG0/P9t9qxIClMmXDvU/1vI+Xn3rMUejHQTZ8YfzpbH8ac8kEz+ahcF6vVdjXNu2UCa 25EWKn52CMGldvoc4uurD3/s5ZY4McFSqhkN8p7rWl63b6jAnMqC6aYKomSn+/8r4+r4 Dl3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q/XInnjGS8dWPoo6MBuw9o7czB/X+NGrNH22i+GMByw=; b=u/28VyUw05uxRV2G1PhzGtg5maU/l+j4pceAlCu09rEkDMtmgFtz1DUzKzhcYxV1fc i3Sogi2hSoDZMuqO8ZP5yYL0jO8lMLQY9uNUTdB7WEAUv2kXRlBaBQf2PkvaHkyJbsTg 3OFg2ls66p00iwy6/Qj9CGvElvVLQcn66f+9RO/qZCaG0FQSznHc0+Gp4QgOJ5fT1k7H Tm6N02Mypgyj3fz94kxrn9NL0DSheXAy7o9r1BtqTc7TdTtEZSaINngtUeW19Jrfq1Vf lhst9ksvQxL0uTD0f6aoLKEmXySNtAuesA/rpSLFiFQ5REH2NqwRjysDYxaZx2/w/hRi eRSA== X-Gm-Message-State: AOAM531ErPBLMqL/bZ9Li0JoKT/m+imSqll4UOwXehix26KyPfEWmcXI iHECUJTKVjaqKQ3aCLmmuDn8hKjYIdpL/A== X-Google-Smtp-Source: ABdhPJwqA40psUjpdaAVar48MNZo3vfQjll9os0UuS4P0ZnzkC9optRqWrpCXbNWv1WzhFlzAVmKSg== X-Received: by 2002:a5d:59ae:: with SMTP id p14mr24202969wrr.278.1632683014639; Sun, 26 Sep 2021 12:03:34 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v20sm14691523wra.73.2021.09.26.12.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:03:34 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Jeff King , Phillip Wood , =?utf-8?q?Ren=C3=A9_Scharfe?= , =?utf-8?b?w4Z2YXIgQXJuZmo=?= =?utf-8?b?w7Zyw7AgQmphcm1hc29u?= Subject: [PATCH v2 3/8] Makefile: don't perform "mv $@+ $@" dance for $(GENERATED_H) Date: Sun, 26 Sep 2021 21:03:24 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1291.g8857a6a91ac In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the "cmd.sh > $@+ && mv $@+ $@" pattern used for generating the config-list.h and command-list.h to just "cmd.sh >$@". This was needed as a guard to ensure that we don't have an empty file if the script failed, but since 7b76d6bf221 (Makefile: add and use the ".DELETE_ON_ERROR" flag, 2021-06-29) GNU make ensures that doesn't happen. There's still a lot of other places in the Makefile where we needlessly use this pattern, but I'm just changing these because I'm about to add a new $(GENERATED_H) target, let's have them all look and act the same way. Even with ".DELETE_ON_ERROR" there is still a point to using the "mv $@+ $@" pattern in some cases, e.g. to ensure that you have a working binary during recompilation (see [1] for the start of a long discussion about that), but that doesn't apply here. Nothing external uses $(GENERATED_H) directly, it's only ever used in the context of the Makefile's own dependency (re-)generation. 1. https://lore.kernel.org/git/8735t93h0u.fsf@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 47e79a6252a..e6b8d00f221 100644 --- a/Makefile +++ b/Makefile @@ -2231,15 +2231,14 @@ $(BUILT_INS): git$X config-list.h: generate-configlist.sh config-list.h: Documentation/*config.txt Documentation/config/*.txt - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ - >$@+ && mv $@+ $@ + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh >$@ command-list.h: generate-cmdlist.sh command-list.txt command-list.h: $(wildcard Documentation/git*.txt) $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ - command-list.txt >$@+ && mv $@+ $@ + command-list.txt >$@ SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\ $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\ From patchwork Sun Sep 26 19:03:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12518403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 896F8C433EF for ; Sun, 26 Sep 2021 19:03:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6796A60F44 for ; Sun, 26 Sep 2021 19:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbhIZTFS (ORCPT ); Sun, 26 Sep 2021 15:05:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbhIZTFN (ORCPT ); Sun, 26 Sep 2021 15:05:13 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363ECC061575 for ; Sun, 26 Sep 2021 12:03:37 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id x20so728375wrg.10 for ; Sun, 26 Sep 2021 12:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qvUvrKrIrhyz4NOhQc7W18mEfgd+XWyQ4/wuiJfhMU8=; b=Ket08UVYiLT97luMATVgTDbbKg3TkTxb6smugyFlqtDbnEf/8rZgXIYsBlbx937AHi pECK59X/HthnoBpM7uO83YnyDhAUeTiOQw8yZq8J3D/j+FCUlKeVP8KVi+Mv/AosYDAT 3p/PvLDLHPBOidq36ASkfHwvgvRcrMXjfOkMGF80+LuhvNPhVUrygcIA1eoY0bdvzAcK Tk86YuKDtUNl2EwASPFC8xp8TU0oao3JiNhCvyI0uuKVlE7ddfZcsQ7h/2VhTRHH7ufh ymv6+d5EIG8Vk3uwzJasCRWDRQCcKxcpI6yuhwqrf0ny0ZK9nx/xMiIlDDGwPoB73nyt vSsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qvUvrKrIrhyz4NOhQc7W18mEfgd+XWyQ4/wuiJfhMU8=; b=BwrjouDtjrYFlIni5HUWo0q4BI4YYK+8Dof2PZKiTOHRjyquNDkHqyYU2xLk+J8HdO 4Q0ifX2vYyy2HNs1Vnx7KaZrvyYTVjA38zAZzGDTrEYrq52BU1VenAJJx9phL/2HKjlm O9GjS/jfR6k7Frs3syT1copadNNT+iLJ2lZLHEJJz4m89yvafeWoObB9BvoE7mgutUL0 3TnappjaGaIc9yAWcJN5EE7OyNVJ2t4Kwi/WOBOIPjvFGJfTsvv+UsSO7h3ry4Up0J0k ZYQbDepqmsNk9tpALZhaNBdwMps3rWXeUhV7qxrYkrakxIqkYnWJK8Vlxi1bysuOeZ09 hCVg== X-Gm-Message-State: AOAM5317+LvvcHXuNvHbh8HKN15s8vVuE3ucTzlqJB9bik15L9jtKeDt 3gnOsB+RJTIHyCRFcq8C8WQW9Z3dFTuYQA== X-Google-Smtp-Source: ABdhPJz90rSGmaBPqL48N8yV+RE8wjT0yHbLb/LiMcTLhJPCCugdqFs8TPHG+pcYKPsFXe1u0UZDXw== X-Received: by 2002:adf:fb0a:: with SMTP id c10mr24477289wrr.354.1632683015521; Sun, 26 Sep 2021 12:03:35 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v20sm14691523wra.73.2021.09.26.12.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:03:34 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Jeff King , Phillip Wood , =?utf-8?q?Ren=C3=A9_Scharfe?= , =?utf-8?b?w4Z2YXIgQXJuZmo=?= =?utf-8?b?w7Zyw7AgQmphcm1hc29u?= Subject: [PATCH v2 4/8] Makefile: remove an out-of-date comment Date: Sun, 26 Sep 2021 21:03:25 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1291.g8857a6a91ac In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This comment added in dfea575017 (Makefile: lazily compute header dependencies, 2010-01-26) has been out of date since 92b88eba9f (Makefile: use `git ls-files` to list header files, if possible, 2019-03-04), when we did exactly what it tells us not to do and added $(GENERATED_H) to $(OBJECTS) dependencies. The rest of it was also somewhere between inaccurate and outdated, since as of b8ba629264 (Makefile: fold MISC_H into LIB_H, 2012-06-20) it's not followed by a list of header files, that got moved earlier in the file into LIB_H in 60d24dd255 (Makefile: fold XDIFF_H and VCSSVN_H into LIB_H, 2012-07-06). Let's just remove it entirely, to the extent that we have anything useful to say here the comment on the "USE_COMPUTED_HEADER_DEPENDENCIES" variable a few lines above this change does the job for us. Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Makefile b/Makefile index e6b8d00f221..b9bf13239d0 100644 --- a/Makefile +++ b/Makefile @@ -2501,13 +2501,6 @@ ifneq ($(dep_files_present),) include $(dep_files_present) endif else -# Dependencies on header files, for platforms that do not support -# the gcc -MMD option. -# -# Dependencies on automatically generated headers such as command-list.h -# should _not_ be included here, since they are necessary even when -# building an object for the first time. - $(OBJECTS): $(LIB_H) $(GENERATED_H) endif From patchwork Sun Sep 26 19:03:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12518405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 957B7C433F5 for ; Sun, 26 Sep 2021 19:03:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CA2460F12 for ; Sun, 26 Sep 2021 19:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbhIZTFU (ORCPT ); Sun, 26 Sep 2021 15:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbhIZTFP (ORCPT ); Sun, 26 Sep 2021 15:05:15 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1964BC061714 for ; Sun, 26 Sep 2021 12:03:38 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id s21so5406353wra.7 for ; Sun, 26 Sep 2021 12:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tP3nIRkFx66M+sMVZPmffTRNb5/BBU5yc8/EYUZ8LRQ=; b=S6avZ1s7t8Cq+PD07HgekK9IFUkp+rqm83MrMOQNdU4apTPchLO0823FRL5oxPx7cx +cgxaeMC8o2YG1mRzQP5qDgUQ3CGx7xDMSKbWt5BXWu1vtiBVHWx+s59yG9hyXNvs97/ dTD22wLZAl+1oQk/8O7Fg6zgeNCup1zUgFDBZZXHhVrKfieg36bM8q1f1mevKzfT5UqD +zKajE0c3wQ/f4Dayw3j2j3rAvayzk6pGQ3l3vJirwOK09tP/CL3bnrOr8bsZ0PKmqm6 I30gLdT4MiKtP1RnKqZhihW/ywnKqHBDVnXGEBmn4jRIRdqZ0bUkP4Q5s7ibQClk5VQG /YqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tP3nIRkFx66M+sMVZPmffTRNb5/BBU5yc8/EYUZ8LRQ=; b=It7fXVHakg/8S57EwxVsGwldTklJk/lSkKNd0V8OfCfsDVEAvk+TkjvSTD/k3QBOpa sYBAACzK5HJ18/udIPOCiZcYM2LnJDvd2IID2K1Aj8fXuMp5oJLgdGNebbAm3vWItOUl 2v6VQMM9yN4G9ckcbL0zPRno55ji2HRbtUh5/MCBM9z30pnigBAqz4O/bhrbM70FvoyB nlWbIjbAgFbskaE6nS2v1MnABgUIEk6UUCUqajDMeilbM6weS3emQL1vBQyH7V8QyeIE QtThiu3Ui47k4eODuoqUT3zGchIS5cGHEPH3Ou/setq9NizaMUAMd24hsfYELeiWWG/F LbDA== X-Gm-Message-State: AOAM532sD7AbIJMT62H00djOf3iD0PLq1AM8zNY6q96MGl32AJBVfP9i w1uJxT6hfMLgK3wjdvBzqdvs0QouCUmM8g== X-Google-Smtp-Source: ABdhPJyG4YSOYjikRhQAE2aDKsd2S9GLSpnvNGfBlntIhS6XttGwZ4hjj1Sa6MQRLQRG5QDR2E5XPg== X-Received: by 2002:a05:6000:8f:: with SMTP id m15mr2206277wrx.174.1632683016354; Sun, 26 Sep 2021 12:03:36 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v20sm14691523wra.73.2021.09.26.12.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:03:35 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Jeff King , Phillip Wood , =?utf-8?q?Ren=C3=A9_Scharfe?= , =?utf-8?b?w4Z2YXIgQXJuZmo=?= =?utf-8?b?w7Zyw7AgQmphcm1hc29u?= Subject: [PATCH v2 5/8] hook.[ch]: move find_hook() from run-command.c to hook.c Date: Sun, 26 Sep 2021 21:03:26 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1291.g8857a6a91ac In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the find_hook() function from run-command.c to a new hook.c library. This change establishes a stub library that's pretty pointless right now, but will see much wider use with Emily Shaffer's upcoming "configuration-based hooks" series. Eventually all the hook related code will live in hook.[ch]. Let's start that process by moving the simple find_hook() function over as-is. Signed-off-by: Emily Shaffer Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 1 + builtin/am.c | 1 + builtin/bugreport.c | 2 +- builtin/commit.c | 1 + builtin/merge.c | 1 + builtin/receive-pack.c | 1 + builtin/worktree.c | 1 + hook.c | 37 +++++++++++++++++++++++++++++++++++++ hook.h | 11 +++++++++++ refs.c | 1 + run-command.c | 35 +---------------------------------- run-command.h | 7 ------- sequencer.c | 1 + transport.c | 2 +- 14 files changed, 59 insertions(+), 43 deletions(-) create mode 100644 hook.c create mode 100644 hook.h diff --git a/Makefile b/Makefile index b9bf13239d0..1f2b0205da5 100644 --- a/Makefile +++ b/Makefile @@ -904,6 +904,7 @@ LIB_OBJS += hash-lookup.o LIB_OBJS += hashmap.o LIB_OBJS += help.o LIB_OBJS += hex.o +LIB_OBJS += hook.o LIB_OBJS += ident.o LIB_OBJS += json-writer.o LIB_OBJS += kwset.o diff --git a/builtin/am.c b/builtin/am.c index e4a0ff9cd7c..3527945a467 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -11,6 +11,7 @@ #include "parse-options.h" #include "dir.h" #include "run-command.h" +#include "hook.h" #include "quote.h" #include "tempfile.h" #include "lockfile.h" diff --git a/builtin/bugreport.c b/builtin/bugreport.c index 06ed10dc92d..c30a360d695 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -3,7 +3,7 @@ #include "strbuf.h" #include "help.h" #include "compat/compiler.h" -#include "run-command.h" +#include "hook.h" static void get_system_info(struct strbuf *sys_info) diff --git a/builtin/commit.c b/builtin/commit.c index e7320f66f95..5359d961d22 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -19,6 +19,7 @@ #include "revision.h" #include "wt-status.h" #include "run-command.h" +#include "hook.h" #include "refs.h" #include "log-tree.h" #include "strbuf.h" diff --git a/builtin/merge.c b/builtin/merge.c index 3fbdacc7db4..fe664f6a863 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -13,6 +13,7 @@ #include "builtin.h" #include "lockfile.h" #include "run-command.h" +#include "hook.h" #include "diff.h" #include "diff-merges.h" #include "refs.h" diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 48960a9575b..e3895aec622 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -7,6 +7,7 @@ #include "pkt-line.h" #include "sideband.h" #include "run-command.h" +#include "hook.h" #include "exec-cmd.h" #include "commit.h" #include "object.h" diff --git a/builtin/worktree.c b/builtin/worktree.c index 0d0a80da61f..d22ece93e1a 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -8,6 +8,7 @@ #include "branch.h" #include "refs.h" #include "run-command.h" +#include "hook.h" #include "sigchain.h" #include "submodule.h" #include "utf8.h" diff --git a/hook.c b/hook.c new file mode 100644 index 00000000000..ba70b314718 --- /dev/null +++ b/hook.c @@ -0,0 +1,37 @@ +#include "cache.h" +#include "hook.h" +#include "run-command.h" + +const char *find_hook(const char *name) +{ + static struct strbuf path = STRBUF_INIT; + + strbuf_reset(&path); + strbuf_git_path(&path, "hooks/%s", name); + if (access(path.buf, X_OK) < 0) { + int err = errno; + +#ifdef STRIP_EXTENSION + strbuf_addstr(&path, STRIP_EXTENSION); + if (access(path.buf, X_OK) >= 0) + return path.buf; + if (errno == EACCES) + err = errno; +#endif + + if (err == EACCES && advice_enabled(ADVICE_IGNORED_HOOK)) { + static struct string_list advise_given = STRING_LIST_INIT_DUP; + + if (!string_list_lookup(&advise_given, name)) { + string_list_insert(&advise_given, name); + advise(_("The '%s' hook was ignored because " + "it's not set as executable.\n" + "You can disable this warning with " + "`git config advice.ignoredHook false`."), + path.buf); + } + } + return NULL; + } + return path.buf; +} diff --git a/hook.h b/hook.h new file mode 100644 index 00000000000..68624f16059 --- /dev/null +++ b/hook.h @@ -0,0 +1,11 @@ +#ifndef HOOK_H +#define HOOK_H + +/* + * Returns the path to the hook file, or NULL if the hook is missing + * or disabled. Note that this points to static storage that will be + * overwritten by further calls to find_hook and run_hook_*. + */ +const char *find_hook(const char *name); + +#endif diff --git a/refs.c b/refs.c index 8b9f7c3a80a..6211692eaae 100644 --- a/refs.c +++ b/refs.c @@ -10,6 +10,7 @@ #include "refs.h" #include "refs/refs-internal.h" #include "run-command.h" +#include "hook.h" #include "object-store.h" #include "object.h" #include "tag.h" diff --git a/run-command.c b/run-command.c index 04a07e6366e..e4862b8f46d 100644 --- a/run-command.c +++ b/run-command.c @@ -9,6 +9,7 @@ #include "quote.h" #include "config.h" #include "packfile.h" +#include "hook.h" void child_process_init(struct child_process *child) { @@ -1322,40 +1323,6 @@ int async_with_fork(void) #endif } -const char *find_hook(const char *name) -{ - static struct strbuf path = STRBUF_INIT; - - strbuf_reset(&path); - strbuf_git_path(&path, "hooks/%s", name); - if (access(path.buf, X_OK) < 0) { - int err = errno; - -#ifdef STRIP_EXTENSION - strbuf_addstr(&path, STRIP_EXTENSION); - if (access(path.buf, X_OK) >= 0) - return path.buf; - if (errno == EACCES) - err = errno; -#endif - - if (err == EACCES && advice_enabled(ADVICE_IGNORED_HOOK)) { - static struct string_list advise_given = STRING_LIST_INIT_DUP; - - if (!string_list_lookup(&advise_given, name)) { - string_list_insert(&advise_given, name); - advise(_("The '%s' hook was ignored because " - "it's not set as executable.\n" - "You can disable this warning with " - "`git config advice.ignoredHook false`."), - path.buf); - } - } - return NULL; - } - return path.buf; -} - int run_hook_ve(const char *const *env, const char *name, va_list args) { struct child_process hook = CHILD_PROCESS_INIT; diff --git a/run-command.h b/run-command.h index b9aff74914d..5e544acf4bc 100644 --- a/run-command.h +++ b/run-command.h @@ -224,13 +224,6 @@ int finish_command_in_signal(struct child_process *); */ int run_command(struct child_process *); -/* - * Returns the path to the hook file, or NULL if the hook is missing - * or disabled. Note that this points to static storage that will be - * overwritten by further calls to find_hook and run_hook_*. - */ -const char *find_hook(const char *name); - /** * Run a hook. * The first argument is a pathname to an index file, or NULL diff --git a/sequencer.c b/sequencer.c index 614d56f5e21..8ee6c4ac240 100644 --- a/sequencer.c +++ b/sequencer.c @@ -8,6 +8,7 @@ #include "sequencer.h" #include "tag.h" #include "run-command.h" +#include "hook.h" #include "exec-cmd.h" #include "utf8.h" #include "cache-tree.h" diff --git a/transport.c b/transport.c index b37664ba870..e4f1decae20 100644 --- a/transport.c +++ b/transport.c @@ -1,7 +1,7 @@ #include "cache.h" #include "config.h" #include "transport.h" -#include "run-command.h" +#include "hook.h" #include "pkt-line.h" #include "fetch-pack.h" #include "remote.h" From patchwork Sun Sep 26 19:03:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12518407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FCD5C433EF for ; Sun, 26 Sep 2021 19:03:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32AC960EE4 for ; Sun, 26 Sep 2021 19:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbhIZTFV (ORCPT ); Sun, 26 Sep 2021 15:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbhIZTFQ (ORCPT ); Sun, 26 Sep 2021 15:05:16 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD55DC061769 for ; Sun, 26 Sep 2021 12:03:38 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id x20so728554wrg.10 for ; Sun, 26 Sep 2021 12:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NBanF96Un0N3wZuBcysKAvacpqSENpQbHTlJA+31n7A=; b=Dpjl2/xNG6NTn3qeUY1KZYFFYlf0B7yUP7HT5n0zElUSNsZUV0rU7xF5Cc/83FjWBT nStykCKpOmZxtKD8S7FQqDkpBGA/dWKg5fFSWEw58Gr6WS8hLSf9MZ8RAVVo9kwvcGDZ j6iYCUO6CEBBKXPUGLhii2/89Rl5ne1SbqlFZd9W+4yyoIesLE0dvm4gKodM6uLG56iP CVesNpSIlpZR9Jz0CtAhottQ8a0Rpyu08aoicahvwvEPr7P4SzNDWmMpzbs0HDV5Hpqt C2uMRwh/9+W00d1dvYUjlpc5AooAMdkME1uvZgyateoWFQg5ouNX+wW7RCJOcCy5Swox xTdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NBanF96Un0N3wZuBcysKAvacpqSENpQbHTlJA+31n7A=; b=0KS04BsqpPIx1u7EgDQGZbxojt/mjsXGi7sm/qVcrGC/uhA6A8XfJtbP/qg6h9v0h9 ol8ZXXjfqASs9Ww+e58X7lWbppk8kF3TGEvm9xTgZ2PEHZtq+8KyLiZa63WSI7MPtCEE OTNmK/q4qswGKFYIa9oH2S3M5GHIfHT9fWg1LBbn1sdEuhxlzOG8Y67vN0vyjLcPCKQN ZhhDMhJkHGcytELoiWHEO70dSBuTUTet1lCd2uj04Pncp7A300K2lezPy4TrOKAoH74b erg7RQlIvW0884RZMFA0EU/6R+7tZHMgRqlkqTs7NColU72JBnKfUi2vskqAZSs5fmB3 AsyA== X-Gm-Message-State: AOAM533myM8mWGI2jGJU86JKeROd7pn/9amZA7cC7MgRFjfyrsPIQ3y/ G3iCNuQw07fKPi1A3KWV9f3Ehd+hvSMDZg== X-Google-Smtp-Source: ABdhPJyAxLmkVu8BBSeVnoYMKVgggqCmg2+ymnmIQwAQFs+1omTJYr6j2bVA0bieZKaw/X5L51PW2w== X-Received: by 2002:a1c:770d:: with SMTP id t13mr12306658wmi.77.1632683017201; Sun, 26 Sep 2021 12:03:37 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v20sm14691523wra.73.2021.09.26.12.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:03:36 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Jeff King , Phillip Wood , =?utf-8?q?Ren=C3=A9_Scharfe?= , =?utf-8?b?w4Z2YXIgQXJuZmo=?= =?utf-8?b?w7Zyw7AgQmphcm1hc29u?= Subject: [PATCH v2 6/8] hook.c: add a hook_exists() wrapper and use it in bugreport.c Date: Sun, 26 Sep 2021 21:03:27 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1291.g8857a6a91ac In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Add a boolean version of the find_hook() function for those callers who are only interested in checking whether the hook exists, not what the path to it is. Signed-off-by: Emily Shaffer Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bugreport.c | 2 +- hook.c | 5 +++++ hook.h | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/builtin/bugreport.c b/builtin/bugreport.c index c30a360d695..a02c2540bb1 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -82,7 +82,7 @@ static void get_populated_hooks(struct strbuf *hook_info, int nongit) } for (i = 0; i < ARRAY_SIZE(hook); i++) - if (find_hook(hook[i])) + if (hook_exists(hook[i])) strbuf_addf(hook_info, "%s\n", hook[i]); } diff --git a/hook.c b/hook.c index ba70b314718..55e1145a4b7 100644 --- a/hook.c +++ b/hook.c @@ -35,3 +35,8 @@ const char *find_hook(const char *name) } return path.buf; } + +int hook_exists(const char *name) +{ + return !!find_hook(name); +} diff --git a/hook.h b/hook.h index 68624f16059..6aa36fc7ff9 100644 --- a/hook.h +++ b/hook.h @@ -8,4 +8,9 @@ */ const char *find_hook(const char *name); +/** + * A boolean version of find_hook() + */ +int hook_exists(const char *hookname); + #endif From patchwork Sun Sep 26 19:03:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12518409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0391EC433F5 for ; Sun, 26 Sep 2021 19:03:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEA3160EE4 for ; Sun, 26 Sep 2021 19:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbhIZTFW (ORCPT ); Sun, 26 Sep 2021 15:05:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbhIZTFQ (ORCPT ); Sun, 26 Sep 2021 15:05:16 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F0DBC06176A for ; Sun, 26 Sep 2021 12:03:39 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id v17so2015754wrv.9 for ; Sun, 26 Sep 2021 12:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cGhk1Vgzr6nEX1gRTci2F0gc3WPAGl9wU0rY8Mqh1OA=; b=GnzEa54zGqjpjx3WB4oVulf/Fw0lNzLqO7Qak4WAx50hbnGBGl+njz1FN8O5k642y9 GDFRURVhCuyny3MVJkCf6zgs0XaaJXjQGxBSpVsLiflN3Lx7/y9Z3lKVirdJkk5BBuMu sWo1ZL4F73o+znCOaHbGYxCXaOYrzJtZcYF3K0FBFTzobBFTSnSwHYoK7VefeRlLCY4h 5QN2tO6eu5Z06AQ73rpAT8qoC9ZXAx0VMGXPrP7M8u/MkcZHyJI4Ej4xNIYc/K6MUBRG CdfRklZ7ulXqQUmfuXwKkHDRakdlD0cB2c11sbO1UZVDtMyeWSe0w6cmcM194SY5sJrS vMJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cGhk1Vgzr6nEX1gRTci2F0gc3WPAGl9wU0rY8Mqh1OA=; b=7MKfFkBA5H4dPN1OfuAJ/Zy74Kp6JgYCDPnKf6jrUt3TnnuhTAP60EjX0Le4aQXL9a +WbaeoZC4DLomnNyBvhyDl8+TYS4sevvfaqbzKkXl0ILoZ//vXi9gbo0JUgcrAoD81HF TMhA4MXruGtK/8lkq0k9hJUBi/FNruwPpcLhnvMXVxb4COeDHwwKxQktBCpoobRVUTJu 7HUSWEgyxyr/I4nRDkUBQV76zIs30cZ7KBk6BvkP+OxBWffn7/oJtYd+Tzh5Cgb0v8Qu V4ciZAjdYA8tJo4WyqEVkkuoHl0FsR+L4NK/XO8TOM/iXqwo9gKcQqS/3ShLfAeDx7CR TVlQ== X-Gm-Message-State: AOAM532zJVQAeEEP8CruFzYC6kMWy7EBaSVQQul3/Uy7d6G5UR5r0M4F NzdelhZgF2mB96ODQooxjPjgxY/sg2gGSw== X-Google-Smtp-Source: ABdhPJworu0/h4FOi7dnLP+ColgBGfs+DduPvX7hR6bNN+Q6N17e4W7DlMJyt2UghyGCkevOh0m9/g== X-Received: by 2002:a7b:c453:: with SMTP id l19mr12210725wmi.7.1632683017887; Sun, 26 Sep 2021 12:03:37 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v20sm14691523wra.73.2021.09.26.12.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:03:37 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Jeff King , Phillip Wood , =?utf-8?q?Ren=C3=A9_Scharfe?= , =?utf-8?b?w4Z2YXIgQXJuZmo=?= =?utf-8?b?w7Zyw7AgQmphcm1hc29u?= Subject: [PATCH v2 7/8] hook.c users: use "hook_exists()" instead of "find_hook()" Date: Sun, 26 Sep 2021 21:03:28 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1291.g8857a6a91ac In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Use the new hook_exists() function instead of find_hook() where the latter was called in boolean contexts. This make subsequent changes in a series where we further refactor the hook API clearer, as we won't conflate wanting to get the path of the hook with checking for its existence. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/commit.c | 2 +- builtin/merge.c | 2 +- builtin/receive-pack.c | 2 +- sequencer.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 5359d961d22..883c16256c8 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1052,7 +1052,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, return 0; } - if (!no_verify && find_hook("pre-commit")) { + if (!no_verify && hook_exists("pre-commit")) { /* * Re-read the index as pre-commit hook could have updated it, * and write it out as a tree. We must do this before we invoke diff --git a/builtin/merge.c b/builtin/merge.c index fe664f6a863..956b6259f21 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -849,7 +849,7 @@ static void prepare_to_commit(struct commit_list *remoteheads) * and write it out as a tree. We must do this before we invoke * the editor and after we invoke run_status above. */ - if (find_hook("pre-merge-commit")) + if (hook_exists("pre-merge-commit")) discard_cache(); read_cache_from(index_file); strbuf_addbuf(&msg, &merge_msg); diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index e3895aec622..25cc0c907e1 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1464,7 +1464,7 @@ static const char *update_worktree(unsigned char *sha1, const struct worktree *w strvec_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir)); - if (!find_hook(push_to_checkout_hook)) + if (!hook_exists(push_to_checkout_hook)) retval = push_to_deploy(sha1, &env, work_tree); else retval = push_to_checkout(sha1, &env, work_tree); diff --git a/sequencer.c b/sequencer.c index 8ee6c4ac240..e501945796d 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1460,7 +1460,7 @@ static int try_to_commit(struct repository *r, } } - if (find_hook("prepare-commit-msg")) { + if (hook_exists("prepare-commit-msg")) { res = run_prepare_commit_msg_hook(r, msg, hook_commit); if (res) goto out; From patchwork Sun Sep 26 19:03:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12518411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2446C433EF for ; Sun, 26 Sep 2021 19:03:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC78C60EE4 for ; Sun, 26 Sep 2021 19:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbhIZTF0 (ORCPT ); Sun, 26 Sep 2021 15:05:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbhIZTFR (ORCPT ); Sun, 26 Sep 2021 15:05:17 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B6CC061604 for ; Sun, 26 Sep 2021 12:03:40 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id v17so2015853wrv.9 for ; Sun, 26 Sep 2021 12:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cYEONVduxMEKD6Z4E0+Rm3E/MNFnUnQKAp467O6U5mc=; b=hDSMHOqREvGBk17QhKeZB0eQhXgIbXJIY1fJZEY4V44sgwSHIv62QOTl9N7BVBRlPI b8ImDyo3LuPLYA64WfXEaFDFKG+Px5u2Wt3ldDjByfMXtwhQ2UGIbYhuqaZjJ6FkZgn/ yapsEbrN7kh4H9941fjAj7aU1Zj95LgXNwgZLK1zHQAxhtxQOnTEfP8BboA9wNSpqkQZ q4L+mUdz88FVj48y2jepyn90eQcjkZQUxy40BqP8rL58ZAcXjJJodyAe+2CrhiR7PEPu cGRa7IIiExp2ZmnTuhcnKai8nDaFe8oxLdsOWlHOvbdMwjdfuJ6XYMrQEtOdIZUz1KQ8 AAtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cYEONVduxMEKD6Z4E0+Rm3E/MNFnUnQKAp467O6U5mc=; b=Pmfdizgp7bgKMBDGG3itQD/ePQl3USaSFsomZQB2hqOrM3GqmnkGPY9CixADLlfmaJ M9Fz8JaVbTRtNADBM5bk5GoyJOI9NI8w9ezV0HWfy32BMEDmWbOMZFfOPazD3jevN1Oq xC0byT6+Ukdo44JEEfxgK9LmimJiaxSiUMYh1wTVwFXpojw+4Q5JxvcSAHopT6sjKcyn 8gUaYxF+8UAU2uF3IwlB0ysIyvDNNiD90U5BNTNWUaA55KOrMnn+RJ2Hc1LzGthPBV1s lRrjqTzkzIITGLMXuFVC5VzElIcz9frk8EgFYQYeDZ/tdxuTQnJ/Ho0LWt4+r2mYzwm1 wBzg== X-Gm-Message-State: AOAM53299ky/WCM7abIMkprZdWuw911uk2fpEtVT5/PnaG8W1rWIgBNf GBjS8xPJ6ziWDbQYv0p+k5iJHgsboa6MHQ== X-Google-Smtp-Source: ABdhPJwBvXaf5CbNSVfZg78Lhv9yIaYr2YrIbX5zu9GSwoYfOSSD42RVmY+oBsIrr07VBtzwnxtSJw== X-Received: by 2002:a1c:43c3:: with SMTP id q186mr4179033wma.143.1632683018680; Sun, 26 Sep 2021 12:03:38 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v20sm14691523wra.73.2021.09.26.12.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:03:38 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Jeff King , Phillip Wood , =?utf-8?q?Ren=C3=A9_Scharfe?= , =?utf-8?b?w4Z2YXIgQXJuZmo=?= =?utf-8?b?w7Zyw7AgQmphcm1hc29u?= Subject: [PATCH v2 8/8] hook-list.h: add a generated list of hooks, like config-list.h Date: Sun, 26 Sep 2021 21:03:29 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1291.g8857a6a91ac In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Make githooks(5) the source of truth for what hooks git supports, and punt out early on hooks we don't know about in find_hook(). This ensures that the documentation and the C code's idea about existing hooks doesn't diverge. We still have Perl and Python code running its own hooks, but that'll be addressed by Emily Shaffer's upcoming "git hook run" command. This resolves a long-standing TODO item in bugreport.c of there being no centralized listing of hooks, and fixes a bug with the bugreport listing only knowing about 1/4 of the p4 hooks. It didn't know about the recent "reference-transaction" hook either. We could make the find_hook() function die() or BUG() out if the new known_hook() returned 0, but let's make it return NULL just as it does when it can't find a hook of a known type. Making it die() is overly anal, and unlikely to be what we need in catching stupid typos in the name of some new hook hardcoded in git.git's sources. By making this be tolerant of unknown hook names, changes in a later series to make "git hook run" run arbitrary user-configured hook names will be easier to implement. I have not been able to directly test the CMake change being made here. Since 4c2c38e800 (ci: modification of main.yml to use cmake for vs-build job, 2020-06-26) some of the Windows CI has a hard dependency on CMake, this change works there, and is to my eyes an obviously correct use of a pattern established in previous CMake changes, namely: - 061c2240b1 (Introduce CMake support for configuring Git, 2020-06-12) - 709df95b78 (help: move list_config_help to builtin/help, 2020-04-16) - 976aaedca0 (msvc: add a Makefile target to pre-generate the Visual Studio solution, 2019-07-29) The LC_ALL=C is needed because at least in my locale the dash ("-") is ignored for the purposes of sorting, which results in a different order. I'm not aware of anything in git that has a hard dependency on the order, but e.g. the bugreport output would end up using whatever locale was in effect when git was compiled. Signed-off-by: Ævar Arnfjörð Bjarmason Helped-by: René Scharfe --- .gitignore | 1 + Makefile | 8 +++++- builtin/bugreport.c | 44 ++++++----------------------- contrib/buildsystems/CMakeLists.txt | 7 +++++ generate-hooklist.sh | 20 +++++++++++++ 5 files changed, 43 insertions(+), 37 deletions(-) create mode 100755 generate-hooklist.sh diff --git a/.gitignore b/.gitignore index 311841f9bed..6be9de41ae8 100644 --- a/.gitignore +++ b/.gitignore @@ -190,6 +190,7 @@ /gitweb/static/gitweb.min.* /config-list.h /command-list.h +/hook-list.h *.tar.gz *.dsc *.deb diff --git a/Makefile b/Makefile index 1f2b0205da5..21e2bcc21e3 100644 --- a/Makefile +++ b/Makefile @@ -817,6 +817,8 @@ XDIFF_LIB = xdiff/lib.a GENERATED_H += command-list.h GENERATED_H += config-list.h +GENERATED_H += hook-list.h + .PHONY: generated-hdrs generated-hdrs: $(GENERATED_H) @@ -2208,8 +2210,9 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) $(filter %.o,$^) $(LIBS) help.sp help.s help.o: command-list.h +hook.sp hook.s hook.o: hook-list.h -builtin/help.sp builtin/help.s builtin/help.o: config-list.h GIT-PREFIX +builtin/help.sp builtin/help.s builtin/help.o: config-list.h hook-list.h GIT-PREFIX builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \ '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \ @@ -2241,6 +2244,9 @@ command-list.h: $(wildcard Documentation/git*.txt) $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@ +hook-list.h: generate-hooklist.sh Documentation/githooks.txt + $(QUIET_GEN)$(SHELL_PATH) ./generate-hooklist.sh >$@ + SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\ $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\ $(gitwebdir_SQ):$(PERL_PATH_SQ):$(SANE_TEXT_GREP):$(PAGER_ENV):\ diff --git a/builtin/bugreport.c b/builtin/bugreport.c index a02c2540bb1..9de32bc96e7 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -4,6 +4,7 @@ #include "help.h" #include "compat/compiler.h" #include "hook.h" +#include "hook-list.h" static void get_system_info(struct strbuf *sys_info) @@ -41,39 +42,7 @@ static void get_system_info(struct strbuf *sys_info) static void get_populated_hooks(struct strbuf *hook_info, int nongit) { - /* - * NEEDSWORK: Doesn't look like there is a list of all possible hooks; - * so below is a transcription of `git help hooks`. Later, this should - * be replaced with some programmatically generated list (generated from - * doc or else taken from some library which tells us about all the - * hooks) - */ - static const char *hook[] = { - "applypatch-msg", - "pre-applypatch", - "post-applypatch", - "pre-commit", - "pre-merge-commit", - "prepare-commit-msg", - "commit-msg", - "post-commit", - "pre-rebase", - "post-checkout", - "post-merge", - "pre-push", - "pre-receive", - "update", - "post-receive", - "post-update", - "push-to-checkout", - "pre-auto-gc", - "post-rewrite", - "sendemail-validate", - "fsmonitor-watchman", - "p4-pre-submit", - "post-index-change", - }; - int i; + const char **p; if (nongit) { strbuf_addstr(hook_info, @@ -81,9 +50,12 @@ static void get_populated_hooks(struct strbuf *hook_info, int nongit) return; } - for (i = 0; i < ARRAY_SIZE(hook); i++) - if (hook_exists(hook[i])) - strbuf_addf(hook_info, "%s\n", hook[i]); + for (p = hook_name_list; *p; p++) { + const char *hook = *p; + + if (hook_exists(hook)) + strbuf_addf(hook_info, "%s\n", hook); + } } static const char * const bugreport_usage[] = { diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt index 171b4124afe..fd1399c440f 100644 --- a/contrib/buildsystems/CMakeLists.txt +++ b/contrib/buildsystems/CMakeLists.txt @@ -624,6 +624,13 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h) OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h) endif() +if(NOT EXISTS ${CMAKE_BINARY_DIR}/hook-list.h) + message("Generating hook-list.h") + execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-hooklist.sh + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_FILE ${CMAKE_BINARY_DIR}/hook-list.h) +endif() + include_directories(${CMAKE_BINARY_DIR}) #build diff --git a/generate-hooklist.sh b/generate-hooklist.sh new file mode 100755 index 00000000000..2f9f54eb545 --- /dev/null +++ b/generate-hooklist.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Usage: ./generate-hooklist.sh >hook-list.h + +cat <