@@ -1919,25 +1919,8 @@ off_t find_pack_entry_one(const unsigned char *sha1,
19191919 return 0 ;
19201920}
19211921
1922- int matches_pack_name (struct packed_git * p , const char * name )
1923- {
1924- const char * last_c , * c ;
1925-
1926- if (!strcmp (p -> pack_name , name ))
1927- return 1 ;
1928-
1929- for (c = p -> pack_name , last_c = c ; * c ;)
1930- if (* c == '/' )
1931- last_c = ++ c ;
1932- else
1933- ++ c ;
1934- if (!strcmp (last_c , name ))
1935- return 1 ;
1936-
1937- return 0 ;
1938- }
1939-
1940- static int find_pack_entry (const unsigned char * sha1 , struct pack_entry * e , const char * * ignore_packed )
1922+ static int find_pack_ent (const unsigned char * sha1 , struct pack_entry * e ,
1923+ int kept_pack_only )
19411924{
19421925 static struct packed_git * last_found = (void * )1 ;
19431926 struct packed_git * p ;
@@ -1949,15 +1932,8 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
19491932 p = (last_found == (void * )1 ) ? packed_git : last_found ;
19501933
19511934 do {
1952- if (ignore_packed ) {
1953- const char * * ig ;
1954- for (ig = ignore_packed ; * ig ; ig ++ )
1955- if (matches_pack_name (p , * ig ))
1956- break ;
1957- if (* ig )
1958- goto next ;
1959- }
1960-
1935+ if (kept_pack_only && !p -> pack_keep )
1936+ goto next ;
19611937 if (p -> num_bad_objects ) {
19621938 unsigned i ;
19631939 for (i = 0 ; i < p -> num_bad_objects ; i ++ )
@@ -1997,6 +1973,16 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
19971973 return 0 ;
19981974}
19991975
1976+ static int find_pack_entry (const unsigned char * sha1 , struct pack_entry * e )
1977+ {
1978+ return find_pack_ent (sha1 , e , 0 );
1979+ }
1980+
1981+ static int find_kept_pack_entry (const unsigned char * sha1 , struct pack_entry * e )
1982+ {
1983+ return find_pack_ent (sha1 , e , 1 );
1984+ }
1985+
20001986struct packed_git * find_sha1_pack (const unsigned char * sha1 ,
20011987 struct packed_git * packs )
20021988{
@@ -2038,15 +2024,15 @@ int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
20382024 struct pack_entry e ;
20392025 int status ;
20402026
2041- if (!find_pack_entry (sha1 , & e , NULL )) {
2027+ if (!find_pack_entry (sha1 , & e )) {
20422028 /* Most likely it's a loose object. */
20432029 status = sha1_loose_object_info (sha1 , sizep );
20442030 if (status >= 0 )
20452031 return status ;
20462032
20472033 /* Not a loose object; someone else may have just packed it. */
20482034 reprepare_packed_git ();
2049- if (!find_pack_entry (sha1 , & e , NULL ))
2035+ if (!find_pack_entry (sha1 , & e ))
20502036 return status ;
20512037 }
20522038
@@ -2065,7 +2051,7 @@ static void *read_packed_sha1(const unsigned char *sha1,
20652051 struct pack_entry e ;
20662052 void * data ;
20672053
2068- if (!find_pack_entry (sha1 , & e , NULL ))
2054+ if (!find_pack_entry (sha1 , & e ))
20692055 return NULL ;
20702056 data = cache_or_unpack_entry (e .p , e .offset , size , type , 1 );
20712057 if (!data ) {
@@ -2464,17 +2450,23 @@ int has_pack_file(const unsigned char *sha1)
24642450 return 1 ;
24652451}
24662452
2467- int has_sha1_pack (const unsigned char * sha1 , const char * * ignore_packed )
2453+ int has_sha1_pack (const unsigned char * sha1 )
2454+ {
2455+ struct pack_entry e ;
2456+ return find_pack_entry (sha1 , & e );
2457+ }
2458+
2459+ int has_sha1_kept_pack (const unsigned char * sha1 )
24682460{
24692461 struct pack_entry e ;
2470- return find_pack_entry (sha1 , & e , ignore_packed );
2462+ return find_kept_pack_entry (sha1 , & e );
24712463}
24722464
24732465int has_sha1_file (const unsigned char * sha1 )
24742466{
24752467 struct pack_entry e ;
24762468
2477- if (find_pack_entry (sha1 , & e , NULL ))
2469+ if (find_pack_entry (sha1 , & e ))
24782470 return 1 ;
24792471 return has_loose_object (sha1 );
24802472}
0 commit comments