Skip to content

Commit 1456b04

Browse files
committed
Remove post-upload-hook
This hook runs after "git fetch" in the repository the objects are fetched from as the user who fetched, and has security implications. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5c30b8f commit 1456b04

File tree

4 files changed

+2
-172
lines changed

4 files changed

+2
-172
lines changed

Documentation/git-upload-pack.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ The UI for the protocol is on the 'git-fetch-pack' side, and the
2020
program pair is meant to be used to pull updates from a remote
2121
repository. For push operations, see 'git-send-pack'.
2222

23-
After finishing the operation successfully, `post-upload-pack`
24-
hook is called (see linkgit:githooks[5]).
2523

2624
OPTIONS
2725
-------

Documentation/githooks.txt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -310,35 +310,6 @@ Both standard output and standard error output are forwarded to
310310
'git-send-pack' on the other end, so you can simply `echo` messages
311311
for the user.
312312

313-
post-upload-pack
314-
----------------
315-
316-
After upload-pack successfully finishes its operation, this hook is called
317-
for logging purposes.
318-
319-
The hook is passed various pieces of information, one per line, from its
320-
standard input. Currently the following items can be fed to the hook, but
321-
more types of information may be added in the future:
322-
323-
want SHA-1::
324-
40-byte hexadecimal object name the client asked to include in the
325-
resulting pack. Can occur one or more times in the input.
326-
327-
have SHA-1::
328-
40-byte hexadecimal object name the client asked to exclude from
329-
the resulting pack, claiming to have them already. Can occur zero
330-
or more times in the input.
331-
332-
time float::
333-
Number of seconds spent for creating the packfile.
334-
335-
size decimal::
336-
Size of the resulting packfile in bytes.
337-
338-
kind string:
339-
Either "clone" (when the client did not give us any "have", and asked
340-
for all our refs with "want"), or "fetch" (otherwise).
341-
342313
pre-auto-gc
343314
~~~~~~~~~~~
344315

t/t5501-post-upload-pack.sh

Lines changed: 0 additions & 69 deletions
This file was deleted.

upload-pack.c

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -146,79 +146,19 @@ static int do_rev_list(int fd, void *create_full_pack)
146146
return 0;
147147
}
148148

149-
static int feed_msg_to_hook(int fd, const char *fmt, ...)
150-
{
151-
int cnt;
152-
char buf[1024];
153-
va_list params;
154-
155-
va_start(params, fmt);
156-
cnt = vsprintf(buf, fmt, params);
157-
va_end(params);
158-
return write_in_full(fd, buf, cnt) != cnt;
159-
}
160-
161-
static int feed_obj_to_hook(const char *label, struct object_array *oa, int i, int fd)
162-
{
163-
return feed_msg_to_hook(fd, "%s %s\n", label,
164-
sha1_to_hex(oa->objects[i].item->sha1));
165-
}
166-
167-
static int run_post_upload_pack_hook(size_t total, struct timeval *tv)
168-
{
169-
const char *argv[2];
170-
struct child_process proc;
171-
int err, i;
172-
173-
argv[0] = "hooks/post-upload-pack";
174-
argv[1] = NULL;
175-
176-
if (access(argv[0], X_OK) < 0)
177-
return 0;
178-
179-
memset(&proc, 0, sizeof(proc));
180-
proc.argv = argv;
181-
proc.in = -1;
182-
proc.stdout_to_stderr = 1;
183-
err = start_command(&proc);
184-
if (err)
185-
return err;
186-
for (i = 0; !err && i < want_obj.nr; i++)
187-
err |= feed_obj_to_hook("want", &want_obj, i, proc.in);
188-
for (i = 0; !err && i < have_obj.nr; i++)
189-
err |= feed_obj_to_hook("have", &have_obj, i, proc.in);
190-
if (!err)
191-
err |= feed_msg_to_hook(proc.in, "time %ld.%06ld\n",
192-
(long)tv->tv_sec, (long)tv->tv_usec);
193-
if (!err)
194-
err |= feed_msg_to_hook(proc.in, "size %ld\n", (long)total);
195-
if (!err)
196-
err |= feed_msg_to_hook(proc.in, "kind %s\n",
197-
(nr_our_refs == want_obj.nr && !have_obj.nr)
198-
? "clone" : "fetch");
199-
if (close(proc.in))
200-
err = 1;
201-
if (finish_command(&proc))
202-
err = 1;
203-
return err;
204-
}
205-
206149
static void create_pack_file(void)
207150
{
208-
struct timeval start_tv, tv;
209151
struct async rev_list;
210152
struct child_process pack_objects;
211153
int create_full_pack = (nr_our_refs == want_obj.nr && !have_obj.nr);
212154
char data[8193], progress[128];
213155
char abort_msg[] = "aborting due to possible repository "
214156
"corruption on the remote side.";
215157
int buffered = -1;
216-
ssize_t sz, total_sz;
158+
ssize_t sz;
217159
const char *argv[10];
218160
int arg = 0;
219161

220-
gettimeofday(&start_tv, NULL);
221-
total_sz = 0;
222162
if (shallow_nr) {
223163
rev_list.proc = do_rev_list;
224164
rev_list.data = 0;
@@ -344,7 +284,7 @@ static void create_pack_file(void)
344284
sz = xread(pack_objects.out, cp,
345285
sizeof(data) - outsz);
346286
if (0 < sz)
347-
total_sz += sz;
287+
;
348288
else if (sz == 0) {
349289
close(pack_objects.out);
350290
pack_objects.out = -1;
@@ -381,16 +321,6 @@ static void create_pack_file(void)
381321
}
382322
if (use_sideband)
383323
packet_flush(1);
384-
385-
gettimeofday(&tv, NULL);
386-
tv.tv_sec -= start_tv.tv_sec;
387-
if (tv.tv_usec < start_tv.tv_usec) {
388-
tv.tv_sec--;
389-
tv.tv_usec += 1000000;
390-
}
391-
tv.tv_usec -= start_tv.tv_usec;
392-
if (run_post_upload_pack_hook(total_sz, &tv))
393-
warning("post-upload-hook failed");
394324
return;
395325

396326
fail:

0 commit comments

Comments
 (0)