@@ -53,37 +53,16 @@ function(name, commit, force, signature, logMessage) {
5353} ;
5454
5555/**
56- * Look up a branch
56+ * Look up a refs's commit.
5757 *
58- * @param {String|Ref } name Branch name, e.g. "master" or Branch Ref
59- * @param {Function } callback
60- * @return {Ref }
61- */
62- Repository . prototype . getBranch = function ( name , callback ) {
63- name = ( name instanceof Reference ||
64- ~ name . indexOf ( "refs/heads/" ) ) ? name
65- : "refs/heads/" + name ;
66-
67- return this . getReference ( name ) . then ( function ( reference ) {
68- if ( typeof callback === "function" ) {
69- callback ( null , reference ) ;
70- }
71-
72- return reference ;
73- } , callback ) ;
74- } ;
75-
76- /**
77- * Look up a branch's most recent commit.
78- *
79- * @param {String|Ref } name Branch name, e.g. "master" or Branch Ref
58+ * @param {String|Ref } name Ref name, e.g. "master", "refs/heads/master" or Branch Ref
8059 * @param {Function } callback
8160 * @return {Commit }
8261 */
83- Repository . prototype . getBranchCommit = function ( name , callback ) {
62+ Repository . prototype . getReferenceCommit = function ( name , callback ) {
8463 var repository = this ;
8564
86- return this . getBranch ( name ) . then ( function ( reference ) {
65+ return this . getReference ( name ) . then ( function ( reference ) {
8766 return repository . getCommit ( reference . target ( ) ) . then ( function ( commit ) {
8867 if ( typeof callback === "function" ) {
8968 callback ( null , commit ) ;
@@ -112,8 +91,11 @@ Repository.prototype.getCurrentBranch = function() {
11291 */
11392Repository . prototype . getReference = function ( name , callback ) {
11493 var repository = this ;
94+ var lookup = name . indexOf ( "refs/" ) === 0
95+ ? Reference . lookup ( this , name )
96+ : Reference . dwim ( this , name ) ;
11597
116- return Reference . lookup ( this , name ) . then ( function ( reference ) {
98+ return lookup . then ( function ( reference ) {
11799 if ( reference . isSymbolic ( ) ) {
118100 return reference . resolve ( function ( error , reference ) {
119101 reference . repo = repository ;
@@ -507,29 +489,36 @@ Repository.prototype.getRemote = function(remote, callback) {
507489 *
508490 * @param {String|Remote } remote
509491 */
510- Repository . prototype . fetch = function ( remote ) {
492+ Repository . prototype . fetch = function ( remote , remoteCallbacks , callback ) {
511493 var repo = this ;
512494
513495 return repo . getRemote ( remote ) . then ( function ( remote ) {
514- return remote . fetch ( repo . defaultSignature ( ) ) ;
515- } ) ;
496+ remote . setCallbacks ( remoteCallbacks ) ;
497+
498+ return remote . fetch ( repo . defaultSignature ( ) , "Fetch from " + remote )
499+ . then ( function ( ) {
500+ if ( typeof callback === "function" ) {
501+ callback ( ) ;
502+ }
503+ } ) ;
504+ } , callback ) ;
516505} ;
517506
518507/**
519508 * Fetches from all remotes
520509 */
521- Repository . prototype . fetchAll = function ( ) {
510+ Repository . prototype . fetchAll = function ( remoteCallbacks , callback ) {
522511 var repo = this ;
523512
524- return repo . getRemotes ( function ( remotes ) {
513+ return repo . getRemotes ( ) . then ( function ( remotes ) {
525514 var fetchPromises = [ ] ;
526515
527516 remotes . forEach ( function ( remote ) {
528- fetchPromises . push ( repo . fetch ( remote ) ) ;
517+ fetchPromises . push ( repo . fetch ( remote , remoteCallbacks , callback ) ) ;
529518 } ) ;
530519
531520 return Promise . all ( fetchPromises ) ;
532- } ) ;
521+ } , callback ) ;
533522} ;
534523
535524/**
0 commit comments