@@ -10,26 +10,44 @@ var _Repo = function( path, callback ) {
1010 // Internal reference to a Git repository
1111 self . repo = new git . raw . Repo ( ) ;
1212
13+
14+ // Look up a branch and find its tree
15+ self . branch = function ( name , callback ) {
16+ if ( ! callback ) { return ; }
17+
18+ self . ref ( 'refs/heads/' + name , function ( err , ref ) {
19+ if ( err ) { throw err ; }
20+
21+ git . commit ( self . repo ) . lookup ( ref . oid ( ) . oid , function ( ) {
22+ var args = Array . prototype . slice . call ( arguments ) ;
23+ args [ 0 ] = git . util ( ) . error ( args [ 0 ] ) ;
24+
25+ callback . apply ( this , args . concat ( this ) ) ;
26+ } ) ;
27+ } ) ;
28+ } ;
29+
1330 // Work with a specific head reference
14- self . head = function ( name , callback ) {
15- var head = git . ref ( self . repo ) ;
31+ self . ref = function ( name , callback ) {
32+ if ( ! callback ) { return ; }
33+
34+ var ref = git . ref ( self . repo ) ;
1635
17- self . repo . lookupRef ( head . ref , 'refs/heads/' + name , function ( ) {
36+ self . repo . lookupRef ( ref . ref , name , function ( ) {
1837 var args = Array . prototype . slice . call ( arguments ) ;
1938 args [ 0 ] = git . util ( ) . error ( args [ 0 ] ) ;
2039
21- callback . apply ( head , args . concat ( head ) ) ;
40+ callback . apply ( ref , args . concat ( ref ) ) ;
2241 } ) ;
2342 } ;
2443
2544 // Find a single commit
2645 self . commit = function ( sha , callback ) {
27- var oid = git . oid ( sha ) ;
28-
2946 if ( ! callback ) { return ; }
3047
31- var commit = git . commit ( self . repo ) ;
32- commit . lookup ( oid . oid , callback ) ;
48+ var oid = git . oid ( sha ) ;
49+
50+ git . commit ( self . repo ) . lookup ( oid . oid , callback ) ;
3351 } ;
3452
3553 //self.find = function( name, callback ) {
0 commit comments