public function merge(Branch $branch, string $message = '', string $mode = 'auto')
    {
        $valid_modes = [
            'auto', // deafult git behavior
            'ff-only', // force fast forward merge
            'no-ff', // force 3-way merge
        ];
        if (!in_array($mode, $valid_modes)) {
            throw new InvalidArgumentException("Invalid merge mode: $mode.");
        }

        $options = [];
        switch ($mode) {
            case 'ff-only':
                $options[] = MergeCommand::MERGE_OPTION_FF_ONLY;
                break;
            case 'no-ff':
                $options[] = MergeCommand::MERGE_OPTION_NO_FF;
                break;
        }

        $this->caller->execute(MergeCommand::getInstance($this)->merge($branch, $message, $options));

        return $this;
    }