@ -319,16 +319,14 @@ public class RefDirectory extends RefDatabase {
return loose ;
return loose ;
}
}
/** {@inheritDoc} */
@Nullable
@Override
private Ref readAndResolve ( String name , RefList < Ref > packed ) throws IOException {
public Ref exactRef ( String name ) throws IOException {
RefList < Ref > packed = getPackedRefs ( ) ;
Ref ref ;
try {
try {
ref = readRef ( name , packed ) ;
Ref ref = readRef ( name , packed ) ;
if ( ref ! = null ) {
if ( ref ! = null ) {
ref = resolve ( ref , 0 , null , null , packed ) ;
ref = resolve ( ref , 0 , null , null , packed ) ;
}
}
return ref ;
} catch ( IOException e ) {
} catch ( IOException e ) {
if ( name . contains ( "/" ) //$NON-NLS-1$
if ( name . contains ( "/" ) //$NON-NLS-1$
| | ! ( e . getCause ( ) instanceof InvalidObjectIdException ) ) {
| | ! ( e . getCause ( ) instanceof InvalidObjectIdException ) ) {
@ -338,8 +336,14 @@ public class RefDirectory extends RefDatabase {
// While looking for a ref outside of refs/ (e.g., 'config'), we
// While looking for a ref outside of refs/ (e.g., 'config'), we
// found a non-ref file (e.g., a config file) instead. Treat this
// found a non-ref file (e.g., a config file) instead. Treat this
// as a ref-not-found condition.
// as a ref-not-found condition.
ref = null ;
return null ;
}
}
}
/** {@inheritDoc} */
@Override
public Ref exactRef ( String name ) throws IOException {
Ref ref = readAndResolve ( name , getPackedRefs ( ) ) ;
fireRefsChanged ( ) ;
fireRefsChanged ( ) ;
return ref ;
return ref ;
}
}
@ -350,20 +354,10 @@ public class RefDirectory extends RefDatabase {
final RefList < Ref > packed = getPackedRefs ( ) ;
final RefList < Ref > packed = getPackedRefs ( ) ;
Ref ref = null ;
Ref ref = null ;
for ( String prefix : SEARCH_PATH ) {
for ( String prefix : SEARCH_PATH ) {
try {
ref = readAndResolve ( prefix + needle , packed ) ;
ref = readRef ( prefix + needle , packed ) ;
if ( ref ! = null ) {
ref = resolve ( ref , 0 , null , null , packed ) ;
}
if ( ref ! = null ) {
if ( ref ! = null ) {
break ;
break ;
}
}
} catch ( IOException e ) {
if ( ! ( ! needle . contains ( "/" ) & & "" . equals ( prefix ) & & e //$NON-NLS-1$ //$NON-NLS-2$
. getCause ( ) instanceof InvalidObjectIdException ) ) {
throw e ;
}
}
}
}
fireRefsChanged ( ) ;
fireRefsChanged ( ) ;
return ref ;
return ref ;