upload-pack/fetch-pack: support side-band communication
PATCH 4/4 upload-pack/fetch-pack: support side-band communication
This implements a protocol extension between fetch-pack and upload-pack to allow stderr stream from upload-pack (primarily used for the progress bar display) to be passed back.
---
* With this, fetching and cloning over git+ssh:// and git://
does not discard the progress bar and error messages that upload-pack emits on its standard output. They are sent to the downloader and shown to the user.
Somehow this does not work when connecting to git daemon that runs under inetd. Fixes appreciated.
cache.h | 4 ++- fetch-clone.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- fetch-pack.c | 22 +++++++++++++----- pkt-line.c | 4 ++- pkt-line.h | 1 + upload-pack.c | 60 +++++++++++++++++++++++++++++++++++++++++------- 6 files changed, 139 insertions(+), 23 deletions(-)
cache.h +2 -2
@@ -374,8 +374,8 @@ extern char git_commit_encoding[MAX_ENCOextern int copy_fd (int ifd,int ofd);/* Finish off pack transfer receiving end */ -extern int receive_unpack_pack (int fd[2 ],const char *me,int quiet); -extern int receive_keep_pack (int fd[2 ],const char *me,int quiet); +extern int receive_unpack_pack (int fd[2 ],const char *me,int quiet,int ); +extern int receive_keep_pack (int fd[2 ],const char *me,int quiet,int );/* pager.c */ extern void setup_pager (void );
fetch-clone.c +66 -5
105 lines not on this page · raw message
fetch-pack.c +16 -6
@@ -25,7 +25,7 @@ #define POPPED (1U << 4)#define MAX_IN_VAIN 256static struct commit_list *rev_list =NULL ; -static int non_common_revs =0 , multi_ack =0 , use_thin_pack =0 ; +static int non_common_revs =0 , multi_ack =0 , use_thin_pack =0 , use_sideband;static void rev_list_push (struct commit *commit,int mark) {
@@ -165,9 +165,14 @@ static int find_common(int fd[2], unsigncontinue ; } -packet_write (fd[1 ],"want %s%s%s\n" ,sha1_to_hex (remote), - (multi_ack ?" multi_ack" :"" ), - (use_thin_pack ?" thin-pack" :"" )); +if (!fetching) +packet_write (fd[1 ],"want %s%s%s%s\n" , +sha1_to_hex (remote), + (multi_ack ?" multi_ack" :"" ), + (use_sideband ?" side-band" :"" ), + (use_thin_pack ?" thin-pack" :"" )); +else +packet_write (fd[1 ],"want %s\n" ,sha1_to_hex (remote)); fetching++; }packet_flush (fd[1 ]);
@@ -421,6 +426,11 @@ static int fetch_pack(int fd[2], int nr_fprintf (stderr,"Server supports multi_ack\n" ); multi_ack =1 ; } +if (server_supports ("side-band" )) { +if (verbose) +fprintf (stderr,"Server supports side-band\n" ); + use_sideband =1 ; + }if (!ref) {packet_flush (fd[1 ]);die ("no matching remote head" );
@@ -437,9 +447,9 @@ static int fetch_pack(int fd[2], int nr_fprintf (stderr,"warning: no common commits\n" );if (keep_pack) - status =receive_keep_pack (fd,"git-fetch-pack" , quiet); + status =receive_keep_pack (fd,"git-fetch-pack" , quiet, use_sideband);else - status =receive_unpack_pack (fd,"git-fetch-pack" , quiet); + status =receive_unpack_pack (fd,"git-fetch-pack" , quiet, use_sideband);if (status)die ("git-fetch-pack: fetch failed." );
pkt-line.c +3 -1
@@ -16,8 +16,9 @@ #include "pkt-line.h"* The writing side could use stdio, but since the reading * side can't, we stay with pure read/write interfaces. */ -static void safe_write (int fd,const void *buf,unsigned n) +ssize_t safe_write (int fd,const void *buf,ssize_t n) { +ssize_t nn = n;while (n) {int ret =xwrite (fd, buf, n);if (ret >0 ) {
@@ -29,6 +30,7 @@ static void safe_write(int fd, const voidie ("write error (disk full?)" );die ("write error (%s)" ,strerror (errno)); } +return nn; }/*
pkt-line.h +1 -0
@@ -8,5 +8,6 @@ void packet_flush(int fd);void packet_write (int fd,const char *fmt, ...) __attribute__((format (printf,2 ,3 )));int packet_read_line (int fd,char *buffer,unsigned size); +ssize_t safe_write (int ,const void *,ssize_t );#endif
upload-pack.c +51 -9
126 lines not on this page · raw message
Signature · 1 line
1.4.0.g160a
Quoted 7 lines · Junio C Hamano
This implements a protocol extension between fetch-pack and upload-pack to allow stderr stream from upload-pack (primarily used for the progress bar display) to be passed back.
Signed-off-by Junio C Hamano <[email protected]>---
Quoted 7 lines
* With this, fetching and cloning over git+ssh:// and
git://
does not discard the progress bar and error messages that upload-pack emits on its standard output. They are sent to the downloader and shown to the user.Somehow this does not work when connecting to git daemon that runs under inetd. Fixes appreciated.
This seems to fix it.
-- >8 --
Subject: [PATCH] daemon: send stderr to /dev/null instead of closing.
--- daemon.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
daemon.c +1 -1
@@ -757,7 +757,7 @@ int main(int argc, char **argv)struct sockaddr *peer = (struct sockaddr *)&ss;socklen_t slen =sizeof (ss); -fclose (stderr);//FIXME: workaround +freopen ("/dev/null" ,"w" , stderr);if (getpeername (0 , peer, &slen)) peer =NULL ;
Signature · 1 line
1.4.0.g7883
daemon.c int main(int argc, char **argv) · line 760
Quoted 8 lines · Junio C Hamano
Quoted 2 lines
Somehow this does not work when connecting to git daemon that runs under inetd. Fixes appreciated.
This seems to fix it.
daemon.c +1
-1-fclose (stderr);//FIXME: workaround +freopen ("/dev/null" ,"w" , stderr);
Sweet. Thanks!
jdl