Merge branch 'jk/maint-docs'
[git.git] / t / t4100 / t-apply-5.patch
blob5f6ddc105950eac20bcacb7987fabff015320ee3
1 diff a/Documentation/git-rpull.txt b/Documentation/git-rpull.txt
2 --- a/Documentation/git-rpull.txt
3 +++ /dev/null
4 @@ -1,50 +0,0 @@
5 -git-rpull(1)
6 -============
7 -v0.1, May 2005
9 -NAME
10 -----
11 -git-rpull - Pulls from a remote repository over ssh connection
15 -SYNOPSIS
16 ---------
17 -'git-rpull' [-c] [-t] [-a] [-d] [-v] [--recover] commit-id url
19 -DESCRIPTION
20 ------------
21 -Pulls from a remote repository over ssh connection, invoking git-rpush on
22 -the other end.
24 -OPTIONS
25 --------
26 --c::
27 - Get the commit objects.
28 --t::
29 - Get trees associated with the commit objects.
30 --a::
31 - Get all the objects.
32 --d::
33 - Do not check for delta base objects (use this option
34 - only when you know the remote repository is not
35 - deltified).
36 ---recover::
37 - Check dependency of deltified object more carefully than
38 - usual, to recover after earlier pull that was interrupted.
39 --v::
40 - Report what is downloaded.
43 -Author
44 -------
45 -Written by Linus Torvalds <torvalds@osdl.org>
47 -Documentation
48 ---------------
49 -Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
51 -GIT
52 ----
53 -Part of the link:git.html[git] suite
55 diff a/Documentation/git-rpush.txt b/Documentation/git-rpush.txt
56 --- a/Documentation/git-rpush.txt
57 +++ /dev/null
58 @@ -1,30 +0,0 @@
59 -git-rpush(1)
60 -============
61 -v0.1, May 2005
63 -NAME
64 -----
65 -git-rpush - Helper "server-side" program used by git-rpull
68 -SYNOPSIS
69 ---------
70 -'git-rpush'
72 -DESCRIPTION
73 ------------
74 -Helper "server-side" program used by git-rpull.
77 -Author
78 -------
79 -Written by Linus Torvalds <torvalds@osdl.org>
81 -Documentation
82 ---------------
83 -Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
85 -GIT
86 ----
87 -Part of the link:git.html[git] suite
89 diff a/Documentation/git-ssh-pull.txt b/Documentation/git-ssh-pull.txt
90 --- /dev/null
91 +++ b/Documentation/git-ssh-pull.txt
92 @@ -0,0 +1,50 @@
93 +git-ssh-pull(1)
94 +===============
95 +v0.1, May 2005
97 +NAME
98 +----
99 +git-ssh-pull - Pulls from a remote repository over ssh connection
103 +SYNOPSIS
104 +--------
105 +'git-ssh-pull' [-c] [-t] [-a] [-d] [-v] [--recover] commit-id url
107 +DESCRIPTION
108 +-----------
109 +Pulls from a remote repository over ssh connection, invoking git-ssh-push
110 +on the other end.
112 +OPTIONS
113 +-------
114 +-c::
115 + Get the commit objects.
116 +-t::
117 + Get trees associated with the commit objects.
118 +-a::
119 + Get all the objects.
120 +-d::
121 + Do not check for delta base objects (use this option
122 + only when you know the remote repository is not
123 + deltified).
124 +--recover::
125 + Check dependency of deltified object more carefully than
126 + usual, to recover after earlier pull that was interrupted.
127 +-v::
128 + Report what is downloaded.
131 +Author
132 +------
133 +Written by Linus Torvalds <torvalds@osdl.org>
135 +Documentation
136 +--------------
137 +Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
139 +GIT
140 +---
141 +Part of the link:git.html[git] suite
143 diff a/Documentation/git-ssh-push.txt b/Documentation/git-ssh-push.txt
144 --- /dev/null
145 +++ b/Documentation/git-ssh-push.txt
146 @@ -0,0 +1,30 @@
147 +git-ssh-push(1)
148 +===============
149 +v0.1, May 2005
151 +NAME
152 +----
153 +git-ssh-push - Helper "server-side" program used by git-ssh-pull
156 +SYNOPSIS
157 +--------
158 +'git-ssh-push'
160 +DESCRIPTION
161 +-----------
162 +Helper "server-side" program used by git-ssh-pull.
165 +Author
166 +------
167 +Written by Linus Torvalds <torvalds@osdl.org>
169 +Documentation
170 +--------------
171 +Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
173 +GIT
174 +---
175 +Part of the link:git.html[git] suite
177 diff a/Documentation/git.txt b/Documentation/git.txt
178 --- a/Documentation/git.txt
179 +++ b/Documentation/git.txt
180 @@ -148,7 +148,7 @@ link:git-resolve-script.html[git-resolve
181 link:git-tag-script.html[git-tag-script]::
182 An example script to create a tag object signed with GPG
184 -link:git-rpull.html[git-rpull]::
185 +link:git-ssh-pull.html[git-ssh-pull]::
186 Pulls from a remote repository over ssh connection
188 Interogators:
189 @@ -156,8 +156,8 @@ Interogators:
190 link:git-diff-helper.html[git-diff-helper]::
191 Generates patch format output for git-diff-*
193 -link:git-rpush.html[git-rpush]::
194 - Helper "server-side" program used by git-rpull
195 +link:git-ssh-push.html[git-ssh-push]::
196 + Helper "server-side" program used by git-ssh-pull
200 diff a/Makefile b/Makefile
201 --- a/Makefile
202 +++ b/Makefile
203 @@ -30,7 +30,7 @@ PROG= git-update-index git-diff-files
204 git-checkout-cache git-diff-tree git-rev-tree git-ls-files \
205 git-check-files git-ls-tree git-merge-base git-merge-cache \
206 git-unpack-file git-export git-diff-cache git-convert-cache \
207 - git-http-pull git-rpush git-rpull git-rev-list git-mktag \
208 + git-http-pull git-ssh-push git-ssh-pull git-rev-list git-mktag \
209 git-diff-helper git-tar-tree git-local-pull git-write-blob \
210 git-get-tar-commit-id git-mkdelta git-apply git-stripspace
212 @@ -105,8 +105,8 @@ git-diff-cache: diff-cache.c
213 git-convert-cache: convert-cache.c
214 git-http-pull: http-pull.c pull.c
215 git-local-pull: local-pull.c pull.c
216 -git-rpush: rsh.c
217 -git-rpull: rsh.c pull.c
218 +git-ssh-push: rsh.c
219 +git-ssh-pull: rsh.c pull.c
220 git-rev-list: rev-list.c
221 git-mktag: mktag.c
222 git-diff-helper: diff-helper.c
223 diff a/rpull.c b/rpull.c
224 --- a/rpull.c
225 +++ /dev/null
226 @@ -1,83 +0,0 @@
227 -#include "cache.h"
228 -#include "commit.h"
229 -#include "rsh.h"
230 -#include "pull.h"
232 -static int fd_in;
233 -static int fd_out;
235 -static unsigned char remote_version = 0;
236 -static unsigned char local_version = 1;
238 -int fetch(unsigned char *sha1)
240 - int ret;
241 - signed char remote;
242 - char type = 'o';
243 - if (has_sha1_file(sha1))
244 - return 0;
245 - write(fd_out, &type, 1);
246 - write(fd_out, sha1, 20);
247 - if (read(fd_in, &remote, 1) < 1)
248 - return -1;
249 - if (remote < 0)
250 - return remote;
251 - ret = write_sha1_from_fd(sha1, fd_in);
252 - if (!ret)
253 - pull_say("got %s\n", sha1_to_hex(sha1));
254 - return ret;
257 -int get_version(void)
259 - char type = 'v';
260 - write(fd_out, &type, 1);
261 - write(fd_out, &local_version, 1);
262 - if (read(fd_in, &remote_version, 1) < 1) {
263 - return error("Couldn't read version from remote end");
265 - return 0;
268 -int main(int argc, char **argv)
270 - char *commit_id;
271 - char *url;
272 - int arg = 1;
274 - while (arg < argc && argv[arg][0] == '-') {
275 - if (argv[arg][1] == 't') {
276 - get_tree = 1;
277 - } else if (argv[arg][1] == 'c') {
278 - get_history = 1;
279 - } else if (argv[arg][1] == 'd') {
280 - get_delta = 0;
281 - } else if (!strcmp(argv[arg], "--recover")) {
282 - get_delta = 2;
283 - } else if (argv[arg][1] == 'a') {
284 - get_all = 1;
285 - get_tree = 1;
286 - get_history = 1;
287 - } else if (argv[arg][1] == 'v') {
288 - get_verbosely = 1;
290 - arg++;
292 - if (argc < arg + 2) {
293 - usage("git-rpull [-c] [-t] [-a] [-v] [-d] [--recover] commit-id url");
294 - return 1;
296 - commit_id = argv[arg];
297 - url = argv[arg + 1];
299 - if (setup_connection(&fd_in, &fd_out, "git-rpush", url, arg, argv + 1))
300 - return 1;
302 - if (get_version())
303 - return 1;
305 - if (pull(commit_id))
306 - return 1;
308 - return 0;
310 diff a/rpush.c b/rpush.c
311 --- a/rpush.c
312 +++ /dev/null
313 @@ -1,104 +0,0 @@
314 -#include "cache.h"
315 -#include "rsh.h"
316 -#include <sys/socket.h>
317 -#include <errno.h>
319 -unsigned char local_version = 1;
320 -unsigned char remote_version = 0;
322 -int serve_object(int fd_in, int fd_out) {
323 - ssize_t size;
324 - int posn = 0;
325 - char sha1[20];
326 - unsigned long objsize;
327 - void *buf;
328 - signed char remote;
329 - do {
330 - size = read(fd_in, sha1 + posn, 20 - posn);
331 - if (size < 0) {
332 - perror("git-rpush: read ");
333 - return -1;
335 - if (!size)
336 - return -1;
337 - posn += size;
338 - } while (posn < 20);
340 - /* fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1)); */
341 - remote = 0;
343 - buf = map_sha1_file(sha1, &objsize);
345 - if (!buf) {
346 - fprintf(stderr, "git-rpush: could not find %s\n",
347 - sha1_to_hex(sha1));
348 - remote = -1;
351 - write(fd_out, &remote, 1);
353 - if (remote < 0)
354 - return 0;
356 - posn = 0;
357 - do {
358 - size = write(fd_out, buf + posn, objsize - posn);
359 - if (size <= 0) {
360 - if (!size) {
361 - fprintf(stderr, "git-rpush: write closed");
362 - } else {
363 - perror("git-rpush: write ");
365 - return -1;
367 - posn += size;
368 - } while (posn < objsize);
369 - return 0;
372 -int serve_version(int fd_in, int fd_out)
374 - if (read(fd_in, &remote_version, 1) < 1)
375 - return -1;
376 - write(fd_out, &local_version, 1);
377 - return 0;
380 -void service(int fd_in, int fd_out) {
381 - char type;
382 - int retval;
383 - do {
384 - retval = read(fd_in, &type, 1);
385 - if (retval < 1) {
386 - if (retval < 0)
387 - perror("rpush: read ");
388 - return;
390 - if (type == 'v' && serve_version(fd_in, fd_out))
391 - return;
392 - if (type == 'o' && serve_object(fd_in, fd_out))
393 - return;
394 - } while (1);
397 -int main(int argc, char **argv)
399 - int arg = 1;
400 - char *commit_id;
401 - char *url;
402 - int fd_in, fd_out;
403 - while (arg < argc && argv[arg][0] == '-') {
404 - arg++;
406 - if (argc < arg + 2) {
407 - usage("git-rpush [-c] [-t] [-a] commit-id url");
408 - return 1;
410 - commit_id = argv[arg];
411 - url = argv[arg + 1];
412 - if (setup_connection(&fd_in, &fd_out, "git-rpull", url, arg, argv + 1))
413 - return 1;
415 - service(fd_in, fd_out);
416 - return 0;
418 diff a/ssh-pull.c b/ssh-pull.c
419 --- /dev/null
420 +++ b/ssh-pull.c
421 @@ -0,0 +1,83 @@
422 +#include "cache.h"
423 +#include "commit.h"
424 +#include "rsh.h"
425 +#include "pull.h"
427 +static int fd_in;
428 +static int fd_out;
430 +static unsigned char remote_version = 0;
431 +static unsigned char local_version = 1;
433 +int fetch(unsigned char *sha1)
435 + int ret;
436 + signed char remote;
437 + char type = 'o';
438 + if (has_sha1_file(sha1))
439 + return 0;
440 + write(fd_out, &type, 1);
441 + write(fd_out, sha1, 20);
442 + if (read(fd_in, &remote, 1) < 1)
443 + return -1;
444 + if (remote < 0)
445 + return remote;
446 + ret = write_sha1_from_fd(sha1, fd_in);
447 + if (!ret)
448 + pull_say("got %s\n", sha1_to_hex(sha1));
449 + return ret;
452 +int get_version(void)
454 + char type = 'v';
455 + write(fd_out, &type, 1);
456 + write(fd_out, &local_version, 1);
457 + if (read(fd_in, &remote_version, 1) < 1) {
458 + return error("Couldn't read version from remote end");
460 + return 0;
463 +int main(int argc, char **argv)
465 + char *commit_id;
466 + char *url;
467 + int arg = 1;
469 + while (arg < argc && argv[arg][0] == '-') {
470 + if (argv[arg][1] == 't') {
471 + get_tree = 1;
472 + } else if (argv[arg][1] == 'c') {
473 + get_history = 1;
474 + } else if (argv[arg][1] == 'd') {
475 + get_delta = 0;
476 + } else if (!strcmp(argv[arg], "--recover")) {
477 + get_delta = 2;
478 + } else if (argv[arg][1] == 'a') {
479 + get_all = 1;
480 + get_tree = 1;
481 + get_history = 1;
482 + } else if (argv[arg][1] == 'v') {
483 + get_verbosely = 1;
485 + arg++;
487 + if (argc < arg + 2) {
488 + usage("git-ssh-pull [-c] [-t] [-a] [-v] [-d] [--recover] commit-id url");
489 + return 1;
491 + commit_id = argv[arg];
492 + url = argv[arg + 1];
494 + if (setup_connection(&fd_in, &fd_out, "git-ssh-push", url, arg, argv + 1))
495 + return 1;
497 + if (get_version())
498 + return 1;
500 + if (pull(commit_id))
501 + return 1;
503 + return 0;
505 diff a/ssh-push.c b/ssh-push.c
506 --- /dev/null
507 +++ b/ssh-push.c
508 @@ -0,0 +1,104 @@
509 +#include "cache.h"
510 +#include "rsh.h"
511 +#include <sys/socket.h>
512 +#include <errno.h>
514 +unsigned char local_version = 1;
515 +unsigned char remote_version = 0;
517 +int serve_object(int fd_in, int fd_out) {
518 + ssize_t size;
519 + int posn = 0;
520 + char sha1[20];
521 + unsigned long objsize;
522 + void *buf;
523 + signed char remote;
524 + do {
525 + size = read(fd_in, sha1 + posn, 20 - posn);
526 + if (size < 0) {
527 + perror("git-ssh-push: read ");
528 + return -1;
530 + if (!size)
531 + return -1;
532 + posn += size;
533 + } while (posn < 20);
535 + /* fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1)); */
536 + remote = 0;
538 + buf = map_sha1_file(sha1, &objsize);
540 + if (!buf) {
541 + fprintf(stderr, "git-ssh-push: could not find %s\n",
542 + sha1_to_hex(sha1));
543 + remote = -1;
546 + write(fd_out, &remote, 1);
548 + if (remote < 0)
549 + return 0;
551 + posn = 0;
552 + do {
553 + size = write(fd_out, buf + posn, objsize - posn);
554 + if (size <= 0) {
555 + if (!size) {
556 + fprintf(stderr, "git-ssh-push: write closed");
557 + } else {
558 + perror("git-ssh-push: write ");
560 + return -1;
562 + posn += size;
563 + } while (posn < objsize);
564 + return 0;
567 +int serve_version(int fd_in, int fd_out)
569 + if (read(fd_in, &remote_version, 1) < 1)
570 + return -1;
571 + write(fd_out, &local_version, 1);
572 + return 0;
575 +void service(int fd_in, int fd_out) {
576 + char type;
577 + int retval;
578 + do {
579 + retval = read(fd_in, &type, 1);
580 + if (retval < 1) {
581 + if (retval < 0)
582 + perror("git-ssh-push: read ");
583 + return;
585 + if (type == 'v' && serve_version(fd_in, fd_out))
586 + return;
587 + if (type == 'o' && serve_object(fd_in, fd_out))
588 + return;
589 + } while (1);
592 +int main(int argc, char **argv)
594 + int arg = 1;
595 + char *commit_id;
596 + char *url;
597 + int fd_in, fd_out;
598 + while (arg < argc && argv[arg][0] == '-') {
599 + arg++;
601 + if (argc < arg + 2) {
602 + usage("git-ssh-push [-c] [-t] [-a] commit-id url");
603 + return 1;
605 + commit_id = argv[arg];
606 + url = argv[arg + 1];
607 + if (setup_connection(&fd_in, &fd_out, "git-ssh-pull", url, arg, argv + 1))
608 + return 1;
610 + service(fd_in, fd_out);
611 + return 0;