* [PATCH] Make rsh protocol extensible
@ 2005-05-19 5:11 Daniel Barkalow
2005-06-02 20:59 ` Petr Baudis
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Barkalow @ 2005-05-19 5:11 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
This changes the rsh protocol to allow reporting failure in getting an
object without breaking the connection, and to allow other types of
request than for objects to be made. It is a preliminary to any more
extensive pull operation.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Index: rpull.c
===================================================================
--- 75b95bec390d6728b9b1b4572056af8cee34ea7d/rpull.c (mode:100644 sha1:b48e63157c66c160b9751603a92831f77106044c)
+++ c70baff05489356575384857c7cc4d4c641c39e3/rpull.c (mode:100644 sha1:7f5b390d8ed653bfb67363db2c61c576a4d3134d)
@@ -15,7 +15,16 @@
int fetch(unsigned char *sha1)
{
int ret;
- write(fd_out, sha1, 20);
+ signed char remote;
+ char type = 'o';
+ if (has_sha1_file(sha1))
+ return 0;
+ write(fd_out, &type, 1);
+ write(fd_out, sha1, 20);
+ if (read(fd_in, &remote, 1) < 1)
+ return -1;
+ if (remote < 0)
+ return remote;
ret = write_sha1_from_fd(sha1, fd_in);
if (!ret)
pull_say("got %s\n", sha1_to_hex(sha1));
Index: rpush.c
===================================================================
--- 75b95bec390d6728b9b1b4572056af8cee34ea7d/rpush.c (mode:100644 sha1:3f2c898c8f5cf5ba62d689a13c646936b8372ee7)
+++ c70baff05489356575384857c7cc4d4c641c39e3/rpush.c (mode:100644 sha1:07a8461878ad7b1d8cea27e44003b2ed44632834)
@@ -3,46 +3,68 @@
#include <sys/socket.h>
#include <errno.h>
-void service(int fd_in, int fd_out) {
+int serve_object(int fd_in, int fd_out) {
ssize_t size;
- int posn;
+ int posn = 0;
char unsigned sha1[20];
unsigned long objsize;
void *buf;
+ signed char remote;
do {
- posn = 0;
- do {
- size = read(fd_in, sha1 + posn, 20 - posn);
- if (size < 0) {
- perror("rpush: read ");
- return;
+ size = read(fd_in, sha1 + posn, 20 - posn);
+ if (size < 0) {
+ perror("rpush: read ");
+ return -1;
+ }
+ if (!size)
+ return -1;
+ posn += size;
+ } while (posn < 20);
+
+ /* fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1)); */
+ remote = 0;
+
+ buf = map_sha1_file(sha1, &objsize);
+
+ if (!buf) {
+ fprintf(stderr, "rpush: could not find %s\n",
+ sha1_to_hex(sha1));
+ remote = -1;
+ }
+
+ write(fd_out, &remote, 1);
+
+ if (remote < 0)
+ return 0;
+
+ posn = 0;
+ do {
+ size = write(fd_out, buf + posn, objsize - posn);
+ if (size <= 0) {
+ if (!size) {
+ fprintf(stderr, "rpush: write closed");
+ } else {
+ perror("rpush: write ");
}
- if (!size)
- return;
- posn += size;
- } while (posn < 20);
-
- /* fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1)); */
+ return -1;
+ }
+ posn += size;
+ } while (posn < objsize);
+ return 0;
+}
- buf = map_sha1_file(sha1, &objsize);
- if (!buf) {
- fprintf(stderr, "rpush: could not find %s\n",
- sha1_to_hex(sha1));
+void service(int fd_in, int fd_out) {
+ char type;
+ int retval;
+ do {
+ retval = read(fd_in, &type, 1);
+ if (retval < 1) {
+ if (retval < 0)
+ perror("rpush: read ");
return;
}
- posn = 0;
- do {
- size = write(fd_out, buf + posn, objsize - posn);
- if (size <= 0) {
- if (!size) {
- fprintf(stderr, "rpush: write closed");
- } else {
- perror("rpush: write ");
- }
- return;
- }
- posn += size;
- } while (posn < objsize);
+ if (type == 'o' && serve_object(fd_in, fd_out))
+ return;
} while (1);
}
@@ -53,6 +75,8 @@
char *url;
int fd_in, fd_out;
while (arg < argc && argv[arg][0] == '-') {
+ if (argv[arg][1] == 'w')
+ arg++;
arg++;
}
if (argc < arg + 2) {
Index: rsh.c
===================================================================
--- 75b95bec390d6728b9b1b4572056af8cee34ea7d/rsh.c (mode:100644 sha1:5d1cb9d578a8e679fc190a9d7d2c842ad811223f)
+++ c70baff05489356575384857c7cc4d4c641c39e3/rsh.c (mode:100644 sha1:71afc1aa5c9fb3cfe8d49e73471c30e92df9e327)
@@ -36,8 +36,8 @@
*(path++) = '\0';
/* ssh <host> 'cd /<path>; stdio-pull <arg...> <commit-id>' */
snprintf(command, COMMAND_SIZE,
- "cd /%s; %s=objects %s",
- path, DB_ENVIRONMENT, remote_prog);
+ "GIT_DIR='%s' %s",
+ path, remote_prog);
posn = command + strlen(command);
for (i = 0; i < rmt_argc; i++) {
*(posn++) = ' ';
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Make rsh protocol extensible
2005-05-19 5:11 [PATCH] Make rsh protocol extensible Daniel Barkalow
@ 2005-06-02 20:59 ` Petr Baudis
2005-06-03 21:38 ` Daniel Barkalow
0 siblings, 1 reply; 3+ messages in thread
From: Petr Baudis @ 2005-06-02 20:59 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: git
Dear diary, on Thu, May 19, 2005 at 07:11:46AM CEST, I got a letter
where Daniel Barkalow <barkalow@iabervon.org> told me that...
> This changes the rsh protocol to allow reporting failure in getting an
> object without breaking the connection, and to allow other types of
> request than for objects to be made. It is a preliminary to any more
> extensive pull operation.
>
> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
I wanted to apply it but then I figured out that I will better hold it
and ask you what do you think about it now after few weeks. ;-) Should I
still go on and apply it to Cogito?
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Make rsh protocol extensible
2005-06-02 20:59 ` Petr Baudis
@ 2005-06-03 21:38 ` Daniel Barkalow
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Barkalow @ 2005-06-03 21:38 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
On Thu, 2 Jun 2005, Petr Baudis wrote:
> Dear diary, on Thu, May 19, 2005 at 07:11:46AM CEST, I got a letter
> where Daniel Barkalow <barkalow@iabervon.org> told me that...
> > This changes the rsh protocol to allow reporting failure in getting an
> > object without breaking the connection, and to allow other types of
> > request than for objects to be made. It is a preliminary to any more
> > extensive pull operation.
> >
> > Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
>
> I wanted to apply it but then I figured out that I will better hold it
> and ask you what do you think about it now after few weeks. ;-) Should I
> still go on and apply it to Cogito?
At this point, I want to also put in a protocol version number. I'll send
a replacement patch in a bit.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-06-03 21:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-19 5:11 [PATCH] Make rsh protocol extensible Daniel Barkalow
2005-06-02 20:59 ` Petr Baudis
2005-06-03 21:38 ` Daniel Barkalow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).