fn find_target() -> Result<Option<CommitSpec>, CommitErr> {
    let branch_name: LocalBranchName = match GitStatus::new() {
        Ok(GitStatus {
            head: WorktreeHead::Attached { head, .. },
            ..
        }) => head.parse().unwrap(),
        Err(err) => {
            return Err(CommitErr::GitError(err));
        }
        _ => {
            return Ok(None);
        }
    };
    let mut remote = None;
    let target_branch = {
        let mut target_branch = None;
        let prefix = branch_name.setting_name("");
        let target_setting = target_branch_setting(&branch_name);
        let remote_setting = branch_name.setting_name("remote");
        for entry in get_settings(&prefix, &["oaf-target-branch", "remote"]) {
            if let SettingEntry::Valid { key, value } = entry {
                if key == target_setting {
                    target_branch = Some(value);
                } else if key == remote_setting {
                    remote = Some(value);
                }
            }
        }
        if let Some(target_branch) = target_branch {
            if let Some(remote) = remote {
                let local_branch = LocalBranchName {
                    name: short_branch(&target_branch),
                };
                local_branch.with_repo(remote).full()
            } else {
                target_branch
            }
        } else {
            return Ok(None);
        }
    };
    Ok(Some(target_branch.parse()?))
}
/**
 * Find a commit spec to merge into.
 * note: Errors could be caused by a failed status command instead of a failed parse.
 */
Find a commit spec to merge into.
note: Errors could be caused by a failed status command instead of a failed parse.
Find a commit spec to merge into . note : Errors could be caused by a failed status command instead of a failed parse .
fn find_target() -> Result<Option<CommitSpec>, CommitErr> {
    let branch_name: LocalBranchName = match GitStatus::new() {
        Ok(GitStatus {
            head: WorktreeHead::Attached { head, .. },
            ..
        }) => head.parse().unwrap(),
        Err(err) => {
            return Err(CommitErr::GitError(err));
        }
        _ => {
            return Ok(None);
        }
    };
    let mut remote = None;
    let target_branch = {
        let mut target_branch = None;
        let prefix = branch_name.setting_name("");
        let target_setting = target_branch_setting(&branch_name);
        let remote_setting = branch_name.setting_name("remote");
        for entry in get_settings(&prefix, &["oaf-target-branch", "remote"]) {
            if let SettingEntry::Valid { key, value } = entry {
                if key == target_setting {
                    target_branch = Some(value);
                } else if key == remote_setting {
                    remote = Some(value);
                }
            }
        }
        if let Some(target_branch) = target_branch {
            if let Some(remote) = remote {
                let local_branch = LocalBranchName {
                    name: short_branch(&target_branch),
                };
                local_branch.with_repo(remote).full()
            } else {
                target_branch
            }
        } else {
            return Ok(None);
        }
    };
    Ok(Some(target_branch.parse()?))
}
fn find_target ( ) -> Result < Option < CommitSpec > , CommitErr > { let branch_name : LocalBranchName = match GitStatus :: new ( ) { Ok ( GitStatus { head : WorktreeHead :: Attached { head , .. } , .. } ) => head . parse ( ) . unwrap ( ) , Err ( err ) => { return Err ( CommitErr :: GitError ( err ) ) ; } _ => { return Ok ( None ) ; } } ; let mut remote = None ; let target_branch = { let mut target_branch = None ; let prefix = branch_name . setting_name ( " " ) ; let target_setting = target_branch_setting ( & branch_name ) ; let remote_setting = branch_name . setting_name ( " " ) ; for entry in get_settings ( & prefix , & [ " " , " " ] ) { if let SettingEntry :: Valid { key , value } = entry { if key == target_setting { target_branch = Some ( value ) ; } else if key == remote_setting { remote = Some ( value ) ; } } } if let Some ( target_branch ) = target_branch { if let Some ( remote ) = remote { let local_branch = LocalBranchName { name : short_branch ( & target_branch ) , } ; local_branch . with_repo ( remote ) . full ( ) } else { target_branch } } else { return Ok ( None ) ; } } ; Ok ( Some ( target_branch . parse ( ) ? ) ) }
Find a commit spec to merge into.
Find a commit spec to merge into .