]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hook.c: add a hook_exists() wrapper and use it in bugreport.c
authorEmily Shaffer <emilyshaffer@google.com>
Sun, 26 Sep 2021 19:03:27 +0000 (21:03 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Sep 2021 16:44:54 +0000 (09:44 -0700)
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>
builtin/bugreport.c
hook.c
hook.h

index c30a360d6955b9eda0d34537bc42f56e651d0a8a..a02c2540bb17ef08dcd58ff0991c1cbab1da74b9 100644 (file)
@@ -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 ba70b314718845185dd1757efa8f1c1a3b252500..55e1145a4b7b8c59276f082ab0b240817702ace4 100644 (file)
--- 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 68624f16059dfb4f62253d4772a1df264f07936f..6aa36fc7ff9b07e9a97cbfccaa53b81452fe5b37 100644 (file)
--- 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