From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Emily Shaffer" <emilyshaffer@google.com>,
"Jeff Hostetler" <jeffhost@microsoft.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Felipe Contreras" <felipe.contreras@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 2/3] hook.c: add a hook_exists() wrapper and use it in bugreport.c
Date: Thu, 17 Jun 2021 12:09:35 +0200 [thread overview]
Message-ID: <patch-2.3-0cf7e078ef-20210617T100239Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-0.3-0000000000-20210617T100239Z-avarab@gmail.com>
From: Emily Shaffer <emilyshaffer@google.com>
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 <emilyshaffer@google.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
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 596f079a7f..941c8d5e27 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 c4dbef1d0e..97cd799a32 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 68624f1605..4c547ac15e 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
--
2.32.0.576.g59759b6ca7d
next prev parent reply other threads:[~2021-06-17 10:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 10:09 [PATCH 0/3] Add a generated list of hooks in hook-list.h Ævar Arnfjörð Bjarmason
2021-06-17 10:09 ` [PATCH 1/3] hook.[ch]: move find_hook() to this new library Ævar Arnfjörð Bjarmason
2021-06-17 10:09 ` Ævar Arnfjörð Bjarmason [this message]
2021-06-17 10:09 ` [PATCH 3/3] hook-list.h: add a generated list of hooks, like config-list.h Ævar Arnfjörð Bjarmason
2021-06-18 17:05 ` SZEDER Gábor
2021-06-18 17:50 ` Eric Sunshine
2021-06-19 6:06 ` Junio C Hamano
2021-06-20 13:53 ` Ævar Arnfjörð Bjarmason
2021-06-20 12:53 ` René Scharfe
2021-06-22 22:32 ` Johannes Schindelin
2021-06-29 0:32 ` Junio C Hamano
2021-06-29 17:53 ` René Scharfe
2021-06-29 18:53 ` [PATCH v2 0/3] Add a generated list of hooks in hook-list.h Ævar Arnfjörð Bjarmason
2021-06-29 18:54 ` [PATCH v2 1/3] hook.[ch]: move find_hook() to this new library Ævar Arnfjörð Bjarmason
2021-06-29 18:54 ` [PATCH v2 2/3] hook.c: add a hook_exists() wrapper and use it in bugreport.c Ævar Arnfjörð Bjarmason
2021-06-29 18:54 ` [PATCH v2 3/3] hook-list.h: add a generated list of hooks, like config-list.h Ævar Arnfjörð Bjarmason
2021-06-29 19:45 ` René Scharfe
2021-06-29 22:09 ` Ævar Arnfjörð Bjarmason
2021-07-09 20:29 ` Emily Shaffer
2021-07-10 9:03 ` Ævar Arnfjörð Bjarmason
2021-07-12 20:55 ` Emily Shaffer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=patch-2.3-0cf7e078ef-20210617T100239Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=emilyshaffer@google.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jeffhost@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).