git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Request for detailed documentation of git pack protocol

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 5, 2009, 07:24 UTC
Message-ID
<200906050924.43882.jnareb@gmail.com>
In-Reply-To
<20090605004540.GU3355@spearce.org>
On Fri, 5 Jun 2009, Shawn O. Pearce wrote:
Show 33 quoted lines
> Jakub Narebski <jnareb@gmail.com> wrote:
> > 
> > Here we were talking about the following part of exchange: 
> > (I have added "C:" prefix to signal that this is what client, 
> > git-clone here, sends; I have added also explicit "\n" to mark LF
> > characters terminating lines, and put each pkt-line on separate line)
> > 
> > gb>  C: 0054want 74730d410fcb6603ace96f1dc55ea6196122532d multi_ack side-band-64k ofs-delta\n
> > gb>  C: 0032want 7d1665144a3a975c05f1f43902ddaf084e784dbe\n
> > gb>  C: 0032want 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a\n
> > gb>  C: 0032want 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n
> > gb>  C: 0032want 74730d410fcb6603ace96f1dc55ea6196122532d\n
> > gb>  C: 0000
> > gb>  C: 0009done\n
> > 
> > and where server response is (again the quote from "Git Community Book"
> > was modified, removing here doublequotes and doubling of backslashes):
> 
> That should be fine.
> 
> Here's a dummy client that works against both jgit and C Git:
> 
>   perl -e '
> 	$h="fcfcfb1fd94829c1a1704f894fc111d14770d34e";
> 	$c="multi_ack side-band-64k ofs-delta";
>     sub w{$_=shift;printf "%4.4x%s",4+length,$_;}
>     w("git-upload-pack /.git");
>     w("want $h $c\n");
>     printf "0000";
>     w("done")
>   ' | nc localhost 9418
> 
> Are you sure you are flushing the IO buffers in the dummy client?
That is not what I meant. Perhaps I didn't explain it clear enough...

The above sequence works fine with dummy client in Perl; where it hangs is when client tries to wait for server response (NAK or ACK) _before_ sending "done":

      $sock->print(pkt_line("want $h $c\n"));
      $sock->print("0000");
      $sock->flush();
      while (!$sock->eof()) {
        my $r = $sock->read($hex4, 4);  
        ...
      }
      $sock->print("0009done\n");
      $sock->flush();
But perhaps I did something wrong in my dummy client...

Also the flush "0000" seems to be required... but when I tried to repeat it using the above example it actually does not hang, but doesn't get PACK from git-daemon: there is something wrong in above snippet, as I get the same error on server whether I put "0000" flush line or not...

 c$  perl -e '
         my $h="c1e54552c9b35521f189db53db24cc82b5b75816";
         my $c="multi_ack side-band-64k ofs-delta";
         sub w{$_=shift;printf "%04x%s",4+length,$_;}
         w("git-upload-pack /git.git");
         w("want $h $c\n");
         ## printf "0000";    # <-- commented out!
         w("done");
     ' | nc localhost -v 9418
 
 s$  git daemon --export-all --verbose \
         --base-path=/home/local/scm/ /home/local/scm/
 [12791] Connection from 127.0.0.1:42484
 [12791] Request upload-pack for '/git.git'
 fatal: git upload-pack: not our ref c1e54552c9b35521f189db53db24cc82b5b75816 multi_ack side-band-64k ofs-delta
 [12692] [12791] Disconnected (with error)
-- 
Jakub Narebski
Poland
Previous: Shawn O. PearceNext: Jakub Narebski
Message 56 of 66 in “Request for detailed documentation of git pack protocol”
  1. Jakub NarebskiMay 12, 2009
  2. Shawn O. PearceMay 12, 2009
  3. Jakub NarebskiMay 14, 2009
  4. Shawn O. PearceMay 14, 2009
  5. Andreas EricssonMay 14, 2009
  6. Linus TorvaldsMay 15, 2009
  7. Clemens BuchacherMay 15, 2009
  8. Nicolas PitreMay 14, 2009
  9. Jakub NarebskiMay 14, 2009
  10. Scott ChaconMay 14, 2009
  11. Shawn O. PearceMay 14, 2009
  12. Jakub NarebskiMay 14, 2009
  13. A Large Angry SCMMay 15, 2009
  14. Ealdwulf WuffingaMay 15, 2009
  15. Jakub NarebskiJun 2, 2009
  16. Shawn O. PearceJun 2, 2009
  17. Jakub NarebskiJun 3, 2009
  18. Shawn O. PearceJun 3, 2009
  19. Junio C HamanoJun 3, 2009
  20. Shawn O. PearceJun 3, 2009
  21. Jakub NarebskiJun 3, 2009
  22. Shawn O. PearceJun 3, 2009
  23. Shawn O. PearceJun 3, 2009
  24. Jakub NarebskiJun 3, 2009
  25. Shawn O. PearceJun 3, 2009
  26. Jakub NarebskiJun 3, 2009
  27. Shawn O. PearceJun 3, 2009
  28. Jakub NarebskiJun 3, 2009
  29. Shawn O. PearceJun 3, 2009
  30. Jakub NarebskiJun 3, 2009
  31. Shawn O. PearceJun 3, 2009
  32. Junio C HamanoJun 3, 2009
  33. Jakub NarebskiJun 3, 2009
  34. Andreas EricssonJun 4, 2009
  35. Junio C HamanoJun 4, 2009
  36. Scott ChaconJun 6, 2009
  37. Junio C HamanoJun 6, 2009
  38. Jakub NarebskiJun 6, 2009
  39. Tony FinchJun 3, 2009
  40. Junio C HamanoJun 3, 2009
  41. Johannes SixtJun 3, 2009
  42. Robin H. JohnsonJun 3, 2009
  43. Jakub NarebskiJun 3, 2009
  44. Shawn O. PearceJun 3, 2009
  45. Tony FinchJun 3, 2009
  46. Jakub NarebskiJun 3, 2009
  47. Tony FinchJun 3, 2009
  48. Jakub NarebskiJun 4, 2009
  49. Tony FinchJun 4, 2009
  50. Shawn O. PearceJun 4, 2009
  51. Jakub NarebskiJun 3, 2009
  52. Shawn O. PearceJun 3, 2009
  53. Jakub NarebskiJun 4, 2009
  54. Shawn O. PearceJun 4, 2009
  55. Shawn O. PearceJun 5, 2009
  56. Jakub NarebskiJun 5, 2009
  57. Jakub NarebskiJun 5, 2009
  58. Comments pack protocol description in "Git Community Book" (second round)Jakub Narebski, Jun 6, 2009
  59. Scott ChaconJun 6, 2009
  60. Jakub NarebskiJun 7, 2009
  61. Shawn O. PearceJun 7, 2009
  62. Shawn O. PearceJun 7, 2009
  63. Jakub NarebskiJun 13, 2009
  64. Shawn O. PearceJun 7, 2009
  65. Jakub NarebskiJun 9, 2009
  66. Shawn O. PearceJun 9, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.