### 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
for the source tree.
              Allowed archive formats ["zip", "tar.gz", "tar", "tgz"].
            - This will clone and perform git archive from local directory as not
              all git servers support git archive.
        type: path
        version_added: "2.4"
    archive_prefix:
        description:
            - Specify a prefix to add to each file path in archive. Requires I(archive) to be specified.
        version_added: "2.10"
        type: str
    separate_git_dir:
        description:
            - The path to place the cloned repository. If specified, Git repository
              can be separated from working tree.
        type: path
        version_added: "2.7"
    gpg_whitelist:
        description:
           - A list of trusted GPG fingerprints to compare to the fingerprint of the
             GPG-signed commit.
           - Only used when I(verify_commit=yes).
           - Use of this feature requires Git 2.6+ due to its reliance on git's C(--raw) flag to C(verify-commit) and C(verify-tag).
        type: list
        elements: str
        default: []
        version_added: "2.9"
requirements:
    - git>=1.7.1 (the command line tool)
notes: