@@ -26,13 +26,15 @@ static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<
26
26
#define SHALLOW (1u << 16)
27
27
#define NOT_SHALLOW (1u << 17)
28
28
#define CLIENT_SHALLOW (1u << 18)
29
+ #define HIDDEN_REF (1u << 19)
29
30
30
31
static unsigned long oldest_have ;
31
32
32
33
static int multi_ack ;
33
34
static int no_done ;
34
35
static int use_thin_pack , use_ofs_delta , use_include_tag ;
35
36
static int no_progress , daemon_mode ;
37
+ static int allow_tip_sha1_in_want ;
36
38
static int shallow_nr ;
37
39
static struct object_array have_obj ;
38
40
static struct object_array want_obj ;
@@ -487,6 +489,12 @@ static int get_common_commits(void)
487
489
}
488
490
}
489
491
492
+ static int is_our_ref (struct object * o )
493
+ {
494
+ return o -> flags &
495
+ ((allow_tip_sha1_in_want ? HIDDEN_REF : 0 ) | OUR_REF );
496
+ }
497
+
490
498
static void check_non_tip (void )
491
499
{
492
500
static const char * argv [] = {
@@ -523,7 +531,7 @@ static void check_non_tip(void)
523
531
o = get_indexed_object (-- i );
524
532
if (!o )
525
533
continue ;
526
- if (!( o -> flags & OUR_REF ))
534
+ if (!is_our_ref ( o ))
527
535
continue ;
528
536
memcpy (namebuf + 1 , sha1_to_hex (o -> sha1 ), 40 );
529
537
if (write_in_full (cmd .in , namebuf , 42 ) < 0 )
@@ -532,7 +540,7 @@ static void check_non_tip(void)
532
540
namebuf [40 ] = '\n' ;
533
541
for (i = 0 ; i < want_obj .nr ; i ++ ) {
534
542
o = want_obj .objects [i ].item ;
535
- if (o -> flags & OUR_REF )
543
+ if (is_our_ref ( o ) )
536
544
continue ;
537
545
memcpy (namebuf , sha1_to_hex (o -> sha1 ), 40 );
538
546
if (write_in_full (cmd .in , namebuf , 41 ) < 0 )
@@ -566,7 +574,7 @@ static void check_non_tip(void)
566
574
/* Pick one of them (we know there at least is one) */
567
575
for (i = 0 ; i < want_obj .nr ; i ++ ) {
568
576
o = want_obj .objects [i ].item ;
569
- if (!( o -> flags & OUR_REF ))
577
+ if (!is_our_ref ( o ))
570
578
die ("git upload-pack: not our ref %s" ,
571
579
sha1_to_hex (o -> sha1 ));
572
580
}
@@ -646,7 +654,7 @@ static void receive_needs(void)
646
654
sha1_to_hex (sha1_buf ));
647
655
if (!(o -> flags & WANTED )) {
648
656
o -> flags |= WANTED ;
649
- if (!( o -> flags & OUR_REF ))
657
+ if (!is_our_ref ( o ))
650
658
has_non_tip = 1 ;
651
659
add_object_array (o , NULL , & want_obj );
652
660
}
@@ -725,8 +733,10 @@ static int mark_our_ref(const char *refname, const unsigned char *sha1, int flag
725
733
{
726
734
struct object * o = lookup_unknown_object (sha1 );
727
735
728
- if (ref_is_hidden (refname ))
736
+ if (ref_is_hidden (refname )) {
737
+ o -> flags |= HIDDEN_REF ;
729
738
return 1 ;
739
+ }
730
740
if (!o )
731
741
die ("git upload-pack: cannot find object %s:" , sha1_to_hex (sha1 ));
732
742
o -> flags |= OUR_REF ;
@@ -745,9 +755,10 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
745
755
return 0 ;
746
756
747
757
if (capabilities )
748
- packet_write (1 , "%s %s%c%s%s agent=%s\n" ,
758
+ packet_write (1 , "%s %s%c%s%s%s agent=%s\n" ,
749
759
sha1_to_hex (sha1 ), refname_nons ,
750
760
0 , capabilities ,
761
+ allow_tip_sha1_in_want ? " allow-tip-sha1-in-want" : "" ,
751
762
stateless_rpc ? " no-done" : "" ,
752
763
git_user_agent_sanitized ());
753
764
else
@@ -781,6 +792,8 @@ static void upload_pack(void)
781
792
782
793
static int upload_pack_config (const char * var , const char * value , void * unused )
783
794
{
795
+ if (!strcmp ("uploadpack.allowtipsha1inwant" , var ))
796
+ allow_tip_sha1_in_want = git_config_bool (var , value );
784
797
return parse_hide_refs_config (var , value , "uploadpack" );
785
798
}
786
799
0 commit comments