@@ -351,6 +351,29 @@ static int request_pkt(git_pkt **out, const char *line, size_t len)
351351 return 0 ;
352352}
353353
354+ static int have_want_pkt (git_pkt * * out , enum git_pkt_type type , const char * line , size_t len )
355+ {
356+ git_pkt_have_want * pkt ;
357+ size_t min_len ;
358+
359+ min_len = 5 /* 'have ' */ + GIT_OID_HEXSZ ;
360+
361+ if (len < min_len ) {
362+ giterr_set (GITERR_NET , "have/want pkt too short" );
363+ return -1 ;
364+ }
365+
366+ pkt = git__malloc (sizeof (* pkt ));
367+ GITERR_CHECK_ALLOC (pkt );
368+
369+ line += 5 ;
370+ pkt -> type = type ;
371+ git_oid_fromstr (& pkt -> id , line );
372+
373+ * out = (git_pkt * ) pkt ;
374+ return 0 ;
375+ }
376+
354377static int32_t parse_len (const char * line )
355378{
356379 char num [PKT_LEN_SIZE + 1 ];
@@ -456,6 +479,10 @@ int git_pkt_parse_line(
456479 ret = ng_pkt (head , line , len );
457480 else if (!git__prefixcmp (line , "unpack" ))
458481 ret = unpack_pkt (head , line , len );
482+ else if (!git__prefixcmp (line , "have" ))
483+ ret = have_want_pkt (head , GIT_PKT_HAVE , line , len );
484+ else if (!git__prefixcmp (line , "want" ))
485+ ret = have_want_pkt (head , GIT_PKT_WANT , line , len );
459486 else if (!git__prefixcmp (line , "git-upload-pack" ))
460487 ret = request_pkt (head , line , len );
461488 else if (!git__prefixcmp (line , "git-receive-pack" ))
0 commit comments