File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -62,9 +62,6 @@ static int pick_next_hook(struct child_process *cp,
62
62
strvec_push (& cp -> args , hook_path );
63
63
strvec_pushv (& cp -> args , hook_cb -> options -> args .v );
64
64
65
- /* Provide context for errors if necessary */
66
- * pp_task_cb = (char * )hook_path ;
67
-
68
65
/*
69
66
* This pick_next_hook() will be called again, we're only
70
67
* running one hook, so indicate that no more work will be
@@ -80,13 +77,9 @@ static int notify_start_failure(struct strbuf *out,
80
77
void * pp_task_cp )
81
78
{
82
79
struct hook_cb_data * hook_cb = pp_cb ;
83
- const char * hook_path = pp_task_cp ;
84
80
85
81
hook_cb -> rc |= 1 ;
86
82
87
- strbuf_addf (out , _ ("Couldn't start hook '%s'\n" ),
88
- hook_path );
89
-
90
83
return 1 ;
91
84
}
92
85
Original file line number Diff line number Diff line change @@ -151,4 +151,30 @@ test_expect_success TTY 'git commit: stdout and stderr are connected to a TTY' '
151
151
test_hook_tty commit -m"B.new"
152
152
'
153
153
154
+ test_expect_success ' git hook run a hook with a bad shebang' '
155
+ test_when_finished "rm -rf bad-hooks" &&
156
+ mkdir bad-hooks &&
157
+ write_script bad-hooks/test-hook "/bad/path/no/spaces" </dev/null &&
158
+
159
+ # TODO: We should emit the same (or at least a more similar)
160
+ # error on Windows and !Windows. See the OS-specific code in
161
+ # start_command()
162
+ if test_have_prereq !WINDOWS
163
+ then
164
+ cat >expect <<-\EOF
165
+ fatal: cannot run bad-hooks/test-hook: ...
166
+ EOF
167
+ else
168
+ cat >expect <<-\EOF
169
+ error: cannot spawn bad-hooks/test-hook: ...
170
+ EOF
171
+ fi &&
172
+ test_expect_code 1 git \
173
+ -c core.hooksPath=bad-hooks \
174
+ hook run test-hook >out 2>err &&
175
+ test_must_be_empty out &&
176
+ sed -e "s/test-hook: .*/test-hook: .../" <err >actual &&
177
+ test_cmp expect actual
178
+ '
179
+
154
180
test_done
You can’t perform that action at this time.
0 commit comments