### 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
returned: success
    type: str
    sample: 4c020102a9cd6fe908c9a4a326a38f972f63a903
before:
    description: Commit revision before the repository was updated, "null" for new repository.
    returned: success
    type: str
    sample: 67c04ebe40a003bda0efb34eacfb93b0cafdf628
remote_url_changed:
    description: Contains True or False whether or not the remote URL was changed.
    returned: success
    type: bool
    sample: True
warnings:
    description: List of warnings if requested features were not available due to a too old git version.
    returned: error
    type: str
    sample: git version is too old to fully support the depth argument. Falling back to full checkouts.
git_dir_now:
    description: Contains the new path of .git directory if it is changed.
    returned: success
    type: str
    sample: /path/to/new/git/dir
git_dir_before:
    description: Contains the original path of .git directory if it is changed.
    returned: success
    type: str
    sample: /path/to/old/git/dir
'''
import filecmp