@@ -276,7 +276,7 @@ static void create_pack_file(void)
276276 die ("git upload-pack: %s" , abort_msg );
277277}
278278
279- static int got_sha1 (char * hex , unsigned char * sha1 )
279+ static int got_sha1 (const char * hex , unsigned char * sha1 )
280280{
281281 struct object * o ;
282282 int we_knew_they_have = 0 ;
@@ -382,6 +382,8 @@ static int get_common_commits(void)
382382
383383 for (;;) {
384384 char * line = packet_read_line (0 , NULL );
385+ const char * arg ;
386+
385387 reset_timeout ();
386388
387389 if (!line ) {
@@ -403,8 +405,8 @@ static int get_common_commits(void)
403405 got_other = 0 ;
404406 continue ;
405407 }
406- if (starts_with (line , "have " )) {
407- switch (got_sha1 (line + 5 , sha1 )) {
408+ if (skip_prefix (line , "have " , & arg )) {
409+ switch (got_sha1 (arg , sha1 )) {
408410 case -1 : /* they have what we do not */
409411 got_other = 1 ;
410412 if (multi_ack && ok_to_give_up ()) {
@@ -620,14 +622,16 @@ static void receive_needs(void)
620622 const char * features ;
621623 unsigned char sha1_buf [20 ];
622624 char * line = packet_read_line (0 , NULL );
625+ const char * arg ;
626+
623627 reset_timeout ();
624628 if (!line )
625629 break ;
626630
627- if (starts_with (line , "shallow " )) {
631+ if (skip_prefix (line , "shallow " , & arg )) {
628632 unsigned char sha1 [20 ];
629633 struct object * object ;
630- if (get_sha1_hex (line + 8 , sha1 ))
634+ if (get_sha1_hex (arg , sha1 ))
631635 die ("invalid shallow line: %s" , line );
632636 object = parse_object (sha1 );
633637 if (!object )
@@ -640,19 +644,19 @@ static void receive_needs(void)
640644 }
641645 continue ;
642646 }
643- if (starts_with (line , "deepen " )) {
647+ if (skip_prefix (line , "deepen " , & arg )) {
644648 char * end ;
645- depth = strtol (line + 7 , & end , 0 );
646- if (end == line + 7 || depth <= 0 )
649+ depth = strtol (arg , & end , 0 );
650+ if (end == arg || depth <= 0 )
647651 die ("Invalid deepen: %s" , line );
648652 continue ;
649653 }
650- if (!starts_with (line , "want " ) ||
651- get_sha1_hex (line + 5 , sha1_buf ))
654+ if (!skip_prefix (line , "want " , & arg ) ||
655+ get_sha1_hex (arg , sha1_buf ))
652656 die ("git upload-pack: protocol error, "
653657 "expected to get sha, not '%s'" , line );
654658
655- features = line + 45 ;
659+ features = arg + 40 ;
656660
657661 if (parse_feature_request (features , "multi_ack_detailed" ))
658662 multi_ack = 2 ;
@@ -859,7 +863,7 @@ int main(int argc, char **argv)
859863 check_replace_refs = 0 ;
860864
861865 for (i = 1 ; i < argc ; i ++ ) {
862- char * arg = argv [i ];
866+ const char * arg = argv [i ];
863867
864868 if (arg [0 ] != '-' )
865869 break ;
@@ -875,8 +879,8 @@ int main(int argc, char **argv)
875879 strict = 1 ;
876880 continue ;
877881 }
878- if (starts_with (arg , "--timeout=" )) {
879- timeout = atoi (arg + 10 );
882+ if (skip_prefix (arg , "--timeout=" , & arg )) {
883+ timeout = atoi (arg );
880884 daemon_mode = 1 ;
881885 continue ;
882886 }
0 commit comments