Skip to content

Commit 330155e

Browse files
nasamuffingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5e3aba3 commit 330155e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

builtin/bugreport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static void get_populated_hooks(struct strbuf *hook_info, int nongit)
8282
}
8383

8484
for (i = 0; i < ARRAY_SIZE(hook); i++)
85-
if (find_hook(hook[i]))
85+
if (hook_exists(hook[i]))
8686
strbuf_addf(hook_info, "%s\n", hook[i]);
8787
}
8888

hook.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ const char *find_hook(const char *name)
3535
}
3636
return path.buf;
3737
}
38+
39+
int hook_exists(const char *name)
40+
{
41+
return !!find_hook(name);
42+
}

hook.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@
88
*/
99
const char *find_hook(const char *name);
1010

11+
/**
12+
* A boolean version of find_hook()
13+
*/
14+
int hook_exists(const char *hookname);
15+
1116
#endif

0 commit comments

Comments
 (0)