src/main/php/CommandLine/Library/Environment.php
public function guessParentBranchAsCommitHash(string $branchName = 'HEAD') : string
    {
        $initialNumberOfContainingBranches = $this->getCountOfContainingBranches($branchName);
        while ($this->isParentCommitishACommit($branchName)) {
            $branchName .= '^';
            $numberOfContainingBranches = $this->getCountOfContainingBranches($branchName);

            if ($numberOfContainingBranches !== $initialNumberOfContainingBranches) {
                break;
            }
        }
        $gitCommitHash = $this->processRunner->runAsProcess('git', 'rev-parse', $branchName);

        return $gitCommitHash;
    }
public function guessParentBranchAsCommitHash(string $branchName = 'HEAD') : string
    {
        $initialNumberOfContainingBranches = $this->getCountOfContainingBranches($branchName);
        while ($this->isParentCommitishACommit($branchName)) {
            $branchName .= '^';
            $numberOfContainingBranches = $this->getCountOfContainingBranches($branchName);

            if ($numberOfContainingBranches !== $initialNumberOfContainingBranches) {
                break;
            }
        }
        $gitCommitHash = $this->processRunner->runAsProcess('git', 'rev-parse', $branchName);

        return $gitCommitHash;
    }
public function guessParentBranchAsCommitHash ( string $ branchName = 'HEAD' ) : string { $ initialNumberOfContainingBranches = $ this -> getCountOfContainingBranches ( $ branchName ) ; while ( $ this -> isParentCommitishACommit ( $ branchName ) ) { $ branchName .= '^' ; $ numberOfContainingBranches = $ this -> getCountOfContainingBranches ( $ branchName ) ; if ( $ numberOfContainingBranches !== $ initialNumberOfContainingBranches ) { break ; } } $ gitCommitHash = $ this -> processRunner -> runAsProcess ( 'git' , 'rev-parse' , $ branchName ) ; return $ gitCommitHash ; }
This method searches the first parent commit which is part of another branch and returns this commit as merge base
with parent branch.

@param string $branchName

@return string
This method searches the first parent commit which is part of another branch and returns this commit as merge base with parent branch .