@ -181,16 +181,10 @@ public class PullCommand extends GitCommand<PullResult> {
String remoteBranchName = repoConfig . getString (
String remoteBranchName = repoConfig . getString (
ConfigConstants . CONFIG_BRANCH_SECTION , branchName ,
ConfigConstants . CONFIG_BRANCH_SECTION , branchName ,
ConfigConstants . CONFIG_KEY_MERGE ) ;
ConfigConstants . CONFIG_KEY_MERGE ) ;
boolean doRebase = false ;
// check if the branch is configured for pull-rebase
if ( remoteBranchName = = null ) {
boolean doRebase = repoConfig . getBoolean (
// check if the branch is configured for pull-rebase
ConfigConstants . CONFIG_BRANCH_SECTION , branchName ,
remoteBranchName = repoConfig . getString (
ConfigConstants . CONFIG_KEY_REBASE , false ) ;
ConfigConstants . CONFIG_BRANCH_SECTION , branchName ,
ConfigConstants . CONFIG_KEY_REBASE ) ;
if ( remoteBranchName ! = null ) {
doRebase = true ;
}
}
if ( remoteBranchName = = null ) {
if ( remoteBranchName = = null ) {
String missingKey = ConfigConstants . CONFIG_BRANCH_SECTION + DOT
String missingKey = ConfigConstants . CONFIG_BRANCH_SECTION + DOT
@ -237,11 +231,38 @@ public class PullCommand extends GitCommand<PullResult> {
JGitText . get ( ) . operationCanceled ,
JGitText . get ( ) . operationCanceled ,
JGitText . get ( ) . pullTaskName ) ) ;
JGitText . get ( ) . pullTaskName ) ) ;
// we check the updates to see which of the updated branches
// corresponds
// to the remote branch name
AnyObjectId commitToMerge ;
if ( isRemote ) {
Ref r = null ;
if ( fetchRes ! = null ) {
r = fetchRes . getAdvertisedRef ( remoteBranchName ) ;
if ( r = = null )
r = fetchRes . getAdvertisedRef ( Constants . R_HEADS
+ remoteBranchName ) ;
}
if ( r = = null )
throw new JGitInternalException ( MessageFormat . format ( JGitText
. get ( ) . couldNotGetAdvertisedRef , remoteBranchName ) ) ;
else
commitToMerge = r . getObjectId ( ) ;
} else {
try {
commitToMerge = repo . resolve ( remoteBranchName ) ;
} catch ( IOException e ) {
throw new JGitInternalException (
JGitText . get ( ) . exceptionCaughtDuringExecutionOfPullCommand ,
e ) ;
}
}
PullResult result ;
PullResult result ;
if ( doRebase ) {
if ( doRebase ) {
RebaseCommand rebase = new RebaseCommand ( repo ) ;
RebaseCommand rebase = new RebaseCommand ( repo ) ;
try {
try {
RebaseResult rebaseRes = rebase . setUpstream ( remoteBranchName )
RebaseResult rebaseRes = rebase . setUpstream ( commitToMerg e)
. setProgressMonitor ( monitor ) . setOperation (
. setProgressMonitor ( monitor ) . setOperation (
Operation . BEGIN ) . call ( ) ;
Operation . BEGIN ) . call ( ) ;
result = new PullResult ( fetchRes , remote , rebaseRes ) ;
result = new PullResult ( fetchRes , remote , rebaseRes ) ;
@ -255,34 +276,6 @@ public class PullCommand extends GitCommand<PullResult> {
throw new JGitInternalException ( e . getMessage ( ) , e ) ;
throw new JGitInternalException ( e . getMessage ( ) , e ) ;
}
}
} else {
} else {
// we check the updates to see which of the updated branches
// corresponds
// to the remote branch name
AnyObjectId commitToMerge ;
if ( isRemote ) {
Ref r = null ;
if ( fetchRes ! = null ) {
r = fetchRes . getAdvertisedRef ( remoteBranchName ) ;
if ( r = = null )
r = fetchRes . getAdvertisedRef ( Constants . R_HEADS
+ remoteBranchName ) ;
}
if ( r = = null )
throw new JGitInternalException ( MessageFormat . format (
JGitText . get ( ) . couldNotGetAdvertisedRef ,
remoteBranchName ) ) ;
else
commitToMerge = r . getObjectId ( ) ;
} else {
try {
commitToMerge = repo . resolve ( remoteBranchName ) ;
} catch ( IOException e ) {
throw new JGitInternalException (
JGitText . get ( ) . exceptionCaughtDuringExecutionOfPullCommand ,
e ) ;
}
}
MergeCommand merge = new MergeCommand ( repo ) ;
MergeCommand merge = new MergeCommand ( repo ) ;
merge . include (
merge . include (
"branch \'" + remoteBranchName + "\' of " + remoteUri ,
"branch \'" + remoteBranchName + "\' of " + remoteUri ,