### Summary

See: https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/git.py#L760 :

```py
            repo_path = os.path.join(repo_path.split('.git')[0], gitdir)
```

the intention of this code seems to be to strip `.git` from the end of the path.

If the repo path contains `.git` anywhere, like `/tmp/music.gittern/myrepo`, tasks will unexpectedly fail:

```
fatal: [localhost]: FAILED! => {"changed": false, "details": "/tmp/music/../.git/modules/submodule is not a directory", "msg": "Current repo does not have a valid reference to a separate Git dir or it refers to the invalid path"}
```

For a playbook like:
```yaml
---
- hosts: localhost
  tasks:
   - name: test git
     git: 
        repo: ...
        dest: /tmp/music.gittern/myrepo/submodule
```

I can't tell if this is a potential security issue or just an unexpected corner case. What I am pretty sure I can tell, is that that's not how one strips `.git` from the end of a path.

### Issue Type

Bug Report

### Component Name

git

### Ansible Version

```console
$ ansible --version
2.11
```


### Configuration

```console
$ ansible-config dump --only-changed
ANSIBLE_NOCOWS(/home/enrico/dev/transilience/ansible.cfg) = True
```


### OS / Environment

Debian Bullseye

### Steps to Reproduce

Use submodules in a repo whose path contains `.git` anywhere as part of a file name.
For example:
```yaml
---
- hosts: localhost
  tasks:
   - name: test git
     git: 
        repo: ...
        dest: /tmp/music.gittern/myrepo/submodule
```

### Expected Results

I'd expect directory names like `gato.gito` not to be interpreted specially by mistake

### Actual Results

```console
fatal: [localhost]: FAILED! => {"changed": false, "details": "/tmp/music/../.git/modules/submodule is not a directory", "msg": "Current repo does not have a valid reference to a separate Git dir or it refers to the invalid path"}
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
if not force:
                module.fail_json(msg="Local modifications exist in repository (force=no).", **result)
            
            if not module.check_mode:
                reset(git_path, module, dest)
                result.update(changed=True, msg='Local modifications exist.')
        
        if module.check_mode:
            remote_url = get_remote_url(git_path, module, dest, remote)
            remote_url_changed = remote_url and remote_url != repo and unfrackgitpath(remote_url) != unfrackgitpath(repo)
        else:
            remote_url_changed = set_remote_url(git_path, module, repo, dest, remote)
        result.update(remote_url_changed=remote_url_changed)
        if module.check_mode:
            remote_head = get_remote_head(git_path, module, dest, version, remote, bare)
            result.update(changed=(result['before'] != remote_head or remote_url_changed), after=remote_head)
            
            if module._diff:
                diff = get_diff(module, git_path, dest, repo, remote, depth, bare, result['before'], result['after'])
                if diff:
                    result['diff'] = diff
            module.exit_json(**result)
        else:
            fetch(git_path, module, repo, dest, version, remote, depth, bare, refspec, git_version_used, force=force)
        result['after'] = get_version(module, git_path, dest)
    
    
    if not bare:
        switch_version(git_path, module, dest, remote, version, verify_commit, depth, gpg_whitelist)