File tree Expand file tree Collapse file tree 14 files changed +59
-43
lines changed Expand file tree Collapse file tree 14 files changed +59
-43
lines changed Original file line number Diff line number Diff line change @@ -904,6 +904,7 @@ LIB_OBJS += hash-lookup.o
904
904
LIB_OBJS += hashmap.o
905
905
LIB_OBJS += help.o
906
906
LIB_OBJS += hex.o
907
+ LIB_OBJS += hook.o
907
908
LIB_OBJS += ident.o
908
909
LIB_OBJS += json-writer.o
909
910
LIB_OBJS += kwset.o
Original file line number Diff line number Diff line change 11
11
#include "parse-options.h"
12
12
#include "dir.h"
13
13
#include "run-command.h"
14
+ #include "hook.h"
14
15
#include "quote.h"
15
16
#include "tempfile.h"
16
17
#include "lockfile.h"
Original file line number Diff line number Diff line change 3
3
#include "strbuf.h"
4
4
#include "help.h"
5
5
#include "compat/compiler.h"
6
- #include "run-command .h"
6
+ #include "hook .h"
7
7
8
8
9
9
static void get_system_info (struct strbuf * sys_info )
Original file line number Diff line number Diff line change 19
19
#include "revision.h"
20
20
#include "wt-status.h"
21
21
#include "run-command.h"
22
+ #include "hook.h"
22
23
#include "refs.h"
23
24
#include "log-tree.h"
24
25
#include "strbuf.h"
Original file line number Diff line number Diff line change 13
13
#include "builtin.h"
14
14
#include "lockfile.h"
15
15
#include "run-command.h"
16
+ #include "hook.h"
16
17
#include "diff.h"
17
18
#include "diff-merges.h"
18
19
#include "refs.h"
Original file line number Diff line number Diff line change 7
7
#include "pkt-line.h"
8
8
#include "sideband.h"
9
9
#include "run-command.h"
10
+ #include "hook.h"
10
11
#include "exec-cmd.h"
11
12
#include "commit.h"
12
13
#include "object.h"
Original file line number Diff line number Diff line change 8
8
#include "branch.h"
9
9
#include "refs.h"
10
10
#include "run-command.h"
11
+ #include "hook.h"
11
12
#include "sigchain.h"
12
13
#include "submodule.h"
13
14
#include "utf8.h"
Original file line number Diff line number Diff line change
1
+ #include "cache.h"
2
+ #include "hook.h"
3
+ #include "run-command.h"
4
+
5
+ const char * find_hook (const char * name )
6
+ {
7
+ static struct strbuf path = STRBUF_INIT ;
8
+
9
+ strbuf_reset (& path );
10
+ strbuf_git_path (& path , "hooks/%s" , name );
11
+ if (access (path .buf , X_OK ) < 0 ) {
12
+ int err = errno ;
13
+
14
+ #ifdef STRIP_EXTENSION
15
+ strbuf_addstr (& path , STRIP_EXTENSION );
16
+ if (access (path .buf , X_OK ) >= 0 )
17
+ return path .buf ;
18
+ if (errno == EACCES )
19
+ err = errno ;
20
+ #endif
21
+
22
+ if (err == EACCES && advice_enabled (ADVICE_IGNORED_HOOK )) {
23
+ static struct string_list advise_given = STRING_LIST_INIT_DUP ;
24
+
25
+ if (!string_list_lookup (& advise_given , name )) {
26
+ string_list_insert (& advise_given , name );
27
+ advise (_ ("The '%s' hook was ignored because "
28
+ "it's not set as executable.\n"
29
+ "You can disable this warning with "
30
+ "`git config advice.ignoredHook false`." ),
31
+ path .buf );
32
+ }
33
+ }
34
+ return NULL ;
35
+ }
36
+ return path .buf ;
37
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef HOOK_H
2
+ #define HOOK_H
3
+
4
+ /*
5
+ * Returns the path to the hook file, or NULL if the hook is missing
6
+ * or disabled. Note that this points to static storage that will be
7
+ * overwritten by further calls to find_hook and run_hook_*.
8
+ */
9
+ const char * find_hook (const char * name );
10
+
11
+ #endif
Original file line number Diff line number Diff line change 10
10
#include "refs.h"
11
11
#include "refs/refs-internal.h"
12
12
#include "run-command.h"
13
+ #include "hook.h"
13
14
#include "object-store.h"
14
15
#include "object.h"
15
16
#include "tag.h"
Original file line number Diff line number Diff line change 9
9
#include "quote.h"
10
10
#include "config.h"
11
11
#include "packfile.h"
12
+ #include "hook.h"
12
13
13
14
void child_process_init (struct child_process * child )
14
15
{
@@ -1322,40 +1323,6 @@ int async_with_fork(void)
1322
1323
#endif
1323
1324
}
1324
1325
1325
- const char * find_hook (const char * name )
1326
- {
1327
- static struct strbuf path = STRBUF_INIT ;
1328
-
1329
- strbuf_reset (& path );
1330
- strbuf_git_path (& path , "hooks/%s" , name );
1331
- if (access (path .buf , X_OK ) < 0 ) {
1332
- int err = errno ;
1333
-
1334
- #ifdef STRIP_EXTENSION
1335
- strbuf_addstr (& path , STRIP_EXTENSION );
1336
- if (access (path .buf , X_OK ) >= 0 )
1337
- return path .buf ;
1338
- if (errno == EACCES )
1339
- err = errno ;
1340
- #endif
1341
-
1342
- if (err == EACCES && advice_enabled (ADVICE_IGNORED_HOOK )) {
1343
- static struct string_list advise_given = STRING_LIST_INIT_DUP ;
1344
-
1345
- if (!string_list_lookup (& advise_given , name )) {
1346
- string_list_insert (& advise_given , name );
1347
- advise (_ ("The '%s' hook was ignored because "
1348
- "it's not set as executable.\n"
1349
- "You can disable this warning with "
1350
- "`git config advice.ignoredHook false`." ),
1351
- path .buf );
1352
- }
1353
- }
1354
- return NULL ;
1355
- }
1356
- return path .buf ;
1357
- }
1358
-
1359
1326
int run_hook_ve (const char * const * env , const char * name , va_list args )
1360
1327
{
1361
1328
struct child_process hook = CHILD_PROCESS_INIT ;
Original file line number Diff line number Diff line change @@ -224,13 +224,6 @@ int finish_command_in_signal(struct child_process *);
224
224
*/
225
225
int run_command (struct child_process * );
226
226
227
- /*
228
- * Returns the path to the hook file, or NULL if the hook is missing
229
- * or disabled. Note that this points to static storage that will be
230
- * overwritten by further calls to find_hook and run_hook_*.
231
- */
232
- const char * find_hook (const char * name );
233
-
234
227
/**
235
228
* Run a hook.
236
229
* The first argument is a pathname to an index file, or NULL
Original file line number Diff line number Diff line change 8
8
#include "sequencer.h"
9
9
#include "tag.h"
10
10
#include "run-command.h"
11
+ #include "hook.h"
11
12
#include "exec-cmd.h"
12
13
#include "utf8.h"
13
14
#include "cache-tree.h"
Original file line number Diff line number Diff line change 1
1
#include "cache.h"
2
2
#include "config.h"
3
3
#include "transport.h"
4
- #include "run-command .h"
4
+ #include "hook .h"
5
5
#include "pkt-line.h"
6
6
#include "fetch-pack.h"
7
7
#include "remote.h"
You can’t perform that action at this time.
0 commit comments