### 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 version in get_annotated_tags(git_path, module, dest):
        git_sub = "verify-tag"
    else:
        git_sub = "verify-commit"
    cmd = "%s %s %s" % (git_path, git_sub, version)
    if gpg_whitelist:
        cmd += " --raw"
    (rc, out, err) = module.run_command(cmd, cwd=dest)
    if rc != 0:
        module.fail_json(msg='Failed to verify GPG signature of commit/tag "%s"' % version, stdout=out, stderr=err, rc=rc)
    if gpg_whitelist:
        fingerprint = get_gpg_fingerprint(err)
        if fingerprint not in gpg_whitelist:
            module.fail_json(msg='The gpg_whitelist does not include the public key "%s" for this commit' % fingerprint, stdout=out, stderr=err, rc=rc)
    return (rc, out, err)
def get_gpg_fingerprint(output):
    """Return a fingerprint of the primary key.
    Ref:
    https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/DETAILS;hb=HEAD#l482
    """
    for line in output.splitlines():
        data = line.split()
        if data[1] != 'VALIDSIG':
            continue
        
        data_id = 11 if len(data) == 11 else 2
        return data[data_id]
def git_version(git_path, module):