summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmily Shaffer <emilyshaffer@google.com>2021-09-23 10:30:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-23 22:06:48 (GMT)
commit13cb920fa14e4f8fab3ad8c742ba23fbe6ce7709 (patch)
tree5c2d5ef47660abd4a64e2fbdef570070e4357323
parent766f695cea6448cf9250829381232f279d98d953 (diff)
downloadgit-13cb920fa14e4f8fab3ad8c742ba23fbe6ce7709.zip
git-13cb920fa14e4f8fab3ad8c742ba23fbe6ce7709.tar.gz
git-13cb920fa14e4f8fab3ad8c742ba23fbe6ce7709.tar.bz2
hook.c: add a hook_exists() wrapper and use it in bugreport.c
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/bugreport.c2
-rw-r--r--hook.c5
-rw-r--r--hook.h5
3 files changed, 11 insertions, 1 deletions
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index c30a360..a02c254 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 ba70b31..55e1145 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 68624f1..6aa36fc 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