@@ -508,20 +508,22 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,
508
508
{
509
509
struct object_directory * ent ;
510
510
struct strbuf pathbuf = STRBUF_INIT ;
511
+ struct strbuf tmp = STRBUF_INIT ;
511
512
khiter_t pos ;
513
+ int ret = -1 ;
512
514
513
515
if (!is_absolute_path (entry -> buf ) && relative_base ) {
514
516
strbuf_realpath (& pathbuf , relative_base , 1 );
515
517
strbuf_addch (& pathbuf , '/' );
516
518
}
517
519
strbuf_addbuf (& pathbuf , entry );
518
520
519
- if (strbuf_normalize_path ( & pathbuf ) < 0 && relative_base ) {
521
+ if (! strbuf_realpath ( & tmp , pathbuf . buf , 0 ) ) {
520
522
error (_ ("unable to normalize alternate object path: %s" ),
521
523
pathbuf .buf );
522
- strbuf_release (& pathbuf );
523
- return -1 ;
524
+ goto error ;
524
525
}
526
+ strbuf_swap (& pathbuf , & tmp );
525
527
526
528
/*
527
529
* The trailing slash after the directory name is given by
@@ -530,10 +532,8 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,
530
532
while (pathbuf .len && pathbuf .buf [pathbuf .len - 1 ] == '/' )
531
533
strbuf_setlen (& pathbuf , pathbuf .len - 1 );
532
534
533
- if (!alt_odb_usable (r -> objects , & pathbuf , normalized_objdir , & pos )) {
534
- strbuf_release (& pathbuf );
535
- return -1 ;
536
- }
535
+ if (!alt_odb_usable (r -> objects , & pathbuf , normalized_objdir , & pos ))
536
+ goto error ;
537
537
538
538
CALLOC_ARRAY (ent , 1 );
539
539
/* pathbuf.buf is already in r->objects->odb_by_path */
@@ -548,8 +548,11 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,
548
548
549
549
/* recursively add alternates */
550
550
read_info_alternates (r , ent -> path , depth + 1 );
551
-
552
- return 0 ;
551
+ ret = 0 ;
552
+ error :
553
+ strbuf_release (& tmp );
554
+ strbuf_release (& pathbuf );
555
+ return ret ;
553
556
}
554
557
555
558
static const char * parse_alt_odb_entry (const char * string ,
@@ -596,10 +599,7 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,
596
599
return ;
597
600
}
598
601
599
- strbuf_add_absolute_path (& objdirbuf , r -> objects -> odb -> path );
600
- if (strbuf_normalize_path (& objdirbuf ) < 0 )
601
- die (_ ("unable to normalize object directory: %s" ),
602
- objdirbuf .buf );
602
+ strbuf_realpath (& objdirbuf , r -> objects -> odb -> path , 1 );
603
603
604
604
while (* alt ) {
605
605
alt = parse_alt_odb_entry (alt , sep , & entry );
0 commit comments