### 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 git_version_used is None:
            module.fail_json(msg='Cannot find git executable at %s' % git_path)
        if git_version_used < LooseVersion('1.7.5'):
            
            needs_separate_git_dir_fallback = True
        else:
            cmd.append('--separate-git-dir=%s' % separate_git_dir)
    cmd.extend([repo, dest])
    module.run_command(cmd, check_rc=True, cwd=dest_dirname)
    if needs_separate_git_dir_fallback:
        relocate_repo(module, result, separate_git_dir, os.path.join(dest, ".git"), dest)
    if bare and remote != 'origin':
        module.run_command([git_path, 'remote', 'add', remote, repo], check_rc=True, cwd=dest)
    if refspec:
        cmd = [git_path, 'fetch']
        if depth:
            cmd.extend(['--depth', str(depth)])
        cmd.extend([remote, refspec])
        module.run_command(cmd, check_rc=True, cwd=dest)
    if verify_commit:
        verify_commit_sign(git_path, module, dest, version, gpg_whitelist)
def has_local_mods(module, git_path, dest, bare):
    if bare:
        return False
    cmd = "%s status --porcelain" % (git_path)
    rc, stdout, stderr = module.run_command(cmd, cwd=dest)
    lines = stdout.splitlines()
    lines = list(filter(lambda c: not re.search('^\\?\\?.*$', c), lines))
    return len(lines) > 0
def reset(git_path, module, dest):