diff --git a/.coveragerc b/.coveragerc
deleted file mode 100644
index e2b6256e9..000000000
--- a/.coveragerc
+++ /dev/null
@@ -1,7 +0,0 @@
-[run]
-source = git
-
-; to make nosetests happy
-[report]
-include = */git/*
-omit = */git/ext/*
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000000000..3f3d2f050
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,3 @@
+test/fixtures/* eol=lf
+*.sh eol=lf
+/Makefile eol=lf
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000..80819f5d8
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+github: byron
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..2fe73ca77
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,11 @@
+version: 2
+updates:
+- package-ecosystem: "github-actions"
+  directory: "/"
+  schedule:
+    interval: "weekly"
+
+- package-ecosystem: "gitsubmodule"
+  directory: "/"
+  schedule:
+    interval: "weekly"
diff --git a/.github/workflows/alpine-test.yml b/.github/workflows/alpine-test.yml
new file mode 100644
index 000000000..ceba11fb8
--- /dev/null
+++ b/.github/workflows/alpine-test.yml
@@ -0,0 +1,76 @@
+name: test-alpine
+
+on: [push, pull_request, workflow_dispatch]
+
+permissions:
+  contents: read
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+
+    container:
+      image: alpine:latest
+
+    defaults:
+      run:
+        shell: sudo -u runner sh -exo pipefail {0}
+
+    steps:
+    - name: Prepare Alpine Linux
+      run: |
+        apk add sudo git git-daemon python3 py3-pip py3-virtualenv
+        echo 'Defaults env_keep += "CI GITHUB_* RUNNER_*"' >/etc/sudoers.d/ci_env
+        addgroup -g 127 docker
+        adduser -D -u 1001 runner  # TODO: Check if this still works on GHA as intended.
+        adduser runner docker
+      shell: sh -exo pipefail {0}  # Run this as root, not the "runner" user.
+
+    - uses: actions/checkout@v4
+      with:
+        fetch-depth: 0
+
+    - name: Set workspace ownership
+      run: |
+        chown -R runner:docker -- "$GITHUB_WORKSPACE"
+      shell: sh -exo pipefail {0}  # Run this as root, not the "runner" user.
+
+    - name: Prepare this repo for tests
+      run: |
+        ./init-tests-after-clone.sh
+
+    - name: Set git user identity and command aliases for the tests
+      run: |
+        git config --global user.email "travis@ci.com"
+        git config --global user.name "Travis Runner"
+        # If we rewrite the user's config by accident, we will mess it up
+        # and cause subsequent tests to fail
+        cat test/fixtures/.gitconfig >> ~/.gitconfig
+
+    - name: Set up virtual environment
+      run: |
+        python -m venv .venv
+
+    - name: Update PyPA packages
+      run: |
+        . .venv/bin/activate
+        python -m pip install -U pip 'setuptools; python_version<"3.12"' wheel
+
+    - name: Install project and test dependencies
+      run: |
+        . .venv/bin/activate
+        pip install '.[test]'
+
+    - name: Show version and platform information
+      run: |
+        . .venv/bin/activate
+        uname -a
+        command -v git python
+        git version
+        python --version
+        python -c 'import os, sys; print(f"sys.platform={sys.platform!r}, os.name={os.name!r}")'
+
+    - name: Test with pytest
+      run: |
+        . .venv/bin/activate
+        pytest --color=yes -p no:sugar --instafail -vv
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 000000000..2bee952af
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,90 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL"
+
+on:
+  push:
+  pull_request:
+  schedule:
+    - cron: '27 10 * * 3'
+
+jobs:
+  analyze:
+    name: Analyze (${{ matrix.language }})
+    # Runner size impacts CodeQL analysis time. To learn more, please see:
+    #   - https://gh.io/recommended-hardware-resources-for-running-codeql
+    #   - https://gh.io/supported-runners-and-hardware-resources
+    #   - https://gh.io/using-larger-runners (GitHub.com only)
+    # Consider using larger runners or machines with greater resources for possible analysis time improvements.
+    runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
+    permissions:
+      security-events: write
+
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+        - language: actions
+          build-mode: none
+        - language: python
+          build-mode: none
+        # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
+        # Use `c-cpp` to analyze code written in C, C++ or both
+        # Use 'java-kotlin' to analyze code written in Java, Kotlin or both
+        # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
+        # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
+        # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
+        # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
+        # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v4
+
+    # Add any setup steps before running the `github/codeql-action/init` action.
+    # This includes steps like installing compilers or runtimes (`actions/setup-node`
+    # or others). This is typically only required for manual builds.
+    # - name: Setup runtime (example)
+    #   uses: actions/setup-example@v1
+
+    # Initializes the CodeQL tools for scanning.
+    - name: Initialize CodeQL
+      uses: github/codeql-action/init@v3
+      with:
+        languages: ${{ matrix.language }}
+        build-mode: ${{ matrix.build-mode }}
+        # If you wish to specify custom queries, you can do so here or in a config file.
+        # By default, queries listed here will override any specified in a config file.
+        # Prefix the list here with "+" to use these queries and those in the config file.
+
+        # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
+        # queries: security-extended,security-and-quality
+
+    # If the analyze step fails for one of the languages you are analyzing with
+    # "We were unable to automatically build your code", modify the matrix above
+    # to set the build mode to "manual" for that language. Then modify this step
+    # to build your code.
+    # ℹ️ Command-line programs to run using the OS shell.
+    # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+    - if: matrix.build-mode == 'manual'
+      shell: bash
+      run: |
+        echo 'If you are using a "manual" build mode for one or more of the' \
+          'languages you are analyzing, replace this with the commands to build' \
+          'your code, for example:'
+        echo '  make bootstrap'
+        echo '  make release'
+        exit 1
+
+    - name: Perform CodeQL Analysis
+      uses: github/codeql-action/analyze@v3
+      with:
+        category: "/language:${{matrix.language}}"
diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml
new file mode 100644
index 000000000..cc9e1edf0
--- /dev/null
+++ b/.github/workflows/cygwin-test.yml
@@ -0,0 +1,93 @@
+name: test-cygwin
+
+on: [push, pull_request, workflow_dispatch]
+
+permissions:
+  contents: read
+
+jobs:
+  test:
+    strategy:
+      matrix:
+        selection: [fast, perf]
+        include:
+        - selection: fast
+          additional-pytest-args: --ignore=test/performance
+        - selection: perf
+          additional-pytest-args: test/performance
+
+      fail-fast: false
+
+    runs-on: windows-latest
+
+    env:
+      CHERE_INVOKING: "1"
+      CYGWIN_NOWINPATH: "1"
+
+    defaults:
+      run:
+        shell: C:\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr "{0}"
+
+    steps:
+    - name: Force LF line endings
+      run: |
+        git config --global core.autocrlf false  # Affects the non-Cygwin git.
+      shell: pwsh  # Do this outside Cygwin, to affect actions/checkout.
+
+    - uses: actions/checkout@v4
+      with:
+        fetch-depth: 0
+
+    - name: Install Cygwin
+      uses: cygwin/cygwin-install-action@v6
+      with:
+        packages: git python39 python-pip-wheel python-setuptools-wheel python-wheel-wheel
+        add-to-path: false  # No need to change $PATH outside the Cygwin environment.
+
+    - name: Arrange for verbose output
+      run: |
+        # Arrange for verbose output but without shell environment setup details.
+        echo 'set -x' >~/.bash_profile
+
+    - name: Special configuration for Cygwin git
+      run: |
+        git config --global --add safe.directory "$(pwd)"
+        git config --global --add safe.directory "$(pwd)/.git"
+        git config --global core.autocrlf false
+
+    - name: Prepare this repo for tests
+      run: |
+        ./init-tests-after-clone.sh
+
+    - name: Set git user identity and command aliases for the tests
+      run: |
+        git config --global user.email "travis@ci.com"
+        git config --global user.name "Travis Runner"
+        # If we rewrite the user's config by accident, we will mess it up
+        # and cause subsequent tests to fail
+        cat test/fixtures/.gitconfig >> ~/.gitconfig
+
+    - name: Set up virtual environment
+      run: |
+        python3.9 -m venv .venv
+        echo 'BASH_ENV=.venv/bin/activate' >>"$GITHUB_ENV"
+
+    - name: Update PyPA packages
+      run: |
+        python -m pip install -U pip 'setuptools; python_version<"3.12"' wheel
+
+    - name: Install project and test dependencies
+      run: |
+        pip install '.[test]'
+
+    - name: Show version and platform information
+      run: |
+        uname -a
+        command -v git python
+        git version
+        python --version
+        python -c 'import os, sys; print(f"sys.platform={sys.platform!r}, os.name={os.name!r}")'
+
+    - name: Test with pytest (${{ matrix.additional-pytest-args }})
+      run: |
+        pytest --color=yes -p no:sugar --instafail -vv ${{ matrix.additional-pytest-args }}
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 000000000..ceba0dd85
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,19 @@
+name: Lint
+
+on: [push, pull_request, workflow_dispatch]
+
+permissions:
+  contents: read
+
+jobs:
+  lint:
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v4
+
+    - uses: actions/setup-python@v5
+      with:
+        python-version: "3.x"
+
+    - uses: pre-commit/action@v3.0.1
diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml
new file mode 100644
index 000000000..4457a341f
--- /dev/null
+++ b/.github/workflows/pythonpackage.yml
@@ -0,0 +1,117 @@
+# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
+# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
+
+name: Python package
+
+on: [push, pull_request, workflow_dispatch]
+
+permissions:
+  contents: read
+
+jobs:
+  test:
+    strategy:
+      matrix:
+        os-type: [ubuntu, macos, windows]
+        python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.13t"]
+        exclude:
+        - os-type: macos
+          python-version: "3.7"  # Not available for the ARM-based macOS runners.
+        - os-type: macos
+          python-version: "3.13t"
+        - os-type: windows
+          python-version: "3.13"  # FIXME: Fix and enable Python 3.13 on Windows (#1955).
+        - os-type: windows
+          python-version: "3.13t"
+        include:
+        - os-ver: latest
+        - os-type: ubuntu
+          python-version: "3.7"
+          os-ver: "22.04"
+        - experimental: false
+
+      fail-fast: false
+
+    runs-on: ${{ matrix.os-type }}-${{ matrix.os-ver }}
+
+    defaults:
+      run:
+        shell: bash --noprofile --norc -exo pipefail {0}
+
+    steps:
+    - uses: actions/checkout@v4
+      with:
+        fetch-depth: 0
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v5
+      with:
+        python-version: ${{ matrix.python-version }}
+        allow-prereleases: ${{ matrix.experimental }}
+
+    - name: Set up WSL (Windows)
+      if: matrix.os-type == 'windows'
+      uses: Vampire/setup-wsl@v6.0.0
+      with:
+        wsl-version: 1
+        distribution: Alpine
+        additional-packages: bash
+
+    - name: Prepare this repo for tests
+      run: |
+        ./init-tests-after-clone.sh
+
+    - name: Set git user identity and command aliases for the tests
+      run: |
+        git config --global user.email "travis@ci.com"
+        git config --global user.name "Travis Runner"
+        # If we rewrite the user's config by accident, we will mess it up
+        # and cause subsequent tests to fail
+        cat test/fixtures/.gitconfig >> ~/.gitconfig
+
+    - name: Update PyPA packages
+      run: |
+        python -m pip install -U pip 'setuptools; python_version<"3.12"' wheel
+
+    - name: Install project and test dependencies
+      run: |
+        pip install '.[test]'
+
+    - name: Show version and platform information
+      run: |
+        uname -a
+        command -v git python
+        git version
+        python --version
+        python -c 'import os, sys; print(f"sys.platform={sys.platform!r}, os.name={os.name!r}")'
+
+    # For debugging hook tests on native Windows systems that may have WSL.
+    - name: Show bash.exe candidates (Windows)
+      if: matrix.os-type == 'windows'
+      run: |
+        set +e
+        bash.exe -c 'printenv WSL_DISTRO_NAME; uname -a'
+        python -c 'import subprocess; subprocess.run(["bash.exe", "-c", "printenv WSL_DISTRO_NAME; uname -a"])'
+      continue-on-error: true
+
+    - name: Check types with mypy
+      run: |
+        mypy --python-version="${PYTHON_VERSION%t}"  # Version only, with no "t" for free-threaded.
+      env:
+        MYPY_FORCE_COLOR: "1"
+        TERM: "xterm-256color"  # For color: https://github.com/python/mypy/issues/13817
+        PYTHON_VERSION: ${{ matrix.python-version }}
+      # With new versions of mypy new issues might arise. This is a problem if there is
+      # nobody able to fix them, so we have to ignore errors until that changes.
+      continue-on-error: true
+
+    - name: Test with pytest
+      run: |
+        pytest --color=yes -p no:sugar --instafail -vv
+      continue-on-error: false
+
+    - name: Documentation
+      if: matrix.python-version != '3.7'
+      run: |
+        pip install '.[doc]'
+        make -C doc html
diff --git a/.gitignore b/.gitignore
index ce8d0b1b9..eab294a65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,54 @@
+# Cached Python bytecode
+__pycache__/
 *.py[co]
+
+# Other caches
+.cache/
+.mypy_cache/
+.pytest_cache/
+
+# Transient editor files
 *.swp
 *~
-/*.egg-info
+\#*#
+.#*#
+
+# Editor configuration
+nbproject
+*.sublime-workspace
+/.vscode/
+.idea/
+
+# Virtual environments
+.env/
+env/
+.venv/
+venv/
+
+# Build output
+/*egg-info
 /lib/GitPython.egg-info
-cover/
-.coverage
 /build
 /dist
 /doc/_build
-nbproject
-*.sublime-workspace
-.DS_Store
-/*egg-info
+
+# Tox builds/environments
 /.tox
+
+# Code coverage output
+cover/
+.coverage
+.coverage.*
+
+# Monkeytype output
+monkeytype.sqlite3
+monkeytype.sqlite3.*
+
+# Manual command output
+output.txt
+
+# Finder metadata
+.DS_Store
+
+# Files created by OSS-Fuzz when running locally
+fuzz_*.pkg.spec
diff --git a/.gitmodules b/.gitmodules
index 4a3f37c25..251eeeec4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
-[submodule "gitdb"]
-	url = https://github.com/gitpython-developers/gitdb.git
-	path = git/ext/gitdb
+[submodule "gitdb"]
+	url = https://github.com/gitpython-developers/gitdb.git
+	path = git/ext/gitdb
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 000000000..737b56d45
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,38 @@
+repos:
+- repo: https://github.com/codespell-project/codespell
+  rev: v2.4.1
+  hooks:
+  - id: codespell
+    additional_dependencies: [tomli]
+    exclude: ^test/fixtures/
+
+- repo: https://github.com/astral-sh/ruff-pre-commit
+  rev: v0.11.12
+  hooks:
+  - id: ruff-check
+    args: ["--fix"]
+    exclude: ^git/ext/
+  - id: ruff-format
+    exclude: ^git/ext/
+
+- repo: https://github.com/shellcheck-py/shellcheck-py
+  rev: v0.10.0.1
+  hooks:
+  - id: shellcheck
+    args: [--color]
+    exclude: ^test/fixtures/polyglot$|^git/ext/
+
+- repo: https://github.com/pre-commit/pre-commit-hooks
+  rev: v5.0.0
+  hooks:
+  - id: end-of-file-fixer
+    exclude: ^test/fixtures/|COPYING|LICENSE
+  - id: check-symlinks
+  - id: check-toml
+  - id: check-yaml
+  - id: check-merge-conflict
+
+- repo: https://github.com/abravalheri/validate-pyproject
+  rev: v0.24.1
+  hooks:
+  - id: validate-pyproject
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644
index 000000000..9bce80fd2
--- /dev/null
+++ b/.readthedocs.yaml
@@ -0,0 +1,36 @@
+# Read the Docs configuration file for Sphinx projects
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+
+# Required
+version: 2
+
+# Set the OS, Python version and other tools you might need.
+build:
+  os: ubuntu-22.04
+  tools:
+    python: "3.12"
+    # You can also specify other tool versions:
+    # nodejs: "20"
+    # rust: "1.70"
+    # golang: "1.20"
+
+# Build documentation in the "doc/" directory with Sphinx.
+sphinx:
+  configuration: doc/source/conf.py
+  # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
+  # builder: "dirhtml"
+  # Fail on all warnings to avoid broken references
+  fail_on_warning: true
+
+# Optionally build your docs in additional formats such as PDF and ePub.
+formats: all
+
+# Optional but recommended, declare the Python requirements required
+# to build your documentation.
+# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
+python:
+  install:
+  - method: pip
+    path: .
+    extra_requirements:
+    - doc
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 1fda20189..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-language: python
-python:
-  - "2.6"
-  - "2.7"
-  - "3.3"
-  - "3.4"
-  # - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details)
-git:
-  # a higher depth is needed for most of the tests - must be high enough to not actually be shallow
-  # as we clone our own repository in the process
-  depth: 99999
-install:
-  - git submodule update --init --recursive
-  - git fetch --tags
-  - pip install coveralls flake8 sphinx
-
-  # generate some reflog as git-python tests need it (in master)
-  - git checkout master
-  - git reset --hard HEAD~1
-  - git reset --hard HEAD~1
-  - git reset --hard HEAD~1
-  - git reset --hard origin/master
-
-  # as commits are performed with the default user, it needs to be set for travis too
-  - git config --global user.email "travis@ci.com"
-  - git config --global user.name "Travis Runner"
-script: 
-  # Make sure we limit open handles to see if we are leaking them
-  - ulimit -n 64
-  - ulimit -n
-  - nosetests -v --with-coverage
-  - flake8
-  - cd doc && make html
-after_success:
-  - coveralls
diff --git a/AUTHORS b/AUTHORS
index 40fa69883..b57113edd 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -12,5 +12,49 @@ Contributors are:
 -Kai Lautaportti <kai _at_ lautaportti.fi>
 -Paul Sowden <paul _at_ idontsmoke.co.uk>
 -Sebastian Thiel <byronimo _at_ gmail.com>
+-Jonathan Chu <jonathan.chu _at_ me.com>
+-Vincent Driessen <me _at_ nvie.com>
+-Phil Elson <pelson _dot_ pub _at_ gmail.com>
+-Bernard `Guyzmo` Pratz <guyzmo+gitpython+pub@m0g.net>
+-Timothy B. Hartman <tbhartman _at_ gmail.com>
+-Konstantin Popov <konstantin.popov.89 _at_ yandex.ru>
+-Peter Jones <pjones _at_ redhat.com>
+-Anson Mansfield <anson.mansfield _at_ gmail.com>
+-Ken Odegard <ken.odegard _at_ gmail.com>
+-Alexis Horgix Chotard
+-Piotr Babij <piotr.babij _at_ gmail.com>
+-Mikuláš Poul <mikulaspoul _at_ gmail.com>
+-Charles Bouchard-Légaré <cblegare.atl _at_ ntis.ca>
+-Yaroslav Halchenko <debian _at_ onerussian.com>
+-Tim Swast <swast _at_ google.com>
+-William Luc Ritchie
+-David Host <hostdm _at_ outlook.com>
+-A. Jesse Jiryu Davis <jesse _at_ emptysquare.net>
+-Steven Whitman <ninloot _at_ gmail.com>
+-Stefan Stancu <stefan.stancu _at_ gmail.com>
+-César Izurieta <cesar _at_ caih.org>
+-Arthur Milchior <arthur _at_ milchior.fr>
+-Anil Khatri <anil.soccer.khatri _at_ gmail.com>
+-JJ Graham <thetwoj _at_ gmail.com>
+-Ben Thayer <ben _at_ benthayer.com>
+-Dries Kennes <admin _at_ dries007.net>
+-Pratik Anurag <panurag247365 _at_ gmail.com>
+-Harmon <harmon.public _at_ gmail.com>
+-Liam Beguin <liambeguin _at_ gmail.com>
+-Ram Rachum <ram _at_ rachum.com>
+-Alba Mendez <me _at_ alba.sh>
+-Robert Westman <robert _at_ byteflux.io>
+-Hugo van Kemenade
+-Hiroki Tokunaga <tokusan441 _at_ gmail.com>
+-Julien Mauroy <pro.julien.mauroy _at_ gmail.com>
+-Patrick Gerard
+-Luke Twist <itsluketwist@gmail.com>
+-Joseph Hale <me _at_ jhale.dev>
+-Santos Gallegos <stsewd _at_ proton.me>
+-Wenhan Zhu <wzhu.cosmos _at_ gmail.com>
+-Eliah Kagan <eliah.kagan _at_ gmail.com>
+-Ethan Lin <et.repositories _at_ gmail.com>
+-Jonas Scharpf <jonas.scharpf _at_ checkmk.com>
+-Gordon Marx
 
 Portions derived from other open source works and are clearly marked.
diff --git a/CHANGES b/CHANGES
index 9242253ff..9796566ae 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,2 +1,2 @@
 Please see the online documentation for the latest changelog:
-https://github.com/gitpython-developers/GitPython/blob/0.3/doc/source/changes.rst
+https://github.com/gitpython-developers/GitPython/blob/main/doc/source/changes.rst
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..8536d7f73
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,15 @@
+# How to contribute
+
+The following is a short step-by-step rundown of what one typically would do to contribute.
+
+- [Fork this project](https://github.com/gitpython-developers/GitPython/fork) on GitHub.
+- For setting up the environment to run the self tests, please run `init-tests-after-clone.sh`.
+- Please try to **write a test that fails unless the contribution is present.**
+- Try to avoid massive commits and prefer to take small steps, with one commit for each.
+- Feel free to add yourself to AUTHORS file.
+- Create a pull request.
+
+## Fuzzing Test Specific Documentation
+
+For details related to contributing to the fuzzing test suite and OSS-Fuzz integration, please 
+refer to the dedicated [fuzzing README](./fuzzing/README.md).
diff --git a/FUNDING.json b/FUNDING.json
new file mode 100644
index 000000000..bf3faa662
--- /dev/null
+++ b/FUNDING.json
@@ -0,0 +1,7 @@
+{
+  "drips": {
+    "ethereum": {
+      "ownedBy": "0xD0d4dCFc194ec24bCc777e635289e0b10E1a7b87"
+    }
+  }
+}
diff --git a/LICENSE b/LICENSE
index 5a9a6f8d3..ba8a219fe 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,30 +1,29 @@
 Copyright (C) 2008, 2009 Michael Trier and contributors
 All rights reserved.
 
-Redistribution and use in source and binary forms, with or without 
-modification, are permitted provided that the following conditions 
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
 are met:
 
-* Redistributions of source code must retain the above copyright 
+* Redistributions of source code must retain the above copyright
 notice, this list of conditions and the following disclaimer.
 
-* Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
 documentation and/or other materials provided with the distribution.
 
-* Neither the name of the GitPython project nor the names of 
-its contributors may be used to endorse or promote products derived 
+* Neither the name of the GitPython project nor the names of
+its contributors may be used to endorse or promote products derived
 from this software without specific prior written permission.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
-TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/MANIFEST.in b/MANIFEST.in
index 95b2e883f..eac2a1514 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,10 +1,14 @@
-include VERSION
-include LICENSE
-include CHANGES
 include AUTHORS
-include README
+include CHANGES
+include CONTRIBUTING.md
+include LICENSE
+include README.md
+include VERSION
 include requirements.txt
+include test-requirements.txt
+include git/py.typed
 
-graft git/test/fixtures
-graft git/test/performance
+recursive-include doc *
+recursive-exclude test *
 
+global-exclude __pycache__ *.pyc
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..d4f9acf87
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,16 @@
+.PHONY: all clean release force_release
+
+all:
+	@awk -F: '/^[[:alpha:]].*:/ && !/^all:/ {print $$1}' Makefile
+
+clean:
+	rm -rf build/ dist/ .eggs/ .tox/
+
+release: clean
+	./check-version.sh
+	make force_release
+
+force_release: clean
+	./build-release.sh
+	twine upload dist/*
+	git push --tags origin main
diff --git a/README.md b/README.md
index 57e9bbc9e..59c6f995b 100644
--- a/README.md
+++ b/README.md
@@ -1,93 +1,247 @@
+![Python package](https://github.com/gitpython-developers/GitPython/workflows/Python%20package/badge.svg)
+[![Documentation Status](https://readthedocs.org/projects/gitpython/badge/?version=stable)](https://readthedocs.org/projects/gitpython/?badge=stable)
+[![Packaging status](https://repology.org/badge/tiny-repos/python:gitpython.svg)](https://repology.org/metapackage/python:gitpython/versions)
+
+## [Gitoxide](https://github.com/Byron/gitoxide): A peek into the future…
+
+I started working on GitPython in 2009, back in the days when Python was 'my thing' and I had great plans with it.
+Of course, back in the days, I didn't really know what I was doing and this shows in many places. Somewhat similar to
+Python this happens to be 'good enough', but at the same time is deeply flawed and broken beyond repair.
+
+By now, GitPython is widely used and I am sure there is a good reason for that, it's something to be proud of and happy about.
+The community is maintaining the software and is keeping it relevant for which I am absolutely grateful. For the time to come I am happy to continue maintaining GitPython, remaining hopeful that one day it won't be needed anymore.
+
+More than 15 years after my first meeting with 'git' I am still in excited about it, and am happy to finally have the tools and
+probably the skills to scratch that itch of mine: implement `git` in a way that makes tool creation a piece of cake for most.
+
+If you like the idea and want to learn more, please head over to [gitoxide](https://github.com/Byron/gitoxide), an
+implementation of 'git' in [Rust](https://www.rust-lang.org).
+
+*(Please note that `gitoxide` is not currently available for use in Python, and that Rust is required.)*
+
 ## GitPython
 
-GitPython is a python library used to interact with git repositories, high-level like git-porcelain, or low-level like git-plumbing.
+GitPython is a python library used to interact with git repositories, high-level like git-porcelain,
+or low-level like git-plumbing.
+
+It provides abstractions of git objects for easy access of repository data often backed by calling the `git`
+command-line program.
+
+### DEVELOPMENT STATUS
+
+This project is in **maintenance mode**, which means that
 
-It provides abstractions of git objects for easy access of repository data, and additionally allows you to access the git repository more directly using either a pure python implementation, or the faster, but more resource intensive git command implementation.
+- …there will be no feature development, unless these are contributed
+- …there will be no bug fixes, unless they are relevant to the safety of users, or contributed
+- …issues will be responded to with waiting times of up to a month
 
-The object database implementation is optimized for handling large quantities of objects and large datasets, which is achieved by using low-level structures and data streaming.
+The project is open to contributions of all kinds, as well as new maintainers.
 
 ### REQUIREMENTS
 
-* Git ( tested with 1.8.3.4 )
-* Python Nose - used for running the tests
-    -  Tested with nose 1.3.0
-* Mock by Michael Foord used for tests
-    - Tested with 1.0.1
-* Coverage - used for tests coverage
+GitPython needs the `git` executable to be installed on the system and available in your
+`PATH` for most operations. If it is not in your `PATH`, you can help GitPython find it
+by setting the `GIT_PYTHON_GIT_EXECUTABLE=<path/to/git>` environment variable.
 
-The list of dependencies are listed in /requirements.txt and /test-requirements.txt. The installer takes care of installing them for you though.
+- Git (1.7.x or newer)
+- Python >= 3.7
+
+The list of dependencies are listed in `./requirements.txt` and `./test-requirements.txt`.
+The installer takes care of installing them for you.
 
 ### INSTALL
 
-[![Latest Version](https://pypip.in/version/GitPython/badge.svg)](https://pypi.python.org/pypi/GitPython/)
-[![Supported Python Versions](https://pypip.in/py_versions/GitPython/badge.svg)](https://pypi.python.org/pypi/GitPython/)
+GitPython and its required package dependencies can be installed in any of the following ways, all of which should typically be done in a [virtual environment](https://docs.python.org/3/tutorial/venv.html).
+
+#### From PyPI
+
+To obtain and install a copy [from PyPI](https://pypi.org/project/GitPython/), run:
+
+```sh
+pip install GitPython
+```
+
+(A distribution package can also be downloaded for manual installation at [the PyPI page](https://pypi.org/project/GitPython/).)
+
+#### From downloaded source code
+
+If you have downloaded the source code, run this from inside the unpacked `GitPython` directory:
+
+```sh
+pip install .
+```
+
+#### By cloning the source code repository
+
+To clone the [the GitHub repository](https://github.com/gitpython-developers/GitPython) from source to work on the code, you can do it like so:
+
+```sh
+git clone https://github.com/gitpython-developers/GitPython
+cd GitPython
+./init-tests-after-clone.sh
+```
+
+On Windows, `./init-tests-after-clone.sh` can be run in a Git Bash shell.
 
-If you have downloaded the source code:
+If you are cloning [your own fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks), then replace the above `git clone` command with one that gives the URL of your fork. Or use this [`gh`](https://cli.github.com/) command (assuming you have `gh` and your fork is called `GitPython`):
 
-    python setup.py install
+```sh
+gh repo clone GitPython
+```
 
-or if you want to obtain a copy from the Pypi repository:
+Having cloned the repo, create and activate your [virtual environment](https://docs.python.org/3/tutorial/venv.html).
 
-    pip install gitpython
+Then make an [editable install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs):
 
-Both commands will install the required package dependencies.
+```sh
+pip install -e ".[test]"
+```
 
-A distribution package can be obtained for manual installation at:
+In the less common case that you do not want to install test dependencies, `pip install -e .` can be used instead.
 
-    http://pypi.python.org/pypi/GitPython
+#### With editable *dependencies* (not preferred, and rarely needed)
+
+In rare cases, you may want to work on GitPython and one or both of its [gitdb](https://github.com/gitpython-developers/gitdb) and [smmap](https://github.com/gitpython-developers/smmap) dependencies at the same time, with changes in your local working copy of gitdb or smmap immediately reflected in the behavior of your local working copy of GitPython. This can be done by making editable installations of those dependencies in the same virtual environment where you install GitPython.
+
+If you want to do that *and* you want the versions in GitPython's git submodules to be used, then pass `-e git/ext/gitdb` and/or `-e git/ext/gitdb/gitdb/ext/smmap` to `pip install`. This can be done in any order, and in separate `pip install` commands or the same one, so long as `-e` appears before *each* path. For example, you can install GitPython, gitdb, and smmap editably in the currently active virtual environment this way:
+
+```sh
+pip install -e ".[test]" -e git/ext/gitdb -e git/ext/gitdb/gitdb/ext/smmap
+```
+
+The submodules must have been cloned for that to work, but that will already be the case if you have run `./init-tests-after-clone.sh`. You can use `pip list` to check which packages are installed editably and which are installed normally.
+
+To reiterate, this approach should only rarely be used. For most development it is preferable to allow the gitdb and smmap dependencices to be retrieved automatically from PyPI in their latest stable packaged versions.
+
+### Limitations
+
+#### Leakage of System Resources
+
+GitPython is not suited for long-running processes (like daemons) as it tends to
+leak system resources. It was written in a time where destructors (as implemented
+in the `__del__` method) still ran deterministically.
+
+In case you still want to use it in such a context, you will want to search the
+codebase for `__del__` implementations and call these yourself when you see fit.
+
+Another way assure proper cleanup of resources is to factor out GitPython into a
+separate process which can be dropped periodically.
+
+#### Windows support
+
+See [Issue #525](https://github.com/gitpython-developers/GitPython/issues/525).
 
 ### RUNNING TESTS
 
-The easiest way to run test is by using [tox](https://pypi.python.org/pypi/tox) a wrapper around virtualenv. It will take care of setting up environnements with the proper dependencies installed and execute test commands. To install it simply:
+_Important_: Right after cloning this repository, please be sure to have executed
+the `./init-tests-after-clone.sh` script in the repository root. Otherwise
+you will encounter test failures.
 
-    pip install tox
+#### Install test dependencies
 
-Then run:
+Ensure testing libraries are installed. This is taken care of already if you installed with:
 
-    tox
+```sh
+pip install -e ".[test]"
+```
 
-### SOURCE
+If you had installed with a command like `pip install -e .` instead, you can still run
+the above command to add the testing dependencies.
 
-GitPython's git repo is available on GitHub, which can be browsed at [github](https://github.com/gitpython-developers/GitPython) and cloned like that:
+#### Test commands
 
-    git clone git://github.com/gitpython-developers/GitPython.git git-python
+To test, run:
 
-### Live Coding
+```sh
+pytest
+```
 
-You can watch me fix issues or implement new features [live on Twitch][twitch-channel], or have a look at [past recordings on youtube][youtube-playlist]
+To lint, and apply some linting fixes as well as automatic code formatting, run:
 
-* [Live on Twitch][twitch-channel] (just follow the channel to be notified when a session starts)
-* [Archive on Youtube][youtube-playlist]
+```sh
+pre-commit run --all-files
+```
 
-### INFRASTRUCTURE
+This includes the linting and autoformatting done by Ruff, as well as some other checks.
 
-* [User Documentation](http://gitpython.readthedocs.org)
-* [Mailing List](http://groups.google.com/group/git-python)
-* [Issue Tracker](https://github.com/gitpython-developers/GitPython/issues)
+To typecheck, run:
 
-### LICENSE
+```sh
+mypy
+```
 
-New BSD License.  See the LICENSE file.
+#### CI (and tox)
 
-### DEVELOPMENT STATUS
+Style and formatting checks, and running tests on all the different supported Python versions, will be performed:
 
-[![Build Status](https://travis-ci.org/gitpython-developers/GitPython.svg?branch=0.3)](https://travis-ci.org/gitpython-developers/GitPython)
-[![Coverage Status](https://coveralls.io/repos/gitpython-developers/GitPython/badge.png?branch=master)](https://coveralls.io/r/gitpython-developers/GitPython?branch=master)
-[![Documentation Status](https://readthedocs.org/projects/gitpython/badge/?version=stable)](https://readthedocs.org/projects/gitpython/?badge=stable)
+- Upon submitting a pull request.
+- On each push, *if* you have a fork with GitHub Actions enabled.
+- Locally, if you run [`tox`](https://tox.wiki/) (this skips any Python versions you don't have installed).
+
+#### Configuration files
+
+Specific tools are all configured in the `./pyproject.toml` file:
 
-Now that there seems to be a massive user base, this should be motivation enough to let git-python return to a proper state, which means
+- `pytest` (test runner)
+- `coverage.py` (code coverage)
+- `ruff` (linter and formatter)
+- `mypy` (type checker)
 
-* no open pull requests
-* no open issues describing bugs
+Orchestration tools:
 
-#### FUTURE GOALS
+- Configuration for `pre-commit` is in the `./.pre-commit-config.yaml` file.
+- Configuration for `tox` is in `./tox.ini`.
+- Configuration for GitHub Actions (CI) is in files inside `./.github/workflows/`.
 
-There has been a lot of work in the master branch, which is the direction I want git-python to go. Namely, it should be able to freely mix and match the back-end used, depending on your requirements and environment.
+### Contributions
+
+Please have a look at the [contributions file][contributing].
+
+### INFRASTRUCTURE
+
+- [User Documentation](http://gitpython.readthedocs.org)
+- [Questions and Answers](http://stackexchange.com/filters/167317/gitpython)
+- Please post on Stack Overflow and use the `gitpython` tag
+- [Issue Tracker](https://github.com/gitpython-developers/GitPython/issues)
+  - Post reproducible bugs and feature requests as a new issue.
+    Please be sure to provide the following information if posting bugs:
+    - GitPython version (e.g. `import git; git.__version__`)
+    - Python version (e.g. `python --version`)
+    - The encountered stack-trace, if applicable
+    - Enough information to allow reproducing the issue
+
+### How to make a new release
+
+1. Update/verify the **version** in the `VERSION` file.
+2. Update/verify that the `doc/source/changes.rst` changelog file was updated. It should include a link to the forthcoming release page: `https://github.com/gitpython-developers/GitPython/releases/tag/<version>`
+3. Commit everything.
+4. Run `git tag -s <version>` to tag the version in Git.
+5. _Optionally_ create and activate a [virtual environment](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment). (Then the next step can install `build` and `twine`.)
+6. Run `make release`.
+7. Go to [GitHub Releases](https://github.com/gitpython-developers/GitPython/releases) and publish a new one with the recently pushed tag. Generate the changelog.
+
+### Projects using GitPython
+
+- [PyDriller](https://github.com/ishepard/pydriller)
+- [Kivy Designer](https://github.com/kivy/kivy-designer)
+- [Prowl](https://github.com/nettitude/Prowl)
+- [Python Taint](https://github.com/python-security/pyt)
+- [Buster](https://github.com/axitkhurana/buster)
+- [git-ftp](https://github.com/ezyang/git-ftp)
+- [Git-Pandas](https://github.com/wdm0006/git-pandas)
+- [PyGitUp](https://github.com/msiemens/PyGitUp)
+- [PyJFuzz](https://github.com/mseclab/PyJFuzz)
+- [Loki](https://github.com/Neo23x0/Loki)
+- [Omniwallet](https://github.com/OmniLayer/omniwallet)
+- [GitViper](https://github.com/BeayemX/GitViper)
+- [Git Gud](https://github.com/bthayer2365/git-gud)
+
+### LICENSE
 
-* make new master work similarly to 0.3, but with the option to swap for at least one additional backend
-* make a 1.0 release
-* add backends as required
+[3-Clause BSD License](https://opensource.org/license/bsd-3-clause/), also known as the New BSD License. See the [LICENSE file][license].
 
+One file exclusively used for fuzz testing is subject to [a separate license, detailed here](./fuzzing/README.md#license).
+This file is not included in the wheel or sdist packages published by the maintainers of GitPython.
 
-[twitch-channel]: http://www.twitch.tv/byronimo/profile
-[youtube-playlist]: https://www.youtube.com/playlist?list=PLMHbQxe1e9MnoEcLhn6Yhv5KAvpWkJbL0
\ No newline at end of file
+[contributing]: https://github.com/gitpython-developers/GitPython/blob/main/CONTRIBUTING.md
+[license]: https://github.com/gitpython-developers/GitPython/blob/main/LICENSE
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 000000000..0aea34845
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,16 @@
+# Security Policy
+
+## Supported Versions
+
+Only the latest version of GitPython can receive security updates. If a vulnerability is discovered, a fix can be issued in a new release.
+
+| Version | Supported          |
+| ------- | ------------------ |
+| 3.x.x   | :white_check_mark: |
+| < 3.0   | :x:                |
+
+## Reporting a Vulnerability
+
+Please report private portions of a vulnerability to <https://github.com/gitpython-developers/GitPython/security/advisories/new>. Doing so helps to receive updates and collaborate on the matter, without disclosing it publicly right away.
+
+Vulnerabilities in GitPython's dependencies [gitdb](https://github.com/gitpython-developers/gitdb/blob/master/SECURITY.md) or [smmap](https://github.com/gitpython-developers/smmap/blob/master/SECURITY.md), which primarily exist to support GitPython, can be reported here as well, at that same link. The affected package (`GitPython`, `gitdb`, or `smmap`) can be included in the report, if known.
diff --git a/TODO b/TODO
deleted file mode 100644
index 2643676ce..000000000
--- a/TODO
+++ /dev/null
@@ -1,7 +0,0 @@
-For a list of tickets, please visit 
-http://byronimo.lighthouseapp.com/projects/51787-gitpython/overview
-
-
-  
-
-  
diff --git a/VERSION b/VERSION
index c2c0004f0..3c91929a4 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.3.5
+3.1.45
diff --git a/build-release.sh b/build-release.sh
new file mode 100755
index 000000000..1a8dce2c2
--- /dev/null
+++ b/build-release.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# This file is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+#
+# This script builds a release. If run in a venv, it auto-installs its tools.
+# You may want to run "make release" instead of running this script directly.
+
+set -eEu
+
+function release_with() {
+    "$1" -m build --sdist --wheel
+}
+
+function suggest_venv() {
+    local venv_cmd='python -m venv env && source env/bin/activate'
+    printf "HELP: To avoid this error, use a virtual-env with '%s' instead.\n" "$venv_cmd"
+}
+
+if test -n "${VIRTUAL_ENV-}"; then
+    deps=(build twine)  # Install twine along with build, as we need it later.
+    echo "Virtual environment detected. Adding packages: ${deps[*]}"
+    pip install --quiet --upgrade "${deps[@]}"
+    echo 'Starting the build.'
+    release_with python
+else
+    trap suggest_venv ERR  # This keeps the original exit (error) code.
+    echo 'Starting the build.'
+    release_with python3  # Outside a venv, use python3.
+fi
diff --git a/check-version.sh b/check-version.sh
new file mode 100755
index 000000000..579cf789f
--- /dev/null
+++ b/check-version.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+# This file is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+#
+# This script checks if we are in a consistent state to build a new release.
+# See the release instructions in README.md for the steps to make this pass.
+# You may want to run "make release" instead of running this script directly.
+
+set -eEfuo pipefail
+trap 'echo "$0: Check failed. Stopping." >&2' ERR
+
+readonly version_path='VERSION'
+readonly changes_path='doc/source/changes.rst'
+
+function check_status() {
+    git status -s "$@"
+    test -z "$(git status -s "$@")"
+}
+
+function get_latest_tag() {
+    local config_opts
+    printf -v config_opts ' -c versionsort.suffix=-%s' alpha beta pre rc RC
+    # shellcheck disable=SC2086  # Deliberately word-splitting the arguments.
+    git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1
+}
+
+echo 'Checking current directory.'
+test "$(cd -- "$(dirname -- "$0")" && pwd)" = "$(pwd)"  # Ugly, but portable.
+
+echo "Checking that $version_path and $changes_path exist and have no uncommitted changes."
+test -f "$version_path"
+test -f "$changes_path"
+check_status -- "$version_path" "$changes_path"
+
+# This section can be commented out, if absolutely necessary.
+echo 'Checking that ALL changes are committed.'
+check_status --ignore-submodules
+
+version_version="$(<"$version_path")"
+changes_version="$(awk '/^[0-9]/ {print $0; exit}' "$changes_path")"
+latest_tag="$(get_latest_tag)"
+head_sha="$(git rev-parse HEAD)"
+latest_tag_sha="$(git rev-parse "${latest_tag}^{commit}")"
+
+# Display a table of all the current version, tag, and HEAD commit information.
+echo
+echo 'The VERSION must be the same in all locations, and so must the HEAD and tag SHA'
+printf '%-14s = %s\n' 'VERSION file'   "$version_version" \
+                      'changes.rst'    "$changes_version" \
+                      'Latest tag'     "$latest_tag" \
+                      'HEAD SHA'       "$head_sha" \
+                      'Latest tag SHA' "$latest_tag_sha"
+
+# Check that the latest tag and current version match the HEAD we're releasing.
+test "$version_version" = "$changes_version"
+test "$latest_tag" = "$version_version"
+test "$head_sha" = "$latest_tag_sha"
+echo 'OK, everything looks good.'
diff --git a/doc/Makefile b/doc/Makefile
index 39fe377f9..7e0d325fe 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -2,6 +2,7 @@
 #
 
 # You can set these variables from the command line.
+BUILDDIR      = build
 SPHINXOPTS    =
 SPHINXBUILD   = sphinx-build
 PAPER         =
@@ -9,7 +10,7 @@ PAPER         =
 # Internal variables.
 PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
 
 .PHONY: help clean html web pickle htmlhelp latex changes linkcheck
 
@@ -24,52 +25,52 @@ help:
 	@echo "  linkcheck to check all external links for integrity"
 
 clean:
-	-rm -rf build/*
+	-rm -rf $(BUILDDIR)/*
 
 html:
-	mkdir -p build/html build/doctrees
-	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
+	mkdir -p $(BUILDDIR)/html $(BUILDDIR)/doctrees
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
 	@echo
-	@echo "Build finished. The HTML pages are in build/html."
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
 
 pickle:
-	mkdir -p build/pickle build/doctrees
-	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
+	mkdir -p $(BUILDDIR)/pickle $(BUILDDIR)/doctrees
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
 	@echo
 	@echo "Build finished; now you can process the pickle files."
 
 web: pickle
 
 json:
-	mkdir -p build/json build/doctrees
-	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json
+	mkdir -p $(BUILDDIR)/json $(BUILDDIR)/doctrees
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
 	@echo
 	@echo "Build finished; now you can process the JSON files."
 
 htmlhelp:
-	mkdir -p build/htmlhelp build/doctrees
-	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
+	mkdir -p $(BUILDDIR)/htmlhelp $(BUILDDIR)/doctrees
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
 	@echo
 	@echo "Build finished; now you can run HTML Help Workshop with the" \
-	      ".hhp project file in build/htmlhelp."
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
 
 latex:
-	mkdir -p build/latex build/doctrees
-	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
+	mkdir -p $(BUILDDIR)/latex $(BUILDDIR)/doctrees
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
 	@echo
-	@echo "Build finished; the LaTeX files are in build/latex."
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
 	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
 	      "run these through (pdf)latex."
 
 changes:
-	mkdir -p build/changes build/doctrees
-	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
+	mkdir -p $(BUILDDIR)/changes $(BUILDDIR)/doctrees
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
 	@echo
-	@echo "The overview file is in build/changes."
+	@echo "The overview file is in $(BUILDDIR)/changes."
 
 linkcheck:
-	mkdir -p build/linkcheck build/doctrees
-	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
+	mkdir -p $(BUILDDIR)/linkcheck $(BUILDDIR)/doctrees
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
 	@echo
 	@echo "Link check complete; look for any errors in the above output " \
-	      "or in build/linkcheck/output.txt."
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
diff --git a/doc/requirements.txt b/doc/requirements.txt
new file mode 100644
index 000000000..81140d898
--- /dev/null
+++ b/doc/requirements.txt
@@ -0,0 +1,3 @@
+sphinx >= 7.1.2, < 7.2
+sphinx_rtd_theme
+sphinx-autodoc-typehints
diff --git a/doc/source/changes.rst b/doc/source/changes.rst
index d81f90a6b..151059ed2 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -2,11 +2,757 @@
 Changelog
 =========
 
+3.1.45
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/GitPython/releases/tag/3.1.45
+
+3.1.44
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/GitPython/releases/tag/3.1.44
+
+3.1.43
+======
+
+A major visible change will be the added deprecation- or user-warnings,
+and greatly improved typing.
+
+See the following for all changes.
+https://github.com/gitpython-developers/GitPython/releases/tag/3.1.43
+
+3.1.42
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/GitPython/releases/tag/3.1.42
+
+3.1.41
+======
+
+This release is relevant for security as it fixes a possible arbitrary
+code execution on Windows.
+
+See this PR for details: https://github.com/gitpython-developers/GitPython/pull/1792
+An advisory is available soon at: https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-2mqj-m65w-jghx
+
+See the following for all changes.
+https://github.com/gitpython-developers/GitPython/releases/tag/3.1.41
+
+3.1.40
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/GitPython/releases/tag/3.1.40
+
+3.1.38
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/GitPython/releases/tag/3.1.38
+
+3.1.37
+======
+
+This release contains another security fix that further improves validation of symbolic references
+and thus properly fixes this CVE: https://github.com/advisories/GHSA-cwvm-v4w8-q58c .
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/67?closed=1
+
+3.1.36
+======
+
+Note that this release should be a no-op, it's mainly for testing the changed release-process.
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/66?closed=1
+
+3.1.35
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/65?closed=1
+
+3.1.34
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/64?closed=1
+
+3.1.33
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/63?closed=1
+
+3.1.32
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/62?closed=1
+
+3.1.31
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/61?closed=1
+
+3.1.30
+======
+
+- Make injections of command-invocations harder or impossible for clone and others.
+  See https://github.com/gitpython-developers/GitPython/pull/1518 for details.
+  Note that this might constitute a breaking change for some users, and if so please
+  let us know and we add an opt-out to this.
+- Prohibit insecure options and protocols by default, which is potentially a breaking change,
+  but a necessary fix for https://github.com/gitpython-developers/GitPython/issues/1515.
+  Please take a look at the PR for more information and how to bypass these protections
+  in case they cause breakage: https://github.com/gitpython-developers/GitPython/pull/1521.
+  
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/60?closed=1
+
+
+3.1.29
+======
+
+- Make the git.__version__ re-appear.
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/59?closed=1
+
+3.1.28
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/58?closed=1
+
+3.1.27
+======
+
+- Reduced startup time due to optimized imports.
+- Fix a vulenerability that could cause great slowdowns when encountering long remote path names
+  when pulling/fetching.
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/57?closed=1
+
+3.1.26
+======
+
+- Fixes a leaked file descriptor when reading the index, which would cause make writing a previously
+  read index on windows impossible.
+  See https://github.com/gitpython-developers/GitPython/issues/1395 for details.
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/56?closed=1
+
+
+3.1.25
+======
+
+See the following for all changes.
+https://github.com/gitpython-developers/gitpython/milestone/55?closed=1
+
+
+3.1.24
+======
+
+* Newly added timeout flag is not be enabled by default, and was renamed to kill_after_timeout
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/54?closed=1
+https://github.com/gitpython-developers/gitpython/milestone/53?closed=1
+
+3.1.23 (YANKED)
+===============
+
+* This is the second typed release with a lot of improvements under the hood.
+
+* General:
+
+  - Remove python 3.6 support
+  
+  - Remove distutils ahead of deprecation in standard library.
+  
+  - Update sphinx to 4.1.12 and use autodoc-typehints.
+  
+  - Include README as long_description on PyPI
+  
+  - Test against earliest and latest minor version available on Github Actions (e.g. 3.9.0 and 3.9.7)
+  
+
+* Typing:
+
+  - Add types to ALL functions.
+  
+  - Ensure py.typed is collected.
+  
+  - Increase mypy strictness with disallow_untyped_defs, warn_redundant_casts, warn_unreachable.
+  
+  - Use typing.NamedTuple and typing.OrderedDict now 3.6 dropped.
+  
+  - Make Protocol classes ABCs at runtime due to new behaviour/bug in 3.9.7 & 3.10.0-rc1
+  
+  - Remove use of typing.TypeGuard until later release, to allow dependent libs time to update.
+  
+  - Tracking issue: https://github.com/gitpython-developers/GitPython/issues/1095
+
+* Runtime improvements:
+
+  - Add clone_multi_options support to submodule.add()
+  
+  - Delay calling get_user_id() unless essential, to support sand-boxed environments.
+  
+  - Add timeout to handle_process_output(), in case thread.join() hangs.
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/53?closed=1
+
+
+3.1.20 (YANKED)
+===============
+
+* This is the second typed release with a lot of improvements under the hood.
+  * Tracking issue: https://github.com/gitpython-developers/GitPython/issues/1095
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/52?closed=1
+
+
+3.1.19 (YANKED)
+===============
+
+* This is the second typed release with a lot of improvements under the hood.
+  * Tracking issue: https://github.com/gitpython-developers/GitPython/issues/1095
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/51?closed=1
+
+3.1.18
+======
+
+* drop support for python 3.5 to reduce maintenance burden on typing. Lower patch levels of python 3.5 would break, too.
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/50?closed=1
+
+3.1.17
+======
+
+* Fix issues from 3.1.16 (see https://github.com/gitpython-developers/GitPython/issues/1238)
+* Fix issues from 3.1.15 (see https://github.com/gitpython-developers/GitPython/issues/1223)
+* Add more static typing information
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/49?closed=1
+
+3.1.16 (YANKED)
+===============
+
+* Fix issues from 3.1.15 (see https://github.com/gitpython-developers/GitPython/issues/1223)
+* Add more static typing information
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/48?closed=1
+
+3.1.15 (YANKED)
+===============
+
+* add deprecation warning for python 3.5
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/47?closed=1
+
+3.1.14
+======
+
+* git.Commit objects now have a ``replace`` method that will return a
+  copy of the commit with modified attributes.
+* Add python 3.9 support
+* Drop python 3.4 support
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/46?closed=1
+
+3.1.13
+======
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/45?closed=1
+
+3.1.12
+======
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/44?closed=1
+
+3.1.11
+======
+
+Fixes regression of 3.1.10.
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/43?closed=1
+
+3.1.10
+======
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/42?closed=1
+
+
+3.1.9
+=====
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/41?closed=1
+
+
+3.1.8
+=====
+
+* support for 'includeIf' in git configuration files
+* tests are now excluded from the package, making it conisderably smaller
+
+
+See the following for more details:
+https://github.com/gitpython-developers/gitpython/milestone/40?closed=1
+
+
+3.1.7
+=====
+
+* Fix tutorial examples, which disappeared in 3.1.6 due to a missed path change.
+
+3.1.6
+=====
+
+* Greatly reduced package size, see https://github.com/gitpython-developers/GitPython/pull/1031
+
+3.1.5
+=====
+
+* rollback: package size was reduced significantly not placing tests into the package anymore.
+  See https://github.com/gitpython-developers/GitPython/issues/1030
+
+3.1.4
+=====
+
+* all exceptions now keep track of their cause
+* package size was reduced significantly not placing tests into the package anymore.
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/39?closed=1
+
+3.1.3
+=====
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/38?closed=1
+
+3.1.2
+=====
+
+* Re-release of 3.1.1, with known signature
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/37?closed=1
+
+
+3.1.1
+=====
+
+* support for PyOxidizer, which previously failed due to usage of `__file__`.
+
+See the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/36?closed=1
+
+
+3.1.0
+=====
+
+* Switched back to using gitdb package as requirement
+  (`gitdb#59 <https://github.com/gitpython-developers/gitdb/issues/59>`_)
+
+3.0.9
+=====
+
+* Restricted GitDB (gitdb2) version requirement to < 4
+* Removed old nose library from test requirements
+
+Bugfixes
+--------
+
+* Changed to use UTF-8 instead of default encoding when getting information about a symbolic reference
+  (`#774 <https://github.com/gitpython-developers/GitPython/issues/774>`_)
+* Fixed decoding of tag object message so as to replace invalid bytes
+  (`#943 <https://github.com/gitpython-developers/GitPython/issues/943>`_)
+
+3.0.8
+=====
+
+* Added support for Python 3.8
+* Bumped GitDB (gitdb2) version requirement to > 3
+
+Bugfixes
+--------
+
+* Fixed Repo.__repr__ when subclassed
+  (`#968 <https://github.com/gitpython-developers/GitPython/pull/968>`_)
+* Removed compatibility shims for Python < 3.4 and old mock library
+* Replaced usage of deprecated unittest aliases and Logger.warn
+* Removed old, no longer used assert methods
+* Replaced usage of nose assert methods with unittest
+
+3.0.7
+=====
+
+Properly signed re-release of v3.0.6 with new signature
+(See `#980 <https://github.com/gitpython-developers/GitPython/issues/980>`_)
+
+3.0.6
+=====
+
+| Note: There was an issue that caused this version to be released to PyPI without a signature
+| See the changelog for v3.0.7 and `#980 <https://github.com/gitpython-developers/GitPython/issues/980>`_
+
+Bugfixes
+--------
+
+* Fixed warning for usage of environment variables for paths containing ``$`` or ``%``
+  (`#832 <https://github.com/gitpython-developers/GitPython/issues/832>`_,
+  `#961 <https://github.com/gitpython-developers/GitPython/pull/961>`_)
+* Added support for parsing Git internal date format (@<unix timestamp> <timezone offset>)
+  (`#965 <https://github.com/gitpython-developers/GitPython/pull/965>`_)
+* Removed Python 2 and < 3.3 compatibility shims
+  (`#979 <https://github.com/gitpython-developers/GitPython/pull/979>`_)
+* Fixed GitDB (gitdb2) requirement version specifier formatting in requirements.txt
+  (`#979 <https://github.com/gitpython-developers/GitPython/pull/979>`_)
+
+3.0.5 - Bugfixes
+=============================================
+
+see the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/32?closed=1
+
+3.0.4 - Bugfixes
+=============================================
+
+see the following for details:
+https://github.com/gitpython-developers/gitpython/milestone/31?closed=1
+
+3.0.3 - Bugfixes
+=============================================
+
+see the following for (most) details:
+https://github.com/gitpython-developers/gitpython/milestone/30?closed=1
+
+3.0.2 - Bugfixes
+=============================================
+
+* fixes an issue with installation
+
+3.0.1 - Bugfixes and performance improvements
+=============================================
+
+* Fix a `performance regression <https://github.com/gitpython-developers/GitPython/issues/906>`__ which could make certain workloads 50% slower
+* Add `currently_rebasing_on` method on `Repo`, see `the PR <https://github.com/gitpython-developers/GitPython/pull/903/files#diff-c276fc3c4df38382ec884e59657b869dR1065>`__
+* Fix incorrect `requirements.txt` which could lead to broken installations, see this `issue <https://github.com/gitpython-developers/GitPython/issues/908>`__ for details.
+
+3.0.0 - Remove Python 2 support
+===============================
+
+Motivation for this is a patch which improves unicode handling when dealing with filesystem paths.
+Python 2 compatibility was introduced to deal with differences, and I thought it would be a good idea
+to 'just' drop support right now, mere 5 months away from the official maintenance stop of python 2.7.
+
+The underlying motivation clearly is my anger when thinking python and unicode, which was a hassle from the
+start, at least in a codebase as old as GitPython, which totally doesn't handle encodings correctly in many cases.
+
+Having migrated to using `Rust` exclusively for tooling, I still see that correct handling of encodings isn't entirely
+trivial, but at least `Rust` makes clear what has to be done at compile time, allowing to write software that is pretty
+much guaranteed to work once it compiles.
+
+Again, my apologies if removing Python 2 support caused inconveniences, please see release 2.1.13 which returns it.
+
+see the following for (most) details:
+https://github.com/gitpython-developers/gitpython/milestone/27?closed=1
+
+or run have a look at the difference between tags v2.1.12 and v3.0.0:
+https://github.com/gitpython-developers/GitPython/compare/2.1.12...3.0.0.
+
+2.1.15
+======
+
+* Fixed GitDB (gitdb2) requirement version specifier formatting in requirements.txt
+  (Backported from `#979 <https://github.com/gitpython-developers/GitPython/pull/979>`_)
+* Restricted GitDB (gitdb2) version requirement to < 3
+  (`#897 <https://github.com/gitpython-developers/GitPython/issues/897>`_)
+
+2.1.14
+======
+
+* Fixed handling of 0 when transforming kwargs into Git command arguments
+  (Backported from `#899 <https://github.com/gitpython-developers/GitPython/pull/899>`_)
+
+2.1.13 - Bring back Python 2.7 support
+======================================
+
+My apologies for any inconvenience this may have caused. Following semver, backward incompatible changes
+will be introduced in a minor version.
+
+2.1.12 - Bugfixes and Features
+==============================
+
+* Multi-value support and interface improvements for Git configuration. Thanks to A. Jesse Jiryu Davis.
+
+or run have a look at the difference between tags v2.1.11 and v2.1.12:
+https://github.com/gitpython-developers/GitPython/compare/2.1.11...2.1.12
+
+2.1.11 - Bugfixes
+=================
+
+see the following for (most) details:
+https://github.com/gitpython-developers/gitpython/milestone/26?closed=1
+
+or run have a look at the difference between tags v2.1.10 and v2.1.11:
+https://github.com/gitpython-developers/GitPython/compare/2.1.10...2.1.11
+
+2.1.10 - Bugfixes
+=================
+
+see the following for (most) details:
+https://github.com/gitpython-developers/gitpython/milestone/25?closed=1
+
+or run have a look at the difference between tags v2.1.9 and v2.1.10:
+https://github.com/gitpython-developers/GitPython/compare/2.1.9...2.1.10
+
+2.1.9 - Dropping support for Python 2.6
+=======================================
+
+see the following for (most) details:
+https://github.com/gitpython-developers/gitpython/milestone/24?closed=1
+
+or run have a look at the difference between tags v2.1.8 and v2.1.9:
+https://github.com/gitpython-developers/GitPython/compare/2.1.8...2.1.9
+
+
+2.1.8 - bugfixes
+====================================
+
+see the following for (most) details:
+https://github.com/gitpython-developers/gitpython/milestone/23?closed=1
+
+or run have a look at the difference between tags v2.1.7 and v2.1.8:
+https://github.com/gitpython-developers/GitPython/compare/2.1.7...2.1.8
+
+2.1.6 - bugfixes
+====================================
+
+* support for worktrees
+
+2.1.3 - Bugfixes
+====================================
+
+All issues and PRs can be viewed in all detail when following this URL:
+https://github.com/gitpython-developers/GitPython/milestone/21?closed=1
+
+
+2.1.1 - Bugfixes
+====================================
+
+All issues and PRs can be viewed in all detail when following this URL:
+https://github.com/gitpython-developers/GitPython/issues?q=is%3Aclosed+milestone%3A%22v2.1.1+-+Bugfixes%22
+
+
+2.1.0 - Much better windows support!
+====================================
+
+Special thanks to @ankostis, who made this release possible (nearly) single-handedly.
+GitPython is run by its users, and their PRs make all the difference, they keep
+GitPython relevant. Thank you all so much for contributing !
+
+Notable fixes
+-------------
+
+* The `GIT_DIR` environment variable does not override the `path` argument when
+  initializing a `Repo` object anymore. However, if said `path` unset, `GIT_DIR`
+  will be used to fill the void.
+
+All issues and PRs can be viewed in all detail when following this URL:
+https://github.com/gitpython-developers/GitPython/issues?q=is%3Aclosed+milestone%3A%22v2.1.0+-+proper+windows+support%22
+
+
+2.0.9 - Bugfixes
+=============================
+
+* `tag.commit` will now resolve commits deeply.
+* `Repo` objects can now be pickled, which helps with multi-processing.
+* `Head.checkout()` now deals with detached heads, which is when it will return
+  the `HEAD` reference instead.
+
+* `DiffIndex.iter_change_type(...)` produces better results when diffing
+
+2.0.8 - Features and Bugfixes
+=============================
+
+* `DiffIndex.iter_change_type(...)` produces better results when diffing
+  an index against the working tree.
+* `Repo().is_dirty(...)` now supports the `path` parameter, to specify a single
+  path by which to filter the output. Similar to `git status <path>`
+* Symbolic refs created by this library will now be written with a newline
+  character, which was previously missing.
+* `blame()` now properly preserves multi-line commit messages.
+* No longer corrupt ref-logs by writing multi-line comments into them.
+
+2.0.7 - New Features
+====================
+
+* `IndexFile.commit(...,skip_hooks=False)` added. This parameter emulates the
+   behaviour of `--no-verify` on the command-line.
+
+2.0.6 - Fixes and Features
+==========================
+
+* Fix: remote output parser now correctly matches refs with non-ASCII
+  chars in them
+* API: Diffs now have `a_rawpath`, `b_rawpath`, `raw_rename_from`,
+  `raw_rename_to` properties, which are the raw-bytes equivalents of their
+  unicode path counterparts.
+* Fix: TypeError about passing keyword argument to string decode() on
+  Python 2.6.
+* Feature: `setUrl API on Remotes <https://github.com/gitpython-developers/GitPython/pull/446#issuecomment-224670539>`__
+
+2.0.5 - Fixes
+=============
+
+* Fix: parser of fetch info lines choked on some legitimate lines
+
+2.0.4 - Fixes
+=============
+
+* Fix: parser of commit object data is now robust against cases where
+  commit object contains invalid bytes.  The invalid characters are now
+  replaced rather than choked on.
+* Fix: non-ASCII paths are now properly decoded and returned in
+  ``.diff()`` output
+* Fix: `RemoteProgress` will now strip the ', ' prefix or suffix from messages.
+* API: Remote.[fetch|push|pull](...) methods now allow the ``progress`` argument to
+  be a callable. This saves you from creating a custom type with usually just one
+  implemented method.
+
+2.0.3 - Fixes
+=============
+
+* Fix: bug in ``git-blame --incremental`` output parser that broken when
+  commit messages contained ``\r`` characters
+* Fix: progress handler exceptions are not caught anymore, which would usually just hide bugs
+  previously.
+* Fix: The `Git.execute` method will now redirect `stdout` to `devnull` if `with_stdout` is false,
+  which is the intended behaviour based on the parameter's documentation.
+
+2.0.2 - Fixes
+=============
+
+* Fix: source package does not include \*.pyc files
+* Fix: source package does include doc sources
+
+2.0.1 - Fixes
+=============
+
+* Fix: remote output parser now correctly matches refs with "@" in them
+
+2.0.0 - Features
+================
+
+Please note that due to breaking changes, we have to increase the major version.
+
+* **IMPORTANT**: This release drops support for python 2.6, which is
+  officially deprecated by the python maintainers.
+* **CRITICAL**: `Diff` objects created with patch output will now not carry
+  the --- and +++ header lines anymore.  All diffs now start with the
+  @@ header line directly.  Users that rely on the old behaviour can now
+  (reliably) read this information from the a_path and b_path properties
+  without having to parse these lines manually.
+* `Commit` now has extra properties `authored_datetime` and
+  `committer_datetime` (to get Python datetime instances rather than
+  timestamps)
+* `Commit.diff()` now supports diffing the root commit via
+  `Commit.diff(NULL_TREE)`.
+* `Repo.blame()` now respects `incremental=True`, supporting incremental
+  blames.  Incremental blames are slightly faster since they don't include
+  the file's contents in them.
+* Fix: `Diff` objects created with patch output will now have their
+  `a_path` and `b_path` properties parsed out correctly.  Previously, some
+  values may have been populated incorrectly when a file was added or
+  deleted.
+* Fix: diff parsing issues with paths that contain "unsafe" chars, like
+  spaces, tabs, backslashes, etc.
+
+1.0.2 - Fixes
+=============
+
+* IMPORTANT: Changed default object database of `Repo` objects to `GitCmdObjectDB`. The pure-python implementation
+  used previously usually fails to release its resources (i.e. file handles), which can lead to problems when working
+  with large repositories.
+* CRITICAL: fixed incorrect `Commit` object serialization when authored or commit date had timezones which were not
+  divisiblej by 3600 seconds. This would happen if the timezone was something like `+0530` for instance.
+* A list of all additional fixes can be found `on GitHub <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v1.0.2+-+Fixes%22+is%3Aclosed>`__
+* CRITICAL: `Tree.cache` was removed without replacement. It is technically impossible to change individual trees and expect their serialization results to be consistent with what *git* expects. Instead, use the `IndexFile` facilities to adjust the content of the staging area, and write it out to the respective tree objects using `IndexFile.write_tree()` instead.
+
+1.0.1 - Fixes
+=============
+
+* A list of all issues can be found `on GitHub <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v1.0.1+-+Fixes%22+is%3Aclosed>`__
+
+1.0.0 - Notes
+=============
+
+This version is equivalent to v0.3.7, but finally acknowledges that GitPython is stable and production ready.
+
+It follows the `semantic version scheme <http://semver.org>`_, and thus will not break its existing API unless it goes 2.0.
+
+0.3.7 - Fixes
+=============
+* `IndexFile.add()` will now write the index without any extension data by default. However, you may override this behaviour with the new `write_extension_data` keyword argument.
+
+  - Renamed `ignore_tree_extension_data` keyword argument in `IndexFile.write(...)` to `ignore_extension_data`
+* If the git command executed during `Remote.push(...)|fetch(...)` returns with an non-zero exit code and GitPython didn't
+  obtain any head-information, the corresponding `GitCommandError` will be raised. This may break previous code which expected
+  these operations to never raise. However, that behaviour is undesirable as it would effectively hide the fact that there
+  was an error. See `this issue <https://github.com/gitpython-developers/GitPython/issues/271>`__ for more information.
+
+* If the git executable can't be found in the PATH or at the path provided by `GIT_PYTHON_GIT_EXECUTABLE`, this is made
+  obvious by throwing `GitCommandNotFound`, both on unix and on windows.
+
+  - Those who support **GUI on windows** will now have to set `git.Git.USE_SHELL = True` to get the previous behaviour.
+
+* A list of all issues can be found `on GitHub <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v0.3.7+-+Fixes%22+is%3Aclosed>`__
+
+
 0.3.6 - Features
 ================
-* Added `Repo.merge_base()` implementation. See the `respective issue on github <https://github.com/gitpython-developers/GitPython/issues/169>`_
+* **DOCS**
+
+  * special members like `__init__` are now listed in the API documentation
+  * tutorial section was revised entirely, more advanced examples were added.
+
+* **POSSIBLY BREAKING CHANGES**
+
+  * As `rev_parse` will now throw `BadName` as well as `BadObject`, client code will have to catch both exception types.
+  * Repo.working_tree_dir now returns None if it is bare. Previously it raised AssertionError.
+  * IndexFile.add() previously raised AssertionError when paths where used with bare repository, now it raises InvalidGitRepositoryError
+
+* Added `Repo.merge_base()` implementation. See the `respective issue on GitHub <https://github.com/gitpython-developers/GitPython/issues/169>`__
 * `[include]` sections in git configuration files are now respected
-* A list of all issues can be found here: https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v0.3.6+-+Features%22+
+* Added `GitConfigParser.rename_section()`
+* Added `Submodule.rename()`
+* A list of all issues can be found `on GitHub <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v0.3.6+-+Features%22+>`__
 
 0.3.5 - Bugfixes
 ================
@@ -26,17 +772,17 @@ Changelog
 
 0.3.3
 =====
-* When fetching, pulling or pushing, and an error occours, it will not be reported on stdout anymore. However, if there is a fatal error, it will still result in a GitCommandError to be thrown. This goes hand in hand with improved fetch result parsing.
+* When fetching, pulling or pushing, and an error occurs, it will not be reported on stdout anymore. However, if there is a fatal error, it will still result in a GitCommandError to be thrown. This goes hand in hand with improved fetch result parsing.
 * Code Cleanup (in preparation for python 3 support)
 
   * Applied autopep8 and cleaned up code
-  * Using python logging module instead of print statments to signal certain kinds of errors
+  * Using python logging module instead of print statements to signal certain kinds of errors
 
 0.3.2.1
 =======
 * `Fix for #207 <https://github.com/gitpython-developers/GitPython/issues/207>`_
 
-0.3.2 
+0.3.2
 =====
 
 * Release of most recent version as non-RC build, just to allow pip to install the latest version right away.
@@ -47,13 +793,13 @@ Changelog
 * **git** command wrapper
 
  * Added ``version_info`` property which returns a tuple of integers representing the installed git version.
- 
+
  * Added GIT_PYTHON_GIT_EXECUTABLE environment variable, which can be used to set the desired git executable to be used. despite of what would be found in the path.
- 
+
 * **Blob** Type
 
  * Added mode constants to ease the manual creation of blobs
- 
+
 * **IterableList**
 
  * Added __contains__ and __delitem__ methods
@@ -65,8 +811,8 @@ Changelog
  * Parsing of tags was improved. Previously some parts of the name could not be parsed properly.
  * The rev-parse pure python implementation now handles branches correctly if they look like hexadecimal sha's.
  * GIT_PYTHON_TRACE is now set on class level of the Git type, previously it was a module level global variable.
- * GIT_PYTHON_GIT_EXECUTABLE is a class level variable as well. 
- 
+ * GIT_PYTHON_GIT_EXECUTABLE is a class level variable as well.
+
 
 0.3.1 Beta 2
 ============
@@ -75,7 +821,7 @@ Changelog
  * New types: ``RefLog`` and ``RefLogEntry``
  * Reflog is maintained automatically when creating references and deleting them
  * Non-intrusive changes to ``SymbolicReference``, these don't require your code to change. They allow to append messages to the reflog.
- 
+
      * ``abspath`` property added, similar to ``abspath`` of Object instances
      * ``log()`` method added
      * ``log_append(...)`` method added
@@ -84,19 +830,19 @@ Changelog
      * ``set_object(...)`` method added (reflog support)
 
  * **Intrusive Changes** to ``Head`` type
- 
+
   * ``create(...)`` method now supports the reflog, but will not raise ``GitCommandError`` anymore as it is a pure python implementation now. Instead, it raises ``OSError``.
-  
+
  * **Intrusive Changes** to ``Repo`` type
- 
+
   * ``create_head(...)`` method does not support kwargs anymore, instead it supports a logmsg parameter
-     
+
 * Repo.rev_parse now supports the [ref]@{n} syntax, where *n* is the number of steps to look into the reference's past
 
 * **BugFixes**
 
     * Removed incorrect ORIG_HEAD handling
- 
+
 * **Flattened directory** structure to make development more convenient.
 
  * .. note:: This alters the way projects using git-python as a submodule have to adjust their sys.path to be able to import git-python successfully.
@@ -109,7 +855,7 @@ Changelog
 * Head Type changes
 
  * config_reader() & config_writer() methods added for access to head specific options.
- * tracking_branch() & set_tracking_branch() methods addded for easy configuration of tracking branches.
+ * tracking_branch() & set_tracking_branch() methods added for easy configuration of tracking branches.
 
 
 0.3.0 Beta 2
@@ -125,7 +871,7 @@ Renamed Modules
   * git.utils -> git.util
   * git.errors -> git.exc
   * git.objects.utils -> git.objects.util
-  
+
 General
 -------
 * Object instances, and everything derived from it, now use binary sha's internally. The 'sha' member was removed, in favor of the 'binsha' member. An 'hexsha' property is available for convenient conversions. They may only be initialized using their binary shas, reference names or revision specs are not allowed anymore.
@@ -136,67 +882,67 @@ General
 * IndexFile.get_entries_key was renamed to entry_key
 * IndexFile.write_tree: removed missing_ok keyword, its always True now. Instead of raising GitCommandError it raises UnmergedEntriesError. This is required as the pure-python implementation doesn't support the missing_ok keyword yet.
 * diff.Diff.null_hex_sha renamed to NULL_HEX_SHA, to be conforming with the naming in the Object base class
- 
+
 
 0.2 Beta 2
 ===========
  * Commit objects now carry the 'encoding' information of their message. It wasn't parsed previously, and defaults to UTF-8
- * Commit.create_from_tree now uses a pure-python implementation, mimicing git-commit-tree
+ * Commit.create_from_tree now uses a pure-python implementation, mimicking git-commit-tree
 
 0.2
 =====
 General
 -------
-* file mode in Tree, Blob and Diff objects now is an int compatible to definintiions 
-  in the stat module, allowing you to query whether individual user, group and other 
+* file mode in Tree, Blob and Diff objects now is an int compatible to definitions
+  in the stat module, allowing you to query whether individual user, group and other
   read, write and execute bits are set.
 * Adjusted class hierarchy to generally allow comparison and hash for Objects and Refs
-* Improved Tag object which now is a Ref that may contain a tag object with additional 
+* Improved Tag object which now is a Ref that may contain a tag object with additional
   Information
-* id_abbrev method has been removed as it could not assure the returned short SHA's 
+* id_abbrev method has been removed as it could not assure the returned short SHA's
   where unique
 * removed basename method from Objects with path's as it replicated features of os.path
-* from_string and list_from_string methods are now private and were renamed to 
-  _from_string  and _list_from_string respectively. As part of the private API, they 
+* from_string and list_from_string methods are now private and were renamed to
+  _from_string  and _list_from_string respectively. As part of the private API, they
   may change without prior notice.
 * Renamed all find_all methods to list_items - this method is part of the Iterable interface
   that also provides a more efficients and more responsive iter_items method
-* All dates, like authored_date and committer_date, are stored as seconds since epoc
-  to consume less memory - they can be converted using time.gmtime in a more suitable 
+* All dates, like authored_date and committer_date, are stored as seconds since epoch
+  to consume less memory - they can be converted using time.gmtime in a more suitable
   presentation format if needed.
-* Named method parameters changed on a wide scale to unify their use. Now git specific 
+* Named method parameters changed on a wide scale to unify their use. Now git specific
   terms are used everywhere, such as "Reference" ( ref ) and "Revision" ( rev ).
-  Prevously multiple terms where used making it harder to know which type was allowed
+  Previously multiple terms where used making it harder to know which type was allowed
   or not.
 * Unified diff interface to allow easy diffing between trees, trees and index, trees
   and working tree, index and working tree, trees and index. This closely follows
   the git-diff capabilities.
-* Git.execute does not take the with_raw_output option anymore. It was not used 
+* Git.execute does not take the with_raw_output option anymore. It was not used
   by anyone within the project and False by default.
-  
+
 
 Item Iteration
 --------------
-* Previously one would return and process multiple items as list only which can 
-  hurt performance and memory consumption and reduce response times. 
-  iter_items method provide an iterator that will return items on demand as parsed 
+* Previously one would return and process multiple items as list only which can
+  hurt performance and memory consumption and reduce response times.
+  iter_items method provide an iterator that will return items on demand as parsed
   from a stream. This way any amount of objects can be handled.
 * list_items method returns IterableList allowing to access list members by name
-  
+
 objects Package
 ----------------
-* blob, tree, tag and commit module have been moved to new objects package. This should 
-  not affect you though unless you explicitly imported individual objects. If you just 
+* blob, tree, tag and commit module have been moved to new objects package. This should
+  not affect you though unless you explicitly imported individual objects. If you just
   used the git package, names did not change.
-  
+
 Blob
 ----
 * former 'name' member renamed to path as it suits the actual data better
 
 GitCommand
 -----------
-* git.subcommand call scheme now prunes out None from the argument list, allowing 
-  to be called more confortably as None can never be a valid to the git command 
+* git.subcommand call scheme now prunes out None from the argument list, allowing
+  to be called more comfortably as None can never be a valid to the git command
   if converted to a string.
 * Renamed 'git_dir' attribute to 'working_dir' which is exactly how it is used
 
@@ -210,43 +956,43 @@ Config
 * The git configuration can now be read and manipulated directly from within python
   using the GitConfigParser
 * Repo.config_reader() returns a read-only parser
-* Repo.config_writer() returns a read-write parser 
- 
+* Repo.config_writer() returns a read-write parser
+
 Diff
 ----
 * Members a a_commit and b_commit renamed to a_blob and b_blob - they are populated
   with Blob objects if possible
 * Members a_path and b_path removed as this information is kept in the blobs
-* Diffs are now returned as DiffIndex allowing to more quickly find the kind of 
+* Diffs are now returned as DiffIndex allowing to more quickly find the kind of
   diffs you are interested in
-  
+
 Diffing
 -------
-* Commit and Tree objects now support diffing natively with a common interface to 
-  compare agains other Commits or Trees, against the working tree or against the index.
+* Commit and Tree objects now support diffing natively with a common interface to
+  compare against other Commits or Trees, against the working tree or against the index.
 
 Index
 -----
 * A new Index class allows to read and write index files directly, and to perform
   simple two and three way merges based on an arbitrary index.
-  
-Referernces
+
+References
 ------------
 * References are object that point to a Commit
 * SymbolicReference are a pointer to a Reference Object, which itself points to a specific
   Commit
-* They will dynmically retrieve their object at the time of query to assure the information 
-  is actual. Recently objects would be cached, hence ref object not be safely kept 
+* They will dynamically retrieve their object at the time of query to assure the information
+  is actual. Recently objects would be cached, hence ref object not be safely kept
   persistent.
-  
+
 Repo
 ----
 * Moved blame method from Blob to repo as it appeared to belong there much more.
-* active_branch method now returns a Head object instead of a string with the name 
+* active_branch method now returns a Head object instead of a string with the name
   of the active branch.
-* tree method now requires a Ref instance as input and defaults to the active_branche
+* tree method now requires a Ref instance as input and defaults to the active_branch
   instead of master
-* is_dirty now takes additional arguments allowing fine-grained control about what is 
+* is_dirty now takes additional arguments allowing fine-grained control about what is
   considered dirty
 * Removed the following methods:
 
@@ -258,7 +1004,7 @@ Repo
   - 'create' method which equals the 'init' method's functionality
   - 'diff' - it returned a mere string which still had to be parsed
   - 'commit_diff' - moved to Commit, Tree and Diff types respectively
-  
+
 * Renamed the following methods:
 
   - commits to iter_commits to improve the performance, adjusted signature
@@ -266,7 +1012,7 @@ Repo
   - fork_bare to clone, as it was to represent general clone functionality, but implied
     a bare clone to be more versatile
   - archive_tar_gz and archive_tar and replaced by archive method with different signature
-  
+
 * 'commits' method has no max-count of returned commits anymore, it now behaves  like git-rev-list
 * The following methods and properties were added
 
@@ -277,16 +1023,16 @@ Repo
   - 'config_reader' method
   - 'config_writer' method
   - 'bare' property, previously it was a simple attribute that could be written
-  
+
 * Renamed the following attributes
 
   - 'path' is now 'git_dir'
   - 'wd' is now 'working_dir'
-  
+
 * Added attribute
 
   - 'working_tree_dir' which may be None in case of bare repositories
-  
+
 Remote
 ------
 * Added Remote object allowing easy access to remotes
@@ -296,7 +1042,7 @@ Remote
 Test Framework
 --------------
 * Added support for common TestCase base class that provides additional functionality
-  to receive repositories tests can also write to. This way, more aspects can be 
+  to receive repositories tests can also write to. This way, more aspects can be
   tested under real-world ( un-mocked ) conditions.
 
 Tree
@@ -304,7 +1050,7 @@ Tree
 * former 'name' member renamed to path as it suits the actual data better
 * added traverse method allowing to recursively traverse tree items
 * deleted blob method
-* added blobs and trees properties allowing to query the respective items in the 
+* added blobs and trees properties allowing to query the respective items in the
   tree
 * now mimics behaviour of a read-only list instead of a dict to maintain order.
 * content_from_string method is now private and not part of the public API anymore
@@ -320,9 +1066,9 @@ General
 * Removed ambiguity between paths and treeishs. When calling commands that
   accept treeish and path arguments and there is a path with the same name as
   a treeish git cowardly refuses to pick one and asks for the command to use
-  the unambiguous syntax where '--' seperates the treeish from the paths.
+  the unambiguous syntax where '--' separates the treeish from the paths.
 
-* ``Repo.commits``, ``Repo.commits_between``, ``Reop.commits_since``,
+* ``Repo.commits``, ``Repo.commits_between``, ``Repo.commits_since``,
   ``Repo.commit_count``, ``Repo.commit``, ``Commit.count`` and
   ``Commit.find_all`` all now optionally take a path argument which
   constrains the lookup by path.  This changes the order of the positional
@@ -443,14 +1189,14 @@ Git
 
 * Added support for ``stderr``, ``stdin``, and ``with_status``.
 
-* ``git_dir`` is now optional in the constructor for ``git.Git``.  Git now 
+* ``git_dir`` is now optional in the constructor for ``git.Git``.  Git now
   falls back to ``os.getcwd()`` when git_dir is not specified.
 
-* add a ``with_exceptions`` keyword argument to git commands. 
+* add a ``with_exceptions`` keyword argument to git commands.
   ``GitCommandError`` is raised when the exit status is non-zero.
 
-* add support for a ``GIT_PYTHON_TRACE`` environment variable. 
-  ``GIT_PYTHON_TRACE`` allows us to debug GitPython's usage of git through 
+* add support for a ``GIT_PYTHON_TRACE`` environment variable.
+  ``GIT_PYTHON_TRACE`` allows us to debug GitPython's usage of git through
   the use of an environment variable.
 
 Tree
@@ -466,9 +1212,9 @@ Repo
 
 Tree
 ----
-* Corrected problem with ``Tree.__div__`` not working with zero length files.  
-  Removed ``__len__`` override and replaced with size instead. Also made size 
-  cach properly. This is a breaking change.
+* Corrected problem with ``Tree.__div__`` not working with zero length files.
+  Removed ``__len__`` override and replaced with size instead. Also made size
+  cache properly. This is a breaking change.
 
 0.1.1
 =====
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 942996b0b..809762483 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -1,196 +1,188 @@
-# -*- coding: utf-8 -*-
-#
-# GitPython documentation build configuration file, created by
+# GitPython documentation build configuration file, originally created by
 # sphinx-quickstart on Sat Jan 24 11:51:01 2009.
 #
 # This file is execfile()d with the current directory set to its containing dir.
 #
-# The contents of this file are pickled, so don't put values in the namespace
-# that aren't pickleable (module imports are okay, they're removed automatically).
+# The contents of this file are pickled, so don't put values in the namespace that
+# aren't pickleable (module imports are okay, they're removed automatically).
 #
-# Note that not all possible configuration values are present in this
-# autogenerated file.
+# Note that not all possible configuration values are present in this autogenerated
+# file.
 #
-# All configuration values have a default; values that are commented out
-# serve to show the default.
+# All configuration values have a default; values that are commented out serve to show
+# the default.
 
-import sys, os
+import os
+import sys
 
-# If your extensions are in another directory, add it here. If the directory
-# is relative to the documentation root, use os.path.abspath to make it
-# absolute, like shown here.
-#sys.path.append(os.path.abspath('.'))
-sys.path.insert(0, os.path.abspath('../..'))
+# If your extensions are in another directory, add it here. If the directory is relative
+# to the documentation root, use os.path.abspath to make it absolute, like shown here.
+# sys.path.append(os.path.abspath('.'))
+sys.path.insert(0, os.path.abspath("../.."))
 
 # General configuration
 # ---------------------
 
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest']
+# Add any Sphinx extension module names here, as strings. They can be extensions coming
+# with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ["sphinx.ext.autodoc", "sphinx.ext.doctest"]
 
 # Add any paths that contain templates here, relative to this directory.
-templates_path = ['.templates']
+templates_path = []
 
 # The suffix of source filenames.
-source_suffix = '.rst'
+source_suffix = ".rst"
 
 # The encoding of source files.
-#source_encoding = 'utf-8'
+# source_encoding = 'utf-8'
 
 # The master toctree document.
-master_doc = 'index'
+master_doc = "index"
 
 # General information about the project.
-project = u'GitPython'
-copyright = u'Copyright (C) 2008, 2009 Michael Trier and contributors, 2010 Sebastian Thiel'
+project = "GitPython"
+copyright = "Copyright (C) 2008, 2009 Michael Trier and contributors, 2010-2015 Sebastian Thiel"
 
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
+# The version info for the project you're documenting, acts as replacement for |version|
+# and |release|, also used in various other places throughout the built documents.
 #
 # The short X.Y version.
-VERSION = open(os.path.join(os.path.dirname(__file__),"..", "..", 'VERSION')).readline().strip()
+with open(os.path.join(os.path.dirname(__file__), "..", "..", "VERSION")) as fd:
+    VERSION = fd.readline().strip()
 version = VERSION
 # The full version, including alpha/beta/rc tags.
 release = VERSION
 
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = None
+# The language for content autogenerated by Sphinx. Refer to documentation for a list of
+# supported languages.
+# language = None
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
-#today = ''
+# today = ''
 # Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
+# today_fmt = '%B %d, %Y'
 
 # List of documents that shouldn't be included in the build.
-#unused_docs = []
+# unused_docs = []
 
-# List of directories, relative to source directory, that shouldn't be searched
-# for source files.
-exclude_trees = ['build']
+# List of directories, relative to source directory, that shouldn't be searched for
+# source files.
+exclude_trees = ["build"]
 
 # The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
+# default_role = None
 
 # If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
+# add_function_parentheses = True
 
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
+# If true, the current module name will be prepended to all description unit titles
+# (such as .. function::).
+# add_module_names = True
 
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
+# If true, sectionauthor and moduleauthor directives will be shown in the output.
+# They are ignored by default.
+# show_authors = False
 
 # The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
+pygments_style = "sphinx"
+
+manpages_url = "https://git-scm.com/docs/{page}"
 
 
 # Options for HTML output
 # -----------------------
 
-html_theme_options = {
-    "stickysidebar": "true"
-}
-
-# The style sheet to use for HTML and HTML Help pages. A file of that name
-# must exist either in Sphinx' static/ path, or in one of the custom paths
-# given in html_static_path.
-html_style = 'default.css'
+html_theme = "sphinx_rtd_theme"
+html_theme_options = {}
 
-# The name for this set of Sphinx documents.  If None, it defaults to
-# "<project> v<release> documentation".
-#html_title = None
+# The name for this set of Sphinx documents.
+# If None, it defaults to "<project> v<release> documentation".
+# html_title = None
 
-# A shorter title for the navigation bar.  Default is the same as html_title.
-#html_short_title = None
+# A shorter title for the navigation bar. Default is the same as html_title.
+# html_short_title = None
 
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
+# The name of an image file (relative to this directory) to place at the top of the
+# sidebar.
+# html_logo = None
 
-# The name of an image file (within the static path) to use as favicon of the
-# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
+# The name of an image file (within the static path) to use as favicon of the docs.
+# This file should be a Windows icon file (.ico) being 16x16 or 32x32 pixels large.
+# html_favicon = None
 
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['.static']
+# Add any paths that contain custom static files (such as style sheets) here, relative
+# to this directory. They are copied after the builtin static files, so a file named
+# "default.css" will overwrite the builtin "default.css".
+html_static_path = []
 
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, using the
+# given strftime format.
+# html_last_updated_fmt = '%b %d, %Y'
 
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
+# If true, SmartyPants will be used to convert quotes and dashes to typographically
+# correct entities.
+# html_use_smartypants = True
 
 # Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
+# html_sidebars = {}
 
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
+# Additional templates that should be rendered to pages, maps page names to template
+# names.
+# html_additional_pages = {}
 
 # If false, no module index is generated.
-#html_use_modindex = True
+# html_use_modindex = True
 
 # If false, no index is generated.
-#html_use_index = True
+# html_use_index = True
 
 # If true, the index is split into individual pages for each letter.
-#html_split_index = False
+# html_split_index = False
 
 # If true, the reST sources are included in the HTML build as _sources/<name>.
-#html_copy_source = True
+# html_copy_source = True
 
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it.  The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
+# If true, an OpenSearch description file will be output, and all pages will contain a
+# <link> tag referring to it. The value of this option must be the base URL from which
+# the finished HTML is served.
+# html_use_opensearch = ''
 
 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = ''
+# html_file_suffix = ''
 
 # Output file base name for HTML help builder.
-htmlhelp_basename = 'gitpythondoc'
+htmlhelp_basename = "gitpythondoc"
 
 
 # Options for LaTeX output
 # ------------------------
 
 # The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
+# latex_paper_size = 'letter'
 
 # The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
+# latex_font_size = '10pt'
 
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, document class [howto/manual]).
 latex_documents = [
-  ('index', 'GitPython.tex', ur'GitPython Documentation',
-   ur'Michael Trier', 'manual'),
+    ("index", "GitPython.tex", "GitPython Documentation", "Michael Trier", "manual"),
 ]
 
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
+# The name of an image file (relative to this directory) to place at the top of the
+# title page.
+# latex_logo = None
 
 # For "manual" documents, if this is true, then toplevel headings are parts,
 # not chapters.
-#latex_use_parts = False
+# latex_use_parts = False
 
 # Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
+# latex_preamble = ''
 
 # Documents to append as an appendix to all manuals.
-#latex_appendices = []
+# latex_appendices = []
 
 # If false, no module index is generated.
-#latex_use_modindex = True
+# latex_use_modindex = True
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 1079c5c76..ca5229ac3 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -9,7 +9,7 @@ GitPython Documentation
    :maxdepth: 2
 
    intro
-   whatsnew
+   quickstart
    tutorial
    reference
    roadmap
@@ -21,4 +21,3 @@ Indices and tables
 * :ref:`genindex`
 * :ref:`modindex`
 * :ref:`search`
-
diff --git a/doc/source/intro.rst b/doc/source/intro.rst
index 8dac28047..d053bd117 100644
--- a/doc/source/intro.rst
+++ b/doc/source/intro.rst
@@ -13,43 +13,38 @@ The object database implementation is optimized for handling large quantities of
 Requirements
 ============
 
+* `Python`_ >= 3.7
 * `Git`_ 1.7.0 or newer
     It should also work with older versions, but it may be that some operations
     involving remotes will not work as expected.
 * `GitDB`_ - a pure python git database implementation
+* `typing_extensions`_ >= 3.7.3.4 (if python < 3.10)
 
- * `async`_ - asynchronous task scheduling
- 
-* `Python Nose`_ - used for running the tests
-* `Mock by Michael Foord`_ used for tests. Requires version 0.5
-
-.. _Git: http://git-scm.com/
-.. _Python Nose: http://code.google.com/p/python-nose/
-.. _Mock by Michael Foord: http://www.voidspace.org.uk/python/mock.html
-.. _GitDB: http://pypi.python.org/pypi/gitdb
-.. _async: http://pypi.python.org/pypi/async
+.. _Python: https://www.python.org
+.. _Git: https://git-scm.com/
+.. _GitDB: https://pypi.python.org/pypi/gitdb
+.. _typing_extensions: https://pypi.org/project/typing-extensions/
 
 Installing GitPython
 ====================
 
 Installing GitPython is easily done using
-`setuptools`_. Assuming it is
+`pip`_. Assuming it is
 installed, just run the following from the command-line:
 
 .. sourcecode:: none
 
-    # easy_install GitPython
+    # pip install GitPython
 
 This command will download the latest version of GitPython from the
 `Python Package Index <http://pypi.python.org/pypi/GitPython>`_ and install it
-to your system. More information about ``easy_install`` and pypi can be found
+to your system. More information about ``pip`` and pypi can be found
 here:
 
-* `setuptools`_
-* `install setuptools <http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instructions>`_
+* `install pip <https://pip.pypa.io/en/latest/installing.html>`_
 * `pypi <https://pypi.python.org/pypi/GitPython>`_
 
-.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
+.. _pip: https://pip.pypa.io/en/latest/installing.html
 
 Alternatively, you can install from the distribution using the ``setup.py``
 script:
@@ -57,8 +52,24 @@ script:
 .. sourcecode:: none
 
     # python setup.py install
-    
-.. note:: In this case, you have to manually install `GitDB`_ and `async`_ as well. It would be recommended to use the :ref:`git source repository <source-code-label>` in that case.
+
+.. note:: In this case, you have to manually install `GitDB`_ as well. It would be recommended to use the :ref:`git source repository <source-code-label>` in that case.
+
+Limitations
+===========
+
+Leakage of System Resources
+---------------------------
+
+GitPython is not suited for long-running processes (like daemons) as it tends to
+leak system resources. It was written in a time where destructors (as implemented
+in the `__del__` method) still ran deterministically.
+
+In case you still want to use it in such a context, you will want to search the
+codebase for `__del__` implementations and call these yourself when you see fit.
+
+Another way assure proper cleanup of resources is to factor out GitPython into a
+separate process which can be dropped periodically.
 
 Getting Started
 ===============
@@ -71,7 +82,7 @@ Getting Started
 API Reference
 =============
 
-An organized section of the GitPthon API is at :ref:`api_reference_toplevel`.
+An organized section of the GitPython API is at :ref:`api_reference_toplevel`.
 
 .. _source-code-label:
 
@@ -84,29 +95,30 @@ GitPython's git repo is available on GitHub, which can be browsed at:
 
 and cloned using::
 
-	$ git clone git://github.com/gitpython-developers/GitPython.git git-python
-	
+	$ git clone https://github.com/gitpython-developers/GitPython git-python
+
 Initialize all submodules to obtain the required dependencies with::
-    
+
     $ cd git-python
     $ git submodule update --init --recursive
-    
-Finally verify the installation by running the `nose powered <http://code.google.com/p/python-nose/>`_ unit tests::
-    
-    $ nosetests
-    
-Mailing List
-============
-http://groups.google.com/group/git-python
+
+Finally verify the installation by running unit tests::
+
+    $ python -m unittest
+
+Questions and Answers
+=====================
+Please use stackoverflow for questions, and don't forget to tag it with `gitpython` to assure the right people see the question in a timely manner.
+
+http://stackoverflow.com/questions/tagged/gitpython
 
 Issue Tracker
 =============
-The issue tracker is hosted by github:
+The issue tracker is hosted by GitHub:
 
 https://github.com/gitpython-developers/GitPython/issues
-	
+
 License Information
 ===================
 GitPython is licensed under the New BSD License.  See the LICENSE file for
 more information.
-
diff --git a/doc/source/quickstart.rst b/doc/source/quickstart.rst
new file mode 100644
index 000000000..c5930eb8a
--- /dev/null
+++ b/doc/source/quickstart.rst
@@ -0,0 +1,244 @@
+.. _quickdoc_toplevel:
+
+.. highlight:: python
+
+.. _quickdoc-label:
+
+==============================
+GitPython Quick Start Tutorial
+==============================
+Welcome to the GitPython Quickstart Guide! Designed for developers seeking a practical and interactive learning experience, this concise resource offers step-by-step code snippets to swiftly initialize/clone repositories, perform essential Git operations, and explore GitPython's capabilities. Get ready to dive in, experiment, and unleash the power of GitPython in your projects!
+
+
+git.Repo
+********
+
+There are a few ways to create a :class:`git.Repo <git.repo.base.Repo>` object
+
+Initialize a new git Repo
+#########################
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+        :language: python
+        :dedent: 8
+        :start-after: # [1-test_init_repo_object]
+        :end-before: # ![1-test_init_repo_object]
+
+Existing local git Repo
+#######################
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+        :language: python
+        :dedent: 8
+        :start-after: # [2-test_init_repo_object]
+        :end-before: # ![2-test_init_repo_object]
+
+Clone from URL
+##############
+
+For the rest of this tutorial we will use a clone from https://github.com/gitpython-developers/QuickStartTutorialFiles.git
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+        :language: python
+        :dedent: 8
+        :start-after: # [1-test_cloned_repo_object]
+        :end-before: # ![1-test_cloned_repo_object]
+
+
+Trees & Blobs
+**************
+
+Latest Commit Tree
+##################
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [12-test_cloned_repo_object]
+            :end-before: # ![12-test_cloned_repo_object]
+
+Any Commit Tree
+###############
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [13-test_cloned_repo_object]
+            :end-before: # ![13-test_cloned_repo_object]
+
+Display level 1 Contents
+########################
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [14-test_cloned_repo_object]
+            :end-before: # ![14-test_cloned_repo_object]
+
+Recurse through the Tree
+########################
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [15-test_cloned_repo_object]
+            :end-before: # ![15-test_cloned_repo_object]
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [16-test_cloned_repo_object]
+            :end-before: # ![16-test_cloned_repo_object]
+
+
+
+
+Usage
+****************
+
+Add file to staging area
+########################
+
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+        :language: python
+        :dedent: 8
+        :start-after: # [2-test_cloned_repo_object]
+        :end-before: # ![2-test_cloned_repo_object]
+
+    Now lets add the updated file to git
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+        :language: python
+        :dedent: 8
+        :start-after: # [3-test_cloned_repo_object]
+        :end-before: # ![3-test_cloned_repo_object]
+
+    Notice the add method requires a list as a parameter
+
+    Warning: If you experience any trouble with this, try to invoke :class:`git <git.cmd.Git>` instead via repo.git.add(path)
+
+Commit
+######
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+        :language: python
+        :dedent: 8
+        :start-after: # [4-test_cloned_repo_object]
+        :end-before: # ![4-test_cloned_repo_object]
+
+List of commits associated with a file
+#######################################
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+        :language: python
+        :dedent: 8
+        :start-after: # [5-test_cloned_repo_object]
+        :end-before: # ![5-test_cloned_repo_object]
+
+    Notice this returns a generator object
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+        :language: python
+        :dedent: 8
+        :start-after: # [6-test_cloned_repo_object]
+        :end-before: # ![6-test_cloned_repo_object]
+
+    returns list of :class:`Commit <git.objects.commit.Commit>` objects
+
+Printing text files
+####################
+Lets print the latest version of `<local_dir>/dir1/file2.txt`
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [17-test_cloned_repo_object]
+            :end-before: # ![17-test_cloned_repo_object]
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [18-test_cloned_repo_object]
+            :end-before: # ![18-test_cloned_repo_object]
+
+    Previous version of `<local_dir>/dir1/file2.txt`
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [18.1-test_cloned_repo_object]
+            :end-before: # ![18.1-test_cloned_repo_object]
+
+Status
+######
+    * Untracked files
+
+        Lets create a new file
+
+        .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [7-test_cloned_repo_object]
+            :end-before: # ![7-test_cloned_repo_object]
+
+        .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [8-test_cloned_repo_object]
+            :end-before: # ![8-test_cloned_repo_object]
+
+    * Modified files
+
+        .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [9-test_cloned_repo_object]
+            :end-before: # ![9-test_cloned_repo_object]
+
+        .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [10-test_cloned_repo_object]
+            :end-before: # ![10-test_cloned_repo_object]
+
+        returns a list of :class:`Diff <git.diff.Diff>` objects
+
+        .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [11-test_cloned_repo_object]
+            :end-before: # ![11-test_cloned_repo_object]
+
+Diffs
+######
+
+Compare staging area to head commit
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [11.1-test_cloned_repo_object]
+            :end-before: # ![11.1-test_cloned_repo_object]
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [11.2-test_cloned_repo_object]
+            :end-before: # ![11.2-test_cloned_repo_object]
+
+Compare commit to commit
+
+    .. literalinclude:: ../../test/test_quick_doc.py
+            :language: python
+            :dedent: 8
+            :start-after: # [11.3-test_cloned_repo_object]
+            :end-before: # ![11.3-test_cloned_repo_object]
+
+
+More Resources
+****************
+
+Remember, this is just the beginning! There's a lot more you can achieve with GitPython in your development workflow.
+To explore further possibilities and discover advanced features, check out the full :ref:`GitPython tutorial <tutorial_toplevel>`
+and the :ref:`API Reference <api_reference_toplevel>`. Happy coding!
diff --git a/doc/source/reference.rst b/doc/source/reference.rst
index 7adc53287..13dd38d02 100644
--- a/doc/source/reference.rst
+++ b/doc/source/reference.rst
@@ -3,33 +3,47 @@
 API Reference
 =============
 
+Top-Level
+---------
+
+.. py:data:: git.__version__
+
+   Current GitPython version.
+
+.. automodule:: git
+   :members: refresh
+
 Objects.Base
 ------------
 
 .. automodule:: git.objects.base
    :members:
-   :undoc-members:  
- 
+   :undoc-members:
+   :special-members:
+
 Objects.Blob
 ------------
 
 .. automodule:: git.objects.blob
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Objects.Commit
 --------------
 
 .. automodule:: git.objects.commit
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Objects.Tag
 -----------
 
 .. automodule:: git.objects.tag
    :members:
    :undoc-members:
+   :special-members:
 
 Objects.Tree
 ------------
@@ -37,6 +51,7 @@ Objects.Tree
 .. automodule:: git.objects.tree
    :members:
    :undoc-members:
+   :special-members:
 
 Objects.Functions
 -----------------
@@ -44,6 +59,7 @@ Objects.Functions
 .. automodule:: git.objects.fun
    :members:
    :undoc-members:
+   :special-members:
 
 Objects.Submodule.base
 ----------------------
@@ -51,6 +67,7 @@ Objects.Submodule.base
 .. automodule:: git.objects.submodule.base
    :members:
    :undoc-members:
+   :special-members:
 
 Objects.Submodule.root
 ----------------------
@@ -58,20 +75,23 @@ Objects.Submodule.root
 .. automodule:: git.objects.submodule.root
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Objects.Submodule.util
 ----------------------
 
 .. automodule:: git.objects.submodule.util
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Objects.Util
 -------------
 
 .. automodule:: git.objects.util
    :members:
    :undoc-members:
+   :special-members:
 
 Index.Base
 ----------
@@ -79,6 +99,7 @@ Index.Base
 .. automodule:: git.index.base
    :members:
    :undoc-members:
+   :special-members:
 
 Index.Functions
 ---------------
@@ -86,28 +107,31 @@ Index.Functions
 .. automodule:: git.index.fun
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Index.Types
 -----------
 
 .. automodule:: git.index.typ
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Index.Util
 -------------
 
 .. automodule:: git.index.util
    :members:
    :undoc-members:
-   
+   :special-members:
+
 GitCmd
 ------
 
 .. automodule:: git.cmd
    :members:
    :undoc-members:
-
+   :special-members:
 
 Config
 ------
@@ -115,13 +139,15 @@ Config
 .. automodule:: git.config
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Diff
 ----
 
 .. automodule:: git.diff
    :members:
    :undoc-members:
+   :special-members:
 
 Exceptions
 ----------
@@ -129,21 +155,24 @@ Exceptions
 .. automodule:: git.exc
    :members:
    :undoc-members:
+   :special-members:
+
 
- 
 Refs.symbolic
 -------------
 
 .. automodule:: git.refs.symbolic
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Refs.reference
 --------------
 
 .. automodule:: git.refs.reference
    :members:
    :undoc-members:
+   :special-members:
 
 Refs.head
 ---------
@@ -151,34 +180,39 @@ Refs.head
 .. automodule:: git.refs.head
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Refs.tag
 ------------
 
 .. automodule:: git.refs.tag
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Refs.remote
 ------------
 
 .. automodule:: git.refs.remote
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Refs.log
 ------------
 
 .. automodule:: git.refs.log
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Remote
 ------
 
 .. automodule:: git.remote
    :members:
    :undoc-members:
+   :special-members:
 
 Repo.Base
 ---------
@@ -186,13 +220,39 @@ Repo.Base
 .. automodule:: git.repo.base
    :members:
    :undoc-members:
-   
+   :special-members:
+
 Repo.Functions
 --------------
 
 .. automodule:: git.repo.fun
    :members:
    :undoc-members:
+   :special-members:
+
+Compat
+------
+
+.. automodule:: git.compat
+   :members:
+   :undoc-members:
+   :special-members:
+
+DB
+--
+
+.. automodule:: git.db
+   :members:
+   :undoc-members:
+   :special-members:
+
+Types
+-----
+
+.. automodule:: git.types
+   :members:
+   :undoc-members:
+   :special-members:
 
 Util
 ----
@@ -200,3 +260,4 @@ Util
 .. automodule:: git.util
    :members:
    :undoc-members:
+   :special-members:
diff --git a/doc/source/roadmap.rst b/doc/source/roadmap.rst
index f93d5e65b..34c953626 100644
--- a/doc/source/roadmap.rst
+++ b/doc/source/roadmap.rst
@@ -2,8 +2,7 @@
 #######
 Roadmap
 #######
-The full list of milestones including associated tasks can be found on github: 
+The full list of milestones including associated tasks can be found on GitHub:
 https://github.com/gitpython-developers/GitPython/issues
 
 Select the respective milestone to filter the list of issues accordingly.
-
diff --git a/doc/source/tutorial.rst b/doc/source/tutorial.rst
index 3f45b70dc..fd3b14c57 100644
--- a/doc/source/tutorial.rst
+++ b/doc/source/tutorial.rst
@@ -8,427 +8,517 @@
 GitPython Tutorial
 ==================
 
-GitPython provides object model access to your git repository. This tutorial is  composed of multiple sections, each of which explains a real-life usecase.
-
-Initialize a Repo object
-************************
-
-The first step is to create a ``Repo`` object to represent your repository::
-
-    from git import *
-    repo = Repo("/Users/mtrier/Development/git-python")
-    assert repo.bare == False
-
-In the above example, the directory ``/Users/mtrier/Development/git-python`` is my working repository and contains the ``.git`` directory. You can also initialize GitPython with a *bare* repository::
-
-    repo = Repo.init("/var/git/git-python.git", bare=True)
-    assert repo.bare == True
-    
-A repo object provides high-level access to your data, it allows you to create and delete heads, tags and remotes and access the configuration of the  repository::
-    
-    repo.config_reader()        # get a config reader for read-only access
-    repo.config_writer()        # get a config writer to change configuration 
-
-Query the active branch, query untracked files or whether the repository data  has been modified::
-    
-    repo.is_dirty()
-    False
-    repo.untracked_files
-    ['my_untracked_file']
-    
-Clone from existing repositories or initialize new empty ones::
-
-    cloned_repo = repo.clone("to/this/path")
-    new_repo = Repo.init("path/for/new/repo")
-    
-Archive the repository contents to a tar file::
-
-    repo.archive(open("repo.tar",'w'))
-    
-    
-Object Databases
-****************
-``Repo`` instances are powered by its object database instance which will be used when extracting any data, or when writing new objects.
+GitPython provides object model access to your git repository. This tutorial is composed of multiple sections, most of which explain a real-life use case.
 
-The type of the database determines certain performance characteristics, such as the quantity of objects that can be read per second, the resource usage when reading large data files, as well as the average memory footprint of your application.
+All code presented here originated from `test_docs.py <https://github.com/gitpython-developers/GitPython/blob/main/test/test_docs.py>`_ to assure correctness. Knowing this should also allow you to more easily run the code for your own testing purposes. All you need is a developer installation of git-python.
+
+Meet the Repo type
+******************
+
+The first step is to create a :class:`git.Repo <git.repo.base.Repo>` object to represent your repository.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [1-test_init_repo_object]
+    :end-before: # ![1-test_init_repo_object]
+
+In the above example, the directory ``self.rorepo.working_tree_dir`` equals ``/Users/mtrier/Development/git-python`` and is my working repository which contains the ``.git`` directory. You can also initialize GitPython with a *bare* repository.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [2-test_init_repo_object]
+    :end-before: # ![2-test_init_repo_object]
+
+A repo object provides high-level access to your data, it allows you to create and delete heads, tags and remotes and access the configuration of the repository.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [3-test_init_repo_object]
+    :end-before: # ![3-test_init_repo_object]
+
+Query the active branch, query untracked files or whether the repository data has been modified.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [4-test_init_repo_object]
+    :end-before: # ![4-test_init_repo_object]
+
+Clone from existing repositories or initialize new empty ones.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [5-test_init_repo_object]
+    :end-before: # ![5-test_init_repo_object]
+
+Archive the repository contents to a tar file.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [6-test_init_repo_object]
+    :end-before: # ![6-test_init_repo_object]
+
+Advanced Repo Usage
+===================
+
+And of course, there is much more you can do with this type, most of the following will be explained in greater detail in specific tutorials. Don't worry if you don't understand some of these examples right away, as they may require a thorough understanding of git's inner workings.
+
+Query relevant repository paths ...
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [7-test_init_repo_object]
+    :end-before: # ![7-test_init_repo_object]
+
+:class:`Heads <git.refs.head.Head>` Heads are branches in git-speak. :class:`References <git.refs.reference.Reference>` are pointers to a specific commit or to other references. Heads and :class:`Tags <git.refs.tag.TagReference>` are a kind of references. GitPython allows you to query them rather intuitively.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [8-test_init_repo_object]
+    :end-before: # ![8-test_init_repo_object]
+
+You can also create new heads ...
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [9-test_init_repo_object]
+    :end-before: # ![9-test_init_repo_object]
+
+... and tags ...
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [10-test_init_repo_object]
+    :end-before: # ![10-test_init_repo_object]
+
+You can traverse down to :class:`git objects <git.objects.base.Object>` through references and other objects. Some objects like :class:`commits <git.objects.commit.Commit>` have additional meta-data to query.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [11-test_init_repo_object]
+    :end-before: # ![11-test_init_repo_object]
+
+:class:`Remotes <git.remote.Remote>` allow to handle fetch, pull and push operations, while providing optional real-time progress information to :class:`progress delegates <git.util.RemoteProgress>`.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [12-test_init_repo_object]
+    :end-before: # ![12-test_init_repo_object]
+
+The :class:`index <git.index.base.IndexFile>` is also called stage in git-speak. It is used to prepare new commits, and can be used to keep results of merge operations. Our index implementation allows to stream date into the index, which is useful for bare repositories that do not have a working tree.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [13-test_init_repo_object]
+    :end-before: # ![13-test_init_repo_object]
+
+:class:`Submodules <git.objects.submodule.Submodule>` represent all aspects of git submodules, which allows you query all of their related information, and manipulate in various ways.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [14-test_init_repo_object]
+    :end-before: # ![14-test_init_repo_object]
 
-GitDB
-=====
-The GitDB is a pure-python implementation of the git object database. It is the default database to use in GitPython 0.3. Its uses less memory when handling huge files, but will be 2 to 5 times slower when extracting large quantities small of objects from densely packed repositories::
-    
-    repo = Repo("path/to/repo", odbt=GitDB)
 
-GitCmdObjectDB
-==============
-The git command database uses persistent git-cat-file instances to read repository information. These operate very fast under all conditions, but will consume additional memory for the process itself. When extracting large files, memory usage will be much higher than the one of the ``GitDB``::
-    
-    repo = Repo("path/to/repo", odbt=GitCmdObjectDB)
-    
 Examining References
 ********************
 
-References are the tips of your commit graph from which you can easily examine  the history of your project::
-
-    heads = repo.heads
-    master = heads.master       # lists can be accessed by name for convenience
-    master.commit               # the commit pointed to by head called master
-    master.rename("new_name")   # rename heads
-    
-Tags are (usually immutable) references to a commit and/or a tag object::
-
-    tags = repo.tags
-    tagref = tags[0]
-    tagref.tag                  # tags may have tag objects carrying additional information
-    tagref.commit               # but they always point to commits
-    repo.delete_tag(tagref)     # delete or
-    repo.create_tag("my_tag")   # create tags using the repo for convenience
-    
-A symbolic reference is a special case of a reference as it points to another reference instead of a commit::
-
-    head = repo.head            # the head points to the active branch/ref
-    master = head.reference     # retrieve the reference the head points to
-    master.commit               # from here you use it as any other reference
-    
-Access the reflog easily::
-    
-    log = master.log()
-    log[0]                      # first (i.e. oldest) reflog entry
-    log[-1]                     # last (i.e. most recent) reflog entry
-    
-For more information on the reflog, see the ``RefLog`` type's documentation.
+:class:`References <git.refs.reference.Reference>` are the tips of your commit graph from which you can easily examine the history of your project.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [1-test_references_and_objects]
+    :end-before: # ![1-test_references_and_objects]
+
+:class:`Tags <git.refs.tag.TagReference>` are (usually immutable) references to a commit and/or a tag object.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [2-test_references_and_objects]
+    :end-before: # ![2-test_references_and_objects]
+
+A :class:`symbolic reference <git.refs.symbolic.SymbolicReference>` is a special case of a reference as it points to another reference instead of a commit.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [3-test_references_and_objects]
+    :end-before: # ![3-test_references_and_objects]
+
+Access the :class:`reflog <git.refs.log.RefLog>` easily.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [4-test_references_and_objects]
+    :end-before: # ![4-test_references_and_objects]
 
 Modifying References
 ********************
-You can easily create and delete reference types or modify where they point to::
+You can easily create and delete :class:`reference types <git.refs.reference.Reference>` or modify where they point to.
 
-    repo.delete_head('master')           # delete an existing head
-    master = repo.create_head('master')  # create a new one
-    master.commit = 'HEAD~10'            # set branch to another commit without changing index or working tree 
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [5-test_references_and_objects]
+    :end-before: # ![5-test_references_and_objects]
 
-Create or delete tags the same way except you may not change them afterwards::
+Create or delete :class:`tags <git.refs.tag.TagReference>` the same way except you may not change them afterwards.
 
-    new_tag = repo.create_tag('my_tag', 'my message')
-    repo.delete_tag(new_tag)
-    
-Change the symbolic reference to switch branches cheaply ( without adjusting the index or the working copy )::
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [6-test_references_and_objects]
+    :end-before: # ![6-test_references_and_objects]
 
-    new_branch = repo.create_head('new_branch')
-    repo.head.reference = new_branch
+Change the :class:`symbolic reference <git.refs.symbolic.SymbolicReference>` to switch branches cheaply (without adjusting the index or the working tree).
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [7-test_references_and_objects]
+    :end-before: # ![7-test_references_and_objects]
 
 Understanding Objects
 *********************
-An Object is anything storable in git's object database. Objects contain information about their type, their uncompressed size as well as the actual data. Each object is uniquely identified by a binary SHA1 hash, being 20 bytes in size.
-
-Git only knows 4 distinct object types being Blobs, Trees, Commits and Tags.
-
-In Git-Python, all objects can be accessed through their common base, compared  and hashed. They are usually not instantiated directly, but through references or specialized repository functions::
-
-    hc = repo.head.commit
-    hct = hc.tree
-    hc != hct
-    hc != repo.tags[0]
-    hc == repo.head.reference.commit
-    
-Common fields are::
-
-    hct.type
-    'tree'
-    hct.size
-    166
-    hct.hexsha
-    'a95eeb2a7082212c197cabbf2539185ec74ed0e8'
-    hct.binsha
-    'binary 20 byte sha1'
-    
-Index Objects are objects that can be put into git's index. These objects are trees, blobs and submodules which additionally know about their path in the filesystem as well as their mode::
-    
-    hct.path            # root tree has no path
-    ''
-    hct.trees[0].path   # the first subdirectory has one though
-    'dir'
-    htc.mode            # trees have the mode of a linux directory
-    040000
-    '%o' % htc.blobs[0].mode    # blobs have a specific mode though comparable to a standard linux fs
-    100644
-    
-Access blob data (or any object data) directly or using streams::
-    
-    htc.blobs[0].data_stream.read()      # stream object to read data from
-    htc.blobs[0].stream_data(open("blob_data", "w")) # write data to given stream
-    
-    
-The Commit object
-*****************
+An Object is anything storable in git's object database. Objects contain information about their type, their uncompressed size as well as the actual data. Each object is uniquely identified by a binary SHA1 hash, being 20 bytes in size, or 40 bytes in hexadecimal notation.
 
-Commit objects contain information about a specific commit. Obtain commits using  references as done in `Examining References`_ or as follows.
+Git only knows 4 distinct object types being :class:`Blobs <git.objects.blob.Blob>`, :class:`Trees <git.objects.tree.Tree>`, :class:`Commits <git.objects.commit.Commit>` and :class:`Tags <git.objects.tag.TagObject>`.
 
-Obtain commits at the specified revision::
+In GitPython, all objects can be accessed through their common base, can be compared and hashed. They are usually not instantiated directly, but through references or specialized repository functions.
 
-    repo.commit('master')
-    repo.commit('v0.1')
-    repo.commit('HEAD~10')
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [8-test_references_and_objects]
+    :end-before: # ![8-test_references_and_objects]
 
-Iterate 100 commits::
+Common fields are ...
 
-    repo.iter_commits('master', max_count=100)
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [9-test_references_and_objects]
+    :end-before: # ![9-test_references_and_objects]
 
-If you need paging, you can specify a number of commits to skip::
+:class:`Index objects <git.objects.base.IndexObject>` are objects that can be put into git's index. These objects are trees, blobs and submodules which additionally know about their path in the file system as well as their mode.
 
-    repo.iter_commits('master', max_count=10, skip=20)
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [10-test_references_and_objects]
+    :end-before: # ![10-test_references_and_objects]
 
-The above will return commits 21-30 from the commit list.::
+Access :class:`blob <git.objects.blob.Blob>` data (or any object data) using streams.
 
-    headcommit = repo.head.commit 
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [11-test_references_and_objects]
+    :end-before: # ![11-test_references_and_objects]
 
-    headcommit.hexsha
-    '207c0c4418115df0d30820ab1a9acd2ea4bf4431'
 
-    headcommit.parents
-    (<git.Commit "a91c45eee0b41bf3cdaad3418ca3850664c4a4b4">,)
+The Commit object
+*****************
 
-    headcommit.tree
-    <git.Tree "563413aedbeda425d8d9dcbb744247d0c3e8a0ac">
+:class:`Commit <git.objects.commit.Commit>` objects contain information about a specific commit. Obtain commits using  references as done in `Examining References`_ or as follows.
 
-    headcommit.author
-    <git.Actor "Michael Trier <mtrier@gmail.com>">
+Obtain commits at the specified revision
 
-    headcommit.authored_date        # seconds since epoch
-    1256291446
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [12-test_references_and_objects]
+    :end-before: # ![12-test_references_and_objects]
 
-    headcommit.committer
-    <git.Actor "Michael Trier <mtrier@gmail.com>">
+Iterate 50 commits, and if you need paging, you can specify a number of commits to skip.
 
-    headcommit.committed_date
-    1256291446
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [13-test_references_and_objects]
+    :end-before: # ![13-test_references_and_objects]
 
-    headcommit.message
-    'cleaned up a lot of test information. Fixed escaping so it works with
-    subprocess.'
+A commit object carries all sorts of meta-data
 
-Note: date time is represented in a ``seconds since epoch`` format. Conversion to human readable form can be accomplished with the various `time module <http://docs.python.org/library/time.html>`_ methods::
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [14-test_references_and_objects]
+    :end-before: # ![14-test_references_and_objects]
 
-    import time
-    time.asctime(time.gmtime(headcommit.committed_date))
-    'Wed May 7 05:56:02 2008'
+Note: date time is represented in a ``seconds since epoch`` format. Conversion to human readable form can be accomplished with the various `time module <http://docs.python.org/library/time.html>`_ methods.
 
-    time.strftime("%a, %d %b %Y %H:%M", time.gmtime(headcommit.committed_date))
-    'Wed, 7 May 2008 05:56'
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [15-test_references_and_objects]
+    :end-before: # ![15-test_references_and_objects]
 
-You can traverse a commit's ancestry by chaining calls to ``parents``::
+You can traverse a commit's ancestry by chaining calls to ``parents``
 
-    headcommit.parents[0].parents[0].parents[0]
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [16-test_references_and_objects]
+    :end-before: # ![16-test_references_and_objects]
 
 The above corresponds to ``master^^^`` or ``master~3`` in git parlance.
 
 The Tree object
 ***************
 
-A tree records pointers to the contents of a directory. Let's say you want the root tree of the latest commit on the master branch::
-
-    tree = repo.heads.master.commit.tree
-    <git.Tree "a006b5b1a8115185a228b7514cdcd46fed90dc92">
+A :class:`tree <git.objects.tree.Tree>` records pointers to the contents of a directory. Let's say you want the root tree of the latest commit on the master branch
 
-    tree.hexsha
-    'a006b5b1a8115185a228b7514cdcd46fed90dc92'
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [17-test_references_and_objects]
+    :end-before: # ![17-test_references_and_objects]
 
-Once you have a tree, you can get the contents::
+Once you have a tree, you can get its contents
 
-    tree.trees          # trees are subdirectories
-    [<git.Tree "f7eb5df2e465ab621b1db3f5714850d6732cfed2">]
-    
-    tree.blobs          # blobs are files
-    [<git.Blob "a871e79d59cf8488cac4af0c8f990b7a989e2b53">,
-    <git.Blob "3594e94c04db171e2767224db355f514b13715c5">,
-    <git.Blob "e79b05161e4836e5fbf197aeb52515753e8d6ab6">,
-    <git.Blob "94954abda49de8615a048f8d2e64b5de848e27a1">]
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [18-test_references_and_objects]
+    :end-before: # ![18-test_references_and_objects]
 
-Its useful to know that a tree behaves like a list with the ability to  query entries by name::
+It is useful to know that a tree behaves like a list with the ability to query entries by name
 
-    tree[0] == tree['dir']			# access by index and by sub-path
-    <git.Tree "f7eb5df2e465ab621b1db3f5714850d6732cfed2">
-    for entry in tree: do_something_with(entry)
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [19-test_references_and_objects]
+    :end-before: # ![19-test_references_and_objects]
 
-    blob = tree[0][0]
-    blob.name
-    'file'
-    blob.path
-    'dir/file'
-    blob.abspath
-    '/Users/mtrier/Development/git-python/dir/file'
-    >>>tree['dir/file'].binsha == blob.binsha
+There is a convenience method that allows you to get a named sub-object from a tree with a syntax similar to how paths are written in a posix system
 
-There is a convenience method that allows you to get a named sub-object from a tree with a syntax similar to how paths are written in an unix system::
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [20-test_references_and_objects]
+    :end-before: # ![20-test_references_and_objects]
 
-    tree/"lib"
-    <git.Tree "c1c7214dde86f76bc3e18806ac1f47c38b2b7a30">
-    tree/"dir/file" == blob
+You can also get a commit's root tree directly from the repository
 
-You can also get a tree directly from the repository if you know its name::
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [21-test_references_and_objects]
+    :end-before: # ![21-test_references_and_objects]
 
-    repo.tree()
-    <git.Tree "master">
+As trees allow direct access to their intermediate child entries only, use the traverse method to obtain an iterator to retrieve entries recursively
 
-    repo.tree("c1c7214dde86f76bc3e18806ac1f47c38b2b7a30")
-    <git.Tree "c1c7214dde86f76bc3e18806ac1f47c38b2b7a30">
-    repo.tree('0.1.6')
-    <git.Tree "6825a94104164d9f0f5632607bebd2a32a3579e5">
-    
-As trees only allow direct access to their direct entries, use the traverse  method to obtain an iterator to traverse entries recursively::
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [22-test_references_and_objects]
+    :end-before: # ![22-test_references_and_objects]
 
-    tree.traverse()
-    <generator object at 0x7f6598bd65a8>
-    for entry in tree.traverse(): do_something_with(entry)
-    
-    
-.. note:: If tree's return Submodule objects, they will assume that they exist at the current head's commit. The tree it originated from may be rooted at another commit though, which has to be told to the Submodule object using its ``set_parent_commit(my_commit)`` method.
+.. note:: If trees return Submodule objects, they will assume that they exist at the current head's commit. The tree it originated from may be rooted at another commit though, that it doesn't know. That is why the caller would have to set the submodule's owning or parent commit using the ``set_parent_commit(my_commit)`` method.
 
-    
 The Index Object
 ****************
-The git index is the stage containing changes to be written with the next commit or where merges finally have to take place. You may freely access and manipulate  this information using the IndexFile Object::
-
-    index = repo.index
-    
-Access objects and add/remove entries. Commit the changes::
-
-    for stage, blob in index.iter_blobs(): do_something(...)
-    # Access blob objects
-    for (path, stage), entry in index.entries.iteritems: pass
-    # Access the entries directly
-    index.add(['my_new_file'])      # add a new file to the index
-    index.remove(['dir/existing_file'])
-    new_commit = index.commit("my commit message") # commit by commit message first
-    my_author = Actor("An author", "author@example.com")
-    my_committer = Actor("A committer", "committer@example.com")
-    next_commit = index.commit("my commit message", author=my_author, commiter=my_committer) # commit by commit message and author and committer
-    
-Create new indices from other trees or as result of a merge. Write that result to a new index file::
-
-    tmp_index = Index.from_tree(repo, 'HEAD~1') # load a tree into a temporary index
-    merge_index = Index.from_tree(repo, 'base', 'HEAD', 'some_branch') # merge two trees three-way
-    merge_index.write("merged_index")
-    
+The git index is the stage containing changes to be written with the next commit or where merges finally have to take place. You may freely access and manipulate this information using the :class:`IndexFile <git.index.base.IndexFile>` object.
+Modify the index with ease
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [23-test_references_and_objects]
+    :end-before: # ![23-test_references_and_objects]
+
+Create new indices from other trees or as result of a merge. Write that result to a new index file for later inspection.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [24-test_references_and_objects]
+    :end-before: # ![24-test_references_and_objects]
+
 Handling Remotes
 ****************
 
-Remotes are used as alias for a foreign repository to ease pushing to and fetching from them::
-
-    test_remote = repo.create_remote('test', 'git@server:repo.git')
-    repo.delete_remote(test_remote) # create and delete remotes
-    origin = repo.remotes.origin    # get default remote by name
-    origin.refs                     # local remote references
-    o = origin.rename('new_origin') # rename remotes
-    o.fetch()                       # fetch, pull and push from and to the remote
-    o.pull()
-    o.push()
-
-You can easily access configuration information for a remote by accessing options  as if they where attributes::
-    
-    o.url
-    'git@server:dummy_repo.git'
-    
-Change configuration for a specific remote only::
-    
-    o.config_writer.set("pushurl", "other_url")
-    
-    
+:class:`Remotes <git.remote.Remote>` are used as alias for a foreign repository to ease pushing to and fetching from them
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [25-test_references_and_objects]
+    :end-before: # ![25-test_references_and_objects]
+
+You can easily access configuration information for a remote by accessing options as if they were attributes. The modification of remote configuration is more explicit though.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [26-test_references_and_objects]
+    :end-before: # ![26-test_references_and_objects]
+
+You can also specify per-call custom environments using a new context manager on the Git command, e.g. for using a specific SSH key. The following example works with `git` starting at *v2.3*::
+
+    ssh_cmd = 'ssh -i id_deployment_key'
+    with repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
+        repo.remotes.origin.fetch()
+
+This one sets a custom script to be executed in place of `ssh`, and can be used in `git` prior to *v2.3*::
+
+    ssh_executable = os.path.join(rw_dir, 'my_ssh_executable.sh')
+    with repo.git.custom_environment(GIT_SSH=ssh_executable):
+        repo.remotes.origin.fetch()
+
+Here's an example executable that can be used in place of the `ssh_executable` above:
+
+.. code-block:: shell
+
+    #!/bin/sh
+    ID_RSA=/var/lib/openshift/5562b947ecdd5ce939000038/app-deployments/id_rsa
+    exec /usr/bin/ssh -o StrictHostKeyChecking=no -i $ID_RSA "$@"
+
+Please note that the script must be executable (i.e. `chmod +x script.sh`). `StrictHostKeyChecking=no` is used to avoid prompts asking to save the hosts key to `~/.ssh/known_hosts`, which happens in case you run this as daemon.
+
+You might also have a look at `Git.update_environment(...)` in case you want to setup a changed environment more permanently.
+
 Submodule Handling
 ******************
-Submodules can be conveniently handled using the methods provided by Git-Python, and as an added benefit, Git-Python provides functionality which behave smarter and less error prone than its original c-git implementation, that is Git-Python tries hard to keep your repository consistent when updating submodules recursively or adjusting the existing configuration.
-
-In the following brief example, you will learn about the very basics, assuming you operate on the Git-Python repository itself::
-    
-    >>> repo = Repo('path/to/git-python/repository')
-    >>> sms = repo.submodules
-    [git.Submodule(name=gitdb, path=lib/git/ext/gitdb, url=git://github.com/gitpython-developers/GitPython.git, branch=master)]
-    >>> sm = sms[0]
-    >>> sm.name
-    'gitdb'
-    >>> sm.module()                                        # The module is the actual repository referenced by the submodule 
-    <git.Repo "<prefix>/git-python/lib/git/ext/gitdb/.git">
-    >>> sm.module_exists()
-    True
-    >>> sm.abspath == sm.module().working_tree_dir         # the submodule's absolute path is the module's path
-    True
-    >>> sm.hexsha                                          # Its sha defines the commit to checkout
-    '2ddc5bad224d8f545ef3bb2ab3df98dfe063c5b6'
-    >>> sm.exists()                                        # yes, this submodule is valid and exists
-    True
-    >>> sm.config_reader().get_value('path') == sm.path    # read its configuration conveniently
-    True
-    >>> sm.children()                                      # query the submodule hierarchy
-    [git.Submodule(name=async, path=ext/async, url=git://github.com/gitpython-developers/async.git, branch=master)]
-
-In addition to the query functionality, you can move the submodule's repository to a different path <``move(...)``>, write its configuration <``config_writer().set_value(...)``>, update its working tree <``update(...)``>, and remove and add them <``remove(...)``, ``add(...)``>.
-
-If you obtained your submodule object by traversing a tree object which is not rooted at the head's commit, you have to inform the submodule about its actual commit to retrieve the data from by using the ``set_parent_commit(...)`` method.
-
-The special ``RootModule`` type allows you to treat your master repository as root of a hierarchy of submodules, which allows very convenient submodule handling. Its ``update(...)`` method is reimplemented to provide an advanced way of updating submodules as they change their values. The update method will track changes and make sure your working tree and submodule checkouts stay consistent, which is very useful in case submodules get deleted or added to name just two of the handled cases.
-
-Additionally, Git-Python adds functionality to track a specific branch, instead of just a commit. Supported by customized update methods, you are able to automatically update submodules to the latest revision available in the remote repository, as well as to keep track of changes and movements of these submodules. To use it, set the name of the branch you want to track to the ``submodule.$name.branch`` option of the *.gitmodules*  file, and use Git-Python update methods on the resulting repository with the ``to_latest_revision`` parameter turned on. In the latter case, the sha of your submodule will be ignored, instead a local tracking branch will be updated to the respective remote branch automatically. The resulting behaviour is much like the one of svn::externals, which can be useful in times. 
+:class:`Submodules <git.objects.submodule.base.Submodule>` can be conveniently handled using the methods provided by GitPython, and as an added benefit, GitPython provides functionality which behave smarter and less error prone than its original c-git implementation, that is GitPython tries hard to keep your repository consistent when updating submodules recursively or adjusting the existing configuration.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [1-test_submodules]
+    :end-before: # ![1-test_submodules]
+
+In addition to the query functionality, you can move the submodule's repository to a different path <``move(...)``>,
+write its configuration <``config_writer().set_value(...).release()``>, update its working tree <``update(...)``>,
+and remove or add them <``remove(...)``, ``add(...)``>.
+
+If you obtained your submodule object by traversing a tree object which is not rooted at the head's commit,
+you have to inform the submodule about its actual commit to retrieve the data from
+by using the ``set_parent_commit(...)`` method.
+
+The special :class:`RootModule <git.objects.submodule.root.RootModule>` type allows you to treat your superproject (master repository) as root of a hierarchy of submodules, which allows very convenient submodule handling. Its ``update(...)`` method is reimplemented to provide an advanced way of updating submodules as they change their values over time. The update method will track changes and make sure your working tree and submodule checkouts stay consistent, which is very useful in case submodules get deleted or added to name just two of the handled cases.
+
+Additionally, GitPython adds functionality to track a specific branch, instead of just a commit. Supported by customized update methods, you are able to automatically update submodules to the latest revision available in the remote repository, as well as to keep track of changes and movements of these submodules. To use it, set the name of the branch you want to track to the ``submodule.$name.branch`` option of the *.gitmodules*  file, and use GitPython update methods on the resulting repository with the ``to_latest_revision`` parameter turned on. In the latter case, the sha of your submodule will be ignored, instead a local tracking branch will be updated to the respective remote branch automatically, provided there are no local changes. The resulting behaviour is much like the one of svn::externals, which can be useful in times.
 
 Obtaining Diff Information
 **************************
 
-Diffs can generally be obtained by subclasses of ``Diffable`` as they provide  the ``diff`` method. This operation yields a DiffIndex allowing you to easily access diff information about paths.
+Diffs can generally be obtained by subclasses of :class:`Diffable <git.diff.Diffable>` as they provide the ``diff`` method. This operation yields a :class:`DiffIndex <git.diff.DiffIndex>` allowing you to easily access diff information about paths.
 
-Diffs can be made between the Index and Trees, Index and the working tree, trees and trees as well as trees and the working copy. If commits are involved, their tree will be used implicitly::
+Diffs can be made between the Index and Trees, Index and the working tree, trees and trees as well as trees and the working copy. If commits are involved, their tree will be used implicitly.
 
-    hcommit = repo.head.commit
-    idiff = hcommit.diff()          # diff tree against index
-    tdiff = hcommit.diff('HEAD~1')  # diff tree against previous tree
-    wdiff = hcommit.diff(None)      # diff tree against working tree
-    
-    index = repo.index
-    index.diff()                    # diff index against itself yielding empty diff
-    index.diff(None)                # diff index against working copy
-    index.diff('HEAD')              # diff index against current HEAD tree
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [27-test_references_and_objects]
+    :end-before: # ![27-test_references_and_objects]
 
-The item returned is a DiffIndex which is essentially a list of Diff objects. It  provides additional filtering to ease finding what you might be looking for::
+The item returned is a DiffIndex which is essentially a list of Diff objects. It provides additional filtering to ease finding what you might be looking for.
 
-    for diff_added in wdiff.iter_change_type('A'): do_something_with(diff_added)
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [28-test_references_and_objects]
+    :end-before: # ![28-test_references_and_objects]
 
-Use the diff framework if you want to implement git-status like functionality.     
+Use the diff framework if you want to implement git-status like functionality.
 
 * A diff between the index and the commit's tree your HEAD points to
- 
- * use repo.index.diff(repo.head)
-  
+
+ * use ``repo.index.diff(repo.head.commit)``
+
 * A diff between the index and the working tree
- 
- * use repo.index.diff(None)
-  
+
+ * use ``repo.index.diff(None)``
+
 * A list of untracked files
- 
- * use repo.untracked_files
 
-    
+ * use ``repo.untracked_files``
+
 Switching Branches
 ******************
-To switch between branches, you effectively need to point your HEAD to the new branch head and reset your index and working copy to match. A simple manual way to do it is the following one::
+To switch between branches similar to ``git checkout``, you effectively need to point your HEAD symbolic reference to the new branch and reset your index and working copy to match. A simple manual way to do it is the following one
 
-    repo.head.reference = repo.heads.other_branch
-    repo.head.reset(index=True, working_tree=True)
-    
-The previous approach would brutally overwrite the user's changes in the working copy and index though and is less sophisticated than a git-checkout for instance which generally prevents you from destroying your work. Use the safer approach as follows::
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [29-test_references_and_objects]
+    :end-before: # ![29-test_references_and_objects]
 
-	repo.heads.master.checkout()			# checkout the branch using git-checkout
-	repo.heads.other_branch.checkout()
+The previous approach would brutally overwrite the user's changes in the working copy and index though and is less sophisticated than a ``git-checkout``. The latter will generally prevent you from destroying your work. Use the safer approach as follows.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [30-test_references_and_objects]
+    :end-before: # ![30-test_references_and_objects]
+
+Initializing a repository
+*************************
+
+In this example, we will initialize an empty repository, add an empty file to the index, and commit the change.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: def test_add_file_and_commit
+    :end-before: # ![test_add_file_and_commit]
+
+Please have a look at the individual methods as they usually support a vast amount of arguments to customize their behavior.
 
 Using git directly
 ******************
-In case you are missing functionality as it has not been wrapped, you may conveniently use the git command directly. It is owned by each repository instance::
+In case you are missing functionality as it has not been wrapped, you may conveniently use the :class:`git <git.cmd.Git>` command directly. It is owned by each repository instance.
+
+.. literalinclude:: ../../test/test_docs.py
+    :language: python
+    :dedent: 8
+    :start-after: # [31-test_references_and_objects]
+    :end-before: # ![31-test_references_and_objects]
 
-    git = repo.git
-    git.checkout('head', b="my_new_branch")         # default command
-    git.for_each_ref()                              # '-' becomes '_' when calling it
-    
 The return value will by default be a string of the standard output channel produced by the command.
 
-Keyword arguments translate to short and long keyword arguments on the commandline.
+Keyword arguments translate to short and long keyword arguments on the command-line.
 The special notion ``git.command(flag=True)`` will create a flag without value like ``command --flag``.
 
-If ``None`` is found in the arguments, it will be dropped silently. Lists and tuples  passed as arguments will be unpacked recursively to individual arguments. Objects are converted to strings using the str(...) function.
+If ``None`` is found in the arguments, it will be dropped silently. Lists and tuples passed as arguments will be unpacked recursively to individual arguments. Objects are converted to strings using the ``str(...)`` function.
+
+
+Object Databases
+****************
+:class:`git.Repo <git.repo.base.Repo>` instances are powered by its object database instance which will be used when extracting any data, or when writing new objects.
+
+The type of the database determines certain performance characteristics, such as the quantity of objects that can be read per second, the resource usage when reading large data files, as well as the average memory footprint of your application.
+
+GitDB
+=====
+The GitDB is a pure-python implementation of the git object database. It is the default database to use in GitPython 0.3. It uses less memory when handling huge files, but will be 2 to 5 times slower when extracting large quantities of small objects from densely packed repositories::
+
+    repo = Repo("path/to/repo", odbt=GitDB)
+
+
+GitCmdObjectDB
+==============
+The git command database uses persistent git-cat-file instances to read repository information. These operate very fast under all conditions, but will consume additional memory for the process itself. When extracting large files, memory usage will be much higher than ``GitDB``::
+
+    repo = Repo("path/to/repo", odbt=GitCmdObjectDB)
 
 Git Command Debugging and Customization
 ***************************************
@@ -437,9 +527,14 @@ Using environment variables, you can further adjust the behaviour of the git com
 
 * **GIT_PYTHON_TRACE**
 
- * If set to non-0, all executed git commands will be printed to stdout.
- * if set to *full*, the executed git command will be printed along with its output.
- 
+ * If set to non-0, all executed git commands will be shown as they happen
+ * If set to *full*, the executed git command _and_ its entire output on stdout and stderr will be shown as they happen
+
+ **NOTE**: All logging is outputted using a Python logger, so make sure your program is configured to show INFO-level messages.  If this is not the case, try adding the following to your program::
+
+    import logging
+    logging.basicConfig(level=logging.INFO)
+
 * **GIT_PYTHON_GIT_EXECUTABLE**
 
  * If set, it should contain the full path to the git executable, e.g. *c:\\Program Files (x86)\\Git\\bin\\git.exe* on windows or */usr/bin/git* on linux.
@@ -447,7 +542,6 @@ Using environment variables, you can further adjust the behaviour of the git com
 And even more ...
 *****************
 
-There is more functionality in there, like the ability to archive repositories, get stats and logs, blame, and probably a few other things that were not mentioned here.  
+There is more functionality in there, like the ability to archive repositories, get stats and logs, blame, and probably a few other things that were not mentioned here.
 
 Check the unit tests for an in-depth introduction on how each function is supposed to be used.
-
diff --git a/doc/source/whatsnew.rst b/doc/source/whatsnew.rst
deleted file mode 100644
index f71d88e60..000000000
--- a/doc/source/whatsnew.rst
+++ /dev/null
@@ -1,59 +0,0 @@
-
-################
-Whats New in 0.3
-################
-GitPython 0.3 is the first step in creating a hybrid which uses a pure python implementations for all simple git features which can be implemented without significant performance penalties. Everything else is still performed using the git command, which is nicely integrated and easy to use.
-
-Its biggest strength, being the support for all git features through the git command itself, is a weakness as well considering the possibly vast amount of times the git command is being started up. Depending on the actual command being performed, the git repository will be initialized on many of these invocations, causing additional overhead for possibly tiny operations.
-
-Keeping as many major operations in the python world will result in improved caching benefits as certain data structures just have to be initialized once and can be reused multiple times. This mode of operation may improve performance when altering the git database on a low level, and is clearly beneficial on operating systems where command invocations are very slow.
-
-****************
-Object Databases
-****************
-An object database provides a simple interface to query object information or to write new object data. Objects are generally identified by their 20 byte binary sha1 value during query.
-
-GitPython uses the ``gitdb`` project to provide a pure-python implementation of the git database, which includes reading and writing loose objects, reading pack files and handling alternate repositories.
-
-The great thing about this is that ``Repo`` objects can use any object database, hence it easily supports different implementations with different performance characteristics. If you are thinking in extremes, you can implement your own database representation, which may be more efficient for what you want to do specifically, like handling big files more efficiently.
-
-************************
-Reduced Memory Footprint
-************************
-Objects, such as commits, tags, trees and blobs now use 20 byte sha1 signatures internally, reducing their memory demands by 20 bytes per object, allowing you to keep more objects in memory at the same time. 
-
-The internal caches of tree objects were improved to use less memory as well.
-
-##################
-Upgrading from 0.2
-##################
-GitPython 0.2 essentially behaves like GitPython 0.3 with a Repository using the ``GitCmdObjectDB`` instead of the ``GitDB`` as object database backend. Additionally it can be used more conveniently through implicit conversions and provides a feature set strikingly similar to 0.3.
-
-**************************
-Why you should not upgrade
-**************************
-GitPython 0.3 in most cases will not run faster than GitPython 0.2, the opposite might be the case at it uses the pure python implementation by default.
-There have been a few renames which will need additional adjustments in your code.
-
-Generally, if you only read git repositories, version 0.2 is sufficient and very well performing.
-
-**********************
-Why you should upgrade
-**********************
-GitPython 0.2 has reached its end of line, and it is unlikely to receive more than contributed patches. 0.3 is the main development branch which will lead into the future.
-
-GitPython 0.3 provides memory usage optimization and is very flexible in the way it uses to access the object database. With minimal effort, 0.3 will be running as fast as 0.2. It marks the first step of more versions to come, and will improve over time. 
-
-GitPython 0.3 is especially suitable for everyone who needs not only read, but also write access to a git repository. It is optimized to keep the memory consumption as low as possible, especially when handling large data sets. GitPython 0.3 operates on streams, not on possibly huge chunks of data.
-
-
-**************
-Guided Upgrade
-**************
-This guide should help to make the upgrade as painless as possible, hence it points out where to start, and what to look out for.
-
-* Have a look at https://github.com/gitpython-developers/GitPython/blob/0.3/doc/source/changes.rst
-* Start applying the renames, generally the ``utils`` modules are now called ``util``, ``errors`` is called ``exc``.
-* Search for occurrences of the ``sha`` property of object instances. A similar value can be obtained through the new ``hexsha`` property. The native sha1 value is the ``binsha`` though.
-* Search for code which instantiates objects directly. Their initializer now requires a 20 byte binary Sha1, rev-specs cannot be used anymore. For a similar effect, either convert your hexadecimal shas to binary shas beforehand ( ``binascii.unhexlify`` for instance ), or use higher level functions such as ``Object.new``, ``Repo.commit`` or ``Repo.tree``. The latter ones takes rev-specs and hexadecimal sha1 hashes.
-
diff --git a/etc/sublime-text/git-python.sublime-project b/etc/sublime-text/git-python.sublime-project
deleted file mode 100644
index 3dab9f656..000000000
--- a/etc/sublime-text/git-python.sublime-project
+++ /dev/null
@@ -1,62 +0,0 @@
-{
-	"folders":
-	[
-		// GIT-PYTHON
-		/////////////
-		{
-			"follow_symlinks": true,
-			"path": "../..",
-			"file_exclude_patterns" : [
-				"*.sublime-workspace",
-				".git",
-				".noseids",
-				".coverage"
-			],
-			"folder_exclude_patterns" : [
-				".git",
-				"cover",
-				"git/ext",
-				"dist",
-				".tox",
-				"doc/build",
-				"*.egg-info"
-			]
-		},
-		// GITDB
-		////////
-		{
-			"follow_symlinks": true,
-			"path": "../../git/ext/gitdb",
-			"file_exclude_patterns" : [
-				"*.sublime-workspace",
-				".git",
-				".noseids",
-				".coverage"
-			],
-			"folder_exclude_patterns" : [
-				".git",
-				"cover",
-				"gitdb/ext",
-				"dist",
-				"doc/build",
-				".tox",
-			]
-		},
-		// // SMMAP
-		// ////////
-		{
-			"follow_symlinks": true,
-			"path": "../../git/ext/gitdb/gitdb/ext/smmap",
-			"file_exclude_patterns" : [
-				"*.sublime-workspace",
-				".git",
-				".noseids",
-				".coverage"
-			],
-			"folder_exclude_patterns" : [
-				".git",
-				"cover",
-			]
-		},
-	]
-}
diff --git a/fuzzing/LICENSE-APACHE b/fuzzing/LICENSE-APACHE
new file mode 100644
index 000000000..8dada3eda
--- /dev/null
+++ b/fuzzing/LICENSE-APACHE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/fuzzing/LICENSE-BSD b/fuzzing/LICENSE-BSD
new file mode 120000
index 000000000..ea5b60640
--- /dev/null
+++ b/fuzzing/LICENSE-BSD
@@ -0,0 +1 @@
+../LICENSE
\ No newline at end of file
diff --git a/fuzzing/README.md b/fuzzing/README.md
new file mode 100644
index 000000000..286f529eb
--- /dev/null
+++ b/fuzzing/README.md
@@ -0,0 +1,226 @@
+# Fuzzing GitPython
+
+[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/gitpython.svg)][oss-fuzz-issue-tracker]
+
+This directory contains files related to GitPython's suite of fuzz tests that are executed daily on automated
+infrastructure provided by [OSS-Fuzz][oss-fuzz-repo]. This document aims to provide necessary information for working
+with fuzzing in GitPython.
+
+The latest details regarding OSS-Fuzz test status, including build logs and coverage reports, is available
+on [the Open Source Fuzzing Introspection website](https://introspector.oss-fuzz.com/project-profile?project=gitpython).
+
+## How to Contribute
+
+There are many ways to contribute to GitPython's fuzzing efforts! Contributions are welcomed through issues,
+discussions, or pull requests on this repository.
+
+Areas that are particularly appreciated include:
+
+- **Tackling the existing backlog of open issues**. While fuzzing is an effective way to identify bugs, that information
+  isn't useful unless they are fixed. If you are not sure where to start, the issues tab is a great place to get ideas!
+- **Improvements to this (or other) documentation** make it easier for new contributors to get involved, so even small
+  improvements can have a large impact over time. If you see something that could be made easier by a documentation
+  update of any size, please consider suggesting it!
+
+For everything else, such as expanding test coverage, optimizing test performance, or enhancing error detection
+capabilities, jump into the "Getting Started" section below.
+
+## Getting Started with Fuzzing GitPython
+
+> [!TIP]
+> **New to fuzzing or unfamiliar with OSS-Fuzz?**
+>
+> These resources are an excellent place to start:
+>
+> - [OSS-Fuzz documentation][oss-fuzz-docs] - Continuous fuzzing service for open source software.
+> - [Google/fuzzing][google-fuzzing-repo] - Tutorials, examples, discussions, research proposals, and other resources
+    related to fuzzing.
+> - [CNCF Fuzzing Handbook](https://github.com/cncf/tag-security/blob/main/security-fuzzing-handbook/handbook-fuzzing.pdf) -
+    A comprehensive guide for fuzzing open source software.
+> - [Efficient Fuzzing Guide by The Chromium Project](https://chromium.googlesource.com/chromium/src/+/main/testing/libfuzzer/efficient_fuzzing.md) -
+    Explores strategies to enhance the effectiveness of your fuzz tests, recommended for those looking to optimize their
+    testing efforts.
+
+### Setting Up Your Local Environment
+
+Before contributing to fuzzing efforts, ensure Python and Docker are installed on your machine. Docker is required for
+running fuzzers in containers provided by OSS-Fuzz and for safely executing test files directly. [Install Docker](https://docs.docker.com/get-docker/) following the official guide if you do not already have it.
+
+### Understanding Existing Fuzz Targets
+
+Review the `fuzz-targets/` directory to familiarize yourself with how existing tests are implemented. See
+the [Files & Directories Overview](#files--directories-overview) for more details on the directory structure.
+
+### Contributing to Fuzz Tests
+
+Start by reviewing the [Atheris documentation][atheris-repo] and the section
+on [Running Fuzzers Locally](#running-fuzzers-locally) to begin writing or improving fuzz tests.
+
+## Files & Directories Overview
+
+The `fuzzing/` directory is organized into three key areas:
+
+### Fuzz Targets (`fuzz-targets/`)
+
+Contains Python files for each fuzz test.
+
+**Things to Know**:
+
+- Each fuzz test targets a specific part of GitPython's functionality.
+- Test files adhere to the naming convention: `fuzz_<API Under Test>.py`, where `<API Under Test>` indicates the
+  functionality targeted by the test.
+- Any functionality that involves performing operations on input data is a possible candidate for fuzz testing, but
+  features that involve processing untrusted user input or parsing operations are typically going to be the most
+  interesting.
+- The goal of these tests is to identify previously unknown or unexpected error cases caused by a given input. For that
+  reason, fuzz tests should gracefully handle anticipated exception cases with a `try`/`except` block to avoid false
+  positives that halt the fuzzing engine.
+
+### OSS-Fuzz Scripts (`oss-fuzz-scripts/`)
+
+Includes scripts for building and integrating fuzz targets with OSS-Fuzz:
+
+- **`container-environment-bootstrap.sh`** - Sets up the execution environment. It is responsible for fetching default
+  dictionary entries and ensuring all required build dependencies are installed and up-to-date.
+- **`build.sh`** - Executed within the Docker container, this script builds fuzz targets with necessary instrumentation
+  and prepares seed corpora and dictionaries for use.
+
+**Where to learn more:**
+
+- [OSS-Fuzz documentation on the build.sh](https://google.github.io/oss-fuzz/getting-started/new-project-guide/#buildsh)
+- [See GitPython's build.sh and Dockerfile in the OSS-Fuzz repository](https://github.com/google/oss-fuzz/tree/master/projects/gitpython)
+
+### Local Development Helpers (`local-dev-helpers/`)
+
+Contains tools to make local development tasks easier.
+See [the "Running Fuzzers Locally" section below](#running-fuzzers-locally) for further documentation and use cases related to files found here.
+
+## Running Fuzzers Locally
+
+> [!WARNING]
+> **Some fuzz targets in this repository write to the filesystem** during execution.
+> For that reason, it is strongly recommended to **always use Docker when executing fuzz targets**, even when it may be
+> possible to do so without it.
+>
+> Although [I/O operations such as writing to disk are not considered best practice](https://github.com/google/fuzzing/blob/master/docs/good-fuzz-target.md#io), the current implementation of at least one test requires it. 
+> See [the "Setting Up Your Local Environment" section above](#setting-up-your-local-environment) if you do not already have Docker installed on your machine.
+>
+> PRs that replace disk I/O with in-memory alternatives are very much welcomed!
+
+### Direct Execution of Fuzz Targets
+
+Directly executing fuzz targets allows for quick iteration and testing of changes which can be helpful during early
+development of new fuzz targets or for validating changes made to an existing test.
+The [Dockerfile](./local-dev-helpers/Dockerfile) located in the `local-dev-helpers/` subdirectory provides a lightweight
+container environment preconfigured with [Atheris][atheris-repo] that makes it easy to execute a fuzz target directly.
+
+**From the root directory of your GitPython repository clone**:
+
+1. Build the local development helper image:
+
+```shell
+docker build -f fuzzing/local-dev-helpers/Dockerfile -t gitpython-fuzzdev .
+```
+
+2. Then execute a fuzz target inside the image, for example:
+
+```shell
+ docker run -it -v "$PWD":/src gitpython-fuzzdev python fuzzing/fuzz-targets/fuzz_config.py -atheris_runs=10000
+```
+
+The above command executes [`fuzz_config.py`](./fuzz-targets/fuzz_config.py) and exits after `10000` runs, or earlier if
+the fuzzer finds an error.
+
+Docker CLI's `-v` flag specifies a volume mount in Docker that maps the directory in which the command is run (which
+should be the root directory of your local GitPython clone) to a directory inside the container, so any modifications
+made between invocations will be reflected immediately without the need to rebuild the image each time.
+
+### Running OSS-Fuzz Locally
+
+This approach uses Docker images provided by OSS-Fuzz for building and running fuzz tests locally. It offers
+comprehensive features but requires a local clone of the OSS-Fuzz repository and sufficient disk space for Docker
+containers.
+
+#### Build the Execution Environment
+
+Clone the OSS-Fuzz repository and prepare the Docker environment:
+
+```shell
+git clone --depth 1 https://github.com/google/oss-fuzz.git oss-fuzz
+cd oss-fuzz
+python infra/helper.py build_image gitpython
+python infra/helper.py build_fuzzers --sanitizer address gitpython
+```
+
+> [!TIP]
+> The `build_fuzzers` command above accepts a local file path pointing to your GitPython repository clone as the last
+> argument.
+> This makes it easy to build fuzz targets you are developing locally in this repository without changing anything in
+> the OSS-Fuzz repo!
+> For example, if you have cloned this repository (or a fork of it) into: `~/code/GitPython`
+> Then running this command would build new or modified fuzz targets using the `~/code/GitPython/fuzzing/fuzz-targets`
+> directory:
+> ```shell
+> python infra/helper.py build_fuzzers --sanitizer address gitpython ~/code/GitPython
+> ```
+
+Verify the build of your fuzzers with the optional `check_build` command:
+
+```shell
+python infra/helper.py check_build gitpython
+```
+
+#### Run a Fuzz Target
+
+Setting an environment variable for the fuzz target argument of the execution command makes it easier to quickly select
+a different target between runs:
+
+```shell
+# specify the fuzz target without the .py extension:
+export FUZZ_TARGET=fuzz_config
+```
+
+Execute the desired fuzz target:
+
+```shell
+python infra/helper.py run_fuzzer gitpython $FUZZ_TARGET -- -max_total_time=60 -print_final_stats=1
+```
+
+> [!TIP]
+> In the example above, the "`-- -max_total_time=60 -print_final_stats=1`" portion of the command is optional but quite
+> useful.
+>
+> Every argument provided after "`--`" in the above command is passed to the fuzzing engine directly. In this case:
+> - `-max_total_time=60` tells the LibFuzzer to stop execution after 60 seconds have elapsed.
+> - `-print_final_stats=1` tells the LibFuzzer to print a summary of useful metrics about the target run upon
+    completion.
+>
+> But almost any [LibFuzzer option listed in the documentation](https://llvm.org/docs/LibFuzzer.html#options) should
+> work as well.
+
+#### Next Steps
+
+For detailed instructions on advanced features like reproducing OSS-Fuzz issues or using the Fuzz Introspector, refer
+to [the official OSS-Fuzz documentation][oss-fuzz-docs].
+
+## LICENSE
+
+All files located within the `fuzzing/` directory are subject to [the same license](../LICENSE)
+as [the other files in this repository](../README.md#license) with one exception:
+
+[`fuzz_config.py`](./fuzz-targets/fuzz_config.py) was migrated to this repository from the OSS-Fuzz project's repository
+where it was originally created. As such, [`fuzz_config.py`](./fuzz-targets/fuzz_config.py) retains its original license
+and copyright notice (Apache License, Version 2.0 and Copyright 2023 Google LLC respectively) as in a header
+comment, followed by a notice stating that it has have been modified contributors to GitPython.
+[LICENSE-APACHE](./LICENSE-APACHE) contains the original license used by the OSS-Fuzz project repository at the time the
+file was migrated.
+
+[oss-fuzz-repo]: https://github.com/google/oss-fuzz
+
+[oss-fuzz-docs]: https://google.github.io/oss-fuzz
+
+[oss-fuzz-issue-tracker]: https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:gitpython
+
+[google-fuzzing-repo]: https://github.com/google/fuzzing
+
+[atheris-repo]: https://github.com/google/atheris
diff --git a/fuzzing/fuzz-targets/fuzz_blob.py b/fuzzing/fuzz-targets/fuzz_blob.py
new file mode 100644
index 000000000..ce888e85f
--- /dev/null
+++ b/fuzzing/fuzz-targets/fuzz_blob.py
@@ -0,0 +1,40 @@
+import atheris
+import sys
+import os
+import tempfile
+
+if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
+    path_to_bundled_git_binary = os.path.abspath(os.path.join(os.path.dirname(__file__), "git"))
+    os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = path_to_bundled_git_binary
+
+with atheris.instrument_imports():
+    import git
+
+
+def TestOneInput(data):
+    fdp = atheris.FuzzedDataProvider(data)
+
+    with tempfile.TemporaryDirectory() as temp_dir:
+        repo = git.Repo.init(path=temp_dir)
+        binsha = fdp.ConsumeBytes(20)
+        mode = fdp.ConsumeInt(fdp.ConsumeIntInRange(0, fdp.remaining_bytes()))
+        path = fdp.ConsumeUnicodeNoSurrogates(fdp.remaining_bytes())
+
+        try:
+            blob = git.Blob(repo, binsha, mode, path)
+        except AssertionError as e:
+            if "Require 20 byte binary sha, got" in str(e):
+                return -1
+            else:
+                raise e
+
+        _ = blob.mime_type
+
+
+def main():
+    atheris.Setup(sys.argv, TestOneInput)
+    atheris.Fuzz()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/fuzzing/fuzz-targets/fuzz_config.py b/fuzzing/fuzz-targets/fuzz_config.py
new file mode 100644
index 000000000..4eddc32ff
--- /dev/null
+++ b/fuzzing/fuzz-targets/fuzz_config.py
@@ -0,0 +1,57 @@
+# Copyright 2023 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+###############################################################################
+# Note: This file has been modified by contributors to GitPython.
+# The original state of this file may be referenced here:
+# https://github.com/google/oss-fuzz/commit/f26f254558fc48f3c9bc130b10507386b94522da
+###############################################################################
+import atheris
+import sys
+import io
+import os
+from configparser import MissingSectionHeaderError, ParsingError
+
+if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
+    path_to_bundled_git_binary = os.path.abspath(os.path.join(os.path.dirname(__file__), "git"))
+    os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = path_to_bundled_git_binary
+
+with atheris.instrument_imports():
+    import git
+
+
+def TestOneInput(data):
+    sio = io.BytesIO(data)
+    sio.name = "/tmp/fuzzconfig.config"
+    git_config = git.GitConfigParser(sio)
+    try:
+        git_config.read()
+    except (MissingSectionHeaderError, ParsingError, UnicodeDecodeError):
+        return -1  # Reject inputs raising expected exceptions
+    except ValueError as e:
+        if "embedded null byte" in str(e):
+            # The `os.path.expanduser` function, which does not accept strings
+            # containing null bytes might raise this.
+            return -1
+        else:
+            raise e  # Raise unanticipated exceptions as they might be bugs
+
+
+def main():
+    atheris.Setup(sys.argv, TestOneInput)
+    atheris.Fuzz()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/fuzzing/fuzz-targets/fuzz_diff.py b/fuzzing/fuzz-targets/fuzz_diff.py
new file mode 100644
index 000000000..d4bd68b57
--- /dev/null
+++ b/fuzzing/fuzz-targets/fuzz_diff.py
@@ -0,0 +1,86 @@
+import sys
+import os
+import io
+import tempfile
+from binascii import Error as BinasciiError
+
+import atheris
+
+if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
+    path_to_bundled_git_binary = os.path.abspath(os.path.join(os.path.dirname(__file__), "git"))
+    os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = path_to_bundled_git_binary
+
+with atheris.instrument_imports():
+    from git import Repo, Diff
+
+
+class BytesProcessAdapter:
+    """Allows bytes to be used as process objects returned by subprocess.Popen."""
+
+    @atheris.instrument_func
+    def __init__(self, input_string):
+        self.stdout = io.BytesIO(input_string)
+        self.stderr = io.BytesIO()
+
+    @atheris.instrument_func
+    def wait(self):
+        return 0
+
+    poll = wait
+
+
+@atheris.instrument_func
+def TestOneInput(data):
+    fdp = atheris.FuzzedDataProvider(data)
+
+    with tempfile.TemporaryDirectory() as temp_dir:
+        repo = Repo.init(path=temp_dir)
+        try:
+            diff = Diff(
+                repo,
+                a_rawpath=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())),
+                b_rawpath=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())),
+                a_blob_id=fdp.ConsumeBytes(20),
+                b_blob_id=fdp.ConsumeBytes(20),
+                a_mode=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())),
+                b_mode=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())),
+                new_file=fdp.ConsumeBool(),
+                deleted_file=fdp.ConsumeBool(),
+                copied_file=fdp.ConsumeBool(),
+                raw_rename_from=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())),
+                raw_rename_to=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())),
+                diff=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())),
+                change_type=fdp.PickValueInList(["A", "D", "C", "M", "R", "T", "U"]),
+                score=fdp.ConsumeIntInRange(0, fdp.remaining_bytes()),
+            )
+        except BinasciiError:
+            return -1
+        except AssertionError as e:
+            if "Require 20 byte binary sha, got" in str(e):
+                return -1
+            else:
+                raise e
+
+        _ = diff.__str__()
+        _ = diff.a_path
+        _ = diff.b_path
+        _ = diff.rename_from
+        _ = diff.rename_to
+        _ = diff.renamed_file
+
+        diff_index = diff._index_from_patch_format(
+            repo, proc=BytesProcessAdapter(fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())))
+        )
+
+        diff._handle_diff_line(
+            lines_bytes=fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, fdp.remaining_bytes())), repo=repo, index=diff_index
+        )
+
+
+def main():
+    atheris.Setup(sys.argv, TestOneInput)
+    atheris.Fuzz()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/fuzzing/fuzz-targets/fuzz_repo.py b/fuzzing/fuzz-targets/fuzz_repo.py
new file mode 100644
index 000000000..7bd82c120
--- /dev/null
+++ b/fuzzing/fuzz-targets/fuzz_repo.py
@@ -0,0 +1,47 @@
+import atheris
+import io
+import sys
+import os
+import tempfile
+
+if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
+    path_to_bundled_git_binary = os.path.abspath(os.path.join(os.path.dirname(__file__), "git"))
+    os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = path_to_bundled_git_binary
+
+with atheris.instrument_imports():
+    import git
+
+
+def TestOneInput(data):
+    fdp = atheris.FuzzedDataProvider(data)
+
+    with tempfile.TemporaryDirectory() as temp_dir:
+        repo = git.Repo.init(path=temp_dir)
+
+        # Generate a minimal set of files based on fuzz data to minimize I/O operations.
+        file_paths = [os.path.join(temp_dir, f"File{i}") for i in range(min(3, fdp.ConsumeIntInRange(1, 3)))]
+        for file_path in file_paths:
+            with open(file_path, "wb") as f:
+                # The chosen upperbound for count of bytes we consume by writing to these
+                # files is somewhat arbitrary and may be worth experimenting with if the
+                # fuzzer coverage plateaus.
+                f.write(fdp.ConsumeBytes(fdp.ConsumeIntInRange(1, 512)))
+
+        repo.index.add(file_paths)
+        repo.index.commit(fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(1, 80)))
+
+        fuzz_tree = git.Tree(repo, git.Tree.NULL_BIN_SHA, 0, "")
+
+        try:
+            fuzz_tree._deserialize(io.BytesIO(data))
+        except IndexError:
+            return -1
+
+
+def main():
+    atheris.Setup(sys.argv, TestOneInput)
+    atheris.Fuzz()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/fuzzing/fuzz-targets/fuzz_submodule.py b/fuzzing/fuzz-targets/fuzz_submodule.py
new file mode 100644
index 000000000..afa653d0d
--- /dev/null
+++ b/fuzzing/fuzz-targets/fuzz_submodule.py
@@ -0,0 +1,125 @@
+import atheris
+import sys
+import os
+import tempfile
+from configparser import ParsingError
+from utils import (
+    setup_git_environment,
+    handle_exception,
+    get_max_filename_length,
+)
+
+# Setup the Git environment
+setup_git_environment()
+from git import Repo, GitCommandError, InvalidGitRepositoryError
+
+
+def sanitize_input(input_str, max_length=255):
+    """Sanitize and truncate inputs to avoid invalid Git operations."""
+    sanitized = "".join(ch for ch in input_str if ch.isalnum() or ch in ("-", "_", "."))
+    return sanitized[:max_length]
+
+
+def TestOneInput(data):
+    fdp = atheris.FuzzedDataProvider(data)
+
+    with tempfile.TemporaryDirectory() as repo_temp_dir:
+        repo = Repo.init(path=repo_temp_dir)
+        repo.index.commit("Initial commit")
+
+        try:
+            with tempfile.TemporaryDirectory() as submodule_temp_dir:
+                sub_repo = Repo.init(submodule_temp_dir, bare=fdp.ConsumeBool())
+                commit_message = sanitize_input(fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(1, 512)))
+                sub_repo.index.commit(commit_message)
+
+                submodule_name = sanitize_input(
+                    fdp.ConsumeUnicodeNoSurrogates(
+                        fdp.ConsumeIntInRange(1, get_max_filename_length(repo.working_tree_dir))
+                    )
+                )
+
+                submodule_path = os.path.relpath(
+                    os.path.join(repo.working_tree_dir, submodule_name),
+                    start=repo.working_tree_dir,
+                )
+
+                # Ensure submodule_path is valid
+                if not submodule_name or submodule_name.startswith("/") or ".." in submodule_name:
+                    return -1  # Reject invalid input so they are not added to the corpus
+
+                submodule = repo.create_submodule(submodule_name, submodule_path, url=sub_repo.git_dir)
+                repo.index.commit("Added submodule")
+
+                with submodule.config_writer() as writer:
+                    key_length = fdp.ConsumeIntInRange(1, max(1, fdp.remaining_bytes()))
+                    value_length = fdp.ConsumeIntInRange(1, max(1, fdp.remaining_bytes()))
+
+                    writer.set_value(
+                        sanitize_input(fdp.ConsumeUnicodeNoSurrogates(key_length)),
+                        sanitize_input(fdp.ConsumeUnicodeNoSurrogates(value_length)),
+                    )
+                    writer.release()
+
+                submodule.update(
+                    init=fdp.ConsumeBool(),
+                    dry_run=fdp.ConsumeBool(),
+                    force=fdp.ConsumeBool(),
+                )
+
+                submodule_repo = submodule.module()
+
+                new_file_name = sanitize_input(
+                    fdp.ConsumeUnicodeNoSurrogates(
+                        fdp.ConsumeIntInRange(1, get_max_filename_length(submodule_repo.working_tree_dir))
+                    )
+                )
+                new_file_path = os.path.join(submodule_repo.working_tree_dir, new_file_name)
+                with open(new_file_path, "wb") as new_file:
+                    new_file.write(fdp.ConsumeBytes(fdp.ConsumeIntInRange(1, 512)))
+
+                submodule_repo.index.add([new_file_path])
+                submodule_repo.index.commit("Added new file to submodule")
+
+                repo.submodule_update(recursive=fdp.ConsumeBool())
+                submodule_repo.head.reset(
+                    commit="HEAD~1",
+                    working_tree=fdp.ConsumeBool(),
+                    head=fdp.ConsumeBool(),
+                )
+
+                module_option_value, configuration_option_value = fdp.PickValueInList(
+                    [(True, False), (False, True), (True, True)]
+                )
+                submodule.remove(
+                    module=module_option_value,
+                    configuration=configuration_option_value,
+                    dry_run=fdp.ConsumeBool(),
+                    force=fdp.ConsumeBool(),
+                )
+                repo.index.commit(f"Removed submodule {submodule_name}")
+
+        except (
+            ParsingError,
+            GitCommandError,
+            InvalidGitRepositoryError,
+            FileNotFoundError,
+            FileExistsError,
+            IsADirectoryError,
+            NotADirectoryError,
+            BrokenPipeError,
+            PermissionError,
+        ):
+            return -1
+        except Exception as e:
+            return handle_exception(e)
+
+
+def main():
+    atheris.instrument_all()
+    atheris.Setup(sys.argv, TestOneInput)
+    atheris.Fuzz()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/fuzzing/fuzz-targets/utils.py b/fuzzing/fuzz-targets/utils.py
new file mode 100644
index 000000000..97e6eab98
--- /dev/null
+++ b/fuzzing/fuzz-targets/utils.py
@@ -0,0 +1,122 @@
+import atheris  # pragma: no cover
+import os  # pragma: no cover
+import re  # pragma: no cover
+import traceback  # pragma: no cover
+import sys  # pragma: no cover
+from typing import Set, Tuple, List  # pragma: no cover
+
+
+@atheris.instrument_func
+def is_expected_exception_message(exception: Exception, error_message_list: List[str]) -> bool:  # pragma: no cover
+    """
+    Checks if the message of a given exception matches any of the expected error messages, case-insensitively.
+
+    Args:
+         exception (Exception): The exception object raised during execution.
+         error_message_list (List[str]): A list of error message substrings to check against the exception's message.
+
+    Returns:
+      bool: True if the exception's message contains any of the substrings from the error_message_list,
+      case-insensitively, otherwise False.
+    """
+    exception_message = str(exception).lower()
+    for error in error_message_list:
+        if error.lower() in exception_message:
+            return True
+    return False
+
+
+@atheris.instrument_func
+def get_max_filename_length(path: str) -> int:  # pragma: no cover
+    """
+    Get the maximum filename length for the filesystem containing the given path.
+
+    Args:
+        path (str): The path to check the filesystem for.
+
+    Returns:
+        int: The maximum filename length.
+    """
+    return os.pathconf(path, "PC_NAME_MAX")
+
+
+@atheris.instrument_func
+def read_lines_from_file(file_path: str) -> list:
+    """Read lines from a file and return them as a list."""
+    try:
+        with open(file_path, "r") as f:
+            return [line.strip() for line in f if line.strip()]
+    except FileNotFoundError:
+        print(f"File not found: {file_path}")
+        return []
+    except IOError as e:
+        print(f"Error reading file {file_path}: {e}")
+        return []
+
+
+@atheris.instrument_func
+def load_exception_list(file_path: str = "explicit-exceptions-list.txt") -> Set[Tuple[str, str]]:
+    """Load and parse the exception list from a default or specified file."""
+    try:
+        bundle_dir = os.path.dirname(os.path.abspath(__file__))
+        full_path = os.path.join(bundle_dir, file_path)
+        lines = read_lines_from_file(full_path)
+        exception_list: Set[Tuple[str, str]] = set()
+        for line in lines:
+            match = re.match(r"(.+):(\d+):", line)
+            if match:
+                file_path: str = match.group(1).strip()
+                line_number: str = str(match.group(2).strip())
+                exception_list.add((file_path, line_number))
+        return exception_list
+    except Exception as e:
+        print(f"Error loading exception list: {e}")
+        return set()
+
+
+@atheris.instrument_func
+def match_exception_with_traceback(exception_list: Set[Tuple[str, str]], exc_traceback) -> bool:
+    """Match exception traceback with the entries in the exception list."""
+    for filename, lineno, _, _ in traceback.extract_tb(exc_traceback):
+        for file_pattern, line_pattern in exception_list:
+            # Ensure filename and line_number are strings for regex matching
+            if re.fullmatch(file_pattern, filename) and re.fullmatch(line_pattern, str(lineno)):
+                return True
+    return False
+
+
+@atheris.instrument_func
+def check_exception_against_list(exc_traceback, exception_file: str = "explicit-exceptions-list.txt") -> bool:
+    """Check if the exception traceback matches any entry in the exception list."""
+    exception_list = load_exception_list(exception_file)
+    return match_exception_with_traceback(exception_list, exc_traceback)
+
+
+@atheris.instrument_func
+def handle_exception(e: Exception) -> int:
+    """Encapsulate exception handling logic for reusability."""
+    exc_traceback = e.__traceback__
+    if check_exception_against_list(exc_traceback):
+        return -1
+    else:
+        raise e
+
+
+@atheris.instrument_func
+def setup_git_environment() -> None:
+    """Set up the environment variables for Git."""
+    bundle_dir = os.path.dirname(os.path.abspath(__file__))
+    if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):  # pragma: no cover
+        bundled_git_binary_path = os.path.join(bundle_dir, "git")
+        os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = bundled_git_binary_path
+
+    if not sys.warnoptions:  # pragma: no cover
+        # The warnings filter below can be overridden by passing the -W option
+        # to the Python interpreter command line or setting the `PYTHONWARNINGS` environment variable.
+        import warnings
+        import logging
+
+        # Fuzzing data causes some modules to generate a large number of warnings
+        # which are not usually interesting and make the test output hard to read, so we ignore them.
+        warnings.simplefilter("ignore")
+        logging.getLogger().setLevel(logging.ERROR)
diff --git a/fuzzing/local-dev-helpers/Dockerfile b/fuzzing/local-dev-helpers/Dockerfile
new file mode 100644
index 000000000..426de05dd
--- /dev/null
+++ b/fuzzing/local-dev-helpers/Dockerfile
@@ -0,0 +1,22 @@
+# syntax=docker/dockerfile:1
+
+# Use the same Python version as OSS-Fuzz to accidental incompatibilities in test code
+FROM python:3.8-bookworm
+
+LABEL project="GitPython Fuzzing Local Dev Helper"
+
+WORKDIR /src
+
+COPY . .
+
+# Update package managers, install necessary packages, and cleanup unnecessary files in a single RUN to keep the image smaller.
+RUN apt-get update && \
+    apt-get install -y git clang && \
+    python -m pip install --upgrade pip && \
+    python -m pip install atheris && \
+    python -m pip install -e . && \
+    apt-get clean && \
+    apt-get autoremove -y && \
+    rm -rf /var/lib/apt/lists/*
+
+CMD ["bash"]
diff --git a/fuzzing/oss-fuzz-scripts/build.sh b/fuzzing/oss-fuzz-scripts/build.sh
new file mode 100644
index 000000000..c156e872d
--- /dev/null
+++ b/fuzzing/oss-fuzz-scripts/build.sh
@@ -0,0 +1,19 @@
+# shellcheck shell=bash
+#
+# This file is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+set -euo pipefail
+
+python3 -m pip install .
+
+find "$SRC" -maxdepth 1 \
+  \( -name '*_seed_corpus.zip' -o -name '*.options' -o -name '*.dict' \) \
+  -exec printf '[%s] Copying: %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" {} \; \
+  -exec chmod a-x {} \; \
+  -exec cp {} "$OUT" \;
+
+# Build fuzzers in $OUT.
+find "$SRC/gitpython/fuzzing" -name 'fuzz_*.py' -print0 | while IFS= read -r -d '' fuzz_harness; do
+  compile_python_fuzzer "$fuzz_harness" --add-binary="$(command -v git):." --add-data="$SRC/explicit-exceptions-list.txt:."
+done
diff --git a/fuzzing/oss-fuzz-scripts/container-environment-bootstrap.sh b/fuzzing/oss-fuzz-scripts/container-environment-bootstrap.sh
new file mode 100755
index 000000000..924a3cbf3
--- /dev/null
+++ b/fuzzing/oss-fuzz-scripts/container-environment-bootstrap.sh
@@ -0,0 +1,108 @@
+#!/usr/bin/env bash
+#
+# This file is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+set -euo pipefail
+
+#################
+# Prerequisites #
+#################
+
+for cmd in python3 git wget zip; do
+  command -v "$cmd" >/dev/null 2>&1 || {
+    printf '[%s] Required command %s not found, exiting.\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$cmd" >&2
+    exit 1
+  }
+done
+
+#############
+# Functions #
+#############
+
+download_and_concatenate_common_dictionaries() {
+  # Assign the first argument as the target file where all contents will be concatenated
+  local target_file="$1"
+
+  # Shift the arguments so the first argument (target_file path) is removed
+  # and only URLs are left for the loop below.
+  shift
+
+  for url in "$@"; do
+    wget -qO- "$url" >>"$target_file"
+    # Ensure there's a newline between each file's content
+    echo >>"$target_file"
+  done
+}
+
+create_seed_corpora_zips() {
+  local seed_corpora_dir="$1"
+  local output_zip
+  for dir in "$seed_corpora_dir"/*; do
+    if [ -d "$dir" ] && [ -n "$dir" ]; then
+      output_zip="$SRC/$(basename "$dir")_seed_corpus.zip"
+      printf '[%s] Zipping the contents of %s into %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$dir" "$output_zip"
+      zip -jur "$output_zip" "$dir"/*
+    fi
+  done
+}
+
+prepare_dictionaries_for_fuzz_targets() {
+  local dictionaries_dir="$1"
+  local fuzz_targets_dir="$2"
+  local common_base_dictionary_filename="$WORK/__base.dict"
+
+  printf '[%s] Copying .dict files from %s to %s\n' "$(date '+%Y-%m-%d %H:%M:%S')"  "$dictionaries_dir" "$SRC/"
+  cp -v "$dictionaries_dir"/*.dict "$SRC/"
+
+  download_and_concatenate_common_dictionaries "$common_base_dictionary_filename" \
+    "https://raw.githubusercontent.com/google/fuzzing/master/dictionaries/utf8.dict" \
+    "https://raw.githubusercontent.com/google/fuzzing/master/dictionaries/url.dict"
+
+  find "$fuzz_targets_dir" -name 'fuzz_*.py' -print0 | while IFS= read -r -d '' fuzz_harness; do
+    if [[ -r "$common_base_dictionary_filename" ]]; then
+      # Strip the `.py` extension from the filename and replace it with `.dict`.
+      fuzz_harness_dictionary_filename="$(basename "$fuzz_harness" .py).dict"
+      local output_file="$SRC/$fuzz_harness_dictionary_filename"
+
+      printf '[%s] Appending %s to %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$common_base_dictionary_filename" "$output_file"
+      if [[ -s "$output_file" ]]; then
+        # If a dictionary file for this fuzzer already exists and is not empty,
+        # we append a new line to the end of it before appending any new entries.
+        #
+        # LibFuzzer will happily ignore multiple empty lines in a dictionary but fail with an error
+        # if any single line has incorrect syntax (e.g., if we accidentally add two entries to the same line.)
+        # See docs for valid syntax: https://llvm.org/docs/LibFuzzer.html#id32
+        echo >>"$output_file"
+      fi
+      cat "$common_base_dictionary_filename" >>"$output_file"
+    fi
+  done
+}
+
+########################
+# Main execution logic #
+########################
+# Seed corpora and dictionaries are hosted in a separate repository to avoid additional bloat in this repo.
+# We clone into the $WORK directory because OSS-Fuzz cleans it up after building the image, keeping the image small.
+git clone --depth 1 https://github.com/gitpython-developers/qa-assets.git "$WORK/qa-assets"
+
+create_seed_corpora_zips "$WORK/qa-assets/gitpython/corpora"
+
+prepare_dictionaries_for_fuzz_targets "$WORK/qa-assets/gitpython/dictionaries" "$SRC/gitpython/fuzzing"
+
+pushd "$SRC/gitpython/"
+# Search for 'raise' and 'assert' statements in Python files within GitPython's source code and submodules, saving the
+# matched file path, line number, and line content to a file named 'explicit-exceptions-list.txt'.
+# This file can then be used by fuzz harnesses to check exception tracebacks and filter out explicitly raised or otherwise
+# anticipated exceptions to reduce false positive test failures.
+
+git grep -n --recurse-submodules -e '\braise\b' -e '\bassert\b' -- '*.py' -- ':!setup.py' -- ':!test/**' -- ':!fuzzing/**' > "$SRC/explicit-exceptions-list.txt"
+
+popd
+
+
+# The OSS-Fuzz base image has outdated dependencies by default so we upgrade them below.
+python3 -m pip install --upgrade pip
+# Upgrade to the latest versions known to work at the time the below changes were introduced:
+python3 -m pip install 'setuptools~=69.0' 'pyinstaller~=6.0'
diff --git a/git/__init__.py b/git/__init__.py
index 5630b91d0..1b2360e3a 100644
--- a/git/__init__.py
+++ b/git/__init__.py
@@ -1,54 +1,300 @@
-# __init__.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-# flake8: noqa
-
-import os
-import sys
-import inspect
-
-__version__ = 'git'
-
-
-#{ Initialization
-def _init_externals():
-    """Initialize external projects by putting them into the path"""
-    sys.path.append(os.path.join(os.path.dirname(__file__), 'ext', 'gitdb'))
-
-    try:
-        import gitdb
-    except ImportError:
-        raise ImportError("'gitdb' could not be found in your PYTHONPATH")
-    # END verify import
-
-#} END initialization
-
-#################
-_init_externals()
-#################
-
-#{ Imports
-
-from git.config import GitConfigParser
-from git.objects import *
-from git.refs import *
-from git.diff import *
-from git.exc import *
-from git.db import *
-from git.cmd import Git
-from git.repo import Repo
-from git.remote import *
-from git.index import *
-from git.util import (
-    LockFile,
-    BlockingLockFile,
-    Stats,
-    Actor
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+# @PydevCodeAnalysisIgnore
+
+__all__ = [
+    "Actor",
+    "AmbiguousObjectName",
+    "BadName",
+    "BadObject",
+    "BadObjectType",
+    "BaseIndexEntry",
+    "Blob",
+    "BlobFilter",
+    "BlockingLockFile",
+    "CacheError",
+    "CheckoutError",
+    "CommandError",
+    "Commit",
+    "Diff",
+    "DiffConstants",
+    "DiffIndex",
+    "Diffable",
+    "FetchInfo",
+    "Git",
+    "GitCmdObjectDB",
+    "GitCommandError",
+    "GitCommandNotFound",
+    "GitConfigParser",
+    "GitDB",
+    "GitError",
+    "HEAD",
+    "Head",
+    "HookExecutionError",
+    "INDEX",
+    "IndexEntry",
+    "IndexFile",
+    "IndexObject",
+    "InvalidDBRoot",
+    "InvalidGitRepositoryError",
+    "List",  # Deprecated - import this from `typing` instead.
+    "LockFile",
+    "NULL_TREE",
+    "NoSuchPathError",
+    "ODBError",
+    "Object",
+    "Optional",  # Deprecated - import this from `typing` instead.
+    "ParseError",
+    "PathLike",
+    "PushInfo",
+    "RefLog",
+    "RefLogEntry",
+    "Reference",
+    "Remote",
+    "RemoteProgress",
+    "RemoteReference",
+    "Repo",
+    "RepositoryDirtyError",
+    "RootModule",
+    "RootUpdateProgress",
+    "Sequence",  # Deprecated - import from `typing`, or `collections.abc` in 3.9+.
+    "StageType",
+    "Stats",
+    "Submodule",
+    "SymbolicReference",
+    "TYPE_CHECKING",  # Deprecated - import this from `typing` instead.
+    "Tag",
+    "TagObject",
+    "TagReference",
+    "Tree",
+    "TreeModifier",
+    "Tuple",  # Deprecated - import this from `typing` instead.
+    "Union",  # Deprecated - import this from `typing` instead.
+    "UnmergedEntriesError",
+    "UnsafeOptionError",
+    "UnsafeProtocolError",
+    "UnsupportedOperation",
+    "UpdateProgress",
+    "WorkTreeRepositoryUnsupported",
+    "refresh",
+    "remove_password_if_present",
+    "rmtree",
+    "safe_decode",
+    "to_hex_sha",
+]
+
+__version__ = "git"
+
+from typing import Any, List, Optional, Sequence, TYPE_CHECKING, Tuple, Union
+
+if TYPE_CHECKING:
+    from types import ModuleType
+
+import warnings
+
+from gitdb.util import to_hex_sha
+
+from git.exc import (
+    AmbiguousObjectName,
+    BadName,
+    BadObject,
+    BadObjectType,
+    CacheError,
+    CheckoutError,
+    CommandError,
+    GitCommandError,
+    GitCommandNotFound,
+    GitError,
+    HookExecutionError,
+    InvalidDBRoot,
+    InvalidGitRepositoryError,
+    NoSuchPathError,
+    ODBError,
+    ParseError,
+    RepositoryDirtyError,
+    UnmergedEntriesError,
+    UnsafeOptionError,
+    UnsafeProtocolError,
+    UnsupportedOperation,
+    WorkTreeRepositoryUnsupported,
 )
+from git.types import PathLike
+
+try:
+    from git.compat import safe_decode  # @NoMove
+    from git.config import GitConfigParser  # @NoMove
+    from git.objects import (  # @NoMove
+        Blob,
+        Commit,
+        IndexObject,
+        Object,
+        RootModule,
+        RootUpdateProgress,
+        Submodule,
+        TagObject,
+        Tree,
+        TreeModifier,
+        UpdateProgress,
+    )
+    from git.refs import (  # @NoMove
+        HEAD,
+        Head,
+        RefLog,
+        RefLogEntry,
+        Reference,
+        RemoteReference,
+        SymbolicReference,
+        Tag,
+        TagReference,
+    )
+    from git.diff import (  # @NoMove
+        INDEX,
+        NULL_TREE,
+        Diff,
+        DiffConstants,
+        DiffIndex,
+        Diffable,
+    )
+    from git.db import GitCmdObjectDB, GitDB  # @NoMove
+    from git.cmd import Git  # @NoMove
+    from git.repo import Repo  # @NoMove
+    from git.remote import FetchInfo, PushInfo, Remote, RemoteProgress  # @NoMove
+    from git.index import (  # @NoMove
+        BaseIndexEntry,
+        BlobFilter,
+        CheckoutError,
+        IndexEntry,
+        IndexFile,
+        StageType,
+        # NOTE: This tells type checkers what util resolves to. We delete it, and it is
+        # really resolved by __getattr__, which warns. See below on what to use instead.
+        util,
+    )
+    from git.util import (  # @NoMove
+        Actor,
+        BlockingLockFile,
+        LockFile,
+        Stats,
+        remove_password_if_present,
+        rmtree,
+    )
+except GitError as _exc:
+    raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc
+
+
+def _warned_import(message: str, fullname: str) -> "ModuleType":
+    import importlib
+
+    warnings.warn(message, DeprecationWarning, stacklevel=3)
+    return importlib.import_module(fullname)
+
+
+def _getattr(name: str) -> Any:
+    # TODO: If __version__ is made dynamic and lazily fetched, put that case right here.
+
+    if name == "util":
+        return _warned_import(
+            "The expression `git.util` and the import `from git import util` actually "
+            "reference git.index.util, and not the git.util module accessed in "
+            '`from git.util import XYZ` or `sys.modules["git.util"]`. This potentially '
+            "confusing behavior is currently preserved for compatibility, but may be "
+            "changed in the future and should not be relied on.",
+            fullname="git.index.util",
+        )
+
+    for names, prefix in (
+        ({"head", "log", "reference", "symbolic", "tag"}, "git.refs"),
+        ({"base", "fun", "typ"}, "git.index"),
+    ):
+        if name not in names:
+            continue
+
+        fullname = f"{prefix}.{name}"
+
+        return _warned_import(
+            f"{__name__}.{name} is a private alias of {fullname} and subject to "
+            f"immediate removal. Use {fullname} instead.",
+            fullname=fullname,
+        )
+
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
+
+
+if not TYPE_CHECKING:
+    # NOTE: The expression `git.util` gives git.index.util and `from git import util`
+    # imports git.index.util, NOT git.util. It may not be feasible to change this until
+    # the next major version, to avoid breaking code inadvertently relying on it.
+    #
+    # - If git.index.util *is* what you want, use (or import from) that, to avoid
+    #   confusion.
+    #
+    # - To use the "real" git.util module, write `from git.util import ...`, or if
+    #   necessary access it as `sys.modules["git.util"]`.
+    #
+    # Note also that `import git.util` technically imports the "real" git.util... but
+    # the *expression* `git.util` after doing so is still git.index.util!
+    #
+    # (This situation differs from that of other indirect-submodule imports that are
+    # unambiguously non-public and subject to immediate removal. Here, the public
+    # git.util module, though different, makes less discoverable that the expression
+    # `git.util` refers to a non-public attribute of the git module.)
+    #
+    # This had originally come about by a wildcard import. Now that all intended imports
+    # are explicit, the intuitive but potentially incompatible binding occurs due to the
+    # usual rules for Python submodule bindings. So for now we replace that binding with
+    # git.index.util, delete that, and let __getattr__ handle it and issue a warning.
+    #
+    # For the same runtime behavior, it would be enough to forgo importing util, and
+    # delete util as created naturally; __getattr__ would behave the same. But type
+    # checkers would not know what util refers to when accessed as an attribute of git.
+    del util
+
+    # This is "hidden" to preserve static checking for undefined/misspelled attributes.
+    __getattr__ = _getattr
+
+# { Initialize git executable path
+
+GIT_OK = None
+
+
+def refresh(path: Optional[PathLike] = None) -> None:
+    """Convenience method for setting the git executable path.
+
+    :param path:
+        Optional path to the Git executable. If not absolute, it is resolved
+        immediately, relative to the current directory.
+
+    :note:
+        The `path` parameter is usually omitted and cannot be used to specify a custom
+        command whose location is looked up in a path search on each call. See
+        :meth:`Git.refresh <git.cmd.Git.refresh>` for details on how to achieve this.
+
+    :note:
+        This calls :meth:`Git.refresh <git.cmd.Git.refresh>` and sets other global
+        configuration according to the effect of doing so. As such, this function should
+        usually be used instead of using :meth:`Git.refresh <git.cmd.Git.refresh>` or
+        :meth:`FetchInfo.refresh <git.remote.FetchInfo.refresh>` directly.
+
+    :note:
+        This function is called automatically, with no arguments, at import time.
+    """
+    global GIT_OK
+    GIT_OK = False
+
+    if not Git.refresh(path=path):
+        return
+    if not FetchInfo.refresh():  # noqa: F405
+        return  # type: ignore[unreachable]
+
+    GIT_OK = True
+
 
-#} END imports
+try:
+    refresh()
+except Exception as _exc:
+    raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc
 
-__all__ = [name for name, obj in locals().items()
-           if not (name.startswith('_') or inspect.ismodule(obj))]
+# } END initialize git executable path
diff --git a/git/cmd.py b/git/cmd.py
index 4ceebb4ca..15d7820df 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -1,45 +1,95 @@
-# cmd.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
+from __future__ import annotations
+
+__all__ = ["GitMeta", "Git"]
+
+import contextlib
+import io
+import itertools
+import logging
 import os
+import re
+import signal
+import subprocess
+from subprocess import DEVNULL, PIPE, Popen
 import sys
-import select
-import logging
+from textwrap import dedent
 import threading
-from subprocess import (
-    call,
-    Popen,
-    PIPE
+import warnings
+
+from git.compat import defenc, force_bytes, safe_decode
+from git.exc import (
+    CommandError,
+    GitCommandError,
+    GitCommandNotFound,
+    UnsafeOptionError,
+    UnsafeProtocolError,
 )
-
-
-from .util import (
-    LazyMixin,
+from git.util import (
+    cygpath,
+    expand_path,
+    is_cygwin_git,
+    patch_env,
+    remove_password_if_present,
     stream_copy,
-    WaitGroup
 )
-from .exc import GitCommandError
-from git.compat import (
-    string_types,
-    defenc,
-    PY3,
-    # just to satisfy flake8 on py3
-    unicode
+
+# typing ---------------------------------------------------------------------------
+
+from typing import (
+    Any,
+    AnyStr,
+    BinaryIO,
+    Callable,
+    Dict,
+    IO,
+    Iterator,
+    List,
+    Mapping,
+    Optional,
+    Sequence,
+    TYPE_CHECKING,
+    TextIO,
+    Tuple,
+    Union,
+    cast,
+    overload,
 )
 
-execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output',
-                  'with_exceptions', 'as_process', 'stdout_as_string',
-                  'output_stream')
+if sys.version_info >= (3, 10):
+    from typing import TypeAlias
+else:
+    from typing_extensions import TypeAlias
+
+from git.types import Literal, PathLike, TBD
 
-log = logging.getLogger('git.cmd')
+if TYPE_CHECKING:
+    from git.diff import DiffIndex
+    from git.repo.base import Repo
 
-__all__ = ('Git', )
+# ---------------------------------------------------------------------------------
 
-if sys.platform != 'win32':
-    WindowsError = OSError
+execute_kwargs = {
+    "istream",
+    "with_extended_output",
+    "with_exceptions",
+    "as_process",
+    "output_stream",
+    "stdout_as_string",
+    "kill_after_timeout",
+    "with_stdout",
+    "universal_newlines",
+    "shell",
+    "env",
+    "max_chunk_size",
+    "strip_newline_in_stdout",
+}
+
+_logger = logging.getLogger(__name__)
 
 
 # ==============================================================================
@@ -48,125 +98,519 @@
 # Documentation
 ## @{
 
-def handle_process_output(process, stdout_handler, stderr_handler, finalizer):
-    """Registers for notifications to lean that process output is ready to read, and dispatches lines to
-    the respective line handlers. We are able to handle carriage returns in case progress is sent by that
-    mean. For performance reasons, we only apply this to stderr.
-    This function returns once the finalizer returns
-    :return: result of finalizer
-    :param process: subprocess.Popen instance
-    :param stdout_handler: f(stdout_line_string), or None
-    :param stderr_hanlder: f(stderr_line_string), or None
-    :param finalizer: f(proc) - wait for proc to finish"""
-    def read_line_fast(stream):
-        return stream.readline()
-
-    def read_line_slow(stream):
-        line = b''
-        while True:
-            char = stream.read(1)       # reads individual single byte strings
-            if not char:
-                break
 
-            if char in (b'\r', b'\n') and line:
-                break
-            else:
-                line += char
-            # END process parsed line
-        # END while file is not done reading
-        return line
-    # end
+def handle_process_output(
+    process: "Git.AutoInterrupt" | Popen,
+    stdout_handler: Union[
+        None,
+        Callable[[AnyStr], None],
+        Callable[[List[AnyStr]], None],
+        Callable[[bytes, "Repo", "DiffIndex"], None],
+    ],
+    stderr_handler: Union[None, Callable[[AnyStr], None], Callable[[List[AnyStr]], None]],
+    finalizer: Union[None, Callable[[Union[Popen, "Git.AutoInterrupt"]], None]] = None,
+    decode_streams: bool = True,
+    kill_after_timeout: Union[None, float] = None,
+) -> None:
+    R"""Register for notifications to learn that process output is ready to read, and
+    dispatch lines to the respective line handlers.
+
+    This function returns once the finalizer returns.
+
+    :param process:
+        :class:`subprocess.Popen` instance.
+
+    :param stdout_handler:
+        f(stdout_line_string), or ``None``.
+
+    :param stderr_handler:
+        f(stderr_line_string), or ``None``.
+
+    :param finalizer:
+        f(proc) - wait for proc to finish.
+
+    :param decode_streams:
+        Assume stdout/stderr streams are binary and decode them before pushing their
+        contents to handlers.
+
+        This defaults to ``True``. Set it to ``False`` if:
+
+        - ``universal_newlines == True``, as then streams are in text mode, or
+        - decoding must happen later, such as for :class:`~git.diff.Diff`\s.
+
+    :param kill_after_timeout:
+        :class:`float` or ``None``, Default = ``None``
+
+        To specify a timeout in seconds for the git command, after which the process
+        should be killed.
+    """
+
+    # Use 2 "pump" threads and wait for both to finish.
+    def pump_stream(
+        cmdline: List[str],
+        name: str,
+        stream: Union[BinaryIO, TextIO],
+        is_decode: bool,
+        handler: Union[None, Callable[[Union[bytes, str]], None]],
+    ) -> None:
+        try:
+            for line in stream:
+                if handler:
+                    if is_decode:
+                        assert isinstance(line, bytes)
+                        line_str = line.decode(defenc)
+                        handler(line_str)
+                    else:
+                        handler(line)
+
+        except Exception as ex:
+            _logger.error(f"Pumping {name!r} of cmd({remove_password_if_present(cmdline)}) failed due to: {ex!r}")
+            if "I/O operation on closed file" not in str(ex):
+                # Only reraise if the error was not due to the stream closing.
+                raise CommandError([f"<{name}-pump>"] + remove_password_if_present(cmdline), ex) from ex
+        finally:
+            stream.close()
+
+    if hasattr(process, "proc"):
+        process = cast("Git.AutoInterrupt", process)
+        cmdline: str | Tuple[str, ...] | List[str] = getattr(process.proc, "args", "")
+        p_stdout = process.proc.stdout if process.proc else None
+        p_stderr = process.proc.stderr if process.proc else None
+    else:
+        process = cast(Popen, process)  # type: ignore[redundant-cast]
+        cmdline = getattr(process, "args", "")
+        p_stdout = process.stdout
+        p_stderr = process.stderr
+
+    if not isinstance(cmdline, (tuple, list)):
+        cmdline = cmdline.split()
+
+    pumps: List[Tuple[str, IO, Callable[..., None] | None]] = []
+    if p_stdout:
+        pumps.append(("stdout", p_stdout, stdout_handler))
+    if p_stderr:
+        pumps.append(("stderr", p_stderr, stderr_handler))
+
+    threads: List[threading.Thread] = []
+
+    for name, stream, handler in pumps:
+        t = threading.Thread(target=pump_stream, args=(cmdline, name, stream, decode_streams, handler))
+        t.daemon = True
+        t.start()
+        threads.append(t)
+
+    # FIXME: Why join? Will block if stdin needs feeding...
+    for t in threads:
+        t.join(timeout=kill_after_timeout)
+        if t.is_alive():
+            if isinstance(process, Git.AutoInterrupt):
+                process._terminate()
+            else:  # Don't want to deal with the other case.
+                raise RuntimeError(
+                    "Thread join() timed out in cmd.handle_process_output()."
+                    f" kill_after_timeout={kill_after_timeout} seconds"
+                )
+            if stderr_handler:
+                error_str: Union[str, bytes] = (
+                    f"error: process killed because it timed out. kill_after_timeout={kill_after_timeout} seconds"
+                )
+                if not decode_streams and isinstance(p_stderr, BinaryIO):
+                    # Assume stderr_handler needs binary input.
+                    error_str = cast(str, error_str)
+                    error_str = error_str.encode()
+                # We ignore typing on the next line because mypy does not like the way
+                # we inferred that stderr takes str or bytes.
+                stderr_handler(error_str)  # type: ignore[arg-type]
+
+    if finalizer:
+        finalizer(process)
+
+
+safer_popen: Callable[..., Popen]
+
+if sys.platform == "win32":
+
+    def _safer_popen_windows(
+        command: Union[str, Sequence[Any]],
+        *,
+        shell: bool = False,
+        env: Optional[Mapping[str, str]] = None,
+        **kwargs: Any,
+    ) -> Popen:
+        """Call :class:`subprocess.Popen` on Windows but don't include a CWD in the
+        search.
+
+        This avoids an untrusted search path condition where a file like ``git.exe`` in
+        a malicious repository would be run when GitPython operates on the repository.
+        The process using GitPython may have an untrusted repository's working tree as
+        its current working directory. Some operations may temporarily change to that
+        directory before running a subprocess. In addition, while by default GitPython
+        does not run external commands with a shell, it can be made to do so, in which
+        case the CWD of the subprocess, which GitPython usually sets to a repository
+        working tree, can itself be searched automatically by the shell. This wrapper
+        covers all those cases.
+
+        :note:
+            This currently works by setting the
+            :envvar:`NoDefaultCurrentDirectoryInExePath` environment variable during
+            subprocess creation. It also takes care of passing Windows-specific process
+            creation flags, but that is unrelated to path search.
+
+        :note:
+            The current implementation contains a race condition on :attr:`os.environ`.
+            GitPython isn't thread-safe, but a program using it on one thread should
+            ideally be able to mutate :attr:`os.environ` on another, without
+            unpredictable results. See comments in:
+            https://github.com/gitpython-developers/GitPython/pull/1650
+        """
+        # CREATE_NEW_PROCESS_GROUP is needed for some ways of killing it afterwards.
+        # https://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal
+        # https://docs.python.org/3/library/subprocess.html#subprocess.CREATE_NEW_PROCESS_GROUP
+        creationflags = subprocess.CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP
+
+        # When using a shell, the shell is the direct subprocess, so the variable must
+        # be set in its environment, to affect its search behavior.
+        if shell:
+            # The original may be immutable, or the caller may reuse it. Mutate a copy.
+            env = {} if env is None else dict(env)
+            env["NoDefaultCurrentDirectoryInExePath"] = "1"  # The "1" can be any value.
+
+        # When not using a shell, the current process does the search in a
+        # CreateProcessW API call, so the variable must be set in our environment. With
+        # a shell, that's unnecessary if https://github.com/python/cpython/issues/101283
+        # is patched. In Python versions where it is unpatched, in the rare case the
+        # ComSpec environment variable is unset, the search for the shell itself is
+        # unsafe. Setting NoDefaultCurrentDirectoryInExePath in all cases, as done here,
+        # is simpler and protects against that. (As above, the "1" can be any value.)
+        with patch_env("NoDefaultCurrentDirectoryInExePath", "1"):
+            return Popen(
+                command,
+                shell=shell,
+                env=env,
+                creationflags=creationflags,
+                **kwargs,
+            )
+
+    safer_popen = _safer_popen_windows
+else:
+    safer_popen = Popen
+
+
+def dashify(string: str) -> str:
+    return string.replace("_", "-")
+
+
+def slots_to_dict(self: "Git", exclude: Sequence[str] = ()) -> Dict[str, Any]:
+    return {s: getattr(self, s) for s in self.__slots__ if s not in exclude}
+
+
+def dict_to_slots_and__excluded_are_none(self: object, d: Mapping[str, Any], excluded: Sequence[str] = ()) -> None:
+    for k, v in d.items():
+        setattr(self, k, v)
+    for k in excluded:
+        setattr(self, k, None)
+
+
+## -- End Utilities -- @}
+
+
+class _AutoInterrupt:
+    """Process wrapper that terminates the wrapped process on finalization.
+
+    This kills/interrupts the stored process instance once this instance goes out of
+    scope. It is used to prevent processes piling up in case iterators stop reading.
+
+    All attributes are wired through to the contained process object.
+
+    The wait method is overridden to perform automatic status code checking and possibly
+    raise.
+    """
+
+    __slots__ = ("proc", "args", "status")
+
+    # If this is non-zero it will override any status code during _terminate, used
+    # to prevent race conditions in testing.
+    _status_code_if_terminate: int = 0
+
+    def __init__(self, proc: Union[None, subprocess.Popen], args: Any) -> None:
+        self.proc = proc
+        self.args = args
+        self.status: Union[int, None] = None
+
+    def _terminate(self) -> None:
+        """Terminate the underlying process."""
+        if self.proc is None:
+            return
+
+        proc = self.proc
+        self.proc = None
+        if proc.stdin:
+            proc.stdin.close()
+        if proc.stdout:
+            proc.stdout.close()
+        if proc.stderr:
+            proc.stderr.close()
+        # Did the process finish already so we have a return code?
+        try:
+            if proc.poll() is not None:
+                self.status = self._status_code_if_terminate or proc.poll()
+                return
+        except OSError as ex:
+            _logger.info("Ignored error after process had died: %r", ex)
+
+        # It can be that nothing really exists anymore...
+        if os is None or getattr(os, "kill", None) is None:
+            return
+
+        # Try to kill it.
+        try:
+            proc.terminate()
+            status = proc.wait()  # Ensure the process goes away.
+
+            self.status = self._status_code_if_terminate or status
+        except OSError as ex:
+            _logger.info("Ignored error after process had died: %r", ex)
+        # END exception handling
+
+    def __del__(self) -> None:
+        self._terminate()
+
+    def __getattr__(self, attr: str) -> Any:
+        return getattr(self.proc, attr)
+
+    # TODO: Bad choice to mimic `proc.wait()` but with different args.
+    def wait(self, stderr: Union[None, str, bytes] = b"") -> int:
+        """Wait for the process and return its status code.
+
+        :param stderr:
+            Previously read value of stderr, in case stderr is already closed.
 
-    def dispatch_line(stream, handler, readline):
-            # this can possibly block for a while, but since we wake-up with at least one or more lines to handle,
-            # we are good ...
-            line = readline(stream).decode(defenc)
-            if line and handler:
+        :warn:
+            May deadlock if output or error pipes are used and not handled separately.
+
+        :raise git.exc.GitCommandError:
+            If the return status is not 0.
+        """
+        if stderr is None:
+            stderr_b = b""
+        stderr_b = force_bytes(data=stderr, encoding="utf-8")
+        status: Union[int, None]
+        if self.proc is not None:
+            status = self.proc.wait()
+            p_stderr = self.proc.stderr
+        else:  # Assume the underlying proc was killed earlier or never existed.
+            status = self.status
+            p_stderr = None
+
+        def read_all_from_possibly_closed_stream(stream: Union[IO[bytes], None]) -> bytes:
+            if stream:
                 try:
-                    handler(line)
-                except Exception:
-                    # Keep reading, have to pump the lines empty nontheless
-                    log.error("Line handler exception on line: %s", line, exc_info=True)
-                # end
-            return line
-        # end dispatch helper
-    # end
-
-    def deplete_buffer(stream, handler, readline, wg=None):
+                    return stderr_b + force_bytes(stream.read())
+                except (OSError, ValueError):
+                    return stderr_b or b""
+            else:
+                return stderr_b or b""
+
+        # END status handling
+
+        if status != 0:
+            errstr = read_all_from_possibly_closed_stream(p_stderr)
+            _logger.debug("AutoInterrupt wait stderr: %r" % (errstr,))
+            raise GitCommandError(remove_password_if_present(self.args), status, errstr)
+        return status
+
+
+_AutoInterrupt.__name__ = "AutoInterrupt"
+_AutoInterrupt.__qualname__ = "Git.AutoInterrupt"
+
+
+class _CatFileContentStream:
+    """Object representing a sized read-only stream returning the contents of
+    an object.
+
+    This behaves like a stream, but counts the data read and simulates an empty stream
+    once our sized content region is empty.
+
+    If not all data are read to the end of the object's lifetime, we read the rest to
+    ensure the underlying stream continues to work.
+    """
+
+    __slots__ = ("_stream", "_nbr", "_size")
+
+    def __init__(self, size: int, stream: IO[bytes]) -> None:
+        self._stream = stream
+        self._size = size
+        self._nbr = 0  # Number of bytes read.
+
+        # Special case: If the object is empty, has null bytes, get the final
+        # newline right away.
+        if size == 0:
+            stream.read(1)
+        # END handle empty streams
+
+    def read(self, size: int = -1) -> bytes:
+        bytes_left = self._size - self._nbr
+        if bytes_left == 0:
+            return b""
+        if size > -1:
+            # Ensure we don't try to read past our limit.
+            size = min(bytes_left, size)
+        else:
+            # They try to read all, make sure it's not more than what remains.
+            size = bytes_left
+        # END check early depletion
+        data = self._stream.read(size)
+        self._nbr += len(data)
+
+        # Check for depletion, read our final byte to make the stream usable by
+        # others.
+        if self._size - self._nbr == 0:
+            self._stream.read(1)  # final newline
+        # END finish reading
+        return data
+
+    def readline(self, size: int = -1) -> bytes:
+        if self._nbr == self._size:
+            return b""
+
+        # Clamp size to lowest allowed value.
+        bytes_left = self._size - self._nbr
+        if size > -1:
+            size = min(bytes_left, size)
+        else:
+            size = bytes_left
+        # END handle size
+
+        data = self._stream.readline(size)
+        self._nbr += len(data)
+
+        # Handle final byte.
+        if self._size - self._nbr == 0:
+            self._stream.read(1)
+        # END finish reading
+
+        return data
+
+    def readlines(self, size: int = -1) -> List[bytes]:
+        if self._nbr == self._size:
+            return []
+
+        # Leave all additional logic to our readline method, we just check the size.
+        out = []
+        nbr = 0
         while True:
-            line = dispatch_line(stream, handler, readline)
+            line = self.readline()
             if not line:
                 break
-        # end deplete buffer
-        if wg:
-            wg.done()
-    # end
+            out.append(line)
+            if size > -1:
+                nbr += len(line)
+                if nbr > size:
+                    break
+            # END handle size constraint
+        # END readline loop
+        return out
 
-    fdmap = {process.stdout.fileno(): (process.stdout, stdout_handler, read_line_fast),
-             process.stderr.fileno(): (process.stderr, stderr_handler, read_line_slow)}
+    # skipcq: PYL-E0301
+    def __iter__(self) -> "Git.CatFileContentStream":
+        return self
 
-    if hasattr(select, 'poll'):
-        # poll is preferred, as select is limited to file handles up to 1024 ... . This could otherwise be
-        # an issue for us, as it matters how many handles or own process has
-        poll = select.poll()
-        READ_ONLY = select.POLLIN | select.POLLPRI | select.POLLHUP | select.POLLERR
-        CLOSED = select.POLLHUP | select.POLLERR
+    def __next__(self) -> bytes:
+        line = self.readline()
+        if not line:
+            raise StopIteration
 
-        poll.register(process.stdout, READ_ONLY)
-        poll.register(process.stderr, READ_ONLY)
+        return line
 
-        closed_streams = set()
-        while True:
-            # no timeout
-            poll_result = poll.poll()
-            for fd, result in poll_result:
-                if result & CLOSED:
-                    closed_streams.add(fd)
-                else:
-                    dispatch_line(*fdmap[fd])
-                # end handle closed stream
-            # end for each poll-result tuple
+    next = __next__
 
-            if len(closed_streams) == len(fdmap):
-                break
-            # end its all done
-        # end endless loop
+    def __del__(self) -> None:
+        bytes_left = self._size - self._nbr
+        if bytes_left:
+            # Read and discard - seeking is impossible within a stream.
+            # This includes any terminating newline.
+            self._stream.read(bytes_left + 1)
+        # END handle incomplete read
 
-        # Depelete all remaining buffers
-        for stream, handler, readline in fdmap.values():
-            deplete_buffer(stream, handler, readline)
-        # end for each file handle
-    else:
-        # Oh ... probably we are on windows. select.select() can only handle sockets, we have files
-        # The only reliable way to do this now is to use threads and wait for both to finish
-        # Since the finalizer is expected to wait, we don't have to introduce our own wait primitive
-        # NO: It's not enough unfortunately, and we will have to sync the threads
-        wg = WaitGroup()
-        for fno in fdmap.keys():
-            wg.add(1)
-            stream, handler, readline = fdmap[fno]
-            t = threading.Thread(target=lambda: deplete_buffer(stream, handler, readline, wg))
-            t.start()
-        # end
-        # NOTE: Just joining threads can possibly fail as there is a gap between .start() and when it's
-        # actually started, which could make the wait() call to just return because the thread is not yet
-        # active
-        wg.wait()
-    # end
-
-    return finalizer(process)
-
-
-def dashify(string):
-    return string.replace('_', '-')
 
-## -- End Utilities -- @}
+_CatFileContentStream.__name__ = "CatFileContentStream"
+_CatFileContentStream.__qualname__ = "Git.CatFileContentStream"
 
 
-class Git(LazyMixin):
+_USE_SHELL_DEFAULT_MESSAGE = (
+    "Git.USE_SHELL is deprecated, because only its default value of False is safe. "
+    "It will be removed in a future release."
+)
+
+_USE_SHELL_DANGER_MESSAGE = (
+    "Setting Git.USE_SHELL to True is unsafe and insecure, as the effect of special "
+    "shell syntax cannot usually be accounted for. This can result in a command "
+    "injection vulnerability and arbitrary code execution. Git.USE_SHELL is deprecated "
+    "and will be removed in a future release."
+)
+
 
+def _warn_use_shell(*, extra_danger: bool) -> None:
+    warnings.warn(
+        _USE_SHELL_DANGER_MESSAGE if extra_danger else _USE_SHELL_DEFAULT_MESSAGE,
+        DeprecationWarning,
+        stacklevel=3,
+    )
+
+
+class _GitMeta(type):
+    """Metaclass for :class:`Git`.
+
+    This helps issue :class:`DeprecationWarning` if :attr:`Git.USE_SHELL` is used.
     """
-    The Git class manages communication with the Git binary.
+
+    def __getattribute(cls, name: str) -> Any:
+        if name == "USE_SHELL":
+            _warn_use_shell(extra_danger=False)
+        return super().__getattribute__(name)
+
+    def __setattr(cls, name: str, value: Any) -> Any:
+        if name == "USE_SHELL":
+            _warn_use_shell(extra_danger=value)
+        super().__setattr__(name, value)
+
+    if not TYPE_CHECKING:
+        # To preserve static checking for undefined/misspelled attributes while letting
+        # the methods' bodies be type-checked, these are defined as non-special methods,
+        # then bound to special names out of view of static type checkers. (The original
+        # names invoke name mangling (leading "__") to avoid confusion in other scopes.)
+        __getattribute__ = __getattribute
+        __setattr__ = __setattr
+
+
+GitMeta = _GitMeta
+"""Alias of :class:`Git`'s metaclass, whether it is :class:`type` or a custom metaclass.
+
+Whether the :class:`Git` class has the default :class:`type` as its metaclass or uses a
+custom metaclass is not documented and may change at any time. This statically checkable
+metaclass alias is equivalent at runtime to ``type(Git)``. This should almost never be
+used. Code that benefits from it is likely to be remain brittle even if it is used.
+
+In view of the :class:`Git` class's intended use and :class:`Git` objects' dynamic
+callable attributes representing git subcommands, it rarely makes sense to inherit from
+:class:`Git` at all. Using :class:`Git` in multiple inheritance can be especially tricky
+to do correctly. Attempting uses of :class:`Git` where its metaclass is relevant, such
+as when a sibling class has an unrelated metaclass and a shared lower bound metaclass
+might have to be introduced to solve a metaclass conflict, is not recommended.
+
+:note:
+    The correct static type of the :class:`Git` class itself, and any subclasses, is
+    ``Type[Git]``. (This can be written as ``type[Git]`` in Python 3.9 later.)
+
+    :class:`GitMeta` should never be used in any annotation where ``Type[Git]`` is
+    intended or otherwise possible to use. This alias is truly only for very rare and
+    inherently precarious situations where it is necessary to deal with the metaclass
+    explicitly.
+"""
+
+
+class Git(metaclass=_GitMeta):
+    """The Git class manages communication with the Git binary.
 
     It provides a convenient interface to calling the Git binary, such as in::
 
@@ -174,261 +618,509 @@ class Git(LazyMixin):
      g.init()                   # calls 'git init' program
      rval = g.ls_files()        # calls 'git ls-files' program
 
-    ``Debugging``
-        Set the GIT_PYTHON_TRACE environment variable print each invocation
-        of the command to stdout.
-        Set its value to 'full' to see details about the returned values.
+    Debugging:
+
+    * Set the :envvar:`GIT_PYTHON_TRACE` environment variable to print each invocation
+      of the command to stdout.
+    * Set its value to ``full`` to see details about the returned values.
     """
-    __slots__ = ("_working_dir", "cat_file_all", "cat_file_header", "_version_info",
-                 "_git_options")
+
+    __slots__ = (
+        "_working_dir",
+        "cat_file_all",
+        "cat_file_header",
+        "_version_info",
+        "_version_info_token",
+        "_git_options",
+        "_persistent_git_options",
+        "_environment",
+    )
+
+    _excluded_ = (
+        "cat_file_all",
+        "cat_file_header",
+        "_version_info",
+        "_version_info_token",
+    )
+
+    re_unsafe_protocol = re.compile(r"(.+)::.+")
+
+    def __getstate__(self) -> Dict[str, Any]:
+        return slots_to_dict(self, exclude=self._excluded_)
+
+    def __setstate__(self, d: Dict[str, Any]) -> None:
+        dict_to_slots_and__excluded_are_none(self, d, excluded=self._excluded_)
 
     # CONFIGURATION
-    # The size in bytes read from stdout when copying git's output to another stream
-    max_chunk_size = 1024 * 64
 
-    git_exec_name = "git"           # default that should work on linux and windows
-    git_exec_name_win = "git.cmd"   # alternate command name, windows only
+    git_exec_name = "git"
+    """Default git command that should work on Linux, Windows, and other systems."""
 
-    # Enables debugging of GitPython's git commands
     GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False)
+    """Enables debugging of GitPython's git commands."""
+
+    USE_SHELL: bool = False
+    """Deprecated. If set to ``True``, a shell will be used when executing git commands.
+
+    Code that uses ``USE_SHELL = True`` or that passes ``shell=True`` to any GitPython
+    functions should be updated to use the default value of ``False`` instead. ``True``
+    is unsafe unless the effect of syntax treated specially by the shell is fully
+    considered and accounted for, which is not possible under most circumstances. As
+    detailed below, it is also no longer needed, even where it had been in the past.
+
+    It is in many if not most cases a command injection vulnerability for an application
+    to set :attr:`USE_SHELL` to ``True``. Any attacker who can cause a specially crafted
+    fragment of text to make its way into any part of any argument to any git command
+    (including paths, branch names, etc.) can cause the shell to read and write
+    arbitrary files and execute arbitrary commands. Innocent input may also accidentally
+    contain special shell syntax, leading to inadvertent malfunctions.
+
+    In addition, how a value of ``True`` interacts with some aspects of GitPython's
+    operation is not precisely specified and may change without warning, even before
+    GitPython 4.0.0 when :attr:`USE_SHELL` may be removed. This includes:
+
+    * Whether or how GitPython automatically customizes the shell environment.
+
+    * Whether, outside of Windows (where :class:`subprocess.Popen` supports lists of
+      separate arguments even when ``shell=True``), this can be used with any GitPython
+      functionality other than direct calls to the :meth:`execute` method.
+
+    * Whether any GitPython feature that runs git commands ever attempts to partially
+      sanitize data a shell may treat specially. Currently this is not done.
+
+    Prior to GitPython 2.0.8, this had a narrow purpose in suppressing console windows
+    in graphical Windows applications. In 2.0.8 and higher, it provides no benefit, as
+    GitPython solves that problem more robustly and safely by using the
+    ``CREATE_NO_WINDOW`` process creation flag on Windows.
+
+    Because Windows path search differs subtly based on whether a shell is used, in rare
+    cases changing this from ``True`` to ``False`` may keep an unusual git "executable",
+    such as a batch file, from being found. To fix this, set the command name or full
+    path in the :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable or pass the
+    full path to :func:`git.refresh` (or invoke the script using a ``.exe`` shim).
+
+    Further reading:
+
+    * :meth:`Git.execute` (on the ``shell`` parameter).
+    * https://github.com/gitpython-developers/GitPython/commit/0d9390866f9ce42870d3116094cd49e0019a970a
+    * https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
+    * https://github.com/python/cpython/issues/91558#issuecomment-1100942950
+    * https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
+    """
 
-    # Provide the full path to the git executable. Otherwise it assumes git is in the path
     _git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE"
-    GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name)
+    _refresh_env_var = "GIT_PYTHON_REFRESH"
 
-    class AutoInterrupt(object):
+    GIT_PYTHON_GIT_EXECUTABLE = None
+    """Provide the full path to the git executable. Otherwise it assumes git is in the
+    executable search path.
 
-        """Kill/Interrupt the stored process instance once this instance goes out of scope. It is
-        used to prevent processes piling up in case iterators stop reading.
-        Besides all attributes are wired through to the contained process object.
+    :note:
+        The git executable is actually found during the refresh step in the top level
+        ``__init__``. It can also be changed by explicitly calling :func:`git.refresh`.
+    """
 
-        The wait method was overridden to perform automatic status code checking
-        and possibly raise."""
-        __slots__ = ("proc", "args")
+    _refresh_token = object()  # Since None would match an initial _version_info_token.
 
-        def __init__(self, proc, args):
-            self.proc = proc
-            self.args = args
+    @classmethod
+    def refresh(cls, path: Union[None, PathLike] = None) -> bool:
+        """Update information about the git executable :class:`Git` objects will use.
 
-        def __del__(self):
-            if self.proc is None:
-                return
+        Called by the :func:`git.refresh` function in the top level ``__init__``.
 
-            proc = self.proc
-            self.proc = None
-            if proc.stdin:
-                proc.stdin.close()
-            proc.stdout.close()
-            proc.stderr.close()
+        :param path:
+            Optional path to the git executable. If not absolute, it is resolved
+            immediately, relative to the current directory. (See note below.)
 
-            # did the process finish already so we have a return code ?
-            if proc.poll() is not None:
-                return
+        :note:
+            The top-level :func:`git.refresh` should be preferred because it calls this
+            method and may also update other state accordingly.
 
-            # can be that nothing really exists anymore ...
-            if os is None:
-                return
+        :note:
+            There are three different ways to specify the command that refreshing causes
+            to be used for git:
+
+            1. Pass no `path` argument and do not set the
+               :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable. The command
+               name ``git`` is used. It is looked up in a path search by the system, in
+               each command run (roughly similar to how git is found when running
+               ``git`` commands manually). This is usually the desired behavior.
+
+            2. Pass no `path` argument but set the :envvar:`GIT_PYTHON_GIT_EXECUTABLE`
+               environment variable. The command given as the value of that variable is
+               used. This may be a simple command or an arbitrary path. It is looked up
+               in each command run. Setting :envvar:`GIT_PYTHON_GIT_EXECUTABLE` to
+               ``git`` has the same effect as not setting it.
+
+            3. Pass a `path` argument. This path, if not absolute, is immediately
+               resolved, relative to the current directory. This resolution occurs at
+               the time of the refresh. When git commands are run, they are run using
+               that previously resolved path. If a `path` argument is passed, the
+               :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable is not
+               consulted.
 
-            # try to kill it
-            try:
-                os.kill(proc.pid, 2)   # interrupt signal
-                proc.wait()    # ensure process goes away
-            except (OSError, WindowsError):
-                pass  # ignore error when process already died
-            except AttributeError:
-                # try windows
-                # for some reason, providing None for stdout/stderr still prints something. This is why
-                # we simply use the shell and redirect to nul. Its slower than CreateProcess, question
-                # is whether we really want to see all these messages. Its annoying no matter what.
-                call(("TASKKILL /F /T /PID %s 2>nul 1>nul" % str(proc.pid)), shell=True)
-            # END exception handling
-
-        def __getattr__(self, attr):
-            return getattr(self.proc, attr)
-
-        def wait(self):
-            """Wait for the process and return its status code.
-
-            :raise GitCommandError: if the return status is not 0"""
-            status = self.proc.wait()
-            if status != 0:
-                raise GitCommandError(self.args, status, self.proc.stderr.read().decode(defenc))
-            # END status handling
-            return status
-    # END auto interrupt
-
-    class CatFileContentStream(object):
-
-        """Object representing a sized read-only stream returning the contents of
-        an object.
-        It behaves like a stream, but counts the data read and simulates an empty
-        stream once our sized content region is empty.
-        If not all data is read to the end of the objects's lifetime, we read the
-        rest to assure the underlying stream continues to work"""
-
-        __slots__ = ('_stream', '_nbr', '_size')
-
-        def __init__(self, size, stream):
-            self._stream = stream
-            self._size = size
-            self._nbr = 0           # num bytes read
-
-            # special case: if the object is empty, has null bytes, get the
-            # final newline right away.
-            if size == 0:
-                stream.read(1)
-            # END handle empty streams
-
-        def read(self, size=-1):
-            bytes_left = self._size - self._nbr
-            if bytes_left == 0:
-                return ''
-            if size > -1:
-                # assure we don't try to read past our limit
-                size = min(bytes_left, size)
-            else:
-                # they try to read all, make sure its not more than what remains
-                size = bytes_left
-            # END check early depletion
-            data = self._stream.read(size)
-            self._nbr += len(data)
-
-            # check for depletion, read our final byte to make the stream usable by others
-            if self._size - self._nbr == 0:
-                self._stream.read(1)    # final newline
-            # END finish reading
-            return data
-
-        def readline(self, size=-1):
-            if self._nbr == self._size:
-                return ''
-
-            # clamp size to lowest allowed value
-            bytes_left = self._size - self._nbr
-            if size > -1:
-                size = min(bytes_left, size)
+        :note:
+            Refreshing always sets the :attr:`Git.GIT_PYTHON_GIT_EXECUTABLE` class
+            attribute, which can be read on the :class:`Git` class or any of its
+            instances to check what command is used to run git. This attribute should
+            not be confused with the related :envvar:`GIT_PYTHON_GIT_EXECUTABLE`
+            environment variable. The class attribute is set no matter how refreshing is
+            performed.
+        """
+        # Discern which path to refresh with.
+        if path is not None:
+            new_git = os.path.expanduser(path)
+            new_git = os.path.abspath(new_git)
+        else:
+            new_git = os.environ.get(cls._git_exec_env_var, cls.git_exec_name)
+
+        # Keep track of the old and new git executable path.
+        old_git = cls.GIT_PYTHON_GIT_EXECUTABLE
+        old_refresh_token = cls._refresh_token
+        cls.GIT_PYTHON_GIT_EXECUTABLE = new_git
+        cls._refresh_token = object()
+
+        # Test if the new git executable path is valid. A GitCommandNotFound error is
+        # raised by us. A PermissionError is raised if the git executable cannot be
+        # executed for whatever reason.
+        has_git = False
+        try:
+            cls().version()
+            has_git = True
+        except (GitCommandNotFound, PermissionError):
+            pass
+
+        # Warn or raise exception if test failed.
+        if not has_git:
+            err = (
+                dedent(
+                    """\
+                Bad git executable.
+                The git executable must be specified in one of the following ways:
+                    - be included in your $PATH
+                    - be set via $%s
+                    - explicitly set via git.refresh(<full-path-to-git-executable>)
+                """
+                )
+                % cls._git_exec_env_var
+            )
+
+            # Revert to whatever the old_git was.
+            cls.GIT_PYTHON_GIT_EXECUTABLE = old_git
+            cls._refresh_token = old_refresh_token
+
+            if old_git is None:
+                # On the first refresh (when GIT_PYTHON_GIT_EXECUTABLE is None) we only
+                # are quiet, warn, or error depending on the GIT_PYTHON_REFRESH value.
+
+                # Determine what the user wants to happen during the initial refresh. We
+                # expect GIT_PYTHON_REFRESH to either be unset or be one of the
+                # following values:
+                #
+                #   0|q|quiet|s|silence|silent|n|none
+                #   1|w|warn|warning|l|log
+                #   2|r|raise|e|error|exception
+
+                mode = os.environ.get(cls._refresh_env_var, "raise").lower()
+
+                quiet = ["quiet", "q", "silence", "s", "silent", "none", "n", "0"]
+                warn = ["warn", "w", "warning", "log", "l", "1"]
+                error = ["error", "e", "exception", "raise", "r", "2"]
+
+                if mode in quiet:
+                    pass
+                elif mode in warn or mode in error:
+                    err = dedent(
+                        """\
+                        %s
+                        All git commands will error until this is rectified.
+
+                        This initial message can be silenced or aggravated in the future by setting the
+                        $%s environment variable. Use one of the following values:
+                            - %s: for no message or exception
+                            - %s: for a warning message (logging level CRITICAL, displayed by default)
+                            - %s: for a raised exception
+
+                        Example:
+                            export %s=%s
+                        """
+                    ) % (
+                        err,
+                        cls._refresh_env_var,
+                        "|".join(quiet),
+                        "|".join(warn),
+                        "|".join(error),
+                        cls._refresh_env_var,
+                        quiet[0],
+                    )
+
+                    if mode in warn:
+                        _logger.critical(err)
+                    else:
+                        raise ImportError(err)
+                else:
+                    err = dedent(
+                        """\
+                        %s environment variable has been set but it has been set with an invalid value.
+
+                        Use only the following values:
+                            - %s: for no message or exception
+                            - %s: for a warning message (logging level CRITICAL, displayed by default)
+                            - %s: for a raised exception
+                        """
+                    ) % (
+                        cls._refresh_env_var,
+                        "|".join(quiet),
+                        "|".join(warn),
+                        "|".join(error),
+                    )
+                    raise ImportError(err)
+
+                # We get here if this was the initial refresh and the refresh mode was
+                # not error. Go ahead and set the GIT_PYTHON_GIT_EXECUTABLE such that we
+                # discern the difference between the first refresh at import time
+                # and subsequent calls to git.refresh or this refresh method.
+                cls.GIT_PYTHON_GIT_EXECUTABLE = cls.git_exec_name
             else:
-                size = bytes_left
-            # END handle size
+                # After the first refresh (when GIT_PYTHON_GIT_EXECUTABLE is no longer
+                # None) we raise an exception.
+                raise GitCommandNotFound(new_git, err)
+
+        return has_git
+
+    @classmethod
+    def is_cygwin(cls) -> bool:
+        return is_cygwin_git(cls.GIT_PYTHON_GIT_EXECUTABLE)
 
-            data = self._stream.readline(size)
-            self._nbr += len(data)
+    @overload
+    @classmethod
+    def polish_url(cls, url: str, is_cygwin: Literal[False] = ...) -> str: ...
 
-            # handle final byte
-            if self._size - self._nbr == 0:
-                self._stream.read(1)
-            # END finish reading
+    @overload
+    @classmethod
+    def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str: ...
 
-            return data
+    @classmethod
+    def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> PathLike:
+        """Remove any backslashes from URLs to be written in config files.
 
-        def readlines(self, size=-1):
-            if self._nbr == self._size:
-                return list()
+        Windows might create config files containing paths with backslashes, but git
+        stops liking them as it will escape the backslashes. Hence we undo the escaping
+        just to be sure.
+        """
+        if is_cygwin is None:
+            is_cygwin = cls.is_cygwin()
 
-            # leave all additional logic to our readline method, we just check the size
-            out = list()
-            nbr = 0
-            while True:
-                line = self.readline()
-                if not line:
-                    break
-                out.append(line)
-                if size > -1:
-                    nbr += len(line)
-                    if nbr > size:
-                        break
-                # END handle size constraint
-            # END readline loop
-            return out
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            line = self.readline()
-            if not line:
-                raise StopIteration
-            return line
-
-        def __del__(self):
-            bytes_left = self._size - self._nbr
-            if bytes_left:
-                # read and discard - seeking is impossible within a stream
-                # includes terminating newline
-                self._stream.read(bytes_left + 1)
-            # END handle incomplete read
-
-    def __init__(self, working_dir=None):
+        if is_cygwin:
+            url = cygpath(url)
+        else:
+            url = os.path.expandvars(url)
+            if url.startswith("~"):
+                url = os.path.expanduser(url)
+            url = url.replace("\\\\", "\\").replace("\\", "/")
+        return url
+
+    @classmethod
+    def check_unsafe_protocols(cls, url: str) -> None:
+        """Check for unsafe protocols.
+
+        Apart from the usual protocols (http, git, ssh), Git allows "remote helpers"
+        that have the form ``<transport>::<address>``. One of these helpers (``ext::``)
+        can be used to invoke any arbitrary command.
+
+        See:
+
+        - https://git-scm.com/docs/gitremote-helpers
+        - https://git-scm.com/docs/git-remote-ext
+        """
+        match = cls.re_unsafe_protocol.match(url)
+        if match:
+            protocol = match.group(1)
+            raise UnsafeProtocolError(
+                f"The `{protocol}::` protocol looks suspicious, use `allow_unsafe_protocols=True` to allow it."
+            )
+
+    @classmethod
+    def check_unsafe_options(cls, options: List[str], unsafe_options: List[str]) -> None:
+        """Check for unsafe options.
+
+        Some options that are passed to ``git <command>`` can be used to execute
+        arbitrary commands. These are blocked by default.
+        """
+        # Options can be of the form `foo`, `--foo bar`, or `--foo=bar`, so we need to
+        # check if they start with "--foo" or if they are equal to "foo".
+        bare_unsafe_options = [option.lstrip("-") for option in unsafe_options]
+        for option in options:
+            for unsafe_option, bare_option in zip(unsafe_options, bare_unsafe_options):
+                if option.startswith(unsafe_option) or option == bare_option:
+                    raise UnsafeOptionError(
+                        f"{unsafe_option} is not allowed, use `allow_unsafe_options=True` to allow it."
+                    )
+
+    AutoInterrupt: TypeAlias = _AutoInterrupt
+
+    CatFileContentStream: TypeAlias = _CatFileContentStream
+
+    def __init__(self, working_dir: Union[None, PathLike] = None) -> None:
         """Initialize this instance with:
 
         :param working_dir:
-           Git directory we should work in. If None, we always work in the current
-           directory as returned by os.getcwd().
-           It is meant to be the working tree directory if available, or the
-           .git directory in case of bare repositories."""
-        super(Git, self).__init__()
-        self._working_dir = working_dir
-        self._git_options = ()
+            Git directory we should work in. If ``None``, we always work in the current
+            directory as returned by :func:`os.getcwd`.
+            This is meant to be the working tree directory if available, or the
+            ``.git`` directory in case of bare repositories.
+        """
+        super().__init__()
+        self._working_dir = expand_path(working_dir)
+        self._git_options: Union[List[str], Tuple[str, ...]] = ()
+        self._persistent_git_options: List[str] = []
 
-        # cached command slots
-        self.cat_file_header = None
-        self.cat_file_all = None
+        # Extra environment variables to pass to git commands
+        self._environment: Dict[str, str] = {}
+
+        # Cached version slots
+        self._version_info: Union[Tuple[int, ...], None] = None
+        self._version_info_token: object = None
+
+        # Cached command slots
+        self.cat_file_header: Union[None, TBD] = None
+        self.cat_file_all: Union[None, TBD] = None
 
-    def __getattr__(self, name):
-        """A convenience method as it allows to call the command as if it was
-        an object.
-        :return: Callable object that will execute call _call_process with your arguments."""
-        if name[0] == '_':
-            return LazyMixin.__getattr__(self, name)
+    def __getattribute__(self, name: str) -> Any:
+        if name == "USE_SHELL":
+            _warn_use_shell(extra_danger=False)
+        return super().__getattribute__(name)
+
+    def __getattr__(self, name: str) -> Any:
+        """A convenience method as it allows to call the command as if it was an object.
+
+        :return:
+            Callable object that will execute call :meth:`_call_process` with your
+            arguments.
+        """
+        if name.startswith("_"):
+            return super().__getattribute__(name)
         return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
 
-    def _set_cache_(self, attr):
-        if attr == '_version_info':
-            # We only use the first 4 numbers, as everthing else could be strings in fact (on windows)
-            version_numbers = self._call_process('version').split(' ')[2]
-            self._version_info = tuple(int(n) for n in version_numbers.split('.')[:4] if n.isdigit())
-        else:
-            super(Git, self)._set_cache_(attr)
-        # END handle version info
+    def set_persistent_git_options(self, **kwargs: Any) -> None:
+        """Specify command line options to the git executable for subsequent
+        subcommand calls.
+
+        :param kwargs:
+            A dict of keyword arguments.
+            These arguments are passed as in :meth:`_call_process`, but will be passed
+            to the git command rather than the subcommand.
+        """
+
+        self._persistent_git_options = self.transform_kwargs(split_single_char_options=True, **kwargs)
 
     @property
-    def working_dir(self):
+    def working_dir(self) -> Union[None, PathLike]:
         """:return: Git directory we are working on"""
         return self._working_dir
 
     @property
-    def version_info(self):
+    def version_info(self) -> Tuple[int, ...]:
+        """
+        :return: Tuple with integers representing the major, minor and additional
+            version numbers as parsed from :manpage:`git-version(1)`. Up to four fields
+            are used.
+
+            This value is generated on demand and is cached.
         """
-        :return: tuple(int, int, int, int) tuple with integers representing the major, minor
-            and additional version numbers as parsed from git version.
-            This value is generated on demand and is cached"""
+        # Refreshing is global, but version_info caching is per-instance.
+        refresh_token = self._refresh_token  # Copy token in case of concurrent refresh.
+
+        # Use the cached version if obtained after the most recent refresh.
+        if self._version_info_token is refresh_token:
+            assert self._version_info is not None, "Bug: corrupted token-check state"
+            return self._version_info
+
+        # Run "git version" and parse it.
+        process_version = self._call_process("version")
+        version_string = process_version.split(" ")[2]
+        version_fields = version_string.split(".")[:4]
+        leading_numeric_fields = itertools.takewhile(str.isdigit, version_fields)
+        self._version_info = tuple(map(int, leading_numeric_fields))
+
+        # This value will be considered valid until the next refresh.
+        self._version_info_token = refresh_token
         return self._version_info
 
-    def execute(self, command,
-                istream=None,
-                with_keep_cwd=False,
-                with_extended_output=False,
-                with_exceptions=True,
-                as_process=False,
-                output_stream=None,
-                stdout_as_string=True,
-                **subprocess_kwargs
-                ):
-        """Handles executing the command on the shell and consumes and returns
-        the returned information (stdout)
+    @overload
+    def execute(
+        self,
+        command: Union[str, Sequence[Any]],
+        *,
+        as_process: Literal[True],
+    ) -> "AutoInterrupt": ...
+
+    @overload
+    def execute(
+        self,
+        command: Union[str, Sequence[Any]],
+        *,
+        as_process: Literal[False] = False,
+        stdout_as_string: Literal[True],
+    ) -> Union[str, Tuple[int, str, str]]: ...
+
+    @overload
+    def execute(
+        self,
+        command: Union[str, Sequence[Any]],
+        *,
+        as_process: Literal[False] = False,
+        stdout_as_string: Literal[False] = False,
+    ) -> Union[bytes, Tuple[int, bytes, str]]: ...
+
+    @overload
+    def execute(
+        self,
+        command: Union[str, Sequence[Any]],
+        *,
+        with_extended_output: Literal[False],
+        as_process: Literal[False],
+        stdout_as_string: Literal[True],
+    ) -> str: ...
+
+    @overload
+    def execute(
+        self,
+        command: Union[str, Sequence[Any]],
+        *,
+        with_extended_output: Literal[False],
+        as_process: Literal[False],
+        stdout_as_string: Literal[False],
+    ) -> bytes: ...
+
+    def execute(
+        self,
+        command: Union[str, Sequence[Any]],
+        istream: Union[None, BinaryIO] = None,
+        with_extended_output: bool = False,
+        with_exceptions: bool = True,
+        as_process: bool = False,
+        output_stream: Union[None, BinaryIO] = None,
+        stdout_as_string: bool = True,
+        kill_after_timeout: Union[None, float] = None,
+        with_stdout: bool = True,
+        universal_newlines: bool = False,
+        shell: Union[None, bool] = None,
+        env: Union[None, Mapping[str, str]] = None,
+        max_chunk_size: int = io.DEFAULT_BUFFER_SIZE,
+        strip_newline_in_stdout: bool = True,
+        **subprocess_kwargs: Any,
+    ) -> Union[str, bytes, Tuple[int, Union[str, bytes], str], AutoInterrupt]:
+        R"""Handle executing the command, and consume and return the returned
+        information (stdout).
 
         :param command:
             The command argument list to execute.
-            It should be a string, or a sequence of program arguments. The
+            It should be a sequence of program arguments, or a string. The
             program to execute is the first item in the args sequence or string.
 
         :param istream:
-            Standard input filehandle passed to subprocess.Popen.
-
-        :param with_keep_cwd:
-            Whether to use the current working directory from os.getcwd().
-            The cmd otherwise uses its own working_dir that it has been initialized
-            with if possible.
+            Standard input filehandle passed to :class:`subprocess.Popen`.
 
         :param with_extended_output:
             Whether to return a (status, stdout, stderr) tuple.
@@ -438,95 +1130,249 @@ def execute(self, command,
 
         :param as_process:
             Whether to return the created process instance directly from which
-            streams can be read on demand. This will render with_extended_output and
-            with_exceptions ineffective - the caller will have
-            to deal with the details himself.
-            It is important to note that the process will be placed into an AutoInterrupt
-            wrapper that will interrupt the process once it goes out of scope. If you
-            use the command in iterators, you should pass the whole process instance
-            instead of a single stream.
+            streams can be read on demand. This will render `with_extended_output`
+            and `with_exceptions` ineffective - the caller will have to deal with
+            the details. It is important to note that the process will be placed
+            into an :class:`AutoInterrupt` wrapper that will interrupt the process
+            once it goes out of scope. If you use the command in iterators, you
+            should pass the whole process instance instead of a single stream.
 
         :param output_stream:
             If set to a file-like object, data produced by the git command will be
-            output to the given stream directly.
-            This feature only has any effect if as_process is False. Processes will
-            always be created with a pipe due to issues with subprocess.
-            This merely is a workaround as data will be copied from the
-            output pipe to the given output stream directly.
-            Judging from the implementation, you shouldn't use this flag !
+            copied to the given stream instead of being returned as a string.
+            This feature only has any effect if `as_process` is ``False``.
 
         :param stdout_as_string:
-            if False, the commands standard output will be bytes. Otherwise, it will be
-            decoded into a string using the default encoding (usually utf-8).
+            If ``False``, the command's standard output will be bytes. Otherwise, it
+            will be decoded into a string using the default encoding (usually UTF-8).
             The latter can fail, if the output contains binary data.
 
+        :param kill_after_timeout:
+            Specifies a timeout in seconds for the git command, after which the process
+            should be killed. This will have no effect if `as_process` is set to
+            ``True``. It is set to ``None`` by default and will let the process run
+            until the timeout is explicitly specified. Uses of this feature should be
+            carefully considered, due to the following limitations:
+
+            1. This feature is not supported at all on Windows.
+            2. Effectiveness may vary by operating system. ``ps --ppid`` is used to
+               enumerate child processes, which is available on most GNU/Linux systems
+               but not most others.
+            3. Deeper descendants do not receive signals, though they may sometimes
+               terminate as a consequence of their parent processes being killed.
+            4. `kill_after_timeout` uses ``SIGKILL``, which can have negative side
+               effects on a repository. For example, stale locks in case of
+               :manpage:`git-gc(1)` could render the repository incapable of accepting
+               changes until the lock is manually removed.
+
+        :param with_stdout:
+            If ``True``, default ``True``, we open stdout on the created process.
+
+        :param universal_newlines:
+            If ``True``, pipes will be opened as text, and lines are split at all known
+            line endings.
+
+        :param shell:
+            Whether to invoke commands through a shell
+            (see :class:`Popen(..., shell=True) <subprocess.Popen>`).
+            If this is not ``None``, it overrides :attr:`USE_SHELL`.
+
+            Passing ``shell=True`` to this or any other GitPython function should be
+            avoided, as it is unsafe under most circumstances. This is because it is
+            typically not feasible to fully consider and account for the effect of shell
+            expansions, especially when passing ``shell=True`` to other methods that
+            forward it to :meth:`Git.execute`. Passing ``shell=True`` is also no longer
+            needed (nor useful) to work around any known operating system specific
+            issues.
+
+        :param env:
+            A dictionary of environment variables to be passed to
+            :class:`subprocess.Popen`.
+
+        :param max_chunk_size:
+            Maximum number of bytes in one chunk of data passed to the `output_stream`
+            in one invocation of its ``write()`` method. If the given number is not
+            positive then the default value is used.
+
+        :param strip_newline_in_stdout:
+            Whether to strip the trailing ``\n`` of the command stdout.
+
         :param subprocess_kwargs:
-            Keyword arguments to be passed to subprocess.Popen. Please note that
-            some of the valid kwargs are already set by this method, the ones you
+            Keyword arguments to be passed to :class:`subprocess.Popen`. Please note
+            that some of the valid kwargs are already set by this method; the ones you
             specify may not be the same ones.
 
         :return:
-            * str(output) if extended_output = False (Default)
-            * tuple(int(status), str(stdout), str(stderr)) if extended_output = True
+            * str(output), if `extended_output` is ``False`` (Default)
+            * tuple(int(status), str(stdout), str(stderr)),
+              if `extended_output` is ``True``
+
+            If `output_stream` is ``True``, the stdout value will be your output stream:
 
-            if ouput_stream is True, the stdout value will be your output stream:
-            * output_stream if extended_output = False
-            * tuple(int(status), output_stream, str(stderr)) if extended_output = True
+            * output_stream, if `extended_output` is ``False``
+            * tuple(int(status), output_stream, str(stderr)),
+              if `extended_output` is ``True``
 
-            Note git is executed with LC_MESSAGES="C" to ensure consitent
+            Note that git is executed with ``LC_MESSAGES="C"`` to ensure consistent
             output regardless of system language.
 
-        :raise GitCommandError:
+        :raise git.exc.GitCommandError:
 
         :note:
-           If you add additional keyword arguments to the signature of this method,
-           you must update the execute_kwargs tuple housed in this module."""
-        if self.GIT_PYTHON_TRACE and (self.GIT_PYTHON_TRACE != 'full' or as_process):
-            log.info(' '.join(command))
+            If you add additional keyword arguments to the signature of this method, you
+            must update the ``execute_kwargs`` variable housed in this module.
+        """
+        # Remove password for the command if present.
+        redacted_command = remove_password_if_present(command)
+        if self.GIT_PYTHON_TRACE and (self.GIT_PYTHON_TRACE != "full" or as_process):
+            _logger.info(" ".join(redacted_command))
 
         # Allow the user to have the command executed in their working dir.
-        if with_keep_cwd or self._working_dir is None:
-            cwd = os.getcwd()
+        try:
+            cwd = self._working_dir or os.getcwd()  # type: Union[None, str]
+            if not os.access(str(cwd), os.X_OK):
+                cwd = None
+        except FileNotFoundError:
+            cwd = None
+
+        # Start the process.
+        inline_env = env
+        env = os.environ.copy()
+        # Attempt to force all output to plain ASCII English, which is what some parsing
+        # code may expect.
+        # According to https://askubuntu.com/a/311796, we are setting LANGUAGE as well
+        # just to be sure.
+        env["LANGUAGE"] = "C"
+        env["LC_ALL"] = "C"
+        env.update(self._environment)
+        if inline_env is not None:
+            env.update(inline_env)
+
+        if sys.platform == "win32":
+            if kill_after_timeout is not None:
+                raise GitCommandError(
+                    redacted_command,
+                    '"kill_after_timeout" feature is not supported on Windows.',
+                )
+            cmd_not_found_exception = OSError
+        else:
+            cmd_not_found_exception = FileNotFoundError
+        # END handle
+
+        stdout_sink = PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb")
+        if shell is None:
+            # Get the value of USE_SHELL with no deprecation warning. Do this without
+            # warnings.catch_warnings, to avoid a race condition with application code
+            # configuring warnings. The value could be looked up in type(self).__dict__
+            # or Git.__dict__, but those can break under some circumstances. This works
+            # the same as self.USE_SHELL in more situations; see Git.__getattribute__.
+            shell = super().__getattribute__("USE_SHELL")
+        _logger.debug(
+            "Popen(%s, cwd=%s, stdin=%s, shell=%s, universal_newlines=%s)",
+            redacted_command,
+            cwd,
+            "<valid stream>" if istream else "None",
+            shell,
+            universal_newlines,
+        )
+        try:
+            proc = safer_popen(
+                command,
+                env=env,
+                cwd=cwd,
+                bufsize=-1,
+                stdin=(istream or DEVNULL),
+                stderr=PIPE,
+                stdout=stdout_sink,
+                shell=shell,
+                universal_newlines=universal_newlines,
+                encoding=defenc if universal_newlines else None,
+                **subprocess_kwargs,
+            )
+        except cmd_not_found_exception as err:
+            raise GitCommandNotFound(redacted_command, err) from err
         else:
-            cwd = self._working_dir
+            # Replace with a typeguard for Popen[bytes]?
+            proc.stdout = cast(BinaryIO, proc.stdout)
+            proc.stderr = cast(BinaryIO, proc.stderr)
 
-        # Start the process
-        env = os.environ.copy()
-        env["LC_MESSAGES"] = "C"
-        proc = Popen(command,
-                     env=env,
-                     cwd=cwd,
-                     stdin=istream,
-                     stderr=PIPE,
-                     stdout=PIPE,
-                     # Prevent cmd prompt popups on windows by using a shell ... .
-                     # See https://github.com/gitpython-developers/GitPython/pull/126
-                     shell=sys.platform == 'win32',
-                     close_fds=(os.name == 'posix'),  # unsupported on windows
-                     **subprocess_kwargs
-                     )
         if as_process:
             return self.AutoInterrupt(proc, command)
 
-        # Wait for the process to return
+        if sys.platform != "win32" and kill_after_timeout is not None:
+            # Help mypy figure out this is not None even when used inside communicate().
+            timeout = kill_after_timeout
+
+            def kill_process(pid: int) -> None:
+                """Callback to kill a process.
+
+                This callback implementation would be ineffective and unsafe on Windows.
+                """
+                p = Popen(["ps", "--ppid", str(pid)], stdout=PIPE)
+                child_pids = []
+                if p.stdout is not None:
+                    for line in p.stdout:
+                        if len(line.split()) > 0:
+                            local_pid = (line.split())[0]
+                            if local_pid.isdigit():
+                                child_pids.append(int(local_pid))
+                try:
+                    os.kill(pid, signal.SIGKILL)
+                    for child_pid in child_pids:
+                        try:
+                            os.kill(child_pid, signal.SIGKILL)
+                        except OSError:
+                            pass
+                    # Tell the main routine that the process was killed.
+                    kill_check.set()
+                except OSError:
+                    # It is possible that the process gets completed in the duration
+                    # after timeout happens and before we try to kill the process.
+                    pass
+                return
+
+            def communicate() -> Tuple[AnyStr, AnyStr]:
+                watchdog.start()
+                out, err = proc.communicate()
+                watchdog.cancel()
+                if kill_check.is_set():
+                    err = 'Timeout: the command "%s" did not complete in %d secs.' % (
+                        " ".join(redacted_command),
+                        timeout,
+                    )
+                    if not universal_newlines:
+                        err = err.encode(defenc)
+                return out, err
+
+            # END helpers
+
+            kill_check = threading.Event()
+            watchdog = threading.Timer(timeout, kill_process, args=(proc.pid,))
+        else:
+            communicate = proc.communicate
+
+        # Wait for the process to return.
         status = 0
-        stdout_value = b''
-        stderr_value = b''
+        stdout_value: Union[str, bytes] = b""
+        stderr_value: Union[str, bytes] = b""
+        newline = "\n" if universal_newlines else b"\n"
         try:
             if output_stream is None:
-                stdout_value, stderr_value = proc.communicate()
-                # strip trailing "\n"
-                if stdout_value.endswith(b"\n"):
+                stdout_value, stderr_value = communicate()
+                # Strip trailing "\n".
+                if stdout_value.endswith(newline) and strip_newline_in_stdout:  # type: ignore[arg-type]
                     stdout_value = stdout_value[:-1]
-                if stderr_value.endswith(b"\n"):
+                if stderr_value.endswith(newline):  # type: ignore[arg-type]
                     stderr_value = stderr_value[:-1]
+
                 status = proc.returncode
             else:
-                stream_copy(proc.stdout, output_stream, self.max_chunk_size)
-                stdout_value = output_stream
+                max_chunk_size = max_chunk_size if max_chunk_size and max_chunk_size > 0 else io.DEFAULT_BUFFER_SIZE
+                stream_copy(proc.stdout, output_stream, max_chunk_size)
+                stdout_value = proc.stdout.read()
                 stderr_value = proc.stderr.read()
-                # strip trailing "\n"
-                if stderr_value.endswith(b"\n"):
+                # Strip trailing "\n".
+                if stderr_value.endswith(newline):  # type: ignore[arg-type]
                     stderr_value = stderr_value[:-1]
                 status = proc.wait()
             # END stdout handling
@@ -534,181 +1380,263 @@ def execute(self, command,
             proc.stdout.close()
             proc.stderr.close()
 
-        if self.GIT_PYTHON_TRACE == 'full':
-            cmdstr = " ".join(command)
+        if self.GIT_PYTHON_TRACE == "full":
+            cmdstr = " ".join(redacted_command)
+
+            def as_text(stdout_value: Union[bytes, str]) -> str:
+                return not output_stream and safe_decode(stdout_value) or "<OUTPUT_STREAM>"
+
+            # END as_text
+
             if stderr_value:
-                log.info("%s -> %d; stdout: '%s'; stderr: '%s'",
-                         cmdstr, status, stdout_value.decode(defenc), stderr_value.decode(defenc))
+                _logger.info(
+                    "%s -> %d; stdout: '%s'; stderr: '%s'",
+                    cmdstr,
+                    status,
+                    as_text(stdout_value),
+                    safe_decode(stderr_value),
+                )
             elif stdout_value:
-                log.info("%s -> %d; stdout: '%s'", cmdstr, status, stdout_value.decode(defenc))
+                _logger.info("%s -> %d; stdout: '%s'", cmdstr, status, as_text(stdout_value))
             else:
-                log.info("%s -> %d", cmdstr, status)
+                _logger.info("%s -> %d", cmdstr, status)
         # END handle debug printing
 
         if with_exceptions and status != 0:
-            if with_extended_output:
-                raise GitCommandError(command, status, stderr_value, stdout_value)
-            else:
-                raise GitCommandError(command, status, stderr_value)
+            raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
 
-        if isinstance(stdout_value, bytes) and stdout_as_string:  # could also be output_stream
-            stdout_value = stdout_value.decode(defenc)
+        if isinstance(stdout_value, bytes) and stdout_as_string:  # Could also be output_stream.
+            stdout_value = safe_decode(stdout_value)
 
-        # Allow access to the command's status code
+        # Allow access to the command's status code.
         if with_extended_output:
-            return (status, stdout_value, stderr_value.decode(defenc))
+            return (status, stdout_value, safe_decode(stderr_value))
         else:
             return stdout_value
 
-    def transform_kwargs(self, split_single_char_options=False, **kwargs):
-        """Transforms Python style kwargs into git command line options."""
-        args = list()
+    def environment(self) -> Dict[str, str]:
+        return self._environment
+
+    def update_environment(self, **kwargs: Any) -> Dict[str, Union[str, None]]:
+        """Set environment variables for future git invocations. Return all changed
+        values in a format that can be passed back into this function to revert the
+        changes.
+
+        Examples::
+
+            old_env = self.update_environment(PWD='/tmp')
+            self.update_environment(**old_env)
+
+        :param kwargs:
+            Environment variables to use for git processes.
+
+        :return:
+            Dict that maps environment variables to their old values
+        """
+        old_env = {}
+        for key, value in kwargs.items():
+            # Set value if it is None.
+            if value is not None:
+                old_env[key] = self._environment.get(key)
+                self._environment[key] = value
+            # Remove key from environment if its value is None.
+            elif key in self._environment:
+                old_env[key] = self._environment[key]
+                del self._environment[key]
+        return old_env
+
+    @contextlib.contextmanager
+    def custom_environment(self, **kwargs: Any) -> Iterator[None]:
+        """A context manager around the above :meth:`update_environment` method to
+        restore the environment back to its previous state after operation.
+
+        Examples::
+
+            with self.custom_environment(GIT_SSH='/bin/ssh_wrapper'):
+                repo.remotes.origin.fetch()
+
+        :param kwargs:
+            See :meth:`update_environment`.
+        """
+        old_env = self.update_environment(**kwargs)
+        try:
+            yield
+        finally:
+            self.update_environment(**old_env)
+
+    def transform_kwarg(self, name: str, value: Any, split_single_char_options: bool) -> List[str]:
+        if len(name) == 1:
+            if value is True:
+                return ["-%s" % name]
+            elif value not in (False, None):
+                if split_single_char_options:
+                    return ["-%s" % name, "%s" % value]
+                else:
+                    return ["-%s%s" % (name, value)]
+        else:
+            if value is True:
+                return ["--%s" % dashify(name)]
+            elif value is not False and value is not None:
+                return ["--%s=%s" % (dashify(name), value)]
+        return []
+
+    def transform_kwargs(self, split_single_char_options: bool = True, **kwargs: Any) -> List[str]:
+        """Transform Python-style kwargs into git command line options."""
+        args = []
         for k, v in kwargs.items():
-            if len(k) == 1:
-                if v is True:
-                    args.append("-%s" % k)
-                elif type(v) is not bool:
-                    if split_single_char_options:
-                        args.extend(["-%s" % k, "%s" % v])
-                    else:
-                        args.append("-%s%s" % (k, v))
+            if isinstance(v, (list, tuple)):
+                for value in v:
+                    args += self.transform_kwarg(k, value, split_single_char_options)
             else:
-                if v is True:
-                    args.append("--%s" % dashify(k))
-                elif type(v) is not bool:
-                    args.append("--%s=%s" % (dashify(k), v))
+                args += self.transform_kwarg(k, v, split_single_char_options)
         return args
 
     @classmethod
-    def __unpack_args(cls, arg_list):
-        if not isinstance(arg_list, (list, tuple)):
-            # This is just required for unicode conversion, as subprocess can't handle it
-            # However, in any other case, passing strings (usually utf-8 encoded) is totally fine
-            if not PY3 and isinstance(arg_list, unicode):
-                return [arg_list.encode(defenc)]
-            return [str(arg_list)]
-
-        outlist = list()
-        for arg in arg_list:
-            if isinstance(arg_list, (list, tuple)):
-                outlist.extend(cls.__unpack_args(arg))
-            elif not PY3 and isinstance(arg_list, unicode):
-                outlist.append(arg_list.encode(defenc))
-            # END recursion
-            else:
-                outlist.append(str(arg))
-        # END for each arg
+    def _unpack_args(cls, arg_list: Sequence[str]) -> List[str]:
+        outlist = []
+        if isinstance(arg_list, (list, tuple)):
+            for arg in arg_list:
+                outlist.extend(cls._unpack_args(arg))
+        else:
+            outlist.append(str(arg_list))
+
         return outlist
 
-    def __call__(self, **kwargs):
-        """Specify command line options to the git executable
-        for a subcommand call
+    def __call__(self, **kwargs: Any) -> "Git":
+        """Specify command line options to the git executable for a subcommand call.
 
         :param kwargs:
-            is a dict of keyword arguments.
-            these arguments are passed as in _call_process
-            but will be passed to the git command rather than
-            the subcommand.
-
-        ``Examples``::
-            git(work_tree='/tmp').difftool()"""
-        self._git_options = self.transform_kwargs(
-            split_single_char_options=True, **kwargs)
+            A dict of keyword arguments.
+            These arguments are passed as in :meth:`_call_process`, but will be passed
+            to the git command rather than the subcommand.
+
+        Examples::
+
+            git(work_tree='/tmp').difftool()
+        """
+        self._git_options = self.transform_kwargs(split_single_char_options=True, **kwargs)
         return self
 
-    def _call_process(self, method, *args, **kwargs):
-        """Run the given git command with the specified arguments and return
-        the result as a String
+    @overload
+    def _call_process(
+        self, method: str, *args: None, **kwargs: None
+    ) -> str: ...  # If no args were given, execute the call with all defaults.
+
+    @overload
+    def _call_process(
+        self,
+        method: str,
+        istream: int,
+        as_process: Literal[True],
+        *args: Any,
+        **kwargs: Any,
+    ) -> "Git.AutoInterrupt": ...
+
+    @overload
+    def _call_process(
+        self, method: str, *args: Any, **kwargs: Any
+    ) -> Union[str, bytes, Tuple[int, Union[str, bytes], str], "Git.AutoInterrupt"]: ...
+
+    def _call_process(
+        self, method: str, *args: Any, **kwargs: Any
+    ) -> Union[str, bytes, Tuple[int, Union[str, bytes], str], "Git.AutoInterrupt"]:
+        """Run the given git command with the specified arguments and return the result
+        as a string.
 
         :param method:
-            is the command. Contained "_" characters will be converted to dashes,
-            such as in 'ls_files' to call 'ls-files'.
+            The command. Contained ``_`` characters will be converted to hyphens, such
+            as in ``ls_files`` to call ``ls-files``.
 
         :param args:
-            is the list of arguments. If None is included, it will be pruned.
-            This allows your commands to call git more conveniently as None
-            is realized as non-existent
+            The list of arguments. If ``None`` is included, it will be pruned.
+            This allows your commands to call git more conveniently, as ``None`` is
+            realized as non-existent.
 
         :param kwargs:
-            is a dict of keyword arguments.
-            This function accepts the same optional keyword arguments
-            as execute().
+            Contains key-values for the following:
+
+            - The :meth:`execute()` kwds, as listed in ``execute_kwargs``.
+            - "Command options" to be converted by :meth:`transform_kwargs`.
+            - The ``insert_kwargs_after`` key which its value must match one of
+              ``*args``.
+
+            It also contains any command options, to be appended after the matched arg.
+
+        Examples::
 
-        ``Examples``::
             git.rev_list('master', max_count=10, header=True)
 
-        :return: Same as ``execute``"""
-        # Handle optional arguments prior to calling transform_kwargs
-        # otherwise these'll end up in args, which is bad.
-        _kwargs = dict()
-        for kwarg in execute_kwargs:
-            try:
-                _kwargs[kwarg] = kwargs.pop(kwarg)
-            except KeyError:
-                pass
+        turns into::
 
-        # Prepare the argument list
-        opt_args = self.transform_kwargs(**kwargs)
-        ext_args = self.__unpack_args([a for a in args if a is not None])
+            git rev-list max-count 10 --header master
 
-        args = opt_args + ext_args
+        :return:
+            Same as :meth:`execute`. If no args are given, used :meth:`execute`'s
+            default (especially ``as_process = False``, ``stdout_as_string = True``) and
+            return :class:`str`.
+        """
+        # Handle optional arguments prior to calling transform_kwargs.
+        # Otherwise these'll end up in args, which is bad.
+        exec_kwargs = {k: v for k, v in kwargs.items() if k in execute_kwargs}
+        opts_kwargs = {k: v for k, v in kwargs.items() if k not in execute_kwargs}
 
-        def make_call():
-            call = [self.GIT_PYTHON_GIT_EXECUTABLE]
+        insert_after_this_arg = opts_kwargs.pop("insert_kwargs_after", None)
 
-            # add the git options, the reset to empty
-            # to avoid side_effects
-            call.extend(self._git_options)
-            self._git_options = ()
+        # Prepare the argument list.
 
-            call.extend([dashify(method)])
-            call.extend(args)
-            return call
-        # END utility to recreate call after changes
+        opt_args = self.transform_kwargs(**opts_kwargs)
+        ext_args = self._unpack_args([a for a in args if a is not None])
 
-        if sys.platform == 'win32':
-            try:
-                try:
-                    return self.execute(make_call(), **_kwargs)
-                except WindowsError:
-                    # did we switch to git.cmd already, or was it changed from default ? permanently fail
-                    if self.GIT_PYTHON_GIT_EXECUTABLE != self.git_exec_name:
-                        raise
-                    # END handle overridden variable
-                    type(self).GIT_PYTHON_GIT_EXECUTABLE = self.git_exec_name_win
-
-                    try:
-                        return self.execute(make_call(), **_kwargs)
-                    finally:
-                        import warnings
-                        msg = "WARNING: Automatically switched to use git.cmd as git executable"
-                        msg += ", which reduces performance by ~70%."
-                        msg += "Its recommended to put git.exe into the PATH or to "
-                        msg += "set the %s " % self._git_exec_env_var
-                        msg += "environment variable to the executable's location"
-                        warnings.warn(msg)
-                    # END print of warning
-                # END catch first failure
-            except WindowsError:
-                raise WindowsError("The system cannot find or execute the file at %r" % self.GIT_PYTHON_GIT_EXECUTABLE)
-            # END provide better error message
+        if insert_after_this_arg is None:
+            args_list = opt_args + ext_args
         else:
-            return self.execute(make_call(), **_kwargs)
-        # END handle windows default installation
+            try:
+                index = ext_args.index(insert_after_this_arg)
+            except ValueError as err:
+                raise ValueError(
+                    "Couldn't find argument '%s' in args %s to insert cmd options after"
+                    % (insert_after_this_arg, str(ext_args))
+                ) from err
+            # END handle error
+            args_list = ext_args[: index + 1] + opt_args + ext_args[index + 1 :]
+        # END handle opts_kwargs
+
+        call = [self.GIT_PYTHON_GIT_EXECUTABLE]
+
+        # Add persistent git options.
+        call.extend(self._persistent_git_options)
+
+        # Add the git options, then reset to empty to avoid side effects.
+        call.extend(self._git_options)
+        self._git_options = ()
+
+        call.append(dashify(method))
+        call.extend(args_list)
+
+        return self.execute(call, **exec_kwargs)
 
-    def _parse_object_header(self, header_line):
+    def _parse_object_header(self, header_line: str) -> Tuple[str, str, int]:
         """
         :param header_line:
-            <hex_sha> type_string size_as_int
+            A line of the form::
 
-        :return: (hex_sha, type_string, size_as_int)
+                <hex_sha> type_string size_as_int
 
-        :raise ValueError: if the header contains indication for an error due to
-            incorrect input sha"""
+        :return:
+            (hex_sha, type_string, size_as_int)
+
+        :raise ValueError:
+            If the header contains indication for an error due to incorrect input sha.
+        """
         tokens = header_line.split()
         if len(tokens) != 3:
             if not tokens:
-                raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip()))
+                err_msg = (
+                    f"SHA is empty, possible dubious ownership in the repository "
+                    f"""at {self._working_dir}.\n            If this is unintended run:\n\n         """
+                    f"""             "git config --global --add safe.directory {self._working_dir}" """
+                )
+                raise ValueError(err_msg)
             else:
                 raise ValueError("SHA %s could not be resolved, git returned: %r" % (tokens[0], header_line.strip()))
             # END handle actual return value
@@ -718,20 +1646,21 @@ def _parse_object_header(self, header_line):
             raise ValueError("Failed to parse header: %r" % header_line)
         return (tokens[0], tokens[1], int(tokens[2]))
 
-    def _prepare_ref(self, ref):
-        # required for command to separate refs on stdin, as bytes
-        refstr = ref
+    def _prepare_ref(self, ref: AnyStr) -> bytes:
+        # Required for command to separate refs on stdin, as bytes.
         if isinstance(ref, bytes):
-            # Assume 40 bytes hexsha - bin-to-ascii for some reason returns bytes, not text
-            refstr = ref.decode('ascii')
-        elif not isinstance(ref, string_types):
-            refstr = str(ref)               # could be ref-object
+            # Assume 40 bytes hexsha - bin-to-ascii for some reason returns bytes, not text.
+            refstr: str = ref.decode("ascii")
+        elif not isinstance(ref, str):
+            refstr = str(ref)  # Could be ref-object.
+        else:
+            refstr = ref
 
         if not refstr.endswith("\n"):
             refstr += "\n"
         return refstr.encode(defenc)
 
-    def _get_persistent_cmd(self, attr_name, cmd_name, *args, **kwargs):
+    def _get_persistent_cmd(self, attr_name: str, cmd_name: str, *args: Any, **kwargs: Any) -> "Git.AutoInterrupt":
         cur_val = getattr(self, attr_name)
         if cur_val is not None:
             return cur_val
@@ -741,48 +1670,72 @@ def _get_persistent_cmd(self, attr_name, cmd_name, *args, **kwargs):
 
         cmd = self._call_process(cmd_name, *args, **options)
         setattr(self, attr_name, cmd)
+        cmd = cast("Git.AutoInterrupt", cmd)
         return cmd
 
-    def __get_object_header(self, cmd, ref):
-        cmd.stdin.write(self._prepare_ref(ref))
-        cmd.stdin.flush()
-        return self._parse_object_header(cmd.stdout.readline())
+    def __get_object_header(self, cmd: "Git.AutoInterrupt", ref: AnyStr) -> Tuple[str, str, int]:
+        if cmd.stdin and cmd.stdout:
+            cmd.stdin.write(self._prepare_ref(ref))
+            cmd.stdin.flush()
+            return self._parse_object_header(cmd.stdout.readline())
+        else:
+            raise ValueError("cmd stdin was empty")
 
-    def get_object_header(self, ref):
-        """ Use this method to quickly examine the type and size of the object behind
-        the given ref.
+    def get_object_header(self, ref: str) -> Tuple[str, str, int]:
+        """Use this method to quickly examine the type and size of the object behind the
+        given ref.
 
-        :note: The method will only suffer from the costs of command invocation
-            once and reuses the command in subsequent calls.
+        :note:
+            The method will only suffer from the costs of command invocation once and
+            reuses the command in subsequent calls.
 
-        :return: (hexsha, type_string, size_as_int)"""
+        :return:
+            (hexsha, type_string, size_as_int)
+        """
         cmd = self._get_persistent_cmd("cat_file_header", "cat_file", batch_check=True)
         return self.__get_object_header(cmd, ref)
 
-    def get_object_data(self, ref):
-        """ As get_object_header, but returns object data as well
-        :return: (hexsha, type_string, size_as_int,data_string)
-        :note: not threadsafe"""
+    def get_object_data(self, ref: str) -> Tuple[str, str, int, bytes]:
+        """Similar to :meth:`get_object_header`, but returns object data as well.
+
+        :return:
+            (hexsha, type_string, size_as_int, data_string)
+
+        :note:
+            Not threadsafe.
+        """
         hexsha, typename, size, stream = self.stream_object_data(ref)
         data = stream.read(size)
-        del(stream)
+        del stream
         return (hexsha, typename, size, data)
 
-    def stream_object_data(self, ref):
-        """ As get_object_header, but returns the data as a stream
+    def stream_object_data(self, ref: str) -> Tuple[str, str, int, "Git.CatFileContentStream"]:
+        """Similar to :meth:`get_object_data`, but returns the data as a stream.
+
+        :return:
+            (hexsha, type_string, size_as_int, stream)
 
-        :return: (hexsha, type_string, size_as_int, stream)
-        :note: This method is not threadsafe, you need one independent Command instance per thread to be safe !"""
+        :note:
+            This method is not threadsafe. You need one independent :class:`Git`
+            instance per thread to be safe!
+        """
         cmd = self._get_persistent_cmd("cat_file_all", "cat_file", batch=True)
         hexsha, typename, size = self.__get_object_header(cmd, ref)
-        return (hexsha, typename, size, self.CatFileContentStream(size, cmd.stdout))
+        cmd_stdout = cmd.stdout if cmd.stdout is not None else io.BytesIO()
+        return (hexsha, typename, size, self.CatFileContentStream(size, cmd_stdout))
 
-    def clear_cache(self):
+    def clear_cache(self) -> "Git":
         """Clear all kinds of internal caches to release resources.
 
         Currently persistent commands will be interrupted.
 
-        :return: self"""
+        :return:
+            self
+        """
+        for cmd in (self.cat_file_all, self.cat_file_header):
+            if cmd:
+                cmd.__del__()
+
         self.cat_file_all = None
         self.cat_file_header = None
         return self
diff --git a/git/compat.py b/git/compat.py
index 1ea2119e1..d7d9a55a9 100644
--- a/git/compat.py
+++ b/git/compat.py
@@ -1,68 +1,165 @@
-#-*-coding:utf-8-*-
-# config.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-"""utilities to help provide compatibility with python 3"""
-# flake8: noqa
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
+"""Utilities to help provide compatibility with Python 3.
+
+This module exists for historical reasons. Code outside GitPython may make use of public
+members of this module, but is unlikely to benefit from doing so. GitPython continues to
+use some of these utilities, in some cases for compatibility across different platforms.
+"""
+
+import locale
+import os
 import sys
+import warnings
 
-from gitdb.utils.compat import (
-    PY3,
-    xrange,
-    MAXSIZE,
-    izip,
-)
+from gitdb.utils.encoding import force_bytes, force_text  # noqa: F401
 
-from gitdb.utils.encoding import (
-    string_types,
-    text_type,
-    force_bytes,
-    force_text
+# typing --------------------------------------------------------------------
+
+from typing import (
+    Any,  # noqa: F401
+    AnyStr,
+    Dict,  # noqa: F401
+    IO,  # noqa: F401
+    List,
+    Optional,
+    TYPE_CHECKING,
+    Tuple,  # noqa: F401
+    Type,  # noqa: F401
+    Union,
+    overload,
 )
 
-defenc = sys.getdefaultencoding()
-if PY3:
-    import io
-    FileType = io.IOBase
-    def byte_ord(b):
-        return b
-    def bchr(n):
-        return bytes([n])
-    def mviter(d):
-        return d.values()
-    unicode = str
-else:
-    FileType = file
-    # usually, this is just ascii, which might not enough for our encoding needs
-    # Unless it's set specifically, we override it to be utf-8
-    if defenc == 'ascii':
-        defenc = 'utf-8'
-    byte_ord = ord
-    bchr = chr
-    unicode = unicode
-    def mviter(d):
-        return d.itervalues()
-
-
-def with_metaclass(meta, *bases):
-    """copied from https://github.com/Byron/bcore/blob/master/src/python/butility/future.py#L15"""
-    class metaclass(meta):
-        __call__ = type.__call__
-        __init__ = type.__init__
-
-        def __new__(cls, name, nbases, d):
-            if nbases is None:
-                return type.__new__(cls, name, (), d)
-            # There may be clients who rely on this attribute to be set to a reasonable value, which is why
-            # we set the __metaclass__ attribute explicitly
-            if not PY3 and '___metaclass__' not in d:
-                d['__metaclass__'] = meta
-            # end
-            return meta(name, bases, d)
-        # end
-    # end metaclass
-    return metaclass(meta.__name__ + 'Helper', None, {})
-    # end handle py2
+# ---------------------------------------------------------------------------
+
+
+_deprecated_platform_aliases = {
+    "is_win": os.name == "nt",
+    "is_posix": os.name == "posix",
+    "is_darwin": sys.platform == "darwin",
+}
+
+
+def _getattr(name: str) -> Any:
+    try:
+        value = _deprecated_platform_aliases[name]
+    except KeyError:
+        raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
+
+    warnings.warn(
+        f"{__name__}.{name} and other is_<platform> aliases are deprecated. "
+        "Write the desired os.name or sys.platform check explicitly instead.",
+        DeprecationWarning,
+        stacklevel=2,
+    )
+    return value
+
+
+if not TYPE_CHECKING:  # Preserve static checking for undefined/misspelled attributes.
+    __getattr__ = _getattr
+
+
+def __dir__() -> List[str]:
+    return [*globals(), *_deprecated_platform_aliases]
+
+
+is_win: bool
+"""Deprecated alias for ``os.name == "nt"`` to check for native Windows.
+
+This is deprecated because it is clearer to write out :attr:`os.name` or
+:attr:`sys.platform` checks explicitly, especially in cases where it matters which is
+used.
+
+:note:
+    ``is_win`` is ``False`` on Cygwin, but is often wrongly assumed ``True``. To detect
+    Cygwin, use ``sys.platform == "cygwin"``.
+"""
+
+is_posix: bool
+"""Deprecated alias for ``os.name == "posix"`` to check for Unix-like ("POSIX") systems.
+
+This is deprecated because it clearer to write out :attr:`os.name` or
+:attr:`sys.platform` checks explicitly, especially in cases where it matters which is
+used.
+
+:note:
+    For POSIX systems, more detailed information is available in :attr:`sys.platform`,
+    while :attr:`os.name` is always ``"posix"`` on such systems, including macOS
+    (Darwin).
+"""
+
+is_darwin: bool
+"""Deprecated alias for ``sys.platform == "darwin"`` to check for macOS (Darwin).
+
+This is deprecated because it clearer to write out :attr:`os.name` or
+:attr:`sys.platform` checks explicitly.
+
+:note:
+    For macOS (Darwin), ``os.name == "posix"`` as in other Unix-like systems, while
+    ``sys.platform == "darwin"``.
+"""
+
+defenc = sys.getfilesystemencoding()
+"""The encoding used to convert between Unicode and bytes filenames."""
+
+
+@overload
+def safe_decode(s: None) -> None: ...
+
+
+@overload
+def safe_decode(s: AnyStr) -> str: ...
+
+
+def safe_decode(s: Union[AnyStr, None]) -> Optional[str]:
+    """Safely decode a binary string to Unicode."""
+    if isinstance(s, str):
+        return s
+    elif isinstance(s, bytes):
+        return s.decode(defenc, "surrogateescape")
+    elif s is None:
+        return None
+    else:
+        raise TypeError("Expected bytes or text, but got %r" % (s,))
+
+
+@overload
+def safe_encode(s: None) -> None: ...
+
+
+@overload
+def safe_encode(s: AnyStr) -> bytes: ...
+
+
+def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]:
+    """Safely encode a binary string to Unicode."""
+    if isinstance(s, str):
+        return s.encode(defenc)
+    elif isinstance(s, bytes):
+        return s
+    elif s is None:
+        return None
+    else:
+        raise TypeError("Expected bytes or text, but got %r" % (s,))
+
+
+@overload
+def win_encode(s: None) -> None: ...
+
+
+@overload
+def win_encode(s: AnyStr) -> bytes: ...
+
+
+def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
+    """Encode Unicode strings for process arguments on Windows."""
+    if isinstance(s, str):
+        return s.encode(locale.getpreferredencoding(False))
+    elif isinstance(s, bytes):
+        return s
+    elif s is not None:
+        raise TypeError("Expected bytes or text, but got %r" % (s,))
+    return None
diff --git a/git/config.py b/git/config.py
index 4c4cb4912..345290a39 100644
--- a/git/config.py
+++ b/git/config.py
@@ -1,503 +1,801 @@
-# config.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-"""Module containing module parser implementation able to properly read and write
-configuration files"""
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-import re
-try:
-    import ConfigParser as cp
-except ImportError:
-    # PY3
-    import configparser as cp
+"""Parser for reading and writing configuration files."""
+
+__all__ = ["GitConfigParser", "SectionConstraint"]
+
+import abc
+import configparser as cp
+import fnmatch
+from functools import wraps
 import inspect
+from io import BufferedReader, IOBase
 import logging
-import abc
 import os
+import os.path as osp
+import re
+import sys
 
-from git.odict import OrderedDict
+from git.compat import defenc, force_text
 from git.util import LockFile
-from git.compat import (
-    string_types,
-    FileType,
-    defenc,
-    with_metaclass,
-    PY3
+
+# typing-------------------------------------------------------
+
+from typing import (
+    Any,
+    Callable,
+    Generic,
+    IO,
+    List,
+    Dict,
+    Sequence,
+    TYPE_CHECKING,
+    Tuple,
+    TypeVar,
+    Union,
+    cast,
 )
 
-__all__ = ('GitConfigParser', 'SectionConstraint')
+from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, assert_never, _T
+
+if TYPE_CHECKING:
+    from io import BytesIO
+
+    from git.repo.base import Repo
+
+T_ConfigParser = TypeVar("T_ConfigParser", bound="GitConfigParser")
+T_OMD_value = TypeVar("T_OMD_value", str, bytes, int, float, bool)
 
+if sys.version_info[:3] < (3, 7, 2):
+    # typing.Ordereddict not added until Python 3.7.2.
+    from collections import OrderedDict
 
-log = logging.getLogger('git.config')
+    OrderedDict_OMD = OrderedDict
+else:
+    from typing import OrderedDict
 
+    OrderedDict_OMD = OrderedDict[str, List[T_OMD_value]]  # type: ignore[assignment, misc]
 
-class MetaParserBuilder(abc.ABCMeta):
+# -------------------------------------------------------------
 
-    """Utlity class wrapping base-class methods into decorators that assure read-only properties"""
-    def __new__(metacls, name, bases, clsdict):
+_logger = logging.getLogger(__name__)
+
+CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository")
+"""The configuration level of a configuration file."""
+
+CONDITIONAL_INCLUDE_REGEXP = re.compile(r"(?<=includeIf )\"(gitdir|gitdir/i|onbranch):(.+)\"")
+"""Section pattern to detect conditional includes.
+
+See: https://git-scm.com/docs/git-config#_conditional_includes
+"""
+
+
+class MetaParserBuilder(abc.ABCMeta):  # noqa: B024
+    """Utility class wrapping base-class methods into decorators that assure read-only
+    properties."""
+
+    def __new__(cls, name: str, bases: Tuple, clsdict: Dict[str, Any]) -> "MetaParserBuilder":
+        """Equip all base-class methods with a needs_values decorator, and all non-const
+        methods with a :func:`set_dirty_and_flush_changes` decorator in addition to
+        that.
         """
-        Equip all base-class methods with a needs_values decorator, and all non-const methods
-        with a set_dirty_and_flush_changes decorator in addition to that."""
-        kmm = '_mutating_methods_'
+        kmm = "_mutating_methods_"
         if kmm in clsdict:
             mutating_methods = clsdict[kmm]
             for base in bases:
                 methods = (t for t in inspect.getmembers(base, inspect.isroutine) if not t[0].startswith("_"))
-                for name, method in methods:
-                    if name in clsdict:
+                for method_name, method in methods:
+                    if method_name in clsdict:
                         continue
                     method_with_values = needs_values(method)
-                    if name in mutating_methods:
+                    if method_name in mutating_methods:
                         method_with_values = set_dirty_and_flush_changes(method_with_values)
                     # END mutating methods handling
 
-                    clsdict[name] = method_with_values
+                    clsdict[method_name] = method_with_values
                 # END for each name/method pair
             # END for each base
         # END if mutating methods configuration is set
 
-        new_type = super(MetaParserBuilder, metacls).__new__(metacls, name, bases, clsdict)
+        new_type = super().__new__(cls, name, bases, clsdict)
         return new_type
 
 
-def needs_values(func):
-    """Returns method assuring we read values (on demand) before we try to access them"""
+def needs_values(func: Callable[..., _T]) -> Callable[..., _T]:
+    """Return a method for ensuring we read values (on demand) before we try to access
+    them."""
 
-    def assure_data_present(self, *args, **kwargs):
+    @wraps(func)
+    def assure_data_present(self: "GitConfigParser", *args: Any, **kwargs: Any) -> _T:
         self.read()
         return func(self, *args, **kwargs)
+
     # END wrapper method
-    assure_data_present.__name__ = func.__name__
     return assure_data_present
 
 
-def set_dirty_and_flush_changes(non_const_func):
-    """Return method that checks whether given non constant function may be called.
-    If so, the instance will be set dirty.
-    Additionally, we flush the changes right to disk"""
+def set_dirty_and_flush_changes(non_const_func: Callable[..., _T]) -> Callable[..., _T]:
+    """Return a method that checks whether given non constant function may be called.
 
-    def flush_changes(self, *args, **kwargs):
+    If so, the instance will be set dirty. Additionally, we flush the changes right to
+    disk.
+    """
+
+    def flush_changes(self: "GitConfigParser", *args: Any, **kwargs: Any) -> _T:
         rval = non_const_func(self, *args, **kwargs)
+        self._dirty = True
         self.write()
         return rval
+
     # END wrapper method
     flush_changes.__name__ = non_const_func.__name__
     return flush_changes
 
 
-class SectionConstraint(object):
-
+class SectionConstraint(Generic[T_ConfigParser]):
     """Constrains a ConfigParser to only option commands which are constrained to
     always use the section we have been initialized with.
 
-    It supports all ConfigParser methods that operate on an option"""
+    It supports all ConfigParser methods that operate on an option.
+
+    :note:
+        If used as a context manager, will release the wrapped ConfigParser.
+    """
+
     __slots__ = ("_config", "_section_name")
-    _valid_attrs_ = ("get_value", "set_value", "get", "set", "getint", "getfloat", "getboolean", "has_option",
-                     "remove_section", "remove_option", "options")
 
-    def __init__(self, config, section):
+    _valid_attrs_ = (
+        "get_value",
+        "set_value",
+        "get",
+        "set",
+        "getint",
+        "getfloat",
+        "getboolean",
+        "has_option",
+        "remove_section",
+        "remove_option",
+        "options",
+    )
+
+    def __init__(self, config: T_ConfigParser, section: str) -> None:
         self._config = config
         self._section_name = section
 
-    def __del__(self):
+    def __del__(self) -> None:
         # Yes, for some reason, we have to call it explicitly for it to work in PY3 !
         # Apparently __del__ doesn't get call anymore if refcount becomes 0
         # Ridiculous ... .
         self._config.release()
 
-    def __getattr__(self, attr):
+    def __getattr__(self, attr: str) -> Any:
         if attr in self._valid_attrs_:
             return lambda *args, **kwargs: self._call_config(attr, *args, **kwargs)
-        return super(SectionConstraint, self).__getattribute__(attr)
+        return super().__getattribute__(attr)
 
-    def _call_config(self, method, *args, **kwargs):
-        """Call the configuration at the given method which must take a section name
-        as first argument"""
+    def _call_config(self, method: str, *args: Any, **kwargs: Any) -> Any:
+        """Call the configuration at the given method which must take a section name as
+        first argument."""
         return getattr(self._config, method)(self._section_name, *args, **kwargs)
 
     @property
-    def config(self):
-        """return: Configparser instance we constrain"""
+    def config(self) -> T_ConfigParser:
+        """return: ConfigParser instance we constrain"""
         return self._config
 
-    def release(self):
-        """Equivalent to GitConfigParser.release(), which is called on our underlying parser instance"""
+    def release(self) -> None:
+        """Equivalent to :meth:`GitConfigParser.release`, which is called on our
+        underlying parser instance."""
         return self._config.release()
 
+    def __enter__(self) -> "SectionConstraint[T_ConfigParser]":
+        self._config.__enter__()
+        return self
+
+    def __exit__(self, exception_type: str, exception_value: str, traceback: str) -> None:
+        self._config.__exit__(exception_type, exception_value, traceback)
+
+
+class _OMD(OrderedDict_OMD):
+    """Ordered multi-dict."""
 
-class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, object)):
+    def __setitem__(self, key: str, value: _T) -> None:
+        super().__setitem__(key, [value])
 
+    def add(self, key: str, value: Any) -> None:
+        if key not in self:
+            super().__setitem__(key, [value])
+            return
+
+        super().__getitem__(key).append(value)
+
+    def setall(self, key: str, values: List[_T]) -> None:
+        super().__setitem__(key, values)
+
+    def __getitem__(self, key: str) -> Any:
+        return super().__getitem__(key)[-1]
+
+    def getlast(self, key: str) -> Any:
+        return super().__getitem__(key)[-1]
+
+    def setlast(self, key: str, value: Any) -> None:
+        if key not in self:
+            super().__setitem__(key, [value])
+            return
+
+        prior = super().__getitem__(key)
+        prior[-1] = value
+
+    def get(self, key: str, default: Union[_T, None] = None) -> Union[_T, None]:
+        return super().get(key, [default])[-1]
+
+    def getall(self, key: str) -> List[_T]:
+        return super().__getitem__(key)
+
+    def items(self) -> List[Tuple[str, _T]]:  # type: ignore[override]
+        """List of (key, last value for key)."""
+        return [(k, self[k]) for k in self]
+
+    def items_all(self) -> List[Tuple[str, List[_T]]]:
+        """List of (key, list of values for key)."""
+        return [(k, self.getall(k)) for k in self]
+
+
+def get_config_path(config_level: Lit_config_levels) -> str:
+    # We do not support an absolute path of the gitconfig on Windows.
+    # Use the global config instead.
+    if sys.platform == "win32" and config_level == "system":
+        config_level = "global"
+
+    if config_level == "system":
+        return "/etc/gitconfig"
+    elif config_level == "user":
+        config_home = os.environ.get("XDG_CONFIG_HOME") or osp.join(os.environ.get("HOME", "~"), ".config")
+        return osp.normpath(osp.expanduser(osp.join(config_home, "git", "config")))
+    elif config_level == "global":
+        return osp.normpath(osp.expanduser("~/.gitconfig"))
+    elif config_level == "repository":
+        raise ValueError("No repo to get repository configuration from. Use Repo._get_config_path")
+    else:
+        # Should not reach here. Will raise ValueError if does. Static typing will warn
+        # about missing elifs.
+        assert_never(  # type: ignore[unreachable]
+            config_level,
+            ValueError(f"Invalid configuration level: {config_level!r}"),
+        )
+
+
+class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
     """Implements specifics required to read git style configuration files.
 
-    This variation behaves much like the git.config command such that the configuration
-    will be read on demand based on the filepath given during initialization.
+    This variation behaves much like the :manpage:`git-config(1)` command, such that the
+    configuration will be read on demand based on the filepath given during
+    initialization.
 
     The changes will automatically be written once the instance goes out of scope, but
     can be triggered manually as well.
 
-    The configuration file will be locked if you intend to change values preventing other
-    instances to write concurrently.
+    The configuration file will be locked if you intend to change values preventing
+    other instances to write concurrently.
 
     :note:
         The config is case-sensitive even when queried, hence section and option names
-        must match perfectly."""
+        must match perfectly.
+
+    :note:
+        If used as a context manager, this will release the locked file.
+    """
 
-    #{ Configuration
-    # The lock type determines the type of lock to use in new configuration readers.
-    # They must be compatible to the LockFile interface.
-    # A suitable alternative would be the BlockingLockFile
+    # { Configuration
     t_lock = LockFile
-    re_comment = re.compile('^\s*[#;]')
+    """The lock type determines the type of lock to use in new configuration readers.
 
-    #} END configuration
+    They must be compatible to the :class:`~git.util.LockFile` interface.
+    A suitable alternative would be the :class:`~git.util.BlockingLockFile`.
+    """
 
-    OPTCRE = re.compile(
-        r'\s*(?P<option>[^:=\s][^:=]*)'       # very permissive, incuding leading whitespace
-        r'\s*(?P<vi>[:=])\s*'                 # any number of space/tab,
-                                              # followed by separator
-                                              # (either : or =), followed
-                                              # by any # space/tab
-        r'(?P<value>.*)$'                     # everything up to eol
-    )
+    re_comment = re.compile(r"^\s*[#;]")
+    # } END configuration
 
-    # list of RawConfigParser methods able to change the instance
-    _mutating_methods_ = ("add_section", "remove_section", "remove_option", "set")
+    optvalueonly_source = r"\s*(?P<option>[^:=\s][^:=]*)"
+
+    OPTVALUEONLY = re.compile(optvalueonly_source)
+
+    OPTCRE = re.compile(optvalueonly_source + r"\s*(?P<vi>[:=])\s*" + r"(?P<value>.*)$")
 
-    def __init__(self, file_or_files, read_only=True, merge_includes=True):
-        """Initialize a configuration reader to read the given file_or_files and to
-        possibly allow changes to it by setting read_only False
+    del optvalueonly_source
+
+    _mutating_methods_ = ("add_section", "remove_section", "remove_option", "set")
+    """Names of :class:`~configparser.RawConfigParser` methods able to change the
+    instance."""
+
+    def __init__(
+        self,
+        file_or_files: Union[None, PathLike, "BytesIO", Sequence[Union[PathLike, "BytesIO"]]] = None,
+        read_only: bool = True,
+        merge_includes: bool = True,
+        config_level: Union[Lit_config_levels, None] = None,
+        repo: Union["Repo", None] = None,
+    ) -> None:
+        """Initialize a configuration reader to read the given `file_or_files` and to
+        possibly allow changes to it by setting `read_only` False.
 
         :param file_or_files:
-            A single file path or file objects or multiple of these
+            A file path or file object, or a sequence of possibly more than one of them.
 
         :param read_only:
-            If True, the ConfigParser may only read the data , but not change it.
-            If False, only a single file path or file object may be given. We will write back the changes
-            when they happen, or when the ConfigParser is released. This will not happen if other
-            configuration files have been included
-        :param merge_includes: if True, we will read files mentioned in [include] sections and merge their
-            contents into ours. This makes it impossible to write back an individual configuration file.
-            Thus, if you want to modify a single conifguration file, turn this off to leave the original
-            dataset unaltered when reading it."""
-        cp.RawConfigParser.__init__(self, dict_type=OrderedDict)
-
-        # Used in python 3, needs to stay in sync with sections for underlying implementation to work
-        if not hasattr(self, '_proxies'):
+            If ``True``, the ConfigParser may only read the data, but not change it.
+            If ``False``, only a single file path or file object may be given. We will
+            write back the changes when they happen, or when the ConfigParser is
+            released. This will not happen if other configuration files have been
+            included.
+
+        :param merge_includes:
+            If ``True``, we will read files mentioned in ``[include]`` sections and
+            merge their contents into ours. This makes it impossible to write back an
+            individual configuration file. Thus, if you want to modify a single
+            configuration file, turn this off to leave the original dataset unaltered
+            when reading it.
+
+        :param repo:
+            Reference to repository to use if ``[includeIf]`` sections are found in
+            configuration files.
+        """
+        cp.RawConfigParser.__init__(self, dict_type=_OMD)
+        self._dict: Callable[..., _OMD]
+        self._defaults: _OMD
+        self._sections: _OMD
+
+        # Used in Python 3. Needs to stay in sync with sections for underlying
+        # implementation to work.
+        if not hasattr(self, "_proxies"):
             self._proxies = self._dict()
 
-        self._file_or_files = file_or_files
+        if file_or_files is not None:
+            self._file_or_files: Union[PathLike, "BytesIO", Sequence[Union[PathLike, "BytesIO"]]] = file_or_files
+        else:
+            if config_level is None:
+                if read_only:
+                    self._file_or_files = [
+                        get_config_path(cast(Lit_config_levels, f)) for f in CONFIG_LEVELS if f != "repository"
+                    ]
+                else:
+                    raise ValueError("No configuration level or configuration files specified")
+            else:
+                self._file_or_files = [get_config_path(config_level)]
+
         self._read_only = read_only
+        self._dirty = False
         self._is_initialized = False
         self._merge_includes = merge_includes
-        self._lock = None
-
-        if not read_only:
-            if isinstance(file_or_files, (tuple, list)):
-                raise ValueError(
-                    "Write-ConfigParsers can operate on a single file only, multiple files have been passed")
-            # END single file check
+        self._repo = repo
+        self._lock: Union["LockFile", None] = None
+        self._acquire_lock()
+
+    def _acquire_lock(self) -> None:
+        if not self._read_only:
+            if not self._lock:
+                if isinstance(self._file_or_files, (str, os.PathLike)):
+                    file_or_files = self._file_or_files
+                elif isinstance(self._file_or_files, (tuple, list, Sequence)):
+                    raise ValueError(
+                        "Write-ConfigParsers can operate on a single file only, multiple files have been passed"
+                    )
+                else:
+                    file_or_files = self._file_or_files.name
 
-            if not isinstance(file_or_files, string_types):
-                file_or_files = file_or_files.name
-            # END get filename from handle/stream
-            # initialize lock base - we want to write
-            self._lock = self.t_lock(file_or_files)
+                # END get filename from handle/stream
+                # Initialize lock base - we want to write.
+                self._lock = self.t_lock(file_or_files)
+            # END lock check
 
             self._lock._obtain_lock()
         # END read-only check
 
-    def __del__(self):
-        """Write pending changes if required and release locks"""
-        # NOTE: only consistent in PY2
+    def __del__(self) -> None:
+        """Write pending changes if required and release locks."""
+        # NOTE: Only consistent in Python 2.
         self.release()
 
-    def release(self):
-        """Flush changes and release the configuration write lock. This instance must not be used anymore afterwards.
-        In Python 3, it's required to explicitly release locks and flush changes, as __del__ is not called
-        deterministically anymore."""
-        # checking for the lock here makes sure we do not raise during write()
-        # in case an invalid parser was created who could not get a lock
+    def __enter__(self) -> "GitConfigParser":
+        self._acquire_lock()
+        return self
+
+    def __exit__(self, *args: Any) -> None:
+        self.release()
+
+    def release(self) -> None:
+        """Flush changes and release the configuration write lock. This instance must
+        not be used anymore afterwards.
+
+        In Python 3, it's required to explicitly release locks and flush changes, as
+        ``__del__`` is not called deterministically anymore.
+        """
+        # Checking for the lock here makes sure we do not raise during write()
+        # in case an invalid parser was created who could not get a lock.
         if self.read_only or (self._lock and not self._lock._has_lock()):
             return
 
         try:
-            try:
-                self.write()
-            except IOError:
-                log.error("Exception during destruction of GitConfigParser", exc_info=True)
-            except ReferenceError:
-                # This happens in PY3 ... and usually means that some state cannot be written
-                # as the sections dict cannot be iterated
-                # Usually when shutting down the interpreter, don'y know how to fix this
-                pass
+            self.write()
+        except IOError:
+            _logger.error("Exception during destruction of GitConfigParser", exc_info=True)
+        except ReferenceError:
+            # This happens in Python 3... and usually means that some state cannot be
+            # written as the sections dict cannot be iterated. This usually happens when
+            # the interpreter is shutting down. Can it be fixed?
+            pass
         finally:
-            self._lock._release_lock()
+            if self._lock is not None:
+                self._lock._release_lock()
 
-    def optionxform(self, optionstr):
-        """Do not transform options in any way when writing"""
+    def optionxform(self, optionstr: str) -> str:
+        """Do not transform options in any way when writing."""
         return optionstr
 
-    def _read(self, fp, fpname):
-        """A direct copy of the py2.4 version of the super class's _read method
-        to assure it uses ordered dicts. Had to change one line to make it work.
-
-        Future versions have this fixed, but in fact its quite embarassing for the
-        guys not to have done it right in the first place !
-
-        Removed big comments to make it more compact.
+    def _read(self, fp: Union[BufferedReader, IO[bytes]], fpname: str) -> None:
+        """Originally a direct copy of the Python 2.4 version of
+        :meth:`RawConfigParser._read <configparser.RawConfigParser._read>`, to ensure it
+        uses ordered dicts.
 
-        Made sure it ignores initial whitespace as git uses tabs"""
-        cursect = None                            # None, or a dictionary
+        The ordering bug was fixed in Python 2.4, and dict itself keeps ordering since
+        Python 3.7. This has some other changes, especially that it ignores initial
+        whitespace, since git uses tabs. (Big comments are removed to be more compact.)
+        """
+        cursect = None  # None, or a dictionary.
         optname = None
         lineno = 0
         is_multi_line = False
-        e = None                                  # None, or an exception
+        e = None  # None, or an exception.
 
-        def string_decode(v):
-            if v[-1] == '\\':
+        def string_decode(v: str) -> str:
+            if v and v.endswith("\\"):
                 v = v[:-1]
-            # end cut trailing escapes to prevent decode error
+            # END cut trailing escapes to prevent decode error
 
-            if PY3:
-                return v.encode(defenc).decode('unicode_escape')
-            else:
-                return v.decode('string_escape')
-            # end
-        # end
+            return v.encode(defenc).decode("unicode_escape")
+
+        # END string_decode
 
         while True:
-            # we assume to read binary !
+            # We assume to read binary!
             line = fp.readline().decode(defenc)
             if not line:
                 break
             lineno = lineno + 1
-            # comment or blank line?
-            if line.strip() == '' or self.re_comment.match(line):
+            # Comment or blank line?
+            if line.strip() == "" or self.re_comment.match(line):
                 continue
-            if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
-                # no leading whitespace
+            if line.split(None, 1)[0].lower() == "rem" and line[0] in "rR":
+                # No leading whitespace.
                 continue
 
-            # is it a section header?
+            # Is it a section header?
             mo = self.SECTCRE.match(line.strip())
             if not is_multi_line and mo:
-                sectname = mo.group('header').strip()
+                sectname: str = mo.group("header").strip()
                 if sectname in self._sections:
                     cursect = self._sections[sectname]
                 elif sectname == cp.DEFAULTSECT:
                     cursect = self._defaults
                 else:
-                    cursect = self._dict((('__name__', sectname),))
+                    cursect = self._dict((("__name__", sectname),))
                     self._sections[sectname] = cursect
                     self._proxies[sectname] = None
-                # So sections can't start with a continuation line
+                # So sections can't start with a continuation line.
                 optname = None
-            # no section header in the file?
+            # No section header in the file?
             elif cursect is None:
                 raise cp.MissingSectionHeaderError(fpname, lineno, line)
-            # an option line?
+            # An option line?
             elif not is_multi_line:
                 mo = self.OPTCRE.match(line)
                 if mo:
-                    # We might just have handled the last line, which could contain a quotation we want to remove
-                    optname, vi, optval = mo.group('option', 'vi', 'value')
-                    if vi in ('=', ':') and ';' in optval:
-                        pos = optval.find(';')
+                    # We might just have handled the last line, which could contain a quotation we want to remove.
+                    optname, vi, optval = mo.group("option", "vi", "value")
+                    optname = self.optionxform(optname.rstrip())
+
+                    if vi in ("=", ":") and ";" in optval and not optval.strip().startswith('"'):
+                        pos = optval.find(";")
                         if pos != -1 and optval[pos - 1].isspace():
                             optval = optval[:pos]
                     optval = optval.strip()
-                    if optval == '""':
-                        optval = ''
-                    # end handle empty string
-                    optname = self.optionxform(optname.rstrip())
-                    if len(optval) > 1 and optval[0] == '"' and optval[-1] != '"':
+
+                    if len(optval) < 2 or optval[0] != '"':
+                        # Does not open quoting.
+                        pass
+                    elif optval[-1] != '"':
+                        # Opens quoting and does not close: appears to start multi-line quoting.
                         is_multi_line = True
                         optval = string_decode(optval[1:])
-                    # end handle multi-line
-                    cursect[optname] = optval
+                    elif optval.find("\\", 1, -1) == -1 and optval.find('"', 1, -1) == -1:
+                        # Opens and closes quoting. Single line, and all we need is quote removal.
+                        optval = optval[1:-1]
+                    # TODO: Handle other quoted content, especially well-formed backslash escapes.
+
+                    # Preserves multiple values for duplicate optnames.
+                    cursect.add(optname, optval)
                 else:
-                    if not e:
-                        e = cp.ParsingError(fpname)
-                    e.append(lineno, repr(line))
+                    # Check if it's an option with no value - it's just ignored by git.
+                    if not self.OPTVALUEONLY.match(line):
+                        if not e:
+                            e = cp.ParsingError(fpname)
+                        e.append(lineno, repr(line))
                     continue
             else:
                 line = line.rstrip()
                 if line.endswith('"'):
                     is_multi_line = False
                     line = line[:-1]
-                # end handle quotations
-                cursect[optname] += string_decode(line)
+                # END handle quotations
+                optval = cursect.getlast(optname)
+                cursect.setlast(optname, optval + string_decode(line))
             # END parse section or option
         # END while reading
 
-        # if any parsing errors occurred, raise an exception
+        # If any parsing errors occurred, raise an exception.
         if e:
             raise e
 
-    def _has_includes(self):
-        return self._merge_includes and self.has_section('include')
+    def _has_includes(self) -> Union[bool, int]:
+        return self._merge_includes and len(self._included_paths())
+
+    def _included_paths(self) -> List[Tuple[str, str]]:
+        """List all paths that must be included to configuration.
+
+        :return:
+            The list of paths, where each path is a tuple of (option, value).
+        """
+        paths = []
 
-    def read(self):
-        """Reads the data stored in the files we have been initialized with. It will
-        ignore files that cannot be read, possibly leaving an empty configuration
+        for section in self.sections():
+            if section == "include":
+                paths += self.items(section)
 
-        :return: Nothing
-        :raise IOError: if a file cannot be handled"""
+            match = CONDITIONAL_INCLUDE_REGEXP.search(section)
+            if match is None or self._repo is None:
+                continue
+
+            keyword = match.group(1)
+            value = match.group(2).strip()
+
+            if keyword in ["gitdir", "gitdir/i"]:
+                value = osp.expanduser(value)
+
+                if not any(value.startswith(s) for s in ["./", "/"]):
+                    value = "**/" + value
+                if value.endswith("/"):
+                    value += "**"
+
+                # Ensure that glob is always case insensitive if required.
+                if keyword.endswith("/i"):
+                    value = re.sub(
+                        r"[a-zA-Z]",
+                        lambda m: "[{}{}]".format(m.group().lower(), m.group().upper()),
+                        value,
+                    )
+                if self._repo.git_dir:
+                    if fnmatch.fnmatchcase(str(self._repo.git_dir), value):
+                        paths += self.items(section)
+
+            elif keyword == "onbranch":
+                try:
+                    branch_name = self._repo.active_branch.name
+                except TypeError:
+                    # Ignore section if active branch cannot be retrieved.
+                    continue
+
+                if fnmatch.fnmatchcase(branch_name, value):
+                    paths += self.items(section)
+
+        return paths
+
+    def read(self) -> None:  # type: ignore[override]
+        """Read the data stored in the files we have been initialized with.
+
+        This will ignore files that cannot be read, possibly leaving an empty
+        configuration.
+
+        :raise IOError:
+            If a file cannot be handled.
+        """
         if self._is_initialized:
             return
         self._is_initialized = True
 
-        if not isinstance(self._file_or_files, (tuple, list)):
+        files_to_read: List[Union[PathLike, IO]] = [""]
+        if isinstance(self._file_or_files, (str, os.PathLike)):
+            # For str or Path, as str is a type of Sequence.
             files_to_read = [self._file_or_files]
-        else:
+        elif not isinstance(self._file_or_files, (tuple, list, Sequence)):
+            # Could merge with above isinstance once runtime type known.
+            files_to_read = [self._file_or_files]
+        else:  # For lists or tuples.
             files_to_read = list(self._file_or_files)
-        # end assure we have a copy of the paths to handle
+        # END ensure we have a copy of the paths to handle
 
         seen = set(files_to_read)
         num_read_include_files = 0
         while files_to_read:
             file_path = files_to_read.pop(0)
-            fp = file_path
-            close_fp = False
+            file_ok = False
 
-            # assume a path if it is not a file-object
-            if not hasattr(fp, "seek"):
+            if hasattr(file_path, "seek"):
+                # Must be a file-object.
+                # TODO: Replace cast with assert to narrow type, once sure.
+                file_path = cast(IO[bytes], file_path)
+                self._read(file_path, file_path.name)
+            else:
+                # Assume a path if it is not a file-object.
+                file_path = cast(PathLike, file_path)
                 try:
-                    fp = open(file_path, 'rb')
-                    close_fp = True
+                    with open(file_path, "rb") as fp:
+                        file_ok = True
+                        self._read(fp, fp.name)
                 except IOError:
                     continue
-            # END fp handling
 
-            try:
-                self._read(fp, fp.name)
-            finally:
-                if close_fp:
-                    fp.close()
-            # END read-handling
-
-            # Read includes and append those that we didn't handle yet
-            # We expect all paths to be normalized and absolute (and will assure that is the case)
+            # Read includes and append those that we didn't handle yet. We expect all
+            # paths to be normalized and absolute (and will ensure that is the case).
             if self._has_includes():
-                for _, include_path in self.items('include'):
-                    if not os.path.isabs(include_path):
-                        if not close_fp:
+                for _, include_path in self._included_paths():
+                    if include_path.startswith("~"):
+                        include_path = osp.expanduser(include_path)
+                    if not osp.isabs(include_path):
+                        if not file_ok:
                             continue
-                        # end ignore relative paths if we don't know the configuration file path
-                        assert os.path.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
-                        include_path = os.path.join(os.path.dirname(file_path), include_path)
-                    # end make include path absolute
-                    include_path = os.path.normpath(include_path)
+                        # END ignore relative paths if we don't know the configuration file path
+                        file_path = cast(PathLike, file_path)
+                        assert osp.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
+                        include_path = osp.join(osp.dirname(file_path), include_path)
+                    # END make include path absolute
+                    include_path = osp.normpath(include_path)
                     if include_path in seen or not os.access(include_path, os.R_OK):
                         continue
                     seen.add(include_path)
-                    files_to_read.append(include_path)
+                    # Insert included file to the top to be considered first.
+                    files_to_read.insert(0, include_path)
                     num_read_include_files += 1
-                # each include path in configuration file
-            # end handle includes
+                # END each include path in configuration file
+            # END handle includes
         # END for each file object to read
 
-        # If there was no file included, we can safely write back (potentially) the configuration file
-        # without altering it's meaning
+        # If there was no file included, we can safely write back (potentially) the
+        # configuration file without altering its meaning.
         if num_read_include_files == 0:
             self._merge_includes = False
-        # end
 
-    def _write(self, fp):
+    def _write(self, fp: IO) -> None:
         """Write an .ini-format representation of the configuration state in
-        git compatible format"""
-        def write_section(name, section_dict):
+        git compatible format."""
+
+        def write_section(name: str, section_dict: _OMD) -> None:
             fp.write(("[%s]\n" % name).encode(defenc))
-            for (key, value) in section_dict.items():
-                if key != "__name__":
-                    fp.write(("\t%s = %s\n" % (key, str(value).replace('\n', '\n\t'))).encode(defenc))
+
+            values: Sequence[str]  # Runtime only gets str in tests, but should be whatever _OMD stores.
+            v: str
+            for key, values in section_dict.items_all():
+                if key == "__name__":
+                    continue
+
+                for v in values:
+                    fp.write(("\t%s = %s\n" % (key, self._value_to_string(v).replace("\n", "\n\t"))).encode(defenc))
                 # END if key is not __name__
+
         # END section writing
 
         if self._defaults:
             write_section(cp.DEFAULTSECT, self._defaults)
+        value: _OMD
+
         for name, value in self._sections.items():
             write_section(name, value)
 
-    def items(self, section_name):
+    def items(self, section_name: str) -> List[Tuple[str, str]]:  # type: ignore[override]
         """:return: list((option, value), ...) pairs of all items in the given section"""
-        return [(k, v) for k, v in super(GitConfigParser, self).items(section_name) if k != '__name__']
+        return [(k, v) for k, v in super().items(section_name) if k != "__name__"]
+
+    def items_all(self, section_name: str) -> List[Tuple[str, List[str]]]:
+        """:return: list((option, [values...]), ...) pairs of all items in the given section"""
+        rv = _OMD(self._defaults)
+
+        for k, vs in self._sections[section_name].items_all():
+            if k == "__name__":
+                continue
+
+            if k in rv and rv.getall(k) == vs:
+                continue
+
+            for v in vs:
+                rv.add(k, v)
+
+        return rv.items_all()
 
     @needs_values
-    def write(self):
-        """Write changes to our file, if there are changes at all
+    def write(self) -> None:
+        """Write changes to our file, if there are changes at all.
 
-        :raise IOError: if this is a read-only writer instance or if we could not obtain
-            a file lock"""
+        :raise IOError:
+            If this is a read-only writer instance or if we could not obtain a file
+            lock.
+        """
         self._assure_writable("write")
+        if not self._dirty:
+            return
 
         if isinstance(self._file_or_files, (list, tuple)):
-            raise AssertionError("Cannot write back if there is not exactly a single file to write to, have %i files"
-                                 % len(self._file_or_files))
-        # end assert multiple files
+            raise AssertionError(
+                "Cannot write back if there is not exactly a single file to write to, have %i files"
+                % len(self._file_or_files)
+            )
+        # END assert multiple files
 
         if self._has_includes():
-            log.debug("Skipping write-back of confiuration file as include files were merged in." +
-                      "Set merge_includes=False to prevent this.")
+            _logger.debug(
+                "Skipping write-back of configuration file as include files were merged in."
+                + "Set merge_includes=False to prevent this."
+            )
             return
-        # end
+        # END stop if we have include files
 
         fp = self._file_or_files
-        close_fp = False
 
-        # we have a physical file on disk, so get a lock
-        if isinstance(fp, string_types + (FileType, )):
+        # We have a physical file on disk, so get a lock.
+        is_file_lock = isinstance(fp, (str, os.PathLike, IOBase))  # TODO: Use PathLike (having dropped 3.5).
+        if is_file_lock and self._lock is not None:  # Else raise error?
             self._lock._obtain_lock()
-        # END get lock for physical files
 
         if not hasattr(fp, "seek"):
-            fp = open(self._file_or_files, "wb")
-            close_fp = True
+            fp = cast(PathLike, fp)
+            with open(fp, "wb") as fp_open:
+                self._write(fp_open)
         else:
+            fp = cast("BytesIO", fp)
             fp.seek(0)
-            # make sure we do not overwrite into an existing file
-            if hasattr(fp, 'truncate'):
+            # Make sure we do not overwrite into an existing file.
+            if hasattr(fp, "truncate"):
                 fp.truncate()
-            # END
-        # END handle stream or file
-
-        # WRITE DATA
-        try:
             self._write(fp)
-        finally:
-            if close_fp:
-                fp.close()
-        # END data writing
 
-        # we do not release the lock - it will be done automatically once the
-        # instance vanishes
-
-    def _assure_writable(self, method_name):
+    def _assure_writable(self, method_name: str) -> None:
         if self.read_only:
             raise IOError("Cannot execute non-constant method %s.%s" % (self, method_name))
 
-    @needs_values
-    @set_dirty_and_flush_changes
-    def add_section(self, section):
-        """Assures added options will stay in order"""
-        return super(GitConfigParser, self).add_section(section)
+    def add_section(self, section: str) -> None:
+        """Assures added options will stay in order."""
+        return super().add_section(section)
 
     @property
-    def read_only(self):
-        """:return: True if this instance may change the configuration file"""
+    def read_only(self) -> bool:
+        """:return: ``True`` if this instance may change the configuration file"""
         return self._read_only
 
-    def get_value(self, section, option, default=None):
-        """
+    # FIXME: Figure out if default or return type can really include bool.
+    def get_value(
+        self,
+        section: str,
+        option: str,
+        default: Union[int, float, str, bool, None] = None,
+    ) -> Union[int, float, str, bool]:
+        """Get an option's value.
+
+        If multiple values are specified for this option in the section, the last one
+        specified is returned.
+
         :param default:
-            If not None, the given default value will be returned in case
-            the option did not exist
-        :return: a properly typed value, either int, float or string
+            If not ``None``, the given default value will be returned in case the option
+            did not exist.
+
+        :return:
+            A properly typed value, either int, float or string
 
-        :raise TypeError: in case the value could not be understood
-            Otherwise the exceptions known to the ConfigParser will be raised."""
+        :raise TypeError:
+            In case the value could not be understood.
+            Otherwise the exceptions known to the ConfigParser will be raised.
+        """
         try:
             valuestr = self.get(section, option)
         except Exception:
@@ -505,44 +803,149 @@ def get_value(self, section, option, default=None):
                 return default
             raise
 
+        return self._string_to_value(valuestr)
+
+    def get_values(
+        self,
+        section: str,
+        option: str,
+        default: Union[int, float, str, bool, None] = None,
+    ) -> List[Union[int, float, str, bool]]:
+        """Get an option's values.
+
+        If multiple values are specified for this option in the section, all are
+        returned.
+
+        :param default:
+            If not ``None``, a list containing the given default value will be returned
+            in case the option did not exist.
+
+        :return:
+            A list of properly typed values, either int, float or string
+
+        :raise TypeError:
+            In case the value could not be understood.
+            Otherwise the exceptions known to the ConfigParser will be raised.
+        """
+        try:
+            self.sections()
+            lst = self._sections[section].getall(option)
+        except Exception:
+            if default is not None:
+                return [default]
+            raise
+
+        return [self._string_to_value(valuestr) for valuestr in lst]
+
+    def _string_to_value(self, valuestr: str) -> Union[int, float, str, bool]:
         types = (int, float)
         for numtype in types:
             try:
                 val = numtype(valuestr)
-
                 # truncated value ?
                 if val != float(valuestr):
                     continue
-
                 return val
             except (ValueError, TypeError):
                 continue
         # END for each numeric type
 
-        # try boolean values as git uses them
+        # Try boolean values as git uses them.
         vl = valuestr.lower()
-        if vl == 'false':
+        if vl == "false":
             return False
-        if vl == 'true':
+        if vl == "true":
             return True
 
-        if not isinstance(valuestr, string_types):
-            raise TypeError("Invalid value type: only int, long, float and str are allowed", valuestr)
+        if not isinstance(valuestr, str):
+            raise TypeError(
+                "Invalid value type: only int, long, float and str are allowed",
+                valuestr,
+            )
 
         return valuestr
 
+    def _value_to_string(self, value: Union[str, bytes, int, float, bool]) -> str:
+        if isinstance(value, (int, float, bool)):
+            return str(value)
+        return force_text(value)
+
+    @needs_values
+    @set_dirty_and_flush_changes
+    def set_value(self, section: str, option: str, value: Union[str, bytes, int, float, bool]) -> "GitConfigParser":
+        """Set the given option in section to the given value.
+
+        This will create the section if required, and will not throw as opposed to the
+        default ConfigParser ``set`` method.
+
+        :param section:
+            Name of the section in which the option resides or should reside.
+
+        :param option:
+            Name of the options whose value to set.
+
+        :param value:
+            Value to set the option to. It must be a string or convertible to a string.
+
+        :return:
+            This instance
+        """
+        if not self.has_section(section):
+            self.add_section(section)
+        self.set(section, option, self._value_to_string(value))
+        return self
+
     @needs_values
     @set_dirty_and_flush_changes
-    def set_value(self, section, option, value):
-        """Sets the given option in section to the given value.
-        It will create the section if required, and will not throw as opposed to the default
-        ConfigParser 'set' method.
+    def add_value(self, section: str, option: str, value: Union[str, bytes, int, float, bool]) -> "GitConfigParser":
+        """Add a value for the given option in section.
+
+        This will create the section if required, and will not throw as opposed to the
+        default ConfigParser ``set`` method. The value becomes the new value of the
+        option as returned by :meth:`get_value`, and appends to the list of values
+        returned by :meth:`get_values`.
 
-        :param section: Name of the section in which the option resides or should reside
-        :param option: Name of the options whose value to set
+        :param section:
+            Name of the section in which the option resides or should reside.
 
-        :param value: Value to set the option to. It must be a string or convertible
-            to a string"""
+        :param option:
+            Name of the option.
+
+        :param value:
+            Value to add to option. It must be a string or convertible to a string.
+
+        :return:
+            This instance
+        """
         if not self.has_section(section):
             self.add_section(section)
-        self.set(section, option, str(value))
+        self._sections[section].add(option, self._value_to_string(value))
+        return self
+
+    def rename_section(self, section: str, new_name: str) -> "GitConfigParser":
+        """Rename the given section to `new_name`.
+
+        :raise ValueError:
+            If:
+
+            * `section` doesn't exist.
+            * A section with `new_name` does already exist.
+
+        :return:
+            This instance
+        """
+        if not self.has_section(section):
+            raise ValueError("Source section '%s' doesn't exist" % section)
+        if self.has_section(new_name):
+            raise ValueError("Destination section '%s' already exists" % new_name)
+
+        super().add_section(new_name)
+        new_section = self._sections[new_name]
+        for k, vs in self.items_all(section):
+            new_section.setall(k, vs)
+        # END for each value to copy
+
+        # This call writes back the changes, which is why we don't have the respective
+        # decorator.
+        self.remove_section(section)
+        return self
diff --git a/git/db.py b/git/db.py
index c4e198585..cacd030d0 100644
--- a/git/db.py
+++ b/git/db.py
@@ -1,63 +1,71 @@
-"""Module with our own gitdb implementation - it uses the git command"""
-from gitdb.base import (
-    OInfo,
-    OStream
-)
-from gitdb.util import (
-    bin_to_hex,
-    hex_to_bin
-)
-from gitdb.db import GitDB
-from gitdb.db import LooseObjectDB
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-from .exc import (
-    GitCommandError,
-    BadObject
-)
+"""Module with our own gitdb implementation - it uses the git command."""
 
+__all__ = ["GitCmdObjectDB", "GitDB"]
 
-__all__ = ('GitCmdObjectDB', 'GitDB')
+from gitdb.base import OInfo, OStream
+from gitdb.db import GitDB, LooseObjectDB
+from gitdb.exc import BadObject
 
-# class GitCmdObjectDB(CompoundDB, ObjectDBW):
+from git.util import bin_to_hex, hex_to_bin
+from git.exc import GitCommandError
 
+# typing-------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+from git.types import PathLike
+
+if TYPE_CHECKING:
+    from git.cmd import Git
+
+# --------------------------------------------------------
 
-class GitCmdObjectDB(LooseObjectDB):
 
+class GitCmdObjectDB(LooseObjectDB):
     """A database representing the default git object store, which includes loose
-    objects, pack files and an alternates file
+    objects, pack files and an alternates file.
 
     It will create objects only in the loose object database.
-    :note: for now, we use the git command to do all the lookup, just until he
-        have packs and the other implementations
     """
 
-    def __init__(self, root_path, git):
-        """Initialize this instance with the root and a git command"""
-        super(GitCmdObjectDB, self).__init__(root_path)
+    def __init__(self, root_path: PathLike, git: "Git") -> None:
+        """Initialize this instance with the root and a git command."""
+        super().__init__(root_path)
         self._git = git
 
-    def info(self, sha):
-        hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
+    def info(self, binsha: bytes) -> OInfo:
+        """Get a git object header (using git itself)."""
+        hexsha, typename, size = self._git.get_object_header(bin_to_hex(binsha))
         return OInfo(hex_to_bin(hexsha), typename, size)
 
-    def stream(self, sha):
-        """For now, all lookup is done by git itself"""
-        hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(sha))
+    def stream(self, binsha: bytes) -> OStream:
+        """Get git object data as a stream supporting ``read()`` (using git itself)."""
+        hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(binsha))
         return OStream(hex_to_bin(hexsha), typename, size, stream)
 
     # { Interface
 
-    def partial_to_complete_sha_hex(self, partial_hexsha):
-        """:return: Full binary 20 byte sha from the given partial hexsha
-        :raise AmbiguousObjectName:
-        :raise BadObject:
-        :note: currently we only raise BadObject as git does not communicate
-            AmbiguousObjects separately"""
+    def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes:
+        """
+        :return:
+            Full binary 20 byte sha from the given partial hexsha
+
+        :raise gitdb.exc.AmbiguousObjectName:
+
+        :raise gitdb.exc.BadObject:
+
+        :note:
+            Currently we only raise :exc:`~gitdb.exc.BadObject` as git does not
+            communicate ambiguous objects separately.
+        """
         try:
-            hexsha, typename, size = self._git.get_object_header(partial_hexsha)
+            hexsha, _typename, _size = self._git.get_object_header(partial_hexsha)
             return hex_to_bin(hexsha)
-        except (GitCommandError, ValueError):
-            raise BadObject(partial_hexsha)
+        except (GitCommandError, ValueError) as e:
+            raise BadObject(partial_hexsha) from e
         # END handle exceptions
 
-    #} END interface
+    # } END interface
diff --git a/git/diff.py b/git/diff.py
index dfee00e22..9c6ae59e0 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -1,392 +1,775 @@
-# diff.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["DiffConstants", "NULL_TREE", "INDEX", "Diffable", "DiffIndex", "Diff"]
+
+import enum
 import re
+import warnings
+
+from git.cmd import handle_process_output
+from git.compat import defenc
+from git.objects.blob import Blob
+from git.objects.util import mode_str_to_int
+from git.util import finalize_process, hex_to_bin
+
+# typing ------------------------------------------------------------------
+
+from typing import (
+    Any,
+    Iterator,
+    List,
+    Match,
+    Optional,
+    Tuple,
+    TYPE_CHECKING,
+    TypeVar,
+    Union,
+    cast,
+)
+from git.types import Literal, PathLike
 
-from gitdb.util import hex_to_bin
+if TYPE_CHECKING:
+    from subprocess import Popen
 
-from .objects.blob import Blob
-from .objects.util import mode_str_to_int
+    from git.cmd import Git
+    from git.objects.base import IndexObject
+    from git.objects.commit import Commit
+    from git.objects.tree import Tree
+    from git.repo.base import Repo
 
-from git.compat import (
-    defenc,
-    PY3
-)
+Lit_change_type = Literal["A", "D", "C", "M", "R", "T", "U"]
+
+# ------------------------------------------------------------------------
+
+
+@enum.unique
+class DiffConstants(enum.Enum):
+    """Special objects for :meth:`Diffable.diff`.
+
+    See the :meth:`Diffable.diff` method's ``other`` parameter, which accepts various
+    values including these.
+
+    :note:
+        These constants are also available as attributes of the :mod:`git.diff` module,
+        the :class:`Diffable` class and its subclasses and instances, and the top-level
+        :mod:`git` module.
+    """
+
+    NULL_TREE = enum.auto()
+    """Stand-in indicating you want to compare against the empty tree in diffs.
+
+    Also accessible as :const:`git.NULL_TREE`, :const:`git.diff.NULL_TREE`, and
+    :const:`Diffable.NULL_TREE`.
+    """
+
+    INDEX = enum.auto()
+    """Stand-in indicating you want to diff against the index.
+
+    Also accessible as :const:`git.INDEX`, :const:`git.diff.INDEX`, and
+    :const:`Diffable.INDEX`, as well as :const:`Diffable.Index`. The latter has been
+    kept for backward compatibility and made an alias of this, so it may still be used.
+    """
+
+
+NULL_TREE: Literal[DiffConstants.NULL_TREE] = DiffConstants.NULL_TREE
+"""Stand-in indicating you want to compare against the empty tree in diffs.
+
+See :meth:`Diffable.diff`, which accepts this as a value of its ``other`` parameter.
+
+This is an alias of :const:`DiffConstants.NULL_TREE`, which may also be accessed as
+:const:`git.NULL_TREE` and :const:`Diffable.NULL_TREE`.
+"""
+
+INDEX: Literal[DiffConstants.INDEX] = DiffConstants.INDEX
+"""Stand-in indicating you want to diff against the index.
+
+See :meth:`Diffable.diff`, which accepts this as a value of its ``other`` parameter.
+
+This is an alias of :const:`DiffConstants.INDEX`, which may also be accessed as
+:const:`git.INDEX` and :const:`Diffable.INDEX`, as well as :const:`Diffable.Index`.
+"""
+
+_octal_byte_re = re.compile(rb"\\([0-9]{3})")
+
+
+def _octal_repl(matchobj: Match) -> bytes:
+    value = matchobj.group(1)
+    value = int(value, 8)
+    value = bytes(bytearray((value,)))
+    return value
+
+
+def decode_path(path: bytes, has_ab_prefix: bool = True) -> Optional[bytes]:
+    if path == b"/dev/null":
+        return None
 
+    if path.startswith(b'"') and path.endswith(b'"'):
+        path = path[1:-1].replace(b"\\n", b"\n").replace(b"\\t", b"\t").replace(b'\\"', b'"').replace(b"\\\\", b"\\")
 
-__all__ = ('Diffable', 'DiffIndex', 'Diff')
+    path = _octal_byte_re.sub(_octal_repl, path)
 
+    if has_ab_prefix:
+        assert path.startswith(b"a/") or path.startswith(b"b/")
+        path = path[2:]
 
-class Diffable(object):
+    return path
 
-    """Common interface for all object that can be diffed against another object of compatible type.
+
+class Diffable:
+    """Common interface for all objects that can be diffed against another object of
+    compatible type.
 
     :note:
-        Subclasses require a repo member as it is the case for Object instances, for practical
-        reasons we do not derive from Object."""
-    __slots__ = tuple()
+        Subclasses require a :attr:`repo` member, as it is the case for
+        :class:`~git.objects.base.Object` instances. For practical reasons we do not
+        derive from :class:`~git.objects.base.Object`.
+    """
+
+    __slots__ = ()
+
+    repo: "Repo"
+    """Repository to operate on. Must be provided by subclass or sibling class."""
+
+    NULL_TREE = NULL_TREE
+    """Stand-in indicating you want to compare against the empty tree in diffs.
+
+    See the :meth:`diff` method, which accepts this as a value of its ``other``
+    parameter.
+
+    This is the same as :const:`DiffConstants.NULL_TREE`, and may also be accessed as
+    :const:`git.NULL_TREE` and :const:`git.diff.NULL_TREE`.
+    """
+
+    INDEX = INDEX
+    """Stand-in indicating you want to diff against the index.
 
-    # standin indicating you want to diff against the index
-    class Index(object):
-        pass
+    See the :meth:`diff` method, which accepts this as a value of its ``other``
+    parameter.
 
-    def _process_diff_args(self, args):
+    This is the same as :const:`DiffConstants.INDEX`, and may also be accessed as
+    :const:`git.INDEX` and :const:`git.diff.INDEX`, as well as :class:`Diffable.INDEX`,
+    which is kept for backward compatibility (it is now defined an alias of this).
+    """
+
+    Index = INDEX
+    """Stand-in indicating you want to diff against the index
+    (same as :const:`~Diffable.INDEX`).
+
+    This is an alias of :const:`~Diffable.INDEX`, for backward compatibility. See
+    :const:`~Diffable.INDEX` and :meth:`diff` for details.
+
+    :note:
+        Although always meant for use as an opaque constant, this was formerly defined
+        as a class. Its usage is unchanged, but static type annotations that attempt
+        to permit only this object must be changed to avoid new mypy errors. This was
+        previously not possible to do, though ``Type[Diffable.Index]`` approximated it.
+        It is now possible to do precisely, using ``Literal[DiffConstants.INDEX]``.
+    """
+
+    def _process_diff_args(
+        self,
+        args: List[Union[PathLike, "Diffable"]],
+    ) -> List[Union[PathLike, "Diffable"]]:
         """
         :return:
-            possibly altered version of the given args list.
-            Method is called right before git command execution.
-            Subclasses can use it to alter the behaviour of the superclass"""
+            Possibly altered version of the given args list.
+            This method is called right before git command execution.
+            Subclasses can use it to alter the behaviour of the superclass.
+        """
         return args
 
-    def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
-        """Creates diffs between two items being trees, trees and index or an
-        index and the working tree.
+    def diff(
+        self,
+        other: Union[DiffConstants, "Tree", "Commit", str, None] = INDEX,
+        paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] = None,
+        create_patch: bool = False,
+        **kwargs: Any,
+    ) -> "DiffIndex[Diff]":
+        """Create diffs between two items being trees, trees and index or an index and
+        the working tree. Detects renames automatically.
 
         :param other:
-            Is the item to compare us with.
-            If None, we will be compared to the working tree.
-            If Treeish, it will be compared against the respective tree
-            If Index ( type ), it will be compared against the index.
-            It defaults to Index to assure the method will not by-default fail
-            on bare repositories.
+            This the item to compare us with.
+
+            * If ``None``, we will be compared to the working tree.
+
+            * If a :class:`~git.types.Tree_ish` or string, it will be compared against
+              the respective tree.
+
+            * If :const:`INDEX`, it will be compared against the index.
+
+            * If :const:`NULL_TREE`, it will compare against the empty tree.
+
+            This parameter defaults to :const:`INDEX` (rather than ``None``) so that the
+            method will not by default fail on bare repositories.
 
         :param paths:
-            is a list of paths or a single path to limit the diff to.
-            It will only include at least one of the givne path or paths.
+            This a list of paths or a single path to limit the diff to. It will only
+            include at least one of the given path or paths.
 
         :param create_patch:
-            If True, the returned Diff contains a detailed patch that if applied
-            makes the self to other. Patches are somwhat costly as blobs have to be read
-            and diffed.
+            If ``True``, the returned :class:`Diff` contains a detailed patch that if
+            applied makes the self to other. Patches are somewhat costly as blobs have
+            to be read and diffed.
 
         :param kwargs:
-            Additional arguments passed to git-diff, such as
-            R=True to swap both sides of the diff.
+            Additional arguments passed to :manpage:`git-diff(1)`, such as ``R=True`` to
+            swap both sides of the diff.
 
-        :return: git.DiffIndex
+        :return:
+            A :class:`DiffIndex` representing the computed diff.
 
         :note:
-            Rename detection will only work if create_patch is True.
+            On a bare repository, `other` needs to be provided as :const:`INDEX`, or as
+            an instance of :class:`~git.objects.tree.Tree` or
+            :class:`~git.objects.commit.Commit`, or a git command error will occur.
+        """
+        args: List[Union[PathLike, Diffable]] = []
+        args.append("--abbrev=40")  # We need full shas.
+        args.append("--full-index")  # Get full index paths, not only filenames.
 
-            On a bare repository, 'other' needs to be provided as Index or as
-            as Tree/Commit, or a git command error will occour"""
-        args = list()
-        args.append("--abbrev=40")        # we need full shas
-        args.append("--full-index")       # get full index paths, not only filenames
+        # Remove default '-M' arg (check for renames) if user is overriding it.
+        if not any(x in kwargs for x in ("find_renames", "no_renames", "M")):
+            args.append("-M")
 
-        args.append("-M")                 # check for renames, in both formats
         if create_patch:
             args.append("-p")
+            args.append("--no-ext-diff")
         else:
             args.append("--raw")
+            args.append("-z")
 
-        # in any way, assure we don't see colored output,
-        # fixes https://github.com/gitpython-developers/GitPython/issues/172
-        args.append('--no-color')
+        # Ensure we never see colored output.
+        # Fixes: https://github.com/gitpython-developers/GitPython/issues/172
+        args.append("--no-color")
 
         if paths is not None and not isinstance(paths, (tuple, list)):
             paths = [paths]
 
-        if other is not None and other is not self.Index:
-            args.insert(0, other)
-        if other is self.Index:
+        diff_cmd = self.repo.git.diff
+        if other is INDEX:
             args.insert(0, "--cached")
+        elif other is NULL_TREE:
+            args.insert(0, "-r")  # Recursive diff-tree.
+            args.insert(0, "--root")
+            diff_cmd = self.repo.git.diff_tree
+        elif other is not None:
+            args.insert(0, "-r")  # Recursive diff-tree.
+            args.insert(0, other)
+            diff_cmd = self.repo.git.diff_tree
 
         args.insert(0, self)
 
-        # paths is list here or None
+        # paths is a list or tuple here, or None.
         if paths:
             args.append("--")
             args.extend(paths)
         # END paths handling
 
-        kwargs['as_process'] = True
-        proc = self.repo.git.diff(*self._process_diff_args(args), **kwargs)
+        kwargs["as_process"] = True
+        proc = diff_cmd(*self._process_diff_args(args), **kwargs)
 
-        diff_method = Diff._index_from_raw_format
-        if create_patch:
-            diff_method = Diff._index_from_patch_format
-        index = diff_method(self.repo, proc.stdout)
+        diff_method = Diff._index_from_patch_format if create_patch else Diff._index_from_raw_format
+        index = diff_method(self.repo, proc)
 
         proc.wait()
         return index
 
 
-class DiffIndex(list):
+T_Diff = TypeVar("T_Diff", bound="Diff")
+
+
+class DiffIndex(List[T_Diff]):
+    R"""An index for diffs, allowing a list of :class:`Diff`\s to be queried by the diff
+    properties.
+
+    The class improves the diff handling convenience.
+    """
 
-    """Implements an Index for diffs, allowing a list of Diffs to be queried by
-    the diff properties.
+    change_type = ("A", "C", "D", "R", "M", "T")
+    """Change type invariant identifying possible ways a blob can have changed:
 
-    The class improves the diff handling convenience"""
-    # change type invariant identifying possible ways a blob can have changed
-    # A = Added
-    # D = Deleted
-    # R = Renamed
-    # M = modified
-    change_type = ("A", "D", "R", "M")
+    * ``A`` = Added
+    * ``D`` = Deleted
+    * ``R`` = Renamed
+    * ``M`` = Modified
+    * ``T`` = Changed in the type
+    """
 
-    def iter_change_type(self, change_type):
+    def iter_change_type(self, change_type: Lit_change_type) -> Iterator[T_Diff]:
         """
         :return:
-            iterator yieling Diff instances that match the given change_type
+            Iterator yielding :class:`Diff` instances that match the given `change_type`
 
         :param change_type:
-            Member of DiffIndex.change_type, namely:
+            Member of :attr:`DiffIndex.change_type`, namely:
 
             * 'A' for added paths
             * 'D' for deleted paths
             * 'R' for renamed paths
-            * 'M' for paths with modified data"""
+            * 'M' for paths with modified data
+            * 'T' for changed in the type paths
+        """
         if change_type not in self.change_type:
             raise ValueError("Invalid change type: %s" % change_type)
 
-        for diff in self:
-            if change_type == "A" and diff.new_file:
-                yield diff
-            elif change_type == "D" and diff.deleted_file:
-                yield diff
-            elif change_type == "R" and diff.renamed:
-                yield diff
-            elif change_type == "M" and diff.a_blob and diff.b_blob and diff.a_blob != diff.b_blob:
-                yield diff
+        for diffidx in self:
+            if diffidx.change_type == change_type:
+                yield diffidx
+            elif change_type == "A" and diffidx.new_file:
+                yield diffidx
+            elif change_type == "D" and diffidx.deleted_file:
+                yield diffidx
+            elif change_type == "C" and diffidx.copied_file:
+                yield diffidx
+            elif change_type == "R" and diffidx.renamed_file:
+                yield diffidx
+            elif change_type == "M" and diffidx.a_blob and diffidx.b_blob and diffidx.a_blob != diffidx.b_blob:
+                yield diffidx
         # END for each diff
 
 
-class Diff(object):
-
+class Diff:
     """A Diff contains diff information between two Trees.
 
-    It contains two sides a and b of the diff, members are prefixed with
-    "a" and "b" respectively to inidcate that.
+    It contains two sides a and b of the diff. Members are prefixed with "a" and "b"
+    respectively to indicate that.
 
     Diffs keep information about the changed blob objects, the file mode, renames,
     deletions and new files.
 
-    There are a few cases where None has to be expected as member variable value:
+    There are a few cases where ``None`` has to be expected as member variable value:
 
-    ``New File``::
+    New File::
 
         a_mode is None
         a_blob is None
+        a_path is None
 
-    ``Deleted File``::
+    Deleted File::
 
         b_mode is None
         b_blob is None
+        b_path is None
 
-    ``Working Tree Blobs``
+    Working Tree Blobs:
 
         When comparing to working trees, the working tree blob will have a null hexsha
-        as a corresponding object does not yet exist. The mode will be null as well.
-        But the path will be available though.
-        If it is listed in a diff the working tree version of the file must
-        be different to the version in the index or tree, and hence has been modified."""
+        as a corresponding object does not yet exist. The mode will be null as well. The
+        path will be available, though.
 
-    # precompiled regex
-    re_header = re.compile(r"""
+        If it is listed in a diff, the working tree version of the file must differ from
+        the version in the index or tree, and hence has been modified.
+    """
+
+    # Precompiled regex.
+    re_header = re.compile(
+        rb"""
                                 ^diff[ ]--git
-                                    [ ](?:a/)?(?P<a_path>.+?)[ ](?:b/)?(?P<b_path>.+?)\n
-                                (?:^similarity[ ]index[ ](?P<similarity_index>\d+)%\n
-                                   ^rename[ ]from[ ](?P<rename_from>\S+)\n
-                                   ^rename[ ]to[ ](?P<rename_to>\S+)(?:\n|$))?
+                                    [ ](?P<a_path_fallback>"?[ab]/.+?"?)[ ](?P<b_path_fallback>"?[ab]/.+?"?)\n
                                 (?:^old[ ]mode[ ](?P<old_mode>\d+)\n
                                    ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))?
+                                (?:^similarity[ ]index[ ]\d+%\n
+                                   ^rename[ ]from[ ](?P<rename_from>.*)\n
+                                   ^rename[ ]to[ ](?P<rename_to>.*)(?:\n|$))?
                                 (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))?
                                 (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))?
+                                (?:^similarity[ ]index[ ]\d+%\n
+                                   ^copy[ ]from[ ].*\n
+                                   ^copy[ ]to[ ](?P<copied_file_name>.*)(?:\n|$))?
                                 (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
                                     \.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
-                            """.encode('ascii'), re.VERBOSE | re.MULTILINE)
-    # can be used for comparisons
+                                (?:^---[ ](?P<a_path>[^\t\n\r\f\v]*)[\t\r\f\v]*(?:\n|$))?
+                                (?:^\+\+\+[ ](?P<b_path>[^\t\n\r\f\v]*)[\t\r\f\v]*(?:\n|$))?
+                            """,
+        re.VERBOSE | re.MULTILINE,
+    )
+
+    # These can be used for comparisons.
     NULL_HEX_SHA = "0" * 40
     NULL_BIN_SHA = b"\0" * 20
 
-    __slots__ = ("a_blob", "b_blob", "a_mode", "b_mode", "new_file", "deleted_file",
-                 "rename_from", "rename_to", "diff")
-
-    def __init__(self, repo, a_path, b_path, a_blob_id, b_blob_id, a_mode,
-                 b_mode, new_file, deleted_file, rename_from,
-                 rename_to, diff):
-
-        self.a_mode = a_mode
-        self.b_mode = b_mode
-
-        if self.a_mode:
-            self.a_mode = mode_str_to_int(self.a_mode)
-        if self.b_mode:
-            self.b_mode = mode_str_to_int(self.b_mode)
-
-        if a_blob_id is None:
+    __slots__ = (
+        "a_blob",
+        "b_blob",
+        "a_mode",
+        "b_mode",
+        "a_rawpath",
+        "b_rawpath",
+        "new_file",
+        "deleted_file",
+        "copied_file",
+        "raw_rename_from",
+        "raw_rename_to",
+        "diff",
+        "change_type",
+        "score",
+    )
+
+    def __init__(
+        self,
+        repo: "Repo",
+        a_rawpath: Optional[bytes],
+        b_rawpath: Optional[bytes],
+        a_blob_id: Union[str, bytes, None],
+        b_blob_id: Union[str, bytes, None],
+        a_mode: Union[bytes, str, None],
+        b_mode: Union[bytes, str, None],
+        new_file: bool,
+        deleted_file: bool,
+        copied_file: bool,
+        raw_rename_from: Optional[bytes],
+        raw_rename_to: Optional[bytes],
+        diff: Union[str, bytes, None],
+        change_type: Optional[Lit_change_type],
+        score: Optional[int],
+    ) -> None:
+        assert a_rawpath is None or isinstance(a_rawpath, bytes)
+        assert b_rawpath is None or isinstance(b_rawpath, bytes)
+        self.a_rawpath = a_rawpath
+        self.b_rawpath = b_rawpath
+
+        self.a_mode = mode_str_to_int(a_mode) if a_mode else None
+        self.b_mode = mode_str_to_int(b_mode) if b_mode else None
+
+        # Determine whether this diff references a submodule. If it does then
+        # we need to overwrite "repo" to the corresponding submodule's repo instead.
+        if repo and a_rawpath:
+            for submodule in repo.submodules:
+                if submodule.path == a_rawpath.decode(defenc, "replace"):
+                    if submodule.module_exists():
+                        repo = submodule.module()
+                    break
+
+        self.a_blob: Union["IndexObject", None]
+        if a_blob_id is None or a_blob_id == self.NULL_HEX_SHA:
             self.a_blob = None
         else:
-            assert self.a_mode
-            self.a_blob = Blob(repo, hex_to_bin(a_blob_id), mode=self.a_mode, path=a_path)
-        if b_blob_id is None:
+            self.a_blob = Blob(repo, hex_to_bin(a_blob_id), mode=self.a_mode, path=self.a_path)
+
+        self.b_blob: Union["IndexObject", None]
+        if b_blob_id is None or b_blob_id == self.NULL_HEX_SHA:
             self.b_blob = None
         else:
-            assert self.b_mode
-            self.b_blob = Blob(repo, hex_to_bin(b_blob_id), mode=self.b_mode, path=b_path)
+            self.b_blob = Blob(repo, hex_to_bin(b_blob_id), mode=self.b_mode, path=self.b_path)
 
-        self.new_file = new_file
-        self.deleted_file = deleted_file
+        self.new_file: bool = new_file
+        self.deleted_file: bool = deleted_file
+        self.copied_file: bool = copied_file
 
-        # be clear and use None instead of empty strings
-        self.rename_from = rename_from or None
-        self.rename_to = rename_to or None
+        # Be clear and use None instead of empty strings.
+        assert raw_rename_from is None or isinstance(raw_rename_from, bytes)
+        assert raw_rename_to is None or isinstance(raw_rename_to, bytes)
+        self.raw_rename_from = raw_rename_from or None
+        self.raw_rename_to = raw_rename_to or None
 
         self.diff = diff
+        self.change_type: Union[Lit_change_type, None] = change_type
+        self.score = score
 
-    def __eq__(self, other):
+    def __eq__(self, other: object) -> bool:
         for name in self.__slots__:
             if getattr(self, name) != getattr(other, name):
                 return False
         # END for each name
         return True
 
-    def __ne__(self, other):
+    def __ne__(self, other: object) -> bool:
         return not (self == other)
 
-    def __hash__(self):
+    def __hash__(self) -> int:
         return hash(tuple(getattr(self, n) for n in self.__slots__))
 
-    def __str__(self):
+    def __str__(self) -> str:
         h = "%s"
         if self.a_blob:
             h %= self.a_blob.path
         elif self.b_blob:
             h %= self.b_blob.path
 
-        msg = ''
-        l = None    # temp line
-        ll = 0      # line length
-        for b, n in zip((self.a_blob, self.b_blob), ('lhs', 'rhs')):
+        msg = ""
+        line = None
+        line_length = 0
+        for b, n in zip((self.a_blob, self.b_blob), ("lhs", "rhs")):
             if b:
-                l = "\n%s: %o | %s" % (n, b.mode, b.hexsha)
+                line = "\n%s: %o | %s" % (n, b.mode, b.hexsha)
             else:
-                l = "\n%s: None" % n
+                line = "\n%s: None" % n
             # END if blob is not None
-            ll = max(len(l), ll)
-            msg += l
+            line_length = max(len(line), line_length)
+            msg += line
         # END for each blob
 
-        # add headline
-        h += '\n' + '=' * ll
+        # Add headline.
+        h += "\n" + "=" * line_length
 
         if self.deleted_file:
-            msg += '\nfile deleted in rhs'
+            msg += "\nfile deleted in rhs"
         if self.new_file:
-            msg += '\nfile added in rhs'
+            msg += "\nfile added in rhs"
+        if self.copied_file:
+            msg += "\nfile %r copied from %r" % (self.b_path, self.a_path)
         if self.rename_from:
-            msg += '\nfile renamed from %r' % self.rename_from
+            msg += "\nfile renamed from %r" % self.rename_from
         if self.rename_to:
-            msg += '\nfile renamed to %r' % self.rename_to
+            msg += "\nfile renamed to %r" % self.rename_to
         if self.diff:
-            msg += '\n---'
+            msg += "\n---"
             try:
-                msg += self.diff.decode(defenc)
+                msg += self.diff.decode(defenc) if isinstance(self.diff, bytes) else self.diff
             except UnicodeDecodeError:
-                msg += 'OMITTED BINARY DATA'
-            # end handle encoding
-            msg += '\n---'
+                msg += "OMITTED BINARY DATA"
+            # END handle encoding
+            msg += "\n---"
         # END diff info
 
-        # Python2 sillyness: have to assure we convert our likely to be unicode object to a string with the
-        # right encoding. Otherwise it tries to convert it using ascii, which may fail ungracefully
-        res = h + msg
-        if not PY3:
-            res = res.encode(defenc)
-        # end
-        return res
+        return h + msg
+
+    @property
+    def a_path(self) -> Optional[str]:
+        return self.a_rawpath.decode(defenc, "replace") if self.a_rawpath else None
+
+    @property
+    def b_path(self) -> Optional[str]:
+        return self.b_rawpath.decode(defenc, "replace") if self.b_rawpath else None
 
     @property
-    def renamed(self):
-        """:returns: True if the blob of our diff has been renamed"""
+    def rename_from(self) -> Optional[str]:
+        return self.raw_rename_from.decode(defenc, "replace") if self.raw_rename_from else None
+
+    @property
+    def rename_to(self) -> Optional[str]:
+        return self.raw_rename_to.decode(defenc, "replace") if self.raw_rename_to else None
+
+    @property
+    def renamed(self) -> bool:
+        """Deprecated, use :attr:`renamed_file` instead.
+
+        :return:
+            ``True`` if the blob of our diff has been renamed
+
+        :note:
+            This property is deprecated.
+            Please use the :attr:`renamed_file` property instead.
+        """
+        warnings.warn(
+            "Diff.renamed is deprecated, use Diff.renamed_file instead",
+            DeprecationWarning,
+            stacklevel=2,
+        )
+        return self.renamed_file
+
+    @property
+    def renamed_file(self) -> bool:
+        """:return: ``True`` if the blob of our diff has been renamed"""
         return self.rename_from != self.rename_to
 
     @classmethod
-    def _index_from_patch_format(cls, repo, stream):
-        """Create a new DiffIndex from the given text which must be in patch format
-        :param repo: is the repository we are operating on - it is required
-        :param stream: result of 'git diff' as a stream (supporting file protocol)
-        :return: git.DiffIndex """
-        # for now, we have to bake the stream
-        text = stream.read()
-        index = DiffIndex()
-        previous_header = None
-        for header in cls.re_header.finditer(text):
-            a_path, b_path, similarity_index, rename_from, rename_to, \
-                old_mode, new_mode, new_file_mode, deleted_file_mode, \
-                a_blob_id, b_blob_id, b_mode = header.groups()
-            new_file, deleted_file = bool(new_file_mode), bool(deleted_file_mode)
-
-            # Our only means to find the actual text is to see what has not been matched by our regex,
-            # and then retro-actively assin it to our index
+    def _pick_best_path(cls, path_match: bytes, rename_match: bytes, path_fallback_match: bytes) -> Optional[bytes]:
+        if path_match:
+            return decode_path(path_match)
+
+        if rename_match:
+            return decode_path(rename_match, has_ab_prefix=False)
+
+        if path_fallback_match:
+            return decode_path(path_fallback_match)
+
+        return None
+
+    @classmethod
+    def _index_from_patch_format(cls, repo: "Repo", proc: Union["Popen", "Git.AutoInterrupt"]) -> DiffIndex["Diff"]:
+        """Create a new :class:`DiffIndex` from the given process output which must be
+        in patch format.
+
+        :param repo:
+            The repository we are operating on.
+
+        :param proc:
+            :manpage:`git-diff(1)` process to read from
+            (supports :class:`Git.AutoInterrupt <git.cmd.Git.AutoInterrupt>` wrapper).
+
+        :return:
+            :class:`DiffIndex`
+        """
+
+        # FIXME: Here SLURPING raw, need to re-phrase header-regexes linewise.
+        text_list: List[bytes] = []
+        handle_process_output(proc, text_list.append, None, finalize_process, decode_streams=False)
+
+        # For now, we have to bake the stream.
+        text = b"".join(text_list)
+        index: "DiffIndex" = DiffIndex()
+        previous_header: Union[Match[bytes], None] = None
+        header: Union[Match[bytes], None] = None
+        a_path, b_path = None, None  # For mypy.
+        a_mode, b_mode = None, None  # For mypy.
+        for _header in cls.re_header.finditer(text):
+            (
+                a_path_fallback,
+                b_path_fallback,
+                old_mode,
+                new_mode,
+                rename_from,
+                rename_to,
+                new_file_mode,
+                deleted_file_mode,
+                copied_file_name,
+                a_blob_id,
+                b_blob_id,
+                b_mode,
+                a_path,
+                b_path,
+            ) = _header.groups()
+
+            new_file, deleted_file, copied_file = (
+                bool(new_file_mode),
+                bool(deleted_file_mode),
+                bool(copied_file_name),
+            )
+
+            a_path = cls._pick_best_path(a_path, rename_from, a_path_fallback)
+            b_path = cls._pick_best_path(b_path, rename_to, b_path_fallback)
+
+            # Our only means to find the actual text is to see what has not been matched
+            # by our regex, and then retro-actively assign it to our index.
             if previous_header is not None:
-                index[-1].diff = text[previous_header.end():header.start()]
-            # end assign actual diff
+                index[-1].diff = text[previous_header.end() : _header.start()]
+            # END assign actual diff
 
-            # Make sure the mode is set if the path is set. Otherwise the resulting blob is invalid
-            # We just use the one mode we should have parsed
+            # Make sure the mode is set if the path is set. Otherwise the resulting blob
+            # is invalid. We just use the one mode we should have parsed.
             a_mode = old_mode or deleted_file_mode or (a_path and (b_mode or new_mode or new_file_mode))
             b_mode = b_mode or new_mode or new_file_mode or (b_path and a_mode)
-            index.append(Diff(repo,
-                              a_path and a_path.decode(defenc),
-                              b_path and b_path.decode(defenc),
-                              a_blob_id and a_blob_id.decode(defenc),
-                              b_blob_id and b_blob_id.decode(defenc),
-                              a_mode and a_mode.decode(defenc),
-                              b_mode and b_mode.decode(defenc),
-                              new_file, deleted_file,
-                              rename_from and rename_from.decode(defenc),
-                              rename_to and rename_to.decode(defenc),
-                              None))
-
-            previous_header = header
-        # end for each header we parse
-        if index:
-            index[-1].diff = text[header.end():]
-        # end assign last diff
+            index.append(
+                Diff(
+                    repo,
+                    a_path,
+                    b_path,
+                    a_blob_id and a_blob_id.decode(defenc),
+                    b_blob_id and b_blob_id.decode(defenc),
+                    a_mode and a_mode.decode(defenc),
+                    b_mode and b_mode.decode(defenc),
+                    new_file,
+                    deleted_file,
+                    copied_file,
+                    rename_from,
+                    rename_to,
+                    None,
+                    None,
+                    None,
+                )
+            )
+
+            previous_header = _header
+            header = _header
+        # END for each header we parse
+        if index and header:
+            index[-1].diff = text[header.end() :]
+        # END assign last diff
 
         return index
 
-    @classmethod
-    def _index_from_raw_format(cls, repo, stream):
-        """Create a new DiffIndex from the given stream which must be in raw format.
-        :return: git.DiffIndex"""
-        # handles
-        # :100644 100644 687099101... 37c5e30c8... M    .gitignore
-        index = DiffIndex()
-        for line in stream.readlines():
-            line = line.decode(defenc)
-            if not line.startswith(":"):
+    @staticmethod
+    def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex["Diff"]) -> None:
+        lines = lines_bytes.decode(defenc)
+
+        # Discard everything before the first colon, and the colon itself.
+        _, _, lines = lines.partition(":")
+
+        for line in lines.split("\x00:"):
+            if not line:
+                # The line data is empty, skip.
                 continue
-            # END its not a valid diff line
-            old_mode, new_mode, a_blob_id, b_blob_id, change_type, path = line[1:].split(None, 5)
-            path = path.strip()
-            a_path = path
-            b_path = path
+            meta, _, path = line.partition("\x00")
+            path = path.rstrip("\x00")
+            a_blob_id: Optional[str]
+            b_blob_id: Optional[str]
+            old_mode, new_mode, a_blob_id, b_blob_id, _change_type = meta.split(None, 4)
+            # Change type can be R100
+            # R: status letter
+            # 100: score (in case of copy and rename)
+            change_type: Lit_change_type = cast(Lit_change_type, _change_type[0])
+            score_str = "".join(_change_type[1:])
+            score = int(score_str) if score_str.isdigit() else None
+            path = path.strip("\n")
+            a_path = path.encode(defenc)
+            b_path = path.encode(defenc)
             deleted_file = False
             new_file = False
+            copied_file = False
             rename_from = None
             rename_to = None
 
-            # NOTE: We cannot conclude from the existance of a blob to change type
-            # as diffs with the working do not have blobs yet
-            if change_type == 'D':
-                b_blob_id = None
+            # NOTE: We cannot conclude from the existence of a blob to change type,
+            # as diffs with the working do not have blobs yet.
+            if change_type == "D":
+                b_blob_id = None  # Optional[str]
                 deleted_file = True
-            elif change_type == 'A':
+            elif change_type == "A":
                 a_blob_id = None
                 new_file = True
-            elif change_type[0] == 'R':     # parses RXXX, where XXX is a confidence value
-                a_path, b_path = path.split('\t', 1)
+            elif change_type == "C":
+                copied_file = True
+                a_path_str, b_path_str = path.split("\x00", 1)
+                a_path = a_path_str.encode(defenc)
+                b_path = b_path_str.encode(defenc)
+            elif change_type == "R":
+                a_path_str, b_path_str = path.split("\x00", 1)
+                a_path = a_path_str.encode(defenc)
+                b_path = b_path_str.encode(defenc)
                 rename_from, rename_to = a_path, b_path
+            elif change_type == "T":
+                # Nothing to do.
+                pass
             # END add/remove handling
 
-            diff = Diff(repo, a_path, b_path, a_blob_id, b_blob_id, old_mode, new_mode,
-                        new_file, deleted_file, rename_from, rename_to, '')
+            diff = Diff(
+                repo,
+                a_path,
+                b_path,
+                a_blob_id,
+                b_blob_id,
+                old_mode,
+                new_mode,
+                new_file,
+                deleted_file,
+                copied_file,
+                rename_from,
+                rename_to,
+                "",
+                change_type,
+                score,
+            )
             index.append(diff)
-        # END for each line
+
+    @classmethod
+    def _index_from_raw_format(cls, repo: "Repo", proc: "Popen") -> "DiffIndex[Diff]":
+        """Create a new :class:`DiffIndex` from the given process output which must be
+        in raw format.
+
+        :param repo:
+            The repository we are operating on.
+
+        :param proc:
+            Process to read output from.
+
+        :return:
+            :class:`DiffIndex`
+        """
+        # handles
+        # :100644 100644 687099101... 37c5e30c8... M    .gitignore
+
+        index: "DiffIndex" = DiffIndex()
+        handle_process_output(
+            proc,
+            lambda byt: cls._handle_diff_line(byt, repo, index),
+            None,
+            finalize_process,
+            decode_streams=False,
+        )
 
         return index
diff --git a/git/exc.py b/git/exc.py
index d9b7cbd20..583eee8c1 100644
--- a/git/exc.py
+++ b/git/exc.py
@@ -1,86 +1,228 @@
-# exc.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-""" Module containing all exceptions thrown througout the git package, """
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-from gitdb.exc import *     # NOQA
+"""Exceptions thrown throughout the git package."""
 
-from git.compat import defenc
+__all__ = [
+    # Defined in gitdb.exc:
+    "AmbiguousObjectName",
+    "BadName",
+    "BadObject",
+    "BadObjectType",
+    "InvalidDBRoot",
+    "ODBError",
+    "ParseError",
+    "UnsupportedOperation",
+    # Introduced in this module:
+    "GitError",
+    "InvalidGitRepositoryError",
+    "WorkTreeRepositoryUnsupported",
+    "NoSuchPathError",
+    "UnsafeProtocolError",
+    "UnsafeOptionError",
+    "CommandError",
+    "GitCommandNotFound",
+    "GitCommandError",
+    "CheckoutError",
+    "CacheError",
+    "UnmergedEntriesError",
+    "HookExecutionError",
+    "RepositoryDirtyError",
+]
 
+from gitdb.exc import (
+    AmbiguousObjectName,
+    BadName,
+    BadObject,
+    BadObjectType,
+    InvalidDBRoot,
+    ODBError,
+    ParseError,
+    UnsupportedOperation,
+)
 
-class InvalidGitRepositoryError(Exception):
-    """ Thrown if the given repository appears to have an invalid format.  """
+from git.compat import safe_decode
+from git.util import remove_password_if_present
 
+# typing ----------------------------------------------------
 
-class NoSuchPathError(OSError):
-    """ Thrown if a path could not be access by the system. """
+from typing import List, Sequence, Tuple, TYPE_CHECKING, Union
 
+from git.types import PathLike
 
-class GitCommandError(Exception):
-    """ Thrown if execution of the git command fails with non-zero status code. """
+if TYPE_CHECKING:
+    from git.repo.base import Repo
 
-    def __init__(self, command, status, stderr=None, stdout=None):
-        self.stderr = stderr
-        self.stdout = stdout
-        self.status = status
-        self.command = command
+# ------------------------------------------------------------------
+
+
+class GitError(Exception):
+    """Base class for all package exceptions."""
+
+
+class InvalidGitRepositoryError(GitError):
+    """Thrown if the given repository appears to have an invalid format."""
+
+
+class WorkTreeRepositoryUnsupported(InvalidGitRepositoryError):
+    """Thrown to indicate we can't handle work tree repositories."""
+
+
+class NoSuchPathError(GitError, OSError):
+    """Thrown if a path could not be access by the system."""
+
+
+class UnsafeProtocolError(GitError):
+    """Thrown if unsafe protocols are passed without being explicitly allowed."""
+
+
+class UnsafeOptionError(GitError):
+    """Thrown if unsafe options are passed without being explicitly allowed."""
 
-    def __str__(self):
-        ret = "'%s' returned with exit code %i" % \
-              (' '.join(str(i) for i in self.command), self.status)
-        if self.stderr:
-            ret += "\nstderr: '%s'" % self.stderr.decode(defenc)
-        if self.stdout:
-            ret += "\nstdout: '%s'" % self.stdout.decode(defenc)
-        return ret
 
+class CommandError(GitError):
+    """Base class for exceptions thrown at every stage of :class:`~subprocess.Popen`
+    execution.
 
-class CheckoutError(Exception):
+    :param command:
+        A non-empty list of argv comprising the command-line.
+    """
+
+    _msg = "Cmd('%s') failed%s"
+    """Format string with 2 ``%s`` for ``<cmdline>`` and the rest.
+
+    For example: ``"'%s' failed%s"``
+
+    Subclasses may override this attribute, provided it is still in this form.
+    """
+
+    def __init__(
+        self,
+        command: Union[List[str], Tuple[str, ...], str],
+        status: Union[str, int, None, Exception] = None,
+        stderr: Union[bytes, str, None] = None,
+        stdout: Union[bytes, str, None] = None,
+    ) -> None:
+        if not isinstance(command, (tuple, list)):
+            command = command.split()
+        self.command = remove_password_if_present(command)
+        self.status = status
+        if status:
+            if isinstance(status, Exception):
+                status = "%s('%s')" % (type(status).__name__, safe_decode(str(status)))
+            else:
+                try:
+                    status = "exit code(%s)" % int(status)
+                except (ValueError, TypeError):
+                    s = safe_decode(str(status))
+                    status = "'%s'" % s if isinstance(status, str) else s
+
+        self._cmd = safe_decode(self.command[0])
+        self._cmdline = " ".join(safe_decode(i) for i in self.command)
+        self._cause = status and " due to: %s" % status or "!"
+        stdout_decode = safe_decode(stdout)
+        stderr_decode = safe_decode(stderr)
+        self.stdout = stdout_decode and "\n  stdout: '%s'" % stdout_decode or ""
+        self.stderr = stderr_decode and "\n  stderr: '%s'" % stderr_decode or ""
+
+    def __str__(self) -> str:
+        return (self._msg + "\n  cmdline: %s%s%s") % (
+            self._cmd,
+            self._cause,
+            self._cmdline,
+            self.stdout,
+            self.stderr,
+        )
+
+
+class GitCommandNotFound(CommandError):
+    """Thrown if we cannot find the ``git`` executable in the :envvar:`PATH` or at the
+    path given by the :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable."""
+
+    def __init__(self, command: Union[List[str], Tuple[str], str], cause: Union[str, Exception]) -> None:
+        super().__init__(command, cause)
+        self._msg = "Cmd('%s') not found%s"
+
+
+class GitCommandError(CommandError):
+    """Thrown if execution of the git command fails with non-zero status code."""
+
+    def __init__(
+        self,
+        command: Union[List[str], Tuple[str, ...], str],
+        status: Union[str, int, None, Exception] = None,
+        stderr: Union[bytes, str, None] = None,
+        stdout: Union[bytes, str, None] = None,
+    ) -> None:
+        super().__init__(command, status, stderr, stdout)
+
+
+class CheckoutError(GitError):
     """Thrown if a file could not be checked out from the index as it contained
     changes.
 
-    The .failed_files attribute contains a list of relative paths that failed
-    to be checked out as they contained changes that did not exist in the index.
+    The :attr:`failed_files` attribute contains a list of relative paths that failed to
+    be checked out as they contained changes that did not exist in the index.
 
-    The .failed_reasons attribute contains a string informing about the actual
+    The :attr:`failed_reasons` attribute contains a string informing about the actual
     cause of the issue.
 
-    The .valid_files attribute contains a list of relative paths to files that
-    were checked out successfully and hence match the version stored in the
-    index"""
-
-    def __init__(self, message, failed_files, valid_files, failed_reasons):
+    The :attr:`valid_files` attribute contains a list of relative paths to files that
+    were checked out successfully and hence match the version stored in the index.
+    """
+
+    def __init__(
+        self,
+        message: str,
+        failed_files: Sequence[PathLike],
+        valid_files: Sequence[PathLike],
+        failed_reasons: List[str],
+    ) -> None:
         Exception.__init__(self, message)
         self.failed_files = failed_files
         self.failed_reasons = failed_reasons
         self.valid_files = valid_files
 
-    def __str__(self):
+    def __str__(self) -> str:
         return Exception.__str__(self) + ":%s" % self.failed_files
 
 
-class CacheError(Exception):
-
-    """Base for all errors related to the git index, which is called cache internally"""
+class CacheError(GitError):
+    """Base for all errors related to the git index, which is called "cache"
+    internally."""
 
 
 class UnmergedEntriesError(CacheError):
     """Thrown if an operation cannot proceed as there are still unmerged
-    entries in the cache"""
+    entries in the cache."""
 
 
-class HookExecutionError(Exception):
-    """Thrown if a hook exits with a non-zero exit code. It provides access to the exit code and the string returned
-    via standard output"""
+class HookExecutionError(CommandError):
+    """Thrown if a hook exits with a non-zero exit code.
 
-    def __init__(self, command, status, stdout, stderr):
-        self.command = command
-        self.status = status
-        self.stdout = stdout
-        self.stderr = stderr
+    This provides access to the exit code and the string returned via standard output.
+    """
+
+    def __init__(
+        self,
+        command: Union[List[str], Tuple[str, ...], str],
+        status: Union[str, int, None, Exception],
+        stderr: Union[bytes, str, None] = None,
+        stdout: Union[bytes, str, None] = None,
+    ) -> None:
+        super().__init__(command, status, stderr, stdout)
+        self._msg = "Hook('%s') failed%s"
+
+
+class RepositoryDirtyError(GitError):
+    """Thrown whenever an operation on a repository fails as it has uncommitted changes
+    that would be overwritten."""
+
+    def __init__(self, repo: "Repo", message: str) -> None:
+        self.repo = repo
+        self.message = message
 
-    def __str__(self):
-        return ("'%s' hook returned with exit code %i\nstdout: '%s'\nstderr: '%s'"
-                % (self.command, self.status, self.stdout, self.stderr))
+    def __str__(self) -> str:
+        return "Operation cannot be performed on %r: %s" % (self.repo, self.message)
diff --git a/git/ext/gitdb b/git/ext/gitdb
index f2233fbf4..335c0f661 160000
--- a/git/ext/gitdb
+++ b/git/ext/gitdb
@@ -1 +1 @@
-Subproject commit f2233fbf40f3f69309ce5cc714e99fcbdcd33ec3
+Subproject commit 335c0f66173eecdc7b2597c2b6c3d1fde795df30
diff --git a/git/index/__init__.py b/git/index/__init__.py
index 2516f01f8..ba48110fd 100644
--- a/git/index/__init__.py
+++ b/git/index/__init__.py
@@ -1,6 +1,16 @@
-"""Initialize the index package"""
-# flake8: noqa
-from __future__ import absolute_import
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-from .base import *
-from .typ import *
+"""Initialize the index package."""
+
+__all__ = [
+    "BaseIndexEntry",
+    "BlobFilter",
+    "CheckoutError",
+    "IndexEntry",
+    "IndexFile",
+    "StageType",
+]
+
+from .base import CheckoutError, IndexFile
+from .typ import BaseIndexEntry, BlobFilter, IndexEntry, StageType
diff --git a/git/index/base.py b/git/index/base.py
index 7002385ce..7cc9d3ade 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -1,249 +1,286 @@
-# index.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-import tempfile
-import os
-import sys
-import subprocess
-import glob
-from io import BytesIO
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-from stat import S_ISLNK
-
-from .typ import (
-    BaseIndexEntry,
-    IndexEntry,
-)
+"""Module containing :class:`IndexFile`, an Index implementation facilitating all kinds
+of index manipulations such as querying and merging."""
 
-from .util import (
-    TemporaryFileSwap,
-    post_clear_cache,
-    default_index,
-    git_working_dir
-)
+__all__ = ["IndexFile", "CheckoutError", "StageType"]
 
-import git.diff as diff
-from git.exc import (
-    GitCommandError,
-    CheckoutError
-)
+import contextlib
+import datetime
+import glob
+from io import BytesIO
+import os
+import os.path as osp
+from stat import S_ISLNK
+import subprocess
+import sys
+import tempfile
 
-from git.objects import (
-    Blob,
-    Submodule,
-    Tree,
-    Object,
-    Commit,
-)
+from gitdb.base import IStream
+from gitdb.db import MemoryDB
 
+from git.compat import defenc, force_bytes
+import git.diff as git_diff
+from git.exc import CheckoutError, GitCommandError, GitError, InvalidGitRepositoryError
+from git.objects import Blob, Commit, Object, Submodule, Tree
 from git.objects.util import Serializable
-from git.compat import (
-    izip,
-    xrange,
-    string_types,
-    force_bytes,
-    defenc,
-    mviter
-)
-
 from git.util import (
+    Actor,
     LazyMixin,
     LockedFD,
     join_path_native,
     file_contents_ro,
     to_native_path_linux,
+    unbare_repo,
+    to_bin_sha,
 )
 
 from .fun import (
+    S_IFGITLINK,
+    aggressive_tree_merge,
     entry_key,
-    write_cache,
     read_cache,
-    aggressive_tree_merge,
-    write_tree_from_cache,
+    run_commit_hook,
     stat_mode_to_index_mode,
-    S_IFGITLINK,
-    run_commit_hook
+    write_cache,
+    write_tree_from_cache,
+)
+from .typ import BaseIndexEntry, IndexEntry, StageType
+from .util import TemporaryFileSwap, post_clear_cache, default_index, git_working_dir
+
+# typing -----------------------------------------------------------------------------
+
+from typing import (
+    Any,
+    BinaryIO,
+    Callable,
+    Dict,
+    Generator,
+    IO,
+    Iterable,
+    Iterator,
+    List,
+    NoReturn,
+    Sequence,
+    TYPE_CHECKING,
+    Tuple,
+    Union,
 )
 
-from gitdb.base import IStream
-from gitdb.db import MemoryDB
-from gitdb.util import to_bin_sha
+from git.types import Literal, PathLike
+
+if TYPE_CHECKING:
+    from subprocess import Popen
 
-__all__ = ('IndexFile', 'CheckoutError')
+    from git.refs.reference import Reference
+    from git.repo import Repo
 
 
-class IndexFile(LazyMixin, diff.Diffable, Serializable):
+Treeish = Union[Tree, Commit, str, bytes]
 
+# ------------------------------------------------------------------------------------
+
+
+@contextlib.contextmanager
+def _named_temporary_file_for_subprocess(directory: PathLike) -> Generator[str, None, None]:
+    """Create a named temporary file git subprocesses can open, deleting it afterward.
+
+    :param directory:
+        The directory in which the file is created.
+
+    :return:
+        A context manager object that creates the file and provides its name on entry,
+        and deletes it on exit.
     """
-    Implements an Index that can be manipulated using a native implementation in
-    order to save git command function calls wherever possible.
+    if sys.platform == "win32":
+        fd, name = tempfile.mkstemp(dir=directory)
+        os.close(fd)
+        try:
+            yield name
+        finally:
+            os.remove(name)
+    else:
+        with tempfile.NamedTemporaryFile(dir=directory) as ctx:
+            yield ctx.name
 
-    It provides custom merging facilities allowing to merge without actually changing
-    your index or your working tree. This way you can perform own test-merges based
-    on the index only without having to deal with the working copy. This is useful
-    in case of partial working trees.
 
-    ``Entries``
+class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
+    """An Index that can be manipulated using a native implementation in order to save
+    git command function calls wherever possible.
 
-    The index contains an entries dict whose keys are tuples of type IndexEntry
-    to facilitate access.
+    This provides custom merging facilities allowing to merge without actually changing
+    your index or your working tree. This way you can perform your own test merges based
+    on the index only without having to deal with the working copy. This is useful in
+    case of partial working trees.
 
-    You may read the entries dict or manipulate it using IndexEntry instance, i.e.::
+    Entries:
 
-        index.entries[index.entry_key(index_entry_instance)] = index_entry_instance
+        The index contains an entries dict whose keys are tuples of type
+        :class:`~git.index.typ.IndexEntry` to facilitate access.
+
+        You may read the entries dict or manipulate it using IndexEntry instance, i.e.::
+
+            index.entries[index.entry_key(index_entry_instance)] = index_entry_instance
+
+    Make sure you use :meth:`index.write() <write>` once you are done manipulating the
+    index directly before operating on it using the git command.
+    """
 
-    Make sure you use index.write() once you are done manipulating the index directly
-    before operating on it using the git command"""
     __slots__ = ("repo", "version", "entries", "_extension_data", "_file_path")
-    _VERSION = 2            # latest version we support
-    S_IFGITLINK = S_IFGITLINK  # a submodule
 
-    def __init__(self, repo, file_path=None):
-        """Initialize this Index instance, optionally from the given ``file_path``.
-        If no file_path is given, we will be created from the current index file.
+    _VERSION = 2
+    """The latest version we support."""
+
+    S_IFGITLINK = S_IFGITLINK
+    """Flags for a submodule."""
+
+    def __init__(self, repo: "Repo", file_path: Union[PathLike, None] = None) -> None:
+        """Initialize this Index instance, optionally from the given `file_path`.
+
+        If no `file_path` is given, we will be created from the current index file.
 
         If a stream is not given, the stream will be initialized from the current
-        repository's index on demand."""
+        repository's index on demand.
+        """
         self.repo = repo
         self.version = self._VERSION
-        self._extension_data = b''
-        self._file_path = file_path or self._index_path()
+        self._extension_data = b""
+        self._file_path: PathLike = file_path or self._index_path()
 
-    def _set_cache_(self, attr):
+    def _set_cache_(self, attr: str) -> None:
         if attr == "entries":
-            # read the current index
-            # try memory map for speed
-            lfd = LockedFD(self._file_path)
             try:
-                fd = lfd.open(write=False, stream=False)
+                fd = os.open(self._file_path, os.O_RDONLY)
             except OSError:
-                lfd.rollback()
-                # in new repositories, there may be no index, which means we are empty
-                self.entries = dict()
+                # In new repositories, there may be no index, which means we are empty.
+                self.entries: Dict[Tuple[PathLike, StageType], IndexEntry] = {}
                 return
             # END exception handling
 
-            # Here it comes: on windows in python 2.5, memory maps aren't closed properly
-            # Hence we are in trouble if we try to delete a file that is memory mapped,
-            # which happens during read-tree.
-            # In this case, we will just read the memory in directly.
-            # Its insanely bad ... I am disappointed !
-            allow_mmap = (os.name != 'nt' or sys.version_info[1] > 5)
-            stream = file_contents_ro(fd, stream=True, allow_mmap=allow_mmap)
-
             try:
-                self._deserialize(stream)
+                stream = file_contents_ro(fd, stream=True, allow_mmap=True)
             finally:
-                lfd.rollback()
-                # The handles will be closed on desctruction
-            # END read from default index on demand
+                os.close(fd)
+
+            self._deserialize(stream)
         else:
-            super(IndexFile, self)._set_cache_(attr)
+            super()._set_cache_(attr)
 
-    def _index_path(self):
-        return join_path_native(self.repo.git_dir, "index")
+    def _index_path(self) -> PathLike:
+        if self.repo.git_dir:
+            return join_path_native(self.repo.git_dir, "index")
+        else:
+            raise GitCommandError("No git directory given to join index path")
 
     @property
-    def path(self):
-        """ :return: Path to the index file we are representing """
+    def path(self) -> PathLike:
+        """:return: Path to the index file we are representing"""
         return self._file_path
 
-    def _delete_entries_cache(self):
-        """Safely clear the entries cache so it can be recreated"""
+    def _delete_entries_cache(self) -> None:
+        """Safely clear the entries cache so it can be recreated."""
         try:
-            del(self.entries)
+            del self.entries
         except AttributeError:
-            # fails in python 2.6.5 with this exception
+            # It failed in Python 2.6.5 with AttributeError.
+            # FIXME: Look into whether we can just remove this except clause now.
             pass
         # END exception handling
 
-    #{ Serializable Interface
+    # { Serializable Interface
 
-    def _deserialize(self, stream):
-        """Initialize this instance with index values read from the given stream"""
-        self.version, self.entries, self._extension_data, conten_sha = read_cache(stream)
+    def _deserialize(self, stream: IO) -> "IndexFile":
+        """Initialize this instance with index values read from the given stream."""
+        self.version, self.entries, self._extension_data, _conten_sha = read_cache(stream)
         return self
 
-    def _entries_sorted(self):
-        """:return: list of entries, in a sorted fashion, first by path, then by stage"""
+    def _entries_sorted(self) -> List[IndexEntry]:
+        """:return: List of entries, in a sorted fashion, first by path, then by stage"""
         return sorted(self.entries.values(), key=lambda e: (e.path, e.stage))
 
-    def _serialize(self, stream, ignore_tree_extension_data=False):
+    def _serialize(self, stream: IO, ignore_extension_data: bool = False) -> "IndexFile":
         entries = self._entries_sorted()
-        write_cache(entries,
-                    stream,
-                    (ignore_tree_extension_data and None) or self._extension_data)
+        extension_data = self._extension_data  # type: Union[None, bytes]
+        if ignore_extension_data:
+            extension_data = None
+        write_cache(entries, stream, extension_data)
         return self
 
-    #} END serializable interface
+    # } END serializable interface
 
-    def write(self, file_path=None, ignore_tree_extension_data=False):
-        """Write the current state to our file path or to the given one
+    def write(
+        self,
+        file_path: Union[None, PathLike] = None,
+        ignore_extension_data: bool = False,
+    ) -> None:
+        """Write the current state to our file path or to the given one.
 
         :param file_path:
-            If None, we will write to our stored file path from which we have
-            been initialized. Otherwise we write to the given file path.
-            Please note that this will change the file_path of this index to
-            the one you gave.
-
-        :param ignore_tree_extension_data:
-            If True, the TREE type extension data read in the index will not
-            be written to disk. Use this if you have altered the index and
-            would like to use git-write-tree afterwards to create a tree
-            representing your written changes.
-            If this data is present in the written index, git-write-tree
-            will instead write the stored/cached tree.
-            Alternatively, use IndexFile.write_tree() to handle this case
-            automatically
-
-        :return: self"""
-        # make sure we have our entries read before getting a write lock
-        # else it would be done when streaming. This can happen
-        # if one doesn't change the index, but writes it right away
-        self.entries
+            If ``None``, we will write to our stored file path from which we have been
+            initialized. Otherwise we write to the given file path. Please note that
+            this will change the `file_path` of this index to the one you gave.
+
+        :param ignore_extension_data:
+            If ``True``, the TREE type extension data read in the index will not be
+            written to disk. NOTE that no extension data is actually written. Use this
+            if you have altered the index and would like to use
+            :manpage:`git-write-tree(1)` afterwards to create a tree representing your
+            written changes. If this data is present in the written index,
+            :manpage:`git-write-tree(1)` will instead write the stored/cached tree.
+            Alternatively, use :meth:`write_tree` to handle this case automatically.
+        """
+        # Make sure we have our entries read before getting a write lock.
+        # Otherwise it would be done when streaming.
+        # This can happen if one doesn't change the index, but writes it right away.
+        self.entries  # noqa: B018
         lfd = LockedFD(file_path or self._file_path)
         stream = lfd.open(write=True, stream=True)
 
-        self._serialize(stream, ignore_tree_extension_data)
+        try:
+            self._serialize(stream, ignore_extension_data)
+        except BaseException:
+            lfd.rollback()
+            raise
 
         lfd.commit()
 
-        # make sure we represent what we have written
+        # Make sure we represent what we have written.
         if file_path is not None:
             self._file_path = file_path
 
     @post_clear_cache
     @default_index
-    def merge_tree(self, rhs, base=None):
-        """Merge the given rhs treeish into the current index, possibly taking
+    def merge_tree(self, rhs: Treeish, base: Union[None, Treeish] = None) -> "IndexFile":
+        """Merge the given `rhs` treeish into the current index, possibly taking
         a common base treeish into account.
 
-        As opposed to the from_tree_ method, this allows you to use an already
-        existing tree as the left side of the merge
+        As opposed to the :func:`from_tree` method, this allows you to use an already
+        existing tree as the left side of the merge.
 
         :param rhs:
-            treeish reference pointing to the 'other' side of the merge.
+            Treeish reference pointing to the 'other' side of the merge.
 
         :param base:
-            optional treeish reference pointing to the common base of 'rhs' and
-            this index which equals lhs
+            Optional treeish reference pointing to the common base of `rhs` and this
+            index which equals lhs.
 
         :return:
-            self ( containing the merge and possibly unmerged entries in case of
-            conflicts )
-
-        :raise GitCommandError:
-            If there is a merge conflict. The error will
-            be raised at the first conflicting path. If you want to have proper
-            merge resolution to be done by yourself, you have to commit the changed
-            index ( or make a valid tree from it ) and retry with a three-way
-            index.from_tree call. """
+            self (containing the merge and possibly unmerged entries in case of
+            conflicts)
+
+        :raise git.exc.GitCommandError:
+            If there is a merge conflict. The error will be raised at the first
+            conflicting path. If you want to have proper merge resolution to be done by
+            yourself, you have to commit the changed index (or make a valid tree from
+            it) and retry with a three-way :meth:`index.from_tree <from_tree>` call.
+        """
         # -i : ignore working tree status
         # --aggressive : handle more merge cases
         # -m : do an actual merge
-        args = ["--aggressive", "-i", "-m"]
+        args: List[Union[Treeish, str]] = ["--aggressive", "-i", "-m"]
         if base is not None:
             args.append(base)
         args.append(rhs)
@@ -252,174 +289,229 @@ def merge_tree(self, rhs, base=None):
         return self
 
     @classmethod
-    def new(cls, repo, *tree_sha):
-        """ Merge the given treeish revisions into a new index which is returned.
-        This method behaves like git-read-tree --aggressive when doing the merge.
+    def new(cls, repo: "Repo", *tree_sha: Union[str, Tree]) -> "IndexFile":
+        """Merge the given treeish revisions into a new index which is returned.
 
-        :param repo: The repository treeish are located in.
+        This method behaves like ``git-read-tree --aggressive`` when doing the merge.
+
+        :param repo:
+            The repository treeish are located in.
 
         :param tree_sha:
-            20 byte or 40 byte tree sha or tree objects
+            20 byte or 40 byte tree sha or tree objects.
 
         :return:
-            New IndexFile instance. Its path will be undefined.
-            If you intend to write such a merged Index, supply an alternate file_path
-            to its 'write' method."""
-        base_entries = aggressive_tree_merge(repo.odb, [to_bin_sha(str(t)) for t in tree_sha])
+            New :class:`IndexFile` instance. Its path will be undefined.
+            If you intend to write such a merged Index, supply an alternate
+            ``file_path`` to its :meth:`write` method.
+        """
+        tree_sha_bytes: List[bytes] = [to_bin_sha(str(t)) for t in tree_sha]
+        base_entries = aggressive_tree_merge(repo.odb, tree_sha_bytes)
 
         inst = cls(repo)
-        # convert to entries dict
-        entries = dict(izip(((e.path, e.stage) for e in base_entries),
-                            (IndexEntry.from_base(e) for e in base_entries)))
+        # Convert to entries dict.
+        entries: Dict[Tuple[PathLike, int], IndexEntry] = dict(
+            zip(
+                ((e.path, e.stage) for e in base_entries),
+                (IndexEntry.from_base(e) for e in base_entries),
+            )
+        )
 
         inst.entries = entries
         return inst
 
     @classmethod
-    def from_tree(cls, repo, *treeish, **kwargs):
-        """Merge the given treeish revisions into a new index which is returned.
-        The original index will remain unaltered
+    def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile":
+        R"""Merge the given treeish revisions into a new index which is returned.
+        The original index will remain unaltered.
 
         :param repo:
             The repository treeish are located in.
 
         :param treeish:
-            One, two or three Tree Objects, Commits or 40 byte hexshas. The result
-            changes according to the amount of trees.
-            If 1 Tree is given, it will just be read into a new index
-            If 2 Trees are given, they will be merged into a new index using a
-            two way merge algorithm. Tree 1 is the 'current' tree, tree 2 is the 'other'
-            one. It behaves like a fast-forward.
-            If 3 Trees are given, a 3-way merge will be performed with the first tree
-            being the common ancestor of tree 2 and tree 3. Tree 2 is the 'current' tree,
-            tree 3 is the 'other' one
+            One, two or three :class:`~git.objects.tree.Tree` objects,
+            :class:`~git.objects.commit.Commit`\s or 40 byte hexshas.
+
+            The result changes according to the amount of trees:
+
+            1. If 1 Tree is given, it will just be read into a new index.
+            2. If 2 Trees are given, they will be merged into a new index using a two
+               way merge algorithm. Tree 1 is the 'current' tree, tree 2 is the 'other'
+               one. It behaves like a fast-forward.
+            3. If 3 Trees are given, a 3-way merge will be performed with the first tree
+               being the common ancestor of tree 2 and tree 3. Tree 2 is the 'current'
+               tree, tree 3 is the 'other' one.
 
         :param kwargs:
-            Additional arguments passed to git-read-tree
+            Additional arguments passed to :manpage:`git-read-tree(1)`.
 
         :return:
-            New IndexFile instance. It will point to a temporary index location which
-            does not exist anymore. If you intend to write such a merged Index, supply
-            an alternate file_path to its 'write' method.
+            New :class:`IndexFile` instance. It will point to a temporary index location
+            which does not exist anymore. If you intend to write such a merged Index,
+            supply an alternate ``file_path`` to its :meth:`write` method.
 
         :note:
-            In the three-way merge case, --aggressive will be specified to automatically
-            resolve more cases in a commonly correct manner. Specify trivial=True as kwarg
-            to override that.
+            In the three-way merge case, ``--aggressive`` will be specified to
+            automatically resolve more cases in a commonly correct manner. Specify
+            ``trivial=True`` as a keyword argument to override that.
 
-            As the underlying git-read-tree command takes into account the current index,
-            it will be temporarily moved out of the way to assure there are no unsuspected
-            interferences."""
+            As the underlying :manpage:`git-read-tree(1)` command takes into account the
+            current index, it will be temporarily moved out of the way to prevent any
+            unexpected interference.
+        """
         if len(treeish) == 0 or len(treeish) > 3:
             raise ValueError("Please specify between 1 and 3 treeish, got %i" % len(treeish))
 
-        arg_list = list()
-        # ignore that working tree and index possibly are out of date
+        arg_list: List[Union[Treeish, str]] = []
+        # Ignore that the working tree and index possibly are out of date.
         if len(treeish) > 1:
-            # drop unmerged entries when reading our index and merging
+            # Drop unmerged entries when reading our index and merging.
             arg_list.append("--reset")
-            # handle non-trivial cases the way a real merge does
+            # Handle non-trivial cases the way a real merge does.
             arg_list.append("--aggressive")
         # END merge handling
 
-        # tmp file created in git home directory to be sure renaming
-        # works - /tmp/ dirs could be on another device
-        tmp_index = tempfile.mktemp('', '', repo.git_dir)
-        arg_list.append("--index-output=%s" % tmp_index)
-        arg_list.extend(treeish)
-
-        # move current index out of the way - otherwise the merge may fail
-        # as it considers existing entries. moving it essentially clears the index.
-        # Unfortunately there is no 'soft' way to do it.
-        # The TemporaryFileSwap assure the original file get put back
-        index_handler = TemporaryFileSwap(join_path_native(repo.git_dir, 'index'))
-        try:
-            repo.git.read_tree(*arg_list, **kwargs)
-            index = cls(repo, tmp_index)
-            index.entries       # force it to read the file as we will delete the temp-file
-            del(index_handler)  # release as soon as possible
-        finally:
-            if os.path.exists(tmp_index):
-                os.remove(tmp_index)
-        # END index merge handling
-
-        return index
+        # Create the temporary file in the .git directory to be sure renaming
+        # works - /tmp/ directories could be on another device.
+        with _named_temporary_file_for_subprocess(repo.git_dir) as tmp_index:
+            arg_list.append("--index-output=%s" % tmp_index)
+            arg_list.extend(treeish)
+
+            # Move the current index out of the way - otherwise the merge may fail as it
+            # considers existing entries. Moving it essentially clears the index.
+            # Unfortunately there is no 'soft' way to do it.
+            # The TemporaryFileSwap ensures the original file gets put back.
+            with TemporaryFileSwap(join_path_native(repo.git_dir, "index")):
+                repo.git.read_tree(*arg_list, **kwargs)
+                index = cls(repo, tmp_index)
+                index.entries  # noqa: B018 # Force it to read the file as we will delete the temp-file.
+                return index
+            # END index merge handling
 
     # UTILITIES
-    def _iter_expand_paths(self, paths):
-        """Expand the directories in list of paths to the corresponding paths accordingly,
 
-        Note: git will add items multiple times even if a glob overlapped
-        with manually specified paths or if paths where specified multiple
-        times - we respect that and do not prune"""
-        def raise_exc(e):
+    @unbare_repo
+    def _iter_expand_paths(self: "IndexFile", paths: Sequence[PathLike]) -> Iterator[PathLike]:
+        """Expand the directories in list of paths to the corresponding paths
+        accordingly.
+
+        :note:
+            git will add items multiple times even if a glob overlapped with manually
+            specified paths or if paths where specified multiple times - we respect that
+            and do not prune.
+        """
+
+        def raise_exc(e: Exception) -> NoReturn:
             raise e
-        r = self.repo.working_tree_dir
+
+        r = str(self.repo.working_tree_dir)
         rs = r + os.sep
         for path in paths:
-            abs_path = path
-            if not os.path.isabs(abs_path):
-                abs_path = os.path.join(r, path)
+            abs_path = str(path)
+            if not osp.isabs(abs_path):
+                abs_path = osp.join(r, path)
             # END make absolute path
 
-            # resolve globs if possible
-            if '?' in path or '*' in path or '[' in path:
-                for f in self._iter_expand_paths(glob.glob(abs_path)):
-                    yield f.replace(rs, '')
-                continue
+            try:
+                st = os.lstat(abs_path)  # Handles non-symlinks as well.
+            except OSError:
+                # The lstat call may fail as the path may contain globs as well.
+                pass
+            else:
+                if S_ISLNK(st.st_mode):
+                    yield abs_path.replace(rs, "")
+                    continue
+            # END check symlink
+
+            # If the path is not already pointing to an existing file, resolve globs if possible.
+            if not os.path.exists(abs_path) and ("?" in abs_path or "*" in abs_path or "[" in abs_path):
+                resolved_paths = glob.glob(abs_path)
+                # not abs_path in resolved_paths:
+                #   A glob() resolving to the same path we are feeding it with is a
+                #   glob() that failed to resolve. If we continued calling ourselves
+                #   we'd endlessly recurse. If the condition below evaluates to true
+                #   then we are likely dealing with a file whose name contains wildcard
+                #   characters.
+                if abs_path not in resolved_paths:
+                    for f in self._iter_expand_paths(glob.glob(abs_path)):
+                        yield str(f).replace(rs, "")
+                    continue
             # END glob handling
             try:
-                for root, dirs, files in os.walk(abs_path, onerror=raise_exc):
+                for root, _dirs, files in os.walk(abs_path, onerror=raise_exc):
                     for rela_file in files:
-                        # add relative paths only
-                        yield os.path.join(root.replace(rs, ''), rela_file)
+                        # Add relative paths only.
+                        yield osp.join(root.replace(rs, ""), rela_file)
                     # END for each file in subdir
                 # END for each subdirectory
             except OSError:
-                # was a file or something that could not be iterated
-                yield path.replace(rs, '')
+                # It was a file or something that could not be iterated.
+                yield abs_path.replace(rs, "")
             # END path exception handling
         # END for each path
 
-    def _write_path_to_stdin(self, proc, filepath, item, fmakeexc, fprogress,
-                             read_from_stdout=True):
-        """Write path to proc.stdin and make sure it processes the item, including progress.
-
-        :return: stdout string
-        :param read_from_stdout: if True, proc.stdout will be read after the item
-            was sent to stdin. In that case, it will return None
-        :note: There is a bug in git-update-index that prevents it from sending
-            reports just in time. This is why we have a version that tries to
-            read stdout and one which doesn't. In fact, the stdout is not
-            important as the piped-in files are processed anyway and just in time
-        :note: Newlines are essential here, gits behaviour is somewhat inconsistent
-            on this depending on the version, hence we try our best to deal with
-            newlines carefully. Usually the last newline will not be sent, instead
-            we will close stdin to break the pipe."""
+    def _write_path_to_stdin(
+        self,
+        proc: "Popen",
+        filepath: PathLike,
+        item: PathLike,
+        fmakeexc: Callable[..., GitError],
+        fprogress: Callable[[PathLike, bool, PathLike], None],
+        read_from_stdout: bool = True,
+    ) -> Union[None, str]:
+        """Write path to ``proc.stdin`` and make sure it processes the item, including
+        progress.
+
+        :return:
+            stdout string
+
+        :param read_from_stdout:
+            If ``True``, ``proc.stdout`` will be read after the item was sent to stdin.
+            In that case, it will return ``None``.
 
+        :note:
+            There is a bug in :manpage:`git-update-index(1)` that prevents it from
+            sending reports just in time. This is why we have a version that tries to
+            read stdout and one which doesn't. In fact, the stdout is not important as
+            the piped-in files are processed anyway and just in time.
+
+        :note:
+            Newlines are essential here, git's behaviour is somewhat inconsistent on
+            this depending on the version, hence we try our best to deal with newlines
+            carefully. Usually the last newline will not be sent, instead we will close
+            stdin to break the pipe.
+        """
         fprogress(filepath, False, item)
-        rval = None
-        try:
-            proc.stdin.write(("%s\n" % filepath).encode(defenc))
-        except IOError:
-            # pipe broke, usually because some error happend
-            raise fmakeexc()
-        # END write exception handling
-        proc.stdin.flush()
-        if read_from_stdout:
+        rval: Union[None, str] = None
+
+        if proc.stdin is not None:
+            try:
+                proc.stdin.write(("%s\n" % filepath).encode(defenc))
+            except IOError as e:
+                # Pipe broke, usually because some error happened.
+                raise fmakeexc() from e
+            # END write exception handling
+            proc.stdin.flush()
+
+        if read_from_stdout and proc.stdout is not None:
             rval = proc.stdout.readline().strip()
         fprogress(filepath, True, item)
         return rval
 
-    def iter_blobs(self, predicate=lambda t: True):
+    def iter_blobs(
+        self, predicate: Callable[[Tuple[StageType, Blob]], bool] = lambda t: True
+    ) -> Iterator[Tuple[StageType, Blob]]:
         """
-        :return: Iterator yielding tuples of Blob objects and stages, tuple(stage, Blob)
+        :return:
+            Iterator yielding tuples of :class:`~git.objects.blob.Blob` objects and
+            stages, tuple(stage, Blob).
 
         :param predicate:
-            Function(t) returning True if tuple(stage, Blob) should be yielded by the
-            iterator. A default filter, the BlobFilter, allows you to yield blobs
-            only if they match a given list of paths. """
-        for entry in mviter(self.entries):
+            Function(t) returning ``True`` if tuple(stage, Blob) should be yielded by
+            the iterator. A default filter, the :class:`~git.index.typ.BlobFilter`, allows you
+            to yield blobs only if they match a given list of paths.
+        """
+        for entry in self.entries.values():
             blob = entry.to_blob(self.repo)
             blob.size = entry.size
             output = (entry.stage, blob)
@@ -427,56 +519,63 @@ def iter_blobs(self, predicate=lambda t: True):
                 yield output
         # END for each entry
 
-    def unmerged_blobs(self):
+    def unmerged_blobs(self) -> Dict[PathLike, List[Tuple[StageType, Blob]]]:
         """
         :return:
-            Iterator yielding dict(path : list( tuple( stage, Blob, ...))), being
-            a dictionary associating a path in the index with a list containing
-            sorted stage/blob pairs
+            Dict(path : list(tuple(stage, Blob, ...))), being a dictionary associating a
+            path in the index with a list containing sorted stage/blob pairs.
 
         :note:
-            Blobs that have been removed in one side simply do not exist in the
-            given stage. I.e. a file removed on the 'other' branch whose entries
-            are at stage 3 will not have a stage 3 entry.
+            Blobs that have been removed in one side simply do not exist in the given
+            stage. That is, a file removed on the 'other' branch whose entries are at
+            stage 3 will not have a stage 3 entry.
         """
-        is_unmerged_blob = lambda t: t[0] != 0
-        path_map = dict()
+
+        def is_unmerged_blob(t: Tuple[StageType, Blob]) -> bool:
+            return t[0] != 0
+
+        path_map: Dict[PathLike, List[Tuple[StageType, Blob]]] = {}
         for stage, blob in self.iter_blobs(is_unmerged_blob):
-            path_map.setdefault(blob.path, list()).append((stage, blob))
+            path_map.setdefault(blob.path, []).append((stage, blob))
         # END for each unmerged blob
-        for l in mviter(path_map):
-            l.sort()
+        for line in path_map.values():
+            line.sort()
+
         return path_map
 
     @classmethod
-    def entry_key(cls, *entry):
+    def entry_key(cls, *entry: Union[BaseIndexEntry, PathLike, StageType]) -> Tuple[PathLike, StageType]:
         return entry_key(*entry)
 
-    def resolve_blobs(self, iter_blobs):
-        """Resolve the blobs given in blob iterator. This will effectively remove the
-        index entries of the respective path at all non-null stages and add the given
-        blob as new stage null blob.
+    def resolve_blobs(self, iter_blobs: Iterator[Blob]) -> "IndexFile":
+        """Resolve the blobs given in blob iterator.
+
+        This will effectively remove the index entries of the respective path at all
+        non-null stages and add the given blob as new stage null blob.
+
+        For each path there may only be one blob, otherwise a :exc:`ValueError` will be
+        raised claiming the path is already at stage 0.
 
-        For each path there may only be one blob, otherwise a ValueError will be raised
-        claiming the path is already at stage 0.
+        :raise ValueError:
+            If one of the blobs already existed at stage 0.
 
-        :raise ValueError: if one of the blobs already existed at stage 0
-        :return: self
+        :return:
+            self
 
         :note:
             You will have to write the index manually once you are done, i.e.
-            index.resolve_blobs(blobs).write()
+            ``index.resolve_blobs(blobs).write()``.
         """
         for blob in iter_blobs:
             stage_null_key = (blob.path, 0)
             if stage_null_key in self.entries:
-                raise ValueError("Path %r already exists at stage 0" % blob.path)
+                raise ValueError("Path %r already exists at stage 0" % str(blob.path))
             # END assert blob is not stage 0 already
 
-            # delete all possible stages
+            # Delete all possible stages.
             for stage in (1, 2, 3):
                 try:
-                    del(self.entries[(blob.path, stage)])
+                    del self.entries[(blob.path, stage)]
                 except KeyError:
                     pass
                 # END ignore key errors
@@ -487,43 +586,57 @@ def resolve_blobs(self, iter_blobs):
 
         return self
 
-    def update(self):
+    def update(self) -> "IndexFile":
         """Reread the contents of our index file, discarding all cached information
         we might have.
 
-        :note: This is a possibly dangerious operations as it will discard your changes
-            to index.entries
-        :return: self"""
+        :note:
+            This is a possibly dangerous operations as it will discard your changes to
+            :attr:`index.entries <entries>`.
+
+        :return:
+            self
+        """
         self._delete_entries_cache()
-        # allows to lazily reread on demand
+        # Allows to lazily reread on demand.
         return self
 
-    def write_tree(self):
-        """Writes this index to a corresponding Tree object into the repository's
-        object database and return it.
-
-        :return: Tree object representing this index
-        :note: The tree will be written even if one or more objects the tree refers to
-            does not yet exist in the object database. This could happen if you added
-            Entries to the index directly.
-        :raise ValueError: if there are no entries in the cache
-        :raise UnmergedEntriesError: """
-        # we obtain no lock as we just flush our contents to disk as tree
-        # If we are a new index, the entries access will load our data accordingly
+    def write_tree(self) -> Tree:
+        """Write this index to a corresponding :class:`~git.objects.tree.Tree` object
+        into the repository's object database and return it.
+
+        :return:
+            :class:`~git.objects.tree.Tree` object representing this index.
+
+        :note:
+            The tree will be written even if one or more objects the tree refers to does
+            not yet exist in the object database. This could happen if you added entries
+            to the index directly.
+
+        :raise ValueError:
+            If there are no entries in the cache.
+
+        :raise git.exc.UnmergedEntriesError:
+        """
+        # We obtain no lock as we just flush our contents to disk as tree.
+        # If we are a new index, the entries access will load our data accordingly.
         mdb = MemoryDB()
         entries = self._entries_sorted()
         binsha, tree_items = write_tree_from_cache(entries, mdb, slice(0, len(entries)))
 
-        # copy changed trees only
+        # Copy changed trees only.
         mdb.stream_copy(mdb.sha_iter(), self.repo.odb)
 
-        # note: additional deserialization could be saved if write_tree_from_cache
-        # would return sorted tree entries
-        root_tree = Tree(self.repo, binsha, path='')
+        # Note: Additional deserialization could be saved if write_tree_from_cache would
+        # return sorted tree entries.
+        root_tree = Tree(self.repo, binsha, path="")
         root_tree._cache = tree_items
         return root_tree
 
-    def _process_diff_args(self, args):
+    def _process_diff_args(
+        self,
+        args: List[Union[PathLike, "git_diff.Diffable"]],
+    ) -> List[Union[PathLike, "git_diff.Diffable"]]:
         try:
             args.pop(args.index(self))
         except IndexError:
@@ -531,23 +644,37 @@ def _process_diff_args(self, args):
         # END remove self
         return args
 
-    def _to_relative_path(self, path):
-        """:return: Version of path relative to our git directory or raise ValueError
-        if it is not within our git direcotory"""
-        if not os.path.isabs(path):
+    def _to_relative_path(self, path: PathLike) -> PathLike:
+        """
+        :return:
+            Version of path relative to our git directory or raise :exc:`ValueError` if
+            it is not within our git directory.
+
+        :raise ValueError:
+        """
+        if not osp.isabs(path):
             return path
-        relative_path = path.replace(self.repo.working_tree_dir + os.sep, "")
-        if relative_path == path:
+        if self.repo.bare:
+            raise InvalidGitRepositoryError("require non-bare repository")
+        if not osp.normpath(str(path)).startswith(str(self.repo.working_tree_dir)):
             raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
-        return relative_path
-
-    def _preprocess_add_items(self, items):
-        """ Split the items into two lists of path strings and BaseEntries. """
-        paths = list()
-        entries = list()
+        result = os.path.relpath(path, self.repo.working_tree_dir)
+        if str(path).endswith(os.sep) and not result.endswith(os.sep):
+            result += os.sep
+        return result
+
+    def _preprocess_add_items(
+        self, items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]]
+    ) -> Tuple[List[PathLike], List[BaseIndexEntry]]:
+        """Split the items into two lists of path strings and BaseEntries."""
+        paths = []
+        entries = []
+        # if it is a string put in list
+        if isinstance(items, (str, os.PathLike)):
+            items = [items]
 
         for item in items:
-            if isinstance(item, string_types):
+            if isinstance(item, (str, os.PathLike)):
                 paths.append(self._to_relative_path(item))
             elif isinstance(item, (Blob, Submodule)):
                 entries.append(BaseIndexEntry.from_blob(item))
@@ -556,45 +683,71 @@ def _preprocess_add_items(self, items):
             else:
                 raise TypeError("Invalid Type: %r" % item)
         # END for each item
-        return (paths, entries)
+        return paths, entries
+
+    def _store_path(self, filepath: PathLike, fprogress: Callable) -> BaseIndexEntry:
+        """Store file at filepath in the database and return the base index entry.
+
+        :note:
+            This needs the :func:`~git.index.util.git_working_dir` decorator active!
+            This must be ensured in the calling code.
+        """
+        st = os.lstat(filepath)  # Handles non-symlinks as well.
 
-    def _store_path(self, filepath, fprogress):
-        """Store file at filepath in the database and return the base index entry
-        Needs the git_working_dir decorator active ! This must be assured in the calling code"""
-        st = os.lstat(filepath)     # handles non-symlinks as well
-        stream = None
         if S_ISLNK(st.st_mode):
-            # in PY3, readlink is string, but we need bytes. In PY2, it's just OS encoded bytes, we assume UTF-8
-            stream = BytesIO(force_bytes(os.readlink(filepath), encoding='utf-8'))
+            # In PY3, readlink is a string, but we need bytes.
+            # In PY2, it was just OS encoded bytes, we assumed UTF-8.
+            def open_stream() -> BinaryIO:
+                return BytesIO(force_bytes(os.readlink(filepath), encoding=defenc))
         else:
-            stream = open(filepath, 'rb')
-        # END handle stream
-        fprogress(filepath, False, filepath)
-        istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream))
-        fprogress(filepath, True, filepath)
-        return BaseIndexEntry((stat_mode_to_index_mode(st.st_mode),
-                               istream.binsha, 0, to_native_path_linux(filepath)))
 
+            def open_stream() -> BinaryIO:
+                return open(filepath, "rb")
+
+        with open_stream() as stream:
+            fprogress(filepath, False, filepath)
+            istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream))
+            fprogress(filepath, True, filepath)
+        return BaseIndexEntry(
+            (
+                stat_mode_to_index_mode(st.st_mode),
+                istream.binsha,
+                0,
+                to_native_path_linux(filepath),
+            )
+        )
+
+    @unbare_repo
     @git_working_dir
-    def _entries_for_paths(self, paths, path_rewriter, fprogress, entries):
-        entries_added = list()
+    def _entries_for_paths(
+        self,
+        paths: List[str],
+        path_rewriter: Union[Callable, None],
+        fprogress: Callable,
+        entries: List[BaseIndexEntry],
+    ) -> List[BaseIndexEntry]:
+        entries_added: List[BaseIndexEntry] = []
         if path_rewriter:
             for path in paths:
-                if os.path.isabs(path):
+                if osp.isabs(path):
                     abspath = path
-                    gitrelative_path = path[len(self.repo.working_tree_dir) + 1:]
+                    gitrelative_path = path[len(str(self.repo.working_tree_dir)) + 1 :]
                 else:
                     gitrelative_path = path
-                    abspath = os.path.join(self.repo.working_tree_dir, gitrelative_path)
-                # end obtain relative and absolute paths
-
-                blob = Blob(self.repo, Blob.NULL_BIN_SHA,
-                            stat_mode_to_index_mode(os.stat(abspath).st_mode),
-                            to_native_path_linux(gitrelative_path))
+                    if self.repo.working_tree_dir:
+                        abspath = osp.join(self.repo.working_tree_dir, gitrelative_path)
+                # END obtain relative and absolute paths
+
+                blob = Blob(
+                    self.repo,
+                    Blob.NULL_BIN_SHA,
+                    stat_mode_to_index_mode(os.stat(abspath).st_mode),
+                    to_native_path_linux(gitrelative_path),
+                )
                 # TODO: variable undefined
                 entries.append(BaseIndexEntry.from_blob(blob))
             # END for each path
-            del(paths[:])
+            del paths[:]
         # END rewrite paths
 
         # HANDLE PATHS
@@ -605,10 +758,17 @@ def _entries_for_paths(self, paths, path_rewriter, fprogress, entries):
         # END path handling
         return entries_added
 
-    def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=None,
-            write=True):
-        """Add files from the working tree, specific blobs or BaseIndexEntries
-        to the index.
+    def add(
+        self,
+        items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]],
+        force: bool = True,
+        fprogress: Callable = lambda *args: None,
+        path_rewriter: Union[Callable[..., PathLike], None] = None,
+        write: bool = True,
+        write_extension_data: bool = False,
+    ) -> List[BaseIndexEntry]:
+        R"""Add files from the working tree, specific blobs, or
+        :class:`~git.index.typ.BaseIndexEntry`\s to the index.
 
         :param items:
             Multiple types of items are supported, types can be mixed within one call.
@@ -616,88 +776,122 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non
             relative or absolute.
 
             - path string
-                strings denote a relative or absolute path into the repository pointing to
-                an existing file, i.e. CHANGES, lib/myfile.ext, '/home/gitrepo/lib/myfile.ext'.
+
+                Strings denote a relative or absolute path into the repository pointing
+                to an existing file, e.g., ``CHANGES``, ``lib/myfile.ext``,
+                ``/home/gitrepo/lib/myfile.ext``.
+
+                Absolute paths must start with working tree directory of this index's
+                repository to be considered valid. For example, if it was initialized
+                with a non-normalized path, like ``/root/repo/../repo``, absolute paths
+                to be added must start with ``/root/repo/../repo``.
 
                 Paths provided like this must exist. When added, they will be written
                 into the object database.
 
-                PathStrings may contain globs, such as 'lib/__init__*' or can be directories
-                like 'lib', the latter ones will add all the files within the dirctory and
-                subdirectories.
+                PathStrings may contain globs, such as ``lib/__init__*``. Or they can be
+                directories like ``lib``, which will add all the files within the
+                directory and subdirectories.
+
+                This equals a straight :manpage:`git-add(1)`.
 
-                This equals a straight git-add.
+                They are added at stage 0.
 
-                They are added at stage 0
+            - :class:`~git.objects.blob.Blob` or
+              :class:`~git.objects.submodule.base.Submodule` object
 
-            - Blob or Submodule object
                 Blobs are added as they are assuming a valid mode is set.
-                The file they refer to may or may not exist in the file system, but
-                must be a path relative to our repository.
 
-                If their sha is null ( 40*0 ), their path must exist in the file system
-                relative to the git repository as an object will be created from
-                the data at the path.
-                The handling now very much equals the way string paths are processed, except that
-                the mode you have set will be kept. This allows you to create symlinks
-                by settings the mode respectively and writing the target of the symlink
-                directly into the file. This equals a default Linux-Symlink which
-                is not dereferenced automatically, except that it can be created on
-                filesystems not supporting it as well.
+                The file they refer to may or may not exist in the file system, but must
+                be a path relative to our repository.
+
+                If their sha is null (40*0), their path must exist in the file system
+                relative to the git repository as an object will be created from the
+                data at the path.
 
-                Please note that globs or directories are not allowed in Blob objects.
+                The handling now very much equals the way string paths are processed,
+                except that the mode you have set will be kept. This allows you to
+                create symlinks by settings the mode respectively and writing the target
+                of the symlink directly into the file. This equals a default Linux
+                symlink which is not dereferenced automatically, except that it can be
+                created on filesystems not supporting it as well.
 
-                They are added at stage 0
+                Please note that globs or directories are not allowed in
+                :class:`~git.objects.blob.Blob` objects.
 
-            - BaseIndexEntry or type
-                Handling equals the one of Blob objects, but the stage may be
-                explicitly set. Please note that Index Entries require binary sha's.
+                They are added at stage 0.
+
+            - :class:`~git.index.typ.BaseIndexEntry` or type
+
+                Handling equals the one of :class:`~git.objects.blob.Blob` objects, but
+                the stage may be explicitly set. Please note that Index Entries require
+                binary sha's.
 
         :param force:
             **CURRENTLY INEFFECTIVE**
-            If True, otherwise ignored or excluded files will be
-            added anyway.
-            As opposed to the git-add command, we enable this flag by default
-            as the API user usually wants the item to be added even though
-            they might be excluded.
+            If ``True``, otherwise ignored or excluded files will be added anyway. As
+            opposed to the :manpage:`git-add(1)` command, we enable this flag by default
+            as the API user usually wants the item to be added even though they might be
+            excluded.
 
         :param fprogress:
-            Function with signature f(path, done=False, item=item) called for each
-            path to be added, one time once it is about to be added where done==False
-            and once after it was added where done=True.
-            item is set to the actual item we handle, either a Path or a BaseIndexEntry
-            Please note that the processed path is not guaranteed to be present
-            in the index already as the index is currently being processed.
+            Function with signature ``f(path, done=False, item=item)`` called for each
+            path to be added, one time once it is about to be added where ``done=False``
+            and once after it was added where ``done=True``.
+
+            ``item`` is set to the actual item we handle, either a path or a
+            :class:`~git.index.typ.BaseIndexEntry`.
+
+            Please note that the processed path is not guaranteed to be present in the
+            index already as the index is currently being processed.
 
         :param path_rewriter:
-            Function with signature (string) func(BaseIndexEntry) function returning a path
+            Function, with signature ``(string) func(BaseIndexEntry)``, returning a path
             for each passed entry which is the path to be actually recorded for the
-            object created from entry.path. This allows you to write an index which
-            is not identical to the layout of the actual files on your hard-disk.
-            If not None and ``items`` contain plain paths, these paths will be
-            converted to Entries beforehand and passed to the path_rewriter.
-            Please note that entry.path is relative to the git repository.
+            object created from :attr:`entry.path <git.index.typ.BaseIndexEntry.path>`.
+            This allows you to write an index which is not identical to the layout of
+            the actual files on your hard-disk. If not ``None`` and `items` contain
+            plain paths, these paths will be converted to Entries beforehand and passed
+            to the path_rewriter. Please note that ``entry.path`` is relative to the git
+            repository.
 
         :param write:
-                If True, the index will be written once it was altered. Otherwise
-                the changes only exist in memory and are not available to git commands.
+            If ``True``, the index will be written once it was altered. Otherwise the
+            changes only exist in memory and are not available to git commands.
+
+        :param write_extension_data:
+            If ``True``, extension data will be written back to the index. This can lead
+            to issues in case it is containing the 'TREE' extension, which will cause
+            the :manpage:`git-commit(1)` command to write an old tree, instead of a new
+            one representing the now changed index.
+
+            This doesn't matter if you use :meth:`IndexFile.commit`, which ignores the
+            'TREE' extension altogether. You should set it to ``True`` if you intend to
+            use :meth:`IndexFile.commit` exclusively while maintaining support for
+            third-party extensions. Besides that, you can usually safely ignore the
+            built-in extensions when using GitPython on repositories that are not
+            handled manually at all.
+
+            All current built-in extensions are listed here:
+            https://git-scm.com/docs/index-format
 
         :return:
-            List(BaseIndexEntries) representing the entries just actually added.
+            List of :class:`~git.index.typ.BaseIndexEntry`\s representing the entries
+            just actually added.
 
         :raise OSError:
-            if a supplied Path did not exist. Please note that BaseIndexEntry
-            Objects that do not have a null sha will be added even if their paths
-            do not exist.
+            If a supplied path did not exist. Please note that
+            :class:`~git.index.typ.BaseIndexEntry` objects that do not have a null sha
+            will be added even if their paths do not exist.
         """
-        # sort the entries into strings and Entries, Blobs are converted to entries
-        # automatically
-        # paths can be git-added, for everything else we use git-update-index
+        # Sort the entries into strings and Entries.
+        # Blobs are converted to entries automatically.
+        # Paths can be git-added. For everything else we use git-update-index.
         paths, entries = self._preprocess_add_items(items)
-        entries_added = list()
-        # This code needs a working tree, therefore we try not to run it unless required.
+        entries_added: List[BaseIndexEntry] = []
+        # This code needs a working tree, so we try not to run it unless required.
         # That way, we are OK on a bare repository as well.
-        # If there are no paths, the rewriter has nothing to do either
+        # If there are no paths, the rewriter has nothing to do either.
         if paths:
             entries_added.extend(self._entries_for_paths(paths, path_rewriter, fprogress, entries))
 
@@ -706,66 +900,83 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non
             null_mode_entries = [e for e in entries if e.mode == 0]
             if null_mode_entries:
                 raise ValueError(
-                    "At least one Entry has a null-mode - please use index.remove to remove files for clarity")
+                    "At least one Entry has a null-mode - please use index.remove to remove files for clarity"
+                )
             # END null mode should be remove
 
-            # HANLDE ENTRY OBJECT CREATION
-            # create objects if required, otherwise go with the existing shas
+            # HANDLE ENTRY OBJECT CREATION
+            # Create objects if required, otherwise go with the existing shas.
             null_entries_indices = [i for i, e in enumerate(entries) if e.binsha == Object.NULL_BIN_SHA]
             if null_entries_indices:
+
                 @git_working_dir
-                def handle_null_entries(self):
+                def handle_null_entries(self: "IndexFile") -> None:
                     for ei in null_entries_indices:
                         null_entry = entries[ei]
                         new_entry = self._store_path(null_entry.path, fprogress)
 
-                        # update null entry
+                        # Update null entry.
                         entries[ei] = BaseIndexEntry(
-                            (null_entry.mode, new_entry.binsha, null_entry.stage, null_entry.path))
+                            (
+                                null_entry.mode,
+                                new_entry.binsha,
+                                null_entry.stage,
+                                null_entry.path,
+                            )
+                        )
                     # END for each entry index
-                # end closure
+
+                # END closure
+
                 handle_null_entries(self)
             # END null_entry handling
 
             # REWRITE PATHS
-            # If we have to rewrite the entries, do so now, after we have generated
-            # all object sha's
+            # If we have to rewrite the entries, do so now, after we have generated all
+            # object sha's.
             if path_rewriter:
                 for i, e in enumerate(entries):
                     entries[i] = BaseIndexEntry((e.mode, e.binsha, e.stage, path_rewriter(e)))
                 # END for each entry
             # END handle path rewriting
 
-            # just go through the remaining entries and provide progress info
+            # Just go through the remaining entries and provide progress info.
             for i, entry in enumerate(entries):
                 progress_sent = i in null_entries_indices
                 if not progress_sent:
                     fprogress(entry.path, False, entry)
                     fprogress(entry.path, True, entry)
                 # END handle progress
-            # END for each enty
+            # END for each entry
             entries_added.extend(entries)
         # END if there are base entries
 
         # FINALIZE
-        # add the new entries to this instance
+        # Add the new entries to this instance.
         for entry in entries_added:
             self.entries[(entry.path, 0)] = IndexEntry.from_base(entry)
 
         if write:
-            self.write()
+            self.write(ignore_extension_data=not write_extension_data)
         # END handle write
 
         return entries_added
 
-    def _items_to_rela_paths(self, items):
+    def _items_to_rela_paths(
+        self,
+        items: Union[PathLike, Sequence[Union[PathLike, BaseIndexEntry, Blob, Submodule]]],
+    ) -> List[PathLike]:
         """Returns a list of repo-relative paths from the given items which
-        may be absolute or relative paths, entries or blobs"""
-        paths = list()
+        may be absolute or relative paths, entries or blobs."""
+        paths = []
+        # If string, put in list.
+        if isinstance(items, (str, os.PathLike)):
+            items = [items]
+
         for item in items:
             if isinstance(item, (BaseIndexEntry, (Blob, Submodule))):
                 paths.append(self._to_relative_path(item.path))
-            elif isinstance(item, string_types):
+            elif isinstance(item, (str, os.PathLike)):
                 paths.append(self._to_relative_path(item))
             else:
                 raise TypeError("Invalid item type: %r" % item)
@@ -774,101 +985,126 @@ def _items_to_rela_paths(self, items):
 
     @post_clear_cache
     @default_index
-    def remove(self, items, working_tree=False, **kwargs):
-        """Remove the given items from the index and optionally from
-        the working tree as well.
+    def remove(
+        self,
+        items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]],
+        working_tree: bool = False,
+        **kwargs: Any,
+    ) -> List[str]:
+        R"""Remove the given items from the index and optionally from the working tree
+        as well.
 
         :param items:
             Multiple types of items are supported which may be be freely mixed.
 
             - path string
+
                 Remove the given path at all stages. If it is a directory, you must
-                specify the r=True keyword argument to remove all file entries
-                below it. If absolute paths are given, they will be converted
-                to a path relative to the git repository directory containing
-                the working tree
+                specify the ``r=True`` keyword argument to remove all file entries below
+                it. If absolute paths are given, they will be converted to a path
+                relative to the git repository directory containing the working tree
+
+                The path string may include globs, such as ``*.c``.
 
-                The path string may include globs, such as *.c.
+            - :class:`~git.objects.blob.Blob` object
 
-            - Blob Object
                 Only the path portion is used in this case.
 
-            - BaseIndexEntry or compatible type
-                The only relevant information here Yis the path. The stage is ignored.
+            - :class:`~git.index.typ.BaseIndexEntry` or compatible type
+
+                The only relevant information here is the path. The stage is ignored.
 
         :param working_tree:
-            If True, the entry will also be removed from the working tree, physically
-            removing the respective file. This may fail if there are uncommited changes
-            in it.
+            If ``True``, the entry will also be removed from the working tree,
+            physically removing the respective file. This may fail if there are
+            uncommitted changes in it.
 
         :param kwargs:
-            Additional keyword arguments to be passed to git-rm, such
-            as 'r' to allow recurive removal of
+            Additional keyword arguments to be passed to :manpage:`git-rm(1)`, such as
+            ``r`` to allow recursive removal.
 
         :return:
-            List(path_string, ...) list of repository relative paths that have
-            been removed effectively.
-            This is interesting to know in case you have provided a directory or
-            globs. Paths are relative to the repository. """
-        args = list()
+            List(path_string, ...) list of repository relative paths that have been
+            removed effectively.
+
+            This is interesting to know in case you have provided a directory or globs.
+            Paths are relative to the repository.
+        """
+        args = []
         if not working_tree:
             args.append("--cached")
         args.append("--")
 
-        # preprocess paths
+        # Preprocess paths.
         paths = self._items_to_rela_paths(items)
         removed_paths = self.repo.git.rm(args, paths, **kwargs).splitlines()
 
-        # process output to gain proper paths
+        # Process output to gain proper paths.
         # rm 'path'
         return [p[4:-1] for p in removed_paths]
 
     @post_clear_cache
     @default_index
-    def move(self, items, skip_errors=False, **kwargs):
+    def move(
+        self,
+        items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]],
+        skip_errors: bool = False,
+        **kwargs: Any,
+    ) -> List[Tuple[str, str]]:
         """Rename/move the items, whereas the last item is considered the destination of
-        the move operation. If the destination is a file, the first item ( of two )
-        must be a file as well. If the destination is a directory, it may be preceeded
-        by one or more directories or files.
+        the move operation.
+
+        If the destination is a file, the first item (of two) must be a file as well.
+
+        If the destination is a directory, it may be preceded by one or more directories
+        or files.
 
         The working tree will be affected in non-bare repositories.
 
-        :parma items:
-            Multiple types of items are supported, please see the 'remove' method
+        :param items:
+            Multiple types of items are supported, please see the :meth:`remove` method
             for reference.
+
         :param skip_errors:
-            If True, errors such as ones resulting from missing source files will
-            be skpped.
+            If ``True``, errors such as ones resulting from missing source files will be
+            skipped.
+
         :param kwargs:
-            Additional arguments you would like to pass to git-mv, such as dry_run
-            or force.
+            Additional arguments you would like to pass to :manpage:`git-mv(1)`, such as
+            ``dry_run`` or ``force``.
+
+        :return:
+            List(tuple(source_path_string, destination_path_string), ...)
+
+            A list of pairs, containing the source file moved as well as its actual
+            destination. Relative to the repository root.
 
-        :return:List(tuple(source_path_string, destination_path_string), ...)
-            A list of pairs, containing the source file moved as well as its
-            actual destination. Relative to the repository root.
+        :raise ValueError:
+            If only one item was given.
 
-        :raise ValueErorr: If only one item was given
-            GitCommandError: If git could not handle your request"""
-        args = list()
+        :raise git.exc.GitCommandError:
+            If git could not handle your request.
+        """
+        args = []
         if skip_errors:
-            args.append('-k')
+            args.append("-k")
 
         paths = self._items_to_rela_paths(items)
         if len(paths) < 2:
             raise ValueError("Please provide at least one source and one destination of the move operation")
 
-        was_dry_run = kwargs.pop('dry_run', kwargs.pop('n', None))
-        kwargs['dry_run'] = True
+        was_dry_run = kwargs.pop("dry_run", kwargs.pop("n", None))
+        kwargs["dry_run"] = True
 
-        # first execute rename in dryrun so the command tells us what it actually does
-        # ( for later output )
-        out = list()
+        # First execute rename in dry run so the command tells us what it actually does
+        # (for later output).
+        out = []
         mvlines = self.repo.git.mv(args, paths, **kwargs).splitlines()
 
-        # parse result - first 0:n/2 lines are 'checking ', the remaining ones
-        # are the 'renaming' ones which we parse
-        for ln in xrange(int(len(mvlines) / 2), len(mvlines)):
-            tokens = mvlines[ln].split(' to ')
+        # Parse result - first 0:n/2 lines are 'checking ', the remaining ones are the
+        # 'renaming' ones which we parse.
+        for ln in range(int(len(mvlines) / 2), len(mvlines)):
+            tokens = mvlines[ln].split(" to ")
             assert len(tokens) == 2, "Too many tokens in %s" % mvlines[ln]
 
             # [0] = Renaming x
@@ -876,114 +1112,188 @@ def move(self, items, skip_errors=False, **kwargs):
             out.append((tokens[0][9:], tokens[1]))
         # END for each line to parse
 
-        # either prepare for the real run, or output the dry-run result
+        # Either prepare for the real run, or output the dry-run result.
         if was_dry_run:
             return out
-        # END handle dryrun
+        # END handle dry run
 
-        # now apply the actual operation
-        kwargs.pop('dry_run')
+        # Now apply the actual operation.
+        kwargs.pop("dry_run")
         self.repo.git.mv(args, paths, **kwargs)
 
         return out
 
-    def commit(self, message, parent_commits=None, head=True, author=None, committer=None):
-        """Commit the current default index file, creating a commit object.
-        For more information on the arguments, see tree.commit.
+    def commit(
+        self,
+        message: str,
+        parent_commits: Union[List[Commit], None] = None,
+        head: bool = True,
+        author: Union[None, Actor] = None,
+        committer: Union[None, Actor] = None,
+        author_date: Union[datetime.datetime, str, None] = None,
+        commit_date: Union[datetime.datetime, str, None] = None,
+        skip_hooks: bool = False,
+    ) -> Commit:
+        """Commit the current default index file, creating a
+        :class:`~git.objects.commit.Commit` object.
+
+        For more information on the arguments, see
+        :meth:`Commit.create_from_tree <git.objects.commit.Commit.create_from_tree>`.
 
-        :note: If you have manually altered the .entries member of this instance,
-               don't forget to write() your changes to disk beforehand.
-        :return: Commit object representing the new commit"""
-        run_commit_hook('pre-commit', self)
+        :note:
+            If you have manually altered the :attr:`entries` member of this instance,
+            don't forget to :meth:`write` your changes to disk beforehand.
+
+        :note:
+            Passing ``skip_hooks=True`` is the equivalent of using ``-n`` or
+            ``--no-verify`` on the command line.
+
+        :return:
+            :class:`~git.objects.commit.Commit` object representing the new commit
+        """
+        if not skip_hooks:
+            run_commit_hook("pre-commit", self)
+
+            self._write_commit_editmsg(message)
+            run_commit_hook("commit-msg", self, self._commit_editmsg_filepath())
+            message = self._read_commit_editmsg()
+            self._remove_commit_editmsg()
         tree = self.write_tree()
-        rval = Commit.create_from_tree(self.repo, tree, message, parent_commits,
-                                       head, author=author, committer=committer)
-        run_commit_hook('post-commit', self)
+        rval = Commit.create_from_tree(
+            self.repo,
+            tree,
+            message,
+            parent_commits,
+            head,
+            author=author,
+            committer=committer,
+            author_date=author_date,
+            commit_date=commit_date,
+        )
+        if not skip_hooks:
+            run_commit_hook("post-commit", self)
         return rval
 
-    @classmethod
-    def _flush_stdin_and_wait(cls, proc, ignore_stdout=False):
-        proc.stdin.flush()
-        proc.stdin.close()
-        stdout = ''
-        if not ignore_stdout:
+    def _write_commit_editmsg(self, message: str) -> None:
+        with open(self._commit_editmsg_filepath(), "wb") as commit_editmsg_file:
+            commit_editmsg_file.write(message.encode(defenc))
+
+    def _remove_commit_editmsg(self) -> None:
+        os.remove(self._commit_editmsg_filepath())
+
+    def _read_commit_editmsg(self) -> str:
+        with open(self._commit_editmsg_filepath(), "rb") as commit_editmsg_file:
+            return commit_editmsg_file.read().decode(defenc)
+
+    def _commit_editmsg_filepath(self) -> str:
+        return osp.join(self.repo.common_dir, "COMMIT_EDITMSG")
+
+    def _flush_stdin_and_wait(cls, proc: "Popen[bytes]", ignore_stdout: bool = False) -> bytes:
+        stdin_IO = proc.stdin
+        if stdin_IO:
+            stdin_IO.flush()
+            stdin_IO.close()
+
+        stdout = b""
+        if not ignore_stdout and proc.stdout:
             stdout = proc.stdout.read()
-        proc.stdout.close()
-        proc.wait()
+
+        if proc.stdout:
+            proc.stdout.close()
+            proc.wait()
         return stdout
 
     @default_index
-    def checkout(self, paths=None, force=False, fprogress=lambda *args: None, **kwargs):
-        """Checkout the given paths or all files from the version known to the index into
-        the working tree.
+    def checkout(
+        self,
+        paths: Union[None, Iterable[PathLike]] = None,
+        force: bool = False,
+        fprogress: Callable = lambda *args: None,
+        **kwargs: Any,
+    ) -> Union[None, Iterator[PathLike], Sequence[PathLike]]:
+        """Check out the given paths or all files from the version known to the index
+        into the working tree.
 
-        :note: Be sure you have written pending changes using the ``write`` method
-            in case you have altered the enties dictionary directly
+        :note:
+            Be sure you have written pending changes using the :meth:`write` method in
+            case you have altered the entries dictionary directly.
 
         :param paths:
-            If None, all paths in the index will be checked out. Otherwise an iterable
-            of relative or absolute paths or a single path pointing to files or directories
-            in the index is expected.
+            If ``None``, all paths in the index will be checked out.
+            Otherwise an iterable of relative or absolute paths or a single path
+            pointing to files or directories in the index is expected.
 
         :param force:
-            If True, existing files will be overwritten even if they contain local modifications.
-            If False, these will trigger a CheckoutError.
+            If ``True``, existing files will be overwritten even if they contain local
+            modifications.
+            If ``False``, these will trigger a :exc:`~git.exc.CheckoutError`.
 
         :param fprogress:
-            see Index.add_ for signature and explanation.
-            The provided progress information will contain None as path and item if no
-            explicit paths are given. Otherwise progress information will be send
-            prior and after a file has been checked out
+            See :meth:`IndexFile.add` for signature and explanation.
+
+            The provided progress information will contain ``None`` as path and item if
+            no explicit paths are given. Otherwise progress information will be send
+            prior and after a file has been checked out.
 
         :param kwargs:
-            Additional arguments to be pasesd to git-checkout-index
+            Additional arguments to be passed to :manpage:`git-checkout-index(1)`.
 
         :return:
-            iterable yielding paths to files which have been checked out and are
-            guaranteed to match the version stored in the index
-
-        :raise CheckoutError:
-            If at least one file failed to be checked out. This is a summary,
-            hence it will checkout as many files as it can anyway.
-            If one of files or directories do not exist in the index
-            ( as opposed to the  original git command who ignores them ).
-            Raise GitCommandError if error lines could not be parsed - this truly is
-            an exceptional state
-
-        .. note:: The checkout is limited to checking out the files in the
-            index. Files which are not in the index anymore and exist in
-            the working tree will not be deleted. This behaviour is fundamentally
-            different to *head.checkout*, i.e. if you want git-checkout like behaviour,
-            use head.checkout instead of index.checkout.
-            """
+            Iterable yielding paths to files which have been checked out and are
+            guaranteed to match the version stored in the index.
+
+        :raise git.exc.CheckoutError:
+            * If at least one file failed to be checked out. This is a summary, hence it
+              will checkout as many files as it can anyway.
+            * If one of files or directories do not exist in the index (as opposed to
+              the original git command, which ignores them).
+
+        :raise git.exc.GitCommandError:
+            If error lines could not be parsed - this truly is an exceptional state.
+
+        :note:
+            The checkout is limited to checking out the files in the index. Files which
+            are not in the index anymore and exist in the working tree will not be
+            deleted. This behaviour is fundamentally different to ``head.checkout``,
+            i.e. if you want :manpage:`git-checkout(1)`-like behaviour, use
+            ``head.checkout`` instead of ``index.checkout``.
+        """
         args = ["--index"]
         if force:
             args.append("--force")
 
-        def handle_stderr(proc, iter_checked_out_files):
-            stderr = proc.stderr.read()
-            if not stderr:
-                return
+        failed_files = []
+        failed_reasons = []
+        unknown_lines = []
+
+        def handle_stderr(proc: "Popen[bytes]", iter_checked_out_files: Iterable[PathLike]) -> None:
+            stderr_IO = proc.stderr
+            if not stderr_IO:
+                return  # Return early if stderr empty.
+
+            stderr_bytes = stderr_IO.read()
             # line contents:
-            stderr = stderr.decode(defenc)
+            stderr = stderr_bytes.decode(defenc)
             # git-checkout-index: this already exists
-            failed_files = list()
-            failed_reasons = list()
-            unknown_lines = list()
-            endings = (' already exists', ' is not in the cache', ' does not exist at stage', ' is unmerged')
+            endings = (
+                " already exists",
+                " is not in the cache",
+                " does not exist at stage",
+                " is unmerged",
+            )
             for line in stderr.splitlines():
                 if not line.startswith("git checkout-index: ") and not line.startswith("git-checkout-index: "):
                     is_a_dir = " is a directory"
                     unlink_issue = "unable to unlink old '"
-                    already_exists_issue = ' already exists, no checkout'   # created by entry.c:checkout_entry(...)
+                    already_exists_issue = " already exists, no checkout"  # created by entry.c:checkout_entry(...)
                     if line.endswith(is_a_dir):
-                        failed_files.append(line[:-len(is_a_dir)])
+                        failed_files.append(line[: -len(is_a_dir)])
                         failed_reasons.append(is_a_dir)
                     elif line.startswith(unlink_issue):
-                        failed_files.append(line[len(unlink_issue):line.rfind("'")])
+                        failed_files.append(line[len(unlink_issue) : line.rfind("'")])
                         failed_reasons.append(unlink_issue)
                     elif line.endswith(already_exists_issue):
-                        failed_files.append(line[:-len(already_exists_issue)])
+                        failed_files.append(line[: -len(already_exists_issue)])
                         failed_reasons.append(already_exists_issue)
                     else:
                         unknown_lines.append(line)
@@ -992,63 +1302,70 @@ def handle_stderr(proc, iter_checked_out_files):
 
                 for e in endings:
                     if line.endswith(e):
-                        failed_files.append(line[20:-len(e)])
+                        failed_files.append(line[20 : -len(e)])
                         failed_reasons.append(e)
                         break
                     # END if ending matches
                 # END for each possible ending
             # END for each line
             if unknown_lines:
-                raise GitCommandError(("git-checkout-index", ), 128, stderr)
+                raise GitCommandError(("git-checkout-index",), 128, stderr)
             if failed_files:
                 valid_files = list(set(iter_checked_out_files) - set(failed_files))
                 raise CheckoutError(
                     "Some files could not be checked out from the index due to local modifications",
-                    failed_files, valid_files, failed_reasons)
+                    failed_files,
+                    valid_files,
+                    failed_reasons,
+                )
+
         # END stderr handler
 
         if paths is None:
             args.append("--all")
-            kwargs['as_process'] = 1
+            kwargs["as_process"] = 1
             fprogress(None, False, None)
             proc = self.repo.git.checkout_index(*args, **kwargs)
             proc.wait()
             fprogress(None, True, None)
-            rval_iter = (e.path for e in mviter(self.entries))
+            rval_iter = (e.path for e in self.entries.values())
             handle_stderr(proc, rval_iter)
             return rval_iter
         else:
-            if isinstance(paths, string_types):
+            if isinstance(paths, str):
                 paths = [paths]
 
-            # make sure we have our entries loaded before we start checkout_index
-            # which will hold a lock on it. We try to get the lock as well during
-            # our entries initialization
-            self.entries
+            # Make sure we have our entries loaded before we start checkout_index, which
+            # will hold a lock on it. We try to get the lock as well during our entries
+            # initialization.
+            self.entries  # noqa: B018
 
             args.append("--stdin")
-            kwargs['as_process'] = True
-            kwargs['istream'] = subprocess.PIPE
+            kwargs["as_process"] = True
+            kwargs["istream"] = subprocess.PIPE
             proc = self.repo.git.checkout_index(args, **kwargs)
-            make_exc = lambda: GitCommandError(("git-checkout-index",) + tuple(args), 128, proc.stderr.read())
-            checked_out_files = list()
+
+            # FIXME: Reading from GIL!
+            def make_exc() -> GitCommandError:
+                return GitCommandError(("git-checkout-index", *args), 128, proc.stderr.read())
+
+            checked_out_files: List[PathLike] = []
 
             for path in paths:
                 co_path = to_native_path_linux(self._to_relative_path(path))
-                # if the item is not in the index, it could be a directory
+                # If the item is not in the index, it could be a directory.
                 path_is_directory = False
 
                 try:
                     self.entries[(co_path, 0)]
                 except KeyError:
-                    dir = co_path
-                    if not dir.endswith('/'):
-                        dir += '/'
-                    for entry in mviter(self.entries):
-                        if entry.path.startswith(dir):
+                    folder = str(co_path)
+                    if not folder.endswith("/"):
+                        folder += "/"
+                    for entry in self.entries.values():
+                        if str(entry.path).startswith(folder):
                             p = entry.path
-                            self._write_path_to_stdin(proc, p, p, make_exc,
-                                                      fprogress, read_from_stdout=False)
+                            self._write_path_to_stdin(proc, p, p, make_exc, fprogress, read_from_stdout=False)
                             checked_out_files.append(p)
                             path_is_directory = True
                         # END if entry is in directory
@@ -1056,54 +1373,79 @@ def handle_stderr(proc, iter_checked_out_files):
                 # END path exception handlnig
 
                 if not path_is_directory:
-                    self._write_path_to_stdin(proc, co_path, path, make_exc,
-                                              fprogress, read_from_stdout=False)
+                    self._write_path_to_stdin(proc, co_path, path, make_exc, fprogress, read_from_stdout=False)
                     checked_out_files.append(co_path)
                 # END path is a file
             # END for each path
-            self._flush_stdin_and_wait(proc, ignore_stdout=True)
+            try:
+                self._flush_stdin_and_wait(proc, ignore_stdout=True)
+            except GitCommandError:
+                # Without parsing stdout we don't know what failed.
+                raise CheckoutError(  # noqa: B904
+                    "Some files could not be checked out from the index, probably because they didn't exist.",
+                    failed_files,
+                    [],
+                    failed_reasons,
+                )
 
             handle_stderr(proc, checked_out_files)
             return checked_out_files
         # END paths handling
-        assert "Should not reach this point"
 
     @default_index
-    def reset(self, commit='HEAD', working_tree=False, paths=None, head=False, **kwargs):
-        """Reset the index to reflect the tree at the given commit. This will not
-        adjust our HEAD reference as opposed to HEAD.reset by default.
+    def reset(
+        self,
+        commit: Union[Commit, "Reference", str] = "HEAD",
+        working_tree: bool = False,
+        paths: Union[None, Iterable[PathLike]] = None,
+        head: bool = False,
+        **kwargs: Any,
+    ) -> "IndexFile":
+        """Reset the index to reflect the tree at the given commit. This will not adjust
+        our HEAD reference by default, as opposed to
+        :meth:`HEAD.reset <git.refs.head.HEAD.reset>`.
 
         :param commit:
-            Revision, Reference or Commit specifying the commit we should represent.
-            If you want to specify a tree only, use IndexFile.from_tree and overwrite
-            the default index.
+            Revision, :class:`~git.refs.reference.Reference` or
+            :class:`~git.objects.commit.Commit` specifying the commit we should
+            represent.
+
+            If you want to specify a tree only, use :meth:`IndexFile.from_tree` and
+            overwrite the default index.
 
         :param working_tree:
-            If True, the files in the working tree will reflect the changed index.
-            If False, the working tree will not be touched
+            If ``True``, the files in the working tree will reflect the changed index.
+            If ``False``, the working tree will not be touched.
             Please note that changes to the working copy will be discarded without
-            warning !
+            warning!
 
         :param head:
-            If True, the head will be set to the given commit. This is False by default,
-            but if True, this method behaves like HEAD.reset.
+            If ``True``, the head will be set to the given commit. This is ``False`` by
+            default, but if ``True``, this method behaves like
+            :meth:`HEAD.reset <git.refs.head.HEAD.reset>`.
 
-        :param paths: if given as an iterable of absolute or repository-relative paths,
-            only these will be reset to their state at the given commit'ish.
+        :param paths:
+            If given as an iterable of absolute or repository-relative paths, only these
+            will be reset to their state at the given commit-ish.
             The paths need to exist at the commit, otherwise an exception will be
             raised.
 
         :param kwargs:
-            Additional keyword arguments passed to git-reset
+            Additional keyword arguments passed to :manpage:`git-reset(1)`.
 
-        .. note:: IndexFile.reset, as opposed to HEAD.reset, will not delete anyfiles
-            in order to maintain a consistent working tree. Instead, it will just
-            checkout the files according to their state in the index.
-            If you want git-reset like behaviour, use *HEAD.reset* instead.
+        :note:
+            :meth:`IndexFile.reset`, as opposed to
+            :meth:`HEAD.reset <git.refs.head.HEAD.reset>`, will not delete any files in
+            order to maintain a consistent working tree. Instead, it will just check out
+            the files according to their state in the index.
+            If you want :manpage:`git-reset(1)`-like behaviour, use
+            :meth:`HEAD.reset <git.refs.head.HEAD.reset>` instead.
 
-        :return: self """
-        # what we actually want to do is to merge the tree into our existing
-        # index, which is what git-read-tree does
+        :return:
+            self
+        """
+        # What we actually want to do is to merge the tree into our existing index,
+        # which is what git-read-tree does.
         new_inst = type(self).from_tree(self.repo, commit)
         if not paths:
             self.entries = new_inst.entries
@@ -1115,9 +1457,9 @@ def reset(self, commit='HEAD', working_tree=False, paths=None, head=False, **kwa
                     key = entry_key(path, 0)
                     self.entries[key] = nie[key]
                 except KeyError:
-                    # if key is not in theirs, it musn't be in ours
+                    # If key is not in theirs, it mustn't be in ours.
                     try:
-                        del(self.entries[key])
+                        del self.entries[key]
                     except KeyError:
                         pass
                     # END handle deletion keyerror
@@ -1136,38 +1478,55 @@ def reset(self, commit='HEAD', working_tree=False, paths=None, head=False, **kwa
 
         return self
 
-    @default_index
-    def diff(self, other=diff.Diffable.Index, paths=None, create_patch=False, **kwargs):
-        """Diff this index against the working copy or a Tree or Commit object
-
-        For a documentation of the parameters and return values, see
-        Diffable.diff
+    # FIXME: This is documented to accept the same parameters as Diffable.diff, but this
+    # does not handle NULL_TREE for `other`. (The suppressed mypy error is about this.)
+    def diff(
+        self,
+        other: Union[  # type: ignore[override]
+            Literal[git_diff.DiffConstants.INDEX],
+            "Tree",
+            "Commit",
+            str,
+            None,
+        ] = git_diff.INDEX,
+        paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] = None,
+        create_patch: bool = False,
+        **kwargs: Any,
+    ) -> git_diff.DiffIndex[git_diff.Diff]:
+        """Diff this index against the working copy or a :class:`~git.objects.tree.Tree`
+        or :class:`~git.objects.commit.Commit` object.
+
+        For documentation of the parameters and return values, see
+        :meth:`Diffable.diff <git.diff.Diffable.diff>`.
 
         :note:
-            Will only work with indices that represent the default git index as
-            they have not been initialized with a stream.
+            Will only work with indices that represent the default git index as they
+            have not been initialized with a stream.
         """
-        # index against index is always empty
-        if other is self.Index:
-            return diff.DiffIndex()
-
-        # index against anything but None is a reverse diff with the respective
-        # item. Handle existing -R flags properly. Transform strings to the object
-        # so that we can call diff on it
-        if isinstance(other, string_types):
+        # Only run if we are the default repository index.
+        if self._file_path != self._index_path():
+            raise AssertionError("Cannot call %r on indices that do not represent the default git index" % self.diff())
+        # Index against index is always empty.
+        if other is self.INDEX:
+            return git_diff.DiffIndex()
+
+        # Index against anything but None is a reverse diff with the respective item.
+        # Handle existing -R flags properly.
+        # Transform strings to the object so that we can call diff on it.
+        if isinstance(other, str):
             other = self.repo.rev_parse(other)
         # END object conversion
 
-        if isinstance(other, Object):
-            # invert the existing R flag
-            cur_val = kwargs.get('R', False)
-            kwargs['R'] = not cur_val
-            return other.diff(self.Index, paths, create_patch, **kwargs)
-        # END diff against other item handlin
+        if isinstance(other, Object):  # For Tree or Commit.
+            # Invert the existing R flag.
+            cur_val = kwargs.get("R", False)
+            kwargs["R"] = not cur_val
+            return other.diff(self.INDEX, paths, create_patch, **kwargs)
+        # END diff against other item handling
 
-        # if other is not None here, something is wrong
+        # If other is not None here, something is wrong.
         if other is not None:
-            raise ValueError("other must be None, Diffable.Index, a Tree or Commit, was %r" % other)
+            raise ValueError("other must be None, Diffable.INDEX, a Tree or Commit, was %r" % other)
 
-        # diff against working copy - can be handled by superclass natively
-        return super(IndexFile, self).diff(other, paths, create_patch, **kwargs)
+        # Diff against working copy - can be handled by superclass natively.
+        return super().diff(other, paths, create_patch, **kwargs)
diff --git a/git/index/fun.py b/git/index/fun.py
index f07cf7dc3..d03ec6759 100644
--- a/git/index/fun.py
+++ b/git/index/fun.py
@@ -1,178 +1,257 @@
-# Contains standalone functions to accompany the index implementation and make it
-# more versatile
-# NOTE: Autodoc hates it if this is a docstring
-from stat import (
-    S_IFDIR,
-    S_IFLNK,
-    S_ISLNK,
-    S_ISDIR,
-    S_IFMT,
-    S_IFREG,
-)
-
-S_IFGITLINK = S_IFLNK | S_IFDIR     # a submodule
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Standalone functions to accompany the index implementation and make it more
+versatile."""
+
+__all__ = [
+    "write_cache",
+    "read_cache",
+    "write_tree_from_cache",
+    "entry_key",
+    "stat_mode_to_index_mode",
+    "S_IFGITLINK",
+    "run_commit_hook",
+    "hook_path",
+]
 
 from io import BytesIO
 import os
+import os.path as osp
+from pathlib import Path
+from stat import S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, S_ISDIR, S_ISLNK, S_IXUSR
 import subprocess
+import sys
 
-from git.util import IndexFileSHA1Writer
-from git.exc import (
-    UnmergedEntriesError,
-    HookExecutionError
-)
+from gitdb.base import IStream
+from gitdb.typ import str_tree_type
+
+from git.cmd import handle_process_output, safer_popen
+from git.compat import defenc, force_bytes, force_text, safe_decode
+from git.exc import HookExecutionError, UnmergedEntriesError
 from git.objects.fun import (
-    tree_to_stream,
     traverse_tree_recursive,
-    traverse_trees_recursive
+    traverse_trees_recursive,
+    tree_to_stream,
 )
+from git.util import IndexFileSHA1Writer, finalize_process
 
-from .typ import (
-    BaseIndexEntry,
-    IndexEntry,
-    CE_NAMEMASK,
-    CE_STAGESHIFT
-)
-CE_NAMEMASK_INV = ~CE_NAMEMASK
+from .typ import BaseIndexEntry, IndexEntry, CE_NAMEMASK, CE_STAGESHIFT
+from .util import pack, unpack
 
-from .util import (
-    pack,
-    unpack
-)
+# typing -----------------------------------------------------------------------------
 
-from gitdb.base import IStream
-from gitdb.typ import str_tree_type
-from git.compat import (
-    defenc,
-    force_text
-)
+from typing import Dict, IO, List, Sequence, TYPE_CHECKING, Tuple, Type, Union, cast
+
+from git.types import PathLike
+
+if TYPE_CHECKING:
+    from git.db import GitCmdObjectDB
+    from git.objects.tree import TreeCacheTup
+
+    from .base import IndexFile
+
+# ------------------------------------------------------------------------------------
+
+S_IFGITLINK = S_IFLNK | S_IFDIR
+"""Flags for a submodule."""
 
-__all__ = ('write_cache', 'read_cache', 'write_tree_from_cache', 'entry_key',
-           'stat_mode_to_index_mode', 'S_IFGITLINK', 'run_commit_hook', 'hook_path')
+CE_NAMEMASK_INV = ~CE_NAMEMASK
 
 
-def hook_path(name, git_dir):
+def hook_path(name: str, git_dir: PathLike) -> str:
     """:return: path to the given named hook in the given git repository directory"""
-    return os.path.join(git_dir, 'hooks', name)
+    return osp.join(git_dir, "hooks", name)
+
+
+def _has_file_extension(path: str) -> str:
+    return osp.splitext(path)[1]
+
+
+def run_commit_hook(name: str, index: "IndexFile", *args: str) -> None:
+    """Run the commit hook of the given name. Silently ignore hooks that do not exist.
+
+    :param name:
+        Name of hook, like ``pre-commit``.
 
+    :param index:
+        :class:`~git.index.base.IndexFile` instance.
 
-def run_commit_hook(name, index):
-    """Run the commit hook of the given name. Silently ignores hooks that do not exist.
-    :param name: name of hook, like 'pre-commit'
-    :param index: IndexFile instance
-    :raises HookExecutionError: """
+    :param args:
+        Arguments passed to hook file.
+
+    :raise git.exc.HookExecutionError:
+    """
     hp = hook_path(name, index.repo.git_dir)
     if not os.access(hp, os.X_OK):
         return
 
     env = os.environ.copy()
-    env['GIT_INDEX_FILE'] = index.path
-    env['GIT_EDITOR'] = ':'
-    cmd = subprocess.Popen(hp,
-                           env=env,
-                           stdout=subprocess.PIPE,
-                           stderr=subprocess.PIPE,
-                           close_fds=(os.name == 'posix'))
-    stdout, stderr = cmd.communicate()
-    cmd.stdout.close()
-    cmd.stderr.close()
-
-    if cmd.returncode != 0:
-        stdout = force_text(stdout, defenc)
-        stderr = force_text(stderr, defenc)
-        raise HookExecutionError(hp, cmd.returncode, stdout, stderr)
-    # end handle return code
-
-
-def stat_mode_to_index_mode(mode):
-    """Convert the given mode from a stat call to the corresponding index mode
-    and return it"""
-    if S_ISLNK(mode):   # symlinks
+    env["GIT_INDEX_FILE"] = safe_decode(str(index.path))
+    env["GIT_EDITOR"] = ":"
+    cmd = [hp]
+    try:
+        if sys.platform == "win32" and not _has_file_extension(hp):
+            # Windows only uses extensions to determine how to open files
+            # (doesn't understand shebangs). Try using bash to run the hook.
+            relative_hp = Path(hp).relative_to(index.repo.working_dir).as_posix()
+            cmd = ["bash.exe", relative_hp]
+
+        process = safer_popen(
+            cmd + list(args),
+            env=env,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+            cwd=index.repo.working_dir,
+        )
+    except Exception as ex:
+        raise HookExecutionError(hp, ex) from ex
+    else:
+        stdout_list: List[str] = []
+        stderr_list: List[str] = []
+        handle_process_output(process, stdout_list.append, stderr_list.append, finalize_process)
+        stdout = "".join(stdout_list)
+        stderr = "".join(stderr_list)
+        if process.returncode != 0:
+            stdout = force_text(stdout, defenc)
+            stderr = force_text(stderr, defenc)
+            raise HookExecutionError(hp, process.returncode, stderr, stdout)
+    # END handle return code
+
+
+def stat_mode_to_index_mode(mode: int) -> int:
+    """Convert the given mode from a stat call to the corresponding index mode and
+    return it."""
+    if S_ISLNK(mode):  # symlinks
         return S_IFLNK
-    if S_ISDIR(mode) or S_IFMT(mode) == S_IFGITLINK:    # submodules
+    if S_ISDIR(mode) or S_IFMT(mode) == S_IFGITLINK:  # submodules
         return S_IFGITLINK
-    return S_IFREG | 0o644 | (mode & 0o100)       # blobs with or without executable bit
+    return S_IFREG | (mode & S_IXUSR and 0o755 or 0o644)  # blobs with or without executable bit
 
 
-def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1Writer):
-    """Write the cache represented by entries to a stream
+def write_cache(
+    entries: Sequence[Union[BaseIndexEntry, "IndexEntry"]],
+    stream: IO[bytes],
+    extension_data: Union[None, bytes] = None,
+    ShaStreamCls: Type[IndexFileSHA1Writer] = IndexFileSHA1Writer,
+) -> None:
+    """Write the cache represented by entries to a stream.
 
-    :param entries: **sorted** list of entries
-    :param stream: stream to wrap into the AdapterStreamCls - it is used for
-        final output.
+    :param entries:
+        **Sorted** list of entries.
 
-    :param ShaStreamCls: Type to use when writing to the stream. It produces a sha
-        while writing to it, before the data is passed on to the wrapped stream
+    :param stream:
+        Stream to wrap into the AdapterStreamCls - it is used for final output.
 
-    :param extension_data: any kind of data to write as a trailer, it must begin
-        a 4 byte identifier, followed by its size ( 4 bytes )"""
-    # wrap the stream into a compatible writer
-    stream = ShaStreamCls(stream)
+    :param ShaStreamCls:
+        Type to use when writing to the stream. It produces a sha while writing to it,
+        before the data is passed on to the wrapped stream.
 
-    tell = stream.tell
-    write = stream.write
+    :param extension_data:
+        Any kind of data to write as a trailer, it must begin a 4 byte identifier,
+        followed by its size (4 bytes).
+    """
+    # Wrap the stream into a compatible writer.
+    stream_sha = ShaStreamCls(stream)
+
+    tell = stream_sha.tell
+    write = stream_sha.write
 
-    # header
+    # Header
     version = 2
     write(b"DIRC")
     write(pack(">LL", version, len(entries)))
 
-    # body
+    # Body
     for entry in entries:
         beginoffset = tell()
-        write(entry[4])         # ctime
-        write(entry[5])         # mtime
-        path = entry[3]
-        plen = len(path) & CE_NAMEMASK      # path length
-        assert plen == len(path), "Path %s too long to fit into index" % entry[3]
-        flags = plen | (entry[2] & CE_NAMEMASK_INV)     # clear possible previous values
-        write(pack(">LLLLLL20sH", entry[6], entry[7], entry[0],
-                   entry[8], entry[9], entry[10], entry[1], flags))
-        write(path.encode(defenc))
-        real_size = ((tell() - beginoffset + 8) & ~7)
+        write(entry.ctime_bytes)  # ctime
+        write(entry.mtime_bytes)  # mtime
+        path_str = str(entry.path)
+        path: bytes = force_bytes(path_str, encoding=defenc)
+        plen = len(path) & CE_NAMEMASK  # Path length
+        assert plen == len(path), "Path %s too long to fit into index" % entry.path
+        flags = plen | (entry.flags & CE_NAMEMASK_INV)  # Clear possible previous values.
+        write(
+            pack(
+                ">LLLLLL20sH",
+                entry.dev,
+                entry.inode,
+                entry.mode,
+                entry.uid,
+                entry.gid,
+                entry.size,
+                entry.binsha,
+                flags,
+            )
+        )
+        write(path)
+        real_size = (tell() - beginoffset + 8) & ~7
         write(b"\0" * ((beginoffset + real_size) - tell()))
     # END for each entry
 
-    # write previously cached extensions data
+    # Write previously cached extensions data.
     if extension_data is not None:
-        stream.write(extension_data)
+        stream_sha.write(extension_data)
 
-    # write the sha over the content
-    stream.write_sha()
+    # Write the sha over the content.
+    stream_sha.write_sha()
 
 
-def read_header(stream):
-    """Return tuple(version_long, num_entries) from the given stream"""
+def read_header(stream: IO[bytes]) -> Tuple[int, int]:
+    """Return tuple(version_long, num_entries) from the given stream."""
     type_id = stream.read(4)
     if type_id != b"DIRC":
         raise AssertionError("Invalid index file header: %r" % type_id)
-    version, num_entries = unpack(">LL", stream.read(4 * 2))
+    unpacked = cast(Tuple[int, int], unpack(">LL", stream.read(4 * 2)))
+    version, num_entries = unpacked
 
-    # TODO: handle version 3: extended data, see read-cache.c
-    assert version in (1, 2)
+    # TODO: Handle version 3: extended data, see read-cache.c.
+    assert version in (1, 2), "Unsupported git index version %i, only 1 and 2 are supported" % version
     return version, num_entries
 
 
-def entry_key(*entry):
-    """:return: Key suitable to be used for the index.entries dictionary
-    :param entry: One instance of type BaseIndexEntry or the path and the stage"""
+def entry_key(*entry: Union[BaseIndexEntry, PathLike, int]) -> Tuple[PathLike, int]:
+    """
+    :return:
+        Key suitable to be used for the
+        :attr:`index.entries <git.index.base.IndexFile.entries>` dictionary.
+
+    :param entry:
+        One instance of type BaseIndexEntry or the path and the stage.
+    """
+
+    # def is_entry_key_tup(entry_key: Tuple) -> TypeGuard[Tuple[PathLike, int]]:
+    #     return isinstance(entry_key, tuple) and len(entry_key) == 2
+
     if len(entry) == 1:
-        return (entry[0].path, entry[0].stage)
+        entry_first = entry[0]
+        assert isinstance(entry_first, BaseIndexEntry)
+        return (entry_first.path, entry_first.stage)
     else:
-        return tuple(entry)
+        # assert is_entry_key_tup(entry)
+        entry = cast(Tuple[PathLike, int], entry)
+        return entry
     # END handle entry
 
 
-def read_cache(stream):
-    """Read a cache file from the given stream
-    :return: tuple(version, entries_dict, extension_data, content_sha)
-    * version is the integer version number
-    * entries dict is a dictionary which maps IndexEntry instances to a path at a stage
-    * extension_data is '' or 4 bytes of type + 4 bytes of size + size bytes
-    * content_sha is a 20 byte sha on all cache file contents"""
+def read_cache(
+    stream: IO[bytes],
+) -> Tuple[int, Dict[Tuple[PathLike, int], "IndexEntry"], bytes, bytes]:
+    """Read a cache file from the given stream.
+
+    :return:
+        tuple(version, entries_dict, extension_data, content_sha)
+
+        * *version* is the integer version number.
+        * *entries_dict* is a dictionary which maps IndexEntry instances to a path at a
+          stage.
+        * *extension_data* is ``""`` or 4 bytes of type + 4 bytes of size + size bytes.
+        * *content_sha* is a 20 byte sha on all cache file contents.
+    """
     version, num_entries = read_header(stream)
     count = 0
-    entries = dict()
+    entries: Dict[Tuple[PathLike, int], "IndexEntry"] = {}
 
     read = stream.read
     tell = stream.tell
@@ -180,49 +259,62 @@ def read_cache(stream):
         beginoffset = tell()
         ctime = unpack(">8s", read(8))[0]
         mtime = unpack(">8s", read(8))[0]
-        (dev, ino, mode, uid, gid, size, sha, flags) = \
-            unpack(">LLLLLL20sH", read(20 + 4 * 6 + 2))
+        (dev, ino, mode, uid, gid, size, sha, flags) = unpack(">LLLLLL20sH", read(20 + 4 * 6 + 2))
         path_size = flags & CE_NAMEMASK
         path = read(path_size).decode(defenc)
 
-        real_size = ((tell() - beginoffset + 8) & ~7)
+        real_size = (tell() - beginoffset + 8) & ~7
         read((beginoffset + real_size) - tell())
         entry = IndexEntry((mode, sha, flags, path, ctime, mtime, dev, ino, uid, gid, size))
-        # entry_key would be the method to use, but we safe the effort
+        # entry_key would be the method to use, but we save the effort.
         entries[(path, entry.stage)] = entry
         count += 1
     # END for each entry
 
-    # the footer contains extension data and a sha on the content so far
-    # Keep the extension footer,and verify we have a sha in the end
+    # The footer contains extension data and a sha on the content so far.
+    # Keep the extension footer,and verify we have a sha in the end.
     # Extension data format is:
-    # 4 bytes ID
-    # 4 bytes length of chunk
-    # repeated 0 - N times
+    #   4 bytes ID
+    #   4 bytes length of chunk
+    #   Repeated 0 - N times
     extension_data = stream.read(~0)
-    assert len(extension_data) > 19, "Index Footer was not at least a sha on content as it was only %i bytes in size"\
-                                     % len(extension_data)
+    assert len(extension_data) > 19, (
+        "Index Footer was not at least a sha on content as it was only %i bytes in size" % len(extension_data)
+    )
 
     content_sha = extension_data[-20:]
 
-    # truncate the sha in the end as we will dynamically create it anyway
+    # Truncate the sha in the end as we will dynamically create it anyway.
     extension_data = extension_data[:-20]
 
     return (version, entries, extension_data, content_sha)
 
 
-def write_tree_from_cache(entries, odb, sl, si=0):
-    """Create a tree from the given sorted list of entries and put the respective
-    trees into the given object database
+def write_tree_from_cache(
+    entries: List[IndexEntry], odb: "GitCmdObjectDB", sl: slice, si: int = 0
+) -> Tuple[bytes, List["TreeCacheTup"]]:
+    R"""Create a tree from the given sorted list of entries and put the respective
+    trees into the given object database.
+
+    :param entries:
+        **Sorted** list of :class:`~git.index.typ.IndexEntry`\s.
+
+    :param odb:
+        Object database to store the trees in.
+
+    :param si:
+        Start index at which we should start creating subtrees.
+
+    :param sl:
+        Slice indicating the range we should process on the entries list.
+
+    :return:
+        tuple(binsha, list(tree_entry, ...))
+
+        A tuple of a sha and a list of tree entries being a tuple of hexsha, mode, name.
+    """
+    tree_items: List["TreeCacheTup"] = []
 
-    :param entries: **sorted** list of IndexEntries
-    :param odb: object database to store the trees in
-    :param si: start index at which we should start creating subtrees
-    :param sl: slice indicating the range we should process on the entries list
-    :return: tuple(binsha, list(tree_entry, ...)) a tuple of a sha and a list of
-        tree entries being a tuple of hexsha, mode, name"""
-    tree_items = list()
-    tree_items_append = tree_items.append
     ci = sl.start
     end = sl.stop
     while ci < end:
@@ -231,63 +323,66 @@ def write_tree_from_cache(entries, odb, sl, si=0):
             raise UnmergedEntriesError(entry)
         # END abort on unmerged
         ci += 1
-        rbound = entry.path.find('/', si)
+        rbound = entry.path.find("/", si)
         if rbound == -1:
-            # its not a tree
-            tree_items_append((entry.binsha, entry.mode, entry.path[si:]))
+            # It's not a tree.
+            tree_items.append((entry.binsha, entry.mode, entry.path[si:]))
         else:
-            # find common base range
+            # Find common base range.
             base = entry.path[si:rbound]
             xi = ci
             while xi < end:
                 oentry = entries[xi]
-                orbound = oentry.path.find('/', si)
+                orbound = oentry.path.find("/", si)
                 if orbound == -1 or oentry.path[si:orbound] != base:
                     break
                 # END abort on base mismatch
                 xi += 1
             # END find common base
 
-            # enter recursion
-            # ci - 1 as we want to count our current item as well
-            sha, tree_entry_list = write_tree_from_cache(entries, odb, slice(ci - 1, xi), rbound + 1)
-            tree_items_append((sha, S_IFDIR, base))
+            # Enter recursion.
+            # ci - 1 as we want to count our current item as well.
+            sha, _tree_entry_list = write_tree_from_cache(entries, odb, slice(ci - 1, xi), rbound + 1)
+            tree_items.append((sha, S_IFDIR, base))
 
-            # skip ahead
+            # Skip ahead.
             ci = xi
         # END handle bounds
     # END for each entry
 
-    # finally create the tree
+    # Finally create the tree.
     sio = BytesIO()
-    tree_to_stream(tree_items, sio.write)
+    tree_to_stream(tree_items, sio.write)  # Writes to stream as bytes, but doesn't change tree_items.
     sio.seek(0)
 
     istream = odb.store(IStream(str_tree_type, len(sio.getvalue()), sio))
     return (istream.binsha, tree_items)
 
 
-def _tree_entry_to_baseindexentry(tree_entry, stage):
+def _tree_entry_to_baseindexentry(tree_entry: "TreeCacheTup", stage: int) -> BaseIndexEntry:
     return BaseIndexEntry((tree_entry[1], tree_entry[0], stage << CE_STAGESHIFT, tree_entry[2]))
 
 
-def aggressive_tree_merge(odb, tree_shas):
+def aggressive_tree_merge(odb: "GitCmdObjectDB", tree_shas: Sequence[bytes]) -> List[BaseIndexEntry]:
+    R"""
+    :return:
+        List of :class:`~git.index.typ.BaseIndexEntry`\s representing the aggressive
+        merge of the given trees. All valid entries are on stage 0, whereas the
+        conflicting ones are left on stage 1, 2 or 3, whereas stage 1 corresponds to the
+        common ancestor tree, 2 to our tree and 3 to 'their' tree.
+
+    :param tree_shas:
+        1, 2 or 3 trees as identified by their binary 20 byte shas. If 1 or two, the
+        entries will effectively correspond to the last given tree. If 3 are given, a 3
+        way merge is performed.
     """
-    :return: list of BaseIndexEntries representing the aggressive merge of the given
-        trees. All valid entries are on stage 0, whereas the conflicting ones are left
-        on stage 1, 2 or 3, whereas stage 1 corresponds to the common ancestor tree,
-        2 to our tree and 3 to 'their' tree.
-    :param tree_shas: 1, 2 or 3 trees as identified by their binary 20 byte shas
-        If 1 or two, the entries will effectively correspond to the last given tree
-        If 3 are given, a 3 way merge is performed"""
-    out = list()
-    out_append = out.append
-
-    # one and two way is the same for us, as we don't have to handle an existing
+    out: List[BaseIndexEntry] = []
+
+    # One and two way is the same for us, as we don't have to handle an existing
     # index, instrea
     if len(tree_shas) in (1, 2):
-        for entry in traverse_tree_recursive(odb, tree_shas[-1], ''):
-            out_append(_tree_entry_to_baseindexentry(entry, 0))
+        for entry in traverse_tree_recursive(odb, tree_shas[-1], ""):
+            out.append(_tree_entry_to_baseindexentry(entry, 0))
         # END for each entry
         return out
     # END handle single tree
@@ -295,72 +390,73 @@ def aggressive_tree_merge(odb, tree_shas):
     if len(tree_shas) > 3:
         raise ValueError("Cannot handle %i trees at once" % len(tree_shas))
 
-    # three trees
-    for base, ours, theirs in traverse_trees_recursive(odb, tree_shas, ''):
+    # Three trees.
+    for base, ours, theirs in traverse_trees_recursive(odb, tree_shas, ""):
         if base is not None:
-            # base version exists
+            # Base version exists.
             if ours is not None:
-                # ours exists
+                # Ours exists.
                 if theirs is not None:
-                    # it exists in all branches, if it was changed in both
-                    # its a conflict, otherwise we take the changed version
-                    # This should be the most common branch, so it comes first
-                    if(base[0] != ours[0] and base[0] != theirs[0] and ours[0] != theirs[0]) or \
-                            (base[1] != ours[1] and base[1] != theirs[1] and ours[1] != theirs[1]):
-                        # changed by both
-                        out_append(_tree_entry_to_baseindexentry(base, 1))
-                        out_append(_tree_entry_to_baseindexentry(ours, 2))
-                        out_append(_tree_entry_to_baseindexentry(theirs, 3))
+                    # It exists in all branches. Ff it was changed in both
+                    # its a conflict. Otherwise, we take the changed version.
+                    # This should be the most common branch, so it comes first.
+                    if (base[0] != ours[0] and base[0] != theirs[0] and ours[0] != theirs[0]) or (
+                        base[1] != ours[1] and base[1] != theirs[1] and ours[1] != theirs[1]
+                    ):
+                        # Changed by both.
+                        out.append(_tree_entry_to_baseindexentry(base, 1))
+                        out.append(_tree_entry_to_baseindexentry(ours, 2))
+                        out.append(_tree_entry_to_baseindexentry(theirs, 3))
                     elif base[0] != ours[0] or base[1] != ours[1]:
-                        # only we changed it
-                        out_append(_tree_entry_to_baseindexentry(ours, 0))
+                        # Only we changed it.
+                        out.append(_tree_entry_to_baseindexentry(ours, 0))
                     else:
-                        # either nobody changed it, or they did. In either
-                        # case, use theirs
-                        out_append(_tree_entry_to_baseindexentry(theirs, 0))
+                        # Either nobody changed it, or they did. In either
+                        # case, use theirs.
+                        out.append(_tree_entry_to_baseindexentry(theirs, 0))
                     # END handle modification
                 else:
-
                     if ours[0] != base[0] or ours[1] != base[1]:
-                        # they deleted it, we changed it, conflict
-                        out_append(_tree_entry_to_baseindexentry(base, 1))
-                        out_append(_tree_entry_to_baseindexentry(ours, 2))
+                        # They deleted it, we changed it, conflict.
+                        out.append(_tree_entry_to_baseindexentry(base, 1))
+                        out.append(_tree_entry_to_baseindexentry(ours, 2))
                     # else:
-                    #   we didn't change it, ignore
+                    #   # We didn't change it, ignore.
                     #   pass
                     # END handle our change
                 # END handle theirs
             else:
                 if theirs is None:
-                    # deleted in both, its fine - its out
+                    # Deleted in both, its fine - it's out.
                     pass
                 else:
                     if theirs[0] != base[0] or theirs[1] != base[1]:
-                        # deleted in ours, changed theirs, conflict
-                        out_append(_tree_entry_to_baseindexentry(base, 1))
-                        out_append(_tree_entry_to_baseindexentry(theirs, 3))
+                        # Deleted in ours, changed theirs, conflict.
+                        out.append(_tree_entry_to_baseindexentry(base, 1))
+                        out.append(_tree_entry_to_baseindexentry(theirs, 3))
                     # END theirs changed
                     # else:
-                    #   theirs didnt change
+                    #   # Theirs didn't change.
                     #   pass
                 # END handle theirs
             # END handle ours
         else:
-            # all three can't be None
+            # All three can't be None.
             if ours is None:
-                # added in their branch
-                out_append(_tree_entry_to_baseindexentry(theirs, 0))
+                # Added in their branch.
+                assert theirs is not None
+                out.append(_tree_entry_to_baseindexentry(theirs, 0))
             elif theirs is None:
-                # added in our branch
-                out_append(_tree_entry_to_baseindexentry(ours, 0))
+                # Added in our branch.
+                out.append(_tree_entry_to_baseindexentry(ours, 0))
             else:
-                # both have it, except for the base, see whether it changed
+                # Both have it, except for the base, see whether it changed.
                 if ours[0] != theirs[0] or ours[1] != theirs[1]:
-                    out_append(_tree_entry_to_baseindexentry(ours, 2))
-                    out_append(_tree_entry_to_baseindexentry(theirs, 3))
+                    out.append(_tree_entry_to_baseindexentry(ours, 2))
+                    out.append(_tree_entry_to_baseindexentry(theirs, 3))
                 else:
-                    # it was added the same in both
-                    out_append(_tree_entry_to_baseindexentry(ours, 0))
+                    # It was added the same in both.
+                    out.append(_tree_entry_to_baseindexentry(ours, 0))
                 # END handle two items
             # END handle heads
         # END handle base exists
diff --git a/git/index/typ.py b/git/index/typ.py
index 0998ecb07..974252528 100644
--- a/git/index/typ.py
+++ b/git/index/typ.py
@@ -1,175 +1,202 @@
-"""Module with additional types used by the index"""
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Additional types used by the index."""
+
+__all__ = ["BlobFilter", "BaseIndexEntry", "IndexEntry", "StageType"]
 
 from binascii import b2a_hex
+from pathlib import Path
 
-from .util import (
-    pack,
-    unpack
-)
 from git.objects import Blob
 
+from .util import pack, unpack
+
+# typing ----------------------------------------------------------------------
+
+from typing import NamedTuple, Sequence, TYPE_CHECKING, Tuple, Union, cast
+
+from git.types import PathLike
 
-__all__ = ('BlobFilter', 'BaseIndexEntry', 'IndexEntry')
+if TYPE_CHECKING:
+    from git.repo import Repo
 
-#{ Invariants
-CE_NAMEMASK = 0x0fff
+StageType = int
+
+# ---------------------------------------------------------------------------------
+
+# { Invariants
+CE_NAMEMASK = 0x0FFF
 CE_STAGEMASK = 0x3000
 CE_EXTENDED = 0x4000
 CE_VALID = 0x8000
 CE_STAGESHIFT = 12
 
-#} END invariants
+# } END invariants
 
 
-class BlobFilter(object):
-
-    """
-    Predicate to be used by iter_blobs allowing to filter only return blobs which
-    match the given list of directories or files.
+class BlobFilter:
+    """Predicate to be used by
+    :meth:`IndexFile.iter_blobs <git.index.base.IndexFile.iter_blobs>` allowing to
+    filter only return blobs which match the given list of directories or files.
 
     The given paths are given relative to the repository.
     """
-    __slots__ = 'paths'
 
-    def __init__(self, paths):
-        """:param paths:
-            tuple or list of paths which are either pointing to directories or
-            to files relative to the current repository
+    __slots__ = ("paths",)
+
+    def __init__(self, paths: Sequence[PathLike]) -> None:
+        """
+        :param paths:
+            Tuple or list of paths which are either pointing to directories or to files
+            relative to the current repository.
         """
         self.paths = paths
 
-    def __call__(self, stage_blob):
-        path = stage_blob[1].path
-        for p in self.paths:
-            if path.startswith(p):
+    def __call__(self, stage_blob: Tuple[StageType, Blob]) -> bool:
+        blob_pathlike: PathLike = stage_blob[1].path
+        blob_path: Path = blob_pathlike if isinstance(blob_pathlike, Path) else Path(blob_pathlike)
+        for pathlike in self.paths:
+            path: Path = pathlike if isinstance(pathlike, Path) else Path(pathlike)
+            # TODO: Change to use `PosixPath.is_relative_to` once Python 3.8 is no
+            # longer supported.
+            filter_parts = path.parts
+            blob_parts = blob_path.parts
+            if len(filter_parts) > len(blob_parts):
+                continue
+            if all(i == j for i, j in zip(filter_parts, blob_parts)):
                 return True
-        # END for each path in filter paths
         return False
 
 
-class BaseIndexEntry(tuple):
+class BaseIndexEntryHelper(NamedTuple):
+    """Typed named tuple to provide named attribute access for :class:`BaseIndexEntry`.
 
-    """Small Brother of an index entry which can be created to describe changes
-    done to the index in which case plenty of additional information is not requried.
+    This is needed to allow overriding ``__new__`` in child class to preserve backwards
+    compatibility.
+    """
 
-    As the first 4 data members match exactly to the IndexEntry type, methods
-    expecting a BaseIndexEntry can also handle full IndexEntries even if they
-    use numeric indices for performance reasons. """
+    mode: int
+    binsha: bytes
+    flags: int
+    path: PathLike
+    ctime_bytes: bytes = pack(">LL", 0, 0)
+    mtime_bytes: bytes = pack(">LL", 0, 0)
+    dev: int = 0
+    inode: int = 0
+    uid: int = 0
+    gid: int = 0
+    size: int = 0
+
+
+class BaseIndexEntry(BaseIndexEntryHelper):
+    R"""Small brother of an index entry which can be created to describe changes
+    done to the index in which case plenty of additional information is not required.
+
+    As the first 4 data members match exactly to the :class:`IndexEntry` type, methods
+    expecting a :class:`BaseIndexEntry` can also handle full :class:`IndexEntry`\s even
+    if they use numeric indices for performance reasons.
+    """
 
-    def __str__(self):
+    def __new__(
+        cls,
+        inp_tuple: Union[
+            Tuple[int, bytes, int, PathLike],
+            Tuple[int, bytes, int, PathLike, bytes, bytes, int, int, int, int, int],
+        ],
+    ) -> "BaseIndexEntry":
+        """Override ``__new__`` to allow construction from a tuple for backwards
+        compatibility."""
+        return super().__new__(cls, *inp_tuple)
+
+    def __str__(self) -> str:
         return "%o %s %i\t%s" % (self.mode, self.hexsha, self.stage, self.path)
 
-    def __repr__(self):
+    def __repr__(self) -> str:
         return "(%o, %s, %i, %s)" % (self.mode, self.hexsha, self.stage, self.path)
 
     @property
-    def mode(self):
-        """ File Mode, compatible to stat module constants """
-        return self[0]
-
-    @property
-    def binsha(self):
-        """binary sha of the blob """
-        return self[1]
-
-    @property
-    def hexsha(self):
+    def hexsha(self) -> str:
         """hex version of our sha"""
-        return b2a_hex(self[1]).decode('ascii')
+        return b2a_hex(self.binsha).decode("ascii")
 
     @property
-    def stage(self):
+    def stage(self) -> int:
         """Stage of the entry, either:
 
             * 0 = default stage
             * 1 = stage before a merge or common ancestor entry in case of a 3 way merge
             * 2 = stage of entries from the 'left' side of the merge
-            * 3 = stage of entries from the right side of the merge
+            * 3 = stage of entries from the 'right' side of the merge
 
-        :note: For more information, see http://www.kernel.org/pub/software/scm/git/docs/git-read-tree.html
+        :note:
+            For more information, see :manpage:`git-read-tree(1)`.
         """
-        return (self[2] & CE_STAGEMASK) >> CE_STAGESHIFT
-
-    @property
-    def path(self):
-        """:return: our path relative to the repository working tree root"""
-        return self[3]
-
-    @property
-    def flags(self):
-        """:return: flags stored with this entry"""
-        return self[2]
+        return (self.flags & CE_STAGEMASK) >> CE_STAGESHIFT
 
     @classmethod
-    def from_blob(cls, blob, stage=0):
+    def from_blob(cls, blob: Blob, stage: int = 0) -> "BaseIndexEntry":
         """:return: Fully equipped BaseIndexEntry at the given stage"""
         return cls((blob.mode, blob.binsha, stage << CE_STAGESHIFT, blob.path))
 
-    def to_blob(self, repo):
+    def to_blob(self, repo: "Repo") -> Blob:
         """:return: Blob using the information of this index entry"""
         return Blob(repo, self.binsha, self.mode, self.path)
 
 
 class IndexEntry(BaseIndexEntry):
+    """Allows convenient access to index entry data as defined in
+    :class:`BaseIndexEntry` without completely unpacking it.
 
-    """Allows convenient access to IndexEntry data without completely unpacking it.
-
-    Attributes usully accessed often are cached in the tuple whereas others are
+    Attributes usually accessed often are cached in the tuple whereas others are
     unpacked on demand.
 
-    See the properties for a mapping between names and tuple indices. """
+    See the properties for a mapping between names and tuple indices.
+    """
+
     @property
-    def ctime(self):
+    def ctime(self) -> Tuple[int, int]:
         """
         :return:
             Tuple(int_time_seconds_since_epoch, int_nano_seconds) of the
-            file's creation time"""
-        return unpack(">LL", self[4])
-
-    @property
-    def mtime(self):
-        """See ctime property, but returns modification time """
-        return unpack(">LL", self[5])
-
-    @property
-    def dev(self):
-        """ Device ID """
-        return self[6]
-
-    @property
-    def inode(self):
-        """ Inode ID """
-        return self[7]
-
-    @property
-    def uid(self):
-        """ User ID """
-        return self[8]
-
-    @property
-    def gid(self):
-        """ Group ID """
-        return self[9]
+            file's creation time
+        """
+        return cast(Tuple[int, int], unpack(">LL", self.ctime_bytes))
 
     @property
-    def size(self):
-        """:return: Uncompressed size of the blob """
-        return self[10]
+    def mtime(self) -> Tuple[int, int]:
+        """See :attr:`ctime` property, but returns modification time."""
+        return cast(Tuple[int, int], unpack(">LL", self.mtime_bytes))
 
     @classmethod
-    def from_base(cls, base):
+    def from_base(cls, base: "BaseIndexEntry") -> "IndexEntry":
         """
         :return:
-            Minimal entry as created from the given BaseIndexEntry instance.
-            Missing values will be set to null-like values
+            Minimal entry as created from the given :class:`BaseIndexEntry` instance.
+            Missing values will be set to null-like values.
 
-        :param base: Instance of type BaseIndexEntry"""
+        :param base:
+            Instance of type :class:`BaseIndexEntry`.
+        """
         time = pack(">LL", 0, 0)
         return IndexEntry((base.mode, base.binsha, base.flags, base.path, time, time, 0, 0, 0, 0, 0))
 
     @classmethod
-    def from_blob(cls, blob, stage=0):
+    def from_blob(cls, blob: Blob, stage: int = 0) -> "IndexEntry":
         """:return: Minimal entry resembling the given blob object"""
         time = pack(">LL", 0, 0)
-        return IndexEntry((blob.mode, blob.binsha, stage << CE_STAGESHIFT, blob.path,
-                           time, time, 0, 0, 0, 0, blob.size))
+        return IndexEntry(
+            (
+                blob.mode,
+                blob.binsha,
+                stage << CE_STAGESHIFT,
+                blob.path,
+                time,
+                time,
+                0,
+                0,
+                0,
+                0,
+                blob.size,
+            )
+        )
diff --git a/git/index/util.py b/git/index/util.py
index 171bd8fcf..e59cb609f 100644
--- a/git/index/util.py
+++ b/git/index/util.py
@@ -1,93 +1,121 @@
-"""Module containing index utilities"""
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Index utilities."""
+
+__all__ = ["TemporaryFileSwap", "post_clear_cache", "default_index", "git_working_dir"]
+
+import contextlib
+from functools import wraps
+import os
+import os.path as osp
 import struct
 import tempfile
-import os
+from types import TracebackType
 
-__all__ = ('TemporaryFileSwap', 'post_clear_cache', 'default_index', 'git_working_dir')
+# typing ----------------------------------------------------------------------
 
-#{ Aliases
+from typing import Any, Callable, TYPE_CHECKING, Optional, Type
+
+from git.types import Literal, PathLike, _T
+
+if TYPE_CHECKING:
+    from git.index import IndexFile
+
+# ---------------------------------------------------------------------------------
+
+# { Aliases
 pack = struct.pack
 unpack = struct.unpack
+# } END aliases
 
 
-#} END aliases
-
-class TemporaryFileSwap(object):
+class TemporaryFileSwap:
+    """Utility class moving a file to a temporary location within the same directory and
+    moving it back on to where on object deletion."""
 
-    """Utility class moving a file to a temporary location within the same directory
-    and moving it back on to where on object deletion."""
     __slots__ = ("file_path", "tmp_file_path")
 
-    def __init__(self, file_path):
+    def __init__(self, file_path: PathLike) -> None:
         self.file_path = file_path
-        self.tmp_file_path = self.file_path + tempfile.mktemp('', '', '')
-        # it may be that the source does not exist
-        try:
-            os.rename(self.file_path, self.tmp_file_path)
-        except OSError:
-            pass
+        dirname, basename = osp.split(file_path)
+        fd, self.tmp_file_path = tempfile.mkstemp(prefix=basename, dir=dirname)
+        os.close(fd)
+        with contextlib.suppress(OSError):  # It may be that the source does not exist.
+            os.replace(self.file_path, self.tmp_file_path)
+
+    def __enter__(self) -> "TemporaryFileSwap":
+        return self
+
+    def __exit__(
+        self,
+        exc_type: Optional[Type[BaseException]],
+        exc_val: Optional[BaseException],
+        exc_tb: Optional[TracebackType],
+    ) -> Literal[False]:
+        if osp.isfile(self.tmp_file_path):
+            os.replace(self.tmp_file_path, self.file_path)
+        return False
 
-    def __del__(self):
-        if os.path.isfile(self.tmp_file_path):
-            if os.name == 'nt' and os.path.exists(self.file_path):
-                os.remove(self.file_path)
-            os.rename(self.tmp_file_path, self.file_path)
-        # END temp file exists
 
+# { Decorators
 
-#{ Decorators
 
-def post_clear_cache(func):
-    """Decorator for functions that alter the index using the git command. This would
-    invalidate our possibly existing entries dictionary which is why it must be
-    deleted to allow it to be lazily reread later.
+def post_clear_cache(func: Callable[..., _T]) -> Callable[..., _T]:
+    """Decorator for functions that alter the index using the git command.
 
-    :note:
-        This decorator will not be required once all functions are implemented
-        natively which in fact is possible, but probably not feasible performance wise.
+    When a git command alters the index, this invalidates our possibly existing entries
+    dictionary, which is why it must be deleted to allow it to be lazily reread later.
     """
 
-    def post_clear_cache_if_not_raised(self, *args, **kwargs):
+    @wraps(func)
+    def post_clear_cache_if_not_raised(self: "IndexFile", *args: Any, **kwargs: Any) -> _T:
         rval = func(self, *args, **kwargs)
         self._delete_entries_cache()
         return rval
 
     # END wrapper method
-    post_clear_cache_if_not_raised.__name__ = func.__name__
+
     return post_clear_cache_if_not_raised
 
 
-def default_index(func):
-    """Decorator assuring the wrapped method may only run if we are the default
-    repository index. This is as we rely on git commands that operate
-    on that index only. """
+def default_index(func: Callable[..., _T]) -> Callable[..., _T]:
+    """Decorator ensuring the wrapped method may only run if we are the default
+    repository index.
+
+    This is as we rely on git commands that operate on that index only.
+    """
 
-    def check_default_index(self, *args, **kwargs):
+    @wraps(func)
+    def check_default_index(self: "IndexFile", *args: Any, **kwargs: Any) -> _T:
         if self._file_path != self._index_path():
             raise AssertionError(
-                "Cannot call %r on indices that do not represent the default git index" % func.__name__)
+                "Cannot call %r on indices that do not represent the default git index" % func.__name__
+            )
         return func(self, *args, **kwargs)
-    # END wrpaper method
 
-    check_default_index.__name__ = func.__name__
+    # END wrapper method
+
     return check_default_index
 
 
-def git_working_dir(func):
+def git_working_dir(func: Callable[..., _T]) -> Callable[..., _T]:
     """Decorator which changes the current working dir to the one of the git
-    repository in order to assure relative paths are handled correctly"""
+    repository in order to ensure relative paths are handled correctly."""
 
-    def set_git_working_dir(self, *args, **kwargs):
+    @wraps(func)
+    def set_git_working_dir(self: "IndexFile", *args: Any, **kwargs: Any) -> _T:
         cur_wd = os.getcwd()
-        os.chdir(self.repo.working_tree_dir)
+        os.chdir(str(self.repo.working_tree_dir))
         try:
             return func(self, *args, **kwargs)
         finally:
             os.chdir(cur_wd)
         # END handle working dir
+
     # END wrapper
 
-    set_git_working_dir.__name__ = func.__name__
     return set_git_working_dir
 
-#} END decorators
+
+# } END decorators
diff --git a/git/objects/__init__.py b/git/objects/__init__.py
index ee6428761..4447ca50d 100644
--- a/git/objects/__init__.py
+++ b/git/objects/__init__.py
@@ -1,24 +1,25 @@
-"""
-Import all submodules main classes into the package space
-"""
-# flake8: noqa
-from __future__ import absolute_import
-import inspect
-from .base import *
-# Fix import dependency - add IndexObject to the util module, so that it can be
-# imported by the submodule.base
-from .submodule import util as smutil
-smutil.IndexObject = IndexObject
-smutil.Object = Object
-del(smutil)
-from .submodule.base import *
-from .submodule.root import *
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-# must come after submodule was made available
-from .tag import *
-from .blob import *
-from .commit import *
-from .tree import *
+"""Import all submodules' main classes into the package space."""
 
-__all__ = [name for name, obj in locals().items()
-           if not (name.startswith('_') or inspect.ismodule(obj))]
+__all__ = [
+    "IndexObject",
+    "Object",
+    "Blob",
+    "Commit",
+    "Submodule",
+    "UpdateProgress",
+    "RootModule",
+    "RootUpdateProgress",
+    "TagObject",
+    "Tree",
+    "TreeModifier",
+]
+
+from .base import IndexObject, Object
+from .blob import Blob
+from .commit import Commit
+from .submodule import RootModule, RootUpdateProgress, Submodule, UpdateProgress
+from .tag import TagObject
+from .tree import Tree, TreeModifier
diff --git a/git/objects/base.py b/git/objects/base.py
index eb59b0a91..faf600c6b 100644
--- a/git/objects/base.py
+++ b/git/objects/base.py
@@ -1,180 +1,301 @@
-# base.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-from .util import get_object_type_by_name
-from git.util import LazyMixin, join_path_native, stream_copy
-from gitdb.util import (
-    bin_to_hex,
-    basename
-)
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["Object", "IndexObject"]
+
+import os.path as osp
 
 import gitdb.typ as dbtyp
 
-_assertion_msg_format = "Created object %r whose python type %r disagrees with the acutal git object type %r"
+from git.exc import WorkTreeRepositoryUnsupported
+from git.util import LazyMixin, bin_to_hex, join_path_native, stream_copy
+
+from .util import get_object_type_by_name
+
+# typing ------------------------------------------------------------------
+
+from typing import Any, TYPE_CHECKING, Union
 
-__all__ = ("Object", "IndexObject")
+from git.types import AnyGitObject, GitObjectTypeString, PathLike
+
+if TYPE_CHECKING:
+    from gitdb.base import OStream
+
+    from git.refs.reference import Reference
+    from git.repo import Repo
+
+    from .blob import Blob
+    from .submodule.base import Submodule
+    from .tree import Tree
+
+IndexObjUnion = Union["Tree", "Blob", "Submodule"]
+
+# --------------------------------------------------------------------------
 
 
 class Object(LazyMixin):
+    """Base class for classes representing git object types.
+
+    The following four leaf classes represent specific kinds of git objects:
+
+    * :class:`Blob <git.objects.blob.Blob>`
+    * :class:`Tree <git.objects.tree.Tree>`
+    * :class:`Commit <git.objects.commit.Commit>`
+    * :class:`TagObject <git.objects.tag.TagObject>`
 
-    """Implements an Object which may be Blobs, Trees, Commits and Tags"""
-    NULL_HEX_SHA = '0' * 40
-    NULL_BIN_SHA = b'\0' * 20
+    See :manpage:`gitglossary(7)` on:
+
+    * "object": https://git-scm.com/docs/gitglossary#def_object
+    * "object type": https://git-scm.com/docs/gitglossary#def_object_type
+    * "blob": https://git-scm.com/docs/gitglossary#def_blob_object
+    * "tree object": https://git-scm.com/docs/gitglossary#def_tree_object
+    * "commit object": https://git-scm.com/docs/gitglossary#def_commit_object
+    * "tag object": https://git-scm.com/docs/gitglossary#def_tag_object
+
+    :note:
+        See the :class:`~git.types.AnyGitObject` union type of the four leaf subclasses
+        that represent actual git object types.
+
+    :note:
+        :class:`~git.objects.submodule.base.Submodule` is defined under the hierarchy
+        rooted at this :class:`Object` class, even though submodules are not really a
+        type of git object. (This also applies to its
+        :class:`~git.objects.submodule.root.RootModule` subclass.)
+
+    :note:
+        This :class:`Object` class should not be confused with :class:`object` (the root
+        of the class hierarchy in Python).
+    """
+
+    NULL_HEX_SHA = "0" * 40
+    NULL_BIN_SHA = b"\0" * 20
+
+    TYPES = (
+        dbtyp.str_blob_type,
+        dbtyp.str_tree_type,
+        dbtyp.str_commit_type,
+        dbtyp.str_tag_type,
+    )
 
-    TYPES = (dbtyp.str_blob_type, dbtyp.str_tree_type, dbtyp.str_commit_type, dbtyp.str_tag_type)
     __slots__ = ("repo", "binsha", "size")
-    type = None         # to be set by subclass
 
-    def __init__(self, repo, binsha):
+    type: Union[GitObjectTypeString, None] = None
+    """String identifying (a concrete :class:`Object` subtype for) a git object type.
+
+    The subtypes that this may name correspond to the kinds of git objects that exist,
+    i.e., the objects that may be present in a git repository.
+
+    :note:
+        Most subclasses represent specific types of git objects and override this class
+        attribute accordingly. This attribute is ``None`` in the :class:`Object` base
+        class, as well as the :class:`IndexObject` intermediate subclass, but never
+        ``None`` in concrete leaf subclasses representing specific git object types.
+
+    :note:
+        See also :class:`~git.types.GitObjectTypeString`.
+    """
+
+    def __init__(self, repo: "Repo", binsha: bytes) -> None:
         """Initialize an object by identifying it by its binary sha.
-        All keyword arguments will be set on demand if None.
 
-        :param repo: repository this object is located in
+        All keyword arguments will be set on demand if ``None``.
 
-        :param binsha: 20 byte SHA1"""
-        super(Object, self).__init__()
+        :param repo:
+            Repository this object is located in.
+
+        :param binsha:
+            20 byte SHA1
+        """
+        super().__init__()
         self.repo = repo
         self.binsha = binsha
-        assert len(binsha) == 20, "Require 20 byte binary sha, got %r, len = %i" % (binsha, len(binsha))
+        assert len(binsha) == 20, "Require 20 byte binary sha, got %r, len = %i" % (
+            binsha,
+            len(binsha),
+        )
 
     @classmethod
-    def new(cls, repo, id):
+    def new(cls, repo: "Repo", id: Union[str, "Reference"]) -> AnyGitObject:
         """
-        :return: New Object instance of a type appropriate to the object type behind
-            id. The id of the newly created object will be a binsha even though
-            the input id may have been a Reference or Rev-Spec
+        :return:
+            New :class:`Object` instance of a type appropriate to the object type behind
+            `id`. The id of the newly created object will be a binsha even though the
+            input id may have been a :class:`~git.refs.reference.Reference` or rev-spec.
 
-        :param id: reference, rev-spec, or hexsha
+        :param id:
+            :class:`~git.refs.reference.Reference`, rev-spec, or hexsha.
 
-        :note: This cannot be a __new__ method as it would always call __init__
-            with the input id which is not necessarily a binsha."""
+        :note:
+            This cannot be a ``__new__`` method as it would always call :meth:`__init__`
+            with the input id which is not necessarily a binsha.
+        """
         return repo.rev_parse(str(id))
 
     @classmethod
-    def new_from_sha(cls, repo, sha1):
+    def new_from_sha(cls, repo: "Repo", sha1: bytes) -> AnyGitObject:
+        """
+        :return:
+            New object instance of a type appropriate to represent the given binary sha1
+
+        :param sha1:
+            20 byte binary sha1.
         """
-        :return: new object instance of a type appropriate to represent the given
-            binary sha1
-        :param sha1: 20 byte binary sha1"""
         if sha1 == cls.NULL_BIN_SHA:
-            # the NULL binsha is always the root commit
-            return get_object_type_by_name(b'commit')(repo, sha1)
+            # The NULL binsha is always the root commit.
+            return get_object_type_by_name(b"commit")(repo, sha1)
         # END handle special case
         oinfo = repo.odb.info(sha1)
         inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha)
         inst.size = oinfo.size
         return inst
 
-    def _set_cache_(self, attr):
-        """Retrieve object information"""
+    def _set_cache_(self, attr: str) -> None:
+        """Retrieve object information."""
         if attr == "size":
             oinfo = self.repo.odb.info(self.binsha)
-            self.size = oinfo.size
-            # assert oinfo.type == self.type, _assertion_msg_format % (self.binsha, oinfo.type, self.type)
+            self.size = oinfo.size  # type: int
         else:
-            super(Object, self)._set_cache_(attr)
+            super()._set_cache_(attr)
 
-    def __eq__(self, other):
-        """:return: True if the objects have the same SHA1"""
-        if not hasattr(other, 'binsha'):
+    def __eq__(self, other: Any) -> bool:
+        """:return: ``True`` if the objects have the same SHA1"""
+        if not hasattr(other, "binsha"):
             return False
         return self.binsha == other.binsha
 
-    def __ne__(self, other):
-        """:return: True if the objects do not have the same SHA1 """
-        if not hasattr(other, 'binsha'):
+    def __ne__(self, other: Any) -> bool:
+        """:return: ``True`` if the objects do not have the same SHA1"""
+        if not hasattr(other, "binsha"):
             return True
         return self.binsha != other.binsha
 
-    def __hash__(self):
+    def __hash__(self) -> int:
         """:return: Hash of our id allowing objects to be used in dicts and sets"""
         return hash(self.binsha)
 
-    def __str__(self):
-        """:return: string of our SHA1 as understood by all git commands"""
+    def __str__(self) -> str:
+        """:return: String of our SHA1 as understood by all git commands"""
         return self.hexsha
 
-    def __repr__(self):
-        """:return: string with pythonic representation of our object"""
+    def __repr__(self) -> str:
+        """:return: String with pythonic representation of our object"""
         return '<git.%s "%s">' % (self.__class__.__name__, self.hexsha)
 
     @property
-    def hexsha(self):
+    def hexsha(self) -> str:
         """:return: 40 byte hex version of our 20 byte binary sha"""
-        # b2a_hex produces bytes
-        return bin_to_hex(self.binsha).decode('ascii')
+        # b2a_hex produces bytes.
+        return bin_to_hex(self.binsha).decode("ascii")
 
     @property
-    def data_stream(self):
-        """ :return:  File Object compatible stream to the uncompressed raw data of the object
-        :note: returned streams must be read in order"""
+    def data_stream(self) -> "OStream":
+        """
+        :return:
+            File-object compatible stream to the uncompressed raw data of the object
+
+        :note:
+            Returned streams must be read in order.
+        """
         return self.repo.odb.stream(self.binsha)
 
-    def stream_data(self, ostream):
-        """Writes our data directly to the given output stream
-        :param ostream: File object compatible stream object.
-        :return: self"""
+    def stream_data(self, ostream: "OStream") -> "Object":
+        """Write our data directly to the given output stream.
+
+        :param ostream:
+            File-object compatible stream object.
+
+        :return:
+            self
+        """
         istream = self.repo.odb.stream(self.binsha)
         stream_copy(istream, ostream)
         return self
 
 
 class IndexObject(Object):
+    """Base for all objects that can be part of the index file.
+
+    The classes representing git object types that can be part of the index file are
+    :class:`~git.objects.tree.Tree` and :class:`~git.objects.blob.Blob`. In addition,
+    :class:`~git.objects.submodule.base.Submodule`, which is not really a git object
+    type but can be part of an index file, is also a subclass.
+    """
 
-    """Base for all objects that can be part of the index file , namely Tree, Blob and
-    SubModule objects"""
     __slots__ = ("path", "mode")
 
-    # for compatability with iterable lists
-    _id_attribute_ = 'path'
+    # For compatibility with iterable lists.
+    _id_attribute_ = "path"
+
+    def __init__(
+        self,
+        repo: "Repo",
+        binsha: bytes,
+        mode: Union[None, int] = None,
+        path: Union[None, PathLike] = None,
+    ) -> None:
+        """Initialize a newly instanced :class:`IndexObject`.
+
+        :param repo:
+            The :class:`~git.repo.base.Repo` we are located in.
+
+        :param binsha:
+            20 byte sha1.
+
+        :param mode:
+            The stat-compatible file mode as :class:`int`.
+            Use the :mod:`stat` module to evaluate the information.
 
-    def __init__(self, repo, binsha, mode=None, path=None):
-        """Initialize a newly instanced IndexObject
-        :param repo: is the Repo we are located in
-        :param binsha: 20 byte sha1
-        :param mode: is the stat compatible file mode as int, use the stat module
-            to evaluate the infomration
         :param path:
-            is the path to the file in the file system, relative to the git repository root, i.e.
-            file.ext or folder/other.ext
+            The path to the file in the file system, relative to the git repository
+            root, like ``file.ext`` or ``folder/other.ext``.
+
         :note:
-            Path may not be set of the index object has been created directly as it cannot
-            be retrieved without knowing the parent tree."""
-        super(IndexObject, self).__init__(repo, binsha)
+            Path may not be set if the index object has been created directly, as it
+            cannot be retrieved without knowing the parent tree.
+        """
+        super().__init__(repo, binsha)
         if mode is not None:
             self.mode = mode
         if path is not None:
             self.path = path
 
-    def __hash__(self):
-        """:return:
-            Hash of our path as index items are uniquely identifyable by path, not
-            by their data !"""
+    def __hash__(self) -> int:
+        """
+        :return:
+            Hash of our path as index items are uniquely identifiable by path, not by
+            their data!
+        """
         return hash(self.path)
 
-    def _set_cache_(self, attr):
+    def _set_cache_(self, attr: str) -> None:
         if attr in IndexObject.__slots__:
-            # they cannot be retrieved lateron ( not without searching for them )
+            # They cannot be retrieved later on (not without searching for them).
             raise AttributeError(
                 "Attribute '%s' unset: path and mode attributes must have been set during %s object creation"
-                % (attr, type(self).__name__))
+                % (attr, type(self).__name__)
+            )
         else:
-            super(IndexObject, self)._set_cache_(attr)
-        # END hanlde slot attribute
+            super()._set_cache_(attr)
+        # END handle slot attribute
 
     @property
-    def name(self):
+    def name(self) -> str:
         """:return: Name portion of the path, effectively being the basename"""
-        return basename(self.path)
+        return osp.basename(self.path)
 
     @property
-    def abspath(self):
-        """
+    def abspath(self) -> PathLike:
+        R"""
         :return:
-            Absolute path to this index object in the file system ( as opposed to the
-            .path field which is a path relative to the git repository ).
+            Absolute path to this index object in the file system (as opposed to the
+            :attr:`path` field which is a path relative to the git repository).
 
-            The returned path will be native to the system and contains '\' on windows. """
-        return join_path_native(self.repo.working_tree_dir, self.path)
+            The returned path will be native to the system and contains ``\`` on
+            Windows.
+        """
+        if self.repo.working_tree_dir is not None:
+            return join_path_native(self.repo.working_tree_dir, self.path)
+        else:
+            raise WorkTreeRepositoryUnsupported("working_tree_dir was None or empty")
diff --git a/git/objects/blob.py b/git/objects/blob.py
index 322f6992b..58de59642 100644
--- a/git/objects/blob.py
+++ b/git/objects/blob.py
@@ -1,33 +1,48 @@
-# blob.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["Blob"]
+
 from mimetypes import guess_type
-from . import base
+import sys
+
+if sys.version_info >= (3, 8):
+    from typing import Literal
+else:
+    from typing_extensions import Literal
 
-__all__ = ('Blob', )
+from . import base
 
 
 class Blob(base.IndexObject):
+    """A Blob encapsulates a git blob object.
+
+    See :manpage:`gitglossary(7)` on "blob":
+    https://git-scm.com/docs/gitglossary#def_blob_object
+    """
 
-    """A Blob encapsulates a git blob object"""
     DEFAULT_MIME_TYPE = "text/plain"
-    type = "blob"
+    type: Literal["blob"] = "blob"
 
-    # valid blob modes
+    # Valid blob modes
     executable_mode = 0o100755
     file_mode = 0o100644
     link_mode = 0o120000
 
-    __slots__ = tuple()
+    __slots__ = ()
 
     @property
-    def mime_type(self):
+    def mime_type(self) -> str:
+        """
+        :return:
+            String describing the mime type of this file (based on the filename)
+
+        :note:
+            Defaults to ``text/plain`` in case the actual file type is unknown.
         """
-        :return: String describing the mime type of this file (based on the filename)
-        :note: Defaults to 'text/plain' in case the actual file type is unknown. """
         guesses = None
         if self.path:
-            guesses = guess_type(self.path)
+            guesses = guess_type(str(self.path))
         return guesses and guesses[0] or self.DEFAULT_MIME_TYPE
diff --git a/git/objects/commit.py b/git/objects/commit.py
index f2ce91ca0..fbe0ee9c0 100644
--- a/git/objects/commit.py
+++ b/git/objects/commit.py
@@ -1,106 +1,176 @@
-# commit.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["Commit"]
+
+from collections import defaultdict
+import datetime
+from io import BytesIO
+import logging
+import os
+import re
+from subprocess import Popen, PIPE
+import sys
+from time import altzone, daylight, localtime, time, timezone
+import warnings
 
 from gitdb import IStream
-from gitdb.util import hex_to_bin
-from git.util import (
-    Actor,
-    Iterable,
-    Stats,
-    finalize_process
-)
+
+from git.cmd import Git
 from git.diff import Diffable
+from git.util import Actor, Stats, finalize_process, hex_to_bin
 
-from .tree import Tree
 from . import base
+from .tree import Tree
 from .util import (
-    Traversable,
     Serializable,
-    parse_date,
+    TraversableIterableObj,
     altz_to_utctz_str,
-    parse_actor_and_date
+    from_timestamp,
+    parse_actor_and_date,
+    parse_date,
 )
-from git.compat import text_type
 
-from time import (
-    time,
-    altzone
+# typing ------------------------------------------------------------------
+
+from typing import (
+    Any,
+    Dict,
+    IO,
+    Iterator,
+    List,
+    Sequence,
+    Tuple,
+    TYPE_CHECKING,
+    Union,
+    cast,
 )
-import os
-from io import BytesIO
-import logging
 
-log = logging.getLogger('git.objects.commit')
+if sys.version_info >= (3, 8):
+    from typing import Literal
+else:
+    from typing_extensions import Literal
+
+from git.types import PathLike
 
-__all__ = ('Commit', )
+if TYPE_CHECKING:
+    from git.refs import SymbolicReference
+    from git.repo import Repo
 
+# ------------------------------------------------------------------------
 
-class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
+_logger = logging.getLogger(__name__)
 
-    """Wraps a git Commit object.
 
-    This class will act lazily on some of its attributes and will query the
-    value on demand only if it involves calling the git binary."""
+class Commit(base.Object, TraversableIterableObj, Diffable, Serializable):
+    """Wraps a git commit object.
+
+    See :manpage:`gitglossary(7)` on "commit object":
+    https://git-scm.com/docs/gitglossary#def_commit_object
+
+    :note:
+        This class will act lazily on some of its attributes and will query the value on
+        demand only if it involves calling the git binary.
+    """
 
     # ENVIRONMENT VARIABLES
-    # read when creating new commits
+    # Read when creating new commits.
     env_author_date = "GIT_AUTHOR_DATE"
     env_committer_date = "GIT_COMMITTER_DATE"
 
     # CONFIGURATION KEYS
-    conf_encoding = 'i18n.commitencoding'
+    conf_encoding = "i18n.commitencoding"
 
     # INVARIANTS
     default_encoding = "UTF-8"
 
-    # object configuration
-    type = "commit"
-    __slots__ = ("tree",
-                 "author", "authored_date", "author_tz_offset",
-                 "committer", "committed_date", "committer_tz_offset",
-                 "message", "parents", "encoding", "gpgsig")
+    type: Literal["commit"] = "commit"
+
+    __slots__ = (
+        "tree",
+        "author",
+        "authored_date",
+        "author_tz_offset",
+        "committer",
+        "committed_date",
+        "committer_tz_offset",
+        "message",
+        "parents",
+        "encoding",
+        "gpgsig",
+    )
+
     _id_attribute_ = "hexsha"
 
-    def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None,
-                 committer=None, committed_date=None, committer_tz_offset=None,
-                 message=None, parents=None, encoding=None, gpgsig=None):
-        """Instantiate a new Commit. All keyword arguments taking None as default will
-        be implicitly set on first query.
-        :param binsha: 20 byte sha1
-        :param parents: tuple( Commit, ... )
-            is a tuple of commit ids or actual Commits
-        :param tree: Tree
-            Tree object
-        :param author: Actor
-            is the author string ( will be implicitly converted into an Actor object )
+    parents: Sequence["Commit"]
+
+    def __init__(
+        self,
+        repo: "Repo",
+        binsha: bytes,
+        tree: Union[Tree, None] = None,
+        author: Union[Actor, None] = None,
+        authored_date: Union[int, None] = None,
+        author_tz_offset: Union[None, float] = None,
+        committer: Union[Actor, None] = None,
+        committed_date: Union[int, None] = None,
+        committer_tz_offset: Union[None, float] = None,
+        message: Union[str, bytes, None] = None,
+        parents: Union[Sequence["Commit"], None] = None,
+        encoding: Union[str, None] = None,
+        gpgsig: Union[str, None] = None,
+    ) -> None:
+        """Instantiate a new :class:`Commit`. All keyword arguments taking ``None`` as
+        default will be implicitly set on first query.
+
+        :param binsha:
+            20 byte sha1.
+
+        :param tree:
+            A :class:`~git.objects.tree.Tree` object.
+
+        :param author:
+            The author :class:`~git.util.Actor` object.
+
         :param authored_date: int_seconds_since_epoch
-            is the authored DateTime - use time.gmtime() to convert it into a
-            different format
+            The authored DateTime - use :func:`time.gmtime` to convert it into a
+            different format.
+
         :param author_tz_offset: int_seconds_west_of_utc
-            is the timezone that the authored_date is in
-        :param committer: Actor
-            is the committer string
+            The timezone that the `authored_date` is in.
+
+        :param committer:
+            The committer string, as an :class:`~git.util.Actor` object.
+
         :param committed_date: int_seconds_since_epoch
-            is the committed DateTime - use time.gmtime() to convert it into a
-            different format
+            The committed DateTime - use :func:`time.gmtime` to convert it into a
+            different format.
+
         :param committer_tz_offset: int_seconds_west_of_utc
-            is the timezone that the authored_date is in
+            The timezone that the `committed_date` is in.
+
         :param message: string
-            is the commit message
+            The commit message.
+
         :param encoding: string
-            encoding of the message, defaults to UTF-8
+            Encoding of the message, defaults to UTF-8.
+
         :param parents:
-            List or tuple of Commit objects which are our parent(s) in the commit
-            dependency graph
-        :return: git.Commit
-
-        :note: Timezone information is in the same format and in the same sign
-            as what time.altzone returns. The sign is inverted compared to git's
-            UTC timezone."""
-        super(Commit, self).__init__(repo, binsha)
+            List or tuple of :class:`Commit` objects which are our parent(s) in the
+            commit dependency graph.
+
+        :return:
+            :class:`Commit`
+
+        :note:
+            Timezone information is in the same format and in the same sign as what
+            :func:`time.altzone` returns. The sign is inverted compared to git's UTC
+            timezone.
+        """
+        super().__init__(repo, binsha)
+        self.binsha = binsha
         if tree is not None:
             assert isinstance(tree, Tree), "Tree needs to be a Tree instance, was %s" % type(tree)
         if tree is not None:
@@ -123,122 +193,349 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut
             self.parents = parents
         if encoding is not None:
             self.encoding = encoding
-        self.gpgsig = gpgsig
+        if gpgsig is not None:
+            self.gpgsig = gpgsig
+
+    @classmethod
+    def _get_intermediate_items(cls, commit: "Commit") -> Tuple["Commit", ...]:
+        return tuple(commit.parents)
 
     @classmethod
-    def _get_intermediate_items(cls, commit):
-        return commit.parents
+    def _calculate_sha_(cls, repo: "Repo", commit: "Commit") -> bytes:
+        """Calculate the sha of a commit.
+
+        :param repo:
+            :class:`~git.repo.base.Repo` object the commit should be part of.
+
+        :param commit:
+            :class:`Commit` object for which to generate the sha.
+        """
+
+        stream = BytesIO()
+        commit._serialize(stream)
+        streamlen = stream.tell()
+        stream.seek(0)
+
+        istream = repo.odb.store(IStream(cls.type, streamlen, stream))
+        return istream.binsha
+
+    def replace(self, **kwargs: Any) -> "Commit":
+        """Create new commit object from an existing commit object.
+
+        Any values provided as keyword arguments will replace the corresponding
+        attribute in the new object.
+        """
+
+        attrs = {k: getattr(self, k) for k in self.__slots__}
+
+        for attrname in kwargs:
+            if attrname not in self.__slots__:
+                raise ValueError("invalid attribute name")
+
+        attrs.update(kwargs)
+        new_commit = self.__class__(self.repo, self.NULL_BIN_SHA, **attrs)
+        new_commit.binsha = self._calculate_sha_(self.repo, new_commit)
+
+        return new_commit
 
-    def _set_cache_(self, attr):
+    def _set_cache_(self, attr: str) -> None:
         if attr in Commit.__slots__:
-            # read the data in a chunk, its faster - then provide a file wrapper
-            binsha, typename, self.size, stream = self.repo.odb.stream(self.binsha)
+            # Read the data in a chunk, its faster - then provide a file wrapper.
+            _binsha, _typename, self.size, stream = self.repo.odb.stream(self.binsha)
             self._deserialize(BytesIO(stream.read()))
         else:
-            super(Commit, self)._set_cache_(attr)
+            super()._set_cache_(attr)
         # END handle attrs
 
     @property
-    def summary(self):
+    def authored_datetime(self) -> datetime.datetime:
+        return from_timestamp(self.authored_date, self.author_tz_offset)
+
+    @property
+    def committed_datetime(self) -> datetime.datetime:
+        return from_timestamp(self.committed_date, self.committer_tz_offset)
+
+    @property
+    def summary(self) -> Union[str, bytes]:
         """:return: First line of the commit message"""
-        return self.message.split('\n', 1)[0]
+        if isinstance(self.message, str):
+            return self.message.split("\n", 1)[0]
+        else:
+            return self.message.split(b"\n", 1)[0]
 
-    def count(self, paths='', **kwargs):
-        """Count the number of commits reachable from this commit
+    def count(self, paths: Union[PathLike, Sequence[PathLike]] = "", **kwargs: Any) -> int:
+        """Count the number of commits reachable from this commit.
 
         :param paths:
-            is an optinal path or a list of paths restricting the return value
-            to commits actually containing the paths
+            An optional path or a list of paths restricting the return value to commits
+            actually containing the paths.
 
         :param kwargs:
-            Additional options to be passed to git-rev-list. They must not alter
-            the ouput style of the command, or parsing will yield incorrect results
-        :return: int defining the number of reachable commits"""
-        # yes, it makes a difference whether empty paths are given or not in our case
-        # as the empty paths version will ignore merge commits for some reason.
+            Additional options to be passed to :manpage:`git-rev-list(1)`. They must not
+            alter the output style of the command, or parsing will yield incorrect
+            results.
+
+        :return:
+            An int defining the number of reachable commits
+        """
+        # Yes, it makes a difference whether empty paths are given or not in our case as
+        # the empty paths version will ignore merge commits for some reason.
         if paths:
-            return len(self.repo.git.rev_list(self.hexsha, '--', paths, **kwargs).splitlines())
-        else:
-            return len(self.repo.git.rev_list(self.hexsha, **kwargs).splitlines())
+            return len(self.repo.git.rev_list(self.hexsha, "--", paths, **kwargs).splitlines())
+        return len(self.repo.git.rev_list(self.hexsha, **kwargs).splitlines())
 
     @property
-    def name_rev(self):
+    def name_rev(self) -> str:
         """
         :return:
-            String describing the commits hex sha based on the closest Reference.
-            Mostly useful for UI purposes"""
+            String describing the commits hex sha based on the closest
+            :class:`~git.refs.reference.Reference`.
+
+        :note:
+            Mostly useful for UI purposes.
+        """
         return self.repo.git.name_rev(self)
 
     @classmethod
-    def iter_items(cls, repo, rev, paths='', **kwargs):
-        """Find all commits matching the given criteria.
+    def iter_items(
+        cls,
+        repo: "Repo",
+        rev: Union[str, "Commit", "SymbolicReference"],
+        paths: Union[PathLike, Sequence[PathLike]] = "",
+        **kwargs: Any,
+    ) -> Iterator["Commit"]:
+        R"""Find all commits matching the given criteria.
+
+        :param repo:
+            The :class:`~git.repo.base.Repo`.
+
+        :param rev:
+            Revision specifier. See :manpage:`git-rev-parse(1)` for viable options.
 
-        :param repo: is the Repo
-        :param rev: revision specifier, see git-rev-parse for viable options
         :param paths:
-            is an optinal path or list of paths, if set only Commits that include the path
-            or paths will be considered
+            An optional path or list of paths. If set only :class:`Commit`\s that
+            include the path or paths will be considered.
+
         :param kwargs:
-            optional keyword arguments to git rev-list where
-            ``max_count`` is the maximum number of commits to fetch
-            ``skip`` is the number of commits to skip
-            ``since`` all commits since i.e. '1970-01-01'
-        :return: iterator yielding Commit items"""
-        if 'pretty' in kwargs:
+            Optional keyword arguments to :manpage:`git-rev-list(1)` where:
+
+            * ``max_count`` is the maximum number of commits to fetch.
+            * ``skip`` is the number of commits to skip.
+            * ``since`` selects all commits since some date, e.g. ``"1970-01-01"``.
+
+        :return:
+            Iterator yielding :class:`Commit` items.
+        """
+        if "pretty" in kwargs:
             raise ValueError("--pretty cannot be used as parsing expects single sha's only")
         # END handle pretty
-        args = list()
+
+        # Use -- in all cases, to prevent possibility of ambiguous arguments.
+        # See https://github.com/gitpython-developers/GitPython/issues/264.
+
+        args_list: List[PathLike] = ["--"]
+
         if paths:
-            args.extend(('--', paths))
+            paths_tup: Tuple[PathLike, ...]
+            if isinstance(paths, (str, os.PathLike)):
+                paths_tup = (paths,)
+            else:
+                paths_tup = tuple(paths)
+
+            args_list.extend(paths_tup)
         # END if paths
 
-        proc = repo.git.rev_list(rev, args, as_process=True, **kwargs)
+        proc = repo.git.rev_list(rev, args_list, as_process=True, **kwargs)
         return cls._iter_from_process_or_stream(repo, proc)
 
-    def iter_parents(self, paths='', **kwargs):
-        """Iterate _all_ parents of this commit.
+    def iter_parents(self, paths: Union[PathLike, Sequence[PathLike]] = "", **kwargs: Any) -> Iterator["Commit"]:
+        R"""Iterate *all* parents of this commit.
 
         :param paths:
-            Optional path or list of paths limiting the Commits to those that
-            contain at least one of the paths
-        :param kwargs: All arguments allowed by git-rev-list
-        :return: Iterator yielding Commit objects which are parents of self """
+            Optional path or list of paths limiting the :class:`Commit`\s to those that
+            contain at least one of the paths.
+
+        :param kwargs:
+            All arguments allowed by :manpage:`git-rev-list(1)`.
+
+        :return:
+            Iterator yielding :class:`Commit` objects which are parents of ``self``
+        """
         # skip ourselves
         skip = kwargs.get("skip", 1)
-        if skip == 0:   # skip ourselves
+        if skip == 0:  # skip ourselves
             skip = 1
-        kwargs['skip'] = skip
+        kwargs["skip"] = skip
 
         return self.iter_items(self.repo, self, paths, **kwargs)
 
     @property
-    def stats(self):
+    def stats(self) -> Stats:
         """Create a git stat from changes between this commit and its first parent
         or from all changes done if this is the very first commit.
 
-        :return: git.Stats"""
-        if not self.parents:
-            text = self.repo.git.diff_tree(self.hexsha, '--', numstat=True, root=True)
-            text2 = ""
-            for line in text.splitlines()[1:]:
+        :return:
+            :class:`Stats`
+        """
+
+        def process_lines(lines: List[str]) -> str:
+            text = ""
+            for file_info, line in zip(lines, lines[len(lines) // 2 :]):
+                change_type = file_info.split("\t")[0][-1]
                 (insertions, deletions, filename) = line.split("\t")
-                text2 += "%s\t%s\t%s\n" % (insertions, deletions, filename)
-            text = text2
+                text += "%s\t%s\t%s\t%s\n" % (change_type, insertions, deletions, filename)
+            return text
+
+        if not self.parents:
+            lines = self.repo.git.diff_tree(
+                self.hexsha, "--", numstat=True, no_renames=True, root=True, raw=True
+            ).splitlines()[1:]
+            text = process_lines(lines)
         else:
-            text = self.repo.git.diff(self.parents[0].hexsha, self.hexsha, '--', numstat=True)
+            lines = self.repo.git.diff(
+                self.parents[0].hexsha, self.hexsha, "--", numstat=True, no_renames=True, raw=True
+            ).splitlines()
+            text = process_lines(lines)
         return Stats._list_from_string(self.repo, text)
 
+    @property
+    def trailers(self) -> Dict[str, str]:
+        """Deprecated. Get the trailers of the message as a dictionary.
+
+        :note:
+            This property is deprecated, please use either :attr:`trailers_list` or
+            :attr:`trailers_dict`.
+
+        :return:
+            Dictionary containing whitespace stripped trailer information.
+            Only contains the latest instance of each trailer key.
+        """
+        warnings.warn(
+            "Commit.trailers is deprecated, use Commit.trailers_list or Commit.trailers_dict instead",
+            DeprecationWarning,
+            stacklevel=2,
+        )
+        return {k: v[0] for k, v in self.trailers_dict.items()}
+
+    @property
+    def trailers_list(self) -> List[Tuple[str, str]]:
+        """Get the trailers of the message as a list.
+
+        Git messages can contain trailer information that are similar to :rfc:`822`
+        e-mail headers. See :manpage:`git-interpret-trailers(1)`.
+
+        This function calls ``git interpret-trailers --parse`` onto the message to
+        extract the trailer information, returns the raw trailer data as a list.
+
+        Valid message with trailer::
+
+            Subject line
+
+            some body information
+
+            another information
+
+            key1: value1.1
+            key1: value1.2
+            key2 :    value 2 with inner spaces
+
+        Returned list will look like this::
+
+            [
+                ("key1", "value1.1"),
+                ("key1", "value1.2"),
+                ("key2", "value 2 with inner spaces"),
+            ]
+
+        :return:
+            List containing key-value tuples of whitespace stripped trailer information.
+        """
+        cmd = ["git", "interpret-trailers", "--parse"]
+        proc: Git.AutoInterrupt = self.repo.git.execute(  # type: ignore[call-overload]
+            cmd,
+            as_process=True,
+            istream=PIPE,
+        )
+        trailer: str = proc.communicate(str(self.message).encode())[0].decode("utf8")
+        trailer = trailer.strip()
+
+        if not trailer:
+            return []
+
+        trailer_list = []
+        for t in trailer.split("\n"):
+            key, val = t.split(":", 1)
+            trailer_list.append((key.strip(), val.strip()))
+
+        return trailer_list
+
+    @property
+    def trailers_dict(self) -> Dict[str, List[str]]:
+        """Get the trailers of the message as a dictionary.
+
+        Git messages can contain trailer information that are similar to :rfc:`822`
+        e-mail headers. See :manpage:`git-interpret-trailers(1)`.
+
+        This function calls ``git interpret-trailers --parse`` onto the message to
+        extract the trailer information. The key value pairs are stripped of leading and
+        trailing whitespaces before they get saved into a dictionary.
+
+        Valid message with trailer::
+
+            Subject line
+
+            some body information
+
+            another information
+
+            key1: value1.1
+            key1: value1.2
+            key2 :    value 2 with inner spaces
+
+        Returned dictionary will look like this::
+
+            {
+                "key1": ["value1.1", "value1.2"],
+                "key2": ["value 2 with inner spaces"],
+            }
+
+
+        :return:
+            Dictionary containing whitespace stripped trailer information, mapping
+            trailer keys to a list of their corresponding values.
+        """
+        d = defaultdict(list)
+        for key, val in self.trailers_list:
+            d[key].append(val)
+        return dict(d)
+
     @classmethod
-    def _iter_from_process_or_stream(cls, repo, proc_or_stream):
-        """Parse out commit information into a list of Commit objects
-        We expect one-line per commit, and parse the actual commit information directly
-        from our lighting fast object database
+    def _iter_from_process_or_stream(cls, repo: "Repo", proc_or_stream: Union[Popen, IO]) -> Iterator["Commit"]:
+        """Parse out commit information into a list of :class:`Commit` objects.
+
+        We expect one line per commit, and parse the actual commit information directly
+        from our lighting fast object database.
+
+        :param proc:
+            :manpage:`git-rev-list(1)` process instance - one sha per line.
 
-        :param proc: git-rev-list process instance - one sha per line
-        :return: iterator returning Commit objects"""
-        stream = proc_or_stream
-        if not hasattr(stream, 'readline'):
-            stream = proc_or_stream.stdout
+        :return:
+            Iterator supplying :class:`Commit` objects
+        """
+
+        # def is_proc(inp) -> TypeGuard[Popen]:
+        #     return hasattr(proc_or_stream, 'wait') and not hasattr(proc_or_stream, 'readline')
+
+        # def is_stream(inp) -> TypeGuard[IO]:
+        #     return hasattr(proc_or_stream, 'readline')
+
+        if hasattr(proc_or_stream, "wait"):
+            proc_or_stream = cast(Popen, proc_or_stream)
+            if proc_or_stream.stdout is not None:
+                stream = proc_or_stream.stdout
+        elif hasattr(proc_or_stream, "readline"):
+            proc_or_stream = cast(IO, proc_or_stream)  # type: ignore[redundant-cast]
+            stream = proc_or_stream
 
         readline = stream.readline
         while True:
@@ -247,64 +544,99 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
                 break
             hexsha = line.strip()
             if len(hexsha) > 40:
-                # split additional information, as returned by bisect for instance
-                hexsha, rest = line.split(None, 1)
+                # Split additional information, as returned by bisect for instance.
+                hexsha, _ = line.split(None, 1)
             # END handle extra info
 
             assert len(hexsha) == 40, "Invalid line: %s" % hexsha
-            yield Commit(repo, hex_to_bin(hexsha))
+            yield cls(repo, hex_to_bin(hexsha))
         # END for each line in stream
-        # TODO: Review this - it seems process handling got a bit out of control
-        # due to many developers trying to fix the open file handles issue
-        if hasattr(proc_or_stream, 'wait'):
+
+        # TODO: Review this - it seems process handling got a bit out of control due to
+        # many developers trying to fix the open file handles issue.
+        if hasattr(proc_or_stream, "wait"):
+            proc_or_stream = cast(Popen, proc_or_stream)
             finalize_process(proc_or_stream)
 
     @classmethod
-    def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, author=None, committer=None):
-        """Commit the given tree, creating a commit object.
-
-        :param repo: Repo object the commit should be part of
-        :param tree: Tree object or hex or bin sha
-            the tree of the new commit
-        :param message: Commit message. It may be an empty string if no message is provided.
-            It will be converted to a string in any case.
+    def create_from_tree(
+        cls,
+        repo: "Repo",
+        tree: Union[Tree, str],
+        message: str,
+        parent_commits: Union[None, List["Commit"]] = None,
+        head: bool = False,
+        author: Union[None, Actor] = None,
+        committer: Union[None, Actor] = None,
+        author_date: Union[None, str, datetime.datetime] = None,
+        commit_date: Union[None, str, datetime.datetime] = None,
+    ) -> "Commit":
+        """Commit the given tree, creating a :class:`Commit` object.
+
+        :param repo:
+            :class:`~git.repo.base.Repo` object the commit should be part of.
+
+        :param tree:
+            :class:`~git.objects.tree.Tree` object or hex or bin sha.
+            The tree of the new commit.
+
+        :param message:
+            Commit message. It may be an empty string if no message is provided. It will
+            be converted to a string, in any case.
+
         :param parent_commits:
-            Optional Commit objects to use as parents for the new commit.
-            If empty list, the commit will have no parents at all and become
-            a root commit.
-            If None , the current head commit will be the parent of the
-            new commit object
+            Optional :class:`Commit` objects to use as parents for the new commit. If
+            empty list, the commit will have no parents at all and become a root commit.
+            If ``None``, the current head commit will be the parent of the new commit
+            object.
+
         :param head:
-            If True, the HEAD will be advanced to the new commit automatically.
-            Else the HEAD will remain pointing on the previous commit. This could
+            If ``True``, the HEAD will be advanced to the new commit automatically.
+            Otherwise the HEAD will remain pointing on the previous commit. This could
             lead to undesired results when diffing files.
-        :param author: The name of the author, optional. If unset, the repository
-            configuration is used to obtain this value.
-        :param committer: The name of the committer, optional. If unset, the
-            repository configuration is used to obtain this value.
 
-        :return: Commit object representing the new commit
+        :param author:
+            The name of the author, optional.
+            If unset, the repository configuration is used to obtain this value.
+
+        :param committer:
+            The name of the committer, optional.
+            If unset, the repository configuration is used to obtain this value.
+
+        :param author_date:
+            The timestamp for the author field.
+
+        :param commit_date:
+            The timestamp for the committer field.
+
+        :return:
+            :class:`Commit` object representing the new commit.
 
         :note:
-            Additional information about the committer and Author are taken from the
-            environment or from the git configuration, see git-commit-tree for
-            more information"""
+            Additional information about the committer and author are taken from the
+            environment or from the git configuration. See :manpage:`git-commit-tree(1)`
+            for more information.
+        """
         if parent_commits is None:
             try:
                 parent_commits = [repo.head.commit]
             except ValueError:
-                # empty repositories have no head commit
-                parent_commits = list()
+                # Empty repositories have no head commit.
+                parent_commits = []
             # END handle parent commits
+        else:
+            for p in parent_commits:
+                if not isinstance(p, cls):
+                    raise ValueError(f"Parent commit '{p!r}' must be of type {cls}")
+            # END check parent commit types
         # END if parent commits are unset
 
-        # retrieve all additional information, create a commit object, and
-        # serialize it
+        # Retrieve all additional information, create a commit object, and serialize it.
         # Generally:
-        # * Environment variables override configuration values
-        # * Sensible defaults are set according to the git documentation
+        # * Environment variables override configuration values.
+        # * Sensible defaults are set according to the git documentation.
 
-        # COMMITER AND AUTHOR INFO
+        # COMMITTER AND AUTHOR INFO
         cr = repo.config_reader()
         env = os.environ
 
@@ -313,144 +645,182 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False,
 
         # PARSE THE DATES
         unix_time = int(time())
-        offset = altzone
+        is_dst = daylight and localtime().tm_isdst > 0
+        offset = altzone if is_dst else timezone
 
-        author_date_str = env.get(cls.env_author_date, '')
-        if author_date_str:
+        author_date_str = env.get(cls.env_author_date, "")
+        if author_date:
+            author_time, author_offset = parse_date(author_date)
+        elif author_date_str:
             author_time, author_offset = parse_date(author_date_str)
         else:
             author_time, author_offset = unix_time, offset
         # END set author time
 
-        committer_date_str = env.get(cls.env_committer_date, '')
-        if committer_date_str:
+        committer_date_str = env.get(cls.env_committer_date, "")
+        if commit_date:
+            committer_time, committer_offset = parse_date(commit_date)
+        elif committer_date_str:
             committer_time, committer_offset = parse_date(committer_date_str)
         else:
             committer_time, committer_offset = unix_time, offset
         # END set committer time
 
-        # assume utf8 encoding
-        enc_section, enc_option = cls.conf_encoding.split('.')
+        # Assume UTF-8 encoding.
+        enc_section, enc_option = cls.conf_encoding.split(".")
         conf_encoding = cr.get_value(enc_section, enc_option, cls.default_encoding)
+        if not isinstance(conf_encoding, str):
+            raise TypeError("conf_encoding could not be coerced to str")
 
-        # if the tree is no object, make sure we create one - otherwise
-        # the created commit object is invalid
+        # If the tree is no object, make sure we create one - otherwise the created
+        # commit object is invalid.
         if isinstance(tree, str):
             tree = repo.tree(tree)
         # END tree conversion
 
         # CREATE NEW COMMIT
-        new_commit = cls(repo, cls.NULL_BIN_SHA, tree,
-                         author, author_time, author_offset,
-                         committer, committer_time, committer_offset,
-                         message, parent_commits, conf_encoding)
-
-        stream = BytesIO()
-        new_commit._serialize(stream)
-        streamlen = stream.tell()
-        stream.seek(0)
-
-        istream = repo.odb.store(IStream(cls.type, streamlen, stream))
-        new_commit.binsha = istream.binsha
+        new_commit = cls(
+            repo,
+            cls.NULL_BIN_SHA,
+            tree,
+            author,
+            author_time,
+            author_offset,
+            committer,
+            committer_time,
+            committer_offset,
+            message,
+            parent_commits,
+            conf_encoding,
+        )
+
+        new_commit.binsha = cls._calculate_sha_(repo, new_commit)
 
         if head:
-            # need late import here, importing git at the very beginning throws
-            # as well ...
+            # Need late import here, importing git at the very beginning throws as
+            # well...
             import git.refs
+
             try:
                 repo.head.set_commit(new_commit, logmsg=message)
             except ValueError:
-                # head is not yet set to the ref our HEAD points to
-                # Happens on first commit
-                master = git.refs.Head.create(repo, repo.head.ref, new_commit, logmsg="commit (initial): %s" % message)
-                repo.head.set_reference(master, logmsg='commit: Switching to %s' % master)
+                # head is not yet set to the ref our HEAD points to.
+                # Happens on first commit.
+                master = git.refs.Head.create(
+                    repo,
+                    repo.head.ref,
+                    new_commit,
+                    logmsg="commit (initial): %s" % message,
+                )
+                repo.head.set_reference(master, logmsg="commit: Switching to %s" % master)
             # END handle empty repositories
         # END advance head handling
 
         return new_commit
 
-    #{ Serializable Implementation
+    # { Serializable Implementation
 
-    def _serialize(self, stream):
+    def _serialize(self, stream: BytesIO) -> "Commit":
         write = stream.write
-        write(("tree %s\n" % self.tree).encode('ascii'))
+        write(("tree %s\n" % self.tree).encode("ascii"))
         for p in self.parents:
-            write(("parent %s\n" % p).encode('ascii'))
+            write(("parent %s\n" % p).encode("ascii"))
 
         a = self.author
         aname = a.name
         c = self.committer
         fmt = "%s %s <%s> %s %s\n"
-        write((fmt % ("author", aname, a.email,
-                      self.authored_date,
-                      altz_to_utctz_str(self.author_tz_offset))).encode(self.encoding))
-
-        # encode committer
+        write(
+            (
+                fmt
+                % (
+                    "author",
+                    aname,
+                    a.email,
+                    self.authored_date,
+                    altz_to_utctz_str(self.author_tz_offset),
+                )
+            ).encode(self.encoding)
+        )
+
+        # Encode committer.
         aname = c.name
-        write((fmt % ("committer", aname, c.email,
-                      self.committed_date,
-                      altz_to_utctz_str(self.committer_tz_offset))).encode(self.encoding))
+        write(
+            (
+                fmt
+                % (
+                    "committer",
+                    aname,
+                    c.email,
+                    self.committed_date,
+                    altz_to_utctz_str(self.committer_tz_offset),
+                )
+            ).encode(self.encoding)
+        )
 
         if self.encoding != self.default_encoding:
-            write(("encoding %s\n" % self.encoding).encode('ascii'))
+            write(("encoding %s\n" % self.encoding).encode("ascii"))
 
-        if self.gpgsig:
-            write(b"gpgsig")
-            for sigline in self.gpgsig.rstrip("\n").split("\n"):
-                write((" " + sigline + "\n").encode('ascii'))
+        try:
+            if self.__getattribute__("gpgsig"):
+                write(b"gpgsig")
+                for sigline in self.gpgsig.rstrip("\n").split("\n"):
+                    write((" " + sigline + "\n").encode("ascii"))
+        except AttributeError:
+            pass
 
         write(b"\n")
 
-        # write plain bytes, be sure its encoded according to our encoding
-        if isinstance(self.message, text_type):
+        # Write plain bytes, be sure its encoded according to our encoding.
+        if isinstance(self.message, str):
             write(self.message.encode(self.encoding))
         else:
             write(self.message)
         # END handle encoding
         return self
 
-    def _deserialize(self, stream):
-        """:param from_rev_list: if true, the stream format is coming from the rev-list command
-        Otherwise it is assumed to be a plain data stream from our object"""
+    def _deserialize(self, stream: BytesIO) -> "Commit":
         readline = stream.readline
-        self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id << 12, '')
+        self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id << 12, "")
 
-        self.parents = list()
+        self.parents = []
         next_line = None
         while True:
             parent_line = readline()
-            if not parent_line.startswith(b'parent'):
+            if not parent_line.startswith(b"parent"):
                 next_line = parent_line
                 break
             # END abort reading parents
-            self.parents.append(type(self)(self.repo, hex_to_bin(parent_line.split()[-1].decode('ascii'))))
+            self.parents.append(type(self)(self.repo, hex_to_bin(parent_line.split()[-1].decode("ascii"))))
         # END for each parent line
         self.parents = tuple(self.parents)
 
-        # we don't know actual author encoding before we have parsed it, so keep the lines around
+        # We don't know actual author encoding before we have parsed it, so keep the
+        # lines around.
         author_line = next_line
         committer_line = readline()
 
-        # we might run into one or more mergetag blocks, skip those for now
+        # We might run into one or more mergetag blocks, skip those for now.
         next_line = readline()
-        while next_line.startswith(b'mergetag '):
+        while next_line.startswith(b"mergetag "):
             next_line = readline()
-            while next_line.startswith(' '):
+            while next_line.startswith(b" "):
                 next_line = readline()
-        # end skip mergetags
+        # END skip mergetags
 
-        # now we can have the encoding line, or an empty line followed by the optional
+        # Now we can have the encoding line, or an empty line followed by the optional
         # message.
         self.encoding = self.default_encoding
+        self.gpgsig = ""
 
-        # read headers
+        # Read headers.
         enc = next_line
         buf = enc.strip()
         while buf:
             if buf[0:10] == b"encoding ":
-                self.encoding = buf[buf.find(' ') + 1:].decode('ascii')
+                self.encoding = buf[buf.find(b" ") + 1 :].decode(self.encoding, "ignore")
             elif buf[0:7] == b"gpgsig ":
-                sig = buf[buf.find(b' ') + 1:] + b"\n"
+                sig = buf[buf.find(b" ") + 1 :] + b"\n"
                 is_next_header = False
                 while True:
                     sigbuf = readline()
@@ -461,37 +831,79 @@ def _deserialize(self, stream):
                         is_next_header = True
                         break
                     sig += sigbuf[1:]
-                # end read all signature
-                self.gpgsig = sig.rstrip(b"\n").decode('ascii')
+                # END read all signature
+                self.gpgsig = sig.rstrip(b"\n").decode(self.encoding, "ignore")
                 if is_next_header:
                     continue
             buf = readline().strip()
-        # decode the authors name
 
+        # Decode the author's name.
         try:
-            self.author, self.authored_date, self.author_tz_offset = \
-                parse_actor_and_date(author_line.decode(self.encoding))
+            (
+                self.author,
+                self.authored_date,
+                self.author_tz_offset,
+            ) = parse_actor_and_date(author_line.decode(self.encoding, "replace"))
         except UnicodeDecodeError:
-            log.error("Failed to decode author line '%s' using encoding %s", author_line, self.encoding,
-                      exc_info=True)
+            _logger.error(
+                "Failed to decode author line '%s' using encoding %s",
+                author_line,
+                self.encoding,
+                exc_info=True,
+            )
 
         try:
-            self.committer, self.committed_date, self.committer_tz_offset = \
-                parse_actor_and_date(committer_line.decode(self.encoding))
+            (
+                self.committer,
+                self.committed_date,
+                self.committer_tz_offset,
+            ) = parse_actor_and_date(committer_line.decode(self.encoding, "replace"))
         except UnicodeDecodeError:
-            log.error("Failed to decode committer line '%s' using encoding %s", committer_line, self.encoding,
-                      exc_info=True)
+            _logger.error(
+                "Failed to decode committer line '%s' using encoding %s",
+                committer_line,
+                self.encoding,
+                exc_info=True,
+            )
         # END handle author's encoding
 
-        # a stream from our data simply gives us the plain message
-        # The end of our message stream is marked with a newline that we strip
+        # A stream from our data simply gives us the plain message.
+        # The end of our message stream is marked with a newline that we strip.
         self.message = stream.read()
         try:
-            self.message = self.message.decode(self.encoding)
+            self.message = self.message.decode(self.encoding, "replace")
         except UnicodeDecodeError:
-            log.error("Failed to decode message '%s' using encoding %s", self.message, self.encoding, exc_info=True)
+            _logger.error(
+                "Failed to decode message '%s' using encoding %s",
+                self.message,
+                self.encoding,
+                exc_info=True,
+            )
         # END exception handling
 
         return self
 
-    #} END serializable implementation
+    # } END serializable implementation
+
+    @property
+    def co_authors(self) -> List[Actor]:
+        """Search the commit message for any co-authors of this commit.
+
+        Details on co-authors:
+        https://github.blog/2018-01-29-commit-together-with-co-authors/
+
+        :return:
+            List of co-authors for this commit (as :class:`~git.util.Actor` objects).
+        """
+        co_authors = []
+
+        if self.message:
+            results = re.findall(
+                r"^Co-authored-by: (.*) <(.*?)>$",
+                self.message,
+                re.MULTILINE,
+            )
+            for author in results:
+                co_authors.append(Actor(*author))
+
+        return co_authors
diff --git a/git/objects/fun.py b/git/objects/fun.py
index c04f80b5d..fe57da13a 100644
--- a/git/objects/fun.py
+++ b/git/objects/fun.py
@@ -1,101 +1,138 @@
-"""Module with functions which are supposed to be as fast as possible"""
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Functions that are supposed to be as fast as possible."""
+
+__all__ = [
+    "tree_to_stream",
+    "tree_entries_from_data",
+    "traverse_trees_recursive",
+    "traverse_tree_recursive",
+]
+
 from stat import S_ISDIR
-from git.compat import (
-    byte_ord,
-    defenc,
-    xrange,
-    text_type,
-    bchr
+
+from git.compat import safe_decode, defenc
+
+# typing ----------------------------------------------
+
+from typing import (
+    Callable,
+    List,
+    MutableSequence,
+    Sequence,
+    Tuple,
+    TYPE_CHECKING,
+    Union,
+    overload,
 )
 
-__all__ = ('tree_to_stream', 'tree_entries_from_data', 'traverse_trees_recursive',
-           'traverse_tree_recursive')
+if TYPE_CHECKING:
+    from _typeshed import ReadableBuffer
+
+    from git import GitCmdObjectDB
+
+EntryTup = Tuple[bytes, int, str]  # Same as TreeCacheTup in tree.py.
+EntryTupOrNone = Union[EntryTup, None]
+
+# ---------------------------------------------------
+
 
+def tree_to_stream(entries: Sequence[EntryTup], write: Callable[["ReadableBuffer"], Union[int, None]]) -> None:
+    """Write the given list of entries into a stream using its ``write`` method.
 
-def tree_to_stream(entries, write):
-    """Write the give list of entries into a stream using its write method
-    :param entries: **sorted** list of tuples with (binsha, mode, name)
-    :param write: write method which takes a data string"""
-    ord_zero = ord('0')
-    bit_mask = 7            # 3 bits set
+    :param entries:
+        **Sorted** list of tuples with (binsha, mode, name).
+
+    :param write:
+        A ``write`` method which takes a data string.
+    """
+    ord_zero = ord("0")
+    bit_mask = 7  # 3 bits set.
 
     for binsha, mode, name in entries:
-        mode_str = b''
-        for i in xrange(6):
-            mode_str = bchr(((mode >> (i * 3)) & bit_mask) + ord_zero) + mode_str
+        mode_str = b""
+        for i in range(6):
+            mode_str = bytes([((mode >> (i * 3)) & bit_mask) + ord_zero]) + mode_str
         # END for each 8 octal value
 
-        # git slices away the first octal if its zero
-        if byte_ord(mode_str[0]) == ord_zero:
+        # git slices away the first octal if it's zero.
+        if mode_str[0] == ord_zero:
             mode_str = mode_str[1:]
         # END save a byte
 
-        # here it comes:  if the name is actually unicode, the replacement below
-        # will not work as the binsha is not part of the ascii unicode encoding -
-        # hence we must convert to an utf8 string for it to work properly.
-        # According to my tests, this is exactly what git does, that is it just
-        # takes the input literally, which appears to be utf8 on linux.
-        if isinstance(name, text_type):
-            name = name.encode(defenc)
-        write(b''.join((mode_str, b' ', name, b'\0', binsha)))
+        # Here it comes: If the name is actually unicode, the replacement below will not
+        # work as the binsha is not part of the ascii unicode encoding - hence we must
+        # convert to an UTF-8 string for it to work properly. According to my tests,
+        # this is exactly what git does, that is it just takes the input literally,
+        # which appears to be UTF-8 on linux.
+        if isinstance(name, str):
+            name_bytes = name.encode(defenc)
+        else:
+            name_bytes = name  # type: ignore[unreachable]  # check runtime types - is always str?
+        write(b"".join((mode_str, b" ", name_bytes, b"\0", binsha)))
     # END for each item
 
 
-def tree_entries_from_data(data):
-    """Reads the binary representation of a tree and returns tuples of Tree items
-    :param data: data block with tree data (as bytes)
-    :return: list(tuple(binsha, mode, tree_relative_path), ...)"""
-    ord_zero = ord('0')
-    space_ord = ord(' ')
+def tree_entries_from_data(data: bytes) -> List[EntryTup]:
+    """Read the binary representation of a tree and returns tuples of
+    :class:`~git.objects.tree.Tree` items.
+
+    :param data:
+        Data block with tree data (as bytes).
+
+    :return:
+        list(tuple(binsha, mode, tree_relative_path), ...)
+    """
+    ord_zero = ord("0")
+    space_ord = ord(" ")
     len_data = len(data)
     i = 0
-    out = list()
+    out = []
     while i < len_data:
         mode = 0
 
-        # read mode
-        # Some git versions truncate the leading 0, some don't
-        # The type will be extracted from the mode later
-        while byte_ord(data[i]) != space_ord:
-            # move existing mode integer up one level being 3 bits
-            # and add the actual ordinal value of the character
-            mode = (mode << 3) + (byte_ord(data[i]) - ord_zero)
+        # Read Mode
+        # Some git versions truncate the leading 0, some don't.
+        # The type will be extracted from the mode later.
+        while data[i] != space_ord:
+            # Move existing mode integer up one level being 3 bits and add the actual
+            # ordinal value of the character.
+            mode = (mode << 3) + (data[i] - ord_zero)
             i += 1
         # END while reading mode
 
-        # byte is space now, skip it
+        # Byte is space now, skip it.
         i += 1
 
-        # parse name, it is NULL separated
+        # Parse name, it is NULL separated.
 
         ns = i
-        while byte_ord(data[i]) != 0:
+        while data[i] != 0:
             i += 1
         # END while not reached NULL
 
-        # default encoding for strings in git is utf8
-        # Only use the respective unicode object if the byte stream was encoded
-        name = data[ns:i]
-        try:
-            name = name.decode(defenc)
-        except UnicodeDecodeError:
-            pass
-        # END handle encoding
+        # Default encoding for strings in git is UTF-8.
+        # Only use the respective unicode object if the byte stream was encoded.
+        name_bytes = data[ns:i]
+        name = safe_decode(name_bytes)
 
-        # byte is NULL, get next 20
+        # Byte is NULL, get next 20.
         i += 1
-        sha = data[i:i + 20]
+        sha = data[i : i + 20]
         i = i + 20
         out.append((sha, mode, name))
     # END for each byte in data stream
     return out
 
 
-def _find_by_name(tree_data, name, is_dir, start_at):
-    """return data entry matching the given name and tree mode
-    or None.
-    Before the item is returned, the respective data item is set
-    None in the tree_data list to mark it done"""
+def _find_by_name(tree_data: MutableSequence[EntryTupOrNone], name: str, is_dir: bool, start_at: int) -> EntryTupOrNone:
+    """Return data entry matching the given name and tree mode or ``None``.
+
+    Before the item is returned, the respective data item is set None in the `tree_data`
+    list to mark it done.
+    """
+
     try:
         item = tree_data[start_at]
         if item and item[2] == name and S_ISDIR(item[1]) == is_dir:
@@ -113,96 +150,130 @@ def _find_by_name(tree_data, name, is_dir, start_at):
     return None
 
 
-def _to_full_path(item, path_prefix):
-    """Rebuild entry with given path prefix"""
+@overload
+def _to_full_path(item: None, path_prefix: str) -> None: ...
+
+
+@overload
+def _to_full_path(item: EntryTup, path_prefix: str) -> EntryTup: ...
+
+
+def _to_full_path(item: EntryTupOrNone, path_prefix: str) -> EntryTupOrNone:
+    """Rebuild entry with given path prefix."""
     if not item:
         return item
     return (item[0], item[1], path_prefix + item[2])
 
 
-def traverse_trees_recursive(odb, tree_shas, path_prefix):
+def traverse_trees_recursive(
+    odb: "GitCmdObjectDB", tree_shas: Sequence[Union[bytes, None]], path_prefix: str
+) -> List[Tuple[EntryTupOrNone, ...]]:
     """
-    :return: list with entries according to the given binary tree-shas.
+    :return:
+        List of list with entries according to the given binary tree-shas.
+
         The result is encoded in a list
-        of n tuple|None per blob/commit, (n == len(tree_shas)), where
+        of n tuple|None per blob/commit, (n == len(tree_shas)), where:
+
         * [0] == 20 byte sha
         * [1] == mode as int
         * [2] == path relative to working tree root
-        The entry tuple is None if the respective blob/commit did not
-        exist in the given tree.
-    :param tree_shas: iterable of shas pointing to trees. All trees must
-        be on the same level. A tree-sha may be None in which case None
-    :param path_prefix: a prefix to be added to the returned paths on this level,
-        set it '' for the first iteration
-    :note: The ordering of the returned items will be partially lost"""
-    trees_data = list()
+
+        The entry tuple is ``None`` if the respective blob/commit did not exist in the
+        given tree.
+
+    :param tree_shas:
+        Iterable of shas pointing to trees. All trees must be on the same level.
+        A tree-sha may be ``None``, in which case ``None``.
+
+    :param path_prefix:
+        A prefix to be added to the returned paths on this level.
+        Set it ``""`` for the first iteration.
+
+    :note:
+        The ordering of the returned items will be partially lost.
+    """
+    trees_data: List[List[EntryTupOrNone]] = []
+
     nt = len(tree_shas)
     for tree_sha in tree_shas:
         if tree_sha is None:
-            data = list()
+            data: List[EntryTupOrNone] = []
         else:
-            data = tree_entries_from_data(odb.stream(tree_sha).read())
+            # Make new list for typing as list invariant.
+            data = list(tree_entries_from_data(odb.stream(tree_sha).read()))
         # END handle muted trees
         trees_data.append(data)
     # END for each sha to get data for
 
-    out = list()
-    out_append = out.append
+    out: List[Tuple[EntryTupOrNone, ...]] = []
 
-    # find all matching entries and recursively process them together if the match
-    # is a tree. If the match is a non-tree item, put it into the result.
-    # Processed items will be set None
+    # Find all matching entries and recursively process them together if the match is a
+    # tree. If the match is a non-tree item, put it into the result.
+    # Processed items will be set None.
     for ti, tree_data in enumerate(trees_data):
         for ii, item in enumerate(tree_data):
             if not item:
                 continue
             # END skip already done items
-            entries = [None for n in range(nt)]
+            entries: List[EntryTupOrNone]
+            entries = [None for _ in range(nt)]
             entries[ti] = item
-            sha, mode, name = item                          # its faster to unpack
-            is_dir = S_ISDIR(mode)                          # type mode bits
+            _sha, mode, name = item
+            is_dir = S_ISDIR(mode)  # Type mode bits
 
-            # find this item in all other tree data items
-            # wrap around, but stop one before our current index, hence
-            # ti+nt, not ti+1+nt
+            # Find this item in all other tree data items.
+            # Wrap around, but stop one before our current index, hence ti+nt, not
+            # ti+1+nt.
             for tio in range(ti + 1, ti + nt):
                 tio = tio % nt
                 entries[tio] = _find_by_name(trees_data[tio], name, is_dir, ii)
-            # END for each other item data
 
-            # if we are a directory, enter recursion
+            # END for each other item data
+            # If we are a directory, enter recursion.
             if is_dir:
-                out.extend(traverse_trees_recursive(
-                    odb, [((ei and ei[0]) or None) for ei in entries], path_prefix + name + '/'))
+                out.extend(
+                    traverse_trees_recursive(
+                        odb,
+                        [((ei and ei[0]) or None) for ei in entries],
+                        path_prefix + name + "/",
+                    )
+                )
             else:
-                out_append(tuple(_to_full_path(e, path_prefix) for e in entries))
-            # END handle recursion
+                out.append(tuple(_to_full_path(e, path_prefix) for e in entries))
 
-            # finally mark it done
+            # END handle recursion
+            # Finally mark it done.
             tree_data[ii] = None
         # END for each item
 
-        # we are done with one tree, set all its data empty
-        del(tree_data[:])
+        # We are done with one tree, set all its data empty.
+        del tree_data[:]
     # END for each tree_data chunk
     return out
 
 
-def traverse_tree_recursive(odb, tree_sha, path_prefix):
+def traverse_tree_recursive(odb: "GitCmdObjectDB", tree_sha: bytes, path_prefix: str) -> List[EntryTup]:
     """
-    :return: list of entries of the tree pointed to by the binary tree_sha. An entry
-        has the following format:
+    :return:
+        List of entries of the tree pointed to by the binary `tree_sha`.
+
+        An entry has the following format:
+
         * [0] 20 byte sha
         * [1] mode as int
         * [2] path relative to the repository
-    :param path_prefix: prefix to prepend to the front of all returned paths"""
-    entries = list()
+
+    :param path_prefix:
+        Prefix to prepend to the front of all returned paths.
+    """
+    entries = []
     data = tree_entries_from_data(odb.stream(tree_sha).read())
 
-    # unpacking/packing is faster than accessing individual items
+    # Unpacking/packing is faster than accessing individual items.
     for sha, mode, name in data:
         if S_ISDIR(mode):
-            entries.extend(traverse_tree_recursive(odb, sha, path_prefix + name + '/'))
+            entries.extend(traverse_tree_recursive(odb, sha, path_prefix + name + "/"))
         else:
             entries.append((sha, mode, path_prefix + name))
     # END for each item
diff --git a/git/objects/submodule/__init__.py b/git/objects/submodule/__init__.py
index 82df59b0d..c0604e76f 100644
--- a/git/objects/submodule/__init__.py
+++ b/git/objects/submodule/__init__.py
@@ -1,2 +1,7 @@
-# NOTE: Cannot import anything here as the top-level _init_ has to handle
-# our dependencies
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["Submodule", "UpdateProgress", "RootModule", "RootUpdateProgress"]
+
+from .base import Submodule, UpdateProgress
+from .root import RootModule, RootUpdateProgress
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index e055cb8c4..5031a2e71 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -1,52 +1,88 @@
-from . import util
-from .util import (
-    mkhead,
-    sm_name,
-    sm_section,
-    unbare_repo,
-    SubmoduleConfigParser,
-    find_first_remote_branch
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["Submodule", "UpdateProgress"]
+
+import gc
+from io import BytesIO
+import logging
+import os
+import os.path as osp
+import stat
+import sys
+import uuid
+import urllib
+
+import git
+from git.cmd import Git
+from git.compat import defenc
+from git.config import GitConfigParser, SectionConstraint, cp
+from git.exc import (
+    BadName,
+    InvalidGitRepositoryError,
+    NoSuchPathError,
+    RepositoryDirtyError,
 )
-from git.objects.util import Traversable
-from io import BytesIO                   # need a dict to set bloody .name field
+from git.objects.base import IndexObject, Object
+from git.objects.util import TraversableIterableObj
 from git.util import (
-    Iterable,
+    IterableList,
+    RemoteProgress,
     join_path_native,
+    rmtree,
     to_native_path_linux,
-    RemoteProgress,
-    rmtree
+    unbare_repo,
 )
 
-from git.config import (
-    SectionConstraint,
-    cp
+from .util import (
+    SubmoduleConfigParser,
+    find_first_remote_branch,
+    mkhead,
+    sm_name,
+    sm_section,
 )
-from git.exc import (
-    InvalidGitRepositoryError,
-    NoSuchPathError
+
+# typing ----------------------------------------------------------------------
+
+from typing import (
+    Any,
+    Callable,
+    Dict,
+    Iterator,
+    Mapping,
+    Sequence,
+    TYPE_CHECKING,
+    Union,
+    cast,
 )
-from git.compat import string_types
 
-import stat
-import git
+if sys.version_info >= (3, 8):
+    from typing import Literal
+else:
+    from typing_extensions import Literal
 
-import os
-import logging
+from git.types import Commit_ish, PathLike, TBD
 
-__all__ = ["Submodule", "UpdateProgress"]
+if TYPE_CHECKING:
+    from git.index import IndexFile
+    from git.objects.commit import Commit
+    from git.refs import Head
+    from git.repo import Repo
 
+# -----------------------------------------------------------------------------
 
-log = logging.getLogger('git.objects.submodule.base')
+_logger = logging.getLogger(__name__)
 
 
 class UpdateProgress(RemoteProgress):
-
     """Class providing detailed progress information to the caller who should
-    derive from it and implement the ``update(...)`` message"""
+    derive from it and implement the
+    :meth:`update(...) <git.util.RemoteProgress.update>` message."""
+
     CLONE, FETCH, UPDWKTREE = [1 << x for x in range(RemoteProgress._num_op_codes, RemoteProgress._num_op_codes + 3)]
-    _num_op_codes = RemoteProgress._num_op_codes + 3
+    _num_op_codes: int = RemoteProgress._num_op_codes + 3
 
-    __slots__ = tuple()
+    __slots__ = ()
 
 
 BEGIN = UpdateProgress.BEGIN
@@ -56,116 +92,174 @@ class UpdateProgress(RemoteProgress):
 UPDWKTREE = UpdateProgress.UPDWKTREE
 
 
-# IndexObject comes via util module, its a 'hacky' fix thanks to pythons import
-# mechanism which cause plenty of trouble of the only reason for packages and
-# modules is refactoring - subpackages shoudn't depend on parent packages
-class Submodule(util.IndexObject, Iterable, Traversable):
-
+# IndexObject comes via the util module. It's a 'hacky' fix thanks to Python's import
+# mechanism, which causes plenty of trouble if the only reason for packages and modules
+# is refactoring - subpackages shouldn't depend on parent packages.
+class Submodule(IndexObject, TraversableIterableObj):
     """Implements access to a git submodule. They are special in that their sha
     represents a commit in the submodule's repository which is to be checked out
     at the path of this instance.
+
     The submodule type does not have a string type associated with it, as it exists
     solely as a marker in the tree and index.
 
-    All methods work in bare and non-bare repositories."""
+    All methods work in bare and non-bare repositories.
+    """
 
     _id_attribute_ = "name"
-    k_modules_file = '.gitmodules'
-    k_head_option = 'branch'
-    k_head_default = 'master'
-    k_default_mode = stat.S_IFDIR | stat.S_IFLNK        # submodules are directories with link-status
-
-    # this is a bogus type for base class compatability
-    type = 'submodule'
-
-    __slots__ = ('_parent_commit', '_url', '_branch_path', '_name', '__weakref__')
-    _cache_attrs = ('path', '_url', '_branch_path')
-
-    def __init__(self, repo, binsha, mode=None, path=None, name=None, parent_commit=None, url=None, branch_path=None):
-        """Initialize this instance with its attributes. We only document the ones
-        that differ from ``IndexObject``
-
-        :param repo: Our parent repository
-        :param binsha: binary sha referring to a commit in the remote repository, see url parameter
-        :param parent_commit: see set_parent_commit()
-        :param url: The url to the remote repository which is the submodule
-        :param branch_path: full (relative) path to ref to checkout when cloning the remote repository"""
-        super(Submodule, self).__init__(repo, binsha, mode, path)
+    k_modules_file = ".gitmodules"
+    k_head_option = "branch"
+    k_head_default = "master"
+    k_default_mode = stat.S_IFDIR | stat.S_IFLNK
+    """Submodule flags. Submodules are directories with link-status."""
+
+    type: Literal["submodule"] = "submodule"  # type: ignore[assignment]
+    """This is a bogus type string for base class compatibility."""
+
+    __slots__ = ("_parent_commit", "_url", "_branch_path", "_name", "__weakref__")
+
+    _cache_attrs = ("path", "_url", "_branch_path")
+
+    def __init__(
+        self,
+        repo: "Repo",
+        binsha: bytes,
+        mode: Union[int, None] = None,
+        path: Union[PathLike, None] = None,
+        name: Union[str, None] = None,
+        parent_commit: Union["Commit", None] = None,
+        url: Union[str, None] = None,
+        branch_path: Union[PathLike, None] = None,
+    ) -> None:
+        """Initialize this instance with its attributes.
+
+        We only document the parameters that differ from
+        :class:`~git.objects.base.IndexObject`.
+
+        :param repo:
+            Our parent repository.
+
+        :param binsha:
+            Binary sha referring to a commit in the remote repository.
+            See the `url` parameter.
+
+        :param parent_commit:
+            The :class:`~git.objects.commit.Commit` whose tree is supposed to contain
+            the ``.gitmodules`` blob, or ``None`` to always point to the most recent
+            commit. See :meth:`set_parent_commit` for details.
+
+        :param url:
+            The URL to the remote repository which is the submodule.
+
+        :param branch_path:
+            Full repository-relative path to ref to checkout when cloning the remote
+            repository.
+        """
+        super().__init__(repo, binsha, mode, path)
         self.size = 0
-        if parent_commit is not None:
-            self._parent_commit = parent_commit
+        self._parent_commit = parent_commit
         if url is not None:
             self._url = url
         if branch_path is not None:
-            assert isinstance(branch_path, string_types)
             self._branch_path = branch_path
         if name is not None:
             self._name = name
 
-    def _set_cache_(self, attr):
-        if attr == '_parent_commit':
-            # set a default value, which is the root tree of the current head
-            self._parent_commit = self.repo.commit()
-        elif attr in ('path', '_url', '_branch_path'):
-            reader = self.config_reader()
-            # default submodule values
-            self.path = reader.get_value('path')
-            self._url = reader.get_value('url')
-            # git-python extension values - optional
+    def _set_cache_(self, attr: str) -> None:
+        if attr in ("path", "_url", "_branch_path"):
+            reader: SectionConstraint = self.config_reader()
+            # Default submodule values.
+            try:
+                self.path = reader.get("path")
+            except cp.NoSectionError as e:
+                if self.repo.working_tree_dir is not None:
+                    raise ValueError(
+                        "This submodule instance does not exist anymore in '%s' file"
+                        % osp.join(self.repo.working_tree_dir, ".gitmodules")
+                    ) from e
+
+            self._url = reader.get("url")
+            # GitPython extension values - optional.
             self._branch_path = reader.get_value(self.k_head_option, git.Head.to_full_path(self.k_head_default))
-        elif attr == '_name':
+        elif attr == "_name":
             raise AttributeError("Cannot retrieve the name of a submodule if it was not set initially")
         else:
-            super(Submodule, self)._set_cache_(attr)
+            super()._set_cache_(attr)
         # END handle attribute name
 
-    def _get_intermediate_items(self, item):
-        """:return: all the submodules of our module repository"""
+    @classmethod
+    def _get_intermediate_items(cls, item: "Submodule") -> IterableList["Submodule"]:
+        """:return: All the submodules of our module repository"""
         try:
-            return type(self).list_items(item.module())
+            return cls.list_items(item.module())
         except InvalidGitRepositoryError:
-            return list()
-        # END handle intermeditate items
-
-    def __eq__(self, other):
-        """Compare with another submodule"""
-        # we may only compare by name as this should be the ID they are hashed with
-        # Otherwise this type wouldn't be hashable
-        # return self.path == other.path and self.url == other.url and super(Submodule, self).__eq__(other)
+            return IterableList("")
+        # END handle intermediate items
+
+    @classmethod
+    def _need_gitfile_submodules(cls, git: Git) -> bool:
+        return git.version_info[:3] >= (1, 7, 5)
+
+    def __eq__(self, other: Any) -> bool:
+        """Compare with another submodule."""
+        # We may only compare by name as this should be the ID they are hashed with.
+        # Otherwise this type wouldn't be hashable.
+        # return self.path == other.path and self.url == other.url and super().__eq__(other)
         return self._name == other._name
 
-    def __ne__(self, other):
-        """Compare with another submodule for inequality"""
+    def __ne__(self, other: object) -> bool:
+        """Compare with another submodule for inequality."""
         return not (self == other)
 
-    def __hash__(self):
-        """Hash this instance using its logical id, not the sha"""
+    def __hash__(self) -> int:
+        """Hash this instance using its logical id, not the sha."""
         return hash(self._name)
 
-    def __str__(self):
+    def __str__(self) -> str:
         return self._name
 
-    def __repr__(self):
-        return "git.%s(name=%s, path=%s, url=%s, branch_path=%s)"\
-               % (type(self).__name__, self._name, self.path, self.url, self.branch_path)
+    def __repr__(self) -> str:
+        return "git.%s(name=%s, path=%s, url=%s, branch_path=%s)" % (
+            type(self).__name__,
+            self._name,
+            self.path,
+            self.url,
+            self.branch_path,
+        )
 
     @classmethod
-    def _config_parser(cls, repo, parent_commit, read_only):
-        """:return: Config Parser constrained to our submodule in read or write mode
-        :raise IOError: If the .gitmodules file cannot be found, either locally or in the repository
-            at the given parent commit. Otherwise the exception would be delayed until the first
-            access of the config parser"""
-        parent_matches_head = repo.head.commit == parent_commit
-        if not repo.bare and parent_matches_head:
-            fp_module = cls.k_modules_file
-            fp_module_path = os.path.join(repo.working_tree_dir, fp_module)
-            fp_module = fp_module_path
+    def _config_parser(
+        cls, repo: "Repo", parent_commit: Union["Commit", None], read_only: bool
+    ) -> SubmoduleConfigParser:
+        """
+        :return:
+            Config parser constrained to our submodule in read or write mode
+
+        :raise IOError:
+            If the ``.gitmodules`` file cannot be found, either locally or in the
+            repository at the given parent commit. Otherwise the exception would be
+            delayed until the first access of the config parser.
+        """
+        parent_matches_head = True
+        if parent_commit is not None:
+            try:
+                parent_matches_head = repo.head.commit == parent_commit
+            except ValueError:
+                # We are most likely in an empty repository, so the HEAD doesn't point
+                # to a valid ref.
+                pass
+        # END handle parent_commit
+        fp_module: Union[str, BytesIO]
+        if not repo.bare and parent_matches_head and repo.working_tree_dir:
+            fp_module = osp.join(repo.working_tree_dir, cls.k_modules_file)
         else:
+            assert parent_commit is not None, "need valid parent_commit in bare repositories"
             try:
                 fp_module = cls._sio_modules(parent_commit)
-            except KeyError:
-                raise IOError("Could not find %s file in the tree of parent commit %s" %
-                              (cls.k_modules_file, parent_commit))
+            except KeyError as e:
+                raise IOError(
+                    "Could not find %s file in the tree of parent commit %s" % (cls.k_modules_file, parent_commit)
+                ) from e
             # END handle exceptions
         # END handle non-bare working tree
 
@@ -175,8 +269,8 @@ def _config_parser(cls, repo, parent_commit, read_only):
 
         return SubmoduleConfigParser(fp_module, read_only=read_only)
 
-    def _clear_cache(self):
-        # clear the possibly changed values
+    def _clear_cache(self) -> None:
+        """Clear the possibly changed values."""
         for name in self._cache_attrs:
             try:
                 delattr(self, name)
@@ -186,83 +280,272 @@ def _clear_cache(self):
         # END for each name to delete
 
     @classmethod
-    def _sio_modules(cls, parent_commit):
-        """:return: Configuration file as BytesIO - we only access it through the respective blob's data"""
+    def _sio_modules(cls, parent_commit: "Commit") -> BytesIO:
+        """
+        :return:
+            Configuration file as :class:`~io.BytesIO` - we only access it through the
+            respective blob's data
+        """
         sio = BytesIO(parent_commit.tree[cls.k_modules_file].data_stream.read())
         sio.name = cls.k_modules_file
         return sio
 
-    def _config_parser_constrained(self, read_only):
-        """:return: Config Parser constrained to our submodule in read or write mode"""
-        parser = self._config_parser(self.repo, self._parent_commit, read_only)
+    def _config_parser_constrained(self, read_only: bool) -> SectionConstraint:
+        """:return: Config parser constrained to our submodule in read or write mode"""
+        try:
+            pc = self.parent_commit
+        except ValueError:
+            pc = None
+        # END handle empty parent repository
+        parser = self._config_parser(self.repo, pc, read_only)
         parser.set_submodule(self)
         return SectionConstraint(parser, sm_section(self.name))
 
-    #{ Edit Interface
+    @classmethod
+    def _module_abspath(cls, parent_repo: "Repo", path: PathLike, name: str) -> PathLike:
+        if cls._need_gitfile_submodules(parent_repo.git):
+            return osp.join(parent_repo.git_dir, "modules", name)
+        if parent_repo.working_tree_dir:
+            return osp.join(parent_repo.working_tree_dir, path)
+        raise NotADirectoryError()
 
     @classmethod
-    def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
-        """Add a new submodule to the given repository. This will alter the index
-        as well as the .gitmodules file, but will not create a new commit.
-        If the submodule already exists, no matter if the configuration differs
-        from the one provided, the existing submodule will be returned.
-
-        :param repo: Repository instance which should receive the submodule
-        :param name: The name/identifier for the submodule
-        :param path: repository-relative or absolute path at which the submodule
-            should be located
-            It will be created as required during the repository initialization.
-        :param url: git-clone compatible URL, see git-clone reference for more information
-            If None, the repository is assumed to exist, and the url of the first
-            remote is taken instead. This is useful if you want to make an existing
-            repository a submodule of anotherone.
-        :param branch: name of branch at which the submodule should (later) be checked out.
-            The given branch must exist in the remote repository, and will be checked
-            out locally as a tracking branch.
-            It will only be written into the configuration if it not None, which is
-            when the checked out branch will be the one the remote HEAD pointed to.
-            The result you get in these situation is somewhat fuzzy, and it is recommended
-            to specify at least 'master' here.
-            Examples are 'master' or 'feature/new'
-        :param no_checkout: if True, and if the repository has to be cloned manually,
-            no checkout will be performed
-        :return: The newly created submodule instance
-        :note: works atomically, such that no change will be done if the repository
-            update fails for instance"""
-        if repo.bare:
-            raise InvalidGitRepositoryError("Cannot add submodules to bare repositories")
-        # END handle bare repos
+    def _clone_repo(
+        cls,
+        repo: "Repo",
+        url: str,
+        path: PathLike,
+        name: str,
+        allow_unsafe_options: bool = False,
+        allow_unsafe_protocols: bool = False,
+        **kwargs: Any,
+    ) -> "Repo":
+        """
+        :return:
+            :class:`~git.repo.base.Repo` instance of newly cloned repository.
+
+        :param repo:
+            Our parent repository.
+
+        :param url:
+            URL to clone from.
+
+        :param path:
+            Repository-relative path to the submodule checkout location.
+
+        :param name:
+            Canonical name of the submodule.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
 
+        :param allow_unsafe_options:
+            Allow unsafe options to be used, like ``--upload-pack``.
+
+        :param kwargs:
+            Additional arguments given to :manpage:`git-clone(1)`.
+        """
+        module_abspath = cls._module_abspath(repo, path, name)
+        module_checkout_path = module_abspath
+        if cls._need_gitfile_submodules(repo.git):
+            kwargs["separate_git_dir"] = module_abspath
+            module_abspath_dir = osp.dirname(module_abspath)
+            if not osp.isdir(module_abspath_dir):
+                os.makedirs(module_abspath_dir)
+            module_checkout_path = osp.join(str(repo.working_tree_dir), path)
+
+        if url.startswith("../"):
+            remote_name = repo.active_branch.tracking_branch().remote_name
+            repo_remote_url = repo.remote(remote_name).url
+            url = os.path.join(repo_remote_url, url)
+
+        clone = git.Repo.clone_from(
+            url,
+            module_checkout_path,
+            allow_unsafe_options=allow_unsafe_options,
+            allow_unsafe_protocols=allow_unsafe_protocols,
+            **kwargs,
+        )
+        if cls._need_gitfile_submodules(repo.git):
+            cls._write_git_file_and_module_config(module_checkout_path, module_abspath)
+
+        return clone
+
+    @classmethod
+    def _to_relative_path(cls, parent_repo: "Repo", path: PathLike) -> PathLike:
+        """:return: A path guaranteed to be relative to the given parent repository
+
+        :raise ValueError:
+            If path is not contained in the parent repository's working tree.
+        """
         path = to_native_path_linux(path)
-        if path.endswith('/'):
+        if path.endswith("/"):
             path = path[:-1]
         # END handle trailing slash
 
-        if os.path.isabs(path):
-            working_tree_linux = to_native_path_linux(repo.working_tree_dir)
+        if osp.isabs(path) and parent_repo.working_tree_dir:
+            working_tree_linux = to_native_path_linux(parent_repo.working_tree_dir)
             if not path.startswith(working_tree_linux):
-                raise ValueError("Submodule checkout path '%s' needs to be within the parents repository at '%s'"
-                                 % (working_tree_linux, path))
-            path = path[len(working_tree_linux) + 1:]
+                raise ValueError(
+                    "Submodule checkout path '%s' needs to be within the parents repository at '%s'"
+                    % (working_tree_linux, path)
+                )
+            path = path[len(working_tree_linux.rstrip("/")) + 1 :]
             if not path:
                 raise ValueError("Absolute submodule path '%s' didn't yield a valid relative path" % path)
-            # end verify converted relative path makes sense
-        # end convert to a relative path
+            # END verify converted relative path makes sense
+        # END convert to a relative path
+
+        return path
+
+    @classmethod
+    def _write_git_file_and_module_config(cls, working_tree_dir: PathLike, module_abspath: PathLike) -> None:
+        """Write a ``.git`` file containing a (preferably) relative path to the actual
+        git module repository.
+
+        It is an error if the `module_abspath` cannot be made into a relative path,
+        relative to the `working_tree_dir`.
+
+        :note:
+            This will overwrite existing files!
 
-        # assure we never put backslashes into the url, as some operating systems
-        # like it ...
+        :note:
+            As we rewrite both the git file as well as the module configuration, we
+            might fail on the configuration and will not roll back changes done to the
+            git file. This should be a non-issue, but may easily be fixed if it becomes
+            one.
+
+        :param working_tree_dir:
+            Directory to write the ``.git`` file into.
+
+        :param module_abspath:
+            Absolute path to the bare repository.
+        """
+        git_file = osp.join(working_tree_dir, ".git")
+        rela_path = osp.relpath(module_abspath, start=working_tree_dir)
+        if sys.platform == "win32" and osp.isfile(git_file):
+            os.remove(git_file)
+        with open(git_file, "wb") as fp:
+            fp.write(("gitdir: %s" % rela_path).encode(defenc))
+
+        with GitConfigParser(osp.join(module_abspath, "config"), read_only=False, merge_includes=False) as writer:
+            writer.set_value(
+                "core",
+                "worktree",
+                to_native_path_linux(osp.relpath(working_tree_dir, start=module_abspath)),
+            )
+
+    # { Edit Interface
+
+    @classmethod
+    def add(
+        cls,
+        repo: "Repo",
+        name: str,
+        path: PathLike,
+        url: Union[str, None] = None,
+        branch: Union[str, None] = None,
+        no_checkout: bool = False,
+        depth: Union[int, None] = None,
+        env: Union[Mapping[str, str], None] = None,
+        clone_multi_options: Union[Sequence[TBD], None] = None,
+        allow_unsafe_options: bool = False,
+        allow_unsafe_protocols: bool = False,
+    ) -> "Submodule":
+        """Add a new submodule to the given repository. This will alter the index as
+        well as the ``.gitmodules`` file, but will not create a new commit. If the
+        submodule already exists, no matter if the configuration differs from the one
+        provided, the existing submodule will be returned.
+
+        :param repo:
+            Repository instance which should receive the submodule.
+
+        :param name:
+            The name/identifier for the submodule.
+
+        :param path:
+            Repository-relative or absolute path at which the submodule should be
+            located.
+            It will be created as required during the repository initialization.
+
+        :param url:
+            ``git clone ...``-compatible URL. See :manpage:`git-clone(1)` for more
+            information. If ``None``, the repository is assumed to exist, and the URL of
+            the first remote is taken instead. This is useful if you want to make an
+            existing repository a submodule of another one.
+
+        :param branch:
+            Name of branch at which the submodule should (later) be checked out. The
+            given branch must exist in the remote repository, and will be checked out
+            locally as a tracking branch.
+            It will only be written into the configuration if it not ``None``, which is
+            when the checked out branch will be the one the remote HEAD pointed to.
+            The result you get in these situation is somewhat fuzzy, and it is
+            recommended to specify at least ``master`` here.
+            Examples are ``master`` or ``feature/new``.
+
+        :param no_checkout:
+            If ``True``, and if the repository has to be cloned manually, no checkout
+            will be performed.
+
+        :param depth:
+            Create a shallow clone with a history truncated to the specified number of
+            commits.
+
+        :param env:
+            Optional dictionary containing the desired environment variables.
+
+            Note: Provided variables will be used to update the execution environment
+            for ``git``. If some variable is not specified in `env` and is defined in
+            attr:`os.environ`, the value from attr:`os.environ` will be used. If you
+            want to unset some variable, consider providing an empty string as its
+            value.
+
+        :param clone_multi_options:
+            A list of clone options. Please see
+            :meth:`Repo.clone <git.repo.base.Repo.clone>` for details.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :param allow_unsafe_options:
+            Allow unsafe options to be used, like ``--upload-pack``.
+
+        :return:
+            The newly created :class:`Submodule` instance.
+
+        :note:
+            Works atomically, such that no change will be done if, for example, the
+            repository update fails.
+        """
+        if repo.bare:
+            raise InvalidGitRepositoryError("Cannot add submodules to bare repositories")
+        # END handle bare repos
+
+        path = cls._to_relative_path(repo, path)
+
+        # Ensure we never put backslashes into the URL, as might happen on Windows.
         if url is not None:
             url = to_native_path_linux(url)
-        # END assure url correctness
+        # END ensure URL correctness
 
         # INSTANTIATE INTERMEDIATE SM
-        sm = cls(repo, cls.NULL_BIN_SHA, cls.k_default_mode, path, name, url='invalid-temporary')
+        sm = cls(
+            repo,
+            cls.NULL_BIN_SHA,
+            cls.k_default_mode,
+            path,
+            name,
+            url="invalid-temporary",
+        )
         if sm.exists():
-            # reretrieve submodule from tree
+            # Reretrieve submodule from tree.
             try:
-                return repo.head.commit.tree[path]
+                sm = repo.head.commit.tree[str(path)]
+                sm._name = name
+                return sm
             except KeyError:
-                # could only be in index
+                # Could only be in index.
                 index = repo.index
                 entry = index.entries[index.entry_key(path, 0)]
                 sm.binsha = entry.binsha
@@ -270,79 +553,174 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
             # END handle exceptions
         # END handle existing
 
-        # fake-repo - we only need the functionality on the branch instance
+        # fake-repo - we only need the functionality on the branch instance.
         br = git.Head(repo, git.Head.to_full_path(str(branch) or cls.k_head_default))
         has_module = sm.module_exists()
         branch_is_default = branch is None
         if has_module and url is not None:
             if url not in [r.url for r in sm.module().remotes]:
                 raise ValueError(
-                    "Specified URL '%s' does not match any remote url of the repository at '%s'" % (url, sm.abspath))
+                    "Specified URL '%s' does not match any remote url of the repository at '%s'" % (url, sm.abspath)
+                )
             # END check url
         # END verify urls match
 
-        mrepo = None
+        mrepo: Union[Repo, None] = None
+
         if url is None:
             if not has_module:
-                raise ValueError("A URL was not given and existing repository did not exsit at %s" % path)
+                raise ValueError("A URL was not given and a repository did not exist at %s" % path)
             # END check url
             mrepo = sm.module()
+            # assert isinstance(mrepo, git.Repo)
             urls = [r.url for r in mrepo.remotes]
             if not urls:
                 raise ValueError("Didn't find any remote url in repository at %s" % sm.abspath)
             # END verify we have url
             url = urls[0]
         else:
-            # clone new repo
-            kwargs = {'n': no_checkout}
+            # Clone new repo.
+            kwargs: Dict[str, Union[bool, int, str, Sequence[TBD]]] = {"n": no_checkout}
             if not branch_is_default:
-                kwargs['b'] = br.name
+                kwargs["b"] = br.name
             # END setup checkout-branch
-            mrepo = git.Repo.clone_from(url, os.path.join(repo.working_tree_dir, path), **kwargs)
+
+            if depth:
+                if isinstance(depth, int):
+                    kwargs["depth"] = depth
+                else:
+                    raise ValueError("depth should be an integer")
+            if clone_multi_options:
+                kwargs["multi_options"] = clone_multi_options
+
+            # _clone_repo(cls, repo, url, path, name, **kwargs):
+            mrepo = cls._clone_repo(
+                repo,
+                url,
+                path,
+                name,
+                env=env,
+                allow_unsafe_options=allow_unsafe_options,
+                allow_unsafe_protocols=allow_unsafe_protocols,
+                **kwargs,
+            )
         # END verify url
 
-        # update configuration and index
+        ## See #525 for ensuring git URLs in config-files are valid under Windows.
+        url = Git.polish_url(url)
+
+        # It's important to add the URL to the parent config, to let `git submodule` know.
+        # Otherwise there is a '-' character in front of the submodule listing:
+        #  a38efa84daef914e4de58d1905a500d8d14aaf45 mymodule (v0.9.0-1-ga38efa8)
+        # -a38efa84daef914e4de58d1905a500d8d14aaf45 submodules/intermediate/one
+        writer: Union[GitConfigParser, SectionConstraint]
+
+        with sm.repo.config_writer() as writer:
+            writer.set_value(sm_section(name), "url", url)
+
+        # Update configuration and index.
         index = sm.repo.index
-        writer = sm.config_writer(index=index, write=False)
-        writer.set_value('url', url)
-        writer.set_value('path', path)
-
-        sm._url = url
-        if not branch_is_default:
-            # store full path
-            writer.set_value(cls.k_head_option, br.path)
-            sm._branch_path = br.path
-        # END handle path
-        writer.release()
-        del(writer)
-
-        # we deliberatly assume that our head matches our index !
-        pcommit = repo.head.commit
-        sm._parent_commit = pcommit
-        sm.binsha = mrepo.head.commit.binsha
+        with sm.config_writer(index=index, write=False) as writer:
+            writer.set_value("url", url)
+            writer.set_value("path", path)
+
+            sm._url = url
+            if not branch_is_default:
+                # Store full path.
+                writer.set_value(cls.k_head_option, br.path)
+                sm._branch_path = br.path
+
+        # We deliberately assume that our head matches our index!
+        if mrepo:
+            sm.binsha = mrepo.head.commit.binsha
         index.add([sm], write=True)
 
         return sm
 
-    def update(self, recursive=False, init=True, to_latest_revision=False, progress=None,
-               dry_run=False):
-        """Update the repository of this submodule to point to the checkout
-        we point at with the binsha of this instance.
-
-        :param recursive: if True, we will operate recursively and update child-
-            modules as well.
-        :param init: if True, the module repository will be cloned into place if necessary
-        :param to_latest_revision: if True, the submodule's sha will be ignored during checkout.
-            Instead, the remote will be fetched, and the local tracking branch updated.
-            This only works if we have a local tracking branch, which is the case
-            if the remote repository had a master branch, or of the 'branch' option
-            was specified for this submodule and the branch existed remotely
-        :param progress: UpdateProgress instance or None of no progress should be shown
-        :param dry_run: if True, the operation will only be simulated, but not performed.
-            All performed operations are read-only
-        :note: does nothing in bare repositories
-        :note: method is definitely not atomic if recurisve is True
-        :return: self"""
+    def update(
+        self,
+        recursive: bool = False,
+        init: bool = True,
+        to_latest_revision: bool = False,
+        progress: Union["UpdateProgress", None] = None,
+        dry_run: bool = False,
+        force: bool = False,
+        keep_going: bool = False,
+        env: Union[Mapping[str, str], None] = None,
+        clone_multi_options: Union[Sequence[TBD], None] = None,
+        allow_unsafe_options: bool = False,
+        allow_unsafe_protocols: bool = False,
+    ) -> "Submodule":
+        """Update the repository of this submodule to point to the checkout we point at
+        with the binsha of this instance.
+
+        :param recursive:
+            If ``True``, we will operate recursively and update child modules as well.
+
+        :param init:
+            If ``True``, the module repository will be cloned into place if necessary.
+
+        :param to_latest_revision:
+            If ``True``, the submodule's sha will be ignored during checkout. Instead,
+            the remote will be fetched, and the local tracking branch updated. This only
+            works if we have a local tracking branch, which is the case if the remote
+            repository had a master branch, or if the ``branch`` option was specified
+            for this submodule and the branch existed remotely.
+
+        :param progress:
+            :class:`UpdateProgress` instance, or ``None`` if no progress should be
+            shown.
+
+        :param dry_run:
+            If ``True``, the operation will only be simulated, but not performed.
+            All performed operations are read-only.
+
+        :param force:
+            If ``True``, we may reset heads even if the repository in question is dirty.
+            Additionally we will be allowed to set a tracking branch which is ahead of
+            its remote branch back into the past or the location of the remote branch.
+            This will essentially 'forget' commits.
+
+            If ``False``, local tracking branches that are in the future of their
+            respective remote branches will simply not be moved.
+
+        :param keep_going:
+            If ``True``, we will ignore but log all errors, and keep going recursively.
+            Unless `dry_run` is set as well, `keep_going` could cause
+            subsequent/inherited errors you wouldn't see otherwise.
+            In conjunction with `dry_run`, it can be useful to anticipate all errors
+            when updating submodules.
+
+        :param env:
+            Optional dictionary containing the desired environment variables.
+
+            Note: Provided variables will be used to update the execution environment
+            for ``git``. If some variable is not specified in `env` and is defined in
+            attr:`os.environ`, value from attr:`os.environ` will be used.
+
+            If you want to unset some variable, consider providing the empty string as
+            its value.
+
+        :param clone_multi_options:
+            List of :manpage:`git-clone(1)` options.
+            Please see :meth:`Repo.clone <git.repo.base.Repo.clone>` for details.
+            They only take effect with the `init` option.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :param allow_unsafe_options:
+            Allow unsafe options to be used, like ``--upload-pack``.
+
+        :note:
+            Does nothing in bare repositories.
+
+        :note:
+            This method is definitely not atomic if `recursive` is ``True``.
+
+        :return:
+            self
+        """
         if self.repo.bare:
             return self
         # END pass in bare mode
@@ -350,148 +728,246 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
         if progress is None:
             progress = UpdateProgress()
         # END handle progress
-        prefix = ''
+        prefix = ""
         if dry_run:
             prefix = "DRY-RUN: "
         # END handle prefix
 
-        # to keep things plausible in dry-run mode
+        # To keep things plausible in dry-run mode.
         if dry_run:
             mrepo = None
         # END init mrepo
 
-        # ASSURE REPO IS PRESENT AND UPTODATE
-        #####################################
         try:
-            mrepo = self.module()
-            rmts = mrepo.remotes
-            len_rmts = len(rmts)
-            for i, remote in enumerate(rmts):
-                op = FETCH
-                if i == 0:
-                    op |= BEGIN
-                # END handle start
-
-                progress.update(op, i, len_rmts, prefix + "Fetching remote %s of submodule %r" % (remote, self.name))
-                #===============================
+            # ENSURE REPO IS PRESENT AND UP-TO-DATE
+            #######################################
+            try:
+                mrepo = self.module()
+                rmts = mrepo.remotes
+                len_rmts = len(rmts)
+                for i, remote in enumerate(rmts):
+                    op = FETCH
+                    if i == 0:
+                        op |= BEGIN
+                    # END handle start
+
+                    progress.update(
+                        op,
+                        i,
+                        len_rmts,
+                        prefix + "Fetching remote %s of submodule %r" % (remote, self.name),
+                    )
+                    # ===============================
+                    if not dry_run:
+                        remote.fetch(progress=progress)
+                    # END handle dry-run
+                    # ===============================
+                    if i == len_rmts - 1:
+                        op |= END
+                    # END handle end
+                    progress.update(
+                        op,
+                        i,
+                        len_rmts,
+                        prefix + "Done fetching remote of submodule %r" % self.name,
+                    )
+                # END fetch new data
+            except InvalidGitRepositoryError:
+                mrepo = None
+                if not init:
+                    return self
+                # END early abort if init is not allowed
+
+                # There is no git-repository yet - but delete empty paths.
+                checkout_module_abspath = self.abspath
+                if not dry_run and osp.isdir(checkout_module_abspath):
+                    try:
+                        os.rmdir(checkout_module_abspath)
+                    except OSError as e:
+                        raise OSError(
+                            "Module directory at %r does already exist and is non-empty" % checkout_module_abspath
+                        ) from e
+                    # END handle OSError
+                # END handle directory removal
+
+                # Don't check it out at first - nonetheless it will create a local
+                # branch according to the remote-HEAD if possible.
+                progress.update(
+                    BEGIN | CLONE,
+                    0,
+                    1,
+                    prefix
+                    + "Cloning url '%s' to '%s' in submodule %r" % (self.url, checkout_module_abspath, self.name),
+                )
                 if not dry_run:
-                    remote.fetch(progress=progress)
+                    if self.url.startswith("."):
+                        url = urllib.parse.urljoin(self.repo.remotes.origin.url + "/", self.url)
+                    else:
+                        url = self.url
+                    mrepo = self._clone_repo(
+                        self.repo,
+                        url,
+                        self.path,
+                        self.name,
+                        n=True,
+                        env=env,
+                        multi_options=clone_multi_options,
+                        allow_unsafe_options=allow_unsafe_options,
+                        allow_unsafe_protocols=allow_unsafe_protocols,
+                    )
                 # END handle dry-run
-                #===============================
-                if i == len_rmts - 1:
-                    op |= END
-                # END handle end
-                progress.update(op, i, len_rmts, prefix + "Done fetching remote of submodule %r" % self.name)
-            # END fetch new data
-        except InvalidGitRepositoryError:
-            if not init:
-                return self
-            # END early abort if init is not allowed
-            import git
-
-            # there is no git-repository yet - but delete empty paths
-            module_path = join_path_native(self.repo.working_tree_dir, self.path)
-            if not dry_run and os.path.isdir(module_path):
-                try:
-                    os.rmdir(module_path)
-                except OSError:
-                    raise OSError("Module directory at %r does already exist and is non-empty" % module_path)
-                # END handle OSError
-            # END handle directory removal
-
-            # don't check it out at first - nonetheless it will create a local
-            # branch according to the remote-HEAD if possible
-            progress.update(BEGIN | CLONE, 0, 1, prefix + "Cloning %s to %s in submodule %r" %
-                            (self.url, module_path, self.name))
-            if not dry_run:
-                mrepo = git.Repo.clone_from(self.url, module_path, n=True)
-            # END handle dry-run
-            progress.update(END | CLONE, 0, 1, prefix + "Done cloning to %s" % module_path)
-
-            if not dry_run:
-                # see whether we have a valid branch to checkout
-                try:
-                    # find  a remote which has our branch - we try to be flexible
-                    remote_branch = find_first_remote_branch(mrepo.remotes, self.branch_name)
-                    local_branch = mkhead(mrepo, self.branch_path)
-
-                    # have a valid branch, but no checkout - make sure we can figure
-                    # that out by marking the commit with a null_sha
-                    local_branch.set_object(util.Object(mrepo, self.NULL_BIN_SHA))
-                    # END initial checkout + branch creation
-
-                    # make sure HEAD is not detached
-                    mrepo.head.set_reference(local_branch, logmsg="submodule: attaching head to %s" % local_branch)
-                    mrepo.head.ref.set_tracking_branch(remote_branch)
-                except IndexError:
-                    log.warn("Failed to checkout tracking branch %s", self.branch_path)
-                # END handle tracking branch
-
-                # NOTE: Have to write the repo config file as well, otherwise
-                # the default implementation will be offended and not update the repository
-                # Maybe this is a good way to assure it doesn't get into our way, but
-                # we want to stay backwards compatible too ... . Its so redundant !
-                writer = self.repo.config_writer()
-                writer.set_value(sm_section(self.name), 'url', self.url)
-                writer.release()
+                progress.update(
+                    END | CLONE,
+                    0,
+                    1,
+                    prefix + "Done cloning to %s" % checkout_module_abspath,
+                )
+
+                if not dry_run:
+                    # See whether we have a valid branch to check out.
+                    try:
+                        mrepo = cast("Repo", mrepo)
+                        # Find a remote which has our branch - we try to be flexible.
+                        remote_branch = find_first_remote_branch(mrepo.remotes, self.branch_name)
+                        local_branch = mkhead(mrepo, self.branch_path)
+
+                        # Have a valid branch, but no checkout - make sure we can figure
+                        # that out by marking the commit with a null_sha.
+                        local_branch.set_object(Object(mrepo, self.NULL_BIN_SHA))
+                        # END initial checkout + branch creation
+
+                        # Make sure HEAD is not detached.
+                        mrepo.head.set_reference(
+                            local_branch,
+                            logmsg="submodule: attaching head to %s" % local_branch,
+                        )
+                        mrepo.head.reference.set_tracking_branch(remote_branch)
+                    except (IndexError, InvalidGitRepositoryError):
+                        _logger.warning("Failed to checkout tracking branch %s", self.branch_path)
+                    # END handle tracking branch
+
+                    # NOTE: Have to write the repo config file as well, otherwise the
+                    # default implementation will be offended and not update the
+                    # repository. Maybe this is a good way to ensure it doesn't get into
+                    # our way, but we want to stay backwards compatible too... It's so
+                    # redundant!
+                    with self.repo.config_writer() as writer:
+                        writer.set_value(sm_section(self.name), "url", self.url)
+                # END handle dry_run
+            # END handle initialization
+
+            # DETERMINE SHAS TO CHECK OUT
+            #############################
+            binsha = self.binsha
+            hexsha = self.hexsha
+            if mrepo is not None:
+                # mrepo is only set if we are not in dry-run mode or if the module
+                # existed.
+                is_detached = mrepo.head.is_detached
             # END handle dry_run
-        # END handle initalization
-
-        # DETERMINE SHAS TO CHECKOUT
-        ############################
-        binsha = self.binsha
-        hexsha = self.hexsha
-        if mrepo is not None:
-            # mrepo is only set if we are not in dry-run mode or if the module existed
-            is_detached = mrepo.head.is_detached
-        # END handle dry_run
-
-        if mrepo is not None and to_latest_revision:
-            msg_base = "Cannot update to latest revision in repository at %r as " % mrepo.working_dir
-            if not is_detached:
-                rref = mrepo.head.ref.tracking_branch()
-                if rref is not None:
-                    rcommit = rref.commit
-                    binsha = rcommit.binsha
-                    hexsha = rcommit.hexsha
-                else:
-                    log.error("%s a tracking branch was not set for local branch '%s'", msg_base, mrepo.head.ref)
-                # END handle remote ref
-            else:
-                log.error("%s there was no local tracking branch", msg_base)
-            # END handle detached head
-        # END handle to_latest_revision option
-
-        # update the working tree
-        # handles dry_run
-        if mrepo is not None and mrepo.head.commit.binsha != binsha:
-            progress.update(BEGIN | UPDWKTREE, 0, 1, prefix +
-                            "Updating working tree at %s for submodule %r to revision %s"
-                            % (self.path, self.name, hexsha))
-            if not dry_run:
-                if is_detached:
-                    # NOTE: for now we force, the user is no supposed to change detached
-                    # submodules anyway. Maybe at some point this becomes an option, to
-                    # properly handle user modifications - see below for future options
-                    # regarding rebase and merge.
-                    mrepo.git.checkout(hexsha, force=True)
+
+            if mrepo is not None and to_latest_revision:
+                msg_base = "Cannot update to latest revision in repository at %r as " % mrepo.working_dir
+                if not is_detached:
+                    rref = mrepo.head.reference.tracking_branch()
+                    if rref is not None:
+                        rcommit = rref.commit
+                        binsha = rcommit.binsha
+                        hexsha = rcommit.hexsha
+                    else:
+                        _logger.error(
+                            "%s a tracking branch was not set for local branch '%s'",
+                            msg_base,
+                            mrepo.head.reference,
+                        )
+                    # END handle remote ref
                 else:
-                    # TODO: allow to specify a rebase, merge, or reset
-                    # TODO: Warn if the hexsha forces the tracking branch off the remote
-                    # branch - this should be prevented when setting the branch option
-                    mrepo.head.reset(hexsha, index=True, working_tree=True)
-                # END handle checkout
-            # END handle dry_run
-            progress.update(END | UPDWKTREE, 0, 1, prefix + "Done updating working tree for submodule %r" % self.name)
-        # END update to new commit only if needed
+                    _logger.error("%s there was no local tracking branch", msg_base)
+                # END handle detached head
+            # END handle to_latest_revision option
+
+            # Update the working tree.
+            # Handles dry_run.
+            if mrepo is not None and mrepo.head.commit.binsha != binsha:
+                # We must ensure that our destination sha (the one to point to) is in
+                # the future of our current head. Otherwise, we will reset changes that
+                # might have been done on the submodule, but were not yet pushed. We
+                # also handle the case that history has been rewritten, leaving no
+                # merge-base. In that case we behave conservatively, protecting possible
+                # changes the user had done.
+                may_reset = True
+                if mrepo.head.commit.binsha != self.NULL_BIN_SHA:
+                    base_commit = mrepo.merge_base(mrepo.head.commit, hexsha)
+                    if len(base_commit) == 0 or (base_commit[0] is not None and base_commit[0].hexsha == hexsha):
+                        if force:
+                            msg = "Will force checkout or reset on local branch that is possibly in the future of"
+                            msg += " the commit it will be checked out to, effectively 'forgetting' new commits"
+                            _logger.debug(msg)
+                        else:
+                            msg = "Skipping %s on branch '%s' of submodule repo '%s' as it contains un-pushed commits"
+                            msg %= (
+                                is_detached and "checkout" or "reset",
+                                mrepo.head,
+                                mrepo,
+                            )
+                            _logger.info(msg)
+                            may_reset = False
+                        # END handle force
+                    # END handle if we are in the future
+
+                    if may_reset and not force and mrepo.is_dirty(index=True, working_tree=True, untracked_files=True):
+                        raise RepositoryDirtyError(mrepo, "Cannot reset a dirty repository")
+                    # END handle force and dirty state
+                # END handle empty repo
+
+                # END verify future/past
+                progress.update(
+                    BEGIN | UPDWKTREE,
+                    0,
+                    1,
+                    prefix
+                    + "Updating working tree at %s for submodule %r to revision %s" % (self.path, self.name, hexsha),
+                )
+
+                if not dry_run and may_reset:
+                    if is_detached:
+                        # NOTE: For now we force. The user is not supposed to change
+                        # detached submodules anyway. Maybe at some point this becomes
+                        # an option, to properly handle user modifications - see below
+                        # for future options regarding rebase and merge.
+                        mrepo.git.checkout(hexsha, force=force)
+                    else:
+                        mrepo.head.reset(hexsha, index=True, working_tree=True)
+                    # END handle checkout
+                # If we may reset/checkout.
+                progress.update(
+                    END | UPDWKTREE,
+                    0,
+                    1,
+                    prefix + "Done updating working tree for submodule %r" % self.name,
+                )
+            # END update to new commit only if needed
+        except Exception as err:
+            if not keep_going:
+                raise
+            _logger.error(str(err))
+        # END handle keep_going
 
         # HANDLE RECURSION
         ##################
         if recursive:
-            # in dry_run mode, the module might not exist
+            # In dry_run mode, the module might not exist.
             if mrepo is not None:
                 for submodule in self.iter_items(self.module()):
-                    submodule.update(recursive, init, to_latest_revision, progress=progress, dry_run=dry_run)
+                    submodule.update(
+                        recursive,
+                        init,
+                        to_latest_revision,
+                        progress=progress,
+                        dry_run=dry_run,
+                        force=force,
+                        keep_going=keep_going,
+                    )
                 # END handle recursive update
             # END handle dry run
         # END for each submodule
@@ -499,153 +975,211 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
         return self
 
     @unbare_repo
-    def move(self, module_path, configuration=True, module=True):
+    def move(self, module_path: PathLike, configuration: bool = True, module: bool = True) -> "Submodule":
         """Move the submodule to a another module path. This involves physically moving
         the repository at our current path, changing the configuration, as well as
         adjusting our index entry accordingly.
 
-        :param module_path: the path to which to move our module, given as
-            repository-relative path. Intermediate directories will be created
-            accordingly. If the path already exists, it must be empty.
-            Trailling (back)slashes are removed automatically
-        :param configuration: if True, the configuration will be adjusted to let
-            the submodule point to the given path.
-        :param module: if True, the repository managed by this submodule
-            will be moved, not the configuration. This will effectively
-            leave your repository in an inconsistent state unless the configuration
-            and index already point to the target location.
-        :return: self
-        :raise ValueError: if the module path existed and was not empty, or was a file
-        :note: Currently the method is not atomic, and it could leave the repository
-            in an inconsistent state if a sub-step fails for some reason
+        :param module_path:
+            The path to which to move our module in the parent repository's working
+            tree, given as repository-relative or absolute path. Intermediate
+            directories will be created accordingly. If the path already exists, it must
+            be empty. Trailing (back)slashes are removed automatically.
+
+        :param configuration:
+            If ``True``, the configuration will be adjusted to let the submodule point
+            to the given path.
+
+        :param module:
+            If ``True``, the repository managed by this submodule will be moved as well.
+            If ``False``, we don't move the submodule's checkout, which may leave the
+            parent repository in an inconsistent state.
+
+        :return:
+            self
+
+        :raise ValueError:
+            If the module path existed and was not empty, or was a file.
+
+        :note:
+            Currently the method is not atomic, and it could leave the repository in an
+            inconsistent state if a sub-step fails for some reason.
         """
         if module + configuration < 1:
             raise ValueError("You must specify to move at least the module or the configuration of the submodule")
         # END handle input
 
-        module_path = to_native_path_linux(module_path)
-        if module_path.endswith('/'):
-            module_path = module_path[:-1]
-        # END handle trailing slash
+        module_checkout_path = self._to_relative_path(self.repo, module_path)
 
         # VERIFY DESTINATION
-        if module_path == self.path:
+        if module_checkout_path == self.path:
             return self
         # END handle no change
 
-        dest_path = join_path_native(self.repo.working_tree_dir, module_path)
-        if os.path.isfile(dest_path):
-            raise ValueError("Cannot move repository onto a file: %s" % dest_path)
+        module_checkout_abspath = join_path_native(str(self.repo.working_tree_dir), module_checkout_path)
+        if osp.isfile(module_checkout_abspath):
+            raise ValueError("Cannot move repository onto a file: %s" % module_checkout_abspath)
         # END handle target files
 
         index = self.repo.index
-        tekey = index.entry_key(module_path, 0)
+        tekey = index.entry_key(module_checkout_path, 0)
         # if the target item already exists, fail
         if configuration and tekey in index.entries:
-            raise ValueError("Index entry for target path did alredy exist")
+            raise ValueError("Index entry for target path did already exist")
         # END handle index key already there
 
-        # remove existing destination
+        # Remove existing destination.
         if module:
-            if os.path.exists(dest_path):
-                if len(os.listdir(dest_path)):
+            if osp.exists(module_checkout_abspath):
+                if len(os.listdir(module_checkout_abspath)):
                     raise ValueError("Destination module directory was not empty")
-                # END handle non-emptyness
+                # END handle non-emptiness
 
-                if os.path.islink(dest_path):
-                    os.remove(dest_path)
+                if osp.islink(module_checkout_abspath):
+                    os.remove(module_checkout_abspath)
                 else:
-                    os.rmdir(dest_path)
+                    os.rmdir(module_checkout_abspath)
                 # END handle link
             else:
-                # recreate parent directories
-                # NOTE: renames() does that now
+                # Recreate parent directories.
+                # NOTE: renames() does that now.
                 pass
-            # END handle existance
+            # END handle existence
         # END handle module
 
-        # move the module into place if possible
+        # Move the module into place if possible.
         cur_path = self.abspath
         renamed_module = False
-        if module and os.path.exists(cur_path):
-            os.renames(cur_path, dest_path)
+        if module and osp.exists(cur_path):
+            os.renames(cur_path, module_checkout_abspath)
             renamed_module = True
+
+            if osp.isfile(osp.join(module_checkout_abspath, ".git")):
+                module_abspath = self._module_abspath(self.repo, self.path, self.name)
+                self._write_git_file_and_module_config(module_checkout_abspath, module_abspath)
+            # END handle git file rewrite
         # END move physical module
 
-        # rename the index entry - have to manipulate the index directly as
-        # git-mv cannot be used on submodules ... yeah
+        # Rename the index entry - we have to manipulate the index directly as git-mv
+        # cannot be used on submodules... yeah.
+        previous_sm_path = self.path
         try:
             if configuration:
                 try:
                     ekey = index.entry_key(self.path, 0)
                     entry = index.entries[ekey]
-                    del(index.entries[ekey])
-                    nentry = git.IndexEntry(entry[:3] + (module_path,) + entry[4:])
+                    del index.entries[ekey]
+                    nentry = git.IndexEntry(entry[:3] + (module_checkout_path,) + entry[4:])
                     index.entries[tekey] = nentry
-                except KeyError:
-                    raise InvalidGitRepositoryError("Submodule's entry at %r did not exist" % (self.path))
+                except KeyError as e:
+                    raise InvalidGitRepositoryError("Submodule's entry at %r did not exist" % (self.path)) from e
                 # END handle submodule doesn't exist
 
-                # update configuration
-                writer = self.config_writer(index=index)        # auto-write
-                writer.set_value('path', module_path)
-                self.path = module_path
-                writer.release()
-                del(writer)
+                # Update configuration.
+                with self.config_writer(index=index) as writer:  # Auto-write.
+                    writer.set_value("path", module_checkout_path)
+                    self.path = module_checkout_path
             # END handle configuration flag
         except Exception:
             if renamed_module:
-                os.renames(dest_path, cur_path)
+                os.renames(module_checkout_abspath, cur_path)
             # END undo module renaming
             raise
         # END handle undo rename
 
+        # Auto-rename submodule if its name was 'default', that is, the checkout
+        # directory.
+        if previous_sm_path == self.name:
+            self.rename(module_checkout_path)
+
         return self
 
     @unbare_repo
-    def remove(self, module=True, force=False, configuration=True, dry_run=False):
+    def remove(
+        self,
+        module: bool = True,
+        force: bool = False,
+        configuration: bool = True,
+        dry_run: bool = False,
+    ) -> "Submodule":
         """Remove this submodule from the repository. This will remove our entry
-        from the .gitmodules file and the entry in the .git/config file.
-
-        :param module: If True, the module we point to will be deleted
-            as well. If the module is currently on a commit which is not part
-            of any branch in the remote, if the currently checked out branch
-            working tree, or untracked files,
-            is ahead of its tracking branch,  if you have modifications in the
-            In case the removal of the repository fails for these reasons, the
-            submodule status will not have been altered.
-            If this submodule has child-modules on its own, these will be deleted
-            prior to touching the own module.
-        :param force: Enforces the deletion of the module even though it contains
-            modifications. This basically enforces a brute-force file system based
-            deletion.
-        :param configuration: if True, the submodule is deleted from the configuration,
-            otherwise it isn't. Although this should be enabled most of the times,
-            this flag enables you to safely delete the repository of your submodule.
-        :param dry_run: if True, we will not actually do anything, but throw the errors
-            we would usually throw
-        :return: self
-        :note: doesn't work in bare repositories
-        :raise InvalidGitRepositoryError: thrown if the repository cannot be deleted
-        :raise OSError: if directories or files could not be removed"""
-        if not (module + configuration):
-            raise ValueError("Need to specify to delete at least the module, or the configuration")
-        # END handle params
+        from the ``.gitmodules`` file and the entry in the ``.git/config`` file.
+
+        :param module:
+            If ``True``, the checked out module we point to will be deleted as well. If
+            that module is currently on a commit outside any branch in the remote, or if
+            it is ahead of its tracking branch, or if there are modified or untracked
+            files in its working tree, then the removal will fail. In case the removal
+            of the repository fails for these reasons, the submodule status will not
+            have been altered.
+
+            If this submodule has child modules of its own, these will be deleted prior
+            to touching the direct submodule.
+
+        :param force:
+            Enforces the deletion of the module even though it contains modifications.
+            This basically enforces a brute-force file system based deletion.
+
+        :param configuration:
+            If ``True``, the submodule is deleted from the configuration, otherwise it
+            isn't. Although this should be enabled most of the time, this flag enables
+            you to safely delete the repository of your submodule.
+
+        :param dry_run:
+            If ``True``, we will not actually do anything, but throw the errors we would
+            usually throw.
+
+        :return:
+            self
+
+        :note:
+            Doesn't work in bare repositories.
+
+        :note:
+            Doesn't work atomically, as failure to remove any part of the submodule will
+            leave an inconsistent state.
+
+        :raise git.exc.InvalidGitRepositoryError:
+            Thrown if the repository cannot be deleted.
 
-        # DELETE MODULE REPOSITORY
-        ##########################
+        :raise OSError:
+            If directories or files could not be removed.
+        """
+        if not (module or configuration):
+            raise ValueError("Need to specify to delete at least the module, or the configuration")
+        # END handle parameters
+
+        # Recursively remove children of this submodule.
+        nc = 0
+        for csm in self.children():
+            nc += 1
+            csm.remove(module, force, configuration, dry_run)
+            del csm
+
+        if configuration and not dry_run and nc > 0:
+            # Ensure we don't leave the parent repository in a dirty state, and commit
+            # our changes. It's important for recursive, unforced, deletions to work as
+            # expected.
+            self.module().index.commit("Removed at least one of child-modules of '%s'" % self.name)
+        # END handle recursion
+
+        # DELETE REPOSITORY WORKING TREE
+        ################################
         if module and self.module_exists():
+            mod = self.module()
+            git_dir = mod.git_dir
             if force:
-                # take the fast lane and just delete everything in our module path
-                # TODO: If we run into permission problems, we have a highly inconsistent
-                # state. Delete the .git folders last, start with the submodules first
+                # Take the fast lane and just delete everything in our module path.
+                # TODO: If we run into permission problems, we have a highly
+                # inconsistent state. Delete the .git folders last, start with the
+                # submodules first.
                 mp = self.abspath
-                method = None
-                if os.path.islink(mp):
+                method: Union[None, Callable[[PathLike], None]] = None
+                if osp.islink(mp):
                     method = os.remove
-                elif os.path.isdir(mp):
+                elif osp.isdir(mp):
                     method = rmtree
-                elif os.path.exists(mp):
+                elif osp.exists(mp):
                     raise AssertionError("Cannot forcibly delete repository as it was neither a link, nor a directory")
                 # END handle brutal deletion
                 if not dry_run:
@@ -653,92 +1187,111 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False):
                     method(mp)
                 # END apply deletion method
             else:
-                # verify we may delete our module
-                mod = self.module()
-                if mod.is_dirty(untracked_files=True):
+                # Verify we may delete our module.
+                if mod.is_dirty(index=True, working_tree=True, untracked_files=True):
                     raise InvalidGitRepositoryError(
                         "Cannot delete module at %s with any modifications, unless force is specified"
-                        % mod.working_tree_dir)
+                        % mod.working_tree_dir
+                    )
                 # END check for dirt
 
-                # figure out whether we have new commits compared to the remotes
-                # NOTE: If the user pulled all the time, the remote heads might
-                # not have been updated, so commits coming from the remote look
-                # as if they come from us. But we stay strictly read-only and
-                # don't fetch beforhand.
+                # Figure out whether we have new commits compared to the remotes.
+                # NOTE: If the user pulled all the time, the remote heads might not have
+                # been updated, so commits coming from the remote look as if they come
+                # from us. But we stay strictly read-only and don't fetch beforehand.
                 for remote in mod.remotes:
                     num_branches_with_new_commits = 0
                     rrefs = remote.refs
                     for rref in rrefs:
                         num_branches_with_new_commits += len(mod.git.cherry(rref)) != 0
                     # END for each remote ref
-                    # not a single remote branch contained all our commits
-                    if num_branches_with_new_commits == len(rrefs):
+                    # Not a single remote branch contained all our commits.
+                    if len(rrefs) and num_branches_with_new_commits == len(rrefs):
                         raise InvalidGitRepositoryError(
-                            "Cannot delete module at %s as there are new commits" % mod.working_tree_dir)
+                            "Cannot delete module at %s as there are new commits" % mod.working_tree_dir
+                        )
                     # END handle new commits
-                    # have to manually delete references as python's scoping is
-                    # not existing, they could keep handles open ( on windows this is a problem )
+                    # We have to manually delete some references to allow resources to
+                    # be cleaned up immediately when we are done with them, because
+                    # Python's scoping is no more granular than the whole function (loop
+                    # bodies are not scopes). When the objects stay alive longer, they
+                    # can keep handles open. On Windows, this is a problem.
                     if len(rrefs):
-                        del(rref)
+                        del rref  # skipcq: PYL-W0631
                     # END handle remotes
-                    del(rrefs)
-                    del(remote)
+                    del rrefs
+                    del remote
                 # END for each remote
 
-                # gently remove all submodule repositories
-                for sm in self.children():
-                    sm.remove(module=True, force=False, configuration=False, dry_run=dry_run)
-                    del(sm)
-                # END for each child-submodule
-
-                # finally delete our own submodule
+                # Finally delete our own submodule.
                 if not dry_run:
+                    self._clear_cache()
                     wtd = mod.working_tree_dir
-                    del(mod)        # release file-handles (windows)
-                    rmtree(wtd)
+                    del mod  # Release file-handles (Windows).
+                    gc.collect()
+                    rmtree(str(wtd))
                 # END delete tree if possible
             # END handle force
+
+            if not dry_run and osp.isdir(git_dir):
+                self._clear_cache()
+                rmtree(git_dir)
+            # END handle separate bare repository
         # END handle module deletion
 
+        # Void our data so as not to delay invalid access.
+        if not dry_run:
+            self._clear_cache()
+
         # DELETE CONFIGURATION
         ######################
         if configuration and not dry_run:
-            # first the index-entry
-            index = self.repo.index
+            # First the index-entry.
+            parent_index = self.repo.index
             try:
-                del(index.entries[index.entry_key(self.path, 0)])
+                del parent_index.entries[parent_index.entry_key(self.path, 0)]
             except KeyError:
                 pass
             # END delete entry
-            index.write()
-
-            # now git config - need the config intact, otherwise we can't query
-            # inforamtion anymore
-            writer = self.repo.config_writer()
-            writer.remove_section(sm_section(self.name))
-            writer.release()
-            writer = self.config_writer()
-            writer.remove_section()
-            writer.release()
-        # END delete configuration
+            parent_index.write()
 
-        # void our data not to delay invalid access
-        self._clear_cache()
+            # Now git config - we need the config intact, otherwise we can't query
+            # information anymore.
+
+            with self.repo.config_writer() as gcp_writer:
+                gcp_writer.remove_section(sm_section(self.name))
+
+            with self.config_writer() as sc_writer:
+                sc_writer.remove_section()
+        # END delete configuration
 
         return self
 
-    def set_parent_commit(self, commit, check=True):
+    def set_parent_commit(self, commit: Union[Commit_ish, str, None], check: bool = True) -> "Submodule":
         """Set this instance to use the given commit whose tree is supposed to
-        contain the .gitmodules blob.
+        contain the ``.gitmodules`` blob.
+
+        :param commit:
+            Commit-ish reference pointing at the root tree, or ``None`` to always point
+            to the most recent commit.
 
-        :param commit: Commit'ish reference pointing at the root_tree
-        :param check: if True, relatively expensive checks will be performed to verify
+        :param check:
+            If ``True``, relatively expensive checks will be performed to verify
             validity of the submodule.
-        :raise ValueError: if the commit's tree didn't contain the .gitmodules blob.
-        :raise ValueError: if the parent commit didn't store this submodule under the
-            current path
-        :return: self"""
+
+        :raise ValueError:
+            If the commit's tree didn't contain the ``.gitmodules`` blob.
+
+        :raise ValueError:
+            If the parent commit didn't store this submodule under the current path.
+
+        :return:
+            self
+        """
+        if commit is None:
+            self._parent_commit = None
+            return self
+        # END handle None
         pcommit = self.repo.commit(commit)
         pctree = pcommit.tree
         if self.k_modules_file not in pctree:
@@ -756,58 +1309,137 @@ def set_parent_commit(self, commit, check=True):
             # END handle submodule did not exist
         # END handle checking mode
 
-        # update our sha, it could have changed
-        self.binsha = pctree[self.path].binsha
+        # Update our sha, it could have changed.
+        # If check is False, we might see a parent-commit that doesn't even contain the
+        # submodule anymore. in that case, mark our sha as being NULL.
+        try:
+            self.binsha = pctree[str(self.path)].binsha
+        except KeyError:
+            self.binsha = self.NULL_BIN_SHA
 
         self._clear_cache()
-
         return self
 
     @unbare_repo
-    def config_writer(self, index=None, write=True):
-        """:return: a config writer instance allowing you to read and write the data
-        belonging to this submodule into the .gitmodules file.
-
-        :param index: if not None, an IndexFile instance which should be written.
-            defaults to the index of the Submodule's parent repository.
-        :param write: if True, the index will be written each time a configuration
-            value changes.
-        :note: the parameters allow for a more efficient writing of the index,
-            as you can pass in a modified index on your own, prevent automatic writing,
-            and write yourself once the whole operation is complete
-        :raise ValueError: if trying to get a writer on a parent_commit which does not
-            match the current head commit
-        :raise IOError: If the .gitmodules file/blob could not be read"""
+    def config_writer(
+        self, index: Union["IndexFile", None] = None, write: bool = True
+    ) -> SectionConstraint["SubmoduleConfigParser"]:
+        """
+        :return:
+            A config writer instance allowing you to read and write the data belonging
+            to this submodule into the ``.gitmodules`` file.
+
+        :param index:
+            If not ``None``, an :class:`~git.index.base.IndexFile` instance which should
+            be written. Defaults to the index of the :class:`Submodule`'s parent
+            repository.
+
+        :param write:
+            If ``True``, the index will be written each time a configuration value changes.
+
+        :note:
+            The parameters allow for a more efficient writing of the index, as you can
+            pass in a modified index on your own, prevent automatic writing, and write
+            yourself once the whole operation is complete.
+
+        :raise ValueError:
+            If trying to get a writer on a parent_commit which does not match the
+            current head commit.
+
+        :raise IOError:
+            If the ``.gitmodules`` file/blob could not be read.
+        """
         writer = self._config_parser_constrained(read_only=False)
         if index is not None:
             writer.config._index = index
         writer.config._auto_write = write
         return writer
 
-    #} END edit interface
+    @unbare_repo
+    def rename(self, new_name: str) -> "Submodule":
+        """Rename this submodule.
+
+        :note:
+            This method takes care of renaming the submodule in various places, such as:
+
+            * ``$parent_git_dir / config``
+            * ``$working_tree_dir / .gitmodules``
+            * (git >= v1.8.0: move submodule repository to new name)
+
+        As ``.gitmodules`` will be changed, you would need to make a commit afterwards.
+        The changed ``.gitmodules`` file will already be added to the index.
+
+        :return:
+            This :class:`Submodule` instance
+        """
+        if self.name == new_name:
+            return self
+
+        # .git/config
+        with self.repo.config_writer() as pw:
+            # As we ourselves didn't write anything about submodules into the parent
+            # .git/config, we will not require it to exist, and just ignore missing
+            # entries.
+            if pw.has_section(sm_section(self.name)):
+                pw.rename_section(sm_section(self.name), sm_section(new_name))
+
+        # .gitmodules
+        with self.config_writer(write=True).config as cw:
+            cw.rename_section(sm_section(self.name), sm_section(new_name))
+
+        self._name = new_name
+
+        # .git/modules
+        mod = self.module()
+        if mod.has_separate_working_tree():
+            destination_module_abspath = self._module_abspath(self.repo, self.path, new_name)
+            source_dir = mod.git_dir
+            # Let's be sure the submodule name is not so obviously tied to a directory.
+            if str(destination_module_abspath).startswith(str(mod.git_dir)):
+                tmp_dir = self._module_abspath(self.repo, self.path, str(uuid.uuid4()))
+                os.renames(source_dir, tmp_dir)
+                source_dir = tmp_dir
+            # END handle self-containment
+            os.renames(source_dir, destination_module_abspath)
+            if mod.working_tree_dir:
+                self._write_git_file_and_module_config(mod.working_tree_dir, destination_module_abspath)
+        # END move separate git repository
+
+        return self
+
+    # } END edit interface
 
-    #{ Query Interface
+    # { Query Interface
 
     @unbare_repo
-    def module(self):
-        """:return: Repo instance initialized from the repository at our submodule path
-        :raise InvalidGitRepositoryError: if a repository was not available. This could
-            also mean that it was not yet initialized"""
-        # late import to workaround circular dependencies
-        module_path = self.abspath
+    def module(self) -> "Repo":
+        """
+        :return:
+            :class:`~git.repo.base.Repo` instance initialized from the repository at our
+            submodule path
+
+        :raise git.exc.InvalidGitRepositoryError:
+            If a repository was not available.
+            This could also mean that it was not yet initialized.
+        """
+        module_checkout_abspath = self.abspath
         try:
-            repo = git.Repo(module_path)
+            repo = git.Repo(module_checkout_abspath)
             if repo != self.repo:
                 return repo
             # END handle repo uninitialized
-        except (InvalidGitRepositoryError, NoSuchPathError):
-            raise InvalidGitRepositoryError("No valid repository at %s" % self.path)
+        except (InvalidGitRepositoryError, NoSuchPathError) as e:
+            raise InvalidGitRepositoryError("No valid repository at %s" % module_checkout_abspath) from e
         else:
-            raise InvalidGitRepositoryError("Repository at %r was not yet checked out" % module_path)
+            raise InvalidGitRepositoryError("Repository at %r was not yet checked out" % module_checkout_abspath)
         # END handle exceptions
 
-    def module_exists(self):
-        """:return: True if our module exists and is a valid git repository. See module() method"""
+    def module_exists(self) -> bool:
+        """
+        :return:
+            ``True`` if our module exists and is a valid git repository.
+            See the :meth:`module` method.
+        """
         try:
             self.module()
             return True
@@ -815,28 +1447,31 @@ def module_exists(self):
             return False
         # END handle exception
 
-    def exists(self):
+    def exists(self) -> bool:
         """
-        :return: True if the submodule exists, False otherwise. Please note that
-            a submodule may exist (in the .gitmodules file) even though its module
-            doesn't exist on disk"""
-        # keep attributes for later, and restore them if we have no valid data
-        # this way we do not actually alter the state of the object
+        :return:
+            ``True`` if the submodule exists, ``False`` otherwise.
+            Please note that a submodule may exist (in the ``.gitmodules`` file) even
+            though its module doesn't exist on disk.
+        """
+        # Keep attributes for later, and restore them if we have no valid data.
+        # This way we do not actually alter the state of the object.
         loc = locals()
         for attr in self._cache_attrs:
             try:
                 if hasattr(self, attr):
                     loc[attr] = getattr(self, attr)
                 # END if we have the attribute cache
-            except cp.NoSectionError:
-                # on PY3, this can happen apparently ... don't know why this doesn't happen on PY2
+            except (cp.NoSectionError, ValueError):
+                # On PY3, this can happen apparently... don't know why this doesn't
+                # happen on PY2.
                 pass
         # END for each attr
         self._clear_cache()
 
         try:
             try:
-                self.path
+                self.path  # noqa: B018
                 return True
             except Exception:
                 return False
@@ -850,110 +1485,158 @@ def exists(self):
         # END handle object state consistency
 
     @property
-    def branch(self):
-        """:return: The branch instance that we are to checkout
-        :raise InvalidGitRepositoryError: if our module is not yet checked out"""
+    def branch(self) -> "Head":
+        """
+        :return:
+            The branch instance that we are to checkout
+
+        :raise git.exc.InvalidGitRepositoryError:
+            If our module is not yet checked out.
+        """
         return mkhead(self.module(), self._branch_path)
 
     @property
-    def branch_path(self):
+    def branch_path(self) -> PathLike:
+        """
+        :return:
+            Full repository-relative path as string to the branch we would checkout from
+            the remote and track
         """
-        :return: full (relative) path as string to the branch we would checkout
-            from the remote and track"""
         return self._branch_path
 
     @property
-    def branch_name(self):
-        """:return: the name of the branch, which is the shortest possible branch name"""
-        # use an instance method, for this we create a temporary Head instance
-        # which uses a repository that is available at least ( it makes no difference )
+    def branch_name(self) -> str:
+        """
+        :return:
+            The name of the branch, which is the shortest possible branch name
+        """
+        # Use an instance method, for this we create a temporary Head instance which
+        # uses a repository that is available at least (it makes no difference).
         return git.Head(self.repo, self._branch_path).name
 
     @property
-    def url(self):
-        """:return: The url to the repository which our module-repository refers to"""
+    def url(self) -> str:
+        """:return: The url to the repository our submodule's repository refers to"""
         return self._url
 
     @property
-    def parent_commit(self):
-        """:return: Commit instance with the tree containing the .gitmodules file
-        :note: will always point to the current head's commit if it was not set explicitly"""
+    def parent_commit(self) -> "Commit":
+        """
+        :return:
+            :class:`~git.objects.commit.Commit` instance with the tree containing the
+            ``.gitmodules`` file
+
+        :note:
+            Will always point to the current head's commit if it was not set explicitly.
+        """
+        if self._parent_commit is None:
+            return self.repo.commit()
         return self._parent_commit
 
     @property
-    def name(self):
-        """:return: The name of this submodule. It is used to identify it within the
-            .gitmodules file.
-        :note: by default, the name is the path at which to find the submodule, but
-            in git-python it should be a unique identifier similar to the identifiers
-            used for remotes, which allows to change the path of the submodule
-            easily
+    def name(self) -> str:
+        """
+        :return:
+            The name of this submodule. It is used to identify it within the
+            ``.gitmodules`` file.
+
+        :note:
+            By default, this is the name is the path at which to find the submodule, but
+            in GitPython it should be a unique identifier similar to the identifiers
+            used for remotes, which allows to change the path of the submodule easily.
         """
         return self._name
 
-    def config_reader(self):
+    def config_reader(self) -> SectionConstraint[SubmoduleConfigParser]:
         """
-        :return: ConfigReader instance which allows you to qurey the configuration values
-            of this submodule, as provided by the .gitmodules file
-        :note: The config reader will actually read the data directly from the repository
+        :return:
+            ConfigReader instance which allows you to query the configuration values of
+            this submodule, as provided by the ``.gitmodules`` file.
+
+        :note:
+            The config reader will actually read the data directly from the repository
             and thus does not need nor care about your working tree.
-        :note: Should be cached by the caller and only kept as long as needed
-        :raise IOError: If the .gitmodules file/blob could not be read"""
+
+        :note:
+            Should be cached by the caller and only kept as long as needed.
+
+        :raise IOError:
+            If the ``.gitmodules`` file/blob could not be read.
+        """
         return self._config_parser_constrained(read_only=True)
 
-    def children(self):
+    def children(self) -> IterableList["Submodule"]:
+        """
+        :return:
+            IterableList(Submodule, ...) An iterable list of :class:`Submodule`
+            instances which are children of this submodule or 0 if the submodule is not
+            checked out.
         """
-        :return: IterableList(Submodule, ...) an iterable list of submodules instances
-            which are children of this submodule or 0 if the submodule is not checked out"""
         return self._get_intermediate_items(self)
 
-    #} END query interface
+    # } END query interface
 
-    #{ Iterable Interface
+    # { Iterable Interface
 
     @classmethod
-    def iter_items(cls, repo, parent_commit='HEAD'):
-        """:return: iterator yielding Submodule instances available in the given repository"""
-        pc = repo.commit(parent_commit)         # parent commit instance
+    def iter_items(
+        cls,
+        repo: "Repo",
+        parent_commit: Union[Commit_ish, str] = "HEAD",
+        *args: Any,
+        **kwargs: Any,
+    ) -> Iterator["Submodule"]:
+        """
+        :return:
+            Iterator yielding :class:`Submodule` instances available in the given
+            repository
+        """
         try:
+            pc = repo.commit(parent_commit)  # Parent commit instance
             parser = cls._config_parser(repo, pc, read_only=True)
-        except IOError:
-            raise StopIteration
+        except (IOError, BadName):
+            return
         # END handle empty iterator
 
-        rt = pc.tree                                # root tree
-
         for sms in parser.sections():
             n = sm_name(sms)
-            p = parser.get_value(sms, 'path')
-            u = parser.get_value(sms, 'url')
+            p = parser.get(sms, "path")
+            u = parser.get(sms, "url")
             b = cls.k_head_default
             if parser.has_option(sms, cls.k_head_option):
-                b = str(parser.get_value(sms, cls.k_head_option))
+                b = str(parser.get(sms, cls.k_head_option))
             # END handle optional information
 
-            # get the binsha
+            # Get the binsha.
             index = repo.index
             try:
+                rt = pc.tree  # Root tree
                 sm = rt[p]
             except KeyError:
-                # try the index, maybe it was just added
+                # Try the index, maybe it was just added.
                 try:
                     entry = index.entries[index.entry_key(p, 0)]
                     sm = Submodule(repo, entry.binsha, entry.mode, entry.path)
                 except KeyError:
-                    raise InvalidGitRepositoryError(
-                        "Gitmodule path %r did not exist in revision of parent commit %s" % (p, parent_commit))
+                    # The submodule doesn't exist, probably it wasn't removed from the
+                    # .gitmodules file.
+                    continue
                 # END handle keyerror
             # END handle critical error
 
-            # fill in remaining info - saves time as it doesn't have to be parsed again
+            # Make sure we are looking at a submodule object.
+            if type(sm) is not git.objects.submodule.base.Submodule:
+                continue
+
+            # Fill in remaining info - saves time as it doesn't have to be parsed again.
             sm._name = n
-            sm._parent_commit = pc
+            if pc != repo.commit():
+                sm._parent_commit = pc
+            # END set only if not most recent!
             sm._branch_path = git.Head.to_full_path(b)
             sm._url = u
 
             yield sm
         # END for each section
 
-    #} END iterable interface
+    # } END iterable interface
diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py
index 8c9afff17..d93193fa3 100644
--- a/git/objects/submodule/root.py
+++ b/git/objects/submodule/root.py
@@ -1,28 +1,42 @@
-from .base import (
-    Submodule,
-    UpdateProgress
-)
-from .util import (
-    find_first_remote_branch
-)
-from git.exc import InvalidGitRepositoryError
-import git
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["RootModule", "RootUpdateProgress"]
 
 import logging
 
-__all__ = ["RootModule", "RootUpdateProgress"]
+import git
+from git.exc import InvalidGitRepositoryError
+
+from .base import Submodule, UpdateProgress
+from .util import find_first_remote_branch
+
+# typing -------------------------------------------------------------------
 
-log = logging.getLogger('git.objects.submodule.root')
+from typing import TYPE_CHECKING, Union
+
+from git.types import Commit_ish
+
+if TYPE_CHECKING:
+    from git.repo import Repo
+    from git.util import IterableList
+
+# ----------------------------------------------------------------------------
+
+_logger = logging.getLogger(__name__)
 
 
 class RootUpdateProgress(UpdateProgress):
+    """Utility class which adds more opcodes to
+    :class:`~git.objects.submodule.base.UpdateProgress`."""
 
-    """Utility class which adds more opcodes to the UpdateProgress"""
     REMOVE, PATHCHANGE, BRANCHCHANGE, URLCHANGE = [
-        1 << x for x in range(UpdateProgress._num_op_codes, UpdateProgress._num_op_codes + 4)]
+        1 << x for x in range(UpdateProgress._num_op_codes, UpdateProgress._num_op_codes + 4)
+    ]
     _num_op_codes = UpdateProgress._num_op_codes + 4
 
-    __slots__ = tuple()
+    __slots__ = ()
+
 
 BEGIN = RootUpdateProgress.BEGIN
 END = RootUpdateProgress.END
@@ -33,302 +47,421 @@ class RootUpdateProgress(UpdateProgress):
 
 
 class RootModule(Submodule):
+    """A (virtual) root of all submodules in the given repository.
 
-    """A (virtual) Root of all submodules in the given repository. It can be used
-    to more easily traverse all submodules of the master repository"""
+    This can be used to more easily traverse all submodules of the
+    superproject (master repository).
+    """
 
-    __slots__ = tuple()
+    __slots__ = ()
 
-    k_root_name = '__ROOT__'
+    k_root_name = "__ROOT__"
 
-    def __init__(self, repo):
+    def __init__(self, repo: "Repo") -> None:
         # repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None)
-        super(RootModule, self).__init__(
+        super().__init__(
             repo,
             binsha=self.NULL_BIN_SHA,
             mode=self.k_default_mode,
-            path='',
+            path="",
             name=self.k_root_name,
             parent_commit=repo.head.commit,
-            url='',
-            branch_path=git.Head.to_full_path(self.k_head_default)
+            url="",
+            branch_path=git.Head.to_full_path(self.k_head_default),
         )
 
-    def _clear_cache(self):
-        """May not do anything"""
+    def _clear_cache(self) -> None:
+        """May not do anything."""
         pass
 
-    #{ Interface
-
-    def update(self, previous_commit=None, recursive=True, force_remove=False, init=True,
-               to_latest_revision=False, progress=None, dry_run=False):
+    # { Interface
+
+    def update(  # type: ignore[override]
+        self,
+        previous_commit: Union[Commit_ish, str, None] = None,
+        recursive: bool = True,
+        force_remove: bool = False,
+        init: bool = True,
+        to_latest_revision: bool = False,
+        progress: Union[None, "RootUpdateProgress"] = None,
+        dry_run: bool = False,
+        force_reset: bool = False,
+        keep_going: bool = False,
+    ) -> "RootModule":
         """Update the submodules of this repository to the current HEAD commit.
-        This method behaves smartly by determining changes of the path of a submodules
+
+        This method behaves smartly by determining changes of the path of a submodule's
         repository, next to changes to the to-be-checked-out commit or the branch to be
-        checked out. This works if the submodules ID does not change.
-        Additionally it will detect addition and removal of submodules, which will be handled
-        gracefully.
-
-        :param previous_commit: If set to a commit'ish, the commit we should use
-            as the previous commit the HEAD pointed to before it was set to the commit it points to now.
-            If None, it defaults to HEAD@{1} otherwise
-        :param recursive: if True, the children of submodules will be updated as well
-            using the same technique
-        :param force_remove: If submodules have been deleted, they will be forcibly removed.
-            Otherwise the update may fail if a submodule's repository cannot be deleted as
-            changes have been made to it (see Submodule.update() for more information)
-        :param init: If we encounter a new module which would need to be initialized, then do it.
-        :param to_latest_revision: If True, instead of checking out the revision pointed to
-            by this submodule's sha, the checked out tracking branch will be merged with the
-            newest remote branch fetched from the repository's origin
-        :param progress: RootUpdateProgress instance or None if no progress should be sent
-        :param dry_run: if True, operations will not actually be performed. Progress messages
-            will change accordingly to indicate the WOULD DO state of the operation."""
+        checked out. This works if the submodule's ID does not change.
+
+        Additionally it will detect addition and removal of submodules, which will be
+        handled gracefully.
+
+        :param previous_commit:
+            If set to a commit-ish, the commit we should use as the previous commit the
+            HEAD pointed to before it was set to the commit it points to now.
+            If ``None``, it defaults to ``HEAD@{1}`` otherwise.
+
+        :param recursive:
+            If ``True``, the children of submodules will be updated as well using the
+            same technique.
+
+        :param force_remove:
+            If submodules have been deleted, they will be forcibly removed. Otherwise
+            the update may fail if a submodule's repository cannot be deleted as changes
+            have been made to it.
+            (See :meth:`Submodule.update <git.objects.submodule.base.Submodule.update>`
+            for more information.)
+
+        :param init:
+            If we encounter a new module which would need to be initialized, then do it.
+
+        :param to_latest_revision:
+            If ``True``, instead of checking out the revision pointed to by this
+            submodule's sha, the checked out tracking branch will be merged with the
+            latest remote branch fetched from the repository's origin.
+
+            Unless `force_reset` is specified, a local tracking branch will never be
+            reset into its past, therefore the remote branch must be in the future for
+            this to have an effect.
+
+        :param force_reset:
+            If ``True``, submodules may checkout or reset their branch even if the
+            repository has pending changes that would be overwritten, or if the local
+            tracking branch is in the future of the remote tracking branch and would be
+            reset into its past.
+
+        :param progress:
+            :class:`RootUpdateProgress` instance, or ``None`` if no progress should be
+            sent.
+
+        :param dry_run:
+            If ``True``, operations will not actually be performed. Progress messages
+            will change accordingly to indicate the WOULD DO state of the operation.
+
+        :param keep_going:
+            If ``True``, we will ignore but log all errors, and keep going recursively.
+            Unless `dry_run` is set as well, `keep_going` could cause
+            subsequent/inherited errors you wouldn't see otherwise.
+            In conjunction with `dry_run`, this can be useful to anticipate all errors
+            when updating submodules.
+
+        :return:
+            self
+        """
         if self.repo.bare:
             raise InvalidGitRepositoryError("Cannot update submodules in bare repositories")
         # END handle bare
 
         if progress is None:
             progress = RootUpdateProgress()
-        # END assure progress is set
+        # END ensure progress is set
 
-        prefix = ''
+        prefix = ""
         if dry_run:
-            prefix = 'DRY-RUN: '
+            prefix = "DRY-RUN: "
 
         repo = self.repo
 
-        # SETUP BASE COMMIT
-        ###################
-        cur_commit = repo.head.commit
-        if previous_commit is None:
-            try:
-                previous_commit = repo.commit(repo.head.log_entry(-1).oldhexsha)
-                if previous_commit.binsha == previous_commit.NULL_BIN_SHA:
-                    raise IndexError
-                # END handle initial commit
-            except IndexError:
-                # in new repositories, there is no previous commit
-                previous_commit = cur_commit
-            # END exception handling
-        else:
-            previous_commit = repo.commit(previous_commit)   # obtain commit object
-        # END handle previous commit
-
-        psms = self.list_items(repo, parent_commit=previous_commit)
-        sms = self.list_items(repo)
-        spsms = set(psms)
-        ssms = set(sms)
-
-        # HANDLE REMOVALS
-        ###################
-        rrsm = (spsms - ssms)
-        len_rrsm = len(rrsm)
-        for i, rsm in enumerate(rrsm):
-            op = REMOVE
-            if i == 0:
-                op |= BEGIN
-            # END handle begin
-
-            # fake it into thinking its at the current commit to allow deletion
-            # of previous module. Trigger the cache to be updated before that
-            progress.update(op, i, len_rrsm, prefix + "Removing submodule %r at %s" % (rsm.name, rsm.abspath))
-            rsm._parent_commit = repo.head.commit
-            if not dry_run:
-                rsm.remove(configuration=False, module=True, force=force_remove)
-            # END handle dry-run
-
-            if i == len_rrsm - 1:
-                op |= END
-            # END handle end
-            progress.update(op, i, len_rrsm, prefix + "Done removing submodule %r" % rsm.name)
-        # END for each removed submodule
-
-        # HANDLE PATH RENAMES
-        #####################
-        # url changes + branch changes
-        csms = (spsms & ssms)
-        len_csms = len(csms)
-        for i, csm in enumerate(csms):
-            psm = psms[csm.name]
-            sm = sms[csm.name]
-
-            # PATH CHANGES
-            ##############
-            if sm.path != psm.path and psm.module_exists():
-                progress.update(BEGIN | PATHCHANGE, i, len_csms, prefix +
-                                "Moving repository of submodule %r from %s to %s" % (sm.name, psm.abspath, sm.abspath))
-                # move the module to the new path
-                if not dry_run:
-                    psm.move(sm.path, module=True, configuration=False)
-                # END handle dry_run
+        try:
+            # SETUP BASE COMMIT
+            ###################
+            cur_commit = repo.head.commit
+            if previous_commit is None:
+                try:
+                    previous_commit = repo.commit(repo.head.log_entry(-1).oldhexsha)
+                    if previous_commit.binsha == previous_commit.NULL_BIN_SHA:
+                        raise IndexError
+                    # END handle initial commit
+                except IndexError:
+                    # In new repositories, there is no previous commit.
+                    previous_commit = cur_commit
+                # END exception handling
+            else:
+                previous_commit = repo.commit(previous_commit)  # Obtain commit object.
+            # END handle previous commit
+
+            psms: "IterableList[Submodule]" = self.list_items(repo, parent_commit=previous_commit)
+            sms: "IterableList[Submodule]" = self.list_items(repo)
+            spsms = set(psms)
+            ssms = set(sms)
+
+            # HANDLE REMOVALS
+            ###################
+            rrsm = spsms - ssms
+            len_rrsm = len(rrsm)
+
+            for i, rsm in enumerate(rrsm):
+                op = REMOVE
+                if i == 0:
+                    op |= BEGIN
+                # END handle begin
+
+                # Fake it into thinking its at the current commit to allow deletion
+                # of previous module. Trigger the cache to be updated before that.
                 progress.update(
-                    END | PATHCHANGE, i, len_csms, prefix + "Done moving repository of submodule %r" % sm.name)
-            # END handle path changes
-
-            if sm.module_exists():
-                # HANDLE URL CHANGE
-                ###################
-                if sm.url != psm.url:
-                    # Add the new remote, remove the old one
-                    # This way, if the url just changes, the commits will not
-                    # have to be re-retrieved
-                    nn = '__new_origin__'
-                    smm = sm.module()
-                    rmts = smm.remotes
-
-                    # don't do anything if we already have the url we search in place
-                    if len([r for r in rmts if r.url == sm.url]) == 0:
-                        progress.update(BEGIN | URLCHANGE, i, len_csms, prefix +
-                                        "Changing url of submodule %r from %s to %s" % (sm.name, psm.url, sm.url))
+                    op,
+                    i,
+                    len_rrsm,
+                    prefix + "Removing submodule %r at %s" % (rsm.name, rsm.abspath),
+                )
+                rsm._parent_commit = repo.head.commit
+                rsm.remove(
+                    configuration=False,
+                    module=True,
+                    force=force_remove,
+                    dry_run=dry_run,
+                )
+
+                if i == len_rrsm - 1:
+                    op |= END
+                # END handle end
+                progress.update(op, i, len_rrsm, prefix + "Done removing submodule %r" % rsm.name)
+            # END for each removed submodule
+
+            # HANDLE PATH RENAMES
+            #####################
+            # URL changes + branch changes.
+            csms = spsms & ssms
+            len_csms = len(csms)
+            for i, csm in enumerate(csms):
+                psm: "Submodule" = psms[csm.name]
+                sm: "Submodule" = sms[csm.name]
+
+                # PATH CHANGES
+                ##############
+                if sm.path != psm.path and psm.module_exists():
+                    progress.update(
+                        BEGIN | PATHCHANGE,
+                        i,
+                        len_csms,
+                        prefix + "Moving repository of submodule %r from %s to %s" % (sm.name, psm.abspath, sm.abspath),
+                    )
+                    # Move the module to the new path.
+                    if not dry_run:
+                        psm.move(sm.path, module=True, configuration=False)
+                    # END handle dry_run
+                    progress.update(
+                        END | PATHCHANGE,
+                        i,
+                        len_csms,
+                        prefix + "Done moving repository of submodule %r" % sm.name,
+                    )
+                # END handle path changes
 
+                if sm.module_exists():
+                    # HANDLE URL CHANGE
+                    ###################
+                    if sm.url != psm.url:
+                        # Add the new remote, remove the old one.
+                        # This way, if the url just changes, the commits will not have
+                        # to be re-retrieved.
+                        nn = "__new_origin__"
+                        smm = sm.module()
+                        rmts = smm.remotes
+
+                        # Don't do anything if we already have the url we search in
+                        # place.
+                        if len([r for r in rmts if r.url == sm.url]) == 0:
+                            progress.update(
+                                BEGIN | URLCHANGE,
+                                i,
+                                len_csms,
+                                prefix + "Changing url of submodule %r from %s to %s" % (sm.name, psm.url, sm.url),
+                            )
+
+                            if not dry_run:
+                                assert nn not in [r.name for r in rmts]
+                                smr = smm.create_remote(nn, sm.url)
+                                smr.fetch(progress=progress)
+
+                                # If we have a tracking branch, it should be available
+                                # in the new remote as well.
+                                if len([r for r in smr.refs if r.remote_head == sm.branch_name]) == 0:
+                                    raise ValueError(
+                                        "Submodule branch named %r was not available in new submodule remote at %r"
+                                        % (sm.branch_name, sm.url)
+                                    )
+                                # END head is not detached
+
+                                # Now delete the changed one.
+                                rmt_for_deletion = None
+                                for remote in rmts:
+                                    if remote.url == psm.url:
+                                        rmt_for_deletion = remote
+                                        break
+                                    # END if urls match
+                                # END for each remote
+
+                                # If we didn't find a matching remote, but have exactly
+                                # one, we can safely use this one.
+                                if rmt_for_deletion is None:
+                                    if len(rmts) == 1:
+                                        rmt_for_deletion = rmts[0]
+                                    else:
+                                        # If we have not found any remote with the
+                                        # original URL we may not have a name. This is a
+                                        # special case, and its okay to fail here.
+                                        # Alternatively we could just generate a unique
+                                        # name and leave all existing ones in place.
+                                        raise InvalidGitRepositoryError(
+                                            "Couldn't find original remote-repo at url %r" % psm.url
+                                        )
+                                    # END handle one single remote
+                                # END handle check we found a remote
+
+                                orig_name = rmt_for_deletion.name
+                                smm.delete_remote(rmt_for_deletion)
+                                # NOTE: Currently we leave tags from the deleted remotes
+                                # as well as separate tracking branches in the possibly
+                                # totally changed repository (someone could have changed
+                                # the url to another project). At some point, one might
+                                # want to clean it up, but the danger is high to remove
+                                # stuff the user has added explicitly.
+
+                                # Rename the new remote back to what it was.
+                                smr.rename(orig_name)
+
+                                # Early on, we verified that the our current tracking
+                                # branch exists in the remote. Now we have to ensure
+                                # that the sha we point to is still contained in the new
+                                # remote tracking branch.
+                                smsha = sm.binsha
+                                found = False
+                                rref = smr.refs[self.branch_name]
+                                for c in rref.commit.traverse():
+                                    if c.binsha == smsha:
+                                        found = True
+                                        break
+                                    # END traverse all commits in search for sha
+                                # END for each commit
+
+                                if not found:
+                                    # Adjust our internal binsha to use the one of the
+                                    # remote this way, it will be checked out in the
+                                    # next step. This will change the submodule relative
+                                    # to us, so the user will be able to commit the
+                                    # change easily.
+                                    _logger.warning(
+                                        "Current sha %s was not contained in the tracking\
+             branch at the new remote, setting it the the remote's tracking branch",
+                                        sm.hexsha,
+                                    )
+                                    sm.binsha = rref.commit.binsha
+                                # END reset binsha
+
+                                # NOTE: All checkout is performed by the base
+                                # implementation of update.
+                            # END handle dry_run
+                            progress.update(
+                                END | URLCHANGE,
+                                i,
+                                len_csms,
+                                prefix + "Done adjusting url of submodule %r" % (sm.name),
+                            )
+                        # END skip remote handling if new url already exists in module
+                    # END handle url
+
+                    # HANDLE PATH CHANGES
+                    #####################
+                    if sm.branch_path != psm.branch_path:
+                        # Finally, create a new tracking branch which tracks the new
+                        # remote branch.
+                        progress.update(
+                            BEGIN | BRANCHCHANGE,
+                            i,
+                            len_csms,
+                            prefix
+                            + "Changing branch of submodule %r from %s to %s"
+                            % (sm.name, psm.branch_path, sm.branch_path),
+                        )
                         if not dry_run:
-                            assert nn not in [r.name for r in rmts]
-                            smr = smm.create_remote(nn, sm.url)
-                            smr.fetch(progress=progress)
-
-                            # If we have a tracking branch, it should be available
-                            # in the new remote as well.
-                            if len([r for r in smr.refs if r.remote_head == sm.branch_name]) == 0:
-                                raise ValueError(
-                                    "Submodule branch named %r was not available in new submodule remote at %r"
-                                    % (sm.branch_name, sm.url)
-                                )
-                            # END head is not detached
-
-                            # now delete the changed one
-                            rmt_for_deletion = None
-                            for remote in rmts:
-                                if remote.url == psm.url:
-                                    rmt_for_deletion = remote
-                                    break
-                                # END if urls match
+                            smm = sm.module()
+                            smmr = smm.remotes
+                            # As the branch might not exist yet, we will have to fetch
+                            # all remotes to be sure...
+                            for remote in smmr:
+                                remote.fetch(progress=progress)
                             # END for each remote
 
-                            # if we didn't find a matching remote, but have exactly one,
-                            # we can safely use this one
-                            if rmt_for_deletion is None:
-                                if len(rmts) == 1:
-                                    rmt_for_deletion = rmts[0]
-                                else:
-                                    # if we have not found any remote with the original url
-                                    # we may not have a name. This is a special case,
-                                    # and its okay to fail here
-                                    # Alternatively we could just generate a unique name and leave all
-                                    # existing ones in place
-                                    raise InvalidGitRepositoryError(
-                                        "Couldn't find original remote-repo at url %r" % psm.url)
-                                # END handle one single remote
-                            # END handle check we found a remote
-
-                            orig_name = rmt_for_deletion.name
-                            smm.delete_remote(rmt_for_deletion)
-                            # NOTE: Currently we leave tags from the deleted remotes
-                            # as well as separate tracking branches in the possibly totally
-                            # changed repository ( someone could have changed the url to
-                            # another project ). At some point, one might want to clean
-                            # it up, but the danger is high to remove stuff the user
-                            # has added explicitly
-
-                            # rename the new remote back to what it was
-                            smr.rename(orig_name)
-
-                            # early on, we verified that the our current tracking branch
-                            # exists in the remote. Now we have to assure that the
-                            # sha we point to is still contained in the new remote
-                            # tracking branch.
-                            smsha = sm.binsha
-                            found = False
-                            rref = smr.refs[self.branch_name]
-                            for c in rref.commit.traverse():
-                                if c.binsha == smsha:
-                                    found = True
-                                    break
-                                # END traverse all commits in search for sha
-                            # END for each commit
-
-                            if not found:
-                                # adjust our internal binsha to use the one of the remote
-                                # this way, it will be checked out in the next step
-                                # This will change the submodule relative to us, so
-                                # the user will be able to commit the change easily
-                                log.warn("Current sha %s was not contained in the tracking\
-         branch at the new remote, setting it the the remote's tracking branch", sm.hexsha)
-                                sm.binsha = rref.commit.binsha
-                            # END reset binsha
-
-                            # NOTE: All checkout is performed by the base implementation of update
+                            try:
+                                tbr = git.Head.create(
+                                    smm,
+                                    sm.branch_name,
+                                    logmsg="branch: Created from HEAD",
+                                )
+                            except OSError:
+                                # ...or reuse the existing one.
+                                tbr = git.Head(smm, sm.branch_path)
+                            # END ensure tracking branch exists
+
+                            tbr.set_tracking_branch(find_first_remote_branch(smmr, sm.branch_name))
+                            # NOTE: All head-resetting is done in the base
+                            # implementation of update but we will have to checkout the
+                            # new branch here. As it still points to the currently
+                            # checked out commit, we don't do any harm.
+                            # As we don't want to update working-tree or index, changing
+                            # the ref is all there is to do.
+                            smm.head.reference = tbr
                         # END handle dry_run
-                        progress.update(
-                            END | URLCHANGE, i, len_csms, prefix + "Done adjusting url of submodule %r" % (sm.name))
-                    # END skip remote handling if new url already exists in module
-                # END handle url
-
-                # HANDLE PATH CHANGES
-                #####################
-                if sm.branch_path != psm.branch_path:
-                    # finally, create a new tracking branch which tracks the
-                    # new remote branch
-                    progress.update(BEGIN | BRANCHCHANGE, i, len_csms, prefix +
-                                    "Changing branch of submodule %r from %s to %s"
-                                    % (sm.name, psm.branch_path, sm.branch_path))
-                    if not dry_run:
-                        smm = sm.module()
-                        smmr = smm.remotes
-                        try:
-                            tbr = git.Head.create(smm, sm.branch_name, logmsg='branch: Created from HEAD')
-                        except OSError:
-                            # ... or reuse the existing one
-                            tbr = git.Head(smm, sm.branch_path)
-                        # END assure tracking branch exists
-
-                        tbr.set_tracking_branch(find_first_remote_branch(smmr, sm.branch_name))
-                        # figure out whether the previous tracking branch contains
-                        # new commits compared to the other one, if not we can
-                        # delete it.
-                        try:
-                            tbr = find_first_remote_branch(smmr, psm.branch_name)
-                            if len(smm.git.cherry(tbr, psm.branch)) == 0:
-                                psm.branch.delete(smm, psm.branch)
-                            # END delete original tracking branch if there are no changes
-                        except InvalidGitRepositoryError:
-                            # ignore it if the previous branch couldn't be found in the
-                            # current remotes, this just means we can't handle it
-                            pass
-                        # END exception handling
-
-                        # NOTE: All checkout is done in the base implementation of update
-                    # END handle dry_run
 
-                    progress.update(
-                        END | BRANCHCHANGE, i, len_csms, prefix + "Done changing branch of submodule %r" % sm.name)
-                # END handle branch
-            # END handle
-        # END for each common submodule
+                        progress.update(
+                            END | BRANCHCHANGE,
+                            i,
+                            len_csms,
+                            prefix + "Done changing branch of submodule %r" % sm.name,
+                        )
+                    # END handle branch
+                # END handle
+            # END for each common submodule
+        except Exception as err:
+            if not keep_going:
+                raise
+            _logger.error(str(err))
+        # END handle keep_going
 
         # FINALLY UPDATE ALL ACTUAL SUBMODULES
         ######################################
         for sm in sms:
-            # update the submodule using the default method
-            sm.update(recursive=False, init=init, to_latest_revision=to_latest_revision,
-                      progress=progress, dry_run=dry_run)
-
-            # update recursively depth first - question is which inconsitent
-            # state will be better in case it fails somewhere. Defective branch
-            # or defective depth. The RootSubmodule type will never process itself,
-            # which was done in the previous expression
+            # Update the submodule using the default method.
+            sm.update(
+                recursive=False,
+                init=init,
+                to_latest_revision=to_latest_revision,
+                progress=progress,
+                dry_run=dry_run,
+                force=force_reset,
+                keep_going=keep_going,
+            )
+
+            # Update recursively depth first - question is which inconsistent state will
+            # be better in case it fails somewhere. Defective branch or defective depth.
+            # The RootSubmodule type will never process itself, which was done in the
+            # previous expression.
             if recursive:
-                # the module would exist by now if we are not in dry_run mode
+                # The module would exist by now if we are not in dry_run mode.
                 if sm.module_exists():
-                    type(self)(sm.module()).update(recursive=True, force_remove=force_remove,
-                                                   init=init, to_latest_revision=to_latest_revision,
-                                                   progress=progress, dry_run=dry_run)
+                    type(self)(sm.module()).update(
+                        recursive=True,
+                        force_remove=force_remove,
+                        init=init,
+                        to_latest_revision=to_latest_revision,
+                        progress=progress,
+                        dry_run=dry_run,
+                        force_reset=force_reset,
+                        keep_going=keep_going,
+                    )
                 # END handle dry_run
             # END handle recursive
         # END for each submodule to update
 
-    def module(self):
-        """:return: the actual repository containing the submodules"""
+        return self
+
+    def module(self) -> "Repo":
+        """:return: The actual repository containing the submodules"""
         return self.repo
-    #} END interface
-#} END classes
+
+    # } END interface
+
+
+# } END classes
diff --git a/git/objects/submodule/util.py b/git/objects/submodule/util.py
index 5604dec72..c021510d8 100644
--- a/git/objects/submodule/util.py
+++ b/git/objects/submodule/util.py
@@ -1,47 +1,58 @@
-import git
-from git.exc import InvalidGitRepositoryError
-from git.config import GitConfigParser
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = [
+    "sm_section",
+    "sm_name",
+    "mkhead",
+    "find_first_remote_branch",
+    "SubmoduleConfigParser",
+]
+
 from io import BytesIO
 import weakref
 
-__all__ = ('sm_section', 'sm_name', 'mkhead', 'unbare_repo', 'find_first_remote_branch',
-           'SubmoduleConfigParser')
+import git
+from git.config import GitConfigParser
+from git.exc import InvalidGitRepositoryError
+
+# typing -----------------------------------------------------------------------
+
+from typing import Any, Sequence, TYPE_CHECKING, Union
 
-#{ Utilities
+from git.types import PathLike
 
+if TYPE_CHECKING:
+    from weakref import ReferenceType
 
-def sm_section(name):
-    """:return: section title used in .gitmodules configuration file"""
-    return 'submodule "%s"' % name
+    from git.refs import Head, RemoteReference
+    from git.remote import Remote
+    from git.repo import Repo
 
+    from .base import Submodule
 
-def sm_name(section):
-    """:return: name of the submodule as parsed from the section name"""
+# { Utilities
+
+
+def sm_section(name: str) -> str:
+    """:return: Section title used in ``.gitmodules`` configuration file"""
+    return f'submodule "{name}"'
+
+
+def sm_name(section: str) -> str:
+    """:return: Name of the submodule as parsed from the section name"""
     section = section.strip()
     return section[11:-1]
 
 
-def mkhead(repo, path):
+def mkhead(repo: "Repo", path: PathLike) -> "Head":
     """:return: New branch/head instance"""
     return git.Head(repo, git.Head.to_full_path(path))
 
 
-def unbare_repo(func):
-    """Methods with this decorator raise InvalidGitRepositoryError if they
-    encounter a bare repository"""
-
-    def wrapper(self, *args, **kwargs):
-        if self.repo.bare:
-            raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__)
-        # END bare method
-        return func(self, *args, **kwargs)
-    # END wrapper
-    wrapper.__name__ = func.__name__
-    return wrapper
-
-
-def find_first_remote_branch(remotes, branch_name):
-    """Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryError"""
+def find_first_remote_branch(remotes: Sequence["Remote"], branch_name: str) -> "RemoteReference":
+    """Find the remote branch matching the name of the given branch or raise
+    :exc:`~git.exc.InvalidGitRepositoryError`."""
     for remote in remotes:
         try:
             return remote.refs[branch_name]
@@ -49,40 +60,41 @@ def find_first_remote_branch(remotes, branch_name):
             continue
         # END exception handling
     # END for remote
-    raise InvalidGitRepositoryError("Didn't find remote branch %r in any of the given remotes", branch_name)
+    raise InvalidGitRepositoryError("Didn't find remote branch '%r' in any of the given remotes" % branch_name)
+
 
-#} END utilities
+# } END utilities
 
+# { Classes
 
-#{ Classes
 
 class SubmoduleConfigParser(GitConfigParser):
+    """Catches calls to :meth:`~git.config.GitConfigParser.write`, and updates the
+    ``.gitmodules`` blob in the index with the new data, if we have written into a
+    stream.
 
-    """
-    Catches calls to _write, and updates the .gitmodules blob in the index
-    with the new data, if we have written into a stream. Otherwise it will
-    add the local file to the index to make it correspond with the working tree.
-    Additionally, the cache must be cleared
+    Otherwise it would add the local file to the index to make it correspond with the
+    working tree. Additionally, the cache must be cleared.
 
-    Please note that no mutating method will work in bare mode
+    Please note that no mutating method will work in bare mode.
     """
 
-    def __init__(self, *args, **kwargs):
-        self._smref = None
+    def __init__(self, *args: Any, **kwargs: Any) -> None:
+        self._smref: Union["ReferenceType[Submodule]", None] = None
         self._index = None
         self._auto_write = True
-        super(SubmoduleConfigParser, self).__init__(*args, **kwargs)
+        super().__init__(*args, **kwargs)
 
-    #{ Interface
-    def set_submodule(self, submodule):
-        """Set this instance's submodule. It must be called before
-        the first write operation begins"""
+    # { Interface
+    def set_submodule(self, submodule: "Submodule") -> None:
+        """Set this instance's submodule. It must be called before the first write
+        operation begins."""
         self._smref = weakref.ref(submodule)
 
-    def flush_to_index(self):
-        """Flush changes in our configuration file to the index"""
+    def flush_to_index(self) -> None:
+        """Flush changes in our configuration file to the index."""
         assert self._smref is not None
-        # should always have a file here
+        # Should always have a file here.
         assert not isinstance(self._file_or_files, BytesIO)
 
         sm = self._smref()
@@ -95,14 +107,15 @@ def flush_to_index(self):
             sm._clear_cache()
         # END handle weakref
 
-    #} END interface
+    # } END interface
 
-    #{ Overridden Methods
-    def write(self):
-        rval = super(SubmoduleConfigParser, self).write()
+    # { Overridden Methods
+    def write(self) -> None:  # type: ignore[override]
+        rval: None = super().write()
         self.flush_to_index()
         return rval
+
     # END overridden methods
 
 
-#} END classes
+# } END classes
diff --git a/git/objects/tag.py b/git/objects/tag.py
index c86844478..88671d316 100644
--- a/git/objects/tag.py
+++ b/git/objects/tag.py
@@ -1,43 +1,101 @@
-# objects.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-""" Module containing all object based types. """
-from . import base
-from .util import (
-    get_object_type_by_name,
-    parse_actor_and_date
-)
-from gitdb.util import hex_to_bin
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Provides an :class:`~git.objects.base.Object`-based type for annotated tags.
+
+This defines the :class:`TagObject` class, which represents annotated tags.
+For lightweight tags, see the :mod:`git.refs.tag` module.
+"""
+
+__all__ = ["TagObject"]
+
+import sys
+
 from git.compat import defenc
+from git.util import Actor, hex_to_bin
+
+from . import base
+from .util import get_object_type_by_name, parse_actor_and_date
+
+# typing ----------------------------------------------
+
+from typing import List, TYPE_CHECKING, Union
+
+if sys.version_info >= (3, 8):
+    from typing import Literal
+else:
+    from typing_extensions import Literal
 
-__all__ = ("TagObject", )
+if TYPE_CHECKING:
+    from git.repo import Repo
+
+    from .blob import Blob
+    from .commit import Commit
+    from .tree import Tree
+
+# ---------------------------------------------------
 
 
 class TagObject(base.Object):
+    """Annotated (i.e. non-lightweight) tag carrying additional information about an
+    object we are pointing to.
+
+    See :manpage:`gitglossary(7)` on "tag object":
+    https://git-scm.com/docs/gitglossary#def_tag_object
+    """
+
+    type: Literal["tag"] = "tag"
+
+    __slots__ = (
+        "object",
+        "tag",
+        "tagger",
+        "tagged_date",
+        "tagger_tz_offset",
+        "message",
+    )
 
-    """Non-Lightweight tag carrying additional information about an object we are pointing to."""
-    type = "tag"
-    __slots__ = ("object", "tag", "tagger", "tagged_date", "tagger_tz_offset", "message")
+    def __init__(
+        self,
+        repo: "Repo",
+        binsha: bytes,
+        object: Union[None, base.Object] = None,
+        tag: Union[None, str] = None,
+        tagger: Union[None, Actor] = None,
+        tagged_date: Union[int, None] = None,
+        tagger_tz_offset: Union[int, None] = None,
+        message: Union[str, None] = None,
+    ) -> None:  # @ReservedAssignment
+        """Initialize a tag object with additional data.
 
-    def __init__(self, repo, binsha, object=None, tag=None,
-                 tagger=None, tagged_date=None, tagger_tz_offset=None, message=None):
-        """Initialize a tag object with additional data
+        :param repo:
+            Repository this object is located in.
+
+        :param binsha:
+            20 byte SHA1.
+
+        :param object:
+            :class:`~git.objects.base.Object` instance of object we are pointing to.
+
+        :param tag:
+            Name of this tag.
+
+        :param tagger:
+            :class:`~git.util.Actor` identifying the tagger.
 
-        :param repo: repository this object is located in
-        :param binsha: 20 byte SHA1
-        :param object: Object instance of object we are pointing to
-        :param tag: name of this tag
-        :param tagger: Actor identifying the tagger
         :param tagged_date: int_seconds_since_epoch
-            is the DateTime of the tag creation - use time.gmtime to convert
-            it into a different format
-        :param tagged_tz_offset: int_seconds_west_of_utc is the timezone that the
-            authored_date is in, in a format similar to time.altzone"""
-        super(TagObject, self).__init__(repo, binsha)
+            The DateTime of the tag creation.
+            Use :func:`time.gmtime` to convert it into a different format.
+
+        :param tagger_tz_offset: int_seconds_west_of_utc
+            The timezone that the `tagged_date` is in, in a format similar to
+            :attr:`time.altzone`.
+        """
+        super().__init__(repo, binsha)
         if object is not None:
-            self.object = object
+            self.object: Union["Commit", "Blob", "Tree", "TagObject"] = object
         if tag is not None:
             self.tag = tag
         if tagger is not None:
@@ -49,29 +107,34 @@ def __init__(self, repo, binsha, object=None, tag=None,
         if message is not None:
             self.message = message
 
-    def _set_cache_(self, attr):
-        """Cache all our attributes at once"""
+    def _set_cache_(self, attr: str) -> None:
+        """Cache all our attributes at once."""
         if attr in TagObject.__slots__:
             ostream = self.repo.odb.stream(self.binsha)
-            lines = ostream.read().decode(defenc).splitlines()
+            lines: List[str] = ostream.read().decode(defenc, "replace").splitlines()
 
-            obj, hexsha = lines[0].split(" ")       # object <hexsha>
-            type_token, type_name = lines[1].split(" ")  # type <type_name>
-            self.object = \
-                get_object_type_by_name(type_name.encode('ascii'))(self.repo, hex_to_bin(hexsha))
+            _obj, hexsha = lines[0].split(" ")
+            _type_token, type_name = lines[1].split(" ")
+            object_type = get_object_type_by_name(type_name.encode("ascii"))
+            self.object = object_type(self.repo, hex_to_bin(hexsha))
 
             self.tag = lines[2][4:]  # tag <tag name>
 
-            tagger_info = lines[3]  # tagger <actor> <date>
-            self.tagger, self.tagged_date, self.tagger_tz_offset = parse_actor_and_date(tagger_info)
+            if len(lines) > 3:
+                tagger_info = lines[3]  # tagger <actor> <date>
+                (
+                    self.tagger,
+                    self.tagged_date,
+                    self.tagger_tz_offset,
+                ) = parse_actor_and_date(tagger_info)
 
-            # line 4 empty - it could mark the beginning of the next header
-            # in case there really is no message, it would not exist. Otherwise
-            # a newline separates header from message
+            # Line 4 empty - it could mark the beginning of the next header.
+            # In case there really is no message, it would not exist.
+            # Otherwise a newline separates header from message.
             if len(lines) > 5:
                 self.message = "\n".join(lines[5:])
             else:
-                self.message = ''
+                self.message = ""
         # END check our attributes
         else:
-            super(TagObject, self)._set_cache_(attr)
+            super()._set_cache_(attr)
diff --git a/git/objects/tree.py b/git/objects/tree.py
index f9bee01ea..1845d0d0d 100644
--- a/git/objects/tree.py
+++ b/git/objects/tree.py
@@ -1,38 +1,75 @@
-# tree.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-from git.util import join_path
-import git.diff as diff
-from gitdb.util import to_bin_sha
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["TreeModifier", "Tree"]
+
+import sys
+
+import git.diff as git_diff
+from git.util import IterableList, join_path, to_bin_sha
 
 from . import util
-from .base import IndexObject
+from .base import IndexObjUnion, IndexObject
 from .blob import Blob
+from .fun import tree_entries_from_data, tree_to_stream
 from .submodule.base import Submodule
-from git.compat import string_types
 
-from .fun import (
-    tree_entries_from_data,
-    tree_to_stream
+# typing -------------------------------------------------
+
+from typing import (
+    Any,
+    Callable,
+    Dict,
+    Iterable,
+    Iterator,
+    List,
+    Tuple,
+    TYPE_CHECKING,
+    Type,
+    Union,
+    cast,
 )
 
-__all__ = ("TreeModifier", "Tree")
+if sys.version_info >= (3, 8):
+    from typing import Literal
+else:
+    from typing_extensions import Literal
+
+from git.types import PathLike
+
+if TYPE_CHECKING:
+    from io import BytesIO
+
+    from git.repo import Repo
 
+TreeCacheTup = Tuple[bytes, int, str]
 
-class TreeModifier(object):
+TraversedTreeTup = Union[Tuple[Union["Tree", None], IndexObjUnion, Tuple["Submodule", "Submodule"]]]
 
-    """A utility class providing methods to alter the underlying cache in a list-like fashion.
+# --------------------------------------------------------
+
+
+def cmp(a: str, b: str) -> int:
+    return (a > b) - (a < b)
+
+
+class TreeModifier:
+    """A utility class providing methods to alter the underlying cache in a list-like
+    fashion.
+
+    Once all adjustments are complete, the :attr:`_cache`, which really is a reference
+    to the cache of a tree, will be sorted. This ensures it will be in a serializable
+    state.
+    """
 
-    Once all adjustments are complete, the _cache, which really is a refernce to
-    the cache of a tree, will be sorted. Assuring it will be in a serializable state"""
-    __slots__ = '_cache'
+    __slots__ = ("_cache",)
 
-    def __init__(self, cache):
+    def __init__(self, cache: List[TreeCacheTup]) -> None:
         self._cache = cache
 
-    def _index_by_name(self, name):
+    def _index_by_name(self, name: str) -> int:
         """:return: index of an item with name, or -1 if not found"""
         for i, t in enumerate(self._cache):
             if t[2] == name:
@@ -41,36 +78,52 @@ def _index_by_name(self, name):
         # END for each item in cache
         return -1
 
-    #{ Interface
-    def set_done(self):
+    # { Interface
+    def set_done(self) -> "TreeModifier":
         """Call this method once you are done modifying the tree information.
-        It may be called several times, but be aware that each call will cause
-        a sort operation
-        :return self:"""
-        self._cache.sort(key=lambda t: t[2])    # sort by name
+
+        This may be called several times, but be aware that each call will cause a sort
+        operation.
+
+        :return:
+            self
+        """
+        self._cache.sort(key=lambda x: (x[2] + "/") if x[1] == Tree.tree_id << 12 else x[2])
         return self
-    #} END interface
-
-    #{ Mutators
-    def add(self, sha, mode, name, force=False):
-        """Add the given item to the tree. If an item with the given name already
-        exists, nothing will be done, but a ValueError will be raised if the
-        sha and mode of the existing item do not match the one you add, unless
-        force is True
-
-        :param sha: The 20 or 40 byte sha of the item to add
-        :param mode: int representing the stat compatible mode of the item
-        :param force: If True, an item with your name and information will overwrite
-            any existing item with the same name, no matter which information it has
-        :return: self"""
-        if '/' in name:
+
+    # } END interface
+
+    # { Mutators
+    def add(self, sha: bytes, mode: int, name: str, force: bool = False) -> "TreeModifier":
+        """Add the given item to the tree.
+
+        If an item with the given name already exists, nothing will be done, but a
+        :exc:`ValueError` will be raised if the sha and mode of the existing item do not
+        match the one you add, unless `force` is ``True``.
+
+        :param sha:
+            The 20 or 40 byte sha of the item to add.
+
+        :param mode:
+            :class:`int` representing the stat-compatible mode of the item.
+
+        :param force:
+            If ``True``, an item with your name and information will overwrite any
+            existing item with the same name, no matter which information it has.
+
+        :return:
+            self
+        """
+        if "/" in name:
             raise ValueError("Name must not contain '/' characters")
         if (mode >> 12) not in Tree._map_id_to_type:
             raise ValueError("Invalid object type according to mode %o" % mode)
 
         sha = to_bin_sha(sha)
         index = self._index_by_name(name)
+
         item = (sha, mode, name)
+
         if index == -1:
             self._cache.append(item)
         else:
@@ -85,96 +138,119 @@ def add(self, sha, mode, name, force=False):
         # END handle name exists
         return self
 
-    def add_unchecked(self, binsha, mode, name):
-        """Add the given item to the tree, its correctness is assumed, which
-        puts the caller into responsibility to assure the input is correct.
-        For more information on the parameters, see ``add``
-        :param binsha: 20 byte binary sha"""
-        self._cache.append((binsha, mode, name))
+    def add_unchecked(self, binsha: bytes, mode: int, name: str) -> None:
+        """Add the given item to the tree. Its correctness is assumed, so it is the
+        caller's responsibility to ensure that the input is correct.
+
+        For more information on the parameters, see :meth:`add`.
+
+        :param binsha:
+            20 byte binary sha.
+        """
+        assert isinstance(binsha, bytes) and isinstance(mode, int) and isinstance(name, str)
+        tree_cache = (binsha, mode, name)
+
+        self._cache.append(tree_cache)
 
-    def __delitem__(self, name):
-        """Deletes an item with the given name if it exists"""
+    def __delitem__(self, name: str) -> None:
+        """Delete an item with the given name if it exists."""
         index = self._index_by_name(name)
         if index > -1:
-            del(self._cache[index])
-
-    #} END mutators
+            del self._cache[index]
 
+    # } END mutators
 
-class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
 
-    """Tree objects represent an ordered list of Blobs and other Trees.
+class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable):
+    R"""Tree objects represent an ordered list of :class:`~git.objects.blob.Blob`\s and
+    other :class:`Tree`\s.
 
-    ``Tree as a list``::
+    See :manpage:`gitglossary(7)` on "tree object":
+    https://git-scm.com/docs/gitglossary#def_tree_object
 
-        Access a specific blob using the
-        tree['filename'] notation.
+    Subscripting is supported, as with a list or dict:
 
-        You may as well access by index
-        blob = tree[0]
+    * Access a specific blob using the ``tree["filename"]`` notation.
+    * You may likewise access by index, like ``blob = tree[0]``.
     """
 
-    type = "tree"
-    __slots__ = "_cache"
+    type: Literal["tree"] = "tree"
 
-    # actual integer ids for comparison
-    commit_id = 0o16     # equals stat.S_IFDIR | stat.S_IFLNK - a directory link
+    __slots__ = ("_cache",)
+
+    # Actual integer IDs for comparison.
+    commit_id = 0o16  # Equals stat.S_IFDIR | stat.S_IFLNK - a directory link.
     blob_id = 0o10
     symlink_id = 0o12
     tree_id = 0o04
 
-    _map_id_to_type = {
+    _map_id_to_type: Dict[int, Type[IndexObjUnion]] = {
         commit_id: Submodule,
         blob_id: Blob,
-        symlink_id: Blob
-        # tree id added once Tree is defined
+        symlink_id: Blob,
+        # Tree ID added once Tree is defined.
     }
 
-    def __init__(self, repo, binsha, mode=tree_id << 12, path=None):
-        super(Tree, self).__init__(repo, binsha, mode, path)
+    def __init__(
+        self,
+        repo: "Repo",
+        binsha: bytes,
+        mode: int = tree_id << 12,
+        path: Union[PathLike, None] = None,
+    ):
+        super().__init__(repo, binsha, mode, path)
 
     @classmethod
-    def _get_intermediate_items(cls, index_object):
+    def _get_intermediate_items(
+        cls,
+        index_object: IndexObjUnion,
+    ) -> Union[Tuple["Tree", ...], Tuple[()]]:
         if index_object.type == "tree":
             return tuple(index_object._iter_convert_to_object(index_object._cache))
-        return tuple()
+        return ()
 
-    def _set_cache_(self, attr):
+    def _set_cache_(self, attr: str) -> None:
         if attr == "_cache":
-            # Set the data when we need it
+            # Set the data when we need it.
             ostream = self.repo.odb.stream(self.binsha)
-            self._cache = tree_entries_from_data(ostream.read())
+            self._cache: List[TreeCacheTup] = tree_entries_from_data(ostream.read())
         else:
-            super(Tree, self)._set_cache_(attr)
+            super()._set_cache_(attr)
         # END handle attribute
 
-    def _iter_convert_to_object(self, iterable):
-        """Iterable yields tuples of (binsha, mode, name), which will be converted
-        to the respective object representation"""
+    def _iter_convert_to_object(self, iterable: Iterable[TreeCacheTup]) -> Iterator[IndexObjUnion]:
+        """Iterable yields tuples of (binsha, mode, name), which will be converted to
+        the respective object representation.
+        """
         for binsha, mode, name in iterable:
             path = join_path(self.path, name)
             try:
                 yield self._map_id_to_type[mode >> 12](self.repo, binsha, mode, path)
-            except KeyError:
-                raise TypeError("Unknown mode %o found in tree data for path '%s'" % (mode, path))
+            except KeyError as e:
+                raise TypeError("Unknown mode %o found in tree data for path '%s'" % (mode, path)) from e
         # END for each item
 
-    def join(self, file):
-        """Find the named object in this tree's contents
-        :return: ``git.Blob`` or ``git.Tree`` or ``git.Submodule``
+    def join(self, file: str) -> IndexObjUnion:
+        """Find the named object in this tree's contents.
+
+        :return:
+            :class:`~git.objects.blob.Blob`, :class:`Tree`, or
+            :class:`~git.objects.submodule.base.Submodule`
 
-        :raise KeyError: if given file or tree does not exist in tree"""
+        :raise KeyError:
+            If the given file or tree does not exist in this tree.
+        """
         msg = "Blob or Tree named %r not found"
-        if '/' in file:
+        if "/" in file:
             tree = self
             item = self
-            tokens = file.split('/')
+            tokens = file.split("/")
             for i, token in enumerate(tokens):
                 item = tree[token]
-                if item.type == 'tree':
+                if item.type == "tree":
                     tree = item
                 else:
-                    # safety assertion - blobs are at the end of the path
+                    # Safety assertion - blobs are at the end of the path.
                     if i != len(tokens) - 1:
                         raise KeyError(msg % file)
                     return item
@@ -185,70 +261,118 @@ def join(self, file):
             return item
         else:
             for info in self._cache:
-                if info[2] == file:     # [2] == name
-                    return self._map_id_to_type[info[1] >> 12](self.repo, info[0], info[1],
-                                                               join_path(self.path, info[2]))
+                if info[2] == file:  # [2] == name
+                    return self._map_id_to_type[info[1] >> 12](
+                        self.repo, info[0], info[1], join_path(self.path, info[2])
+                    )
             # END for each obj
             raise KeyError(msg % file)
         # END handle long paths
 
-    def __div__(self, file):
-        """For PY2 only"""
-        return self.join(file)
+    def __truediv__(self, file: str) -> IndexObjUnion:
+        """The ``/`` operator is another syntax for joining.
 
-    def __truediv__(self, file):
-        """For PY3 only"""
+        See :meth:`join` for details.
+        """
         return self.join(file)
 
     @property
-    def trees(self):
-        """:return: list(Tree, ...) list of trees directly below this tree"""
+    def trees(self) -> List["Tree"]:
+        """:return: list(Tree, ...) List of trees directly below this tree"""
         return [i for i in self if i.type == "tree"]
 
     @property
-    def blobs(self):
-        """:return: list(Blob, ...) list of blobs directly below this tree"""
+    def blobs(self) -> List[Blob]:
+        """:return: list(Blob, ...) List of blobs directly below this tree"""
         return [i for i in self if i.type == "blob"]
 
     @property
-    def cache(self):
+    def cache(self) -> TreeModifier:
+        """
+        :return:
+            An object allowing modification of the internal cache. This can be used to
+            change the tree's contents. When done, make sure you call
+            :meth:`~TreeModifier.set_done` on the tree modifier, or serialization
+            behaviour will be incorrect.
+
+        :note:
+            See :class:`TreeModifier` for more information on how to alter the cache.
         """
-        :return: An object allowing to modify the internal cache. This can be used
-            to change the tree's contents. When done, make sure you call ``set_done``
-            on the tree modifier, or serialization behaviour will be incorrect.
-            See the ``TreeModifier`` for more information on how to alter the cache"""
         return TreeModifier(self._cache)
 
-    def traverse(self, predicate=lambda i, d: True,
-                 prune=lambda i, d: False, depth=-1, branch_first=True,
-                 visit_once=False, ignore_self=1):
-        """For documentation, see util.Traversable.traverse
-        Trees are set to visit_once = False to gain more performance in the traversal"""
-        return super(Tree, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self)
+    def traverse(
+        self,
+        predicate: Callable[[Union[IndexObjUnion, TraversedTreeTup], int], bool] = lambda i, d: True,
+        prune: Callable[[Union[IndexObjUnion, TraversedTreeTup], int], bool] = lambda i, d: False,
+        depth: int = -1,
+        branch_first: bool = True,
+        visit_once: bool = False,
+        ignore_self: int = 1,
+        as_edge: bool = False,
+    ) -> Union[Iterator[IndexObjUnion], Iterator[TraversedTreeTup]]:
+        """For documentation, see
+        `Traversable._traverse() <git.objects.util.Traversable._traverse>`.
+
+        Trees are set to ``visit_once = False`` to gain more performance in the
+        traversal.
+        """
+
+        # # To typecheck instead of using cast.
+        # import itertools
+        # def is_tree_traversed(inp: Tuple) -> TypeGuard[Tuple[Iterator[Union['Tree', 'Blob', 'Submodule']]]]:
+        #     return all(isinstance(x, (Blob, Tree, Submodule)) for x in inp[1])
+
+        # ret = super().traverse(predicate, prune, depth, branch_first, visit_once, ignore_self)
+        # ret_tup = itertools.tee(ret, 2)
+        # assert is_tree_traversed(ret_tup), f"Type is {[type(x) for x in list(ret_tup[0])]}"
+        # return ret_tup[0]
+
+        return cast(
+            Union[Iterator[IndexObjUnion], Iterator[TraversedTreeTup]],
+            super()._traverse(
+                predicate,  # type: ignore[arg-type]
+                prune,  # type: ignore[arg-type]
+                depth,
+                branch_first,
+                visit_once,
+                ignore_self,
+            ),
+        )
+
+    def list_traverse(self, *args: Any, **kwargs: Any) -> IterableList[IndexObjUnion]:
+        """
+        :return:
+            :class:`~git.util.IterableList` with the results of the traversal as
+            produced by :meth:`traverse`
+
+            Tree -> IterableList[Union[Submodule, Tree, Blob]]
+        """
+        return super()._list_traverse(*args, **kwargs)
 
     # List protocol
-    def __getslice__(self, i, j):
+
+    def __getslice__(self, i: int, j: int) -> List[IndexObjUnion]:
         return list(self._iter_convert_to_object(self._cache[i:j]))
 
-    def __iter__(self):
+    def __iter__(self) -> Iterator[IndexObjUnion]:
         return self._iter_convert_to_object(self._cache)
 
-    def __len__(self):
+    def __len__(self) -> int:
         return len(self._cache)
 
-    def __getitem__(self, item):
+    def __getitem__(self, item: Union[str, int, slice]) -> IndexObjUnion:
         if isinstance(item, int):
             info = self._cache[item]
             return self._map_id_to_type[info[1] >> 12](self.repo, info[0], info[1], join_path(self.path, info[2]))
 
-        if isinstance(item, string_types):
-            # compatability
+        if isinstance(item, str):
+            # compatibility
             return self.join(item)
         # END index is basestring
 
         raise TypeError("Invalid index type: %r" % item)
 
-    def __contains__(self, item):
+    def __contains__(self, item: Union[IndexObjUnion, PathLike]) -> bool:
         if isinstance(item, IndexObject):
             for info in self._cache:
                 if item.binsha == info[0]:
@@ -256,33 +380,37 @@ def __contains__(self, item):
                 # END compare sha
             # END for each entry
         # END handle item is index object
-        # compatability
+        # compatibility
 
-        # treat item as repo-relative path
-        path = self.path
-        for info in self._cache:
-            if item == join_path(path, info[2]):
-                return True
+        # Treat item as repo-relative path.
+        else:
+            path = self.path
+            for info in self._cache:
+                if item == join_path(path, info[2]):
+                    return True
         # END for each item
         return False
 
-    def __reversed__(self):
-        return reversed(self._iter_convert_to_object(self._cache))
+    def __reversed__(self) -> Iterator[IndexObjUnion]:
+        return reversed(self._iter_convert_to_object(self._cache))  # type: ignore[call-overload]
+
+    def _serialize(self, stream: "BytesIO") -> "Tree":
+        """Serialize this tree into the stream. Assumes sorted tree data.
 
-    def _serialize(self, stream):
-        """Serialize this tree into the stream. Please note that we will assume
-        our tree data to be in a sorted state. If this is not the case, serialization
-        will not generate a correct tree representation as these are assumed to be sorted
-        by algorithms"""
+        :note:
+            We will assume our tree data to be in a sorted state. If this is not the
+            case, serialization will not generate a correct tree representation as these
+            are assumed to be sorted by algorithms.
+        """
         tree_to_stream(self._cache, stream.write)
         return self
 
-    def _deserialize(self, stream):
+    def _deserialize(self, stream: "BytesIO") -> "Tree":
         self._cache = tree_entries_from_data(stream.read())
         return self
 
 
 # END tree
 
-# finalize map definition
+# Finalize map definition.
 Tree._map_id_to_type[Tree.tree_id] = Tree
diff --git a/git/objects/util.py b/git/objects/util.py
index cefef862d..a68d701f5 100644
--- a/git/objects/util.py
+++ b/git/objects/util.py
@@ -1,294 +1,550 @@
-# util.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-"""Module for general utility functions"""
-from git.util import (
-    IterableList,
-    Actor
-)
-
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Utility functions for working with git objects."""
+
+__all__ = [
+    "get_object_type_by_name",
+    "parse_date",
+    "parse_actor_and_date",
+    "ProcessStreamAdapter",
+    "Traversable",
+    "altz_to_utctz_str",
+    "utctz_to_altz",
+    "verify_utctz",
+    "Actor",
+    "tzoffset",
+    "utc",
+]
+
+from abc import ABC, abstractmethod
+import calendar
+from collections import deque
+from datetime import datetime, timedelta, tzinfo
 import re
-from collections import deque as Deque
-
 from string import digits
 import time
-import calendar
+import warnings
+
+from git.util import Actor, IterableList, IterableObj
+
+# typing ------------------------------------------------------------
+
+from typing import (
+    Any,
+    Callable,
+    Deque,
+    Iterator,
+    NamedTuple,
+    Sequence,
+    TYPE_CHECKING,
+    Tuple,
+    Type,
+    TypeVar,
+    Union,
+    cast,
+    overload,
+)
 
-__all__ = ('get_object_type_by_name', 'parse_date', 'parse_actor_and_date',
-           'ProcessStreamAdapter', 'Traversable', 'altz_to_utctz_str', 'utctz_to_altz',
-           'verify_utctz', 'Actor')
+from git.types import Has_id_attribute, Literal
 
-#{ Functions
+if TYPE_CHECKING:
+    from io import BytesIO, StringIO
+    from subprocess import Popen
 
+    from git.types import Protocol, runtime_checkable
+
+    from .blob import Blob
+    from .commit import Commit
+    from .submodule.base import Submodule
+    from .tag import TagObject
+    from .tree import TraversedTreeTup, Tree
+else:
+    Protocol = ABC
+
+    def runtime_checkable(f):
+        return f
+
+
+class TraverseNT(NamedTuple):
+    depth: int
+    item: Union["Traversable", "Blob"]
+    src: Union["Traversable", None]
+
+
+T_TIobj = TypeVar("T_TIobj", bound="TraversableIterableObj")  # For TraversableIterableObj.traverse()
+
+TraversedTup = Union[
+    Tuple[Union["Traversable", None], "Traversable"],  # For Commit, Submodule.
+    "TraversedTreeTup",  # For Tree.traverse().
+]
+
+# --------------------------------------------------------------------
+
+ZERO = timedelta(0)
+
+# { Functions
+
+
+def mode_str_to_int(modestr: Union[bytes, str]) -> int:
+    """Convert mode bits from an octal mode string to an integer mode for git.
+
+    :param modestr:
+        String like ``755`` or ``644`` or ``100644`` - only the last 6 chars will be
+        used.
 
-def mode_str_to_int(modestr):
-    """
-    :param modestr: string like 755 or 644 or 100644 - only the last 6 chars will be used
     :return:
-        String identifying a mode compatible to the mode methods ids of the
-        stat module regarding the rwx permissions for user, group and other,
-        special flags and file system flags, i.e. whether it is a symlink
-        for example."""
+        String identifying a mode compatible to the mode methods ids of the :mod:`stat`
+        module regarding the rwx permissions for user, group and other, special flags
+        and file system flags, such as whether it is a symlink.
+    """
     mode = 0
     for iteration, char in enumerate(reversed(modestr[-6:])):
+        char = cast(Union[str, int], char)
         mode += int(char) << iteration * 3
     # END for each char
     return mode
 
 
-def get_object_type_by_name(object_type_name):
-    """
-    :return: type suitable to handle the given object type name.
-        Use the type to create new instances.
+def get_object_type_by_name(
+    object_type_name: bytes,
+) -> Union[Type["Commit"], Type["TagObject"], Type["Tree"], Type["Blob"]]:
+    """Retrieve the Python class GitPython uses to represent a kind of Git object.
 
-    :param object_type_name: Member of TYPES
+    :return:
+        A type suitable to handle the given as `object_type_name`.
+        This type can be called create new instances.
+
+    :param object_type_name:
+        Member of :attr:`Object.TYPES <git.objects.base.Object.TYPES>`.
 
-    :raise ValueError: In case object_type_name is unknown"""
+    :raise ValueError:
+        If `object_type_name` is unknown.
+    """
     if object_type_name == b"commit":
         from . import commit
+
         return commit.Commit
     elif object_type_name == b"tag":
         from . import tag
+
         return tag.TagObject
     elif object_type_name == b"blob":
         from . import blob
+
         return blob.Blob
     elif object_type_name == b"tree":
         from . import tree
+
         return tree.Tree
     else:
-        raise ValueError("Cannot handle unknown object type: %s" % object_type_name)
+        raise ValueError("Cannot handle unknown object type: %s" % object_type_name.decode())
+
 
+def utctz_to_altz(utctz: str) -> int:
+    """Convert a git timezone offset into a timezone offset west of UTC in seconds
+    (compatible with :attr:`time.altzone`).
 
-def utctz_to_altz(utctz):
-    """we convert utctz to the timezone in seconds, it is the format time.altzone
-    returns. Git stores it as UTC timezone which has the opposite sign as well,
-    which explains the -1 * ( that was made explicit here )
-    :param utctz: git utc timezone string, i.e. +0200"""
-    return -1 * int(float(utctz) / 100 * 3600)
+    :param utctz:
+        git utc timezone string, e.g. +0200
+    """
+    int_utctz = int(utctz)
+    seconds = (abs(int_utctz) // 100) * 3600 + (abs(int_utctz) % 100) * 60
+    return seconds if int_utctz < 0 else -seconds
 
 
-def altz_to_utctz_str(altz):
-    """As above, but inverses the operation, returning a string that can be used
-    in commit objects"""
-    utci = -1 * int((altz / 3600) * 100)
-    utcs = str(abs(utci))
-    utcs = "0" * (4 - len(utcs)) + utcs
-    prefix = (utci < 0 and '-') or '+'
-    return prefix + utcs
+def altz_to_utctz_str(altz: float) -> str:
+    """Convert a timezone offset west of UTC in seconds into a Git timezone offset
+    string.
+
+    :param altz:
+        Timezone offset in seconds west of UTC.
+    """
+    hours = abs(altz) // 3600
+    minutes = (abs(altz) % 3600) // 60
+    sign = "-" if altz >= 60 else "+"
+    return "{}{:02}{:02}".format(sign, hours, minutes)
 
 
-def verify_utctz(offset):
-    """:raise ValueError: if offset is incorrect
-    :return: offset"""
+def verify_utctz(offset: str) -> str:
+    """
+    :raise ValueError:
+        If `offset` is incorrect.
+
+    :return:
+        `offset`
+    """
     fmt_exc = ValueError("Invalid timezone offset format: %s" % offset)
     if len(offset) != 5:
         raise fmt_exc
     if offset[0] not in "+-":
         raise fmt_exc
-    if offset[1] not in digits or\
-       offset[2] not in digits or\
-       offset[3] not in digits or\
-       offset[4] not in digits:
+    if offset[1] not in digits or offset[2] not in digits or offset[3] not in digits or offset[4] not in digits:
         raise fmt_exc
     # END for each char
     return offset
 
 
-def parse_date(string_date):
-    """
-    Parse the given date as one of the following
+class tzoffset(tzinfo):
+    def __init__(self, secs_west_of_utc: float, name: Union[None, str] = None) -> None:
+        self._offset = timedelta(seconds=-secs_west_of_utc)
+        self._name = name or "fixed"
+
+    def __reduce__(self) -> Tuple[Type["tzoffset"], Tuple[float, str]]:
+        return tzoffset, (-self._offset.total_seconds(), self._name)
+
+    def utcoffset(self, dt: Union[datetime, None]) -> timedelta:
+        return self._offset
+
+    def tzname(self, dt: Union[datetime, None]) -> str:
+        return self._name
+
+    def dst(self, dt: Union[datetime, None]) -> timedelta:
+        return ZERO
+
 
+utc = tzoffset(0, "UTC")
+
+
+def from_timestamp(timestamp: float, tz_offset: float) -> datetime:
+    """Convert a `timestamp` + `tz_offset` into an aware :class:`~datetime.datetime`
+    instance."""
+    utc_dt = datetime.fromtimestamp(timestamp, utc)
+    try:
+        local_dt = utc_dt.astimezone(tzoffset(tz_offset))
+        return local_dt
+    except ValueError:
+        return utc_dt
+
+
+def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]:
+    """Parse the given date as one of the following:
+
+        * Aware datetime instance
         * Git internal format: timestamp offset
-        * RFC 2822: Thu, 07 Apr 2005 22:13:13 +0200.
-        * ISO 8601 2005-04-07T22:13:13
-            The T can be a space as well
+        * :rfc:`2822`: ``Thu, 07 Apr 2005 22:13:13 +0200``
+        * ISO 8601: ``2005-04-07T22:13:13`` - The ``T`` can be a space as well.
 
-    :return: Tuple(int(timestamp_UTC), int(offset)), both in seconds since epoch
-    :raise ValueError: If the format could not be understood
-    :note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY.
+    :return:
+        Tuple(int(timestamp_UTC), int(offset)), both in seconds since epoch
+
+    :raise ValueError:
+        If the format could not be understood.
+
+    :note:
+        Date can also be ``YYYY.MM.DD``, ``MM/DD/YYYY`` and ``DD.MM.YYYY``.
     """
-    # git time
+    if isinstance(string_date, datetime):
+        if string_date.tzinfo:
+            utcoffset = cast(timedelta, string_date.utcoffset())  # typeguard, if tzinfoand is not None
+            offset = -int(utcoffset.total_seconds())
+            return int(string_date.astimezone(utc).timestamp()), offset
+        else:
+            raise ValueError(f"string_date datetime object without tzinfo, {string_date}")
+
+    # Git time
     try:
-        if string_date.count(' ') == 1 and string_date.rfind(':') == -1:
-            timestamp, offset = string_date.split()
-            timestamp = int(timestamp)
-            return timestamp, utctz_to_altz(verify_utctz(offset))
+        if string_date.count(" ") == 1 and string_date.rfind(":") == -1:
+            timestamp, offset_str = string_date.split()
+            if timestamp.startswith("@"):
+                timestamp = timestamp[1:]
+            timestamp_int = int(timestamp)
+            return timestamp_int, utctz_to_altz(verify_utctz(offset_str))
         else:
-            offset = "+0000"                    # local time by default
-            if string_date[-5] in '-+':
-                offset = verify_utctz(string_date[-5:])
+            offset_str = "+0000"  # Local time by default.
+            if string_date[-5] in "-+":
+                offset_str = verify_utctz(string_date[-5:])
                 string_date = string_date[:-6]  # skip space as well
             # END split timezone info
-            offset = utctz_to_altz(offset)
+            offset = utctz_to_altz(offset_str)
 
-            # now figure out the date and time portion - split time
-            date_formats = list()
+            # Now figure out the date and time portion - split time.
+            date_formats = []
             splitter = -1
-            if ',' in string_date:
+            if "," in string_date:
                 date_formats.append("%a, %d %b %Y")
-                splitter = string_date.rfind(' ')
+                splitter = string_date.rfind(" ")
             else:
-                # iso plus additional
+                # ISO plus additional
                 date_formats.append("%Y-%m-%d")
                 date_formats.append("%Y.%m.%d")
                 date_formats.append("%m/%d/%Y")
                 date_formats.append("%d.%m.%Y")
 
-                splitter = string_date.rfind('T')
+                splitter = string_date.rfind("T")
                 if splitter == -1:
-                    splitter = string_date.rfind(' ')
+                    splitter = string_date.rfind(" ")
                 # END handle 'T' and ' '
-            # END handle rfc or iso
+            # END handle RFC or ISO
 
             assert splitter > -1
 
-            # split date and time
-            time_part = string_date[splitter + 1:]    # skip space
+            # Split date and time.
+            time_part = string_date[splitter + 1 :]  # Skip space.
             date_part = string_date[:splitter]
 
-            # parse time
+            # Parse time.
             tstruct = time.strptime(time_part, "%H:%M:%S")
 
             for fmt in date_formats:
                 try:
                     dtstruct = time.strptime(date_part, fmt)
-                    utctime = calendar.timegm((dtstruct.tm_year, dtstruct.tm_mon, dtstruct.tm_mday,
-                                               tstruct.tm_hour, tstruct.tm_min, tstruct.tm_sec,
-                                               dtstruct.tm_wday, dtstruct.tm_yday, tstruct.tm_isdst))
+                    utctime = calendar.timegm(
+                        (
+                            dtstruct.tm_year,
+                            dtstruct.tm_mon,
+                            dtstruct.tm_mday,
+                            tstruct.tm_hour,
+                            tstruct.tm_min,
+                            tstruct.tm_sec,
+                            dtstruct.tm_wday,
+                            dtstruct.tm_yday,
+                            tstruct.tm_isdst,
+                        )
+                    )
                     return int(utctime), offset
                 except ValueError:
                     continue
                 # END exception handling
             # END for each fmt
 
-            # still here ? fail
+            # Still here ? fail.
             raise ValueError("no format matched")
         # END handle format
-    except Exception:
-        raise ValueError("Unsupported date format: %s" % string_date)
+    except Exception as e:
+        raise ValueError(f"Unsupported date format or type: {string_date}, type={type(string_date)}") from e
     # END handle exceptions
 
 
-# precompiled regex
-_re_actor_epoch = re.compile(r'^.+? (.*) (\d+) ([+-]\d+).*$')
-_re_only_actor = re.compile(r'^.+? (.*)$')
+# Precompiled regexes
+_re_actor_epoch = re.compile(r"^.+? (.*) (\d+) ([+-]\d+).*$")
+_re_only_actor = re.compile(r"^.+? (.*)$")
 
 
-def parse_actor_and_date(line):
+def parse_actor_and_date(line: str) -> Tuple[Actor, int, int]:
     """Parse out the actor (author or committer) info from a line like::
 
         author Tom Preston-Werner <tom@mojombo.com> 1191999972 -0700
 
-    :return: [Actor, int_seconds_since_epoch, int_timezone_offset]"""
-    actor, epoch, offset = '', 0, 0
+    :return:
+        [Actor, int_seconds_since_epoch, int_timezone_offset]
+    """
+    actor, epoch, offset = "", "0", "0"
     m = _re_actor_epoch.search(line)
     if m:
         actor, epoch, offset = m.groups()
     else:
         m = _re_only_actor.search(line)
-        actor = m.group(1) if m else line or ''
+        actor = m.group(1) if m else line or ""
     return (Actor._from_string(actor), int(epoch), utctz_to_altz(offset))
 
-#} END functions
+
+# } END functions
 
 
-#{ Classes
+# { Classes
 
-class ProcessStreamAdapter(object):
 
-    """Class wireing all calls to the contained Process instance.
+class ProcessStreamAdapter:
+    """Class wiring all calls to the contained Process instance.
 
     Use this type to hide the underlying process to provide access only to a specified
-    stream. The process is usually wrapped into an AutoInterrupt class to kill
-    it if the instance goes out of scope."""
+    stream. The process is usually wrapped into an :class:`~git.cmd.Git.AutoInterrupt`
+    class to kill it if the instance goes out of scope.
+    """
+
     __slots__ = ("_proc", "_stream")
 
-    def __init__(self, process, stream_name):
+    def __init__(self, process: "Popen", stream_name: str) -> None:
         self._proc = process
-        self._stream = getattr(process, stream_name)
+        self._stream: StringIO = getattr(process, stream_name)  # guessed type
 
-    def __getattr__(self, attr):
+    def __getattr__(self, attr: str) -> Any:
         return getattr(self._stream, attr)
 
 
-class Traversable(object):
+@runtime_checkable
+class Traversable(Protocol):
+    """Simple interface to perform depth-first or breadth-first traversals in one
+    direction.
 
-    """Simple interface to perforam depth-first or breadth-first traversals
-    into one direction.
     Subclasses only need to implement one function.
-    Instances of the Subclass must be hashable"""
-    __slots__ = tuple()
+
+    Instances of the subclass must be hashable.
+
+    Defined subclasses:
+
+    * :class:`Commit <git.objects.Commit>`
+    * :class:`Tree <git.objects.tree.Tree>`
+    * :class:`Submodule <git.objects.submodule.base.Submodule>`
+    """
+
+    __slots__ = ()
 
     @classmethod
-    def _get_intermediate_items(cls, item):
+    @abstractmethod
+    def _get_intermediate_items(cls, item: Any) -> Sequence["Traversable"]:
         """
-        Returns:
-            List of items connected to the given item.
-            Must be implemented in subclass
+        :return:
+            Tuple of items connected to the given item.
+            Must be implemented in subclass.
+
+        class Commit::     (cls, Commit) -> Tuple[Commit, ...]
+        class Submodule::  (cls, Submodule) -> Iterablelist[Submodule]
+        class Tree::       (cls, Tree) -> Tuple[Tree, ...]
         """
         raise NotImplementedError("To be implemented in subclass")
 
-    def list_traverse(self, *args, **kwargs):
+    @abstractmethod
+    def list_traverse(self, *args: Any, **kwargs: Any) -> Any:
+        """Traverse self and collect all items found.
+
+        Calling this directly on the abstract base class, including via a ``super()``
+        proxy, is deprecated. Only overridden implementations should be called.
+        """
+        warnings.warn(
+            "list_traverse() method should only be called from subclasses."
+            " Calling from Traversable abstract class will raise NotImplementedError in 4.0.0."
+            " The concrete subclasses in GitPython itself are 'Commit', 'RootModule', 'Submodule', and 'Tree'.",
+            DeprecationWarning,
+            stacklevel=2,
+        )
+        return self._list_traverse(*args, **kwargs)
+
+    def _list_traverse(
+        self, as_edge: bool = False, *args: Any, **kwargs: Any
+    ) -> IterableList[Union["Commit", "Submodule", "Tree", "Blob"]]:
+        """Traverse self and collect all items found.
+
+        :return:
+            :class:`~git.util.IterableList` with the results of the traversal as
+            produced by :meth:`traverse`::
+
+                Commit -> IterableList[Commit]
+                Submodule ->  IterableList[Submodule]
+                Tree -> IterableList[Union[Submodule, Tree, Blob]]
         """
-        :return: IterableList with the results of the traversal as produced by
-            traverse()"""
-        out = IterableList(self._id_attribute_)
-        out.extend(self.traverse(*args, **kwargs))
-        return out
+        # Commit and Submodule have id.__attribute__ as IterableObj.
+        # Tree has id.__attribute__ inherited from IndexObject.
+        if isinstance(self, Has_id_attribute):
+            id = self._id_attribute_
+        else:
+            # Shouldn't reach here, unless Traversable subclass created with no
+            # _id_attribute_.
+            id = ""
+            # Could add _id_attribute_ to Traversable, or make all Traversable also
+            # Iterable?
+
+        if not as_edge:
+            out: IterableList[Union["Commit", "Submodule", "Tree", "Blob"]] = IterableList(id)
+            out.extend(self.traverse(as_edge=as_edge, *args, **kwargs))  # noqa: B026
+            return out
+            # Overloads in subclasses (mypy doesn't allow typing self: subclass).
+            # Union[IterableList['Commit'], IterableList['Submodule'], IterableList[Union['Submodule', 'Tree', 'Blob']]]
+        else:
+            # Raise DeprecationWarning, it doesn't make sense to use this.
+            out_list: IterableList = IterableList(self.traverse(*args, **kwargs))
+            return out_list
 
-    def traverse(self, predicate=lambda i, d: True,
-                 prune=lambda i, d: False, depth=-1, branch_first=True,
-                 visit_once=True, ignore_self=1, as_edge=False):
-        """:return: iterator yieling of items found when traversing self
+    @abstractmethod
+    def traverse(self, *args: Any, **kwargs: Any) -> Any:
+        """Iterator yielding items found when traversing self.
 
-        :param predicate: f(i,d) returns False if item i at depth d should not be included in the result
+        Calling this directly on the abstract base class, including via a ``super()``
+        proxy, is deprecated. Only overridden implementations should be called.
+        """
+        warnings.warn(
+            "traverse() method should only be called from subclasses."
+            " Calling from Traversable abstract class will raise NotImplementedError in 4.0.0."
+            " The concrete subclasses in GitPython itself are 'Commit', 'RootModule', 'Submodule', and 'Tree'.",
+            DeprecationWarning,
+            stacklevel=2,
+        )
+        return self._traverse(*args, **kwargs)
+
+    def _traverse(
+        self,
+        predicate: Callable[[Union["Traversable", "Blob", TraversedTup], int], bool] = lambda i, d: True,
+        prune: Callable[[Union["Traversable", "Blob", TraversedTup], int], bool] = lambda i, d: False,
+        depth: int = -1,
+        branch_first: bool = True,
+        visit_once: bool = True,
+        ignore_self: int = 1,
+        as_edge: bool = False,
+    ) -> Union[Iterator[Union["Traversable", "Blob"]], Iterator[TraversedTup]]:
+        """Iterator yielding items found when traversing `self`.
+
+        :param predicate:
+            A function ``f(i,d)`` that returns ``False`` if item i at depth ``d`` should
+            not be included in the result.
 
         :param prune:
-            f(i,d) return True if the search should stop at item i at depth d.
-            Item i will not be returned.
+            A function ``f(i,d)`` that returns ``True`` if the search should stop at
+            item ``i`` at depth ``d``. Item ``i`` will not be returned.
 
         :param depth:
-            define at which level the iteration should not go deeper
-            if -1, there is no limit
-            if 0, you would effectively only get self, the root of the iteration
-            i.e. if 1, you would only get the first level of predessessors/successors
+            Defines at which level the iteration should not go deeper if -1. There is no
+            limit if 0, you would effectively only get `self`, the root of the
+            iteration. If 1, you would only get the first level of
+            predecessors/successors.
 
         :param branch_first:
-            if True, items will be returned branch first, otherwise depth first
+            If ``True``, items will be returned branch first, otherwise depth first.
 
         :param visit_once:
-            if True, items will only be returned once, although they might be encountered
-            several times. Loops are prevented that way.
+            If ``True``, items will only be returned once, although they might be
+            encountered several times. Loops are prevented that way.
 
         :param ignore_self:
-            if True, self will be ignored and automatically pruned from
-            the result. Otherwise it will be the first item to be returned.
-            If as_edge is True, the source of the first edge is None
+            If ``True``, `self` will be ignored and automatically pruned from the
+            result. Otherwise it will be the first item to be returned. If `as_edge` is
+            ``True``, the source of the first edge is ``None``.
 
         :param as_edge:
-            if True, return a pair of items, first being the source, second the
-            destinatination, i.e. tuple(src, dest) with the edge spanning from
-            source to destination"""
-        visited = set()
-        stack = Deque()
-        stack.append((0, self, None))       # self is always depth level 0
+            If ``True``, return a pair of items, first being the source, second the
+            destination, i.e. tuple(src, dest) with the edge spanning from source to
+            destination.
+
+        :return:
+            Iterator yielding items found when traversing `self`::
+
+                Commit -> Iterator[Union[Commit, Tuple[Commit, Commit]] Submodule ->
+                Iterator[Submodule, Tuple[Submodule, Submodule]] Tree ->
+                Iterator[Union[Blob, Tree, Submodule,
+                                        Tuple[Union[Submodule, Tree], Union[Blob, Tree,
+                                        Submodule]]]
+
+                ignore_self=True is_edge=True -> Iterator[item] ignore_self=True
+                is_edge=False --> Iterator[item] ignore_self=False is_edge=True ->
+                Iterator[item] | Iterator[Tuple[src, item]] ignore_self=False
+                is_edge=False -> Iterator[Tuple[src, item]]
+        """
 
-        def addToStack(stack, item, branch_first, depth):
+        visited = set()
+        stack: Deque[TraverseNT] = deque()
+        stack.append(TraverseNT(0, self, None))  # self is always depth level 0.
+
+        def addToStack(
+            stack: Deque[TraverseNT],
+            src_item: "Traversable",
+            branch_first: bool,
+            depth: int,
+        ) -> None:
             lst = self._get_intermediate_items(item)
-            if not lst:
+            if not lst:  # Empty list
                 return
             if branch_first:
-                stack.extendleft((depth, i, item) for i in lst)
+                stack.extendleft(TraverseNT(depth, i, src_item) for i in lst)
             else:
-                reviter = ((depth, lst[i], item) for i in range(len(lst) - 1, -1, -1))
+                reviter = (TraverseNT(depth, lst[i], src_item) for i in range(len(lst) - 1, -1, -1))
                 stack.extend(reviter)
+
         # END addToStack local method
 
         while stack:
-            d, item, src = stack.pop()          # depth of item, item, item_source
+            d, item, src = stack.pop()  # Depth of item, item, item_source
 
             if visit_once and item in visited:
                 continue
@@ -296,7 +552,14 @@ def addToStack(stack, item, branch_first, depth):
             if visit_once:
                 visited.add(item)
 
-            rval = (as_edge and (src, item)) or item
+            rval: Union[TraversedTup, "Traversable", "Blob"]
+            if as_edge:
+                # If as_edge return (src, item) unless rrc is None
+                # (e.g. for first item).
+                rval = (src, item)
+            else:
+                rval = item
+
             if prune(rval, d):
                 continue
 
@@ -304,29 +567,134 @@ def addToStack(stack, item, branch_first, depth):
             if not skipStartItem and predicate(rval, d):
                 yield rval
 
-            # only continue to next level if this is appropriate !
-            nd = d + 1
-            if depth > -1 and nd > depth:
+            # Only continue to next level if this is appropriate!
+            next_d = d + 1
+            if depth > -1 and next_d > depth:
                 continue
 
-            addToStack(stack, item, branch_first, nd)
+            addToStack(stack, item, branch_first, next_d)
         # END for each item on work stack
 
 
-class Serializable(object):
+@runtime_checkable
+class Serializable(Protocol):
+    """Defines methods to serialize and deserialize objects from and into a data
+    stream."""
+
+    __slots__ = ()
+
+    # @abstractmethod
+    def _serialize(self, stream: "BytesIO") -> "Serializable":
+        """Serialize the data of this object into the given data stream.
 
-    """Defines methods to serialize and deserialize objects from and into a data stream"""
-    __slots__ = tuple()
+        :note:
+            A serialized object would :meth:`_deserialize` into the same object.
 
-    def _serialize(self, stream):
-        """Serialize the data of this object into the given data stream
-        :note: a serialized object would ``_deserialize`` into the same objet
-        :param stream: a file-like object
-        :return: self"""
+        :param stream:
+            A file-like object.
+
+        :return:
+            self
+        """
         raise NotImplementedError("To be implemented in subclass")
 
-    def _deserialize(self, stream):
-        """Deserialize all information regarding this object from the stream
-        :param stream: a file-like object
-        :return: self"""
+    # @abstractmethod
+    def _deserialize(self, stream: "BytesIO") -> "Serializable":
+        """Deserialize all information regarding this object from the stream.
+
+        :param stream:
+            A file-like object.
+
+        :return:
+            self
+        """
         raise NotImplementedError("To be implemented in subclass")
+
+
+class TraversableIterableObj(IterableObj, Traversable):
+    __slots__ = ()
+
+    TIobj_tuple = Tuple[Union[T_TIobj, None], T_TIobj]
+
+    def list_traverse(self: T_TIobj, *args: Any, **kwargs: Any) -> IterableList[T_TIobj]:
+        return super()._list_traverse(*args, **kwargs)
+
+    @overload
+    def traverse(self: T_TIobj) -> Iterator[T_TIobj]: ...
+
+    @overload
+    def traverse(
+        self: T_TIobj,
+        predicate: Callable[[Union[T_TIobj, Tuple[Union[T_TIobj, None], T_TIobj]], int], bool],
+        prune: Callable[[Union[T_TIobj, Tuple[Union[T_TIobj, None], T_TIobj]], int], bool],
+        depth: int,
+        branch_first: bool,
+        visit_once: bool,
+        ignore_self: Literal[True],
+        as_edge: Literal[False],
+    ) -> Iterator[T_TIobj]: ...
+
+    @overload
+    def traverse(
+        self: T_TIobj,
+        predicate: Callable[[Union[T_TIobj, Tuple[Union[T_TIobj, None], T_TIobj]], int], bool],
+        prune: Callable[[Union[T_TIobj, Tuple[Union[T_TIobj, None], T_TIobj]], int], bool],
+        depth: int,
+        branch_first: bool,
+        visit_once: bool,
+        ignore_self: Literal[False],
+        as_edge: Literal[True],
+    ) -> Iterator[Tuple[Union[T_TIobj, None], T_TIobj]]: ...
+
+    @overload
+    def traverse(
+        self: T_TIobj,
+        predicate: Callable[[Union[T_TIobj, TIobj_tuple], int], bool],
+        prune: Callable[[Union[T_TIobj, TIobj_tuple], int], bool],
+        depth: int,
+        branch_first: bool,
+        visit_once: bool,
+        ignore_self: Literal[True],
+        as_edge: Literal[True],
+    ) -> Iterator[Tuple[T_TIobj, T_TIobj]]: ...
+
+    def traverse(
+        self: T_TIobj,
+        predicate: Callable[[Union[T_TIobj, TIobj_tuple], int], bool] = lambda i, d: True,
+        prune: Callable[[Union[T_TIobj, TIobj_tuple], int], bool] = lambda i, d: False,
+        depth: int = -1,
+        branch_first: bool = True,
+        visit_once: bool = True,
+        ignore_self: int = 1,
+        as_edge: bool = False,
+    ) -> Union[Iterator[T_TIobj], Iterator[Tuple[T_TIobj, T_TIobj]], Iterator[TIobj_tuple]]:
+        """For documentation, see :meth:`Traversable._traverse`."""
+
+        ## To typecheck instead of using cast:
+        #
+        # import itertools
+        # from git.types import TypeGuard
+        # def is_commit_traversed(inp: Tuple) -> TypeGuard[Tuple[Iterator[Tuple['Commit', 'Commit']]]]:
+        #     for x in inp[1]:
+        #         if not isinstance(x, tuple) and len(x) != 2:
+        #             if all(isinstance(inner, Commit) for inner in x):
+        #                 continue
+        #     return True
+        #
+        # ret = super(Commit, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self, as_edge)
+        # ret_tup = itertools.tee(ret, 2)
+        # assert is_commit_traversed(ret_tup), f"{[type(x) for x in list(ret_tup[0])]}"
+        # return ret_tup[0]
+
+        return cast(
+            Union[Iterator[T_TIobj], Iterator[Tuple[Union[None, T_TIobj], T_TIobj]]],
+            super()._traverse(
+                predicate,  # type: ignore[arg-type]
+                prune,  # type: ignore[arg-type]
+                depth,
+                branch_first,
+                visit_once,
+                ignore_self,
+                as_edge,
+            ),
+        )
diff --git a/git/odict.py b/git/odict.py
deleted file mode 100644
index f003d14ec..000000000
--- a/git/odict.py
+++ /dev/null
@@ -1,10 +0,0 @@
-try:
-    from collections import OrderedDict
-except ImportError:
-    try:
-        from ordereddict import OrderedDict
-    except ImportError:
-        import warnings
-        warnings.warn("git-python needs the ordereddict module installed in python below 2.6 and below.")
-        warnings.warn("Using standard dictionary as substitute, and cause reordering when writing git config")
-        OrderedDict = dict
diff --git a/git/test/performance/__init__.py b/git/py.typed
similarity index 100%
rename from git/test/performance/__init__.py
rename to git/py.typed
diff --git a/git/refs/__init__.py b/git/refs/__init__.py
index ded8b1f7c..d6157e6f3 100644
--- a/git/refs/__init__.py
+++ b/git/refs/__init__.py
@@ -1,10 +1,21 @@
-# flake8: noqa
-from __future__ import absolute_import
-# import all modules in order, fix the names they require
-from .symbolic import *
-from .reference import *
-from .head import *
-from .tag import *
-from .remote import *
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-from .log import *
+__all__ = [
+    "HEAD",
+    "Head",
+    "RefLog",
+    "RefLogEntry",
+    "Reference",
+    "RemoteReference",
+    "SymbolicReference",
+    "Tag",
+    "TagReference",
+]
+
+from .head import HEAD, Head
+from .log import RefLog, RefLogEntry
+from .reference import Reference
+from .remote import RemoteReference
+from .symbolic import SymbolicReference
+from .tag import Tag, TagReference
diff --git a/git/refs/head.py b/git/refs/head.py
index 18dac3497..683634451 100644
--- a/git/refs/head.py
+++ b/git/refs/head.py
@@ -1,66 +1,106 @@
-from git.config import SectionConstraint
-from git.util import join_path
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Some ref-based objects.
+
+Note the distinction between the :class:`HEAD` and :class:`Head` classes.
+"""
+
+__all__ = ["HEAD", "Head"]
+
+from git.config import GitConfigParser, SectionConstraint
 from git.exc import GitCommandError
+from git.util import join_path
 
-from .symbolic import SymbolicReference
 from .reference import Reference
+from .symbolic import SymbolicReference
 
-__all__ = ["HEAD", "Head"]
+# typing ---------------------------------------------------
+
+from typing import Any, Sequence, TYPE_CHECKING, Union
+
+from git.types import Commit_ish, PathLike
+
+if TYPE_CHECKING:
+    from git.objects import Commit
+    from git.refs import RemoteReference
+    from git.repo import Repo
+
+# -------------------------------------------------------------------
+
+
+def strip_quotes(string: str) -> str:
+    if string.startswith('"') and string.endswith('"'):
+        return string[1:-1]
+    return string
 
 
 class HEAD(SymbolicReference):
+    """Special case of a :class:`~git.refs.symbolic.SymbolicReference` representing the
+    repository's HEAD reference."""
+
+    _HEAD_NAME = "HEAD"
+    _ORIG_HEAD_NAME = "ORIG_HEAD"
+
+    __slots__ = ()
 
-    """Special case of a Symbolic Reference as it represents the repository's
-    HEAD reference."""
-    _HEAD_NAME = 'HEAD'
-    _ORIG_HEAD_NAME = 'ORIG_HEAD'
-    __slots__ = tuple()
+    # TODO: This can be removed once SymbolicReference.commit has static type hints.
+    commit: "Commit"
 
-    def __init__(self, repo, path=_HEAD_NAME):
+    def __init__(self, repo: "Repo", path: PathLike = _HEAD_NAME) -> None:
         if path != self._HEAD_NAME:
             raise ValueError("HEAD instance must point to %r, got %r" % (self._HEAD_NAME, path))
-        super(HEAD, self).__init__(repo, path)
+        super().__init__(repo, path)
 
-    def orig_head(self):
+    def orig_head(self) -> SymbolicReference:
+        """
+        :return:
+            :class:`~git.refs.symbolic.SymbolicReference` pointing at the ORIG_HEAD,
+            which is maintained to contain the previous value of HEAD.
         """
-        :return: SymbolicReference pointing at the ORIG_HEAD, which is maintained
-            to contain the previous value of HEAD"""
         return SymbolicReference(self.repo, self._ORIG_HEAD_NAME)
 
-    def reset(self, commit='HEAD', index=True, working_tree=False,
-              paths=None, **kwargs):
-        """Reset our HEAD to the given commit optionally synchronizing
-        the index and working tree. The reference we refer to will be set to
-        commit as well.
+    def reset(
+        self,
+        commit: Union[Commit_ish, SymbolicReference, str] = "HEAD",
+        index: bool = True,
+        working_tree: bool = False,
+        paths: Union[PathLike, Sequence[PathLike], None] = None,
+        **kwargs: Any,
+    ) -> "HEAD":
+        """Reset our HEAD to the given commit optionally synchronizing the index and
+        working tree. The reference we refer to will be set to commit as well.
 
         :param commit:
-            Commit object, Reference Object or string identifying a revision we
-            should reset HEAD to.
+            :class:`~git.objects.commit.Commit`, :class:`~git.refs.reference.Reference`,
+            or string identifying a revision we should reset HEAD to.
 
         :param index:
-            If True, the index will be set to match the given commit. Otherwise
-            it will not be touched.
+            If ``True``, the index will be set to match the given commit.
+            Otherwise it will not be touched.
 
         :param working_tree:
-            If True, the working tree will be forcefully adjusted to match the given
+            If ``True``, the working tree will be forcefully adjusted to match the given
             commit, possibly overwriting uncommitted changes without warning.
-            If working_tree is True, index must be true as well
+            If `working_tree` is ``True``, `index` must be ``True`` as well.
 
         :param paths:
             Single path or list of paths relative to the git root directory
             that are to be reset. This allows to partially reset individual files.
 
         :param kwargs:
-            Additional arguments passed to git-reset.
+            Additional arguments passed to :manpage:`git-reset(1)`.
 
-        :return: self"""
+        :return:
+            self
+        """
+        mode: Union[str, None]
         mode = "--soft"
-        add_arg = None
         if index:
             mode = "--mixed"
 
-            # it appears, some git-versions declare mixed and paths deprecated
-            # see http://github.com/Byron/GitPython/issues#issue/2
+            # Explicit "--mixed" when passing paths is deprecated since git 1.5.4.
+            # See https://github.com/gitpython-developers/GitPython/discussions/1876.
             if paths:
                 mode = None
             # END special case
@@ -73,15 +113,11 @@ def reset(self, commit='HEAD', index=True, working_tree=False,
 
         # END working tree handling
 
-        if paths:
-            add_arg = "--"
-        # END nicely separate paths from rest
-
         try:
-            self.repo.git.reset(mode, commit, add_arg, paths, **kwargs)
+            self.repo.git.reset(mode, commit, "--", paths, **kwargs)
         except GitCommandError as e:
             # git nowadays may use 1 as status to indicate there are still unstaged
-            # modifications after the reset
+            # modifications after the reset.
             if e.status != 1:
                 raise
         # END handle exception
@@ -90,9 +126,8 @@ def reset(self, commit='HEAD', index=True, working_tree=False,
 
 
 class Head(Reference):
-
-    """A Head is a named reference to a Commit. Every Head instance contains a name
-    and a Commit object.
+    """A Head is a named reference to a :class:`~git.objects.commit.Commit`. Every Head
+    instance contains a name and a :class:`~git.objects.commit.Commit` object.
 
     Examples::
 
@@ -106,81 +141,95 @@ class Head(Reference):
         <git.Commit "1c09f116cbc2cb4100fb6935bb162daa4723f455">
 
         >>> head.commit.hexsha
-        '1c09f116cbc2cb4100fb6935bb162daa4723f455'"""
+        '1c09f116cbc2cb4100fb6935bb162daa4723f455'
+    """
+
     _common_path_default = "refs/heads"
     k_config_remote = "remote"
-    k_config_remote_ref = "merge"           # branch to merge from remote
+    k_config_remote_ref = "merge"  # Branch to merge from remote.
 
     @classmethod
-    def delete(cls, repo, *heads, **kwargs):
-        """Delete the given heads
+    def delete(cls, repo: "Repo", *heads: "Union[Head, str]", force: bool = False, **kwargs: Any) -> None:
+        """Delete the given heads.
 
         :param force:
-            If True, the heads will be deleted even if they are not yet merged into
-            the main development stream.
-            Default False"""
-        force = kwargs.get("force", False)
+            If ``True``, the heads will be deleted even if they are not yet merged into
+            the main development stream. Default ``False``.
+        """
         flag = "-d"
         if force:
             flag = "-D"
         repo.git.branch(flag, *heads)
 
-    def set_tracking_branch(self, remote_reference):
-        """
-        Configure this branch to track the given remote reference. This will alter
-            this branch's configuration accordingly.
+    def set_tracking_branch(self, remote_reference: Union["RemoteReference", None]) -> "Head":
+        """Configure this branch to track the given remote reference. This will
+        alter this branch's configuration accordingly.
+
+        :param remote_reference:
+            The remote reference to track or None to untrack any references.
 
-        :param remote_reference: The remote reference to track or None to untrack
-            any references
-        :return: self"""
+        :return:
+            self
+        """
         from .remote import RemoteReference
+
         if remote_reference is not None and not isinstance(remote_reference, RemoteReference):
             raise ValueError("Incorrect parameter type: %r" % remote_reference)
         # END handle type
 
-        writer = self.config_writer()
-        if remote_reference is None:
-            writer.remove_option(self.k_config_remote)
-            writer.remove_option(self.k_config_remote_ref)
-            if len(writer.options()) == 0:
-                writer.remove_section()
-            # END handle remove section
-        else:
-            writer.set_value(self.k_config_remote, remote_reference.remote_name)
-            writer.set_value(self.k_config_remote_ref, Head.to_full_path(remote_reference.remote_head))
-        # END handle ref value
-        writer.release()
+        with self.config_writer() as writer:
+            if remote_reference is None:
+                writer.remove_option(self.k_config_remote)
+                writer.remove_option(self.k_config_remote_ref)
+                if len(writer.options()) == 0:
+                    writer.remove_section()
+            else:
+                writer.set_value(self.k_config_remote, remote_reference.remote_name)
+                writer.set_value(
+                    self.k_config_remote_ref,
+                    Head.to_full_path(remote_reference.remote_head),
+                )
 
         return self
 
-    def tracking_branch(self):
+    def tracking_branch(self) -> Union["RemoteReference", None]:
+        """
+        :return:
+            The remote reference we are tracking, or ``None`` if we are not a tracking
+            branch.
         """
-        :return: The remote_reference we are tracking, or None if we are
-            not a tracking branch"""
         from .remote import RemoteReference
+
         reader = self.config_reader()
         if reader.has_option(self.k_config_remote) and reader.has_option(self.k_config_remote_ref):
-            ref = Head(self.repo, Head.to_full_path(reader.get_value(self.k_config_remote_ref)))
+            ref = Head(
+                self.repo,
+                Head.to_full_path(strip_quotes(reader.get_value(self.k_config_remote_ref))),
+            )
             remote_refpath = RemoteReference.to_full_path(join_path(reader.get_value(self.k_config_remote), ref.name))
             return RemoteReference(self.repo, remote_refpath)
         # END handle have tracking branch
 
-        # we are not a tracking branch
+        # We are not a tracking branch.
         return None
 
-    def rename(self, new_path, force=False):
-        """Rename self to a new path
+    def rename(self, new_path: PathLike, force: bool = False) -> "Head":
+        """Rename self to a new path.
 
         :param new_path:
-            Either a simple name or a path, i.e. new_name or features/new_name.
-            The prefix refs/heads is implied
+            Either a simple name or a path, e.g. ``new_name`` or ``features/new_name``.
+            The prefix ``refs/heads`` is implied.
 
         :param force:
-            If True, the rename will succeed even if a head with the target name
+            If ``True``, the rename will succeed even if a head with the target name
             already exists.
 
-        :return: self
-        :note: respects the ref log as git commands are used"""
+        :return:
+            self
+
+        :note:
+            Respects the ref log, as git commands are used.
+        """
         flag = "-m"
         if force:
             flag = "-M"
@@ -189,39 +238,45 @@ def rename(self, new_path, force=False):
         self.path = "%s/%s" % (self._common_path_default, new_path)
         return self
 
-    def checkout(self, force=False, **kwargs):
-        """Checkout this head by setting the HEAD to this reference, by updating the index
-        to reflect the tree we point to and by updating the working tree to reflect
-        the latest index.
+    def checkout(self, force: bool = False, **kwargs: Any) -> Union["HEAD", "Head"]:
+        """Check out this head by setting the HEAD to this reference, by updating the
+        index to reflect the tree we point to and by updating the working tree to
+        reflect the latest index.
 
         The command will fail if changed working tree files would be overwritten.
 
         :param force:
-            If True, changes to the index and the working tree will be discarded.
-            If False, GitCommandError will be raised in that situation.
+            If ``True``, changes to the index and the working tree will be discarded.
+            If ``False``, :exc:`~git.exc.GitCommandError` will be raised in that
+            situation.
 
         :param kwargs:
-            Additional keyword arguments to be passed to git checkout, i.e.
-            b='new_branch' to create a new branch at the given spot.
+            Additional keyword arguments to be passed to git checkout, e.g.
+            ``b="new_branch"`` to create a new branch at the given spot.
 
         :return:
-            The active branch after the checkout operation, usually self unless
-            a new branch has been created.
+            The active branch after the checkout operation, usually self unless a new
+            branch has been created.
+            If there is no active branch, as the HEAD is now detached, the HEAD
+            reference will be returned instead.
 
         :note:
-            By default it is only allowed to checkout heads - everything else
-            will leave the HEAD detached which is allowed and possible, but remains
-            a special state that some tools might not be able to handle."""
-        kwargs['f'] = force
-        if kwargs['f'] is False:
-            kwargs.pop('f')
+            By default it is only allowed to checkout heads - everything else will leave
+            the HEAD detached which is allowed and possible, but remains a special state
+            that some tools might not be able to handle.
+        """
+        kwargs["f"] = force
+        if kwargs["f"] is False:
+            kwargs.pop("f")
 
         self.repo.git.checkout(self, **kwargs)
-        return self.repo.active_branch
-
-    #{ Configruation
+        if self.repo.head.is_detached:
+            return self.repo.head
+        else:
+            return self.repo.active_branch
 
-    def _config_parser(self, read_only):
+    # { Configuration
+    def _config_parser(self, read_only: bool) -> SectionConstraint[GitConfigParser]:
         if read_only:
             parser = self.repo.config_reader()
         else:
@@ -230,16 +285,20 @@ def _config_parser(self, read_only):
 
         return SectionConstraint(parser, 'branch "%s"' % self.name)
 
-    def config_reader(self):
+    def config_reader(self) -> SectionConstraint[GitConfigParser]:
+        """
+        :return:
+            A configuration parser instance constrained to only read this instance's
+            values.
         """
-        :return: A configuration parser instance constrained to only read
-            this instance's values"""
         return self._config_parser(read_only=True)
 
-    def config_writer(self):
+    def config_writer(self) -> SectionConstraint[GitConfigParser]:
+        """
+        :return:
+            A configuration writer instance with read-and write access to options of
+            this head.
         """
-        :return: A configuration writer instance with read-and write acccess
-            to options of this head"""
         return self._config_parser(read_only=False)
 
-    #} END configuration
+    # } END configuration
diff --git a/git/refs/log.py b/git/refs/log.py
index fed136087..8f2f2cd38 100644
--- a/git/refs/log.py
+++ b/git/refs/log.py
@@ -1,163 +1,182 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["RefLog", "RefLogEntry"]
+
+from mmap import mmap
+import os.path as osp
+import re
+import time as _time
+
+from git.compat import defenc
+from git.objects.util import (
+    Serializable,
+    altz_to_utctz_str,
+    parse_date,
+)
 from git.util import (
     Actor,
     LockedFD,
     LockFile,
     assure_directory_exists,
-    to_native_path,
-)
-
-from gitdb.util import (
     bin_to_hex,
-    join,
     file_contents_ro_filepath,
+    to_native_path,
 )
 
-from git.objects.util import (
-    parse_date,
-    Serializable,
-    altz_to_utctz_str,
-)
-from git.compat import (
-    PY3,
-    xrange,
-    string_types,
-    defenc
-)
+# typing ------------------------------------------------------------------
 
-import time
-import re
+from typing import Iterator, List, Tuple, TYPE_CHECKING, Union
 
-__all__ = ["RefLog", "RefLogEntry"]
+from git.types import PathLike
 
+if TYPE_CHECKING:
+    from io import BytesIO
 
-class RefLogEntry(tuple):
+    from git.config import GitConfigParser, SectionConstraint
+    from git.refs import SymbolicReference
 
-    """Named tuple allowing easy access to the revlog data fields"""
-    _re_hexsha_only = re.compile('^[0-9A-Fa-f]{40}$')
-    __slots__ = tuple()
+# ------------------------------------------------------------------------------
 
-    def __repr__(self):
-        """Representation of ourselves in git reflog format"""
-        res = self.format()
-        if PY3:
-            return res
-        else:
-            # repr must return a string, which it will auto-encode from unicode using the default encoding.
-            # This usually fails, so we encode ourselves
-            return res.encode(defenc)
 
-    def format(self):
-        """:return: a string suitable to be placed in a reflog file"""
+class RefLogEntry(Tuple[str, str, Actor, Tuple[int, int], str]):
+    """Named tuple allowing easy access to the revlog data fields."""
+
+    _re_hexsha_only = re.compile(r"^[0-9A-Fa-f]{40}$")
+
+    __slots__ = ()
+
+    def __repr__(self) -> str:
+        """Representation of ourselves in git reflog format."""
+        return self.format()
+
+    def format(self) -> str:
+        """:return: A string suitable to be placed in a reflog file."""
         act = self.actor
         time = self.time
-        return u"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha,
-                                                            self.newhexsha,
-                                                            act.name,
-                                                            act.email,
-                                                            time[0],
-                                                            altz_to_utctz_str(time[1]),
-                                                            self.message)
+        return "{} {} {} <{}> {!s} {}\t{}\n".format(
+            self.oldhexsha,
+            self.newhexsha,
+            act.name,
+            act.email,
+            time[0],
+            altz_to_utctz_str(time[1]),
+            self.message,
+        )
 
     @property
-    def oldhexsha(self):
-        """The hexsha to the commit the ref pointed to before the change"""
+    def oldhexsha(self) -> str:
+        """The hexsha to the commit the ref pointed to before the change."""
         return self[0]
 
     @property
-    def newhexsha(self):
-        """The hexsha to the commit the ref now points to, after the change"""
+    def newhexsha(self) -> str:
+        """The hexsha to the commit the ref now points to, after the change."""
         return self[1]
 
     @property
-    def actor(self):
-        """Actor instance, providing access"""
+    def actor(self) -> Actor:
+        """Actor instance, providing access."""
         return self[2]
 
     @property
-    def time(self):
-        """time as tuple:
+    def time(self) -> Tuple[int, int]:
+        """Time as tuple:
 
-        * [0] = int(time)
-        * [1] = int(timezone_offset) in time.altzone format """
+        * [0] = ``int(time)``
+        * [1] = ``int(timezone_offset)`` in :attr:`time.altzone` format
+        """
         return self[3]
 
     @property
-    def message(self):
-        """Message describing the operation that acted on the reference"""
+    def message(self) -> str:
+        """Message describing the operation that acted on the reference."""
         return self[4]
 
     @classmethod
-    def new(self, oldhexsha, newhexsha, actor, time, tz_offset, message):
-        """:return: New instance of a RefLogEntry"""
+    def new(
+        cls,
+        oldhexsha: str,
+        newhexsha: str,
+        actor: Actor,
+        time: int,
+        tz_offset: int,
+        message: str,
+    ) -> "RefLogEntry":  # skipcq: PYL-W0621
+        """:return: New instance of a :class:`RefLogEntry`"""
         if not isinstance(actor, Actor):
             raise ValueError("Need actor instance, got %s" % actor)
         # END check types
         return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), message))
 
     @classmethod
-    def from_line(cls, line):
-        """:return: New RefLogEntry instance from the given revlog line.
-        :param line: line bytes without trailing newline
-        :raise ValueError: If line could not be parsed"""
-        line = line.decode(defenc)
-        fields = line.split('\t', 1)
+    def from_line(cls, line: bytes) -> "RefLogEntry":
+        """:return: New :class:`RefLogEntry` instance from the given revlog line.
+
+        :param line:
+            Line bytes without trailing newline
+
+        :raise ValueError:
+            If `line` could not be parsed.
+        """
+        line_str = line.decode(defenc)
+        fields = line_str.split("\t", 1)
         if len(fields) == 1:
             info, msg = fields[0], None
         elif len(fields) == 2:
             info, msg = fields
         else:
-            raise ValueError("Line must have up to two TAB-separated fields."
-                             " Got %s" % repr(line))
+            raise ValueError("Line must have up to two TAB-separated fields. Got %s" % repr(line_str))
         # END handle first split
 
         oldhexsha = info[:40]
         newhexsha = info[41:81]
         for hexsha in (oldhexsha, newhexsha):
             if not cls._re_hexsha_only.match(hexsha):
-                raise ValueError("Invalid hexsha: %s" % hexsha)
+                raise ValueError("Invalid hexsha: %r" % (hexsha,))
             # END if hexsha re doesn't match
         # END for each hexsha
 
-        email_end = info.find('>', 82)
+        email_end = info.find(">", 82)
         if email_end == -1:
             raise ValueError("Missing token: >")
         # END handle missing end brace
 
-        actor = Actor._from_string(info[82:email_end + 1])
-        time, tz_offset = parse_date(info[email_end + 2:])
+        actor = Actor._from_string(info[82 : email_end + 1])
+        time, tz_offset = parse_date(info[email_end + 2 :])  # skipcq: PYL-W0621
 
         return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), msg))
 
 
-class RefLog(list, Serializable):
-
-    """A reflog contains reflog entries, each of which defines a certain state
-    of the head in question. Custom query methods allow to retrieve log entries
-    by date or by other criteria.
+class RefLog(List[RefLogEntry], Serializable):
+    R"""A reflog contains :class:`RefLogEntry`\s, each of which defines a certain state
+    of the head in question. Custom query methods allow to retrieve log entries by date
+    or by other criteria.
 
-    Reflog entries are orded, the first added entry is first in the list, the last
-    entry, i.e. the last change of the head or reference, is last in the list."""
+    Reflog entries are ordered. The first added entry is first in the list. The last
+    entry, i.e. the last change of the head or reference, is last in the list.
+    """
 
-    __slots__ = ('_path', )
+    __slots__ = ("_path",)
 
-    def __new__(cls, filepath=None):
-        inst = super(RefLog, cls).__new__(cls)
+    def __new__(cls, filepath: Union[PathLike, None] = None) -> "RefLog":
+        inst = super().__new__(cls)
         return inst
 
-    def __init__(self, filepath=None):
+    def __init__(self, filepath: Union[PathLike, None] = None) -> None:
         """Initialize this instance with an optional filepath, from which we will
-        initialize our data. The path is also used to write changes back using
-        the write() method"""
+        initialize our data. The path is also used to write changes back using the
+        :meth:`write` method."""
         self._path = filepath
         if filepath is not None:
             self._read_from_file()
         # END handle filepath
 
-    def _read_from_file(self):
+    def _read_from_file(self) -> None:
         try:
             fmap = file_contents_ro_filepath(self._path, stream=True, allow_mmap=True)
         except OSError:
-            # it is possible and allowed that the file doesn't exist !
+            # It is possible and allowed that the file doesn't exist!
             return
         # END handle invalid log
 
@@ -167,80 +186,103 @@ def _read_from_file(self):
             fmap.close()
         # END handle closing of handle
 
-    #{ Interface
+    # { Interface
 
     @classmethod
-    def from_file(cls, filepath):
+    def from_file(cls, filepath: PathLike) -> "RefLog":
+        """
+        :return:
+            A new :class:`RefLog` instance containing all entries from the reflog at the
+            given `filepath`.
+
+        :param filepath:
+            Path to reflog.
+
+        :raise ValueError:
+            If the file could not be read or was corrupted in some way.
         """
-        :return: a new RefLog instance containing all entries from the reflog
-            at the given filepath
-        :param filepath: path to reflog
-        :raise ValueError: If the file could not be read or was corrupted in some way"""
         return cls(filepath)
 
     @classmethod
-    def path(cls, ref):
+    def path(cls, ref: "SymbolicReference") -> str:
+        """
+        :return:
+            String to absolute path at which the reflog of the given ref instance would
+            be found. The path is not guaranteed to point to a valid file though.
+
+        :param ref:
+            :class:`~git.refs.symbolic.SymbolicReference` instance
         """
-        :return: string to absolute path at which the reflog of the given ref
-            instance would be found. The path is not guaranteed to point to a valid
-            file though.
-        :param ref: SymbolicReference instance"""
-        return join(ref.repo.git_dir, "logs", to_native_path(ref.path))
+        return osp.join(ref.repo.git_dir, "logs", to_native_path(ref.path))
 
     @classmethod
-    def iter_entries(cls, stream):
+    def iter_entries(cls, stream: Union[str, "BytesIO", mmap]) -> Iterator[RefLogEntry]:
+        """
+        :return:
+            Iterator yielding :class:`RefLogEntry` instances, one for each line read
+            from the given stream.
+
+        :param stream:
+            File-like object containing the revlog in its native format or string
+            instance pointing to a file to read.
         """
-        :return: Iterator yielding RefLogEntry instances, one for each line read
-            sfrom the given stream.
-        :param stream: file-like object containing the revlog in its native format
-            or basestring instance pointing to a file to read"""
         new_entry = RefLogEntry.from_line
-        if isinstance(stream, string_types):
-            stream = file_contents_ro_filepath(stream)
+        if isinstance(stream, str):
+            # Default args return mmap since Python 3.
+            _stream = file_contents_ro_filepath(stream)
+            assert isinstance(_stream, mmap)
+        else:
+            _stream = stream
         # END handle stream type
         while True:
-            line = stream.readline()
+            line = _stream.readline()
             if not line:
                 return
             yield new_entry(line.strip())
         # END endless loop
-        stream.close()
 
     @classmethod
-    def entry_at(cls, filepath, index):
-        """:return: RefLogEntry at the given index
-        :param filepath: full path to the index file from which to read the entry
-        :param index: python list compatible index, i.e. it may be negative to
-            specifiy an entry counted from the end of the list
+    def entry_at(cls, filepath: PathLike, index: int) -> "RefLogEntry":
+        """
+        :return:
+            :class:`RefLogEntry` at the given index.
+
+        :param filepath:
+            Full path to the index file from which to read the entry.
+
+        :param index:
+            Python list compatible index, i.e. it may be negative to specify an entry
+            counted from the end of the list.
 
-        :raise IndexError: If the entry didn't exist
+        :raise IndexError:
+            If the entry didn't exist.
 
-        .. note:: This method is faster as it only parses the entry at index, skipping
-            all other lines. Nonetheless, the whole file has to be read if
-            the index is negative
+        :note:
+            This method is faster as it only parses the entry at index, skipping all
+            other lines. Nonetheless, the whole file has to be read if the index is
+            negative.
         """
-        fp = open(filepath, 'rb')
-        if index < 0:
-            return RefLogEntry.from_line(fp.readlines()[index].strip())
-        else:
-            # read until index is reached
-            for i in xrange(index + 1):
+        with open(filepath, "rb") as fp:
+            if index < 0:
+                return RefLogEntry.from_line(fp.readlines()[index].strip())
+            # Read until index is reached.
+
+            for i in range(index + 1):
                 line = fp.readline()
                 if not line:
-                    break
+                    raise IndexError(f"Index file ended at line {i + 1}, before given index was reached")
                 # END abort on eof
             # END handle runup
 
-            if i != index or not line:
-                raise IndexError
-            # END handle exception
-
             return RefLogEntry.from_line(line.strip())
         # END handle index
 
-    def to_file(self, filepath):
+    def to_file(self, filepath: PathLike) -> None:
         """Write the contents of the reflog instance to a file at the given filepath.
-        :param filepath: path to file, parent directories are assumed to exist"""
+
+        :param filepath:
+            Path to file. Parent directories are assumed to exist.
+        """
         lfd = LockedFD(filepath)
         assure_directory_exists(filepath, is_file=True)
 
@@ -248,71 +290,110 @@ def to_file(self, filepath):
         try:
             self._serialize(fp)
             lfd.commit()
-        except:
-            # on failure it rolls back automatically, but we make it clear
+        except BaseException:
             lfd.rollback()
             raise
         # END handle change
 
     @classmethod
-    def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
+    def append_entry(
+        cls,
+        config_reader: Union[Actor, "GitConfigParser", "SectionConstraint", None],
+        filepath: PathLike,
+        oldbinsha: bytes,
+        newbinsha: bytes,
+        message: str,
+        write: bool = True,
+    ) -> "RefLogEntry":
         """Append a new log entry to the revlog at filepath.
 
-        :param config_reader: configuration reader of the repository - used to obtain
-            user information. May also be an Actor instance identifying the committer directly.
-            May also be None
-        :param filepath: full path to the log file
-        :param oldbinsha: binary sha of the previous commit
-        :param newbinsha: binary sha of the current commit
-        :param message: message describing the change to the reference
-        :param write: If True, the changes will be written right away. Otherwise
-            the change will not be written
-        :return: RefLogEntry objects which was appended to the log
-        :note: As we are append-only, concurrent access is not a problem as we
-            do not interfere with readers."""
+        :param config_reader:
+            Configuration reader of the repository - used to obtain user information.
+            May also be an :class:`~git.util.Actor` instance identifying the committer
+            directly or ``None``.
+
+        :param filepath:
+            Full path to the log file.
+
+        :param oldbinsha:
+            Binary sha of the previous commit.
+
+        :param newbinsha:
+            Binary sha of the current commit.
+
+        :param message:
+            Message describing the change to the reference.
+
+        :param write:
+            If ``True``, the changes will be written right away.
+            Otherwise the change will not be written.
+
+        :return:
+            :class:`RefLogEntry` objects which was appended to the log.
+
+        :note:
+            As we are append-only, concurrent access is not a problem as we do not
+            interfere with readers.
+        """
+
         if len(oldbinsha) != 20 or len(newbinsha) != 20:
             raise ValueError("Shas need to be given in binary format")
         # END handle sha type
         assure_directory_exists(filepath, is_file=True)
-        committer = isinstance(config_reader, Actor) and config_reader or Actor.committer(config_reader)
-        entry = RefLogEntry((
-            bin_to_hex(oldbinsha).decode('ascii'),
-            bin_to_hex(newbinsha).decode('ascii'),
-            committer, (int(time.time()), time.altzone), message
-        ))
-
-        lf = LockFile(filepath)
-        lf._obtain_lock_or_raise()
-        fd = open(filepath, 'ab')
-        try:
-            fd.write(entry.format().encode(defenc))
-        finally:
-            fd.close()
-            lf._release_lock()
-        # END handle write operation
-
+        first_line = message.split("\n")[0]
+        if isinstance(config_reader, Actor):
+            committer = config_reader  # mypy thinks this is Actor | Gitconfigparser, but why?
+        else:
+            committer = Actor.committer(config_reader)
+        entry = RefLogEntry(
+            (
+                bin_to_hex(oldbinsha).decode("ascii"),
+                bin_to_hex(newbinsha).decode("ascii"),
+                committer,
+                (int(_time.time()), _time.altzone),
+                first_line,
+            )
+        )
+
+        if write:
+            lf = LockFile(filepath)
+            lf._obtain_lock_or_raise()
+            fd = open(filepath, "ab")
+            try:
+                fd.write(entry.format().encode(defenc))
+            finally:
+                fd.close()
+                lf._release_lock()
+            # END handle write operation
         return entry
 
-    def write(self):
-        """Write this instance's data to the file we are originating from
-        :return: self"""
+    def write(self) -> "RefLog":
+        """Write this instance's data to the file we are originating from.
+
+        :return:
+            self
+        """
         if self._path is None:
             raise ValueError("Instance was not initialized with a path, use to_file(...) instead")
         # END assert path
         self.to_file(self._path)
         return self
 
-    #} END interface
+    # } END interface
 
-    #{ Serializable Interface
-    def _serialize(self, stream):
+    # { Serializable Interface
+
+    def _serialize(self, stream: "BytesIO") -> "RefLog":
         write = stream.write
 
-        # write all entries
+        # Write all entries.
         for e in self:
             write(e.format().encode(defenc))
         # END for each entry
+        return self
 
-    def _deserialize(self, stream):
+    def _deserialize(self, stream: "BytesIO") -> "RefLog":
         self.extend(self.iter_entries(stream))
-    #} END serializable interface
+        return self
+
+    # } END serializable interface
diff --git a/git/refs/reference.py b/git/refs/reference.py
index 8741ebb95..e5d473779 100644
--- a/git/refs/reference.py
+++ b/git/refs/reference.py
@@ -1,57 +1,91 @@
-from git.util import (
-    LazyMixin,
-    Iterable,
-)
-from .symbolic import SymbolicReference
-
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
 __all__ = ["Reference"]
 
-#{ Utilities
+from git.util import IterableObj, LazyMixin
+
+from .symbolic import SymbolicReference, T_References
+
+# typing ------------------------------------------------------------------
+
+from typing import Any, Callable, Iterator, TYPE_CHECKING, Type, Union
+
+from git.types import AnyGitObject, PathLike, _T
+
+if TYPE_CHECKING:
+    from git.repo import Repo
+
+# ------------------------------------------------------------------------------
+
+# { Utilities
 
 
-def require_remote_ref_path(func):
-    """A decorator raising a TypeError if we are not a valid remote, based on the path"""
+def require_remote_ref_path(func: Callable[..., _T]) -> Callable[..., _T]:
+    """A decorator raising :exc:`ValueError` if we are not a valid remote, based on the
+    path."""
 
-    def wrapper(self, *args):
+    def wrapper(self: T_References, *args: Any) -> _T:
         if not self.is_remote():
             raise ValueError("ref path does not point to a remote reference: %s" % self.path)
         return func(self, *args)
+
     # END wrapper
     wrapper.__name__ = func.__name__
     return wrapper
-#}END utilites
 
 
-class Reference(SymbolicReference, LazyMixin, Iterable):
+# } END utilities
+
+
+class Reference(SymbolicReference, LazyMixin, IterableObj):
+    """A named reference to any object.
+
+    Subclasses may apply restrictions though, e.g., a :class:`~git.refs.head.Head` can
+    only point to commits.
+    """
+
+    __slots__ = ()
 
-    """Represents a named reference to any object. Subclasses may apply restrictions though,
-    i.e. Heads can only point to commits."""
-    __slots__ = tuple()
     _points_to_commits_only = False
     _resolve_ref_on_create = True
     _common_path_default = "refs"
 
-    def __init__(self, repo, path, check_path=True):
-        """Initialize this instance
-        :param repo: Our parent repository
+    def __init__(self, repo: "Repo", path: PathLike, check_path: bool = True) -> None:
+        """Initialize this instance.
+
+        :param repo:
+            Our parent repository.
 
         :param path:
-            Path relative to the .git/ directory pointing to the ref in question, i.e.
-            refs/heads/master
-        :param check_path: if False, you can provide any path. Otherwise the path must start with the
-            default path prefix of this type."""
-        if check_path and not path.startswith(self._common_path_default + '/'):
-            raise ValueError("Cannot instantiate %r from path %s" % (self.__class__.__name__, path))
-        super(Reference, self).__init__(repo, path)
-
-    def __str__(self):
+            Path relative to the ``.git/`` directory pointing to the ref in question,
+            e.g. ``refs/heads/master``.
+
+        :param check_path:
+            If ``False``, you can provide any path.
+            Otherwise the path must start with the default path prefix of this type.
+        """
+        if check_path and not str(path).startswith(self._common_path_default + "/"):
+            raise ValueError(f"Cannot instantiate {self.__class__.__name__!r} from path {path}")
+        self.path: str  # SymbolicReference converts to string at the moment.
+        super().__init__(repo, path)
+
+    def __str__(self) -> str:
         return self.name
 
-    #{ Interface
+    # { Interface
 
-    def set_object(self, object, logmsg=None):
-        """Special version which checks if the head-log needs an update as well"""
+    # @ReservedAssignment
+    def set_object(
+        self,
+        object: Union[AnyGitObject, "SymbolicReference", str],
+        logmsg: Union[str, None] = None,
+    ) -> "Reference":
+        """Special version which checks if the head-log needs an update as well.
+
+        :return:
+            self
+        """
         oldbinsha = None
         if logmsg is not None:
             head = self.repo.head
@@ -60,64 +94,83 @@ def set_object(self, object, logmsg=None):
             # END handle commit retrieval
         # END handle message is set
 
-        super(Reference, self).set_object(object, logmsg)
+        super().set_object(object, logmsg)
 
         if oldbinsha is not None:
-            # /* from refs.c in git-source
-            # * Special hack: If a branch is updated directly and HEAD
-            # * points to it (may happen on the remote side of a push
-            # * for example) then logically the HEAD reflog should be
-            # * updated too.
-            # * A generic solution implies reverse symref information,
-            # * but finding all symrefs pointing to the given branch
-            # * would be rather costly for this rare event (the direct
-            # * update of a branch) to be worth it.  So let's cheat and
-            # * check with HEAD only which should cover 99% of all usage
-            # * scenarios (even 100% of the default ones).
-            # */
+            # From refs/files-backend.c in git-source:
+            # /*
+            #  * Special hack: If a branch is updated directly and HEAD
+            #  * points to it (may happen on the remote side of a push
+            #  * for example) then logically the HEAD reflog should be
+            #  * updated too.
+            #  * A generic solution implies reverse symref information,
+            #  * but finding all symrefs pointing to the given branch
+            #  * would be rather costly for this rare event (the direct
+            #  * update of a branch) to be worth it.  So let's cheat and
+            #  * check with HEAD only which should cover 99% of all usage
+            #  * scenarios (even 100% of the default ones).
+            #  */
             self.repo.head.log_append(oldbinsha, logmsg)
         # END check if the head
 
-    # NOTE: Don't have to overwrite properties as the will only work without a the log
+        return self
+
+    # NOTE: No need to overwrite properties, as the will only work without a the log.
 
     @property
-    def name(self):
-        """:return: (shortest) Name of this reference - it may contain path components"""
-        # first two path tokens are can be removed as they are
-        # refs/heads or refs/tags or refs/remotes
-        tokens = self.path.split('/')
+    def name(self) -> str:
+        """
+        :return:
+            (shortest) Name of this reference - it may contain path components
+        """
+        # The first two path tokens can be removed as they are
+        # refs/heads or refs/tags or refs/remotes.
+        tokens = self.path.split("/")
         if len(tokens) < 3:
-            return self.path           # could be refs/HEAD
-        return '/'.join(tokens[2:])
+            return self.path  # could be refs/HEAD
+        return "/".join(tokens[2:])
 
     @classmethod
-    def iter_items(cls, repo, common_path=None):
-        """Equivalent to SymbolicReference.iter_items, but will return non-detached
-        references as well."""
+    def iter_items(
+        cls: Type[T_References],
+        repo: "Repo",
+        common_path: Union[PathLike, None] = None,
+        *args: Any,
+        **kwargs: Any,
+    ) -> Iterator[T_References]:
+        """Equivalent to
+        :meth:`SymbolicReference.iter_items <git.refs.symbolic.SymbolicReference.iter_items>`,
+        but will return non-detached references as well."""
         return cls._iter_items(repo, common_path)
 
-    #}END interface
+    # } END interface
 
-    #{ Remote Interface
+    # { Remote Interface
 
     @property
     @require_remote_ref_path
-    def remote_name(self):
+    def remote_name(self) -> str:
         """
         :return:
-            Name of the remote we are a reference of, such as 'origin' for a reference
-            named 'origin/master'"""
-        tokens = self.path.split('/')
+            Name of the remote we are a reference of, such as ``origin`` for a reference
+            named ``origin/master``.
+        """
+        tokens = self.path.split("/")
         # /refs/remotes/<remote name>/<branch_name>
         return tokens[2]
 
     @property
     @require_remote_ref_path
-    def remote_head(self):
-        """:return: Name of the remote head itself, i.e. master.
-        :note: The returned name is usually not qualified enough to uniquely identify
-            a branch"""
-        tokens = self.path.split('/')
-        return '/'.join(tokens[3:])
-
-    #} END remote interface
+    def remote_head(self) -> str:
+        """
+        :return:
+            Name of the remote head itself, e.g. ``master``.
+
+        :note:
+            The returned name is usually not qualified enough to uniquely identify a
+            branch.
+        """
+        tokens = self.path.split("/")
+        return "/".join(tokens[3:])
+
+    # } END remote interface
diff --git a/git/refs/remote.py b/git/refs/remote.py
index 1f256b752..b4f4f7b36 100644
--- a/git/refs/remote.py
+++ b/git/refs/remote.py
@@ -1,47 +1,79 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Module implementing a remote object allowing easy access to git remotes."""
+
+__all__ = ["RemoteReference"]
+
+import os
+
 from git.util import join_path
-from gitdb.util import join
 
 from .head import Head
 
-import os
+# typing ------------------------------------------------------------------
 
+from typing import Any, Iterator, NoReturn, TYPE_CHECKING, Union
 
-__all__ = ["RemoteReference"]
+from git.types import PathLike
+
+if TYPE_CHECKING:
+    from git.remote import Remote
+    from git.repo import Repo
+
+# ------------------------------------------------------------------------------
 
 
 class RemoteReference(Head):
+    """A reference pointing to a remote head."""
 
-    """Represents a reference pointing to a remote head."""
     _common_path_default = Head._remote_common_path_default
 
     @classmethod
-    def iter_items(cls, repo, common_path=None, remote=None):
-        """Iterate remote references, and if given, constrain them to the given remote"""
+    def iter_items(
+        cls,
+        repo: "Repo",
+        common_path: Union[PathLike, None] = None,
+        remote: Union["Remote", None] = None,
+        *args: Any,
+        **kwargs: Any,
+    ) -> Iterator["RemoteReference"]:
+        """Iterate remote references, and if given, constrain them to the given remote."""
         common_path = common_path or cls._common_path_default
         if remote is not None:
             common_path = join_path(common_path, str(remote))
         # END handle remote constraint
-        return super(RemoteReference, cls).iter_items(repo, common_path)
+        # super is Reference
+        return super().iter_items(repo, common_path)
 
+    # The Head implementation of delete also accepts strs, but this implementation does
+    # not. mypy doesn't have a way of representing tightening the types of arguments in
+    # subclasses and recommends Any or "type: ignore".
+    # (See: https://github.com/python/typing/issues/241)
     @classmethod
-    def delete(cls, repo, *refs, **kwargs):
-        """Delete the given remote references
+    def delete(cls, repo: "Repo", *refs: "RemoteReference", **kwargs: Any) -> None:  # type: ignore[override]
+        """Delete the given remote references.
 
         :note:
-            kwargs are given for compatability with the base class method as we
-            should not narrow the signature."""
+            `kwargs` are given for comparability with the base class method as we
+            should not narrow the signature.
+        """
         repo.git.branch("-d", "-r", *refs)
-        # the official deletion method will ignore remote symbolic refs - these
-        # are generally ignored in the refs/ folder. We don't though
-        # and delete remainders manually
+        # The official deletion method will ignore remote symbolic refs - these are
+        # generally ignored in the refs/ folder. We don't though and delete remainders
+        # manually.
         for ref in refs:
             try:
-                os.remove(join(repo.git_dir, ref.path))
+                os.remove(os.path.join(repo.common_dir, ref.path))
+            except OSError:
+                pass
+            try:
+                os.remove(os.path.join(repo.git_dir, ref.path))
             except OSError:
                 pass
         # END for each ref
 
     @classmethod
-    def create(cls, *args, **kwargs):
-        """Used to disable this method"""
+    def create(cls, *args: Any, **kwargs: Any) -> NoReturn:
+        """Raise :exc:`TypeError`. Defined so the ``create`` method is disabled."""
         raise TypeError("Cannot explicitly create remote references")
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index b5a81ee01..1b90a3115 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -1,153 +1,253 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = ["SymbolicReference"]
+
 import os
 
-from git.objects import Object, Commit
+from gitdb.exc import BadName, BadObject
+
+from git.compat import defenc
+from git.objects.base import Object
+from git.objects.commit import Commit
+from git.refs.log import RefLog
 from git.util import (
+    LockedFD,
+    assure_directory_exists,
+    hex_to_bin,
     join_path,
     join_path_native,
     to_native_path_linux,
-    assure_directory_exists
 )
 
-from gitdb.exc import (
-    BadObject,
-    BadName
-)
-from gitdb.util import (
-    join,
-    dirname,
-    isdir,
-    exists,
-    isfile,
-    rename,
-    hex_to_bin,
-    LockedFD
-)
-from git.compat import (
-    string_types,
-    defenc
+# typing ------------------------------------------------------------------
+
+from typing import (
+    Any,
+    Iterator,
+    List,
+    TYPE_CHECKING,
+    Tuple,
+    Type,
+    TypeVar,
+    Union,
+    cast,
 )
 
-from .log import RefLog
+from git.types import AnyGitObject, PathLike
+
+if TYPE_CHECKING:
+    from git.config import GitConfigParser
+    from git.objects.commit import Actor
+    from git.refs.log import RefLogEntry
+    from git.repo import Repo
+
+
+T_References = TypeVar("T_References", bound="SymbolicReference")
+
+# ------------------------------------------------------------------------------
+
+
+def _git_dir(repo: "Repo", path: Union[PathLike, None]) -> PathLike:
+    """Find the git dir that is appropriate for the path."""
+    name = f"{path}"
+    if name in ["HEAD", "ORIG_HEAD", "FETCH_HEAD", "index", "logs"]:
+        return repo.git_dir
+    return repo.common_dir
 
-__all__ = ["SymbolicReference"]
 
+class SymbolicReference:
+    """Special case of a reference that is symbolic.
 
-class SymbolicReference(object):
+    This does not point to a specific commit, but to another
+    :class:`~git.refs.head.Head`, which itself specifies a commit.
 
-    """Represents a special case of a reference such that this reference is symbolic.
-    It does not point to a specific commit, but to another Head, which itself
-    specifies a commit.
+    A typical example for a symbolic reference is :class:`~git.refs.head.HEAD`.
+    """
 
-    A typical example for a symbolic reference is HEAD."""
     __slots__ = ("repo", "path")
+
     _resolve_ref_on_create = False
     _points_to_commits_only = True
     _common_path_default = ""
     _remote_common_path_default = "refs/remotes"
     _id_attribute_ = "name"
 
-    def __init__(self, repo, path):
+    def __init__(self, repo: "Repo", path: PathLike, check_path: bool = False) -> None:
         self.repo = repo
         self.path = path
 
-    def __str__(self):
-        return self.path
+    def __str__(self) -> str:
+        return str(self.path)
 
-    def __repr__(self):
+    def __repr__(self) -> str:
         return '<git.%s "%s">' % (self.__class__.__name__, self.path)
 
-    def __eq__(self, other):
-        if hasattr(other, 'path'):
+    def __eq__(self, other: object) -> bool:
+        if hasattr(other, "path"):
+            other = cast(SymbolicReference, other)
             return self.path == other.path
         return False
 
-    def __ne__(self, other):
+    def __ne__(self, other: object) -> bool:
         return not (self == other)
 
-    def __hash__(self):
+    def __hash__(self) -> int:
         return hash(self.path)
 
     @property
-    def name(self):
+    def name(self) -> str:
         """
         :return:
-            In case of symbolic references, the shortest assumable name
-            is the path itself."""
-        return self.path
+            In case of symbolic references, the shortest assumable name is the path
+            itself.
+        """
+        return str(self.path)
 
     @property
-    def abspath(self):
-        return join_path_native(self.repo.git_dir, self.path)
+    def abspath(self) -> PathLike:
+        return join_path_native(_git_dir(self.repo, self.path), self.path)
 
     @classmethod
-    def _get_packed_refs_path(cls, repo):
-        return join(repo.git_dir, 'packed-refs')
+    def _get_packed_refs_path(cls, repo: "Repo") -> str:
+        return os.path.join(repo.common_dir, "packed-refs")
 
     @classmethod
-    def _iter_packed_refs(cls, repo):
-        """Returns an iterator yielding pairs of sha1/path pairs (as bytes) for the corresponding refs.
-        :note: The packed refs file will be kept open as long as we iterate"""
+    def _iter_packed_refs(cls, repo: "Repo") -> Iterator[Tuple[str, str]]:
+        """Return an iterator yielding pairs of sha1/path pairs (as strings) for the
+        corresponding refs.
+
+        :note:
+            The packed refs file will be kept open as long as we iterate.
+        """
         try:
-            fp = open(cls._get_packed_refs_path(repo), 'rt')
-            for line in fp:
-                line = line.strip()
-                if not line:
-                    continue
-                if line.startswith('#'):
-                    if line.startswith('# pack-refs with:') and not line.endswith('peeled'):
-                        raise TypeError("PackingType of packed-Refs not understood: %r" % line)
-                    # END abort if we do not understand the packing scheme
-                    continue
-                # END parse comment
+            with open(cls._get_packed_refs_path(repo), "rt", encoding="UTF-8") as fp:
+                for line in fp:
+                    line = line.strip()
+                    if not line:
+                        continue
+                    if line.startswith("#"):
+                        # "# pack-refs with: peeled fully-peeled sorted"
+                        # the git source code shows "peeled",
+                        # "fully-peeled" and "sorted" as the keywords
+                        # that can go on this line, as per comments in git file
+                        # refs/packed-backend.c
+                        # I looked at master on 2017-10-11,
+                        # commit 111ef79afe, after tag v2.15.0-rc1
+                        # from repo https://github.com/git/git.git
+                        if line.startswith("# pack-refs with:") and "peeled" not in line:
+                            raise TypeError("PackingType of packed-Refs not understood: %r" % line)
+                        # END abort if we do not understand the packing scheme
+                        continue
+                    # END parse comment
 
-                # skip dereferenced tag object entries - previous line was actual
-                # tag reference for it
-                if line[0] == '^':
-                    continue
+                    # Skip dereferenced tag object entries - previous line was actual
+                    # tag reference for it.
+                    if line[0] == "^":
+                        continue
 
-                yield tuple(line.split(' ', 1))
-            # END for each line
-        except (OSError, IOError):
-            raise StopIteration
+                    yield cast(Tuple[str, str], tuple(line.split(" ", 1)))
+                # END for each line
+        except OSError:
+            return None
         # END no packed-refs file handling
-        # NOTE: Had try-finally block around here to close the fp,
-        # but some python version woudn't allow yields within that.
-        # I believe files are closing themselves on destruction, so it is
-        # alright.
 
     @classmethod
-    def dereference_recursive(cls, repo, ref_path):
+    def dereference_recursive(cls, repo: "Repo", ref_path: Union[PathLike, None]) -> str:
         """
-        :return: hexsha stored in the reference at the given ref_path, recursively dereferencing all
-            intermediate references as required
-        :param repo: the repository containing the reference at ref_path"""
+        :return:
+            hexsha stored in the reference at the given `ref_path`, recursively
+            dereferencing all intermediate references as required
+
+        :param repo:
+            The repository containing the reference at `ref_path`.
+        """
+
         while True:
             hexsha, ref_path = cls._get_ref_info(repo, ref_path)
             if hexsha is not None:
                 return hexsha
         # END recursive dereferencing
 
+    @staticmethod
+    def _check_ref_name_valid(ref_path: PathLike) -> None:
+        """Check a ref name for validity.
+
+        This is based on the rules described in :manpage:`git-check-ref-format(1)`.
+        """
+        previous: Union[str, None] = None
+        one_before_previous: Union[str, None] = None
+        for c in str(ref_path):
+            if c in " ~^:?*[\\":
+                raise ValueError(
+                    f"Invalid reference '{ref_path}': references cannot contain spaces, tildes (~), carets (^),"
+                    f" colons (:), question marks (?), asterisks (*), open brackets ([) or backslashes (\\)"
+                )
+            elif c == ".":
+                if previous is None or previous == "/":
+                    raise ValueError(
+                        f"Invalid reference '{ref_path}': references cannot start with a period (.) or contain '/.'"
+                    )
+                elif previous == ".":
+                    raise ValueError(f"Invalid reference '{ref_path}': references cannot contain '..'")
+            elif c == "/":
+                if previous == "/":
+                    raise ValueError(f"Invalid reference '{ref_path}': references cannot contain '//'")
+                elif previous is None:
+                    raise ValueError(
+                        f"Invalid reference '{ref_path}': references cannot start with forward slashes '/'"
+                    )
+            elif c == "{" and previous == "@":
+                raise ValueError(f"Invalid reference '{ref_path}': references cannot contain '@{{'")
+            elif ord(c) < 32 or ord(c) == 127:
+                raise ValueError(f"Invalid reference '{ref_path}': references cannot contain ASCII control characters")
+
+            one_before_previous = previous
+            previous = c
+
+        if previous == ".":
+            raise ValueError(f"Invalid reference '{ref_path}': references cannot end with a period (.)")
+        elif previous == "/":
+            raise ValueError(f"Invalid reference '{ref_path}': references cannot end with a forward slash (/)")
+        elif previous == "@" and one_before_previous is None:
+            raise ValueError(f"Invalid reference '{ref_path}': references cannot be '@'")
+        elif any(component.endswith(".lock") for component in str(ref_path).split("/")):
+            raise ValueError(
+                f"Invalid reference '{ref_path}': references cannot have slash-separated components that end with"
+                " '.lock'"
+            )
+
     @classmethod
-    def _get_ref_info(cls, repo, ref_path):
-        """Return: (str(sha), str(target_ref_path)) if available, the sha the file at
-        rela_path points to, or None. target_ref_path is the reference we
-        point to, or None"""
-        tokens = None
+    def _get_ref_info_helper(
+        cls, repo: "Repo", ref_path: Union[PathLike, None]
+    ) -> Union[Tuple[str, None], Tuple[None, str]]:
+        """
+        :return:
+            *(str(sha), str(target_ref_path))*, where:
+
+            * *sha* is of the file at rela_path points to if available, or ``None``.
+            * *target_ref_path* is the reference we point to, or ``None``.
+        """
+        if ref_path:
+            cls._check_ref_name_valid(ref_path)
+
+        tokens: Union[None, List[str], Tuple[str, str]] = None
+        repodir = _git_dir(repo, ref_path)
         try:
-            fp = open(join(repo.git_dir, ref_path), 'rt')
-            value = fp.read().rstrip()
-            fp.close()
-            # Don't only split on spaces, but on whitespace, which allows to parse lines like
+            with open(os.path.join(repodir, str(ref_path)), "rt", encoding="UTF-8") as fp:
+                value = fp.read().rstrip()
+            # Don't only split on spaces, but on whitespace, which allows to parse lines like:
             # 60b64ef992065e2600bfef6187a97f92398a9144                branch 'master' of git-server:/path/to/repo
             tokens = value.split()
-        except (OSError, IOError):
-            # Probably we are just packed, find our entry in the packed refs file
+            assert len(tokens) != 0
+        except OSError:
+            # Probably we are just packed. Find our entry in the packed refs file.
             # NOTE: We are not a symbolic ref if we are in a packed file, as these
-            # are excluded explictly
+            # are excluded explicitly.
             for sha, path in cls._iter_packed_refs(repo):
                 if path != ref_path:
                     continue
-                # sha will be used
+                # sha will be used.
                 tokens = sha, path
                 break
             # END for each packed ref
@@ -155,32 +255,46 @@ def _get_ref_info(cls, repo, ref_path):
         if tokens is None:
             raise ValueError("Reference at %r does not exist" % ref_path)
 
-        # is it a reference ?
-        if tokens[0] == 'ref:':
+        # Is it a reference?
+        if tokens[0] == "ref:":
             return (None, tokens[1])
 
-        # its a commit
+        # It's a commit.
         if repo.re_hexsha_only.match(tokens[0]):
             return (tokens[0], None)
 
         raise ValueError("Failed to parse reference information from %r" % ref_path)
 
-    def _get_object(self):
+    @classmethod
+    def _get_ref_info(cls, repo: "Repo", ref_path: Union[PathLike, None]) -> Union[Tuple[str, None], Tuple[None, str]]:
         """
         :return:
-            The object our ref currently refers to. Refs can be cached, they will
-            always point to the actual object as it gets re-created on each query"""
-        # have to be dynamic here as we may be a tag which can point to anything
-        # Our path will be resolved to the hexsha which will be used accordingly
+            *(str(sha), str(target_ref_path))*, where:
+
+            * *sha* is of the file at rela_path points to if available, or ``None``.
+            * *target_ref_path* is the reference we point to, or ``None``.
+        """
+        return cls._get_ref_info_helper(repo, ref_path)
+
+    def _get_object(self) -> AnyGitObject:
+        """
+        :return:
+            The object our ref currently refers to. Refs can be cached, they will always
+            point to the actual object as it gets re-created on each query.
+        """
+        # We have to be dynamic here as we may be a tag which can point to anything.
+        # Our path will be resolved to the hexsha which will be used accordingly.
         return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
 
-    def _get_commit(self):
+    def _get_commit(self) -> "Commit":
         """
         :return:
-            Commit object we point to, works for detached and non-detached
-            SymbolicReferences. The symbolic reference will be dereferenced recursively."""
+            :class:`~git.objects.commit.Commit` object we point to. This works for
+            detached and non-detached :class:`SymbolicReference` instances. The symbolic
+            reference will be dereferenced recursively.
+        """
         obj = self._get_object()
-        if obj.type == 'tag':
+        if obj.type == "tag":
             obj = obj.object
         # END dereference tag
 
@@ -189,13 +303,22 @@ def _get_commit(self):
         # END handle type
         return obj
 
-    def set_commit(self, commit, logmsg=None):
-        """As set_object, but restricts the type of object to be a Commit
+    def set_commit(
+        self,
+        commit: Union[Commit, "SymbolicReference", str],
+        logmsg: Union[str, None] = None,
+    ) -> "SymbolicReference":
+        """Like :meth:`set_object`, but restricts the type of object to be a
+        :class:`~git.objects.commit.Commit`.
+
+        :raise ValueError:
+            If `commit` is not a :class:`~git.objects.commit.Commit` object, nor does it
+            point to a commit.
 
-        :raise ValueError: If commit is not a Commit object or doesn't point to
-            a commit
-        :return: self"""
-        # check the type - assume the best if it is a base-string
+        :return:
+            self
+        """
+        # Check the type - assume the best if it is a base-string.
         invalid_type = False
         if isinstance(commit, Object):
             invalid_type = commit.type != Commit.type
@@ -204,8 +327,8 @@ def set_commit(self, commit, logmsg=None):
         else:
             try:
                 invalid_type = self.repo.rev_parse(commit).type != Commit.type
-            except (BadObject, BadName):
-                raise ValueError("Invalid object: %s" % commit)
+            except (BadObject, BadName) as e:
+                raise ValueError("Invalid object: %s" % commit) from e
             # END handle exception
         # END verify type
 
@@ -213,23 +336,41 @@ def set_commit(self, commit, logmsg=None):
             raise ValueError("Need commit, got %r" % commit)
         # END handle raise
 
-        # we leave strings to the rev-parse method below
+        # We leave strings to the rev-parse method below.
         self.set_object(commit, logmsg)
 
         return self
 
-    def set_object(self, object, logmsg=None):
-        """Set the object we point to, possibly dereference our symbolic reference first.
-        If the reference does not exist, it will be created
+    def set_object(
+        self,
+        object: Union[AnyGitObject, "SymbolicReference", str],
+        logmsg: Union[str, None] = None,
+    ) -> "SymbolicReference":
+        """Set the object we point to, possibly dereference our symbolic reference
+        first. If the reference does not exist, it will be created.
+
+        :param object:
+            A refspec, a :class:`SymbolicReference` or an
+            :class:`~git.objects.base.Object` instance.
+
+            * :class:`SymbolicReference` instances will be dereferenced beforehand to
+              obtain the git object they point to.
+            * :class:`~git.objects.base.Object` instances must represent git objects
+              (:class:`~git.types.AnyGitObject`).
+
+        :param logmsg:
+            If not ``None``, the message will be used in the reflog entry to be written.
+            Otherwise the reflog is not altered.
+
+        :note:
+            Plain :class:`SymbolicReference` instances may not actually point to objects
+            by convention.
 
-        :param object: a refspec, a SymbolicReference or an Object instance. SymbolicReferences
-            will be dereferenced beforehand to obtain the object they point to
-        :param logmsg: If not None, the message will be used in the reflog entry to be
-            written. Otherwise the reflog is not altered
-        :note: plain SymbolicReferences may not actually point to objects by convention
-        :return: self"""
+        :return:
+            self
+        """
         if isinstance(object, SymbolicReference):
-            object = object.object
+            object = object.object  # @ReservedAssignment
         # END resolve references
 
         is_detached = True
@@ -245,36 +386,71 @@ def set_object(self, object, logmsg=None):
         # set the commit on our reference
         return self._get_reference().set_object(object, logmsg)
 
-    commit = property(_get_commit, set_commit, doc="Query or set commits directly")
-    object = property(_get_object, set_object, doc="Return the object our ref currently refers to")
+    @property
+    def commit(self) -> "Commit":
+        """Query or set commits directly"""
+        return self._get_commit()
+
+    @commit.setter
+    def commit(self, commit: Union[Commit, "SymbolicReference", str]) -> "SymbolicReference":
+        return self.set_commit(commit)
+
+    @property
+    def object(self) -> AnyGitObject:
+        """Return the object our ref currently refers to"""
+        return self._get_object()
+
+    @object.setter
+    def object(self, object: Union[AnyGitObject, "SymbolicReference", str]) -> "SymbolicReference":
+        return self.set_object(object)
+
+    def _get_reference(self) -> "SymbolicReference":
+        """
+        :return:
+            :class:`~git.refs.reference.Reference` object we point to
 
-    def _get_reference(self):
-        """:return: Reference Object we point to
-        :raise TypeError: If this symbolic reference is detached, hence it doesn't point
-            to a reference, but to a commit"""
+        :raise TypeError:
+            If this symbolic reference is detached, hence it doesn't point to a
+            reference, but to a commit.
+        """
         sha, target_ref_path = self._get_ref_info(self.repo, self.path)
         if target_ref_path is None:
             raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
         return self.from_path(self.repo, target_ref_path)
 
-    def set_reference(self, ref, logmsg=None):
-        """Set ourselves to the given ref. It will stay a symbol if the ref is a Reference.
-        Otherwise an Object, given as Object instance or refspec, is assumed and if valid,
-        will be set which effectively detaches the refererence if it was a purely
-        symbolic one.
+    def set_reference(
+        self,
+        ref: Union[AnyGitObject, "SymbolicReference", str],
+        logmsg: Union[str, None] = None,
+    ) -> "SymbolicReference":
+        """Set ourselves to the given `ref`.
+
+        It will stay a symbol if the `ref` is a :class:`~git.refs.reference.Reference`.
+
+        Otherwise a git object, specified as a :class:`~git.objects.base.Object`
+        instance or refspec, is assumed. If it is valid, this reference will be set to
+        it, which effectively detaches the reference if it was a purely symbolic one.
 
-        :param ref: SymbolicReference instance, Object instance or refspec string
-            Only if the ref is a SymbolicRef instance, we will point to it. Everthiny
-            else is dereferenced to obtain the actual object.
-        :param logmsg: If set to a string, the message will be used in the reflog.
+        :param ref:
+            A :class:`SymbolicReference` instance, an :class:`~git.objects.base.Object`
+            instance (specifically an :class:`~git.types.AnyGitObject`), or a refspec
+            string. Only if the ref is a :class:`SymbolicReference` instance, we will
+            point to it. Everything else is dereferenced to obtain the actual object.
+
+        :param logmsg:
+            If set to a string, the message will be used in the reflog.
             Otherwise, a reflog entry is not written for the changed reference.
             The previous commit of the entry will be the commit we point to now.
 
-            See also: log_append()
+            See also: :meth:`log_append`
+
+        :return:
+            self
 
-        :return: self
-        :note: This symbolic reference will not be dereferenced. For that, see
-            ``set_object(...)``"""
+        :note:
+            This symbolic reference will not be dereferenced. For that, see
+            :meth:`set_object`.
+        """
         write_value = None
         obj = None
         if isinstance(ref, SymbolicReference):
@@ -282,12 +458,12 @@ def set_reference(self, ref, logmsg=None):
         elif isinstance(ref, Object):
             obj = ref
             write_value = ref.hexsha
-        elif isinstance(ref, string_types):
+        elif isinstance(ref, str):
             try:
-                obj = self.repo.rev_parse(ref + "^{}")    # optionally deref tags
+                obj = self.repo.rev_parse(ref + "^{}")  # Optionally dereference tags.
                 write_value = obj.hexsha
-            except (BadObject, BadName):
-                raise ValueError("Could not extract object from %s" % ref)
+            except (BadObject, BadName) as e:
+                raise ValueError("Could not extract object from %s" % ref) from e
             # END end try string
         else:
             raise ValueError("Unrecognized Value: %r" % ref)
@@ -298,7 +474,7 @@ def set_reference(self, ref, logmsg=None):
             raise TypeError("Require commit, got %r" % obj)
         # END verify type
 
-        oldbinsha = None
+        oldbinsha: bytes = b""
         if logmsg is not None:
             try:
                 oldbinsha = self.commit.binsha
@@ -312,181 +488,233 @@ def set_reference(self, ref, logmsg=None):
 
         lfd = LockedFD(fpath)
         fd = lfd.open(write=True, stream=True)
-        fd.write(write_value.encode('ascii'))
-        lfd.commit()
-
+        try:
+            fd.write(write_value.encode("utf-8") + b"\n")
+            lfd.commit()
+        except BaseException:
+            lfd.rollback()
+            raise
         # Adjust the reflog
         if logmsg is not None:
             self.log_append(oldbinsha, logmsg)
-        # END handle reflog
 
         return self
 
-    # aliased reference
-    reference = property(_get_reference, set_reference, doc="Returns the Reference we point to")
+    # Aliased reference
+    @property
+    def reference(self) -> "SymbolicReference":
+        return self._get_reference()
+
+    @reference.setter
+    def reference(self, ref: Union[AnyGitObject, "SymbolicReference", str]) -> "SymbolicReference":
+        return self.set_reference(ref)
+
     ref = reference
 
-    def is_valid(self):
+    def is_valid(self) -> bool:
         """
         :return:
-            True if the reference is valid, hence it can be read and points to
-            a valid object or reference."""
+            ``True`` if the reference is valid, hence it can be read and points to a
+            valid object or reference.
+        """
         try:
-            self.object
+            self.object  # noqa: B018
         except (OSError, ValueError):
             return False
         else:
             return True
 
     @property
-    def is_detached(self):
+    def is_detached(self) -> bool:
         """
         :return:
-            True if we are a detached reference, hence we point to a specific commit
-            instead to another reference"""
+            ``True`` if we are a detached reference, hence we point to a specific commit
+            instead to another reference.
+        """
         try:
-            self.ref
+            self.ref  # noqa: B018
             return False
         except TypeError:
             return True
 
-    def log(self):
+    def log(self) -> "RefLog":
         """
-        :return: RefLog for this reference. Its last entry reflects the latest change
-            applied to this reference
+        :return:
+            :class:`~git.refs.log.RefLog` for this reference.
+            Its last entry reflects the latest change applied to this reference.
 
-        .. note:: As the log is parsed every time, its recommended to cache it for use
-            instead of calling this method repeatedly. It should be considered read-only."""
+        :note:
+            As the log is parsed every time, its recommended to cache it for use instead
+            of calling this method repeatedly. It should be considered read-only.
+        """
         return RefLog.from_file(RefLog.path(self))
 
-    def log_append(self, oldbinsha, message, newbinsha=None):
-        """Append a logentry to the logfile of this ref
+    def log_append(
+        self,
+        oldbinsha: bytes,
+        message: Union[str, None],
+        newbinsha: Union[bytes, None] = None,
+    ) -> "RefLogEntry":
+        """Append a logentry to the logfile of this ref.
+
+        :param oldbinsha:
+            Binary sha this ref used to point to.
 
-        :param oldbinsha: binary sha this ref used to point to
-        :param message: A message describing the change
-        :param newbinsha: The sha the ref points to now. If None, our current commit sha
-            will be used
-        :return: added RefLogEntry instance"""
-        # NOTE: we use the committer of the currently active commit - this should be
+        :param message:
+            A message describing the change.
+
+        :param newbinsha:
+            The sha the ref points to now. If None, our current commit sha will be used.
+
+        :return:
+            The added :class:`~git.refs.log.RefLogEntry` instance.
+        """
+        # NOTE: We use the committer of the currently active commit - this should be
         # correct to allow overriding the committer on a per-commit level.
-        # See https://github.com/gitpython-developers/GitPython/pull/146
+        # See https://github.com/gitpython-developers/GitPython/pull/146.
         try:
-            committer_or_reader = self.commit.committer
+            committer_or_reader: Union["Actor", "GitConfigParser"] = self.commit.committer
         except ValueError:
             committer_or_reader = self.repo.config_reader()
-        # end handle newly cloned repositories
-        return RefLog.append_entry(committer_or_reader, RefLog.path(self), oldbinsha,
-                                   (newbinsha is None and self.commit.binsha) or newbinsha,
-                                   message)
-
-    def log_entry(self, index):
-        """:return: RefLogEntry at the given index
-        :param index: python list compatible positive or negative index
-
-        .. note:: This method must read part of the reflog during execution, hence
-            it should be used sparringly, or only if you need just one index.
-            In that case, it will be faster than the ``log()`` method"""
+        # END handle newly cloned repositories
+        if newbinsha is None:
+            newbinsha = self.commit.binsha
+
+        if message is None:
+            message = ""
+
+        return RefLog.append_entry(committer_or_reader, RefLog.path(self), oldbinsha, newbinsha, message)
+
+    def log_entry(self, index: int) -> "RefLogEntry":
+        """
+        :return:
+            :class:`~git.refs.log.RefLogEntry` at the given index
+
+        :param index:
+            Python list compatible positive or negative index.
+
+        :note:
+            This method must read part of the reflog during execution, hence it should
+            be used sparingly, or only if you need just one index. In that case, it will
+            be faster than the :meth:`log` method.
+        """
         return RefLog.entry_at(RefLog.path(self), index)
 
     @classmethod
-    def to_full_path(cls, path):
+    def to_full_path(cls, path: Union[PathLike, "SymbolicReference"]) -> PathLike:
+        """
+        :return:
+            String with a full repository-relative path which can be used to initialize
+            a :class:`~git.refs.reference.Reference` instance, for instance by using
+            :meth:`Reference.from_path <git.refs.reference.Reference.from_path>`.
         """
-        :return: string with a full repository-relative path which can be used to initialize
-            a Reference instance, for instance by using ``Reference.from_path``"""
         if isinstance(path, SymbolicReference):
             path = path.path
         full_ref_path = path
         if not cls._common_path_default:
             return full_ref_path
-        if not path.startswith(cls._common_path_default + "/"):
-            full_ref_path = '%s/%s' % (cls._common_path_default, path)
+        if not str(path).startswith(cls._common_path_default + "/"):
+            full_ref_path = "%s/%s" % (cls._common_path_default, path)
         return full_ref_path
 
     @classmethod
-    def delete(cls, repo, path):
-        """Delete the reference at the given path
+    def delete(cls, repo: "Repo", path: PathLike) -> None:
+        """Delete the reference at the given path.
 
         :param repo:
-            Repository to delete the reference from
+            Repository to delete the reference from.
 
         :param path:
-            Short or full path pointing to the reference, i.e. refs/myreference
-            or just "myreference", hence 'refs/' is implied.
-            Alternatively the symbolic reference to be deleted"""
+            Short or full path pointing to the reference, e.g. ``refs/myreference`` or
+            just ``myreference``, hence ``refs/`` is implied.
+            Alternatively the symbolic reference to be deleted.
+        """
         full_ref_path = cls.to_full_path(path)
-        abs_path = join(repo.git_dir, full_ref_path)
-        if exists(abs_path):
+        abs_path = os.path.join(repo.common_dir, full_ref_path)
+        if os.path.exists(abs_path):
             os.remove(abs_path)
         else:
-            # check packed refs
+            # Check packed refs.
             pack_file_path = cls._get_packed_refs_path(repo)
             try:
-                reader = open(pack_file_path, 'rb')
-            except (OSError, IOError):
-                pass  # it didnt exist at all
-            else:
-                new_lines = list()
-                made_change = False
-                dropped_last_line = False
-                for line in reader:
-                    # keep line if it is a comment or if the ref to delete is not
-                    # in the line
-                    # If we deleted the last line and this one is a tag-reference object,
-                    # we drop it as well
-                    line = line.decode(defenc)
-                    if (line.startswith('#') or full_ref_path not in line) and \
-                            (not dropped_last_line or dropped_last_line and not line.startswith('^')):
-                        new_lines.append(line)
-                        dropped_last_line = False
-                        continue
-                    # END skip comments and lines without our path
+                with open(pack_file_path, "rb") as reader:
+                    new_lines = []
+                    made_change = False
+                    dropped_last_line = False
+                    for line_bytes in reader:
+                        line = line_bytes.decode(defenc)
+                        _, _, line_ref = line.partition(" ")
+                        line_ref = line_ref.strip()
+                        # Keep line if it is a comment or if the ref to delete is not in
+                        # the line.
+                        # If we deleted the last line and this one is a tag-reference
+                        # object, we drop it as well.
+                        if (line.startswith("#") or full_ref_path != line_ref) and (
+                            not dropped_last_line or dropped_last_line and not line.startswith("^")
+                        ):
+                            new_lines.append(line)
+                            dropped_last_line = False
+                            continue
+                        # END skip comments and lines without our path
+
+                        # Drop this line.
+                        made_change = True
+                        dropped_last_line = True
+
+                # Write the new lines.
+                if made_change:
+                    # Binary writing is required, otherwise Windows will open the file
+                    # in text mode and change LF to CRLF!
+                    with open(pack_file_path, "wb") as fd:
+                        fd.writelines(line.encode(defenc) for line in new_lines)
 
-                    # drop this line
-                    made_change = True
-                    dropped_last_line = True
-                # END for each line in packed refs
-                reader.close()
+            except OSError:
+                pass  # It didn't exist at all.
 
-                # write the new lines
-                if made_change:
-                    # write-binary is required, otherwise windows will
-                    # open the file in text mode and change LF to CRLF !
-                    open(pack_file_path, 'wb').writelines(l.encode(defenc) for l in new_lines)
-                # END write out file
-            # END open exception handling
-        # END handle deletion
-
-        # delete the reflog
+        # Delete the reflog.
         reflog_path = RefLog.path(cls(repo, full_ref_path))
         if os.path.isfile(reflog_path):
             os.remove(reflog_path)
         # END remove reflog
 
     @classmethod
-    def _create(cls, repo, path, resolve, reference, force, logmsg=None):
-        """internal method used to create a new symbolic reference.
-        If resolve is False, the reference will be taken as is, creating
-        a proper symbolic reference. Otherwise it will be resolved to the
-        corresponding object and a detached symbolic reference will be created
-        instead"""
+    def _create(
+        cls: Type[T_References],
+        repo: "Repo",
+        path: PathLike,
+        resolve: bool,
+        reference: Union["SymbolicReference", str],
+        force: bool,
+        logmsg: Union[str, None] = None,
+    ) -> T_References:
+        """Internal method used to create a new symbolic reference.
+
+        If `resolve` is ``False``, the reference will be taken as is, creating a proper
+        symbolic reference. Otherwise it will be resolved to the corresponding object
+        and a detached symbolic reference will be created instead.
+        """
+        git_dir = _git_dir(repo, path)
         full_ref_path = cls.to_full_path(path)
-        abs_ref_path = join(repo.git_dir, full_ref_path)
+        abs_ref_path = os.path.join(git_dir, full_ref_path)
 
-        # figure out target data
+        # Figure out target data.
         target = reference
         if resolve:
             target = repo.rev_parse(str(reference))
 
-        if not force and isfile(abs_ref_path):
+        if not force and os.path.isfile(abs_ref_path):
             target_data = str(target)
             if isinstance(target, SymbolicReference):
-                target_data = target.path
+                target_data = str(target.path)
             if not resolve:
                 target_data = "ref: " + target_data
-            existing_data = open(abs_ref_path, 'rb').read().decode(defenc).strip()
+            with open(abs_ref_path, "rb") as fd:
+                existing_data = fd.read().decode(defenc).strip()
             if existing_data != target_data:
-                raise OSError("Reference at %r does already exist, pointing to %r, requested was %r" %
-                              (full_ref_path, existing_data, target_data))
+                raise OSError(
+                    "Reference at %r does already exist, pointing to %r, requested was %r"
+                    % (full_ref_path, existing_data, target_data)
+                )
         # END no force handling
 
         ref = cls(repo, full_ref_path)
@@ -494,107 +722,131 @@ def _create(cls, repo, path, resolve, reference, force, logmsg=None):
         return ref
 
     @classmethod
-    def create(cls, repo, path, reference='HEAD', force=False, logmsg=None):
-        """Create a new symbolic reference, hence a reference pointing to another reference.
+    def create(
+        cls: Type[T_References],
+        repo: "Repo",
+        path: PathLike,
+        reference: Union["SymbolicReference", str] = "HEAD",
+        logmsg: Union[str, None] = None,
+        force: bool = False,
+        **kwargs: Any,
+    ) -> T_References:
+        """Create a new symbolic reference: a reference pointing to another reference.
 
         :param repo:
-            Repository to create the reference in
+            Repository to create the reference in.
 
         :param path:
-            full path at which the new symbolic reference is supposed to be
-            created at, i.e. "NEW_HEAD" or "symrefs/my_new_symref"
+            Full path at which the new symbolic reference is supposed to be created at,
+            e.g. ``NEW_HEAD`` or ``symrefs/my_new_symref``.
 
         :param reference:
-            The reference to which the new symbolic reference should point to.
-            If it is a commit'ish, the symbolic ref will be detached.
+            The reference which the new symbolic reference should point to.
+            If it is a commit-ish, the symbolic ref will be detached.
 
         :param force:
-            if True, force creation even if a symbolic reference with that name already exists.
-            Raise OSError otherwise
+            If ``True``, force creation even if a symbolic reference with that name
+            already exists. Raise :exc:`OSError` otherwise.
 
         :param logmsg:
-            If not None, the message to append to the reflog. Otherwise no reflog
-            entry is written.
+            If not ``None``, the message to append to the reflog.
+            If ``None``, no reflog entry is written.
 
-        :return: Newly created symbolic Reference
+        :return:
+            Newly created symbolic reference
 
         :raise OSError:
-            If a (Symbolic)Reference with the same name but different contents
-            already exists.
+            If a (Symbolic)Reference with the same name but different contents already
+            exists.
 
-        :note: This does not alter the current HEAD, index or Working Tree"""
+        :note:
+            This does not alter the current HEAD, index or working tree.
+        """
         return cls._create(repo, path, cls._resolve_ref_on_create, reference, force, logmsg)
 
-    def rename(self, new_path, force=False):
-        """Rename self to a new path
+    def rename(self, new_path: PathLike, force: bool = False) -> "SymbolicReference":
+        """Rename self to a new path.
 
         :param new_path:
-            Either a simple name or a full path, i.e. new_name or features/new_name.
-            The prefix refs/ is implied for references and will be set as needed.
-            In case this is a symbolic ref, there is no implied prefix
+            Either a simple name or a full path, e.g. ``new_name`` or
+            ``features/new_name``.
+            The prefix ``refs/`` is implied for references and will be set as needed.
+            In case this is a symbolic ref, there is no implied prefix.
 
         :param force:
-            If True, the rename will succeed even if a head with the target name
-            already exists. It will be overwritten in that case
+            If ``True``, the rename will succeed even if a head with the target name
+            already exists. It will be overwritten in that case.
 
-        :return: self
-        :raise OSError: In case a file at path but a different contents already exists """
+        :return:
+            self
+
+        :raise OSError:
+            If a file at path but with different contents already exists.
+        """
         new_path = self.to_full_path(new_path)
         if self.path == new_path:
             return self
 
-        new_abs_path = join(self.repo.git_dir, new_path)
-        cur_abs_path = join(self.repo.git_dir, self.path)
-        if isfile(new_abs_path):
+        new_abs_path = os.path.join(_git_dir(self.repo, new_path), new_path)
+        cur_abs_path = os.path.join(_git_dir(self.repo, self.path), self.path)
+        if os.path.isfile(new_abs_path):
             if not force:
-                # if they point to the same file, its not an error
-                if open(new_abs_path, 'rb').read().strip() != open(cur_abs_path, 'rb').read().strip():
+                # If they point to the same file, it's not an error.
+                with open(new_abs_path, "rb") as fd1:
+                    f1 = fd1.read().strip()
+                with open(cur_abs_path, "rb") as fd2:
+                    f2 = fd2.read().strip()
+                if f1 != f2:
                     raise OSError("File at path %r already exists" % new_abs_path)
-                # else: we could remove ourselves and use the otherone, but
-                # but clarity we just continue as usual
+                # else: We could remove ourselves and use the other one, but...
+                # ...for clarity, we just continue as usual.
             # END not force handling
             os.remove(new_abs_path)
         # END handle existing target file
 
-        dname = dirname(new_abs_path)
-        if not isdir(dname):
+        dname = os.path.dirname(new_abs_path)
+        if not os.path.isdir(dname):
             os.makedirs(dname)
         # END create directory
 
-        rename(cur_abs_path, new_abs_path)
+        os.rename(cur_abs_path, new_abs_path)
         self.path = new_path
 
         return self
 
     @classmethod
-    def _iter_items(cls, repo, common_path=None):
+    def _iter_items(
+        cls: Type[T_References], repo: "Repo", common_path: Union[PathLike, None] = None
+    ) -> Iterator[T_References]:
         if common_path is None:
             common_path = cls._common_path_default
         rela_paths = set()
 
-        # walk loose refs
-        # Currently we do not follow links
-        for root, dirs, files in os.walk(join_path_native(repo.git_dir, common_path)):
-            if 'refs/' not in root:  # skip non-refs subfolders
-                refs_id = [d for d in dirs if d == 'refs']
+        # Walk loose refs.
+        # Currently we do not follow links.
+        for root, dirs, files in os.walk(join_path_native(repo.common_dir, common_path)):
+            if "refs" not in root.split(os.sep):  # Skip non-refs subfolders.
+                refs_id = [d for d in dirs if d == "refs"]
                 if refs_id:
-                    dirs[0:] = ['refs']
+                    dirs[0:] = ["refs"]
             # END prune non-refs folders
 
             for f in files:
+                if f == "packed-refs":
+                    continue
                 abs_path = to_native_path_linux(join_path(root, f))
-                rela_paths.add(abs_path.replace(to_native_path_linux(repo.git_dir) + '/', ""))
+                rela_paths.add(abs_path.replace(to_native_path_linux(repo.common_dir) + "/", ""))
             # END for each file in root directory
         # END for each directory to walk
 
-        # read packed refs
-        for sha, rela_path in cls._iter_packed_refs(repo):
-            if rela_path.startswith(common_path):
+        # Read packed refs.
+        for _sha, rela_path in cls._iter_packed_refs(repo):
+            if rela_path.startswith(str(common_path)):
                 rela_paths.add(rela_path)
             # END relative path matches common path
         # END packed refs reading
 
-        # return paths in sorted order
+        # Yield paths in sorted order.
         for path in sorted(rela_paths):
             try:
                 yield cls.from_path(repo, path)
@@ -603,51 +855,79 @@ def _iter_items(cls, repo, common_path=None):
         # END for each sorted relative refpath
 
     @classmethod
-    def iter_items(cls, repo, common_path=None):
-        """Find all refs in the repository
+    def iter_items(
+        cls: Type[T_References],
+        repo: "Repo",
+        common_path: Union[PathLike, None] = None,
+        *args: Any,
+        **kwargs: Any,
+    ) -> Iterator[T_References]:
+        """Find all refs in the repository.
 
-        :param repo: is the Repo
+        :param repo:
+            The :class:`~git.repo.base.Repo`.
 
         :param common_path:
-            Optional keyword argument to the path which is to be shared by all
-            returned Ref objects.
-            Defaults to class specific portion if None assuring that only
-            refs suitable for the actual class are returned.
+            Optional keyword argument to the path which is to be shared by all returned
+            Ref objects.
+            Defaults to class specific portion if ``None``, ensuring that only refs
+            suitable for the actual class are returned.
 
         :return:
-            git.SymbolicReference[], each of them is guaranteed to be a symbolic
-            ref which is not detached and pointing to a valid ref
+            A list of :class:`SymbolicReference`, each guaranteed to be a symbolic ref
+            which is not detached and pointing to a valid ref.
 
-            List is lexigraphically sorted
-            The returned objects represent actual subclasses, such as Head or TagReference"""
-        return (r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached)
+            The list is lexicographically sorted. The returned objects are instances of
+            concrete subclasses, such as :class:`~git.refs.head.Head` or
+            :class:`~git.refs.tag.TagReference`.
+        """
+        return (r for r in cls._iter_items(repo, common_path) if r.__class__ is SymbolicReference or not r.is_detached)
 
     @classmethod
-    def from_path(cls, repo, path):
-        """
-        :param path: full .git-directory-relative path name to the Reference to instantiate
-        :note: use to_full_path() if you only have a partial path of a known Reference Type
+    def from_path(cls: Type[T_References], repo: "Repo", path: PathLike) -> T_References:
+        """Make a symbolic reference from a path.
+
+        :param path:
+            Full ``.git``-directory-relative path name to the Reference to instantiate.
+
+        :note:
+            Use :meth:`to_full_path` if you only have a partial path of a known
+            Reference type.
+
         :return:
-            Instance of type Reference, Head, or Tag
-            depending on the given path"""
+            Instance of type :class:`~git.refs.reference.Reference`,
+            :class:`~git.refs.head.Head`, or :class:`~git.refs.tag.Tag`, depending on
+            the given path.
+        """
         if not path:
             raise ValueError("Cannot create Reference from %r" % path)
 
-        # Names like HEAD are inserted after the refs module is imported - we have an import dependency
-        # cycle and don't want to import these names in-function
+        # Names like HEAD are inserted after the refs module is imported - we have an
+        # import dependency cycle and don't want to import these names in-function.
         from . import HEAD, Head, RemoteReference, TagReference, Reference
-        for ref_type in (HEAD, Head, RemoteReference, TagReference, Reference, SymbolicReference):
+
+        for ref_type in (
+            HEAD,
+            Head,
+            RemoteReference,
+            TagReference,
+            Reference,
+            SymbolicReference,
+        ):
             try:
+                instance: T_References
                 instance = ref_type(repo, path)
-                if instance.__class__ == SymbolicReference and instance.is_detached:
-                    raise ValueError("SymbolRef was detached, we drop it")
-                return instance
+                if instance.__class__ is SymbolicReference and instance.is_detached:
+                    raise ValueError("SymbolicRef was detached, we drop it")
+                else:
+                    return instance
+
             except ValueError:
                 pass
             # END exception handling
         # END for each type to try
         raise ValueError("Could not find reference type suitable to handle path %r" % path)
 
-    def is_remote(self):
+    def is_remote(self) -> bool:
         """:return: True if this symbolic reference points to a remote branch"""
-        return self.path.startswith(self._remote_common_path_default + "/")
+        return str(self.path).startswith(self._remote_common_path_default + "/")
diff --git a/git/refs/tag.py b/git/refs/tag.py
index 3334e53c1..1e38663ae 100644
--- a/git/refs/tag.py
+++ b/git/refs/tag.py
@@ -1,90 +1,155 @@
-from .reference import Reference
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Provides a :class:`~git.refs.reference.Reference`-based type for lightweight tags.
+
+This defines the :class:`TagReference` class (and its alias :class:`Tag`), which
+represents lightweight tags. For annotated tags (which are git objects), see the
+:mod:`git.objects.tag` module.
+"""
 
 __all__ = ["TagReference", "Tag"]
 
+from .reference import Reference
 
-class TagReference(Reference):
+# typing ------------------------------------------------------------------
+
+from typing import Any, TYPE_CHECKING, Type, Union
+
+from git.types import AnyGitObject, PathLike
 
-    """Class representing a lightweight tag reference which either points to a commit
-    ,a tag object or any other object. In the latter case additional information,
-    like the signature or the tag-creator, is available.
+if TYPE_CHECKING:
+    from git.objects import Commit, TagObject
+    from git.refs import SymbolicReference
+    from git.repo import Repo
 
-    This tag object will always point to a commit object, but may carray additional
+# ------------------------------------------------------------------------------
+
+
+class TagReference(Reference):
+    """A lightweight tag reference which either points to a commit, a tag object or any
+    other object. In the latter case additional information, like the signature or the
+    tag-creator, is available.
+
+    This tag object will always point to a commit object, but may carry additional
     information in a tag object::
 
      tagref = TagReference.list_items(repo)[0]
      print(tagref.commit.message)
      if tagref.tag is not None:
-        print(tagref.tag.message)"""
+        print(tagref.tag.message)
+    """
+
+    __slots__ = ()
 
-    __slots__ = tuple()
-    _common_path_default = "refs/tags"
+    _common_default = "tags"
+    _common_path_default = Reference._common_path_default + "/" + _common_default
 
     @property
-    def commit(self):
-        """:return: Commit object the tag ref points to"""
+    def commit(self) -> "Commit":  # type: ignore[override]  # LazyMixin has unrelated commit method
+        """:return: Commit object the tag ref points to
+
+        :raise ValueError:
+            If the tag points to a tree or blob.
+        """
         obj = self.object
-        if obj.type == "commit":
-            return obj
-        elif obj.type == "tag":
-            # it is a tag object which carries the commit as an object - we can point to anything
-            return obj.object
-        else:
-            raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self)
+        while obj.type != "commit":
+            if obj.type == "tag":
+                # It is a tag object which carries the commit as an object - we can point to anything.
+                obj = obj.object
+            else:
+                raise ValueError(
+                    (
+                        "Cannot resolve commit as tag %s points to a %s object - "
+                        + "use the `.object` property instead to access it"
+                    )
+                    % (self, obj.type)
+                )
+        return obj
 
     @property
-    def tag(self):
+    def tag(self) -> Union["TagObject", None]:
+        """
+        :return:
+            Tag object this tag ref points to, or ``None`` in case we are a lightweight
+            tag
         """
-        :return: Tag object this tag ref points to or None in case
-            we are a light weight tag"""
         obj = self.object
         if obj.type == "tag":
             return obj
         return None
 
-    # make object read-only
-    # It should be reasonably hard to adjust an existing tag
-    object = property(Reference._get_object)
+    # Make object read-only. It should be reasonably hard to adjust an existing tag.
+    @property
+    def object(self) -> AnyGitObject:  # type: ignore[override]
+        return Reference._get_object(self)
 
     @classmethod
-    def create(cls, repo, path, ref='HEAD', message=None, force=False, **kwargs):
+    def create(
+        cls: Type["TagReference"],
+        repo: "Repo",
+        path: PathLike,
+        reference: Union[str, "SymbolicReference"] = "HEAD",
+        logmsg: Union[str, None] = None,
+        force: bool = False,
+        **kwargs: Any,
+    ) -> "TagReference":
         """Create a new tag reference.
 
+        :param repo:
+            The :class:`~git.repo.base.Repo` to create the tag in.
+
         :param path:
-            The name of the tag, i.e. 1.0 or releases/1.0.
-            The prefix refs/tags is implied
+            The name of the tag, e.g. ``1.0`` or ``releases/1.0``.
+            The prefix ``refs/tags`` is implied.
 
-        :param ref:
-            A reference to the object you want to tag. It can be a commit, tree or
-            blob.
+        :param reference:
+            A reference to the :class:`~git.objects.base.Object` you want to tag.
+            The referenced object can be a commit, tree, or blob.
 
-        :param message:
-            If not None, the message will be used in your tag object. This will also
-            create an additional tag object that allows to obtain that information, i.e.::
+        :param logmsg:
+            If not ``None``, the message will be used in your tag object. This will also
+            create an additional tag object that allows to obtain that information,
+            e.g.::
 
                 tagref.tag.message
 
+        :param message:
+            Synonym for the `logmsg` parameter. Included for backwards compatibility.
+            `logmsg` takes precedence if both are passed.
+
         :param force:
-            If True, to force creation of a tag even though that tag already exists.
+            If ``True``, force creation of a tag even though that tag already exists.
 
         :param kwargs:
-            Additional keyword arguments to be passed to git-tag
+            Additional keyword arguments to be passed to :manpage:`git-tag(1)`.
+
+        :return:
+            A new :class:`TagReference`.
+        """
+        if "ref" in kwargs and kwargs["ref"]:
+            reference = kwargs["ref"]
+
+        if "message" in kwargs and kwargs["message"]:
+            kwargs["m"] = kwargs["message"]
+            del kwargs["message"]
+
+        if logmsg:
+            kwargs["m"] = logmsg
 
-        :return: A new TagReference"""
-        args = (path, ref)
-        if message:
-            kwargs['m'] = message
         if force:
-            kwargs['f'] = True
+            kwargs["f"] = True
+
+        args = (path, reference)
 
         repo.git.tag(*args, **kwargs)
         return TagReference(repo, "%s/%s" % (cls._common_path_default, path))
 
     @classmethod
-    def delete(cls, repo, *tags):
-        """Delete the given existing tag or tags"""
+    def delete(cls, repo: "Repo", *tags: "TagReference") -> None:  # type: ignore[override]
+        """Delete the given existing tag or tags."""
         repo.git.tag("-d", *tags)
 
 
-# provide an alias
+# Provide an alias.
 Tag = TagReference
diff --git a/git/remote.py b/git/remote.py
index dbb82796b..20e42b412 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -1,64 +1,121 @@
-# remote.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-# Module implementing a remote object allowing easy access to git remotes
-import re
-import os
+"""Module implementing a remote object allowing easy access to git remotes."""
 
-from .exc import GitCommandError
-from .config import (
-    SectionConstraint,
-    cp,
-)
-from .refs import (
-    Reference,
-    RemoteReference,
-    SymbolicReference,
-    TagReference
-)
+__all__ = ["RemoteProgress", "PushInfo", "FetchInfo", "Remote"]
 
+import contextlib
+import logging
+import re
 
+from git.cmd import Git, handle_process_output
+from git.compat import defenc, force_text
+from git.config import GitConfigParser, SectionConstraint, cp
+from git.exc import GitCommandError
+from git.refs import Head, Reference, RemoteReference, SymbolicReference, TagReference
 from git.util import (
-    LazyMixin,
-    Iterable,
+    CallableRemoteProgress,
     IterableList,
-    RemoteProgress
-)
-from git.util import (
+    IterableObj,
+    LazyMixin,
+    RemoteProgress,
     join_path,
-    finalize_process
 )
-from git.cmd import handle_process_output
-from gitdb.util import join
-from git.compat import defenc
 
+# typing-------------------------------------------------------
+
+from typing import (
+    Any,
+    Callable,
+    Dict,
+    Iterator,
+    List,
+    NoReturn,
+    Optional,
+    Sequence,
+    TYPE_CHECKING,
+    Type,
+    Union,
+    cast,
+    overload,
+)
+
+from git.types import AnyGitObject, Literal, PathLike
+
+if TYPE_CHECKING:
+    from git.objects.commit import Commit
+    from git.objects.submodule.base import UpdateProgress
+    from git.repo.base import Repo
+
+flagKeyLiteral = Literal[" ", "!", "+", "-", "*", "=", "t", "?"]
 
-__all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote')
+# -------------------------------------------------------------
 
-#{ Utilities
+_logger = logging.getLogger(__name__)
 
+# { Utilities
 
-def add_progress(kwargs, git, progress):
-    """Add the --progress flag to the given kwargs dict if supported by the
-    git command. If the actual progress in the given progress instance is not
-    given, we do not request any progress
-    :return: possibly altered kwargs"""
+
+def add_progress(
+    kwargs: Any,
+    git: Git,
+    progress: Union[RemoteProgress, "UpdateProgress", Callable[..., RemoteProgress], None],
+) -> Any:
+    """Add the ``--progress`` flag to the given `kwargs` dict if supported by the git
+    command.
+
+    :note:
+        If the actual progress in the given progress instance is not given, we do not
+        request any progress.
+
+    :return:
+        Possibly altered `kwargs`
+    """
     if progress is not None:
-        v = git.version_info
-        if v[0] > 1 or v[1] > 7 or v[2] > 0 or v[3] > 3:
-            kwargs['progress'] = True
+        v = git.version_info[:2]
+        if v >= (1, 7):
+            kwargs["progress"] = True
         # END handle --progress
     # END handle progress
     return kwargs
 
-#} END utilities
 
+# } END utilities
+
+
+@overload
+def to_progress_instance(progress: None) -> RemoteProgress: ...
+
+
+@overload
+def to_progress_instance(progress: Callable[..., Any]) -> CallableRemoteProgress: ...
+
+
+@overload
+def to_progress_instance(progress: RemoteProgress) -> RemoteProgress: ...
+
+
+def to_progress_instance(
+    progress: Union[Callable[..., Any], RemoteProgress, None],
+) -> Union[RemoteProgress, CallableRemoteProgress]:
+    """Given the `progress` return a suitable object derived from
+    :class:`~git.util.RemoteProgress`."""
+    # New API only needs progress as a function.
+    if callable(progress):
+        return CallableRemoteProgress(progress)
 
-class PushInfo(object):
+    # Where None is passed create a parser that eats the progress.
+    elif progress is None:
+        return RemoteProgress()
 
+    # Assume its the old API with an instance of RemoteProgress.
+    return progress
+
+
+class PushInfo(IterableObj):
     """
     Carries information about the result of a push operation of a single head::
 
@@ -72,70 +129,115 @@ class PushInfo(object):
         info.old_commit # commit at which the remote_ref was standing before we pushed
                         # it to local_ref.commit. Will be None if an error was indicated
         info.summary    # summary line providing human readable english text about the push
+    """
+
+    __slots__ = (
+        "local_ref",
+        "remote_ref_string",
+        "flags",
+        "_old_commit_sha",
+        "_remote",
+        "summary",
+    )
+
+    _id_attribute_ = "pushinfo"
+
+    (
+        NEW_TAG,
+        NEW_HEAD,
+        NO_MATCH,
+        REJECTED,
+        REMOTE_REJECTED,
+        REMOTE_FAILURE,
+        DELETED,
+        FORCED_UPDATE,
+        FAST_FORWARD,
+        UP_TO_DATE,
+        ERROR,
+    ) = [1 << x for x in range(11)]
+
+    _flag_map = {
+        "X": NO_MATCH,
+        "-": DELETED,
+        "*": 0,
+        "+": FORCED_UPDATE,
+        " ": FAST_FORWARD,
+        "=": UP_TO_DATE,
+        "!": ERROR,
+    }
+
+    def __init__(
+        self,
+        flags: int,
+        local_ref: Union[SymbolicReference, None],
+        remote_ref_string: str,
+        remote: "Remote",
+        old_commit: Optional[str] = None,
+        summary: str = "",
+    ) -> None:
+        """Initialize a new instance.
+
+        local_ref: HEAD | Head | RemoteReference | TagReference | Reference | SymbolicReference | None
         """
-    __slots__ = ('local_ref', 'remote_ref_string', 'flags', 'old_commit', '_remote', 'summary')
-
-    NEW_TAG, NEW_HEAD, NO_MATCH, REJECTED, REMOTE_REJECTED, REMOTE_FAILURE, DELETED, \
-        FORCED_UPDATE, FAST_FORWARD, UP_TO_DATE, ERROR = [1 << x for x in range(11)]
-
-    _flag_map = {'X': NO_MATCH,
-                 '-': DELETED,
-                 '*': 0,
-                 '+': FORCED_UPDATE,
-                 ' ': FAST_FORWARD,
-                 '=': UP_TO_DATE,
-                 '!': ERROR}
-
-    def __init__(self, flags, local_ref, remote_ref_string, remote, old_commit=None,
-                 summary=''):
-        """ Initialize a new instance """
         self.flags = flags
         self.local_ref = local_ref
         self.remote_ref_string = remote_ref_string
         self._remote = remote
-        self.old_commit = old_commit
+        self._old_commit_sha = old_commit
         self.summary = summary
 
     @property
-    def remote_ref(self):
+    def old_commit(self) -> Union["Commit", None]:
+        return self._old_commit_sha and self._remote.repo.commit(self._old_commit_sha) or None
+
+    @property
+    def remote_ref(self) -> Union[RemoteReference, TagReference]:
         """
         :return:
-            Remote Reference or TagReference in the local repository corresponding
-            to the remote_ref_string kept in this instance."""
-        # translate heads to a local remote, tags stay as they are
+            Remote :class:`~git.refs.reference.Reference` or
+            :class:`~git.refs.tag.TagReference` in the local repository corresponding to
+            the :attr:`remote_ref_string` kept in this instance.
+        """
+        # Translate heads to a local remote. Tags stay as they are.
         if self.remote_ref_string.startswith("refs/tags"):
             return TagReference(self._remote.repo, self.remote_ref_string)
         elif self.remote_ref_string.startswith("refs/heads"):
             remote_ref = Reference(self._remote.repo, self.remote_ref_string)
-            return RemoteReference(self._remote.repo, "refs/remotes/%s/%s" % (str(self._remote), remote_ref.name))
+            return RemoteReference(
+                self._remote.repo,
+                "refs/remotes/%s/%s" % (str(self._remote), remote_ref.name),
+            )
         else:
             raise ValueError("Could not handle remote ref: %r" % self.remote_ref_string)
         # END
 
     @classmethod
-    def _from_line(cls, remote, line):
-        """Create a new PushInfo instance as parsed from line which is expected to be like
-            refs/heads/master:refs/heads/master 05d2687..1d0568e as bytes"""
-        control_character, from_to, summary = line.split('\t', 3)
+    def _from_line(cls, remote: "Remote", line: str) -> "PushInfo":
+        """Create a new :class:`PushInfo` instance as parsed from line which is expected
+        to be like refs/heads/master:refs/heads/master 05d2687..1d0568e as bytes."""
+        control_character, from_to, summary = line.split("\t", 3)
         flags = 0
 
-        # control character handling
+        # Control character handling
         try:
             flags |= cls._flag_map[control_character]
-        except KeyError:
-            raise ValueError("Control Character %r unknown as parsed from line %r" % (control_character, line))
+        except KeyError as e:
+            raise ValueError("Control character %r unknown as parsed from line %r" % (control_character, line)) from e
         # END handle control character
 
         # from_to handling
-        from_ref_string, to_ref_string = from_to.split(':')
+        from_ref_string, to_ref_string = from_to.split(":")
         if flags & cls.DELETED:
-            from_ref = None
+            from_ref: Union[SymbolicReference, None] = None
         else:
-            from_ref = Reference.from_path(remote.repo, from_ref_string)
+            if from_ref_string == "(delete)":
+                from_ref = None
+            else:
+                from_ref = Reference.from_path(remote.repo, from_ref_string)
 
-        # commit handling, could be message or commit info
-        old_commit = None
-        if summary.startswith('['):
+        # Commit handling, could be message or commit info
+        old_commit: Optional[str] = None
+        if summary.startswith("["):
             if "[rejected]" in summary:
                 flags |= cls.REJECTED
             elif "[remote rejected]" in summary:
@@ -148,23 +250,42 @@ def _from_line(cls, remote, line):
                 flags |= cls.NEW_TAG
             elif "[new branch]" in summary:
                 flags |= cls.NEW_HEAD
-            # uptodate encoded in control character
+            # `uptodate` encoded in control character
         else:
-            # fast-forward or forced update - was encoded in control character,
-            # but we parse the old and new commit
+            # Fast-forward or forced update - was encoded in control character,
+            # but we parse the old and new commit.
             split_token = "..."
             if control_character == " ":
                 split_token = ".."
-            old_sha, new_sha = summary.split(' ')[0].split(split_token)
-            # have to use constructor here as the sha usually is abbreviated
-            old_commit = remote.repo.commit(old_sha)
+            old_sha, _new_sha = summary.split(" ")[0].split(split_token)
+            # Have to use constructor here as the sha usually is abbreviated.
+            old_commit = old_sha
         # END message handling
 
         return PushInfo(flags, from_ref, to_ref_string, remote, old_commit, summary)
 
+    @classmethod
+    def iter_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> NoReturn:  # -> Iterator['PushInfo']:
+        raise NotImplementedError
+
+
+class PushInfoList(IterableList[PushInfo]):
+    """:class:`~git.util.IterableList` of :class:`PushInfo` objects."""
 
-class FetchInfo(object):
+    def __new__(cls) -> "PushInfoList":
+        return cast(PushInfoList, IterableList.__new__(cls, "push_infos"))
 
+    def __init__(self) -> None:
+        super().__init__("push_infos")
+        self.error: Optional[Exception] = None
+
+    def raise_if_error(self) -> None:
+        """Raise an exception if any ref failed to push."""
+        if self.error:
+            raise self.error
+
+
+class FetchInfo(IterableObj):
     """
     Carries information about the results of a fetch operation of a single head::
 
@@ -177,508 +298,951 @@ class FetchInfo(object):
      info.note          # additional notes given by git-fetch intended for the user
      info.old_commit    # if info.flags & info.FORCED_UPDATE|info.FAST_FORWARD,
                         # field is set to the previous location of ref, otherwise None
+     info.remote_ref_path # The path from which we fetched on the remote. It's the remote's version of our info.ref
     """
-    __slots__ = ('ref', 'old_commit', 'flags', 'note')
 
-    NEW_TAG, NEW_HEAD, HEAD_UPTODATE, TAG_UPDATE, REJECTED, FORCED_UPDATE, \
-        FAST_FORWARD, ERROR = [1 << x for x in range(8)]
+    __slots__ = ("ref", "old_commit", "flags", "note", "remote_ref_path")
 
-    #                             %c    %-*s %-*s             -> %s       (%s)
-    re_fetch_result = re.compile("^\s*(.) (\[?[\w\s\.]+\]?)\s+(.+) -> ([/\w_\+\.\-#]+)(    \(.*\)?$)?")
+    _id_attribute_ = "fetchinfo"
 
-    _flag_map = {'!': ERROR,
-                 '+': FORCED_UPDATE,
-                 '-': TAG_UPDATE,
-                 '*': 0,
-                 '=': HEAD_UPTODATE,
-                 ' ': FAST_FORWARD}
+    (
+        NEW_TAG,
+        NEW_HEAD,
+        HEAD_UPTODATE,
+        TAG_UPDATE,
+        REJECTED,
+        FORCED_UPDATE,
+        FAST_FORWARD,
+        ERROR,
+    ) = [1 << x for x in range(8)]
 
-    def __init__(self, ref, flags, note='', old_commit=None):
-        """
-        Initialize a new instance
+    _re_fetch_result = re.compile(r"^ *(?:.{0,3})(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)(    \(.*\)?$)?")
+
+    _flag_map: Dict[flagKeyLiteral, int] = {
+        "!": ERROR,
+        "+": FORCED_UPDATE,
+        "*": 0,
+        "=": HEAD_UPTODATE,
+        " ": FAST_FORWARD,
+        "-": TAG_UPDATE,
+    }
+
+    @classmethod
+    def refresh(cls) -> Literal[True]:
+        """Update information about which :manpage:`git-fetch(1)` flags are supported
+        by the git executable being used.
+
+        Called by the :func:`git.refresh` function in the top level ``__init__``.
         """
+        # Clear the old values in _flag_map.
+        with contextlib.suppress(KeyError):
+            del cls._flag_map["t"]
+        with contextlib.suppress(KeyError):
+            del cls._flag_map["-"]
+
+        # Set the value given the git version.
+        if Git().version_info[:2] >= (2, 10):
+            cls._flag_map["t"] = cls.TAG_UPDATE
+        else:
+            cls._flag_map["-"] = cls.TAG_UPDATE
+
+        return True
+
+    def __init__(
+        self,
+        ref: SymbolicReference,
+        flags: int,
+        note: str = "",
+        old_commit: Union[AnyGitObject, None] = None,
+        remote_ref_path: Optional[PathLike] = None,
+    ) -> None:
+        """Initialize a new instance."""
         self.ref = ref
         self.flags = flags
         self.note = note
         self.old_commit = old_commit
+        self.remote_ref_path = remote_ref_path
 
-    def __str__(self):
+    def __str__(self) -> str:
         return self.name
 
     @property
-    def name(self):
+    def name(self) -> str:
         """:return: Name of our remote ref"""
         return self.ref.name
 
     @property
-    def commit(self):
+    def commit(self) -> "Commit":
         """:return: Commit of our remote ref"""
         return self.ref.commit
 
     @classmethod
-    def _from_line(cls, repo, line, fetch_line):
-        """Parse information from the given line as returned by git-fetch -v
-        and return a new FetchInfo object representing this information.
-
-        We can handle a line as follows
-        "%c %-*s %-*s -> %s%s"
-
-        Where c is either ' ', !, +, -, *, or =
-        ! means error
-        + means success forcing update
-        - means a tag was updated
-        * means birth of new branch or tag
-        = means the head was up to date ( and not moved )
-        ' ' means a fast-forward
-
-        fetch line is the corresponding line from FETCH_HEAD, like
-        acb0fa8b94ef421ad60c8507b634759a472cd56c    not-for-merge   branch '0.1.7RC' of /tmp/tmpya0vairemote_repo"""
-        match = cls.re_fetch_result.match(line)
+    def _from_line(cls, repo: "Repo", line: str, fetch_line: str) -> "FetchInfo":
+        """Parse information from the given line as returned by ``git-fetch -v`` and
+        return a new :class:`FetchInfo` object representing this information.
+
+        We can handle a line as follows::
+
+            %c %-*s %-*s -> %s%s
+
+        Where ``c`` is either a space, ``!``, ``+``, ``-``, ``*``, or ``=``:
+
+        - '!' means error
+        - '+' means success forcing update
+        - '-' means a tag was updated
+        - '*' means birth of new branch or tag
+        - '=' means the head was up to date (and not moved)
+        - ' ' means a fast-forward
+
+        `fetch_line` is the corresponding line from FETCH_HEAD, like::
+
+            acb0fa8b94ef421ad60c8507b634759a472cd56c    not-for-merge   branch '0.1.7RC' of /tmp/tmpya0vairemote_repo
+        """
+        match = cls._re_fetch_result.match(line)
         if match is None:
             raise ValueError("Failed to parse line: %r" % line)
 
-        # parse lines
-        control_character, operation, local_remote_ref, remote_local_ref, note = match.groups()
+        # Parse lines.
+        remote_local_ref_str: str
+        (
+            control_character,
+            operation,
+            local_remote_ref,
+            remote_local_ref_str,
+            note,
+        ) = match.groups()
+        control_character = cast(flagKeyLiteral, control_character)
         try:
-            new_hex_sha, fetch_operation, fetch_note = fetch_line.split("\t")
-            ref_type_name, fetch_note = fetch_note.split(' ', 1)
-        except ValueError:  # unpack error
-            raise ValueError("Failed to parse FETCH__HEAD line: %r" % fetch_line)
+            _new_hex_sha, _fetch_operation, fetch_note = fetch_line.split("\t")
+            ref_type_name, fetch_note = fetch_note.split(" ", 1)
+        except ValueError as e:  # unpack error
+            raise ValueError("Failed to parse FETCH_HEAD line: %r" % fetch_line) from e
 
-        # parse flags from control_character
+        # Parse flags from control_character.
         flags = 0
         try:
             flags |= cls._flag_map[control_character]
-        except KeyError:
-            raise ValueError("Control character %r unknown as parsed from line %r" % (control_character, line))
-        # END control char exception hanlding
+        except KeyError as e:
+            raise ValueError("Control character %r unknown as parsed from line %r" % (control_character, line)) from e
+        # END control char exception handling
 
-        # parse operation string for more info - makes no sense for symbolic refs, but we parse it anyway
-        old_commit = None
+        # Parse operation string for more info.
+        # This makes no sense for symbolic refs, but we parse it anyway.
+        old_commit: Union[AnyGitObject, None] = None
         is_tag_operation = False
-        if 'rejected' in operation:
+        if "rejected" in operation:
             flags |= cls.REJECTED
-        if 'new tag' in operation:
+        if "new tag" in operation:
             flags |= cls.NEW_TAG
             is_tag_operation = True
-        if 'tag update' in operation:
+        if "tag update" in operation:
             flags |= cls.TAG_UPDATE
             is_tag_operation = True
-        if 'new branch' in operation:
+        if "new branch" in operation:
             flags |= cls.NEW_HEAD
-        if '...' in operation or '..' in operation:
-            split_token = '...'
-            if control_character == ' ':
+        if "..." in operation or ".." in operation:
+            split_token = "..."
+            if control_character == " ":
                 split_token = split_token[:-1]
             old_commit = repo.rev_parse(operation.split(split_token)[0])
         # END handle refspec
 
-        # handle FETCH_HEAD and figure out ref type
+        # Handle FETCH_HEAD and figure out ref type.
         # If we do not specify a target branch like master:refs/remotes/origin/master,
         # the fetch result is stored in FETCH_HEAD which destroys the rule we usually
-        # have. In that case we use a symbolic reference which is detached
-        ref_type = None
-        if remote_local_ref == "FETCH_HEAD":
+        # have. In that case we use a symbolic reference which is detached.
+        ref_type: Optional[Type[SymbolicReference]] = None
+        if remote_local_ref_str == "FETCH_HEAD":
             ref_type = SymbolicReference
         elif ref_type_name == "tag" or is_tag_operation:
-            # the ref_type_name can be branch, whereas we are still seeing a tag operation. It happens during
-            # testing, which is based on actual git operations
+            # The ref_type_name can be branch, whereas we are still seeing a tag
+            # operation. It happens during testing, which is based on actual git
+            # operations.
             ref_type = TagReference
         elif ref_type_name in ("remote-tracking", "branch"):
-            # note: remote-tracking is just the first part of the 'remote-tracking branch' token.
-            # We don't parse it correctly, but its enough to know what to do, and its new in git 1.7something
+            # Note: remote-tracking is just the first part of the
+            # 'remote-tracking branch' token. We don't parse it correctly, but it's
+            # enough to know what to do, and it's new in git 1.7something.
             ref_type = RemoteReference
+        elif "/" in ref_type_name:
+            # If the fetch spec look something like '+refs/pull/*:refs/heads/pull/*',
+            # and is thus pretty much anything the user wants, we will have trouble
+            # determining what's going on. For now, we assume the local ref is a Head.
+            ref_type = Head
         else:
             raise TypeError("Cannot handle reference type: %r" % ref_type_name)
         # END handle ref type
 
-        # create ref instance
+        # Create ref instance.
         if ref_type is SymbolicReference:
             remote_local_ref = ref_type(repo, "FETCH_HEAD")
         else:
-            # determine prefix. Tags are usually pulled into refs/tags, they may have subdirectories.
-            # It is not clear sometimes where exactly the item is, unless we have an absolute path as indicated
-            # by the 'ref/' prefix. Otherwise even a tag could be in refs/remotes, which is when it will have the
-            # 'tags/' subdirectory in its path.
-            # We don't want to test for actual existence, but try to figure everything out analytically.
-            ref_path = None
-            remote_local_ref = remote_local_ref.strip()
-            if remote_local_ref.startswith(Reference._common_path_default + "/"):
-                # always use actual type if we get absolute paths
-                # Will always be the case if something is fetched outside of refs/remotes (if its not a tag)
-                ref_path = remote_local_ref
-                if ref_type is not TagReference and not \
-                   remote_local_ref.startswith(RemoteReference._common_path_default + "/"):
+            # Determine prefix. Tags are usually pulled into refs/tags; they may have
+            # subdirectories. It is not clear sometimes where exactly the item is,
+            # unless we have an absolute path as indicated by the 'ref/' prefix.
+            # Otherwise even a tag could be in refs/remotes, which is when it will have
+            # the 'tags/' subdirectory in its path. We don't want to test for actual
+            # existence, but try to figure everything out analytically.
+            ref_path: Optional[PathLike] = None
+            remote_local_ref_str = remote_local_ref_str.strip()
+
+            if remote_local_ref_str.startswith(Reference._common_path_default + "/"):
+                # Always use actual type if we get absolute paths. This will always be
+                # the case if something is fetched outside of refs/remotes (if its not a
+                # tag).
+                ref_path = remote_local_ref_str
+                if ref_type is not TagReference and not remote_local_ref_str.startswith(
+                    RemoteReference._common_path_default + "/"
+                ):
                     ref_type = Reference
                 # END downgrade remote reference
-            elif ref_type is TagReference and 'tags/' in remote_local_ref:
-                # even though its a tag, it is located in refs/remotes
-                ref_path = join_path(RemoteReference._common_path_default, remote_local_ref)
+            elif ref_type is TagReference and "tags/" in remote_local_ref_str:
+                # Even though it's a tag, it is located in refs/remotes.
+                ref_path = join_path(RemoteReference._common_path_default, remote_local_ref_str)
             else:
-                ref_path = join_path(ref_type._common_path_default, remote_local_ref)
+                ref_path = join_path(ref_type._common_path_default, remote_local_ref_str)
             # END obtain refpath
 
-            # even though the path could be within the git conventions, we make
-            # sure we respect whatever the user wanted, and disabled path checking
+            # Even though the path could be within the git conventions, we make sure we
+            # respect whatever the user wanted, and disabled path checking.
             remote_local_ref = ref_type(repo, ref_path, check_path=False)
         # END create ref instance
 
-        note = (note and note.strip()) or ''
+        note = (note and note.strip()) or ""
 
-        return cls(remote_local_ref, flags, note, old_commit)
+        return cls(remote_local_ref, flags, note, old_commit, local_remote_ref)
 
+    @classmethod
+    def iter_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> NoReturn:  # -> Iterator['FetchInfo']:
+        raise NotImplementedError
 
-class Remote(LazyMixin, Iterable):
 
+class Remote(LazyMixin, IterableObj):
     """Provides easy read and write access to a git remote.
 
     Everything not part of this interface is considered an option for the current
-    remote, allowing constructs like remote.pushurl to query the pushurl.
+    remote, allowing constructs like ``remote.pushurl`` to query the pushurl.
 
-    NOTE: When querying configuration, the configuration accessor will be cached
-    to speed up subsequent accesses."""
+    :note:
+        When querying configuration, the configuration accessor will be cached to speed
+        up subsequent accesses.
+    """
 
     __slots__ = ("repo", "name", "_config_reader")
-    _id_attribute_ = "name"
 
-    def __init__(self, repo, name):
-        """Initialize a remote instance
+    _id_attribute_ = "name"
 
-        :param repo: The repository we are a remote of
-        :param name: the name of the remote, i.e. 'origin'"""
+    unsafe_git_fetch_options = [
+        # This option allows users to execute arbitrary commands.
+        # https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---upload-packltupload-packgt
+        "--upload-pack",
+    ]
+    unsafe_git_pull_options = [
+        # This option allows users to execute arbitrary commands.
+        # https://git-scm.com/docs/git-pull#Documentation/git-pull.txt---upload-packltupload-packgt
+        "--upload-pack"
+    ]
+    unsafe_git_push_options = [
+        # This option allows users to execute arbitrary commands.
+        # https://git-scm.com/docs/git-push#Documentation/git-push.txt---execltgit-receive-packgt
+        "--receive-pack",
+        "--exec",
+    ]
+
+    url: str  # Obtained dynamically from _config_reader. See __getattr__ below.
+    """The URL configured for the remote."""
+
+    def __init__(self, repo: "Repo", name: str) -> None:
+        """Initialize a remote instance.
+
+        :param repo:
+            The repository we are a remote of.
+
+        :param name:
+            The name of the remote, e.g. ``origin``.
+        """
         self.repo = repo
         self.name = name
 
-        if os.name == 'nt':
-            # some oddity: on windows, python 2.5, it for some reason does not realize
-            # that it has the config_writer property, but instead calls __getattr__
-            # which will not yield the expected results. 'pinging' the members
-            # with a dir call creates the config_writer property that we require
-            # ... bugs like these make me wonder wheter python really wants to be used
-            # for production. It doesn't happen on linux though.
-            dir(self)
-        # END windows special handling
-
-    def __getattr__(self, attr):
-        """Allows to call this instance like
-        remote.special( *args, **kwargs) to call git-remote special self.name"""
+    def __getattr__(self, attr: str) -> Any:
+        """Allows to call this instance like ``remote.special(*args, **kwargs)`` to
+        call ``git remote special self.name``."""
         if attr == "_config_reader":
-            return super(Remote, self).__getattr__(attr)
+            return super().__getattr__(attr)
 
-        # sometimes, probably due to a bug in python itself, we are being called
-        # even though a slot of the same name exists
+        # Sometimes, probably due to a bug in Python itself, we are being called even
+        # though a slot of the same name exists.
         try:
             return self._config_reader.get(attr)
         except cp.NoOptionError:
-            return super(Remote, self).__getattr__(attr)
+            return super().__getattr__(attr)
         # END handle exception
 
-    def _config_section_name(self):
+    def _config_section_name(self) -> str:
         return 'remote "%s"' % self.name
 
-    def _set_cache_(self, attr):
+    def _set_cache_(self, attr: str) -> None:
         if attr == "_config_reader":
-            self._config_reader = SectionConstraint(self.repo.config_reader(), self._config_section_name())
+            # NOTE: This is cached as __getattr__ is overridden to return remote config
+            # values implicitly, such as in print(r.pushurl).
+            self._config_reader = SectionConstraint(
+                self.repo.config_reader("repository"),
+                self._config_section_name(),
+            )
         else:
-            super(Remote, self)._set_cache_(attr)
+            super()._set_cache_(attr)
 
-    def __str__(self):
+    def __str__(self) -> str:
         return self.name
 
-    def __repr__(self):
+    def __repr__(self) -> str:
         return '<git.%s "%s">' % (self.__class__.__name__, self.name)
 
-    def __eq__(self, other):
-        return self.name == other.name
+    def __eq__(self, other: object) -> bool:
+        return isinstance(other, type(self)) and self.name == other.name
 
-    def __ne__(self, other):
+    def __ne__(self, other: object) -> bool:
         return not (self == other)
 
-    def __hash__(self):
+    def __hash__(self) -> int:
         return hash(self.name)
 
-    def exists(self):
+    def exists(self) -> bool:
+        """
+        :return:
+            ``True`` if this is a valid, existing remote.
+            Valid remotes have an entry in the repository's configuration.
         """
-        :return: True if this is a valid, existing remote.
-            Valid remotes have an entry in the repository's configuration"""
         try:
-            self.config_reader.get('url')
+            self.config_reader.get("url")
             return True
         except cp.NoOptionError:
-            # we have the section at least ...
+            # We have the section at least...
             return True
         except cp.NoSectionError:
             return False
-        # end
 
     @classmethod
-    def iter_items(cls, repo):
-        """:return: Iterator yielding Remote objects of the given repository"""
+    def iter_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> Iterator["Remote"]:
+        """:return: Iterator yielding :class:`Remote` objects of the given repository"""
         for section in repo.config_reader("repository").sections():
-            if not section.startswith('remote'):
+            if not section.startswith("remote "):
                 continue
             lbound = section.find('"')
             rbound = section.rfind('"')
             if lbound == -1 or rbound == -1:
                 raise ValueError("Remote-Section has invalid format: %r" % section)
-            yield Remote(repo, section[lbound + 1:rbound])
+            yield Remote(repo, section[lbound + 1 : rbound])
         # END for each configuration section
 
+    def set_url(
+        self, new_url: str, old_url: Optional[str] = None, allow_unsafe_protocols: bool = False, **kwargs: Any
+    ) -> "Remote":
+        """Configure URLs on current remote (cf. command ``git remote set-url``).
+
+        This command manages URLs on the remote.
+
+        :param new_url:
+            String being the URL to add as an extra remote URL.
+
+        :param old_url:
+            When set, replaces this URL with `new_url` for the remote.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :return:
+            self
+        """
+        if not allow_unsafe_protocols:
+            Git.check_unsafe_protocols(new_url)
+        scmd = "set-url"
+        kwargs["insert_kwargs_after"] = scmd
+        if old_url:
+            self.repo.git.remote(scmd, "--", self.name, new_url, old_url, **kwargs)
+        else:
+            self.repo.git.remote(scmd, "--", self.name, new_url, **kwargs)
+        return self
+
+    def add_url(self, url: str, allow_unsafe_protocols: bool = False, **kwargs: Any) -> "Remote":
+        """Adds a new url on current remote (special case of ``git remote set-url``).
+
+        This command adds new URLs to a given remote, making it possible to have
+        multiple URLs for a single remote.
+
+        :param url:
+            String being the URL to add as an extra remote URL.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :return:
+            self
+        """
+        return self.set_url(url, add=True, allow_unsafe_protocols=allow_unsafe_protocols)
+
+    def delete_url(self, url: str, **kwargs: Any) -> "Remote":
+        """Deletes a new url on current remote (special case of ``git remote set-url``).
+
+        This command deletes new URLs to a given remote, making it possible to have
+        multiple URLs for a single remote.
+
+        :param url:
+            String being the URL to delete from the remote.
+
+        :return:
+            self
+        """
+        return self.set_url(url, delete=True)
+
+    @property
+    def urls(self) -> Iterator[str]:
+        """:return: Iterator yielding all configured URL targets on a remote as strings"""
+        try:
+            remote_details = self.repo.git.remote("get-url", "--all", self.name)
+            assert isinstance(remote_details, str)
+            for line in remote_details.split("\n"):
+                yield line
+        except GitCommandError as ex:
+            ## We are on git < 2.7 (i.e TravisCI as of Oct-2016),
+            #  so `get-utl` command does not exist yet!
+            #    see: https://github.com/gitpython-developers/GitPython/pull/528#issuecomment-252976319
+            #    and: http://stackoverflow.com/a/32991784/548792
+            #
+            if "Unknown subcommand: get-url" in str(ex):
+                try:
+                    remote_details = self.repo.git.remote("show", self.name)
+                    assert isinstance(remote_details, str)
+                    for line in remote_details.split("\n"):
+                        if "  Push  URL:" in line:
+                            yield line.split(": ")[-1]
+                except GitCommandError as _ex:
+                    if any(msg in str(_ex) for msg in ["correct access rights", "cannot run ssh"]):
+                        # If ssh is not setup to access this repository, see issue 694.
+                        remote_details = self.repo.git.config("--get-all", "remote.%s.url" % self.name)
+                        assert isinstance(remote_details, str)
+                        for line in remote_details.split("\n"):
+                            yield line
+                    else:
+                        raise _ex
+            else:
+                raise ex
+
     @property
-    def refs(self):
+    def refs(self) -> IterableList[RemoteReference]:
         """
         :return:
-            IterableList of RemoteReference objects. It is prefixed, allowing
-            you to omit the remote path portion, i.e.::
-            remote.refs.master # yields RemoteReference('/refs/remotes/origin/master')"""
-        out_refs = IterableList(RemoteReference._id_attribute_, "%s/" % self.name)
+            :class:`~git.util.IterableList` of :class:`~git.refs.remote.RemoteReference`
+            objects.
+
+            It is prefixed, allowing you to omit the remote path portion, e.g.::
+
+                remote.refs.master  # yields RemoteReference('/refs/remotes/origin/master')
+        """
+        out_refs: IterableList[RemoteReference] = IterableList(RemoteReference._id_attribute_, "%s/" % self.name)
         out_refs.extend(RemoteReference.list_items(self.repo, remote=self.name))
-        assert out_refs, "Remote %s did not have any references" % self.name
         return out_refs
 
     @property
-    def stale_refs(self):
+    def stale_refs(self) -> IterableList[Reference]:
         """
         :return:
-            IterableList RemoteReference objects that do not have a corresponding
-            head in the remote reference anymore as they have been deleted on the
-            remote side, but are still available locally.
-
-            The IterableList is prefixed, hence the 'origin' must be omitted. See
-            'refs' property for an example."""
-        out_refs = IterableList(RemoteReference._id_attribute_, "%s/" % self.name)
+            :class:`~git.util.IterableList` of :class:`~git.refs.remote.RemoteReference`
+            objects that do not have a corresponding head in the remote reference
+            anymore as they have been deleted on the remote side, but are still
+            available locally.
+
+            The :class:`~git.util.IterableList` is prefixed, hence the 'origin' must be
+            omitted. See :attr:`refs` property for an example.
+
+            To make things more complicated, it can be possible for the list to include
+            other kinds of references, for example, tag references, if these are stale
+            as well. This is a fix for the issue described here:
+            https://github.com/gitpython-developers/GitPython/issues/260
+        """
+        out_refs: IterableList[Reference] = IterableList(RemoteReference._id_attribute_, "%s/" % self.name)
         for line in self.repo.git.remote("prune", "--dry-run", self).splitlines()[2:]:
             # expecting
             # * [would prune] origin/new_branch
             token = " * [would prune] "
             if not line.startswith(token):
-                raise ValueError("Could not parse git-remote prune result: %r" % line)
-            fqhn = "%s/%s" % (RemoteReference._common_path_default, line.replace(token, ""))
-            out_refs.append(RemoteReference(self.repo, fqhn))
+                continue
+            ref_name = line.replace(token, "")
+            # Sometimes, paths start with a full ref name, like refs/tags/foo. See #260.
+            if ref_name.startswith(Reference._common_path_default + "/"):
+                out_refs.append(Reference.from_path(self.repo, ref_name))
+            else:
+                fqhn = "%s/%s" % (RemoteReference._common_path_default, ref_name)
+                out_refs.append(RemoteReference(self.repo, fqhn))
+            # END special case handling
         # END for each line
         return out_refs
 
     @classmethod
-    def create(cls, repo, name, url, **kwargs):
-        """Create a new remote to the given repository
-        :param repo: Repository instance that is to receive the new remote
-        :param name: Desired name of the remote
-        :param url: URL which corresponds to the remote's name
-        :param kwargs: Additional arguments to be passed to the git-remote add command
-        :return: New Remote instance
-        :raise GitCommandError: in case an origin with that name already exists"""
-        repo.git.remote("add", name, url, **kwargs)
+    def create(cls, repo: "Repo", name: str, url: str, allow_unsafe_protocols: bool = False, **kwargs: Any) -> "Remote":
+        """Create a new remote to the given repository.
+
+        :param repo:
+            Repository instance that is to receive the new remote.
+
+        :param name:
+            Desired name of the remote.
+
+        :param url:
+            URL which corresponds to the remote's name.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :param kwargs:
+            Additional arguments to be passed to the ``git remote add`` command.
+
+        :return:
+            New :class:`Remote` instance
+
+        :raise git.exc.GitCommandError:
+            In case an origin with that name already exists.
+        """
+        scmd = "add"
+        kwargs["insert_kwargs_after"] = scmd
+        url = Git.polish_url(url)
+        if not allow_unsafe_protocols:
+            Git.check_unsafe_protocols(url)
+        repo.git.remote(scmd, "--", name, url, **kwargs)
         return cls(repo, name)
 
-    # add is an alias
-    add = create
+    # `add` is an alias.
+    @classmethod
+    def add(cls, repo: "Repo", name: str, url: str, **kwargs: Any) -> "Remote":
+        return cls.create(repo, name, url, **kwargs)
 
     @classmethod
-    def remove(cls, repo, name):
-        """Remove the remote with the given name"""
+    def remove(cls, repo: "Repo", name: str) -> str:
+        """Remove the remote with the given name.
+
+        :return:
+            The passed remote name to remove
+        """
         repo.git.remote("rm", name)
+        if isinstance(name, cls):
+            name._clear_cache()
+        return name
 
-    # alias
-    rm = remove
+    @classmethod
+    def rm(cls, repo: "Repo", name: str) -> str:
+        """Alias of remove.
+        Remove the remote with the given name.
 
-    def rename(self, new_name):
-        """Rename self to the given new_name
-        :return: self """
+        :return:
+            The passed remote name to remove
+        """
+        return cls.remove(repo, name)
+
+    def rename(self, new_name: str) -> "Remote":
+        """Rename self to the given `new_name`.
+
+        :return:
+            self
+        """
         if self.name == new_name:
             return self
 
         self.repo.git.remote("rename", self.name, new_name)
         self.name = new_name
-        try:
-            del(self._config_reader)        # it contains cached values, section names are different now
-        except AttributeError:
-            pass
-        # END handle exception
+        self._clear_cache()
+
         return self
 
-    def update(self, **kwargs):
-        """Fetch all changes for this remote, including new branches which will
-        be forced in ( in case your local remote branch is not part the new remote branches
-        ancestry anymore ).
+    def update(self, **kwargs: Any) -> "Remote":
+        """Fetch all changes for this remote, including new branches which will be
+        forced in (in case your local remote branch is not part the new remote branch's
+        ancestry anymore).
 
         :param kwargs:
-            Additional arguments passed to git-remote update
+            Additional arguments passed to ``git remote update``.
 
-        :return: self """
-        self.repo.git.remote("update", self.name)
+        :return:
+            self
+        """
+        scmd = "update"
+        kwargs["insert_kwargs_after"] = scmd
+        self.repo.git.remote(scmd, self.name, **kwargs)
         return self
 
-    def _get_fetch_info_from_stderr(self, proc, progress):
-        # skip first line as it is some remote info we are not interested in
-        # TODO: Use poll() to process stdout and stderr at same time
-        output = IterableList('name')
-
-        # lines which are no progress are fetch info lines
-        # this also waits for the command to finish
-        # Skip some progress lines that don't provide relevant information
-        fetch_info_lines = list()
-        # Basically we want all fetch info lines which appear to be in regular form, and thus have a
-        # command character. Everything else we ignore,
-        cmds = set(PushInfo._flag_map.keys()) & set(FetchInfo._flag_map.keys())
+    def _get_fetch_info_from_stderr(
+        self,
+        proc: "Git.AutoInterrupt",
+        progress: Union[Callable[..., Any], RemoteProgress, None],
+        kill_after_timeout: Union[None, float] = None,
+    ) -> IterableList["FetchInfo"]:
+        progress = to_progress_instance(progress)
+
+        # Skip first line as it is some remote info we are not interested in.
+        output: IterableList["FetchInfo"] = IterableList("name")
+
+        # Lines which are no progress are fetch info lines.
+        # This also waits for the command to finish.
+        # Skip some progress lines that don't provide relevant information.
+        fetch_info_lines = []
+        # Basically we want all fetch info lines which appear to be in regular form, and
+        # thus have a command character. Everything else we ignore.
+        cmds = set(FetchInfo._flag_map.keys())
 
         progress_handler = progress.new_message_handler()
+        handle_process_output(
+            proc,
+            None,
+            progress_handler,
+            finalizer=None,
+            decode_streams=False,
+            kill_after_timeout=kill_after_timeout,
+        )
+
+        stderr_text = progress.error_lines and "\n".join(progress.error_lines) or ""
+        proc.wait(stderr=stderr_text)
+        if stderr_text:
+            _logger.warning("Error lines received while fetching: %s", stderr_text)
+
+        for line in progress.other_lines:
+            line = force_text(line)
+            for cmd in cmds:
+                if len(line) > 1 and line[0] == " " and line[1] == cmd:
+                    fetch_info_lines.append(line)
+                    continue
+
+        # Read head information.
+        fetch_head = SymbolicReference(self.repo, "FETCH_HEAD")
+        with open(fetch_head.abspath, "rb") as fp:
+            fetch_head_info = [line.decode(defenc) for line in fp.readlines()]
+
+        l_fil = len(fetch_info_lines)
+        l_fhi = len(fetch_head_info)
+        if l_fil != l_fhi:
+            msg = "Fetch head lines do not match lines provided via progress information\n"
+            msg += "length of progress lines %i should be equal to lines in FETCH_HEAD file %i\n"
+            msg += "Will ignore extra progress lines or fetch head lines."
+            msg %= (l_fil, l_fhi)
+            _logger.debug(msg)
+            _logger.debug(b"info lines: " + str(fetch_info_lines).encode("UTF-8"))
+            _logger.debug(b"head info: " + str(fetch_head_info).encode("UTF-8"))
+            if l_fil < l_fhi:
+                fetch_head_info = fetch_head_info[:l_fil]
+            else:
+                fetch_info_lines = fetch_info_lines[:l_fhi]
+            # END truncate correct list
+        # END sanity check + sanitization
 
-        for line in proc.stderr:
-            line = line.decode(defenc)
-            line = line.rstrip()
-            for pline in progress_handler(line):
-                if line.startswith('fatal:'):
-                    raise GitCommandError(("Error when fetching: %s" % line,), 2)
-                # END handle special messages
-                for cmd in cmds:
-                    if len(line) > 1 and line[0] == ' ' and line[1] == cmd:
-                        fetch_info_lines.append(line)
-                        continue
-                    # end find command code
-                # end for each comand code we know
-            # end for each line progress didn't handle
-        # end
-
-        # We are only interested in stderr here ...
-        finalize_process(proc)
-
-        # read head information
-        fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
-        fetch_head_info = [l.decode(defenc) for l in fp.readlines()]
-        fp.close()
-
-        # NOTE: We assume to fetch at least enough progress lines to allow matching each fetch head line with it.
-        assert len(fetch_info_lines) >= len(fetch_head_info), "len(%s) <= len(%s)" % (fetch_head_info,
-                                                                                      fetch_info_lines)
-
-        output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
-                      for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info))
+        for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info):
+            try:
+                output.append(FetchInfo._from_line(self.repo, err_line, fetch_line))
+            except ValueError as exc:
+                _logger.debug("Caught error while parsing line: %s", exc)
+                _logger.warning("Git informed while fetching: %s", err_line.strip())
         return output
 
-    def _get_push_info(self, proc, progress):
-        # read progress information from stderr
-        # we hope stdout can hold all the data, it should ...
-        # read the lines manually as it will use carriage returns between the messages
-        # to override the previous one. This is why we read the bytes manually
-        # TODO: poll() on file descriptors to know what to read next, process streams concurrently
+    def _get_push_info(
+        self,
+        proc: "Git.AutoInterrupt",
+        progress: Union[Callable[..., Any], RemoteProgress, None],
+        kill_after_timeout: Union[None, float] = None,
+    ) -> PushInfoList:
+        progress = to_progress_instance(progress)
+
+        # Read progress information from stderr.
+        # We hope stdout can hold all the data, it should...
+        # Read the lines manually as it will use carriage returns between the messages
+        # to override the previous one. This is why we read the bytes manually.
         progress_handler = progress.new_message_handler()
-        output = IterableList('name')
+        output: PushInfoList = PushInfoList()
 
-        def stdout_handler(line):
+        def stdout_handler(line: str) -> None:
             try:
                 output.append(PushInfo._from_line(self, line))
             except ValueError:
-                # if an error happens, additional info is given which we cannot parse
+                # If an error happens, additional info is given which we parse below.
                 pass
-            # END exception handling
-        # END for each line
 
-        handle_process_output(proc, stdout_handler, progress_handler, finalize_process)
+        handle_process_output(
+            proc,
+            stdout_handler,
+            progress_handler,
+            finalizer=None,
+            decode_streams=False,
+            kill_after_timeout=kill_after_timeout,
+        )
+        stderr_text = progress.error_lines and "\n".join(progress.error_lines) or ""
+        try:
+            proc.wait(stderr=stderr_text)
+        except Exception as e:
+            # This is different than fetch (which fails if there is any stderr
+            # even if there is an output).
+            if not output:
+                raise
+            elif stderr_text:
+                _logger.warning("Error lines received while fetching: %s", stderr_text)
+                output.error = e
+
         return output
 
-    def fetch(self, refspec=None, progress=None, **kwargs):
-        """Fetch the latest changes for this remote
+    def _assert_refspec(self) -> None:
+        """Turns out we can't deal with remotes if the refspec is missing."""
+        config = self.config_reader
+        unset = "placeholder"
+        try:
+            if config.get_value("fetch", default=unset) is unset:
+                msg = "Remote '%s' has no refspec set.\n"
+                msg += "You can set it as follows:"
+                msg += " 'git config --add \"remote.%s.fetch +refs/heads/*:refs/heads/*\"'."
+                raise AssertionError(msg % (self.name, self.name))
+        finally:
+            config.release()
+
+    def fetch(
+        self,
+        refspec: Union[str, List[str], None] = None,
+        progress: Union[RemoteProgress, None, "UpdateProgress"] = None,
+        verbose: bool = True,
+        kill_after_timeout: Union[None, float] = None,
+        allow_unsafe_protocols: bool = False,
+        allow_unsafe_options: bool = False,
+        **kwargs: Any,
+    ) -> IterableList[FetchInfo]:
+        """Fetch the latest changes for this remote.
 
         :param refspec:
             A "refspec" is used by fetch and push to describe the mapping
             between remote ref and local ref. They are combined with a colon in
-            the format <src>:<dst>, preceded by an optional plus sign, +.
-            For example: git fetch $URL refs/heads/master:refs/heads/origin means
+            the format ``<src>:<dst>``, preceded by an optional plus sign, ``+``.
+            For example: ``git fetch $URL refs/heads/master:refs/heads/origin`` means
             "grab the master branch head from the $URL and store it as my origin
-            branch head". And git push $URL refs/heads/master:refs/heads/to-upstream
+            branch head". And ``git push $URL refs/heads/master:refs/heads/to-upstream``
             means "publish my master branch head as to-upstream branch at $URL".
-            See also git-push(1).
+            See also :manpage:`git-push(1)`.
+
+            Taken from the git manual, :manpage:`gitglossary(7)`.
+
+            Fetch supports multiple refspecs (as the underlying :manpage:`git-fetch(1)`
+            does) - supplying a list rather than a string for 'refspec' will make use of
+            this facility.
+
+        :param progress:
+            See the :meth:`push` method.
 
-            Taken from the git manual
+        :param verbose:
+            Boolean for verbose output.
+
+        :param kill_after_timeout:
+            To specify a timeout in seconds for the git command, after which the process
+            should be killed. It is set to ``None`` by default.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :param allow_unsafe_options:
+            Allow unsafe options to be used, like ``--upload-pack``.
+
+        :param kwargs:
+            Additional arguments to be passed to :manpage:`git-fetch(1)`.
 
-            Fetch supports multiple refspecs (as the
-            underlying git-fetch does) - supplying a list rather than a string
-            for 'refspec' will make use of this facility.
-        :param progress: See 'push' method
-        :param kwargs: Additional arguments to be passed to git-fetch
         :return:
-            IterableList(FetchInfo, ...) list of FetchInfo instances providing detailed
-            information about the fetch results
+            IterableList(FetchInfo, ...) list of :class:`FetchInfo` instances providing
+            detailed information about the fetch results
 
         :note:
             As fetch does not provide progress information to non-ttys, we cannot make
-            it available here unfortunately as in the 'push' method."""
+            it available here unfortunately as in the :meth:`push` method.
+        """
+        if refspec is None:
+            # No argument refspec, then ensure the repo's config has a fetch refspec.
+            self._assert_refspec()
+
         kwargs = add_progress(kwargs, self.repo.git, progress)
         if isinstance(refspec, list):
-            args = refspec
+            args: Sequence[Optional[str]] = refspec
         else:
             args = [refspec]
 
-        proc = self.repo.git.fetch(self, *args, with_extended_output=True, as_process=True, v=True, **kwargs)
-        proc.stdout.close()
-        res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
-        if hasattr(self.repo.odb, 'update_cache'):
+        if not allow_unsafe_protocols:
+            for ref in args:
+                if ref:
+                    Git.check_unsafe_protocols(ref)
+
+        if not allow_unsafe_options:
+            Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=self.unsafe_git_fetch_options)
+
+        proc = self.repo.git.fetch(
+            "--", self, *args, as_process=True, with_stdout=False, universal_newlines=True, v=verbose, **kwargs
+        )
+        res = self._get_fetch_info_from_stderr(proc, progress, kill_after_timeout=kill_after_timeout)
+        if hasattr(self.repo.odb, "update_cache"):
             self.repo.odb.update_cache()
         return res
 
-    def pull(self, refspec=None, progress=None, **kwargs):
-        """Pull changes from the given branch, being the same as a fetch followed
-        by a merge of branch with your local branch.
+    def pull(
+        self,
+        refspec: Union[str, List[str], None] = None,
+        progress: Union[RemoteProgress, "UpdateProgress", None] = None,
+        kill_after_timeout: Union[None, float] = None,
+        allow_unsafe_protocols: bool = False,
+        allow_unsafe_options: bool = False,
+        **kwargs: Any,
+    ) -> IterableList[FetchInfo]:
+        """Pull changes from the given branch, being the same as a fetch followed by a
+        merge of branch with your local branch.
+
+        :param refspec:
+            See :meth:`fetch` method.
+
+        :param progress:
+            See :meth:`push` method.
+
+        :param kill_after_timeout:
+            See :meth:`fetch` method.
 
-        :param refspec: see 'fetch' method
-        :param progress: see 'push' method
-        :param kwargs: Additional arguments to be passed to git-pull
-        :return: Please see 'fetch' method """
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :param allow_unsafe_options:
+            Allow unsafe options to be used, like ``--upload-pack``.
+
+        :param kwargs:
+            Additional arguments to be passed to :manpage:`git-pull(1)`.
+
+        :return:
+            Please see :meth:`fetch` method.
+        """
+        if refspec is None:
+            # No argument refspec, then ensure the repo's config has a fetch refspec.
+            self._assert_refspec()
         kwargs = add_progress(kwargs, self.repo.git, progress)
-        proc = self.repo.git.pull(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
-        proc.stdout.close()
-        res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
-        if hasattr(self.repo.odb, 'update_cache'):
+
+        refspec = Git._unpack_args(refspec or [])
+        if not allow_unsafe_protocols:
+            for ref in refspec:
+                Git.check_unsafe_protocols(ref)
+
+        if not allow_unsafe_options:
+            Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=self.unsafe_git_pull_options)
+
+        proc = self.repo.git.pull(
+            "--", self, refspec, with_stdout=False, as_process=True, universal_newlines=True, v=True, **kwargs
+        )
+        res = self._get_fetch_info_from_stderr(proc, progress, kill_after_timeout=kill_after_timeout)
+        if hasattr(self.repo.odb, "update_cache"):
             self.repo.odb.update_cache()
         return res
 
-    def push(self, refspec=None, progress=None, **kwargs):
+    def push(
+        self,
+        refspec: Union[str, List[str], None] = None,
+        progress: Union[RemoteProgress, "UpdateProgress", Callable[..., RemoteProgress], None] = None,
+        kill_after_timeout: Union[None, float] = None,
+        allow_unsafe_protocols: bool = False,
+        allow_unsafe_options: bool = False,
+        **kwargs: Any,
+    ) -> PushInfoList:
         """Push changes from source branch in refspec to target branch in refspec.
 
-        :param refspec: see 'fetch' method
+        :param refspec:
+            See :meth:`fetch` method.
+
         :param progress:
-            Instance of type RemoteProgress allowing the caller to receive
-            progress information until the method returns.
-            If None, progress information will be discarded
+            Can take one of many value types:
+
+            * ``None``, to discard progress information.
+            * A function (callable) that is called with the progress information.
+              Signature: ``progress(op_code, cur_count, max_count=None, message='')``.
+              See :meth:`RemoteProgress.update <git.util.RemoteProgress.update>` for a
+              description of all arguments given to the function.
+            * An instance of a class derived from :class:`~git.util.RemoteProgress` that
+              overrides the
+              :meth:`RemoteProgress.update <git.util.RemoteProgress.update>` method.
+
+        :note:
+            No further progress information is returned after push returns.
+
+        :param kill_after_timeout:
+            To specify a timeout in seconds for the git command, after which the process
+            should be killed. It is set to ``None`` by default.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :param allow_unsafe_options:
+            Allow unsafe options to be used, like ``--receive-pack``.
+
+        :param kwargs:
+            Additional arguments to be passed to :manpage:`git-push(1)`.
 
-        :param kwargs: Additional arguments to be passed to git-push
         :return:
-            IterableList(PushInfo, ...) iterable list of PushInfo instances, each
-            one informing about an individual head which had been updated on the remote
-            side.
-            If the push contains rejected heads, these will have the PushInfo.ERROR bit set
-            in their flags.
-            If the operation fails completely, the length of the returned IterableList will
-            be null."""
+            A :class:`PushInfoList` object, where each list member represents an
+            individual head which had been updated on the remote side.
+
+            If the push contains rejected heads, these will have the
+            :const:`PushInfo.ERROR` bit set in their flags.
+
+            If the operation fails completely, the length of the returned
+            :class:`PushInfoList` will be 0.
+
+            Call :meth:`~PushInfoList.raise_if_error` on the returned object to raise on
+            any failure.
+        """
         kwargs = add_progress(kwargs, self.repo.git, progress)
-        proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, **kwargs)
-        return self._get_push_info(proc, progress or RemoteProgress())
+
+        refspec = Git._unpack_args(refspec or [])
+        if not allow_unsafe_protocols:
+            for ref in refspec:
+                Git.check_unsafe_protocols(ref)
+
+        if not allow_unsafe_options:
+            Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=self.unsafe_git_push_options)
+
+        proc = self.repo.git.push(
+            "--",
+            self,
+            refspec,
+            porcelain=True,
+            as_process=True,
+            universal_newlines=True,
+            kill_after_timeout=kill_after_timeout,
+            **kwargs,
+        )
+        return self._get_push_info(proc, progress, kill_after_timeout=kill_after_timeout)
 
     @property
-    def config_reader(self):
+    def config_reader(self) -> SectionConstraint[GitConfigParser]:
         """
         :return:
-            GitConfigParser compatible object able to read options for only our remote.
-            Hence you may simple type config.get("pushurl") to obtain the information"""
+            :class:`~git.config.GitConfigParser` compatible object able to read options
+            for only our remote. Hence you may simply type ``config.get("pushurl")`` to
+            obtain the information.
+        """
         return self._config_reader
 
+    def _clear_cache(self) -> None:
+        try:
+            del self._config_reader
+        except AttributeError:
+            pass
+        # END handle exception
+
     @property
-    def config_writer(self):
+    def config_writer(self) -> SectionConstraint:
         """
-        :return: GitConfigParser compatible object able to write options for this remote.
+        :return:
+            :class:`~git.config.GitConfigParser`-compatible object able to write options
+            for this remote.
+
         :note:
             You can only own one writer at a time - delete it to release the
-            configuration file and make it useable by others.
+            configuration file and make it usable by others.
 
             To assure consistent results, you should only query options through the
             writer. Once you are done writing, you are free to use the config reader
-            once again."""
+            once again.
+        """
         writer = self.repo.config_writer()
 
-        # clear our cache to assure we re-read the possibly changed configuration
-        try:
-            del(self._config_reader)
-        except AttributeError:
-            pass
-        # END handle exception
+        # Clear our cache to ensure we re-read the possibly changed configuration.
+        self._clear_cache()
         return SectionConstraint(writer, self._config_section_name())
diff --git a/git/repo/__init__.py b/git/repo/__init__.py
index 5619aa692..66319ef95 100644
--- a/git/repo/__init__.py
+++ b/git/repo/__init__.py
@@ -1,4 +1,8 @@
-"""Initialize the Repo package"""
-# flake8: noqa
-from __future__ import absolute_import
-from .base import *
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Initialize the repo package."""
+
+__all__ = ["Repo"]
+
+from .base import Repo
diff --git a/git/repo/base.py b/git/repo/base.py
index 6d9af6d47..7e918df8c 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -1,653 +1,1212 @@
-# repo.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
+from __future__ import annotations
+
+__all__ = ["Repo"]
+
+import gc
+import logging
+import os
+import os.path as osp
+from pathlib import Path
+import re
+import shlex
+import sys
+import warnings
+
+import gitdb
+from gitdb.db.loose import LooseObjectDB
+from gitdb.exc import BadObject
+
+from git.cmd import Git, handle_process_output
+from git.compat import defenc, safe_decode
+from git.config import GitConfigParser
+from git.db import GitCmdObjectDB
 from git.exc import (
+    GitCommandError,
     InvalidGitRepositoryError,
     NoSuchPathError,
-    GitCommandError
-)
-from git.cmd import (
-    Git,
-    handle_process_output
-)
-from git.refs import (
-    HEAD,
-    Head,
-    Reference,
-    TagReference,
-)
-from git.objects import (
-    Submodule,
-    RootModule,
-    Commit
 )
+from git.index import IndexFile
+from git.objects import Submodule, RootModule, Commit
+from git.refs import HEAD, Head, Reference, TagReference
+from git.remote import Remote, add_progress, to_progress_instance
 from git.util import (
     Actor,
-    finalize_process
-)
-from git.index import IndexFile
-from git.config import GitConfigParser
-from git.remote import (
-    Remote,
-    add_progress
-)
-
-from git.db import (
-    GitCmdObjectDB,
-    GitDB
-)
-
-from gitdb.util import (
-    join,
-    isfile,
-    hex_to_bin
+    cygpath,
+    expand_path,
+    finalize_process,
+    hex_to_bin,
+    remove_password_if_present,
 )
 
 from .fun import (
-    rev_parse,
+    find_submodule_git_dir,
+    find_worktree_git_dir,
     is_git_dir,
-    find_git_dir,
+    rev_parse,
     touch,
 )
-from git.compat import (
-    text_type,
-    defenc
-)
 
-import os
-import sys
-import re
+# typing ------------------------------------------------------
+
+from git.types import (
+    CallableProgress,
+    Commit_ish,
+    Lit_config_levels,
+    PathLike,
+    TBD,
+    Tree_ish,
+    assert_never,
+)
+from typing import (
+    Any,
+    BinaryIO,
+    Callable,
+    Dict,
+    Iterator,
+    List,
+    Mapping,
+    NamedTuple,
+    Optional,
+    Sequence,
+    TYPE_CHECKING,
+    TextIO,
+    Tuple,
+    Type,
+    Union,
+    cast,
+)
 
-DefaultDBType = GitDB
-if sys.version_info[:2] < (2, 5):     # python 2.4 compatiblity
-    DefaultDBType = GitCmdObjectDB
-# END handle python 2.4
+from git.types import ConfigLevels_Tup, TypedDict
 
+if TYPE_CHECKING:
+    from git.objects import Tree
+    from git.objects.submodule.base import UpdateProgress
+    from git.refs.symbolic import SymbolicReference
+    from git.remote import RemoteProgress
+    from git.util import IterableList
 
-__all__ = ('Repo', )
+# -----------------------------------------------------------
 
+_logger = logging.getLogger(__name__)
 
-def _expand_path(p):
-    return os.path.abspath(os.path.expandvars(os.path.expanduser(p)))
 
+class BlameEntry(NamedTuple):
+    commit: Dict[str, Commit]
+    linenos: range
+    orig_path: Optional[str]
+    orig_linenos: range
 
-class Repo(object):
 
-    """Represents a git repository and allows you to query references,
-    gather commit information, generate diffs, create and clone repositories query
-    the log.
+class Repo:
+    """Represents a git repository and allows you to query references, create commit
+    information, generate diffs, create and clone repositories, and query the log.
 
     The following attributes are worth using:
 
-    'working_dir' is the working directory of the git command, which is the working tree
-    directory if available or the .git directory in case of bare repositories
-
-    'working_tree_dir' is the working tree directory, but will raise AssertionError
-    if we are a bare repository.
-
-    'git_dir' is the .git repository directory, which is always set."""
-    DAEMON_EXPORT_FILE = 'git-daemon-export-ok'
-    __slots__ = ("working_dir", "_working_tree_dir", "git_dir", "_bare", "git", "odb")
-
-    # precompiled regex
-    re_whitespace = re.compile(r'\s+')
-    re_hexsha_only = re.compile('^[0-9A-Fa-f]{40}$')
-    re_hexsha_shortened = re.compile('^[0-9A-Fa-f]{4,40}$')
-    re_author_committer_start = re.compile(r'^(author|committer)')
-    re_tab_full_line = re.compile(r'^\t(.*)$')
-
-    # invariants
-    # represents the configuration level of a configuration file
-    config_level = ("system", "user", "global", "repository")
-
-    def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=False):
-        """Create a new Repo instance
-
-        :param path: is the path to either the root git directory or the bare git repo::
-
-            repo = Repo("/Users/mtrier/Development/git-python")
-            repo = Repo("/Users/mtrier/Development/git-python.git")
-            repo = Repo("~/Development/git-python.git")
-            repo = Repo("$REPOSITORIES/Development/git-python.git")
-
-        :param odbt: Object DataBase type - a type which is constructed by providing
-            the directory containing the database objects, i.e. .git/objects. It will
-            be used to access all object data
-        :raise InvalidGitRepositoryError:
-        :raise NoSuchPathError:
-        :return: git.Repo """
-        epath = _expand_path(path or os.getcwd())
-        self.git = None  # should be set for __del__ not to fail in case we raise
-        if not os.path.exists(epath):
-            raise NoSuchPathError(epath)
-
-        self.working_dir = None
-        self._working_tree_dir = None
-        self.git_dir = None
-        curpath = epath
+    * :attr:`working_dir` is the working directory of the git command, which is the
+      working tree directory if available or the ``.git`` directory in case of bare
+      repositories.
+
+    * :attr:`working_tree_dir` is the working tree directory, but will return ``None``
+      if we are a bare repository.
+
+    * :attr:`git_dir` is the ``.git`` repository directory, which is always set.
+    """
+
+    DAEMON_EXPORT_FILE = "git-daemon-export-ok"
+
+    # Must exist, or  __del__  will fail in case we raise on `__init__()`.
+    git = cast("Git", None)
+
+    working_dir: PathLike
+    """The working directory of the git command."""
+
+    _working_tree_dir: Optional[PathLike] = None
+
+    git_dir: PathLike
+    """The ``.git`` repository directory."""
+
+    _common_dir: PathLike = ""
 
-        # walk up the path to find the .git dir
+    # Precompiled regex
+    re_whitespace = re.compile(r"\s+")
+    re_hexsha_only = re.compile(r"^[0-9A-Fa-f]{40}$")
+    re_hexsha_shortened = re.compile(r"^[0-9A-Fa-f]{4,40}$")
+    re_envvars = re.compile(r"(\$(\{\s?)?[a-zA-Z_]\w*(\}\s?)?|%\s?[a-zA-Z_]\w*\s?%)")
+    re_author_committer_start = re.compile(r"^(author|committer)")
+    re_tab_full_line = re.compile(r"^\t(.*)$")
+
+    unsafe_git_clone_options = [
+        # Executes arbitrary commands:
+        "--upload-pack",
+        "-u",
+        # Can override configuration variables that execute arbitrary commands:
+        "--config",
+        "-c",
+    ]
+    """Options to :manpage:`git-clone(1)` that allow arbitrary commands to be executed.
+
+    The ``--upload-pack``/``-u`` option allows users to execute arbitrary commands
+    directly:
+    https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---upload-packltupload-packgt
+
+    The ``--config``/``-c`` option allows users to override configuration variables like
+    ``protocol.allow`` and ``core.gitProxy`` to execute arbitrary commands:
+    https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---configltkeygtltvaluegt
+    """
+
+    # Invariants
+    config_level: ConfigLevels_Tup = ("system", "user", "global", "repository")
+    """Represents the configuration level of a configuration file."""
+
+    # Subclass configuration
+    GitCommandWrapperType = Git
+    """Subclasses may easily bring in their own custom types by placing a constructor or
+    type here."""
+
+    def __init__(
+        self,
+        path: Optional[PathLike] = None,
+        odbt: Type[LooseObjectDB] = GitCmdObjectDB,
+        search_parent_directories: bool = False,
+        expand_vars: bool = True,
+    ) -> None:
+        R"""Create a new :class:`Repo` instance.
+
+        :param path:
+            The path to either the worktree directory or the .git directory itself::
+
+                repo = Repo("/Users/mtrier/Development/git-python")
+                repo = Repo("/Users/mtrier/Development/git-python.git")
+                repo = Repo("~/Development/git-python.git")
+                repo = Repo("$REPOSITORIES/Development/git-python.git")
+                repo = Repo(R"C:\Users\mtrier\Development\git-python\.git")
+
+            - In *Cygwin*, `path` may be a ``cygdrive/...`` prefixed path.
+            - If `path` is ``None`` or an empty string, :envvar:`GIT_DIR` is used. If
+              that environment variable is absent or empty, the current directory is
+              used.
+
+        :param odbt:
+            Object DataBase type - a type which is constructed by providing the
+            directory containing the database objects, i.e. ``.git/objects``. It will be
+            used to access all object data.
+
+        :param search_parent_directories:
+            If ``True``, all parent directories will be searched for a valid repo as
+            well.
+
+            Please note that this was the default behaviour in older versions of
+            GitPython, which is considered a bug though.
+
+        :raise git.exc.InvalidGitRepositoryError:
+
+        :raise git.exc.NoSuchPathError:
+
+        :return:
+            :class:`Repo`
+        """
+
+        epath = path or os.getenv("GIT_DIR")
+        if not epath:
+            epath = os.getcwd()
+        if Git.is_cygwin():
+            # Given how the tests are written, this seems more likely to catch Cygwin
+            # git used from Windows than Windows git used from Cygwin. Therefore
+            # changing to Cygwin-style paths is the relevant operation.
+            epath = cygpath(str(epath))
+
+        epath = epath or path or os.getcwd()
+        if not isinstance(epath, str):
+            epath = str(epath)
+        if expand_vars and re.search(self.re_envvars, epath):
+            warnings.warn(
+                "The use of environment variables in paths is deprecated"
+                + "\nfor security reasons and may be removed in the future!!",
+                stacklevel=1,
+            )
+        epath = expand_path(epath, expand_vars)
+        if epath is not None:
+            if not os.path.exists(epath):
+                raise NoSuchPathError(epath)
+
+        # Walk up the path to find the `.git` dir.
+        curpath = epath
+        git_dir = None
         while curpath:
+            # ABOUT osp.NORMPATH
+            # It's important to normalize the paths, as submodules will otherwise
+            # initialize their repo instances with paths that depend on path-portions
+            # that will not exist after being removed. It's just cleaner.
             if is_git_dir(curpath):
-                self.git_dir = curpath
-                self._working_tree_dir = os.path.dirname(self.git_dir)
+                git_dir = curpath
+                # from man git-config : core.worktree
+                # Set the path to the root of the working tree. If GIT_COMMON_DIR
+                # environment variable is set, core.worktree is ignored and not used for
+                # determining the root of working tree. This can be overridden by the
+                # GIT_WORK_TREE environment variable. The value can be an absolute path
+                # or relative to the path to the .git directory, which is either
+                # specified by GIT_DIR, or automatically discovered. If GIT_DIR is
+                # specified but none of GIT_WORK_TREE and core.worktree is specified,
+                # the current working directory is regarded as the top level of your
+                # working tree.
+                self._working_tree_dir = os.path.dirname(git_dir)
+                if os.environ.get("GIT_COMMON_DIR") is None:
+                    gitconf = self._config_reader("repository", git_dir)
+                    if gitconf.has_option("core", "worktree"):
+                        self._working_tree_dir = gitconf.get("core", "worktree")
+                if "GIT_WORK_TREE" in os.environ:
+                    self._working_tree_dir = os.getenv("GIT_WORK_TREE")
                 break
 
-            gitpath = find_git_dir(join(curpath, '.git'))
-            if gitpath is not None:
-                self.git_dir = gitpath
+            dotgit = osp.join(curpath, ".git")
+            sm_gitpath = find_submodule_git_dir(dotgit)
+            if sm_gitpath is not None:
+                git_dir = osp.normpath(sm_gitpath)
+
+            sm_gitpath = find_submodule_git_dir(dotgit)
+            if sm_gitpath is None:
+                sm_gitpath = find_worktree_git_dir(dotgit)
+
+            if sm_gitpath is not None:
+                git_dir = expand_path(sm_gitpath, expand_vars)
                 self._working_tree_dir = curpath
                 break
 
             if not search_parent_directories:
                 break
-            curpath, dummy = os.path.split(curpath)
-            if not dummy:
+            curpath, tail = osp.split(curpath)
+            if not tail:
                 break
         # END while curpath
 
-        if self.git_dir is None:
+        if git_dir is None:
             raise InvalidGitRepositoryError(epath)
+        self.git_dir = git_dir
 
         self._bare = False
         try:
-            self._bare = self.config_reader("repository").getboolean('core', 'bare')
+            self._bare = self.config_reader("repository").getboolean("core", "bare")
         except Exception:
-            # lets not assume the option exists, although it should
+            # Let's not assume the option exists, although it should.
             pass
 
-        # adjust the wd in case we are actually bare - we didn't know that
-        # in the first place
+        try:
+            common_dir = (Path(self.git_dir) / "commondir").read_text().splitlines()[0].strip()
+            self._common_dir = osp.join(self.git_dir, common_dir)
+        except OSError:
+            self._common_dir = ""
+
+        # Adjust the working directory in case we are actually bare - we didn't know
+        # that in the first place.
         if self._bare:
             self._working_tree_dir = None
         # END working dir handling
 
-        self.working_dir = self._working_tree_dir or self.git_dir
-        self.git = Git(self.working_dir)
+        self.working_dir: PathLike = self._working_tree_dir or self.common_dir
+        self.git = self.GitCommandWrapperType(self.working_dir)
 
-        # special handling, in special times
-        args = [join(self.git_dir, 'objects')]
+        # Special handling, in special times.
+        rootpath = osp.join(self.common_dir, "objects")
         if issubclass(odbt, GitCmdObjectDB):
-            args.append(self.git)
-        self.odb = odbt(*args)
+            self.odb = odbt(rootpath, self.git)
+        else:
+            self.odb = odbt(rootpath)
+
+    def __enter__(self) -> "Repo":
+        return self
 
-    def __del__(self):
+    def __exit__(self, *args: Any) -> None:
+        self.close()
+
+    def __del__(self) -> None:
+        try:
+            self.close()
+        except Exception:
+            pass
+
+    def close(self) -> None:
         if self.git:
             self.git.clear_cache()
-
-    def __eq__(self, rhs):
+            # Tempfiles objects on Windows are holding references to open files until
+            # they are collected by the garbage collector, thus preventing deletion.
+            # TODO: Find these references and ensure they are closed and deleted
+            # synchronously rather than forcing a gc collection.
+            if sys.platform == "win32":
+                gc.collect()
+            gitdb.util.mman.collect()
+            if sys.platform == "win32":
+                gc.collect()
+
+    def __eq__(self, rhs: object) -> bool:
         if isinstance(rhs, Repo):
             return self.git_dir == rhs.git_dir
         return False
 
-    def __ne__(self, rhs):
+    def __ne__(self, rhs: object) -> bool:
         return not self.__eq__(rhs)
 
-    def __hash__(self):
+    def __hash__(self) -> int:
         return hash(self.git_dir)
 
-    # Description property
-    def _get_description(self):
-        filename = join(self.git_dir, 'description')
-        return open(filename, 'rb').read().rstrip().decode(defenc)
-
-    def _set_description(self, descr):
-        filename = join(self.git_dir, 'description')
-        open(filename, 'wb').write((descr + '\n').encode(defenc))
-
-    description = property(_get_description, _set_description,
-                           doc="the project's description")
-    del _get_description
-    del _set_description
+    @property
+    def description(self) -> str:
+        """The project's description"""
+        filename = osp.join(self.git_dir, "description")
+        with open(filename, "rb") as fp:
+            return fp.read().rstrip().decode(defenc)
+
+    @description.setter
+    def description(self, descr: str) -> None:
+        filename = osp.join(self.git_dir, "description")
+        with open(filename, "wb") as fp:
+            fp.write((descr + "\n").encode(defenc))
 
     @property
-    def working_tree_dir(self):
-        """:return: The working tree directory of our git repository
-        :raise AssertionError: If we are a bare repository"""
-        if self._working_tree_dir is None:
-            raise AssertionError("Repository at %r is bare and does not have a working tree directory" % self.git_dir)
+    def working_tree_dir(self) -> Optional[PathLike]:
+        """
+        :return:
+            The working tree directory of our git repository.
+            If this is a bare repository, ``None`` is returned.
+        """
         return self._working_tree_dir
 
     @property
-    def bare(self):
-        """:return: True if the repository is bare"""
+    def common_dir(self) -> PathLike:
+        """
+        :return:
+            The git dir that holds everything except possibly HEAD, FETCH_HEAD,
+            ORIG_HEAD, COMMIT_EDITMSG, index, and logs/.
+        """
+        return self._common_dir or self.git_dir
+
+    @property
+    def bare(self) -> bool:
+        """:return: ``True`` if the repository is bare"""
         return self._bare
 
     @property
-    def heads(self):
-        """A list of ``Head`` objects representing the branch heads in
-        this repo
+    def heads(self) -> "IterableList[Head]":
+        """A list of :class:`~git.refs.head.Head` objects representing the branch heads
+        in this repo.
 
-        :return: ``git.IterableList(Head, ...)``"""
+        :return:
+            ``git.IterableList(Head, ...)``
+        """
         return Head.list_items(self)
 
     @property
-    def references(self):
-        """A list of Reference objects representing tags, heads and remote references.
+    def branches(self) -> "IterableList[Head]":
+        """Alias for heads.
+        A list of :class:`~git.refs.head.Head` objects representing the branch heads
+        in this repo.
 
-        :return: IterableList(Reference, ...)"""
+        :return:
+            ``git.IterableList(Head, ...)``
+        """
+        return self.heads
+
+    @property
+    def references(self) -> "IterableList[Reference]":
+        """A list of :class:`~git.refs.reference.Reference` objects representing tags,
+        heads and remote references.
+
+        :return:
+            ``git.IterableList(Reference, ...)``
+        """
         return Reference.list_items(self)
 
-    # alias for references
-    refs = references
+    @property
+    def refs(self) -> "IterableList[Reference]":
+        """Alias for references.
+        A list of :class:`~git.refs.reference.Reference` objects representing tags,
+        heads and remote references.
 
-    # alias for heads
-    branches = heads
+        :return:
+            ``git.IterableList(Reference, ...)``
+        """
+        return self.references
 
     @property
-    def index(self):
-        """:return: IndexFile representing this repository's index."""
+    def index(self) -> "IndexFile":
+        """
+        :return:
+            A :class:`~git.index.base.IndexFile` representing this repository's index.
+
+        :note:
+            This property can be expensive, as the returned
+            :class:`~git.index.base.IndexFile` will be reinitialized.
+            It is recommended to reuse the object.
+        """
         return IndexFile(self)
 
     @property
-    def head(self):
-        """:return: HEAD Object pointing to the current head reference"""
-        return HEAD(self, 'HEAD')
+    def head(self) -> "HEAD":
+        """
+        :return:
+            :class:`~git.refs.head.HEAD` object pointing to the current head reference
+        """
+        return HEAD(self, "HEAD")
 
     @property
-    def remotes(self):
-        """A list of Remote objects allowing to access and manipulate remotes
-        :return: ``git.IterableList(Remote, ...)``"""
+    def remotes(self) -> "IterableList[Remote]":
+        """A list of :class:`~git.remote.Remote` objects allowing to access and
+        manipulate remotes.
+
+        :return:
+            ``git.IterableList(Remote, ...)``
+        """
         return Remote.list_items(self)
 
-    def remote(self, name='origin'):
-        """:return: Remote with the specified name
-        :raise ValueError:  if no remote with such a name exists"""
+    def remote(self, name: str = "origin") -> "Remote":
+        """:return: The remote with the specified name
+
+        :raise ValueError:
+            If no remote with such a name exists.
+        """
         r = Remote(self, name)
         if not r.exists():
             raise ValueError("Remote named '%s' didn't exist" % name)
         return r
 
-    #{ Submodules
+    # { Submodules
 
     @property
-    def submodules(self):
+    def submodules(self) -> "IterableList[Submodule]":
+        """
+        :return:
+            git.IterableList(Submodule, ...) of direct submodules available from the
+            current head
         """
-        :return: git.IterableList(Submodule, ...) of direct submodules
-            available from the current head"""
         return Submodule.list_items(self)
 
-    def submodule(self, name):
-        """ :return: Submodule with the given name
-        :raise ValueError: If no such submodule exists"""
+    def submodule(self, name: str) -> "Submodule":
+        """:return: The submodule with the given name
+
+        :raise ValueError:
+            If no such submodule exists.
+        """
         try:
             return self.submodules[name]
-        except IndexError:
-            raise ValueError("Didn't find submodule named %r" % name)
+        except IndexError as e:
+            raise ValueError("Didn't find submodule named %r" % name) from e
         # END exception handling
 
-    def create_submodule(self, *args, **kwargs):
-        """Create a new submodule
+    def create_submodule(self, *args: Any, **kwargs: Any) -> Submodule:
+        """Create a new submodule.
 
-        :note: See the documentation of Submodule.add for a description of the
-            applicable parameters
-        :return: created submodules"""
+        :note:
+            For a description of the applicable parameters, see the documentation of
+            :meth:`Submodule.add <git.objects.submodule.base.Submodule.add>`.
+
+        :return:
+            The created submodule.
+        """
         return Submodule.add(self, *args, **kwargs)
 
-    def iter_submodules(self, *args, **kwargs):
-        """An iterator yielding Submodule instances, see Traversable interface
-        for a description of args and kwargs
-        :return: Iterator"""
+    def iter_submodules(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]:
+        """An iterator yielding Submodule instances.
+
+        See the :class:`~git.objects.util.Traversable` interface for a description of `args`
+        and `kwargs`.
+
+        :return:
+            Iterator
+        """
         return RootModule(self).traverse(*args, **kwargs)
 
-    def submodule_update(self, *args, **kwargs):
+    def submodule_update(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]:
         """Update the submodules, keeping the repository consistent as it will
-        take the previous state into consideration. For more information, please
-        see the documentation of RootModule.update"""
+        take the previous state into consideration.
+
+        :note:
+            For more information, please see the documentation of
+            :meth:`RootModule.update <git.objects.submodule.root.RootModule.update>`.
+        """
         return RootModule(self).update(*args, **kwargs)
 
-    #}END submodules
+    # }END submodules
 
     @property
-    def tags(self):
-        """A list of ``Tag`` objects that are available in this repo
-        :return: ``git.IterableList(TagReference, ...)`` """
+    def tags(self) -> "IterableList[TagReference]":
+        """A list of :class:`~git.refs.tag.TagReference` objects that are available in
+        this repo.
+
+        :return:
+            ``git.IterableList(TagReference, ...)``
+        """
         return TagReference.list_items(self)
 
-    def tag(self, path):
-        """:return: TagReference Object, reference pointing to a Commit or Tag
-        :param path: path to the tag reference, i.e. 0.1.5 or tags/0.1.5 """
-        return TagReference(self, path)
+    def tag(self, path: PathLike) -> TagReference:
+        """
+        :return:
+            :class:`~git.refs.tag.TagReference` object, reference pointing to a
+            :class:`~git.objects.commit.Commit` or tag
 
-    def create_head(self, path, commit='HEAD', force=False, logmsg=None):
+        :param path:
+            Path to the tag reference, e.g. ``0.1.5`` or ``tags/0.1.5``.
+        """
+        full_path = self._to_full_tag_path(path)
+        return TagReference(self, full_path)
+
+    @staticmethod
+    def _to_full_tag_path(path: PathLike) -> str:
+        path_str = str(path)
+        if path_str.startswith(TagReference._common_path_default + "/"):
+            return path_str
+        if path_str.startswith(TagReference._common_default + "/"):
+            return Reference._common_path_default + "/" + path_str
+        else:
+            return TagReference._common_path_default + "/" + path_str
+
+    def create_head(
+        self,
+        path: PathLike,
+        commit: Union["SymbolicReference", "str"] = "HEAD",
+        force: bool = False,
+        logmsg: Optional[str] = None,
+    ) -> "Head":
         """Create a new head within the repository.
-        For more documentation, please see the Head.create method.
 
-        :return: newly created Head Reference"""
-        return Head.create(self, path, commit, force, logmsg)
+        :note:
+            For more documentation, please see the
+            :meth:`Head.create <git.refs.head.Head.create>` method.
+
+        :return:
+            Newly created :class:`~git.refs.head.Head` Reference.
+        """
+        return Head.create(self, path, commit, logmsg, force)
 
-    def delete_head(self, *heads, **kwargs):
-        """Delete the given heads
+    def delete_head(self, *heads: "Union[str, Head]", **kwargs: Any) -> None:
+        """Delete the given heads.
 
-        :param kwargs: Additional keyword arguments to be passed to git-branch"""
+        :param kwargs:
+            Additional keyword arguments to be passed to :manpage:`git-branch(1)`.
+        """
         return Head.delete(self, *heads, **kwargs)
 
-    def create_tag(self, path, ref='HEAD', message=None, force=False, **kwargs):
+    def create_tag(
+        self,
+        path: PathLike,
+        ref: Union[str, "SymbolicReference"] = "HEAD",
+        message: Optional[str] = None,
+        force: bool = False,
+        **kwargs: Any,
+    ) -> TagReference:
         """Create a new tag reference.
-        For more documentation, please see the TagReference.create method.
 
-        :return: TagReference object """
+        :note:
+            For more documentation, please see the
+            :meth:`TagReference.create <git.refs.tag.TagReference.create>` method.
+
+        :return:
+            :class:`~git.refs.tag.TagReference` object
+        """
         return TagReference.create(self, path, ref, message, force, **kwargs)
 
-    def delete_tag(self, *tags):
-        """Delete the given tag references"""
+    def delete_tag(self, *tags: TagReference) -> None:
+        """Delete the given tag references."""
         return TagReference.delete(self, *tags)
 
-    def create_remote(self, name, url, **kwargs):
+    def create_remote(self, name: str, url: str, **kwargs: Any) -> Remote:
         """Create a new remote.
 
-        For more information, please see the documentation of the Remote.create
-        methods
+        For more information, please see the documentation of the
+        :meth:`Remote.create <git.remote.Remote.create>` method.
 
-        :return: Remote reference"""
+        :return:
+            :class:`~git.remote.Remote` reference
+        """
         return Remote.create(self, name, url, **kwargs)
 
-    def delete_remote(self, remote):
+    def delete_remote(self, remote: "Remote") -> str:
         """Delete the given remote."""
         return Remote.remove(self, remote)
 
-    def _get_config_path(self, config_level):
-        # we do not support an absolute path of the gitconfig on windows ,
-        # use the global config instead
+    def _get_config_path(self, config_level: Lit_config_levels, git_dir: Optional[PathLike] = None) -> str:
+        if git_dir is None:
+            git_dir = self.git_dir
+        # We do not support an absolute path of the gitconfig on Windows.
+        # Use the global config instead.
         if sys.platform == "win32" and config_level == "system":
             config_level = "global"
 
         if config_level == "system":
             return "/etc/gitconfig"
         elif config_level == "user":
-            config_home = os.environ.get("XDG_CONFIG_HOME") or os.path.join(os.environ.get("HOME", '~'), ".config")
-            return os.path.normpath(os.path.expanduser(join(config_home, "git", "config")))
+            config_home = os.environ.get("XDG_CONFIG_HOME") or osp.join(os.environ.get("HOME", "~"), ".config")
+            return osp.normpath(osp.expanduser(osp.join(config_home, "git", "config")))
         elif config_level == "global":
-            return os.path.normpath(os.path.expanduser("~/.gitconfig"))
+            return osp.normpath(osp.expanduser("~/.gitconfig"))
         elif config_level == "repository":
-            return os.path.normpath(join(self.git_dir, "config"))
-
-        raise ValueError("Invalid configuration level: %r" % config_level)
-
-    def config_reader(self, config_level=None):
+            repo_dir = self._common_dir or git_dir
+            if not repo_dir:
+                raise NotADirectoryError
+            else:
+                return osp.normpath(osp.join(repo_dir, "config"))
+        else:
+            assert_never(  # type: ignore[unreachable]
+                config_level,
+                ValueError(f"Invalid configuration level: {config_level!r}"),
+            )
+
+    def config_reader(
+        self,
+        config_level: Optional[Lit_config_levels] = None,
+    ) -> GitConfigParser:
         """
         :return:
-            GitConfigParser allowing to read the full git configuration, but not to write it
+            :class:`~git.config.GitConfigParser` allowing to read the full git
+            configuration, but not to write it.
 
             The configuration will include values from the system, user and repository
             configuration files.
 
         :param config_level:
-            For possible values, see config_writer method
-            If None, all applicable levels will be used. Specify a level in case
-            you know which exact file you whish to read to prevent reading multiple files for
-            instance
-        :note: On windows, system configuration cannot currently be read as the path is
-            unknown, instead the global path will be used."""
-        files = None
+            For possible values, see the :meth:`config_writer` method. If ``None``, all
+            applicable levels will be used. Specify a level in case you know which file
+            you wish to read to prevent reading multiple files.
+
+        :note:
+            On Windows, system configuration cannot currently be read as the path is
+            unknown, instead the global path will be used.
+        """
+        return self._config_reader(config_level=config_level)
+
+    def _config_reader(
+        self,
+        config_level: Optional[Lit_config_levels] = None,
+        git_dir: Optional[PathLike] = None,
+    ) -> GitConfigParser:
         if config_level is None:
-            files = [self._get_config_path(f) for f in self.config_level]
+            files = [
+                self._get_config_path(cast(Lit_config_levels, f), git_dir)
+                for f in self.config_level
+                if cast(Lit_config_levels, f)
+            ]
         else:
-            files = [self._get_config_path(config_level)]
-        return GitConfigParser(files, read_only=True)
+            files = [self._get_config_path(config_level, git_dir)]
+        return GitConfigParser(files, read_only=True, repo=self)
 
-    def config_writer(self, config_level="repository"):
+    def config_writer(self, config_level: Lit_config_levels = "repository") -> GitConfigParser:
         """
         :return:
-            GitConfigParser allowing to write values of the specified configuration file level.
-            Config writers should be retrieved, used to change the configuration ,and written
-            right away as they will lock the configuration file in question and prevent other's
-            to write it.
+            A :class:`~git.config.GitConfigParser` allowing to write values of the
+            specified configuration file level. Config writers should be retrieved, used
+            to change the configuration, and written right away as they will lock the
+            configuration file in question and prevent other's to write it.
 
         :param config_level:
-            One of the following values
-            system = sytem wide configuration file
-            global = user level configuration file
-            repository = configuration file for this repostory only"""
-        return GitConfigParser(self._get_config_path(config_level), read_only=False)
-
-    def commit(self, rev=None):
-        """The Commit object for the specified revision
-        :param rev: revision specifier, see git-rev-parse for viable options.
-        :return: ``git.Commit``"""
+            One of the following values:
+
+            * ``"system"`` = system wide configuration file
+            * ``"global"`` = user level configuration file
+            * ``"`repository"`` = configuration file for this repository only
+        """
+        return GitConfigParser(self._get_config_path(config_level), read_only=False, repo=self, merge_includes=False)
+
+    def commit(self, rev: Union[str, Commit_ish, None] = None) -> Commit:
+        """The :class:`~git.objects.commit.Commit` object for the specified revision.
+
+        :param rev:
+            Revision specifier, see :manpage:`git-rev-parse(1)` for viable options.
+
+        :return:
+            :class:`~git.objects.commit.Commit`
+        """
         if rev is None:
             return self.head.commit
-        else:
-            return self.rev_parse(text_type(rev) + "^0")
+        return self.rev_parse(str(rev) + "^0")
+
+    def iter_trees(self, *args: Any, **kwargs: Any) -> Iterator["Tree"]:
+        """:return: Iterator yielding :class:`~git.objects.tree.Tree` objects
 
-    def iter_trees(self, *args, **kwargs):
-        """:return: Iterator yielding Tree objects
-        :note: Takes all arguments known to iter_commits method"""
+        :note:
+            Accepts all arguments known to the :meth:`iter_commits` method.
+        """
         return (c.tree for c in self.iter_commits(*args, **kwargs))
 
-    def tree(self, rev=None):
-        """The Tree object for the given treeish revision
+    def tree(self, rev: Union[Tree_ish, str, None] = None) -> "Tree":
+        """The :class:`~git.objects.tree.Tree` object for the given tree-ish revision.
+
         Examples::
 
               repo.tree(repo.heads[0])
 
-        :param rev: is a revision pointing to a Treeish ( being a commit or tree )
-        :return: ``git.Tree``
+        :param rev:
+            A revision pointing to a Treeish (being a commit or tree).
+
+        :return:
+            :class:`~git.objects.tree.Tree`
 
         :note:
-            If you need a non-root level tree, find it by iterating the root tree. Otherwise
-            it cannot know about its path relative to the repository root and subsequent
-            operations might have unexpected results."""
+            If you need a non-root level tree, find it by iterating the root tree.
+            Otherwise it cannot know about its path relative to the repository root and
+            subsequent operations might have unexpected results.
+        """
         if rev is None:
             return self.head.commit.tree
-        else:
-            return self.rev_parse(text_type(rev) + "^{tree}")
+        return self.rev_parse(str(rev) + "^{tree}")
 
-    def iter_commits(self, rev=None, paths='', **kwargs):
-        """A list of Commit objects representing the history of a given ref/commit
+    def iter_commits(
+        self,
+        rev: Union[str, Commit, "SymbolicReference", None] = None,
+        paths: Union[PathLike, Sequence[PathLike]] = "",
+        **kwargs: Any,
+    ) -> Iterator[Commit]:
+        """An iterator of :class:`~git.objects.commit.Commit` objects representing the
+        history of a given ref/commit.
 
-        :parm rev:
-            revision specifier, see git-rev-parse for viable options.
-            If None, the active branch will be used.
+        :param rev:
+            Revision specifier, see :manpage:`git-rev-parse(1)` for viable options.
+            If ``None``, the active branch will be used.
 
-        :parm paths:
-            is an optional path or a list of paths to limit the returned commits to
-            Commits that do not contain that path or the paths will not be returned.
+        :param paths:
+            An optional path or a list of paths. If set, only commits that include the
+            path or paths will be returned.
 
-        :parm kwargs:
-            Arguments to be passed to git-rev-list - common ones are
-            max_count and skip
+        :param kwargs:
+            Arguments to be passed to :manpage:`git-rev-list(1)`.
+            Common ones are ``max_count`` and ``skip``.
 
-        :note: to receive only commits between two named revisions, use the
-            "revA..revB" revision specifier
+        :note:
+            To receive only commits between two named revisions, use the
+            ``"revA...revB"`` revision specifier.
 
-        :return ``git.Commit[]``"""
+        :return:
+            Iterator of :class:`~git.objects.commit.Commit` objects
+        """
         if rev is None:
             rev = self.head.commit
 
         return Commit.iter_items(self, rev, paths, **kwargs)
 
-    def merge_base(self, *rev, **kwargs):
-        """Find the closest common ancestor for the given revision (e.g. Commits, Tags, References, etc)
+    def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Commit]:
+        R"""Find the closest common ancestor for the given revision
+        (:class:`~git.objects.commit.Commit`\s, :class:`~git.refs.tag.Tag`\s,
+        :class:`~git.refs.reference.Reference`\s, etc.).
+
+        :param rev:
+            At least two revs to find the common ancestor for.
+
+        :param kwargs:
+            Additional arguments to be passed to the ``repo.git.merge_base()`` command
+            which does all the work.
+
+        :return:
+            A list of :class:`~git.objects.commit.Commit` objects. If ``--all`` was
+            not passed as a keyword argument, the list will have at max one
+            :class:`~git.objects.commit.Commit`, or is empty if no common merge base
+            exists.
 
-        :param rev: At least two revs to find the common ancestor for.
-        :param kwargs: Additional arguments to be passed to the repo.git.merge_base() command which does all the work.
-        :return: A list of Commit objects. If --all was not specified as kwarg, the list will have at max one Commit,
-            or is empty if no common merge base exists.
-        :raises ValueError: If not at least two revs are provided
+        :raise ValueError:
+            If fewer than two revisions are provided.
         """
         if len(rev) < 2:
             raise ValueError("Please specify at least two revs, got only %i" % len(rev))
-        # end handle input
+        # END handle input
 
-        res = list()
+        res: List[Commit] = []
         try:
-            lines = self.git.merge_base(*rev, **kwargs).splitlines()
+            lines: List[str] = self.git.merge_base(*rev, **kwargs).splitlines()
         except GitCommandError as err:
             if err.status == 128:
                 raise
-            # end handle invalid rev
-            # Status code 1 is returned if there is no merge-base
-            # (see https://github.com/git/git/blob/master/builtin/merge-base.c#L16)
+            # END handle invalid rev
+            # Status code 1 is returned if there is no merge-base.
+            # (See: https://github.com/git/git/blob/v2.44.0/builtin/merge-base.c#L19)
             return res
-        # end exception handling
+        # END exception handling
 
         for line in lines:
             res.append(self.commit(line))
-        # end for each merge-base
+        # END for each merge-base
 
         return res
 
-    def _get_daemon_export(self):
-        filename = join(self.git_dir, self.DAEMON_EXPORT_FILE)
-        return os.path.exists(filename)
+    def is_ancestor(self, ancestor_rev: Commit, rev: Commit) -> bool:
+        """Check if a commit is an ancestor of another.
+
+        :param ancestor_rev:
+            Rev which should be an ancestor.
+
+        :param rev:
+            Rev to test against `ancestor_rev`.
 
-    def _set_daemon_export(self, value):
-        filename = join(self.git_dir, self.DAEMON_EXPORT_FILE)
-        fileexists = os.path.exists(filename)
+        :return:
+            ``True`` if `ancestor_rev` is an ancestor to `rev`.
+        """
+        try:
+            self.git.merge_base(ancestor_rev, rev, is_ancestor=True)
+        except GitCommandError as err:
+            if err.status == 1:
+                return False
+            raise
+        return True
+
+    def is_valid_object(self, sha: str, object_type: Union[str, None] = None) -> bool:
+        try:
+            complete_sha = self.odb.partial_to_complete_sha_hex(sha)
+            object_info = self.odb.info(complete_sha)
+            if object_type:
+                if object_info.type == object_type.encode():
+                    return True
+                else:
+                    _logger.debug(
+                        "Commit hash points to an object of type '%s'. Requested were objects of type '%s'",
+                        object_info.type.decode(),
+                        object_type,
+                    )
+                    return False
+            else:
+                return True
+        except BadObject:
+            _logger.debug("Commit hash is invalid.")
+            return False
+
+    def _get_daemon_export(self) -> bool:
+        if self.git_dir:
+            filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
+        return osp.exists(filename)
+
+    def _set_daemon_export(self, value: object) -> None:
+        if self.git_dir:
+            filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
+        fileexists = osp.exists(filename)
         if value and not fileexists:
             touch(filename)
         elif not value and fileexists:
             os.unlink(filename)
 
-    daemon_export = property(_get_daemon_export, _set_daemon_export,
-                             doc="If True, git-daemon may export this repository")
-    del _get_daemon_export
-    del _set_daemon_export
+    @property
+    def daemon_export(self) -> bool:
+        """If True, git-daemon may export this repository"""
+        return self._get_daemon_export()
 
-    def _get_alternates(self):
-        """The list of alternates for this repo from which objects can be retrieved
+    @daemon_export.setter
+    def daemon_export(self, value: object) -> None:
+        self._set_daemon_export(value)
 
-        :return: list of strings being pathnames of alternates"""
-        alternates_path = join(self.git_dir, 'objects', 'info', 'alternates')
+    def _get_alternates(self) -> List[str]:
+        """The list of alternates for this repo from which objects can be retrieved.
 
-        if os.path.exists(alternates_path):
-            try:
-                f = open(alternates_path, 'rb')
+        :return:
+            List of strings being pathnames of alternates
+        """
+        if self.git_dir:
+            alternates_path = osp.join(self.git_dir, "objects", "info", "alternates")
+
+        if osp.exists(alternates_path):
+            with open(alternates_path, "rb") as f:
                 alts = f.read().decode(defenc)
-            finally:
-                f.close()
             return alts.strip().splitlines()
-        else:
-            return list()
+        return []
 
-    def _set_alternates(self, alts):
-        """Sets the alternates
+    def _set_alternates(self, alts: List[str]) -> None:
+        """Set the alternates.
 
-        :parm alts:
-            is the array of string paths representing the alternates at which
-            git should look for objects, i.e. /home/user/repo/.git/objects
+        :param alts:
+            The array of string paths representing the alternates at which git should
+            look for objects, i.e. ``/home/user/repo/.git/objects``.
+
+        :raise git.exc.NoSuchPathError:
 
-        :raise NoSuchPathError:
         :note:
-            The method does not check for the existance of the paths in alts
-            as the caller is responsible."""
-        alternates_path = join(self.git_dir, 'objects', 'info', 'alternates')
+            The method does not check for the existence of the paths in `alts`, as the
+            caller is responsible.
+        """
+        alternates_path = osp.join(self.common_dir, "objects", "info", "alternates")
         if not alts:
-            if isfile(alternates_path):
+            if osp.isfile(alternates_path):
                 os.remove(alternates_path)
         else:
-            try:
-                f = open(alternates_path, 'wb')
+            with open(alternates_path, "wb") as f:
                 f.write("\n".join(alts).encode(defenc))
-            finally:
-                f.close()
-            # END file handling
-        # END alts handling
-
-    alternates = property(_get_alternates, _set_alternates,
-                          doc="Retrieve a list of alternates paths or set a list paths to be used as alternates")
 
-    def is_dirty(self, index=True, working_tree=True, untracked_files=False):
+    @property
+    def alternates(self) -> List[str]:
+        """Retrieve a list of alternates paths or set a list paths to be used as alternates"""
+        return self._get_alternates()
+
+    @alternates.setter
+    def alternates(self, alts: List[str]) -> None:
+        self._set_alternates(alts)
+
+    def is_dirty(
+        self,
+        index: bool = True,
+        working_tree: bool = True,
+        untracked_files: bool = False,
+        submodules: bool = True,
+        path: Optional[PathLike] = None,
+    ) -> bool:
         """
         :return:
-            ``True``, the repository is considered dirty. By default it will react
-            like a git-status without untracked files, hence it is dirty if the
-            index or the working copy have changes."""
+            ``True`` if the repository is considered dirty. By default it will react
+            like a :manpage:`git-status(1)` without untracked files, hence it is dirty
+            if the index or the working copy have changes.
+        """
         if self._bare:
             # Bare repositories with no associated working directory are
-            # always consired to be clean.
+            # always considered to be clean.
             return False
 
-        # start from the one which is fastest to evaluate
-        default_args = ('--abbrev=40', '--full-index', '--raw')
+        # Start from the one which is fastest to evaluate.
+        default_args = ["--abbrev=40", "--full-index", "--raw"]
+        if not submodules:
+            default_args.append("--ignore-submodules")
+        if path:
+            default_args.extend(["--", str(path)])
         if index:
-            # diff index against HEAD
-            if isfile(self.index.path) and \
-                    len(self.git.diff('--cached', *default_args)):
+            # diff index against HEAD.
+            if osp.isfile(self.index.path) and len(self.git.diff("--cached", *default_args)):
                 return True
         # END index handling
         if working_tree:
-            # diff index against working tree
+            # diff index against working tree.
             if len(self.git.diff(*default_args)):
                 return True
         # END working tree handling
         if untracked_files:
-            if len(self.untracked_files):
+            if len(self._get_untracked_files(path, ignore_submodules=not submodules)):
                 return True
         # END untracked files
         return False
 
     @property
-    def untracked_files(self):
+    def untracked_files(self) -> List[str]:
         """
         :return:
             list(str,...)
 
-            Files currently untracked as they have not been staged yet. Paths
-            are relative to the current working directory of the git command.
+            Files currently untracked as they have not been staged yet. Paths are
+            relative to the current working directory of the git command.
+
+        :note:
+            Ignored files will not appear here, i.e. files mentioned in ``.gitignore``.
 
         :note:
-            ignored files will not appear here, i.e. files mentioned in .gitignore"""
-        # make sure we get all files, no only untracked directores
-        proc = self.git.status(porcelain=True,
-                               untracked_files=True,
-                               as_process=True)
-        # Untracked files preffix in porcelain mode
+            This property is expensive, as no cache is involved. To process the result,
+            please consider caching it yourself.
+        """
+        return self._get_untracked_files()
+
+    def _get_untracked_files(self, *args: Any, **kwargs: Any) -> List[str]:
+        # Make sure we get all files, not only untracked directories.
+        proc = self.git.status(*args, porcelain=True, untracked_files=True, as_process=True, **kwargs)
+        # Untracked files prefix in porcelain mode
         prefix = "?? "
-        untracked_files = list()
+        untracked_files = []
         for line in proc.stdout:
             line = line.decode(defenc)
             if not line.startswith(prefix):
                 continue
-            filename = line[len(prefix):].rstrip('\n')
+            filename = line[len(prefix) :].rstrip("\n")
             # Special characters are escaped
             if filename[0] == filename[-1] == '"':
-                filename = filename[1:-1].decode('string_escape')
+                filename = filename[1:-1]
+                # WHATEVER ... it's a mess, but works for me
+                filename = filename.encode("ascii").decode("unicode_escape").encode("latin1").decode(defenc)
             untracked_files.append(filename)
         finalize_process(proc)
         return untracked_files
 
+    def ignored(self, *paths: PathLike) -> List[str]:
+        """Checks if paths are ignored via ``.gitignore``.
+
+        This does so using the :manpage:`git-check-ignore(1)` method.
+
+        :param paths:
+            List of paths to check whether they are ignored or not.
+
+        :return:
+            Subset of those paths which are ignored
+        """
+        try:
+            proc: str = self.git.check_ignore(*paths)
+        except GitCommandError as err:
+            if err.status == 1:
+                # If return code is 1, this means none of the items in *paths are
+                # ignored by Git, so return an empty list.
+                return []
+            else:
+                # Raise the exception on all other return codes.
+                raise
+
+        return proc.replace("\\\\", "\\").replace('"', "").split("\n")
+
     @property
-    def active_branch(self):
+    def active_branch(self) -> Head:
         """The name of the currently active branch.
 
-        :return: Head to the active branch"""
+        :raise TypeError:
+            If HEAD is detached.
+
+        :return:
+            :class:`~git.refs.head.Head` to the active branch
+        """
+        # reveal_type(self.head.reference)  # => Reference
         return self.head.reference
 
-    def blame(self, rev, file):
+    def blame_incremental(self, rev: str | HEAD | None, file: str, **kwargs: Any) -> Iterator["BlameEntry"]:
+        """Iterator for blame information for the given file at the given revision.
+
+        Unlike :meth:`blame`, this does not return the actual file's contents, only a
+        stream of :class:`BlameEntry` tuples.
+
+        :param rev:
+            Revision specifier. If ``None``, the blame will include all the latest
+            uncommitted changes. Otherwise, anything successfully parsed by
+            :manpage:`git-rev-parse(1)` is a valid option.
+
+        :return:
+            Lazy iterator of :class:`BlameEntry` tuples, where the commit indicates the
+            commit to blame for the line, and range indicates a span of line numbers in
+            the resulting file.
+
+        If you combine all line number ranges outputted by this command, you should get
+        a continuous range spanning all line numbers in the file.
+        """
+
+        data: bytes = self.git.blame(rev, "--", file, p=True, incremental=True, stdout_as_string=False, **kwargs)
+        commits: Dict[bytes, Commit] = {}
+
+        stream = (line for line in data.split(b"\n") if line)
+        while True:
+            try:
+                # When exhausted, causes a StopIteration, terminating this function.
+                line = next(stream)
+            except StopIteration:
+                return
+            split_line = line.split()
+            hexsha, orig_lineno_b, lineno_b, num_lines_b = split_line
+            lineno = int(lineno_b)
+            num_lines = int(num_lines_b)
+            orig_lineno = int(orig_lineno_b)
+            if hexsha not in commits:
+                # Now read the next few lines and build up a dict of properties for this
+                # commit.
+                props: Dict[bytes, bytes] = {}
+                while True:
+                    try:
+                        line = next(stream)
+                    except StopIteration:
+                        return
+                    if line == b"boundary":
+                        # "boundary" indicates a root commit and occurs instead of the
+                        # "previous" tag.
+                        continue
+
+                    tag, value = line.split(b" ", 1)
+                    props[tag] = value
+                    if tag == b"filename":
+                        # "filename" formally terminates the entry for --incremental.
+                        orig_filename = value
+                        break
+
+                c = Commit(
+                    self,
+                    hex_to_bin(hexsha),
+                    author=Actor(
+                        safe_decode(props[b"author"]),
+                        safe_decode(props[b"author-mail"].lstrip(b"<").rstrip(b">")),
+                    ),
+                    authored_date=int(props[b"author-time"]),
+                    committer=Actor(
+                        safe_decode(props[b"committer"]),
+                        safe_decode(props[b"committer-mail"].lstrip(b"<").rstrip(b">")),
+                    ),
+                    committed_date=int(props[b"committer-time"]),
+                )
+                commits[hexsha] = c
+            else:
+                # Discard all lines until we find "filename" which is guaranteed to be
+                # the last line.
+                while True:
+                    try:
+                        # Will fail if we reach the EOF unexpectedly.
+                        line = next(stream)
+                    except StopIteration:
+                        return
+                    tag, value = line.split(b" ", 1)
+                    if tag == b"filename":
+                        orig_filename = value
+                        break
+
+            yield BlameEntry(
+                commits[hexsha],
+                range(lineno, lineno + num_lines),
+                safe_decode(orig_filename),
+                range(orig_lineno, orig_lineno + num_lines),
+            )
+
+    def blame(
+        self,
+        rev: Union[str, HEAD, None],
+        file: str,
+        incremental: bool = False,
+        rev_opts: Optional[List[str]] = None,
+        **kwargs: Any,
+    ) -> List[List[Commit | List[str | bytes] | None]] | Iterator[BlameEntry] | None:
         """The blame information for the given file at the given revision.
 
-        :parm rev: revision specifier, see git-rev-parse for viable options.
+        :param rev:
+            Revision specifier. If ``None``, the blame will include all the latest
+            uncommitted changes. Otherwise, anything successfully parsed by
+            :manpage:`git-rev-parse(1)` is a valid option.
+
         :return:
             list: [git.Commit, list: [<line>]]
-            A list of tuples associating a Commit object with a list of lines that
-            changed within the given commit. The Commit objects will be given in order
-            of appearance."""
-        data = self.git.blame(rev, '--', file, p=True, stdout_as_string=False)
-        commits = dict()
-        blames = list()
-        info = None
+
+            A list of lists associating a :class:`~git.objects.commit.Commit` object
+            with a list of lines that changed within the given commit. The
+            :class:`~git.objects.commit.Commit` objects will be given in order of
+            appearance.
+        """
+        if incremental:
+            return self.blame_incremental(rev, file, **kwargs)
+        rev_opts = rev_opts or []
+        data: bytes = self.git.blame(rev, *rev_opts, "--", file, p=True, stdout_as_string=False, **kwargs)
+        commits: Dict[str, Commit] = {}
+        blames: List[List[Commit | List[str | bytes] | None]] = []
+
+        class InfoTD(TypedDict, total=False):
+            sha: str
+            id: str
+            filename: str
+            summary: str
+            author: str
+            author_email: str
+            author_date: int
+            committer: str
+            committer_email: str
+            committer_date: int
+
+        info: InfoTD = {}
 
         keepends = True
-        for line in data.splitlines(keepends):
+        for line_bytes in data.splitlines(keepends):
             try:
-                line = line.rstrip().decode(defenc)
+                line_str = line_bytes.rstrip().decode(defenc)
             except UnicodeDecodeError:
-                firstpart = ''
+                firstpart = ""
+                parts = []
                 is_binary = True
             else:
-                # As we don't have an idea when the binary data ends, as it could contain multiple newlines
-                # in the process. So we rely on being able to decode to tell us what is is.
-                # This can absolutely fail even on text files, but even if it does, we should be fine treating it
-                # as binary instead
-                parts = self.re_whitespace.split(line, 1)
+                # As we don't have an idea when the binary data ends, as it could
+                # contain multiple newlines in the process. So we rely on being able to
+                # decode to tell us what it is. This can absolutely fail even on text
+                # files, but even if it does, we should be fine treating it as binary
+                # instead.
+                parts = self.re_whitespace.split(line_str, 1)
                 firstpart = parts[0]
                 is_binary = False
-            # end handle decode of line
+            # END handle decode of line
 
             if self.re_hexsha_only.search(firstpart):
                 # handles
@@ -656,10 +1215,10 @@ def blame(self, rev, file):
                 # another line of blame with the same data
                 digits = parts[-1].split(" ")
                 if len(digits) == 3:
-                    info = {'id': firstpart}
+                    info = {"id": firstpart}
                     blames.append([None, []])
-                elif info['id'] != firstpart:
-                    info = {'id': firstpart}
+                elif info["id"] != firstpart:
+                    info = {"id": firstpart}
                     blames.append([commits.get(firstpart), []])
                 # END blame data initialization
             else:
@@ -675,49 +1234,64 @@ def blame(self, rev, file):
                     # committer-time 1192271832
                     # committer-tz -0700  - IGNORED BY US
                     role = m.group(0)
-                    if firstpart.endswith('-mail'):
-                        info["%s_email" % role] = parts[-1]
-                    elif firstpart.endswith('-time'):
-                        info["%s_date" % role] = int(parts[-1])
-                    elif role == firstpart:
-                        info[role] = parts[-1]
+                    if role == "author":
+                        if firstpart.endswith("-mail"):
+                            info["author_email"] = parts[-1]
+                        elif firstpart.endswith("-time"):
+                            info["author_date"] = int(parts[-1])
+                        elif role == firstpart:
+                            info["author"] = parts[-1]
+                    elif role == "committer":
+                        if firstpart.endswith("-mail"):
+                            info["committer_email"] = parts[-1]
+                        elif firstpart.endswith("-time"):
+                            info["committer_date"] = int(parts[-1])
+                        elif role == firstpart:
+                            info["committer"] = parts[-1]
                     # END distinguish mail,time,name
                 else:
                     # handle
                     # filename lib/grit.rb
                     # summary add Blob
                     # <and rest>
-                    if firstpart.startswith('filename'):
-                        info['filename'] = parts[-1]
-                    elif firstpart.startswith('summary'):
-                        info['summary'] = parts[-1]
-                    elif firstpart == '':
+                    if firstpart.startswith("filename"):
+                        info["filename"] = parts[-1]
+                    elif firstpart.startswith("summary"):
+                        info["summary"] = parts[-1]
+                    elif firstpart == "":
                         if info:
-                            sha = info['id']
+                            sha = info["id"]
                             c = commits.get(sha)
                             if c is None:
-                                c = Commit(self, hex_to_bin(sha),
-                                           author=Actor._from_string(info['author'] + ' ' + info['author_email']),
-                                           authored_date=info['author_date'],
-                                           committer=Actor._from_string(
-                                               info['committer'] + ' ' + info['committer_email']),
-                                           committed_date=info['committer_date'],
-                                           message=info['summary'])
+                                c = Commit(
+                                    self,
+                                    hex_to_bin(sha),
+                                    author=Actor._from_string(f"{info['author']} {info['author_email']}"),
+                                    authored_date=info["author_date"],
+                                    committer=Actor._from_string(f"{info['committer']} {info['committer_email']}"),
+                                    committed_date=info["committer_date"],
+                                )
                                 commits[sha] = c
-                            # END if commit objects needs initial creation
-                            if not is_binary:
-                                if line and line[0] == '\t':
-                                    line = line[1:]
-                            else:
-                                # NOTE: We are actually parsing lines out of binary data, which can lead to the
-                                # binary being split up along the newline separator. We will append this to the blame
-                                # we are currently looking at, even though it should be concatenated with the last line
-                                # we have seen.
-                                pass
-                            # end handle line contents
                             blames[-1][0] = c
-                            blames[-1][1].append(line)
-                            info = {'id': sha}
+                            # END if commit objects needs initial creation
+
+                            if blames[-1][1] is not None:
+                                line: str | bytes
+                                if not is_binary:
+                                    if line_str and line_str[0] == "\t":
+                                        line_str = line_str[1:]
+                                    line = line_str
+                                else:
+                                    line = line_bytes
+                                    # NOTE: We are actually parsing lines out of binary
+                                    # data, which can lead to the binary being split up
+                                    # along the newline separator. We will append this
+                                    # to the blame we are currently looking at, even
+                                    # though it should be concatenated with the last
+                                    # line we have seen.
+                                blames[-1][1].append(line)
+
+                            info = {"id": sha}
                         # END if we collected commit info
                     # END distinguish filename,summary,rest
                 # END distinguish author|committer vs filename,summary,rest
@@ -725,146 +1299,340 @@ def blame(self, rev, file):
         return blames
 
     @classmethod
-    def init(cls, path=None, mkdir=True, **kwargs):
-        """Initialize a git repository at the given path if specified
+    def init(
+        cls,
+        path: Union[PathLike, None] = None,
+        mkdir: bool = True,
+        odbt: Type[GitCmdObjectDB] = GitCmdObjectDB,
+        expand_vars: bool = True,
+        **kwargs: Any,
+    ) -> "Repo":
+        """Initialize a git repository at the given path if specified.
 
         :param path:
-            is the full path to the repo (traditionally ends with /<name>.git)
-            or None in which case the repository will be created in the current
-            working directory
+            The full path to the repo (traditionally ends with ``/<name>.git``). Or
+            ``None``, in which case the repository will be created in the current
+            working directory.
 
-        :parm mkdir:
-            if specified will create the repository directory if it doesn't
-            already exists. Creates the directory with a mode=0755.
-            Only effective if a path is explicitly given
+        :param mkdir:
+            If specified, will create the repository directory if it doesn't already
+            exist. Creates the directory with a mode=0755.
+            Only effective if a path is explicitly given.
 
-        :parm kwargs:
-            keyword arguments serving as additional options to the git-init command
+        :param odbt:
+            Object DataBase type - a type which is constructed by providing the
+            directory containing the database objects, i.e. ``.git/objects``. It will be
+            used to access all object data.
 
-        :return: ``git.Repo`` (the newly created repo)"""
+        :param expand_vars:
+            If specified, environment variables will not be escaped. This can lead to
+            information disclosure, allowing attackers to access the contents of
+            environment variables.
+
+        :param kwargs:
+            Keyword arguments serving as additional options to the
+            :manpage:`git-init(1)` command.
+
+        :return:
+            :class:`Repo` (the newly created repo)
+        """
         if path:
-            path = _expand_path(path)
-        if mkdir and path and not os.path.exists(path):
+            path = expand_path(path, expand_vars)
+        if mkdir and path and not osp.exists(path):
             os.makedirs(path, 0o755)
 
         # git command automatically chdir into the directory
-        git = Git(path)
+        git = cls.GitCommandWrapperType(path)
         git.init(**kwargs)
-        return Repo(path)
+        return cls(path, odbt=odbt)
 
     @classmethod
-    def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):
-        # special handling for windows for path at which the clone should be
-        # created.
-        # tilde '~' will be expanded to the HOME no matter where the ~ occours. Hence
-        # we at least give a proper error instead of letting git fail
-        prev_cwd = None
-        prev_path = None
-        odbt = kwargs.pop('odbt', odb_default_type)
-        if os.name == 'nt':
-            if '~' in path:
-                raise OSError("Git cannot handle the ~ character in path %r correctly" % path)
-
-            # on windows, git will think paths like c: are relative and prepend the
-            # current working dir ( before it fails ). We temporarily adjust the working
-            # dir to make this actually work
-            match = re.match("(\w:[/\\\])(.*)", path)
-            if match:
-                prev_cwd = os.getcwd()
-                prev_path = path
-                drive, rest_of_path = match.groups()
-                os.chdir(drive)
-                path = rest_of_path
-                kwargs['with_keep_cwd'] = True
-            # END cwd preparation
-        # END windows handling
+    def _clone(
+        cls,
+        git: "Git",
+        url: PathLike,
+        path: PathLike,
+        odb_default_type: Type[GitCmdObjectDB],
+        progress: Union["RemoteProgress", "UpdateProgress", Callable[..., "RemoteProgress"], None] = None,
+        multi_options: Optional[List[str]] = None,
+        allow_unsafe_protocols: bool = False,
+        allow_unsafe_options: bool = False,
+        **kwargs: Any,
+    ) -> "Repo":
+        odbt = kwargs.pop("odbt", odb_default_type)
+
+        # When pathlib.Path or other class-based path is passed
+        if not isinstance(path, str):
+            path = str(path)
+
+        ## A bug win cygwin's Git, when `--bare` or `--separate-git-dir`
+        #  it prepends the cwd or(?) the `url` into the `path, so::
+        #        git clone --bare  /cygwin/d/foo.git  C:\\Work
+        #  becomes::
+        #        git clone --bare  /cygwin/d/foo.git  /cygwin/d/C:\\Work
+        #
+        clone_path = Git.polish_url(path) if Git.is_cygwin() and "bare" in kwargs else path
+        sep_dir = kwargs.get("separate_git_dir")
+        if sep_dir:
+            kwargs["separate_git_dir"] = Git.polish_url(sep_dir)
+        multi = None
+        if multi_options:
+            multi = shlex.split(" ".join(multi_options))
+
+        if not allow_unsafe_protocols:
+            Git.check_unsafe_protocols(str(url))
+        if not allow_unsafe_options:
+            Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=cls.unsafe_git_clone_options)
+        if not allow_unsafe_options and multi_options:
+            Git.check_unsafe_options(options=multi_options, unsafe_options=cls.unsafe_git_clone_options)
+
+        proc = git.clone(
+            multi,
+            "--",
+            Git.polish_url(str(url)),
+            clone_path,
+            with_extended_output=True,
+            as_process=True,
+            v=True,
+            universal_newlines=True,
+            **add_progress(kwargs, git, progress),
+        )
+        if progress:
+            handle_process_output(
+                proc,
+                None,
+                to_progress_instance(progress).new_message_handler(),
+                finalize_process,
+                decode_streams=False,
+            )
+        else:
+            (stdout, stderr) = proc.communicate()
+            cmdline = getattr(proc, "args", "")
+            cmdline = remove_password_if_present(cmdline)
 
-        try:
-            proc = git.clone(url, path, with_extended_output=True, as_process=True,
-                             v=True, **add_progress(kwargs, git, progress))
-            if progress:
-                handle_process_output(proc, None, progress.new_message_handler(), finalize_process)
-            else:
-                finalize_process(proc)
-            # end handle progress
-        finally:
-            if prev_cwd is not None:
-                os.chdir(prev_cwd)
-                path = prev_path
-            # END reset previous working dir
-        # END bad windows handling
-
-        # our git command could have a different working dir than our actual
-        # environment, hence we prepend its working dir if required
-        if not os.path.isabs(path) and git.working_dir:
-            path = join(git._working_dir, path)
-
-        # adjust remotes - there may be operating systems which use backslashes,
-        # These might be given as initial paths, but when handling the config file
-        # that contains the remote from which we were clones, git stops liking it
-        # as it will escape the backslashes. Hence we undo the escaping just to be
-        # sure
-        repo = cls(os.path.abspath(path), odbt=odbt)
+            _logger.debug("Cmd(%s)'s unused stdout: %s", cmdline, stdout)
+            finalize_process(proc, stderr=stderr)
+
+        # Our git command could have a different working dir than our actual
+        # environment, hence we prepend its working dir if required.
+        if not osp.isabs(path):
+            path = osp.join(git._working_dir, path) if git._working_dir is not None else path
+
+        repo = cls(path, odbt=odbt)
+
+        # Retain env values that were passed to _clone().
+        repo.git.update_environment(**git.environment())
+
+        # Adjust remotes - there may be operating systems which use backslashes, These
+        # might be given as initial paths, but when handling the config file that
+        # contains the remote from which we were clones, git stops liking it as it will
+        # escape the backslashes. Hence we undo the escaping just to be sure.
         if repo.remotes:
-            writer = repo.remotes[0].config_writer
-            writer.set_value('url', repo.remotes[0].url.replace("\\\\", "\\").replace("\\", "/"))
-            # PY3: be sure cleanup is performed and lock is released
-            writer.release()
+            with repo.remotes[0].config_writer as writer:
+                writer.set_value("url", Git.polish_url(repo.remotes[0].url))
         # END handle remote repo
         return repo
 
-    def clone(self, path, progress=None, **kwargs):
+    def clone(
+        self,
+        path: PathLike,
+        progress: Optional[CallableProgress] = None,
+        multi_options: Optional[List[str]] = None,
+        allow_unsafe_protocols: bool = False,
+        allow_unsafe_options: bool = False,
+        **kwargs: Any,
+    ) -> "Repo":
         """Create a clone from this repository.
 
-        :param path: is the full path of the new repo (traditionally ends with ./<name>.git).
-        :param progress: See 'git.remote.Remote.push'.
+        :param path:
+            The full path of the new repo (traditionally ends with ``./<name>.git``).
+
+        :param progress:
+            See :meth:`Remote.push <git.remote.Remote.push>`.
+
+        :param multi_options:
+            A list of :manpage:`git-clone(1)` options that can be provided multiple
+            times.
+
+            One option per list item which is passed exactly as specified to clone.
+            For example::
+
+                [
+                    "--config core.filemode=false",
+                    "--config core.ignorecase",
+                    "--recurse-submodule=repo1_path",
+                    "--recurse-submodule=repo2_path",
+                ]
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :param allow_unsafe_options:
+            Allow unsafe options to be used, like ``--upload-pack``.
+
         :param kwargs:
-            * odbt = ObjectDatabase Type, allowing to determine the object database
-              implementation used by the returned Repo instance
-            * All remaining keyword arguments are given to the git-clone command
+            * ``odbt`` = ObjectDatabase Type, allowing to determine the object database
+              implementation used by the returned :class:`Repo` instance.
+            * All remaining keyword arguments are given to the :manpage:`git-clone(1)`
+              command.
 
-        :return: ``git.Repo`` (the newly cloned repo)"""
-        return self._clone(self.git, self.git_dir, path, type(self.odb), progress, **kwargs)
+        :return:
+            :class:`Repo` (the newly cloned repo)
+        """
+        return self._clone(
+            self.git,
+            self.common_dir,
+            path,
+            type(self.odb),
+            progress,
+            multi_options,
+            allow_unsafe_protocols=allow_unsafe_protocols,
+            allow_unsafe_options=allow_unsafe_options,
+            **kwargs,
+        )
 
     @classmethod
-    def clone_from(cls, url, to_path, progress=None, **kwargs):
-        """Create a clone from the given URL
-        :param url: valid git url, see http://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS
-        :param to_path: Path to which the repository should be cloned to
-        :param progress: See 'git.remote.Remote.push'.
-        :param kwargs: see the ``clone`` method
-        :return: Repo instance pointing to the cloned directory"""
-        return cls._clone(Git(os.getcwd()), url, to_path, GitCmdObjectDB, progress, **kwargs)
-
-    def archive(self, ostream, treeish=None, prefix=None, **kwargs):
+    def clone_from(
+        cls,
+        url: PathLike,
+        to_path: PathLike,
+        progress: CallableProgress = None,
+        env: Optional[Mapping[str, str]] = None,
+        multi_options: Optional[List[str]] = None,
+        allow_unsafe_protocols: bool = False,
+        allow_unsafe_options: bool = False,
+        **kwargs: Any,
+    ) -> "Repo":
+        """Create a clone from the given URL.
+
+        :param url:
+            Valid git url, see: https://git-scm.com/docs/git-clone#URLS
+
+        :param to_path:
+            Path to which the repository should be cloned to.
+
+        :param progress:
+            See :meth:`Remote.push <git.remote.Remote.push>`.
+
+        :param env:
+            Optional dictionary containing the desired environment variables.
+
+            Note: Provided variables will be used to update the execution environment
+            for ``git``. If some variable is not specified in `env` and is defined in
+            :attr:`os.environ`, value from :attr:`os.environ` will be used. If you want
+            to unset some variable, consider providing empty string as its value.
+
+        :param multi_options:
+            See the :meth:`clone` method.
+
+        :param allow_unsafe_protocols:
+            Allow unsafe protocols to be used, like ``ext``.
+
+        :param allow_unsafe_options:
+            Allow unsafe options to be used, like ``--upload-pack``.
+
+        :param kwargs:
+            See the :meth:`clone` method.
+
+        :return:
+            :class:`Repo` instance pointing to the cloned directory.
+        """
+        git = cls.GitCommandWrapperType(os.getcwd())
+        if env is not None:
+            git.update_environment(**env)
+        return cls._clone(
+            git,
+            url,
+            to_path,
+            GitCmdObjectDB,
+            progress,
+            multi_options,
+            allow_unsafe_protocols=allow_unsafe_protocols,
+            allow_unsafe_options=allow_unsafe_options,
+            **kwargs,
+        )
+
+    def archive(
+        self,
+        ostream: Union[TextIO, BinaryIO],
+        treeish: Optional[str] = None,
+        prefix: Optional[str] = None,
+        **kwargs: Any,
+    ) -> Repo:
         """Archive the tree at the given revision.
 
-        :parm ostream: file compatible stream object to which the archive will be written as bytes
-        :parm treeish: is the treeish name/id, defaults to active branch
-        :parm prefix: is the optional prefix to prepend to each filename in the archive
-        :parm kwargs: Additional arguments passed to git-archive
+        :param ostream:
+            File-compatible stream object to which the archive will be written as bytes.
+
+        :param treeish:
+            The treeish name/id, defaults to active branch.
+
+        :param prefix:
+            The optional prefix to prepend to each filename in the archive.
+
+        :param kwargs:
+            Additional arguments passed to :manpage:`git-archive(1)`:
+
+            * Use the ``format`` argument to define the kind of format. Use specialized
+              ostreams to write any format supported by Python.
+            * You may specify the special ``path`` keyword, which may either be a
+              repository-relative path to a directory or file to place into the archive,
+              or a list or tuple of multiple paths.
 
-            * Use the 'format' argument to define the kind of format. Use
-              specialized ostreams to write any format supported by python.
-            * You may specify the special **path** keyword, which may either be a repository-relative
-              path to a directory or file to place into the archive, or a list or tuple of multipe paths.
+        :raise git.exc.GitCommandError:
+            If something went wrong.
 
-        :raise GitCommandError: in case something went wrong
-        :return: self"""
+        :return:
+            self
+        """
         if treeish is None:
             treeish = self.head.commit
-        if prefix and 'prefix' not in kwargs:
-            kwargs['prefix'] = prefix
-        kwargs['output_stream'] = ostream
-        path = kwargs.pop('path', list())
+        if prefix and "prefix" not in kwargs:
+            kwargs["prefix"] = prefix
+        kwargs["output_stream"] = ostream
+        path = kwargs.pop("path", [])
+        path = cast(Union[PathLike, List[PathLike], Tuple[PathLike, ...]], path)
         if not isinstance(path, (tuple, list)):
             path = [path]
-        # end assure paths is list
-
-        self.git.archive(treeish, *path, **kwargs)
+        # END ensure paths is list (or tuple)
+        self.git.archive("--", treeish, *path, **kwargs)
         return self
 
+    def has_separate_working_tree(self) -> bool:
+        """
+        :return:
+            True if our :attr:`git_dir` is not at the root of our
+            :attr:`working_tree_dir`, but a ``.git`` file with a platform-agnostic
+            symbolic link. Our :attr:`git_dir` will be wherever the ``.git`` file points
+            to.
+
+        :note:
+            Bare repositories will always return ``False`` here.
+        """
+        if self.bare:
+            return False
+        if self.working_tree_dir:
+            return osp.isfile(osp.join(self.working_tree_dir, ".git"))
+        else:
+            return False  # Or raise Error?
+
     rev_parse = rev_parse
 
-    def __repr__(self):
-        return '<git.Repo "%s">' % self.git_dir
+    def __repr__(self) -> str:
+        clazz = self.__class__
+        return "<%s.%s %r>" % (clazz.__module__, clazz.__name__, self.git_dir)
+
+    def currently_rebasing_on(self) -> Commit | None:
+        """
+        :return:
+            The commit which is currently being replayed while rebasing.
+
+            ``None`` if we are not currently rebasing.
+        """
+        if self.git_dir:
+            rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD")
+        if not osp.isfile(rebase_head_file):
+            return None
+        with open(rebase_head_file, "rt") as f:
+            content = f.readline().strip()
+        return self.commit(content)
diff --git a/git/repo/fun.py b/git/repo/fun.py
index 1ee11ffcc..1c995c6c6 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -1,70 +1,137 @@
-"""Package with general repository related functions"""
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""General repository-related functions."""
+
+from __future__ import annotations
+
+__all__ = [
+    "rev_parse",
+    "is_git_dir",
+    "touch",
+    "find_submodule_git_dir",
+    "name_to_object",
+    "short_to_long",
+    "deref_tag",
+    "to_commit",
+    "find_worktree_git_dir",
+]
+
 import os
+import os.path as osp
+from pathlib import Path
+import stat
 from string import digits
 
-from gitdb.exc import (
-    BadObject,
-    BadName
-)
-from git.refs import SymbolicReference
+from gitdb.exc import BadName, BadObject
+
+from git.cmd import Git
+from git.exc import WorkTreeRepositoryUnsupported
 from git.objects import Object
-from gitdb.util import (
-    join,
-    isdir,
-    isfile,
-    dirname,
-    hex_to_bin,
-    bin_to_hex
-)
-from git.compat import xrange
-
-
-__all__ = ('rev_parse', 'is_git_dir', 'touch', 'find_git_dir', 'name_to_object', 'short_to_long', 'deref_tag',
-           'to_commit')
-
-
-def touch(filename):
-    fp = open(filename, "ab")
-    fp.close()
-
-
-def is_git_dir(d):
-    """ This is taken from the git setup.c:is_git_directory
-    function."""
-    if isdir(d) and \
-            isdir(join(d, 'objects')) and \
-            isdir(join(d, 'refs')):
-        headref = join(d, 'HEAD')
-        return isfile(headref) or \
-            (os.path.islink(headref) and
-             os.readlink(headref).startswith('refs'))
+from git.refs import SymbolicReference
+from git.util import cygpath, bin_to_hex, hex_to_bin
+
+# Typing ----------------------------------------------------------------------
+
+from typing import Optional, TYPE_CHECKING, Union, cast, overload
+
+from git.types import AnyGitObject, Literal, PathLike
+
+if TYPE_CHECKING:
+    from git.db import GitCmdObjectDB
+    from git.objects import Commit, TagObject
+    from git.refs.reference import Reference
+    from git.refs.tag import Tag
+
+    from .base import Repo
+
+# ----------------------------------------------------------------------------
+
+
+def touch(filename: str) -> str:
+    with open(filename, "ab"):
+        pass
+    return filename
+
+
+def is_git_dir(d: PathLike) -> bool:
+    """This is taken from the git setup.c:is_git_directory function.
+
+    :raise git.exc.WorkTreeRepositoryUnsupported:
+        If it sees a worktree directory. It's quite hacky to do that here, but at least
+        clearly indicates that we don't support it. There is the unlikely danger to
+        throw if we see directories which just look like a worktree dir, but are none.
+    """
+    if osp.isdir(d):
+        if (osp.isdir(osp.join(d, "objects")) or "GIT_OBJECT_DIRECTORY" in os.environ) and osp.isdir(
+            osp.join(d, "refs")
+        ):
+            headref = osp.join(d, "HEAD")
+            return osp.isfile(headref) or (osp.islink(headref) and os.readlink(headref).startswith("refs"))
+        elif (
+            osp.isfile(osp.join(d, "gitdir"))
+            and osp.isfile(osp.join(d, "commondir"))
+            and osp.isfile(osp.join(d, "gitfile"))
+        ):
+            raise WorkTreeRepositoryUnsupported(d)
     return False
 
 
-def find_git_dir(d):
+def find_worktree_git_dir(dotgit: PathLike) -> Optional[str]:
+    """Search for a gitdir for this worktree."""
+    try:
+        statbuf = os.stat(dotgit)
+    except OSError:
+        return None
+    if not stat.S_ISREG(statbuf.st_mode):
+        return None
+
+    try:
+        lines = Path(dotgit).read_text().splitlines()
+        for key, value in [line.strip().split(": ") for line in lines]:
+            if key == "gitdir":
+                return value
+    except ValueError:
+        pass
+    return None
+
+
+def find_submodule_git_dir(d: PathLike) -> Optional[PathLike]:
+    """Search for a submodule repo."""
     if is_git_dir(d):
         return d
 
     try:
         with open(d) as fp:
             content = fp.read().rstrip()
-    except (IOError, OSError):
-        # it's probably not a file
+    except IOError:
+        # It's probably not a file.
         pass
     else:
-        if content.startswith('gitdir: '):
+        if content.startswith("gitdir: "):
             path = content[8:]
-            if not os.path.isabs(path):
-                path = join(dirname(d), path)
-            return find_git_dir(path)
-    # end handle exception
+
+            if Git.is_cygwin():
+                # Cygwin creates submodules prefixed with `/cygdrive/...`.
+                # Cygwin git understands Cygwin paths much better than Windows ones.
+                # Also the Cygwin tests are assuming Cygwin paths.
+                path = cygpath(path)
+            if not osp.isabs(path):
+                path = osp.normpath(osp.join(osp.dirname(d), path))
+            return find_submodule_git_dir(path)
+    # END handle exception
     return None
 
 
-def short_to_long(odb, hexsha):
-    """:return: long hexadecimal sha1 from the given less-than-40 byte hexsha
-        or None if no candidate could be found.
-    :param hexsha: hexsha with less than 40 byte"""
+def short_to_long(odb: "GitCmdObjectDB", hexsha: str) -> Optional[bytes]:
+    """
+    :return:
+        Long hexadecimal sha1 from the given less than 40 byte hexsha, or ``None`` if no
+        candidate could be found.
+
+    :param hexsha:
+        hexsha with less than 40 bytes.
+    """
     try:
         return bin_to_hex(odb.partial_to_complete_sha_hex(hexsha))
     except BadObject:
@@ -72,29 +139,48 @@ def short_to_long(odb, hexsha):
     # END exception handling
 
 
-def name_to_object(repo, name, return_ref=False):
+@overload
+def name_to_object(repo: "Repo", name: str, return_ref: Literal[False] = ...) -> AnyGitObject: ...
+
+
+@overload
+def name_to_object(repo: "Repo", name: str, return_ref: Literal[True]) -> Union[AnyGitObject, SymbolicReference]: ...
+
+
+def name_to_object(repo: "Repo", name: str, return_ref: bool = False) -> Union[AnyGitObject, SymbolicReference]:
     """
-    :return: object specified by the given name, hexshas ( short and long )
-        as well as references are supported
-    :param return_ref: if name specifies a reference, we will return the reference
-        instead of the object. Otherwise it will raise BadObject or BadName
+    :return:
+        Object specified by the given name - hexshas (short and long) as well as
+        references are supported.
+
+    :param return_ref:
+        If ``True``, and name specifies a reference, we will return the reference
+        instead of the object. Otherwise it will raise :exc:`~gitdb.exc.BadObject` or
+        :exc:`~gitdb.exc.BadName`.
     """
-    hexsha = None
+    hexsha: Union[None, str, bytes] = None
 
-    # is it a hexsha ? Try the most common ones, which is 7 to 40
+    # Is it a hexsha? Try the most common ones, which is 7 to 40.
     if repo.re_hexsha_shortened.match(name):
         if len(name) != 40:
-            # find long sha for short sha
+            # Find long sha for short sha.
             hexsha = short_to_long(repo.odb, name)
         else:
             hexsha = name
         # END handle short shas
     # END find sha if it matches
 
-    # if we couldn't find an object for what seemed to be a short hexsha
-    # try to find it as reference anyway, it could be named 'aaa' for instance
+    # If we couldn't find an object for what seemed to be a short hexsha, try to find it
+    # as reference anyway, it could be named 'aaa' for instance.
     if hexsha is None:
-        for base in ('%s', 'refs/%s', 'refs/tags/%s', 'refs/heads/%s', 'refs/remotes/%s', 'refs/remotes/%s/HEAD'):
+        for base in (
+            "%s",
+            "refs/%s",
+            "refs/tags/%s",
+            "refs/heads/%s",
+            "refs/remotes/%s",
+            "refs/remotes/%s/HEAD",
+        ):
             try:
                 hexsha = SymbolicReference.dereference_recursive(repo, base % name)
                 if return_ref:
@@ -106,12 +192,12 @@ def name_to_object(repo, name, return_ref=False):
         # END for each base
     # END handle hexsha
 
-    # didn't find any ref, this is an error
+    # Didn't find any ref, this is an error.
     if return_ref:
         raise BadObject("Couldn't find reference named %r" % name)
     # END handle return ref
 
-    # tried everything ? fail
+    # Tried everything ? fail.
     if hexsha is None:
         raise BadName(name)
     # END assert hexsha was found
@@ -119,8 +205,8 @@ def name_to_object(repo, name, return_ref=False):
     return Object.new_from_sha(repo, hex_to_bin(hexsha))
 
 
-def deref_tag(tag):
-    """Recursively dereerence a tag and return the resulting object"""
+def deref_tag(tag: "Tag") -> AnyGitObject:
+    """Recursively dereference a tag and return the resulting object."""
     while True:
         try:
             tag = tag.object
@@ -130,9 +216,9 @@ def deref_tag(tag):
     return tag
 
 
-def to_commit(obj):
-    """Convert the given object to a commit if possible and return it"""
-    if obj.type == 'tag':
+def to_commit(obj: Object) -> "Commit":
+    """Convert the given object to a commit if possible and return it."""
+    if obj.type == "tag":
         obj = deref_tag(obj)
 
     if obj.type != "commit":
@@ -141,25 +227,39 @@ def to_commit(obj):
     return obj
 
 
-def rev_parse(repo, rev):
+def rev_parse(repo: "Repo", rev: str) -> AnyGitObject:
+    """Parse a revision string. Like :manpage:`git-rev-parse(1)`.
+
+    :return:
+        `~git.objects.base.Object` at the given revision.
+
+        This may be any type of git object:
+
+        * :class:`Commit <git.objects.commit.Commit>`
+        * :class:`TagObject <git.objects.tag.TagObject>`
+        * :class:`Tree <git.objects.tree.Tree>`
+        * :class:`Blob <git.objects.blob.Blob>`
+
+    :param rev:
+        :manpage:`git-rev-parse(1)`-compatible revision specification as string.
+        Please see :manpage:`git-rev-parse(1)` for details.
+
+    :raise gitdb.exc.BadObject:
+        If the given revision could not be found.
+
+    :raise ValueError:
+        If `rev` couldn't be parsed.
+
+    :raise IndexError:
+        If an invalid reflog index is specified.
     """
-    :return: Object at the given revision, either Commit, Tag, Tree or Blob
-    :param rev: git-rev-parse compatible revision specification as string, please see
-        http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html
-        for details
-    :note: Currently there is no access to the rev-log, rev-specs may only contain
-        topological tokens such ~ and ^.
-    :raise BadObject: if the given revision could not be found
-    :raise ValueError: If rev couldn't be parsed
-    :raise IndexError: If invalid reflog index is specified"""
-
-    # colon search mode ?
-    if rev.startswith(':/'):
-        # colon search mode
-        raise NotImplementedError("commit by message search ( regex )")
+    # Are we in colon search mode?
+    if rev.startswith(":/"):
+        # Colon search mode
+        raise NotImplementedError("commit by message search (regex)")
     # END handle search
 
-    obj = None
+    obj: Optional[AnyGitObject] = None
     ref = None
     output_type = "commit"
     start = 0
@@ -174,85 +274,93 @@ def rev_parse(repo, rev):
         token = rev[start]
 
         if obj is None:
-            # token is a rev name
+            # token is a rev name.
             if start == 0:
                 ref = repo.head.ref
             else:
-                if token == '@':
-                    ref = name_to_object(repo, rev[:start], return_ref=True)
+                if token == "@":
+                    ref = cast("Reference", name_to_object(repo, rev[:start], return_ref=True))
                 else:
                     obj = name_to_object(repo, rev[:start])
                 # END handle token
             # END handle refname
-
+        else:
             if ref is not None:
-                obj = ref.commit
+                obj = cast("Commit", ref.commit)
             # END handle ref
         # END initialize obj on first token
 
         start += 1
 
-        # try to parse {type}
-        if start < lr and rev[start] == '{':
-            end = rev.find('}', start)
+        # Try to parse {type}.
+        if start < lr and rev[start] == "{":
+            end = rev.find("}", start)
             if end == -1:
                 raise ValueError("Missing closing brace to define type in %s" % rev)
-            output_type = rev[start + 1:end]  # exclude brace
+            output_type = rev[start + 1 : end]  # Exclude brace.
 
-            # handle type
-            if output_type == 'commit':
-                pass  # default
-            elif output_type == 'tree':
+            # Handle type.
+            if output_type == "commit":
+                obj = cast("TagObject", obj)
+                if obj and obj.type == "tag":
+                    obj = deref_tag(obj)
+                else:
+                    # Cannot do anything for non-tags.
+                    pass
+                # END handle tag
+            elif output_type == "tree":
                 try:
+                    obj = cast(AnyGitObject, obj)
                     obj = to_commit(obj).tree
                 except (AttributeError, ValueError):
-                    pass    # error raised later
+                    pass  # Error raised later.
                 # END exception handling
-            elif output_type in ('', 'blob'):
-                if obj.type == 'tag':
+            elif output_type in ("", "blob"):
+                obj = cast("TagObject", obj)
+                if obj and obj.type == "tag":
                     obj = deref_tag(obj)
                 else:
-                    # cannot do anything for non-tags
+                    # Cannot do anything for non-tags.
                     pass
                 # END handle tag
-            elif token == '@':
+            elif token == "@":
                 # try single int
-                assert ref is not None, "Requre Reference to access reflog"
+                assert ref is not None, "Require Reference to access reflog"
                 revlog_index = None
                 try:
-                    # transform reversed index into the format of our revlog
+                    # Transform reversed index into the format of our revlog.
                     revlog_index = -(int(output_type) + 1)
-                except ValueError:
-                    # TODO: Try to parse the other date options, using parse_date
-                    # maybe
-                    raise NotImplementedError("Support for additional @{...} modes not implemented")
+                except ValueError as e:
+                    # TODO: Try to parse the other date options, using parse_date maybe.
+                    raise NotImplementedError("Support for additional @{...} modes not implemented") from e
                 # END handle revlog index
 
                 try:
                     entry = ref.log_entry(revlog_index)
-                except IndexError:
-                    raise IndexError("Invalid revlog index: %i" % revlog_index)
+                except IndexError as e:
+                    raise IndexError("Invalid revlog index: %i" % revlog_index) from e
                 # END handle index out of bound
 
                 obj = Object.new_from_sha(repo, hex_to_bin(entry.newhexsha))
 
-                # make it pass the following checks
-                output_type = None
+                # Make it pass the following checks.
+                output_type = ""
             else:
                 raise ValueError("Invalid output type: %s ( in %s )" % (output_type, rev))
             # END handle output type
 
-            # empty output types don't require any specific type, its just about dereferencing tags
-            if output_type and obj.type != output_type:
-                raise ValueError("Could not accomodate requested object type %r, got %s" % (output_type, obj.type))
-            # END verify ouput type
+            # Empty output types don't require any specific type, its just about
+            # dereferencing tags.
+            if output_type and obj and obj.type != output_type:
+                raise ValueError("Could not accommodate requested object type %r, got %s" % (output_type, obj.type))
+            # END verify output type
 
-            start = end + 1                   # skip brace
+            start = end + 1  # Skip brace.
             parsed_to = start
             continue
         # END parse type
 
-        # try to parse a number
+        # Try to parse a number.
         num = 0
         if token != ":":
             found_digit = False
@@ -266,24 +374,24 @@ def rev_parse(repo, rev):
                 # END handle number
             # END number parse loop
 
-            # no explicit number given, 1 is the default
-            # It could be 0 though
+            # No explicit number given, 1 is the default. It could be 0 though.
             if not found_digit:
                 num = 1
             # END set default num
         # END number parsing only if non-blob mode
 
         parsed_to = start
-        # handle hiererarchy walk
+        # Handle hierarchy walk.
         try:
+            obj = cast(AnyGitObject, obj)
             if token == "~":
                 obj = to_commit(obj)
-                for item in xrange(num):
+                for _ in range(num):
                     obj = obj.parents[0]
                 # END for each history item to walk
             elif token == "^":
                 obj = to_commit(obj)
-                # must be n'th parent
+                # Must be n'th parent.
                 if num:
                     obj = obj.parents[num - 1]
             elif token == ":":
@@ -295,12 +403,14 @@ def rev_parse(repo, rev):
             else:
                 raise ValueError("Invalid token: %r" % token)
             # END end handle tag
-        except (IndexError, AttributeError):
-            raise BadObject("Invalid Revision in %s" % rev)
+        except (IndexError, AttributeError) as e:
+            raise BadName(
+                f"Invalid revision spec '{rev}' - not enough parent commits to reach '{token}{int(num)}'"
+            ) from e
         # END exception handling
     # END parse loop
 
-    # still no obj ? Its probably a simple name
+    # Still no obj? It's probably a simple name.
     if obj is None:
         obj = name_to_object(repo, rev)
         parsed_to = lr
diff --git a/git/test/__init__.py b/git/test/__init__.py
deleted file mode 100644
index 757cbad1f..000000000
--- a/git/test/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# __init__.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
diff --git a/git/test/fixtures/diff_numstat b/git/test/fixtures/diff_numstat
deleted file mode 100644
index 44c6ca2d5..000000000
--- a/git/test/fixtures/diff_numstat
+++ /dev/null
@@ -1,2 +0,0 @@
-29	18	a.txt
-0	5	b.txt
diff --git a/git/test/lib/__init__.py b/git/test/lib/__init__.py
deleted file mode 100644
index 87e267520..000000000
--- a/git/test/lib/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# __init__.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-# flake8: noqa
-import inspect
-from .asserts import *
-from .helper import *
-
-__all__ = [name for name, obj in locals().items()
-           if not (name.startswith('_') or inspect.ismodule(obj))]
diff --git a/git/test/lib/asserts.py b/git/test/lib/asserts.py
deleted file mode 100644
index 60a888b3b..000000000
--- a/git/test/lib/asserts.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# asserts.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-import re
-import stat
-
-from nose.tools import (
-    assert_equal,
-    assert_not_equal,
-    assert_raises,
-    raises,
-    assert_true,
-    assert_false
-)
-
-from mock import patch
-
-__all__ = ['assert_instance_of', 'assert_not_instance_of',
-           'assert_none', 'assert_not_none',
-           'assert_match', 'assert_not_match', 'assert_mode_644',
-           'assert_mode_755',
-           'assert_equal', 'assert_not_equal', 'assert_raises', 'patch', 'raises',
-           'assert_true', 'assert_false']
-
-
-def assert_instance_of(expected, actual, msg=None):
-    """Verify that object is an instance of expected """
-    assert isinstance(actual, expected), msg
-
-
-def assert_not_instance_of(expected, actual, msg=None):
-    """Verify that object is not an instance of expected """
-    assert not isinstance(actual, expected, msg)
-
-
-def assert_none(actual, msg=None):
-    """verify that item is None"""
-    assert actual is None, msg
-
-
-def assert_not_none(actual, msg=None):
-    """verify that item is None"""
-    assert actual is not None, msg
-
-
-def assert_match(pattern, string, msg=None):
-    """verify that the pattern matches the string"""
-    assert_not_none(re.search(pattern, string), msg)
-
-
-def assert_not_match(pattern, string, msg=None):
-    """verify that the pattern does not match the string"""
-    assert_none(re.search(pattern, string), msg)
-
-
-def assert_mode_644(mode):
-    """Verify given mode is 644"""
-    assert (mode & stat.S_IROTH) and (mode & stat.S_IRGRP)
-    assert (mode & stat.S_IWUSR) and (mode & stat.S_IRUSR) and not (mode & stat.S_IXUSR)
-
-
-def assert_mode_755(mode):
-    """Verify given mode is 755"""
-    assert (mode & stat.S_IROTH) and (mode & stat.S_IRGRP) and (mode & stat.S_IXOTH) and (mode & stat.S_IXGRP)
-    assert (mode & stat.S_IWUSR) and (mode & stat.S_IRUSR) and (mode & stat.S_IXUSR)
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
deleted file mode 100644
index c5c5a6201..000000000
--- a/git/test/lib/helper.py
+++ /dev/null
@@ -1,301 +0,0 @@
-# helper.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-from __future__ import print_function
-import os
-import sys
-from unittest import TestCase
-import time
-import tempfile
-import shutil
-import io
-
-from git import Repo, Remote, GitCommandError, Git
-from git.compat import string_types
-
-GIT_REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
-
-__all__ = (
-    'fixture_path', 'fixture', 'absolute_project_path', 'StringProcessAdapter',
-    'with_rw_repo', 'with_rw_and_rw_remote_repo', 'TestBase', 'TestCase', 'GIT_REPO'
-)
-
-#{ Routines
-
-
-def fixture_path(name):
-    test_dir = os.path.dirname(os.path.dirname(__file__))
-    return os.path.join(test_dir, "fixtures", name)
-
-
-def fixture(name):
-    return open(fixture_path(name), 'rb').read()
-
-
-def absolute_project_path():
-    return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
-
-#} END routines
-
-#{ Adapters
-
-
-class StringProcessAdapter(object):
-
-    """Allows to use strings as Process object as returned by SubProcess.Popen.
-    Its tailored to work with the test system only"""
-
-    def __init__(self, input_string):
-        self.stdout = io.BytesIO(input_string)
-        self.stderr = io.BytesIO()
-
-    def wait(self):
-        return 0
-
-    poll = wait
-
-#} END adapters
-
-#{ Decorators
-
-
-def _mktemp(*args):
-    """Wrapper around default tempfile.mktemp to fix an osx issue
-    :note: the OSX special case was removed as it was unclear why that was needed in the first place. It seems
-    to be just fine without it. However, if we leave this special case, and if TMPDIR is set to something custom,
-    prefixing /private/ will lead to incorrect paths on OSX."""
-    tdir = tempfile.mktemp(*args)
-    # See :note: above to learn why this is comented out.
-    # if sys.platform == 'darwin':
-    #     tdir = '/private' + tdir
-    return tdir
-
-
-def _rmtree_onerror(osremove, fullpath, exec_info):
-    """
-    Handle the case on windows that read-only files cannot be deleted by
-    os.remove by setting it to mode 777, then retry deletion.
-    """
-    if os.name != 'nt' or osremove is not os.remove:
-        raise
-
-    os.chmod(fullpath, 0o777)
-    os.remove(fullpath)
-
-
-def with_rw_repo(working_tree_ref, bare=False):
-    """
-    Same as with_bare_repo, but clones the rorepo as non-bare repository, checking
-    out the working tree at the given working_tree_ref.
-
-    This repository type is more costly due to the working copy checkout.
-
-    To make working with relative paths easier, the cwd will be set to the working
-    dir of the repository.
-    """
-    assert isinstance(working_tree_ref, string_types), "Decorator requires ref name for working tree checkout"
-
-    def argument_passer(func):
-        def repo_creator(self):
-            prefix = 'non_'
-            if bare:
-                prefix = ''
-            # END handle prefix
-            repo_dir = _mktemp("%sbare_%s" % (prefix, func.__name__))
-            rw_repo = self.rorepo.clone(repo_dir, shared=True, bare=bare, n=True)
-
-            rw_repo.head.commit = rw_repo.commit(working_tree_ref)
-            if not bare:
-                rw_repo.head.reference.checkout()
-            # END handle checkout
-
-            prev_cwd = os.getcwd()
-            os.chdir(rw_repo.working_dir)
-            try:
-                try:
-                    return func(self, rw_repo)
-                except:
-                    print("Keeping repo after failure: %s" % repo_dir, file=sys.stderr)
-                    repo_dir = None
-                    raise
-            finally:
-                os.chdir(prev_cwd)
-                rw_repo.git.clear_cache()
-                if repo_dir is not None:
-                    shutil.rmtree(repo_dir, onerror=_rmtree_onerror)
-                # END rm test repo if possible
-            # END cleanup
-        # END rw repo creator
-        repo_creator.__name__ = func.__name__
-        return repo_creator
-    # END argument passer
-    return argument_passer
-
-
-def with_rw_and_rw_remote_repo(working_tree_ref):
-    """
-    Same as with_rw_repo, but also provides a writable remote repository from which the
-    rw_repo has been forked as well as a handle for a git-daemon that may be started to
-    run the remote_repo.
-    The remote repository was cloned as bare repository from the rorepo, wheras
-    the rw repo has a working tree and was cloned from the remote repository.
-
-    remote_repo has two remotes: origin and daemon_origin. One uses a local url,
-    the other uses a server url. The daemon setup must be done on system level
-    and should be an inetd service that serves tempdir.gettempdir() and all
-    directories in it.
-
-    The following scetch demonstrates this::
-     rorepo ---<bare clone>---> rw_remote_repo ---<clone>---> rw_repo
-
-    The test case needs to support the following signature::
-        def case(self, rw_repo, rw_remote_repo)
-
-    This setup allows you to test push and pull scenarios and hooks nicely.
-
-    See working dir info in with_rw_repo
-    :note: We attempt to launch our own invocation of git-daemon, which will be shutdown at the end of the test.
-    """
-    assert isinstance(working_tree_ref, string_types), "Decorator requires ref name for working tree checkout"
-
-    def argument_passer(func):
-        def remote_repo_creator(self):
-            remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__)
-            repo_dir = _mktemp("remote_clone_non_bare_repo")
-
-            rw_remote_repo = self.rorepo.clone(remote_repo_dir, shared=True, bare=True)
-            # recursive alternates info ?
-            rw_repo = rw_remote_repo.clone(repo_dir, shared=True, bare=False, n=True)
-            rw_repo.head.commit = working_tree_ref
-            rw_repo.head.reference.checkout()
-
-            # prepare for git-daemon
-            rw_remote_repo.daemon_export = True
-
-            # this thing is just annoying !
-            crw = rw_remote_repo.config_writer()
-            section = "daemon"
-            try:
-                crw.add_section(section)
-            except Exception:
-                pass
-            crw.set(section, "receivepack", True)
-            # release lock
-            crw.release()
-            del(crw)
-
-            # initialize the remote - first do it as local remote and pull, then
-            # we change the url to point to the daemon. The daemon should be started
-            # by the user, not by us
-            d_remote = Remote.create(rw_repo, "daemon_origin", remote_repo_dir)
-            d_remote.fetch()
-            remote_repo_url = "git://localhost%s" % remote_repo_dir
-
-            d_remote.config_writer.set('url', remote_repo_url)
-
-            temp_dir = os.path.dirname(_mktemp())
-            # On windows, this will fail ... we deal with failures anyway and default to telling the user to do it
-            try:
-                gd = Git().daemon(temp_dir, enable='receive-pack', as_process=True)
-                # yes, I know ... fortunately, this is always going to work if sleep time is just large enough
-                time.sleep(0.5)
-            except Exception:
-                gd = None
-            # end
-
-            # try to list remotes to diagnoes whether the server is up
-            try:
-                rw_repo.git.ls_remote(d_remote)
-            except GitCommandError as e:
-                # We assume in good faith that we didn't start the daemon - but make sure we kill it anyway
-                # Of course we expect it to work here already, but maybe there are timing constraints
-                # on some platforms ?
-                if gd is not None:
-                    os.kill(gd.proc.pid, 15)
-                print(str(e))
-                if os.name == 'nt':
-                    msg = "git-daemon needs to run this test, but windows does not have one. "
-                    msg += 'Otherwise, run: git-daemon "%s"' % temp_dir
-                    raise AssertionError(msg)
-                else:
-                    msg = 'Please start a git-daemon to run this test, execute: git daemon --enable=receive-pack "%s"'
-                    msg %= temp_dir
-                    raise AssertionError(msg)
-                # END make assertion
-            # END catch ls remote error
-
-            # adjust working dir
-            prev_cwd = os.getcwd()
-            os.chdir(rw_repo.working_dir)
-            try:
-                return func(self, rw_repo, rw_remote_repo)
-            finally:
-                # gd.proc.kill() ... no idea why that doesn't work
-                if gd is not None:
-                    os.kill(gd.proc.pid, 15)
-
-                os.chdir(prev_cwd)
-                rw_repo.git.clear_cache()
-                rw_remote_repo.git.clear_cache()
-                shutil.rmtree(repo_dir, onerror=_rmtree_onerror)
-                shutil.rmtree(remote_repo_dir, onerror=_rmtree_onerror)
-
-                if gd is not None:
-                    gd.proc.wait()
-            # END cleanup
-        # END bare repo creator
-        remote_repo_creator.__name__ = func.__name__
-        return remote_repo_creator
-        # END remote repo creator
-    # END argument parsser
-
-    return argument_passer
-
-#} END decorators
-
-
-class TestBase(TestCase):
-
-    """
-    Base Class providing default functionality to all tests such as:
-
-    - Utility functions provided by the TestCase base of the unittest method such as::
-        self.fail("todo")
-        self.failUnlessRaises(...)
-
-    - Class level repository which is considered read-only as it is shared among
-      all test cases in your type.
-      Access it using::
-       self.rorepo  # 'ro' stands for read-only
-
-      The rorepo is in fact your current project's git repo. If you refer to specific
-      shas for your objects, be sure you choose some that are part of the immutable portion
-      of the project history ( to assure tests don't fail for others ).
-    """
-
-    @classmethod
-    def setUpClass(cls):
-        """
-        Dynamically add a read-only repository to our actual type. This way
-        each test type has its own repository
-        """
-        cls.rorepo = Repo(GIT_REPO)
-
-    @classmethod
-    def tearDownClass(cls):
-        cls.rorepo.git.clear_cache()
-        cls.rorepo.git = None
-
-    def _make_file(self, rela_path, data, repo=None):
-        """
-        Create a file at the given path relative to our repository, filled
-        with the given data. Returns absolute path to created file.
-        """
-        repo = repo or self.rorepo
-        abs_path = os.path.join(repo.working_tree_dir, rela_path)
-        fp = open(abs_path, "w")
-        fp.write(data)
-        fp.close()
-        return abs_path
diff --git a/git/test/performance/lib.py b/git/test/performance/lib.py
deleted file mode 100644
index bb3f7a998..000000000
--- a/git/test/performance/lib.py
+++ /dev/null
@@ -1,95 +0,0 @@
-"""Contains library functions"""
-import os
-from git.test.lib import (
-    TestBase
-)
-from gitdb.test.lib import skip_on_travis_ci
-import shutil
-import tempfile
-import logging
-
-from git.db import (
-    GitCmdObjectDB,
-    GitDB
-)
-
-from git import (
-    Repo
-)
-
-#{ Invvariants
-k_env_git_repo = "GIT_PYTHON_TEST_GIT_REPO_BASE"
-#} END invariants
-
-
-#{ Base Classes
-
-class TestBigRepoR(TestBase):
-
-    """TestCase providing access to readonly 'big' repositories using the following
-    member variables:
-
-    * gitrorepo
-
-     * Read-Only git repository - actually the repo of git itself
-
-    * puregitrorepo
-
-     * As gitrepo, but uses pure python implementation
-    """
-
-    #{ Invariants
-    #} END invariants
-
-    def setUp(self):
-        # This will raise on travis, which is what we want to happen early as to prevent us to do any work
-        skip_on_travis_ci(lambda *args: None)(self)
-        try:
-            super(TestBigRepoR, self).setUp()
-        except AttributeError:
-            pass
-
-        repo_path = os.environ.get(k_env_git_repo)
-        if repo_path is None:
-            logging.info(
-                ("You can set the %s environment variable to a .git repository of" % k_env_git_repo) +
-                "your choice - defaulting to the gitpython repository")
-            repo_path = os.path.dirname(__file__)
-        # end set some repo path
-        self.gitrorepo = Repo(repo_path, odbt=GitCmdObjectDB, search_parent_directories=True)
-        self.puregitrorepo = Repo(repo_path, odbt=GitDB, search_parent_directories=True)
-
-    def tearDown(self):
-        self.gitrorepo.git.clear_cache()
-        self.gitrorepo = None
-        self.puregitrorepo.git.clear_cache()
-        self.puregitrorepo = None
-
-
-class TestBigRepoRW(TestBigRepoR):
-
-    """As above, but provides a big repository that we can write to.
-
-    Provides ``self.gitrwrepo`` and ``self.puregitrwrepo``"""
-
-    def setUp(self):
-        self.gitrwrepo = None
-        try:
-            super(TestBigRepoRW, self).setUp()
-        except AttributeError:
-            pass
-        dirname = tempfile.mktemp()
-        os.mkdir(dirname)
-        self.gitrwrepo = self.gitrorepo.clone(dirname, shared=True, bare=True, odbt=GitCmdObjectDB)
-        self.puregitrwrepo = Repo(dirname, odbt=GitDB)
-
-    def tearDown(self):
-        super(TestBigRepoRW, self).tearDown()
-        if self.gitrwrepo is not None:
-            shutil.rmtree(self.gitrwrepo.working_dir)
-            self.gitrwrepo.git.clear_cache()
-        self.gitrwrepo = None
-        self.puregitrwrepo.git.clear_cache()
-        self.puregitrwrepo = None
-
-#} END base classes
diff --git a/git/test/performance/test_commit.py b/git/test/performance/test_commit.py
deleted file mode 100644
index 7d3e87c4c..000000000
--- a/git/test/performance/test_commit.py
+++ /dev/null
@@ -1,105 +0,0 @@
-# test_performance.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-from __future__ import print_function
-from io import BytesIO
-from time import time
-import sys
-
-from .lib import TestBigRepoRW
-from git import Commit
-from gitdb import IStream
-from git.compat import xrange
-from git.test.test_commit import assert_commit_serialization
-
-
-class TestPerformance(TestBigRepoRW):
-
-    # ref with about 100 commits in its history
-    ref_100 = '0.1.6'
-
-    def _query_commit_info(self, c):
-        c.author
-        c.authored_date
-        c.author_tz_offset
-        c.committer
-        c.committed_date
-        c.committer_tz_offset
-        c.message
-        c.parents
-
-    def test_iteration(self):
-        no = 0
-        nc = 0
-
-        # find the first commit containing the given path - always do a full
-        # iteration ( restricted to the path in question ), but in fact it should
-        # return quite a lot of commits, we just take one and hence abort the operation
-
-        st = time()
-        for c in self.rorepo.iter_commits(self.ref_100):
-            nc += 1
-            self._query_commit_info(c)
-            for obj in c.tree.traverse():
-                obj.size
-                no += 1
-            # END for each object
-        # END for each commit
-        elapsed_time = time() - st
-        print("Traversed %i Trees and a total of %i unchached objects in %s [s] ( %f objs/s )"
-              % (nc, no, elapsed_time, no / elapsed_time), file=sys.stderr)
-
-    def test_commit_traversal(self):
-        # bound to cat-file parsing performance
-        nc = 0
-        st = time()
-        for c in self.gitrorepo.commit().traverse(branch_first=False):
-            nc += 1
-            self._query_commit_info(c)
-        # END for each traversed commit
-        elapsed_time = time() - st
-        print("Traversed %i Commits in %s [s] ( %f commits/s )"
-              % (nc, elapsed_time, nc / elapsed_time), file=sys.stderr)
-
-    def test_commit_iteration(self):
-        # bound to stream parsing performance
-        nc = 0
-        st = time()
-        for c in Commit.iter_items(self.gitrorepo, self.gitrorepo.head):
-            nc += 1
-            self._query_commit_info(c)
-        # END for each traversed commit
-        elapsed_time = time() - st
-        print("Iterated %i Commits in %s [s] ( %f commits/s )"
-              % (nc, elapsed_time, nc / elapsed_time), file=sys.stderr)
-
-    def test_commit_serialization(self):
-        assert_commit_serialization(self.gitrwrepo, self.gitrwrepo.head, True)
-
-        rwrepo = self.gitrwrepo
-        make_object = rwrepo.odb.store
-        # direct serialization - deserialization can be tested afterwards
-        # serialization is probably limited on IO
-        hc = rwrepo.commit(rwrepo.head)
-
-        nc = 5000
-        st = time()
-        for i in xrange(nc):
-            cm = Commit(rwrepo, Commit.NULL_BIN_SHA, hc.tree,
-                        hc.author, hc.authored_date, hc.author_tz_offset,
-                        hc.committer, hc.committed_date, hc.committer_tz_offset,
-                        str(i), parents=hc.parents, encoding=hc.encoding)
-
-            stream = BytesIO()
-            cm._serialize(stream)
-            slen = stream.tell()
-            stream.seek(0)
-
-            cm.binsha = make_object(IStream(Commit.type, slen, stream)).binsha
-        # END commit creation
-        elapsed = time() - st
-
-        print("Serialized %i commits to loose objects in %f s ( %f commits / s )"
-              % (nc, elapsed, nc / elapsed), file=sys.stderr)
diff --git a/git/test/performance/test_streams.py b/git/test/performance/test_streams.py
deleted file mode 100644
index 4b1738cdf..000000000
--- a/git/test/performance/test_streams.py
+++ /dev/null
@@ -1,145 +0,0 @@
-"""Performance data streaming performance"""
-from __future__ import print_function
-
-from time import time
-import os
-import sys
-import subprocess
-
-from git.test.lib import (
-    with_rw_repo
-)
-from gitdb.util import bin_to_hex
-from gitdb.test.lib import make_memory_file
-
-from .lib import (
-    TestBigRepoR
-)
-
-from gitdb import (
-    LooseObjectDB,
-    IStream
-)
-
-
-class TestObjDBPerformance(TestBigRepoR):
-
-    large_data_size_bytes = 1000 * 1000 * 10        # some MiB should do it
-    moderate_data_size_bytes = 1000 * 1000 * 1      # just 1 MiB
-
-    @with_rw_repo('HEAD', bare=True)
-    def test_large_data_streaming(self, rwrepo):
-        # TODO: This part overlaps with the same file in gitdb.test.performance.test_stream
-        # It should be shared if possible
-        ldb = LooseObjectDB(os.path.join(rwrepo.git_dir, 'objects'))
-
-        for randomize in range(2):
-            desc = (randomize and 'random ') or ''
-            print("Creating %s data ..." % desc, file=sys.stderr)
-            st = time()
-            size, stream = make_memory_file(self.large_data_size_bytes, randomize)
-            elapsed = time() - st
-            print("Done (in %f s)" % elapsed, file=sys.stderr)
-
-            # writing - due to the compression it will seem faster than it is
-            st = time()
-            binsha = ldb.store(IStream('blob', size, stream)).binsha
-            elapsed_add = time() - st
-            assert ldb.has_object(binsha)
-            db_file = ldb.readable_db_object_path(bin_to_hex(binsha))
-            fsize_kib = os.path.getsize(db_file) / 1000
-
-            size_kib = size / 1000
-            msg = "Added %i KiB (filesize = %i KiB) of %s data to loose odb in %f s ( %f Write KiB / s)"
-            msg %= (size_kib, fsize_kib, desc, elapsed_add, size_kib / elapsed_add)
-            print(msg, file=sys.stderr)
-
-            # reading all at once
-            st = time()
-            ostream = ldb.stream(binsha)
-            shadata = ostream.read()
-            elapsed_readall = time() - st
-
-            stream.seek(0)
-            assert shadata == stream.getvalue()
-            msg = "Read %i KiB of %s data at once from loose odb in %f s ( %f Read KiB / s)"
-            msg %= (size_kib, desc, elapsed_readall, size_kib / elapsed_readall)
-            print(msg, file=sys.stderr)
-
-            # reading in chunks of 1 MiB
-            cs = 512 * 1000
-            chunks = list()
-            st = time()
-            ostream = ldb.stream(binsha)
-            while True:
-                data = ostream.read(cs)
-                chunks.append(data)
-                if len(data) < cs:
-                    break
-            # END read in chunks
-            elapsed_readchunks = time() - st
-
-            stream.seek(0)
-            assert b''.join(chunks) == stream.getvalue()
-
-            cs_kib = cs / 1000
-            print("Read %i KiB of %s data in %i KiB chunks from loose odb in %f s ( %f Read KiB / s)"
-                  % (size_kib, desc, cs_kib, elapsed_readchunks, size_kib / elapsed_readchunks), file=sys.stderr)
-
-            # del db file so git has something to do
-            os.remove(db_file)
-
-            # VS. CGIT
-            ##########
-            # CGIT ! Can using the cgit programs be faster ?
-            proc = rwrepo.git.hash_object('-w', '--stdin', as_process=True, istream=subprocess.PIPE)
-
-            # write file - pump everything in at once to be a fast as possible
-            data = stream.getvalue()    # cache it
-            st = time()
-            proc.stdin.write(data)
-            proc.stdin.close()
-            gitsha = proc.stdout.read().strip()
-            proc.wait()
-            gelapsed_add = time() - st
-            del(data)
-            assert gitsha == bin_to_hex(binsha)     # we do it the same way, right ?
-
-            #  as its the same sha, we reuse our path
-            fsize_kib = os.path.getsize(db_file) / 1000
-            msg = "Added %i KiB (filesize = %i KiB) of %s data to using git-hash-object in %f s ( %f Write KiB / s)"
-            msg %= (size_kib, fsize_kib, desc, gelapsed_add, size_kib / gelapsed_add)
-            print(msg, file=sys.stderr)
-
-            # compare ...
-            print("Git-Python is %f %% faster than git when adding big %s files"
-                  % (100.0 - (elapsed_add / gelapsed_add) * 100, desc), file=sys.stderr)
-
-            # read all
-            st = time()
-            s, t, size, data = rwrepo.git.get_object_data(gitsha)
-            gelapsed_readall = time() - st
-            print("Read %i KiB of %s data at once using git-cat-file in %f s ( %f Read KiB / s)"
-                  % (size_kib, desc, gelapsed_readall, size_kib / gelapsed_readall), file=sys.stderr)
-
-            # compare
-            print("Git-Python is %f %% faster than git when reading big %sfiles"
-                  % (100.0 - (elapsed_readall / gelapsed_readall) * 100, desc), file=sys.stderr)
-
-            # read chunks
-            st = time()
-            s, t, size, stream = rwrepo.git.stream_object_data(gitsha)
-            while True:
-                data = stream.read(cs)
-                if len(data) < cs:
-                    break
-            # END read stream
-            gelapsed_readchunks = time() - st
-            msg = "Read %i KiB of %s data in %i KiB chunks from git-cat-file in %f s ( %f Read KiB / s)"
-            msg %= (size_kib, desc, cs_kib, gelapsed_readchunks, size_kib / gelapsed_readchunks)
-            print(msg, file=sys.stderr)
-
-            # compare
-            print("Git-Python is %f %% faster than git when reading big %s files in chunks"
-                  % (100.0 - (elapsed_readchunks / gelapsed_readchunks) * 100, desc), file=sys.stderr)
-        # END for each randomization factor
diff --git a/git/test/test_base.py b/git/test/test_base.py
deleted file mode 100644
index 91b9d0053..000000000
--- a/git/test/test_base.py
+++ /dev/null
@@ -1,132 +0,0 @@
-#-*-coding:utf-8-*-
-# test_base.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-import os
-import tempfile
-
-import git.objects.base as base
-from git.test.lib import (
-    TestBase,
-    assert_raises,
-    with_rw_repo,
-    with_rw_and_rw_remote_repo
-)
-from git import (
-    Blob,
-    Tree,
-    Commit,
-    TagObject
-)
-from git.objects.util import get_object_type_by_name
-from gitdb.util import hex_to_bin
-
-
-class TestBase(TestBase):
-
-    type_tuples = (("blob", "8741fc1d09d61f02ffd8cded15ff603eff1ec070", "blob.py"),
-                   ("tree", "3a6a5e3eeed3723c09f1ef0399f81ed6b8d82e79", "directory"),
-                   ("commit", "4251bd59fb8e11e40c40548cba38180a9536118c", None),
-                   ("tag", "e56a60e8e9cd333cfba0140a77cd12b0d9398f10", None))
-
-    def test_base_object(self):
-        # test interface of base object classes
-        types = (Blob, Tree, Commit, TagObject)
-        assert len(types) == len(self.type_tuples)
-
-        s = set()
-        num_objs = 0
-        num_index_objs = 0
-        for obj_type, (typename, hexsha, path) in zip(types, self.type_tuples):
-            binsha = hex_to_bin(hexsha)
-            item = None
-            if path is None:
-                item = obj_type(self.rorepo, binsha)
-            else:
-                item = obj_type(self.rorepo, binsha, 0, path)
-            # END handle index objects
-            num_objs += 1
-            assert item.hexsha == hexsha
-            assert item.type == typename
-            assert item.size
-            assert item == item
-            assert not item != item
-            assert str(item) == item.hexsha
-            assert repr(item)
-            s.add(item)
-
-            if isinstance(item, base.IndexObject):
-                num_index_objs += 1
-                if hasattr(item, 'path'):                        # never runs here
-                    assert not item.path.startswith("/")        # must be relative
-                    assert isinstance(item.mode, int)
-            # END index object check
-
-            # read from stream
-            data_stream = item.data_stream
-            data = data_stream.read()
-            assert data
-
-            tmpfilename = tempfile.mktemp(suffix='test-stream')
-            tmpfile = open(tmpfilename, 'wb+')
-            assert item == item.stream_data(tmpfile)
-            tmpfile.seek(0)
-            assert tmpfile.read() == data
-            tmpfile.close()
-            os.remove(tmpfilename)
-            # END stream to file directly
-        # END for each object type to create
-
-        # each has a unique sha
-        assert len(s) == num_objs
-        assert len(s | s) == num_objs
-        assert num_index_objs == 2
-
-    def test_get_object_type_by_name(self):
-        for tname in base.Object.TYPES:
-            assert base.Object in get_object_type_by_name(tname).mro()
-        # END for each known type
-
-        assert_raises(ValueError, get_object_type_by_name, b"doesntexist")
-
-    def test_object_resolution(self):
-        # objects must be resolved to shas so they compare equal
-        assert self.rorepo.head.reference.object == self.rorepo.active_branch.object
-
-    @with_rw_repo('HEAD', bare=True)
-    def test_with_bare_rw_repo(self, bare_rw_repo):
-        assert bare_rw_repo.config_reader("repository").getboolean("core", "bare")
-        assert os.path.isfile(os.path.join(bare_rw_repo.git_dir, 'HEAD'))
-
-    @with_rw_repo('0.1.6')
-    def test_with_rw_repo(self, rw_repo):
-        assert not rw_repo.config_reader("repository").getboolean("core", "bare")
-        assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
-
-    @with_rw_and_rw_remote_repo('0.1.6')
-    def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
-        assert not rw_repo.config_reader("repository").getboolean("core", "bare")
-        assert rw_remote_repo.config_reader("repository").getboolean("core", "bare")
-        assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
-
-    @with_rw_repo('0.1.6')
-    def test_add_unicode(self, rw_repo):
-        filename = u"שלום.txt"
-
-        file_path = os.path.join(rw_repo.working_dir, filename)
-        open(file_path, "wb").write(b'something')
-
-        if os.name == 'nt':
-            # on windows, there is no way this works, see images on
-            # https://github.com/gitpython-developers/GitPython/issues/147#issuecomment-68881897
-            # Therefore, it must be added using the python implementation
-            rw_repo.index.add([file_path])
-            # However, when the test winds down, rmtree fails to delete this file, which is recognized
-            # as ??? only.
-        else:
-            # on posix, we can just add unicode files without problems
-            rw_repo.git.add(rw_repo.working_dir)
-        # end
-        rw_repo.index.commit('message')
diff --git a/git/test/test_blob.py b/git/test/test_blob.py
deleted file mode 100644
index b529e80fb..000000000
--- a/git/test/test_blob.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# test_blob.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-from git.test.lib import (
-    TestBase,
-    assert_equal
-)
-from git import Blob
-
-
-class TestBlob(TestBase):
-
-    def test_mime_type_should_return_mime_type_for_known_types(self):
-        blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA, 'path': 'foo.png'})
-        assert_equal("image/png", blob.mime_type)
-
-    def test_mime_type_should_return_text_plain_for_unknown_types(self):
-        blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA, 'path': 'something'})
-        assert_equal("text/plain", blob.mime_type)
-
-    def test_nodict(self):
-        self.failUnlessRaises(AttributeError, setattr, self.rorepo.tree()['AUTHORS'], 'someattr', 2)
diff --git a/git/test/test_commit.py b/git/test/test_commit.py
deleted file mode 100644
index 1f0f8c561..000000000
--- a/git/test/test_commit.py
+++ /dev/null
@@ -1,332 +0,0 @@
-# -*- coding: utf-8 -*-
-# test_commit.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-from __future__ import print_function
-
-from git.test.lib import (
-    TestBase,
-    assert_equal,
-    assert_not_equal,
-    with_rw_repo,
-    fixture_path,
-    StringProcessAdapter
-)
-from git import (
-    Commit,
-    Actor,
-)
-from gitdb import IStream
-from git.compat import (
-    string_types,
-    text_type
-)
-
-from io import BytesIO
-import time
-import sys
-import re
-
-
-def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False):
-    """traverse all commits in the history of commit identified by commit_id and check
-    if the serialization works.
-    :param print_performance_info: if True, we will show how fast we are"""
-    ns = 0      # num serializations
-    nds = 0     # num deserializations
-
-    st = time.time()
-    for cm in rwrepo.commit(commit_id).traverse():
-        nds += 1
-
-        # assert that we deserialize commits correctly, hence we get the same
-        # sha on serialization
-        stream = BytesIO()
-        cm._serialize(stream)
-        ns += 1
-        streamlen = stream.tell()
-        stream.seek(0)
-
-        istream = rwrepo.odb.store(IStream(Commit.type, streamlen, stream))
-        assert istream.hexsha == cm.hexsha.encode('ascii')
-
-        nc = Commit(rwrepo, Commit.NULL_BIN_SHA, cm.tree,
-                    cm.author, cm.authored_date, cm.author_tz_offset,
-                    cm.committer, cm.committed_date, cm.committer_tz_offset,
-                    cm.message, cm.parents, cm.encoding)
-
-        assert nc.parents == cm.parents
-        stream = BytesIO()
-        nc._serialize(stream)
-        ns += 1
-        streamlen = stream.tell()
-        stream.seek(0)
-
-        # reuse istream
-        istream.size = streamlen
-        istream.stream = stream
-        istream.binsha = None
-        nc.binsha = rwrepo.odb.store(istream).binsha
-
-        # if it worked, we have exactly the same contents !
-        assert nc.hexsha == cm.hexsha
-    # END check commits
-    elapsed = time.time() - st
-
-    if print_performance_info:
-        print("Serialized %i and deserialized %i commits in %f s ( (%f, %f) commits / s"
-              % (ns, nds, elapsed, ns / elapsed, nds / elapsed), file=sys.stderr)
-    # END handle performance info
-
-
-class TestCommit(TestBase):
-
-    def test_bake(self):
-
-        commit = self.rorepo.commit('2454ae89983a4496a445ce347d7a41c0bb0ea7ae')
-        # commits have no dict
-        self.failUnlessRaises(AttributeError, setattr, commit, 'someattr', 1)
-        commit.author  # bake
-
-        assert_equal("Sebastian Thiel", commit.author.name)
-        assert_equal("byronimo@gmail.com", commit.author.email)
-        assert commit.author == commit.committer
-        assert isinstance(commit.authored_date, int) and isinstance(commit.committed_date, int)
-        assert isinstance(commit.author_tz_offset, int) and isinstance(commit.committer_tz_offset, int)
-        assert commit.message == "Added missing information to docstrings of commit and stats module\n"
-
-    def test_stats(self):
-        commit = self.rorepo.commit('33ebe7acec14b25c5f84f35a664803fcab2f7781')
-        stats = commit.stats
-
-        def check_entries(d):
-            assert isinstance(d, dict)
-            for key in ("insertions", "deletions", "lines"):
-                assert key in d
-        # END assertion helper
-        assert stats.files
-        assert stats.total
-
-        check_entries(stats.total)
-        assert "files" in stats.total
-
-        for filepath, d in stats.files.items():
-            check_entries(d)
-        # END for each stated file
-
-        # assure data is parsed properly
-        michael = Actor._from_string("Michael Trier <mtrier@gmail.com>")
-        assert commit.author == michael
-        assert commit.committer == michael
-        assert commit.authored_date == 1210193388
-        assert commit.committed_date == 1210193388
-        assert commit.author_tz_offset == 14400, commit.author_tz_offset
-        assert commit.committer_tz_offset == 14400, commit.committer_tz_offset
-        assert commit.message == "initial project\n"
-
-    def test_unicode_actor(self):
-        # assure we can parse unicode actors correctly
-        name = u"Üäöß ÄußÉ"
-        assert len(name) == 9
-        special = Actor._from_string(u"%s <something@this.com>" % name)
-        assert special.name == name
-        assert isinstance(special.name, text_type)
-
-    def test_traversal(self):
-        start = self.rorepo.commit("a4d06724202afccd2b5c54f81bcf2bf26dea7fff")
-        first = self.rorepo.commit("33ebe7acec14b25c5f84f35a664803fcab2f7781")
-        p0 = start.parents[0]
-        p1 = start.parents[1]
-        p00 = p0.parents[0]
-        p10 = p1.parents[0]
-
-        # basic branch first, depth first
-        dfirst = start.traverse(branch_first=False)
-        bfirst = start.traverse(branch_first=True)
-        assert next(dfirst) == p0
-        assert next(dfirst) == p00
-
-        assert next(bfirst) == p0
-        assert next(bfirst) == p1
-        assert next(bfirst) == p00
-        assert next(bfirst) == p10
-
-        # at some point, both iterations should stop
-        assert list(bfirst)[-1] == first
-        stoptraverse = self.rorepo.commit("254d04aa3180eb8b8daf7b7ff25f010cd69b4e7d").traverse(as_edge=True)
-        l = list(stoptraverse)
-        assert len(l[0]) == 2
-
-        # ignore self
-        assert next(start.traverse(ignore_self=False)) == start
-
-        # depth
-        assert len(list(start.traverse(ignore_self=False, depth=0))) == 1
-
-        # prune
-        assert next(start.traverse(branch_first=1, prune=lambda i, d: i == p0)) == p1
-
-        # predicate
-        assert next(start.traverse(branch_first=1, predicate=lambda i, d: i == p1)) == p1
-
-        # traversal should stop when the beginning is reached
-        self.failUnlessRaises(StopIteration, next, first.traverse())
-
-        # parents of the first commit should be empty ( as the only parent has a null
-        # sha )
-        assert len(first.parents) == 0
-
-    def test_iteration(self):
-        # we can iterate commits
-        all_commits = Commit.list_items(self.rorepo, self.rorepo.head)
-        assert all_commits
-        assert all_commits == list(self.rorepo.iter_commits())
-
-        # this includes merge commits
-        mcomit = self.rorepo.commit('d884adc80c80300b4cc05321494713904ef1df2d')
-        assert mcomit in all_commits
-
-        # we can limit the result to paths
-        ltd_commits = list(self.rorepo.iter_commits(paths='CHANGES'))
-        assert ltd_commits and len(ltd_commits) < len(all_commits)
-
-        # show commits of multiple paths, resulting in a union of commits
-        less_ltd_commits = list(Commit.iter_items(self.rorepo, 'master', paths=('CHANGES', 'AUTHORS')))
-        assert len(ltd_commits) < len(less_ltd_commits)
-
-    def test_iter_items(self):
-        # pretty not allowed
-        self.failUnlessRaises(ValueError, Commit.iter_items, self.rorepo, 'master', pretty="raw")
-
-    def test_rev_list_bisect_all(self):
-        """
-        'git rev-list --bisect-all' returns additional information
-        in the commit header.  This test ensures that we properly parse it.
-        """
-        revs = self.rorepo.git.rev_list('933d23bf95a5bd1624fbcdf328d904e1fa173474',
-                                        first_parent=True,
-                                        bisect_all=True)
-
-        commits = Commit._iter_from_process_or_stream(self.rorepo, StringProcessAdapter(revs.encode('ascii')))
-        expected_ids = (
-            '7156cece3c49544abb6bf7a0c218eb36646fad6d',
-            '1f66cfbbce58b4b552b041707a12d437cc5f400a',
-            '33ebe7acec14b25c5f84f35a664803fcab2f7781',
-            '933d23bf95a5bd1624fbcdf328d904e1fa173474'
-        )
-        for sha1, commit in zip(expected_ids, commits):
-            assert_equal(sha1, commit.hexsha)
-
-    def test_count(self):
-        assert self.rorepo.tag('refs/tags/0.1.5').commit.count() == 143
-
-    def test_list(self):
-        # This doesn't work anymore, as we will either attempt getattr with bytes, or compare 20 byte string
-        # with actual 20 byte bytes. This usage makes no sense anyway
-        assert isinstance(Commit.list_items(self.rorepo, '0.1.5', max_count=5)[
-                          '5117c9c8a4d3af19a9958677e45cda9269de1541'], Commit)
-
-    def test_str(self):
-        commit = Commit(self.rorepo, Commit.NULL_BIN_SHA)
-        assert_equal(Commit.NULL_HEX_SHA, str(commit))
-
-    def test_repr(self):
-        commit = Commit(self.rorepo, Commit.NULL_BIN_SHA)
-        assert_equal('<git.Commit "%s">' % Commit.NULL_HEX_SHA, repr(commit))
-
-    def test_equality(self):
-        commit1 = Commit(self.rorepo, Commit.NULL_BIN_SHA)
-        commit2 = Commit(self.rorepo, Commit.NULL_BIN_SHA)
-        commit3 = Commit(self.rorepo, "\1" * 20)
-        assert_equal(commit1, commit2)
-        assert_not_equal(commit2, commit3)
-
-    def test_iter_parents(self):
-        # should return all but ourselves, even if skip is defined
-        c = self.rorepo.commit('0.1.5')
-        for skip in (0, 1):
-            piter = c.iter_parents(skip=skip)
-            first_parent = next(piter)
-            assert first_parent != c
-            assert first_parent == c.parents[0]
-        # END for each
-
-    def test_name_rev(self):
-        name_rev = self.rorepo.head.commit.name_rev
-        assert isinstance(name_rev, string_types)
-
-    @with_rw_repo('HEAD', bare=True)
-    def test_serialization(self, rwrepo):
-        # create all commits of our repo
-        assert_commit_serialization(rwrepo, '0.1.6')
-
-    def test_serialization_unicode_support(self):
-        assert Commit.default_encoding.lower() == 'utf-8'
-
-        # create a commit with unicode in the message, and the author's name
-        # Verify its serialization and deserialization
-        cmt = self.rorepo.commit('0.1.6')
-        assert isinstance(cmt.message, text_type)     # it automatically decodes it as such
-        assert isinstance(cmt.author.name, text_type)  # same here
-
-        cmt.message = u"üäêèß"
-        assert len(cmt.message) == 5
-
-        cmt.author.name = u"äüß"
-        assert len(cmt.author.name) == 3
-
-        cstream = BytesIO()
-        cmt._serialize(cstream)
-        cstream.seek(0)
-        assert len(cstream.getvalue())
-
-        ncmt = Commit(self.rorepo, cmt.binsha)
-        ncmt._deserialize(cstream)
-
-        assert cmt.author.name == ncmt.author.name
-        assert cmt.message == ncmt.message
-        # actually, it can't be printed in a shell as repr wants to have ascii only
-        # it appears
-        cmt.author.__repr__()
-
-    def test_gpgsig(self):
-        cmt = self.rorepo.commit()
-        cmt._deserialize(open(fixture_path('commit_with_gpgsig'), 'rb'))
-
-        fixture_sig = """-----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.11 (GNU/Linux)
-
-iQIcBAABAgAGBQJRk8zMAAoJEG5mS6x6i9IjsTEP/0v2Wx/i7dqyKban6XMIhVdj
-uI0DycfXqnCCZmejidzeao+P+cuK/ZAA/b9fU4MtwkDm2USvnIOrB00W0isxsrED
-sdv6uJNa2ybGjxBolLrfQcWutxGXLZ1FGRhEvkPTLMHHvVriKoNFXcS7ewxP9MBf
-NH97K2wauqA+J4BDLDHQJgADCOmLrGTAU+G1eAXHIschDqa6PZMH5nInetYZONDh
-3SkOOv8VKFIF7gu8X7HC+7+Y8k8U0TW0cjlQ2icinwCc+KFoG6GwXS7u/VqIo1Yp
-Tack6sxIdK7NXJhV5gAeAOMJBGhO0fHl8UUr96vGEKwtxyZhWf8cuIPOWLk06jA0
-g9DpLqmy/pvyRfiPci+24YdYRBua/vta+yo/Lp85N7Hu/cpIh+q5WSLvUlv09Dmo
-TTTG8Hf6s3lEej7W8z2xcNZoB6GwXd8buSDU8cu0I6mEO9sNtAuUOHp2dBvTA6cX
-PuQW8jg3zofnx7CyNcd3KF3nh2z8mBcDLgh0Q84srZJCPRuxRcp9ylggvAG7iaNd
-XMNvSK8IZtWLkx7k3A3QYt1cN4y1zdSHLR2S+BVCEJea1mvUE+jK5wiB9S4XNtKm
-BX/otlTa8pNE3fWYBxURvfHnMY4i3HQT7Bc1QjImAhMnyo2vJk4ORBJIZ1FTNIhJ
-JzJMZDRLQLFvnzqZuCjE
-=przd
------END PGP SIGNATURE-----"""
-        assert cmt.gpgsig == fixture_sig
-
-        cmt.gpgsig = "<test\ndummy\nsig>"
-        assert cmt.gpgsig != fixture_sig
-
-        cstream = BytesIO()
-        cmt._serialize(cstream)
-        assert re.search(r"^gpgsig <test\n dummy\n sig>$", cstream.getvalue().decode('ascii'), re.MULTILINE)
-
-        cstream.seek(0)
-        cmt.gpgsig = None
-        cmt._deserialize(cstream)
-        assert cmt.gpgsig == "<test\ndummy\nsig>"
-
-        cmt.gpgsig = None
-        cstream = BytesIO()
-        cmt._serialize(cstream)
-        assert not re.search(r"^gpgsig ", cstream.getvalue().decode('ascii'), re.MULTILINE)
diff --git a/git/test/test_config.py b/git/test/test_config.py
deleted file mode 100644
index 9a44d9e38..000000000
--- a/git/test/test_config.py
+++ /dev/null
@@ -1,195 +0,0 @@
-# test_config.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-from git.test.lib import (
-    TestCase,
-    fixture_path,
-    assert_equal,
-)
-from gitdb.test.lib import with_rw_directory
-from git import (
-    GitConfigParser
-)
-from git.compat import (
-    string_types,
-)
-import io
-import os
-from copy import copy
-from git.config import cp
-
-
-class TestBase(TestCase):
-
-    def _to_memcache(self, file_path):
-        fp = open(file_path, "rb")
-        sio = io.BytesIO(fp.read())
-        sio.name = file_path
-        return sio
-
-    def _parsers_equal_or_raise(self, lhs, rhs):
-        pass
-
-    def test_read_write(self):
-        # writer must create the exact same file as the one read before
-        for filename in ("git_config", "git_config_global"):
-            file_obj = self._to_memcache(fixture_path(filename))
-            file_obj_orig = copy(file_obj)
-            w_config = GitConfigParser(file_obj, read_only=False)
-            w_config.read()                 # enforce reading
-            assert w_config._sections
-            w_config.write()                # enforce writing
-
-            # we stripped lines when reading, so the results differ
-            assert file_obj.getvalue() and file_obj.getvalue() != file_obj_orig.getvalue()
-
-            # creating an additional config writer must fail due to exclusive access
-            self.failUnlessRaises(IOError, GitConfigParser, file_obj, read_only=False)
-
-            # should still have a lock and be able to make changes
-            assert w_config._lock._has_lock()
-
-            # changes should be written right away
-            sname = "my_section"
-            oname = "mykey"
-            val = "myvalue"
-            w_config.add_section(sname)
-            assert w_config.has_section(sname)
-            w_config.set(sname, oname, val)
-            assert w_config.has_option(sname, oname)
-            assert w_config.get(sname, oname) == val
-
-            sname_new = "new_section"
-            oname_new = "new_key"
-            ival = 10
-            w_config.set_value(sname_new, oname_new, ival)
-            assert w_config.get_value(sname_new, oname_new) == ival
-
-            file_obj.seek(0)
-            r_config = GitConfigParser(file_obj, read_only=True)
-            assert r_config.has_section(sname)
-            assert r_config.has_option(sname, oname)
-            assert r_config.get(sname, oname) == val
-        # END for each filename
-
-    def test_multi_line_config(self):
-        file_obj = self._to_memcache(fixture_path("git_config_with_comments"))
-        config = GitConfigParser(file_obj, read_only=False)
-        ev = "ruby -e '\n"
-        ev += "		system %(git), %(merge-file), %(--marker-size=%L), %(%A), %(%O), %(%B)\n"
-        ev += "		b = File.read(%(%A))\n"
-        ev += "		b.sub!(/^<+ .*\\nActiveRecord::Schema\\.define.:version => (\\d+). do\\n=+\\nActiveRecord::Schema\\."
-        ev += "define.:version => (\\d+). do\\n>+ .*/) do\n"
-        ev += "		  %(ActiveRecord::Schema.define(:version => #{[$1, $2].max}) do)\n"
-        ev += "		end\n"
-        ev += "		File.open(%(%A), %(w)) {|f| f.write(b)}\n"
-        ev += "		exit 1 if b.include?(%(<)*%L)'"
-        assert_equal(config.get('merge "railsschema"', 'driver'), ev)
-        assert_equal(config.get('alias', 'lg'),
-                     "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset'"
-                     " --abbrev-commit --date=relative")
-        assert len(config.sections()) == 23
-
-    def test_base(self):
-        path_repo = fixture_path("git_config")
-        path_global = fixture_path("git_config_global")
-        r_config = GitConfigParser([path_repo, path_global], read_only=True)
-        assert r_config.read_only
-        num_sections = 0
-        num_options = 0
-
-        # test reader methods
-        assert r_config._is_initialized is False
-        for section in r_config.sections():
-            num_sections += 1
-            for option in r_config.options(section):
-                num_options += 1
-                val = r_config.get(section, option)
-                val_typed = r_config.get_value(section, option)
-                assert isinstance(val_typed, (bool, int, float, ) + string_types)
-                assert val
-                assert "\n" not in option
-                assert "\n" not in val
-
-                # writing must fail
-                self.failUnlessRaises(IOError, r_config.set, section, option, None)
-                self.failUnlessRaises(IOError, r_config.remove_option, section, option)
-            # END for each option
-            self.failUnlessRaises(IOError, r_config.remove_section, section)
-        # END for each section
-        assert num_sections and num_options
-        assert r_config._is_initialized is True
-
-        # get value which doesnt exist, with default
-        default = "my default value"
-        assert r_config.get_value("doesnt", "exist", default) == default
-
-        # it raises if there is no default though
-        self.failUnlessRaises(cp.NoSectionError, r_config.get_value, "doesnt", "exist")
-
-    @with_rw_directory
-    def test_config_include(self, rw_dir):
-        def write_test_value(cw, value):
-            cw.set_value(value, 'value', value)
-        # end
-
-        def check_test_value(cr, value):
-            assert cr.get_value(value, 'value') == value
-        # end
-
-        # PREPARE CONFIG FILE A
-        fpa = os.path.join(rw_dir, 'a')
-        cw = GitConfigParser(fpa, read_only=False)
-        write_test_value(cw, 'a')
-
-        fpb = os.path.join(rw_dir, 'b')
-        fpc = os.path.join(rw_dir, 'c')
-        cw.set_value('include', 'relative_path_b', 'b')
-        cw.set_value('include', 'doesntexist', 'foobar')
-        cw.set_value('include', 'relative_cycle_a_a', 'a')
-        cw.set_value('include', 'absolute_cycle_a_a', fpa)
-        cw.release()
-        assert os.path.exists(fpa)
-
-        # PREPARE CONFIG FILE B
-        cw = GitConfigParser(fpb, read_only=False)
-        write_test_value(cw, 'b')
-        cw.set_value('include', 'relative_cycle_b_a', 'a')
-        cw.set_value('include', 'absolute_cycle_b_a', fpa)
-        cw.set_value('include', 'relative_path_c', 'c')
-        cw.set_value('include', 'absolute_path_c', fpc)
-        cw.release()
-
-        # PREPARE CONFIG FILE C
-        cw = GitConfigParser(fpc, read_only=False)
-        write_test_value(cw, 'c')
-        cw.release()
-
-        cr = GitConfigParser(fpa, read_only=True)
-        for tv in ('a', 'b', 'c'):
-            check_test_value(cr, tv)
-        # end for each test to verify
-        assert len(cr.items('include')) == 8, "Expected all include sections to be merged"
-        cr.release()
-
-        # test writable config writers - assure write-back doesn't involve includes
-        cw = GitConfigParser(fpa, read_only=False, merge_includes=True)
-        tv = 'x'
-        write_test_value(cw, tv)
-        cw.release()
-
-        cr = GitConfigParser(fpa, read_only=True)
-        self.failUnlessRaises(cp.NoSectionError, check_test_value, cr, tv)
-        cr.release()
-
-        # But can make it skip includes alltogether, and thus allow write-backs
-        cw = GitConfigParser(fpa, read_only=False, merge_includes=False)
-        write_test_value(cw, tv)
-        cw.release()
-
-        cr = GitConfigParser(fpa, read_only=True)
-        check_test_value(cr, tv)
-        cr.release()
diff --git a/git/test/test_db.py b/git/test/test_db.py
deleted file mode 100644
index 5dcf592a8..000000000
--- a/git/test/test_db.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# test_repo.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-from git.test.lib import TestBase
-from git.db import GitCmdObjectDB
-from gitdb.util import bin_to_hex
-from git.exc import BadObject
-import os
-
-
-class TestDB(TestBase):
-
-    def test_base(self):
-        gdb = GitCmdObjectDB(os.path.join(self.rorepo.git_dir, 'objects'), self.rorepo.git)
-
-        # partial to complete - works with everything
-        hexsha = bin_to_hex(gdb.partial_to_complete_sha_hex("0.1.6"))
-        assert len(hexsha) == 40
-
-        assert bin_to_hex(gdb.partial_to_complete_sha_hex(hexsha[:20])) == hexsha
-
-        # fails with BadObject
-        for invalid_rev in ("0000", "bad/ref", "super bad"):
-            self.failUnlessRaises(BadObject, gdb.partial_to_complete_sha_hex, invalid_rev)
diff --git a/git/test/test_diff.py b/git/test/test_diff.py
deleted file mode 100644
index 42972603e..000000000
--- a/git/test/test_diff.py
+++ /dev/null
@@ -1,153 +0,0 @@
-# test_diff.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-from git.test.lib import (
-    TestBase,
-    StringProcessAdapter,
-    fixture,
-    assert_equal,
-    assert_true,
-
-)
-
-from git import (
-    Diff,
-    DiffIndex
-)
-
-
-class TestDiff(TestBase):
-
-    def _assert_diff_format(self, diffs):
-        # verify that the format of the diff is sane
-        for diff in diffs:
-            if diff.a_mode:
-                assert isinstance(diff.a_mode, int)
-            if diff.b_mode:
-                assert isinstance(diff.b_mode, int)
-
-            if diff.a_blob:
-                assert not diff.a_blob.path.endswith('\n')
-            if diff.b_blob:
-                assert not diff.b_blob.path.endswith('\n')
-        # END for each diff
-        return diffs
-
-    def test_list_from_string_new_mode(self):
-        output = StringProcessAdapter(fixture('diff_new_mode'))
-        diffs = Diff._index_from_patch_format(self.rorepo, output.stdout)
-        self._assert_diff_format(diffs)
-
-        assert_equal(1, len(diffs))
-        assert_equal(10, len(diffs[0].diff.splitlines()))
-
-    def test_diff_with_rename(self):
-        output = StringProcessAdapter(fixture('diff_rename'))
-        diffs = Diff._index_from_patch_format(self.rorepo, output.stdout)
-        self._assert_diff_format(diffs)
-
-        assert_equal(1, len(diffs))
-
-        diff = diffs[0]
-        assert_true(diff.renamed)
-        assert_equal(diff.rename_from, 'AUTHORS')
-        assert_equal(diff.rename_to, 'CONTRIBUTORS')
-
-        output = StringProcessAdapter(fixture('diff_rename_raw'))
-        diffs = Diff._index_from_raw_format(self.rorepo, output.stdout)
-        assert len(diffs) == 1
-        diff = diffs[0]
-        assert diff.renamed
-        assert diff.rename_from == 'this'
-        assert diff.rename_to == 'that'
-        assert len(list(diffs.iter_change_type('R'))) == 1
-
-    def test_binary_diff(self):
-        for method, file_name in ((Diff._index_from_patch_format, 'diff_patch_binary'),
-                                  (Diff._index_from_raw_format, 'diff_raw_binary')):
-            res = method(None, StringProcessAdapter(fixture(file_name)).stdout)
-            assert len(res) == 1
-            assert len(list(res.iter_change_type('M'))) == 1
-            if res[0].diff:
-                assert res[0].diff == b"Binary files a/rps and b/rps differ\n", "in patch mode, we get a diff text"
-                assert str(res[0]), "This call should just work"
-        # end for each method to test
-
-    def test_diff_index(self):
-        output = StringProcessAdapter(fixture('diff_index_patch'))
-        res = Diff._index_from_patch_format(None, output.stdout)
-        assert len(res) == 6
-        for dr in res:
-            assert dr.diff
-            assert str(dr), "Diff to string conversion should be possible"
-        # end for each diff
-
-        dr = res[3]
-        assert dr.diff.endswith(b"+Binary files a/rps and b/rps differ\n")
-
-    def test_diff_patch_format(self):
-        # test all of the 'old' format diffs for completness - it should at least
-        # be able to deal with it
-        fixtures = ("diff_2", "diff_2f", "diff_f", "diff_i", "diff_mode_only",
-                    "diff_new_mode", "diff_numstat", "diff_p", "diff_rename",
-                    "diff_tree_numstat_root")
-
-        for fixture_name in fixtures:
-            diff_proc = StringProcessAdapter(fixture(fixture_name))
-            Diff._index_from_patch_format(self.rorepo, diff_proc.stdout)
-        # END for each fixture
-
-    def test_diff_interface(self):
-        # test a few variations of the main diff routine
-        assertion_map = dict()
-        for i, commit in enumerate(self.rorepo.iter_commits('0.1.6', max_count=2)):
-            diff_item = commit
-            if i % 2 == 0:
-                diff_item = commit.tree
-            # END use tree every second item
-
-            for other in (None, commit.Index, commit.parents[0]):
-                for paths in (None, "CHANGES", ("CHANGES", "lib")):
-                    for create_patch in range(2):
-                        diff_index = diff_item.diff(other=other, paths=paths, create_patch=create_patch)
-                        assert isinstance(diff_index, DiffIndex)
-
-                        if diff_index:
-                            self._assert_diff_format(diff_index)
-                            for ct in DiffIndex.change_type:
-                                key = 'ct_%s' % ct
-                                assertion_map.setdefault(key, 0)
-                                assertion_map[key] = assertion_map[key] + len(list(diff_index.iter_change_type(ct)))
-                            # END for each changetype
-
-                            # check entries
-                            diff_set = set()
-                            diff_set.add(diff_index[0])
-                            diff_set.add(diff_index[0])
-                            assert len(diff_set) == 1
-                            assert diff_index[0] == diff_index[0]
-                            assert not (diff_index[0] != diff_index[0])
-
-                            for dr in diff_index:
-                                assert str(dr), "Diff to string conversion should be possible"
-                        # END diff index checking
-                    # END for each patch option
-                # END for each path option
-            # END for each other side
-        # END for each commit
-
-        # assert we could always find at least one instance of the members we
-        # can iterate in the diff index - if not this indicates its not working correctly
-        # or our test does not span the whole range of possibilities
-        for key, value in assertion_map.items():
-            assert value, "Did not find diff for %s" % key
-        # END for each iteration type
-
-        # test path not existing in the index - should be ignored
-        c = self.rorepo.head.commit
-        cp = c.parents[0]
-        diff_index = c.diff(cp, ["does/not/exist"])
-        assert len(diff_index) == 0
diff --git a/git/test/test_git.py b/git/test/test_git.py
deleted file mode 100644
index f25fa21a8..000000000
--- a/git/test/test_git.py
+++ /dev/null
@@ -1,155 +0,0 @@
-#-*-coding:utf-8-*-
-# test_git.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-import os
-import mock
-from git.test.lib import (TestBase,
-                          patch,
-                          raises,
-                          assert_equal,
-                          assert_true,
-                          assert_match,
-                          fixture_path)
-from git import (Git,
-                 GitCommandError)
-
-from git.compat import PY3
-
-
-class TestGit(TestBase):
-
-    @classmethod
-    def setUpClass(cls):
-        super(TestGit, cls).setUpClass()
-        cls.git = Git(cls.rorepo.working_dir)
-
-    @patch.object(Git, 'execute')
-    def test_call_process_calls_execute(self, git):
-        git.return_value = ''
-        self.git.version()
-        assert_true(git.called)
-        assert_equal(git.call_args, ((['git', 'version'],), {}))
-
-    def test_call_unpack_args_unicode(self):
-        args = Git._Git__unpack_args(u'Unicode€™')
-        if PY3:
-            mangled_value = 'Unicode\u20ac\u2122'
-        else:
-            mangled_value = 'Unicode\xe2\x82\xac\xe2\x84\xa2'
-        assert_equal(args, [mangled_value])
-
-    def test_call_unpack_args(self):
-        args = Git._Git__unpack_args(['git', 'log', '--', u'Unicode€™'])
-        if PY3:
-            mangled_value = 'Unicode\u20ac\u2122'
-        else:
-            mangled_value = 'Unicode\xe2\x82\xac\xe2\x84\xa2'
-        assert_equal(args, ['git', 'log', '--', mangled_value])
-
-    @raises(GitCommandError)
-    def test_it_raises_errors(self):
-        self.git.this_does_not_exist()
-
-    def test_it_transforms_kwargs_into_git_command_arguments(self):
-        assert_equal(["-s"], self.git.transform_kwargs(**{'s': True}))
-        assert_equal(["-s5"], self.git.transform_kwargs(**{'s': 5}))
-
-        assert_equal(["--max-count"], self.git.transform_kwargs(**{'max_count': True}))
-        assert_equal(["--max-count=5"], self.git.transform_kwargs(**{'max_count': 5}))
-
-        # order is undefined
-        res = self.git.transform_kwargs(**{'s': True, 't': True})
-        assert ['-s', '-t'] == res or ['-t', '-s'] == res
-
-    def test_it_executes_git_to_shell_and_returns_result(self):
-        assert_match('^git version [\d\.]{2}.*$', self.git.execute(["git", "version"]))
-
-    def test_it_accepts_stdin(self):
-        filename = fixture_path("cat_file_blob")
-        fh = open(filename, 'r')
-        assert_equal("70c379b63ffa0795fdbfbc128e5a2818397b7ef8",
-                     self.git.hash_object(istream=fh, stdin=True))
-        fh.close()
-
-    @patch.object(Git, 'execute')
-    def test_it_ignores_false_kwargs(self, git):
-        # this_should_not_be_ignored=False implies it *should* be ignored
-        self.git.version(pass_this_kwarg=False)
-        assert_true("pass_this_kwarg" not in git.call_args[1])
-
-    def test_persistent_cat_file_command(self):
-        # read header only
-        import subprocess as sp
-        hexsha = "b2339455342180c7cc1e9bba3e9f181f7baa5167"
-        g = self.git.cat_file(batch_check=True, istream=sp.PIPE, as_process=True)
-        g.stdin.write(b"b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
-        g.stdin.flush()
-        obj_info = g.stdout.readline()
-
-        # read header + data
-        g = self.git.cat_file(batch=True, istream=sp.PIPE, as_process=True)
-        g.stdin.write(b"b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
-        g.stdin.flush()
-        obj_info_two = g.stdout.readline()
-        assert obj_info == obj_info_two
-
-        # read data - have to read it in one large chunk
-        size = int(obj_info.split()[2])
-        data = g.stdout.read(size)
-        g.stdout.read(1)
-
-        # now we should be able to read a new object
-        g.stdin.write(b"b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
-        g.stdin.flush()
-        assert g.stdout.readline() == obj_info
-
-        # same can be achived using the respective command functions
-        hexsha, typename, size = self.git.get_object_header(hexsha)
-        hexsha, typename_two, size_two, data = self.git.get_object_data(hexsha)
-        assert typename == typename_two and size == size_two
-
-    def test_version(self):
-        v = self.git.version_info
-        assert isinstance(v, tuple)
-        for n in v:
-            assert isinstance(n, int)
-        # END verify number types
-
-    def test_cmd_override(self):
-        prev_cmd = self.git.GIT_PYTHON_GIT_EXECUTABLE
-        if os.name == 'nt':
-            exc = GitCommandError
-        else:
-            exc = OSError
-        # end handle windows case
-        try:
-            # set it to something that doens't exist, assure it raises
-            type(self.git).GIT_PYTHON_GIT_EXECUTABLE = os.path.join(
-                "some", "path", "which", "doesn't", "exist", "gitbinary")
-            self.failUnlessRaises(exc, self.git.version)
-        finally:
-            type(self.git).GIT_PYTHON_GIT_EXECUTABLE = prev_cmd
-        # END undo adjustment
-
-    def test_options_are_passed_to_git(self):
-        # This work because any command after git --version is ignored
-        git_version = self.git(version=True).NoOp()
-        git_command_version = self.git.version()
-        self.assertEquals(git_version, git_command_version)
-
-    def test_single_char_git_options_are_passed_to_git(self):
-        input_value = 'TestValue'
-        output_value = self.git(c='user.name=%s' % input_value).config('--get', 'user.name')
-        self.assertEquals(input_value, output_value)
-
-    def test_change_to_transform_kwargs_does_not_break_command_options(self):
-        self.git.log(n=1)
-
-    def test_env_vars_passed_to_git(self):
-        editor = 'non_existant_editor'
-        with mock.patch.dict('os.environ', {'GIT_EDITOR': editor}):
-            assert self.git.var("GIT_EDITOR") == editor
diff --git a/git/test/test_index.py b/git/test/test_index.py
deleted file mode 100644
index 2be776cd0..000000000
--- a/git/test/test_index.py
+++ /dev/null
@@ -1,762 +0,0 @@
-#-*-coding:utf-8-*-
-# test_index.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-from git.test.lib import (
-    TestBase,
-    fixture_path,
-    fixture,
-    with_rw_repo
-)
-from git.util import Actor
-from git.exc import HookExecutionError
-from git import (
-    IndexFile,
-    BlobFilter,
-    UnmergedEntriesError,
-    Tree,
-    Object,
-    Diff,
-    GitCommandError,
-    CheckoutError,
-)
-from git.compat import string_types
-from gitdb.util import hex_to_bin
-import os
-import sys
-import tempfile
-import shutil
-from stat import (
-    S_ISLNK,
-    ST_MODE
-)
-
-from io import BytesIO
-from gitdb.base import IStream
-from git.objects import Blob
-from git.index.typ import (
-    BaseIndexEntry,
-    IndexEntry
-)
-from git.index.fun import hook_path
-
-
-class TestIndex(TestBase):
-
-    def __init__(self, *args):
-        super(TestIndex, self).__init__(*args)
-        self._reset_progress()
-
-    def _assert_fprogress(self, entries):
-        assert len(entries) == len(self._fprogress_map)
-        for path, call_count in self._fprogress_map.items():
-            assert call_count == 2
-        # END for each item in progress map
-        self._reset_progress()
-
-    def _fprogress(self, path, done, item):
-        self._fprogress_map.setdefault(path, 0)
-        curval = self._fprogress_map[path]
-        if curval == 0:
-            assert not done
-        if curval == 1:
-            assert done
-        self._fprogress_map[path] = curval + 1
-
-    def _fprogress_add(self, path, done, item):
-        """Called as progress func - we keep track of the proper
-        call order"""
-        assert item is not None
-        self._fprogress(path, done, item)
-
-    def _reset_progress(self):
-        # maps paths to the count of calls
-        self._fprogress_map = dict()
-
-    def _assert_entries(self, entries):
-        for entry in entries:
-            assert isinstance(entry, BaseIndexEntry)
-            assert not os.path.isabs(entry.path)
-            assert "\\" not in entry.path
-        # END for each entry
-
-    def test_index_file_base(self):
-        # read from file
-        index = IndexFile(self.rorepo, fixture_path("index"))
-        assert index.entries
-        assert index.version > 0
-
-        # test entry
-        entry = next(iter(index.entries.values()))
-        for attr in ("path", "ctime", "mtime", "dev", "inode", "mode", "uid",
-                     "gid", "size", "binsha", "hexsha", "stage"):
-            getattr(entry, attr)
-        # END for each method
-
-        # test update
-        entries = index.entries
-        assert isinstance(index.update(), IndexFile)
-        assert entries is not index.entries
-
-        # test stage
-        index_merge = IndexFile(self.rorepo, fixture_path("index_merge"))
-        assert len(index_merge.entries) == 106
-        assert len(list(e for e in index_merge.entries.values() if e.stage != 0))
-
-        # write the data - it must match the original
-        tmpfile = tempfile.mktemp()
-        index_merge.write(tmpfile)
-        fp = open(tmpfile, 'rb')
-        assert fp.read() == fixture("index_merge")
-        fp.close()
-        os.remove(tmpfile)
-
-    def _cmp_tree_index(self, tree, index):
-        # fail unless both objects contain the same paths and blobs
-        if isinstance(tree, str):
-            tree = self.rorepo.commit(tree).tree
-
-        blist = list()
-        for blob in tree.traverse(predicate=lambda e, d: e.type == "blob", branch_first=False):
-            assert (blob.path, 0) in index.entries
-            blist.append(blob)
-        # END for each blob in tree
-        if len(blist) != len(index.entries):
-            iset = set(k[0] for k in index.entries.keys())
-            bset = set(b.path for b in blist)
-            raise AssertionError("CMP Failed: Missing entries in index: %s, missing in tree: %s" %
-                                 (bset - iset, iset - bset))
-        # END assertion message
-
-    @with_rw_repo('0.1.6')
-    def test_index_file_from_tree(self, rw_repo):
-        common_ancestor_sha = "5117c9c8a4d3af19a9958677e45cda9269de1541"
-        cur_sha = "4b43ca7ff72d5f535134241e7c797ddc9c7a3573"
-        other_sha = "39f85c4358b7346fee22169da9cad93901ea9eb9"
-
-        # simple index from tree
-        base_index = IndexFile.from_tree(rw_repo, common_ancestor_sha)
-        assert base_index.entries
-        self._cmp_tree_index(common_ancestor_sha, base_index)
-
-        # merge two trees - its like a fast-forward
-        two_way_index = IndexFile.from_tree(rw_repo, common_ancestor_sha, cur_sha)
-        assert two_way_index.entries
-        self._cmp_tree_index(cur_sha, two_way_index)
-
-        # merge three trees - here we have a merge conflict
-        three_way_index = IndexFile.from_tree(rw_repo, common_ancestor_sha, cur_sha, other_sha)
-        assert len(list(e for e in three_way_index.entries.values() if e.stage != 0))
-
-        # ITERATE BLOBS
-        merge_required = lambda t: t[0] != 0
-        merge_blobs = list(three_way_index.iter_blobs(merge_required))
-        assert merge_blobs
-        assert merge_blobs[0][0] in (1, 2, 3)
-        assert isinstance(merge_blobs[0][1], Blob)
-
-        # test BlobFilter
-        prefix = 'lib/git'
-        for stage, blob in base_index.iter_blobs(BlobFilter([prefix])):
-            assert blob.path.startswith(prefix)
-
-        # writing a tree should fail with an unmerged index
-        self.failUnlessRaises(UnmergedEntriesError, three_way_index.write_tree)
-
-        # removed unmerged entries
-        unmerged_blob_map = three_way_index.unmerged_blobs()
-        assert unmerged_blob_map
-
-        # pick the first blob at the first stage we find and use it as resolved version
-        three_way_index.resolve_blobs(l[0][1] for l in unmerged_blob_map.values())
-        tree = three_way_index.write_tree()
-        assert isinstance(tree, Tree)
-        num_blobs = 0
-        for blob in tree.traverse(predicate=lambda item, d: item.type == "blob"):
-            assert (blob.path, 0) in three_way_index.entries
-            num_blobs += 1
-        # END for each blob
-        assert num_blobs == len(three_way_index.entries)
-
-    @with_rw_repo('0.1.6')
-    def test_index_merge_tree(self, rw_repo):
-        # A bit out of place, but we need a different repo for this:
-        assert self.rorepo != rw_repo and not (self.rorepo == rw_repo)
-        assert len(set((self.rorepo, self.rorepo, rw_repo, rw_repo))) == 2
-
-        # SINGLE TREE MERGE
-        # current index is at the (virtual) cur_commit
-        next_commit = "4c39f9da792792d4e73fc3a5effde66576ae128c"
-        parent_commit = rw_repo.head.commit.parents[0]
-        manifest_key = IndexFile.entry_key('MANIFEST.in', 0)
-        manifest_entry = rw_repo.index.entries[manifest_key]
-        rw_repo.index.merge_tree(next_commit)
-        # only one change should be recorded
-        assert manifest_entry.binsha != rw_repo.index.entries[manifest_key].binsha
-
-        rw_repo.index.reset(rw_repo.head)
-        assert rw_repo.index.entries[manifest_key].binsha == manifest_entry.binsha
-
-        # FAKE MERGE
-        #############
-        # Add a change with a NULL sha that should conflict with next_commit. We
-        # pretend there was a change, but we do not even bother adding a proper
-        # sha for it ( which makes things faster of course )
-        manifest_fake_entry = BaseIndexEntry((manifest_entry[0], b"\0" * 20, 0, manifest_entry[3]))
-        # try write flag
-        self._assert_entries(rw_repo.index.add([manifest_fake_entry], write=False))
-        # add actually resolves the null-hex-sha for us as a feature, but we can
-        # edit the index manually
-        assert rw_repo.index.entries[manifest_key].binsha != Object.NULL_BIN_SHA
-        # must operate on the same index for this ! Its a bit problematic as
-        # it might confuse people
-        index = rw_repo.index
-        index.entries[manifest_key] = IndexEntry.from_base(manifest_fake_entry)
-        index.write()
-        assert rw_repo.index.entries[manifest_key].hexsha == Diff.NULL_HEX_SHA
-
-        # write an unchanged index ( just for the fun of it )
-        rw_repo.index.write()
-
-        # a three way merge would result in a conflict and fails as the command will
-        # not overwrite any entries in our index and hence leave them unmerged. This is
-        # mainly a protection feature as the current index is not yet in a tree
-        self.failUnlessRaises(GitCommandError, index.merge_tree, next_commit, base=parent_commit)
-
-        # the only way to get the merged entries is to safe the current index away into a tree,
-        # which is like a temporary commit for us. This fails as well as the NULL sha deos not
-        # have a corresponding object
-        # NOTE: missing_ok is not a kwarg anymore, missing_ok is always true
-        # self.failUnlessRaises(GitCommandError, index.write_tree)
-
-        # if missing objects are okay, this would work though ( they are always okay now )
-        # As we can't read back the tree with NULL_SHA, we rather set it to something else
-        index.entries[manifest_key] = IndexEntry(manifest_entry[:1] + (hex_to_bin('f' * 40),) + manifest_entry[2:])
-        tree = index.write_tree()
-
-        # now make a proper three way merge with unmerged entries
-        unmerged_tree = IndexFile.from_tree(rw_repo, parent_commit, tree, next_commit)
-        unmerged_blobs = unmerged_tree.unmerged_blobs()
-        assert len(unmerged_blobs) == 1 and list(unmerged_blobs.keys())[0] == manifest_key[0]
-
-    @with_rw_repo('0.1.6')
-    def test_index_file_diffing(self, rw_repo):
-        # default Index instance points to our index
-        index = IndexFile(rw_repo)
-        assert index.path is not None
-        assert len(index.entries)
-
-        # write the file back
-        index.write()
-
-        # could sha it, or check stats
-
-        # test diff
-        # resetting the head will leave the index in a different state, and the
-        # diff will yield a few changes
-        cur_head_commit = rw_repo.head.reference.commit
-        rw_repo.head.reset('HEAD~6', index=True, working_tree=False)
-
-        # diff against same index is 0
-        diff = index.diff()
-        assert len(diff) == 0
-
-        # against HEAD as string, must be the same as it matches index
-        diff = index.diff('HEAD')
-        assert len(diff) == 0
-
-        # against previous head, there must be a difference
-        diff = index.diff(cur_head_commit)
-        assert len(diff)
-
-        # we reverse the result
-        adiff = index.diff(str(cur_head_commit), R=True)
-        odiff = index.diff(cur_head_commit, R=False)    # now its not reversed anymore
-        assert adiff != odiff
-        assert odiff == diff                    # both unreversed diffs against HEAD
-
-        # against working copy - its still at cur_commit
-        wdiff = index.diff(None)
-        assert wdiff != adiff
-        assert wdiff != odiff
-
-        # against something unusual
-        self.failUnlessRaises(ValueError, index.diff, int)
-
-        # adjust the index to match an old revision
-        cur_branch = rw_repo.active_branch
-        cur_commit = cur_branch.commit
-        rev_head_parent = 'HEAD~1'
-        assert index.reset(rev_head_parent) is index
-
-        assert cur_branch == rw_repo.active_branch
-        assert cur_commit == rw_repo.head.commit
-
-        # there must be differences towards the working tree which is in the 'future'
-        assert index.diff(None)
-
-        # reset the working copy as well to current head,to pull 'back' as well
-        new_data = b"will be reverted"
-        file_path = os.path.join(rw_repo.working_tree_dir, "CHANGES")
-        fp = open(file_path, "wb")
-        fp.write(new_data)
-        fp.close()
-        index.reset(rev_head_parent, working_tree=True)
-        assert not index.diff(None)
-        assert cur_branch == rw_repo.active_branch
-        assert cur_commit == rw_repo.head.commit
-        fp = open(file_path, 'rb')
-        try:
-            assert fp.read() != new_data
-        finally:
-            fp.close()
-
-        # test full checkout
-        test_file = os.path.join(rw_repo.working_tree_dir, "CHANGES")
-        open(test_file, 'ab').write(b"some data")
-        rval = index.checkout(None, force=True, fprogress=self._fprogress)
-        assert 'CHANGES' in list(rval)
-        self._assert_fprogress([None])
-        assert os.path.isfile(test_file)
-
-        os.remove(test_file)
-        rval = index.checkout(None, force=False, fprogress=self._fprogress)
-        assert 'CHANGES' in list(rval)
-        self._assert_fprogress([None])
-        assert os.path.isfile(test_file)
-
-        # individual file
-        os.remove(test_file)
-        rval = index.checkout(test_file, fprogress=self._fprogress)
-        assert list(rval)[0] == 'CHANGES'
-        self._assert_fprogress([test_file])
-        assert os.path.exists(test_file)
-
-        # checking out non-existing file throws
-        self.failUnlessRaises(CheckoutError, index.checkout, "doesnt_exist_ever.txt.that")
-        self.failUnlessRaises(CheckoutError, index.checkout, paths=["doesnt/exist"])
-
-        # checkout file with modifications
-        append_data = b"hello"
-        fp = open(test_file, "ab")
-        fp.write(append_data)
-        fp.close()
-        try:
-            index.checkout(test_file)
-        except CheckoutError as e:
-            assert len(e.failed_files) == 1 and e.failed_files[0] == os.path.basename(test_file)
-            assert (len(e.failed_files) == len(e.failed_reasons)) and isinstance(e.failed_reasons[0], string_types)
-            assert len(e.valid_files) == 0
-            assert open(test_file, 'rb').read().endswith(append_data)
-        else:
-            raise AssertionError("Exception CheckoutError not thrown")
-
-        # if we force it it should work
-        index.checkout(test_file, force=True)
-        assert not open(test_file, 'rb').read().endswith(append_data)
-
-        # checkout directory
-        shutil.rmtree(os.path.join(rw_repo.working_tree_dir, "lib"))
-        rval = index.checkout('lib')
-        assert len(list(rval)) > 1
-
-    def _count_existing(self, repo, files):
-        """
-        Returns count of files that actually exist in the repository directory.
-        """
-        existing = 0
-        basedir = repo.working_tree_dir
-        for f in files:
-            existing += os.path.isfile(os.path.join(basedir, f))
-        # END for each deleted file
-        return existing
-    # END num existing helper
-
-    @with_rw_repo('0.1.6')
-    def test_index_mutation(self, rw_repo):
-        index = rw_repo.index
-        num_entries = len(index.entries)
-        cur_head = rw_repo.head
-
-        uname = "Some Developer"
-        umail = "sd@company.com"
-        writer = rw_repo.config_writer()
-        writer.set_value("user", "name", uname)
-        writer.set_value("user", "email", umail)
-        writer.release()
-
-        # remove all of the files, provide a wild mix of paths, BaseIndexEntries,
-        # IndexEntries
-        def mixed_iterator():
-            count = 0
-            for entry in index.entries.values():
-                type_id = count % 4
-                if type_id == 0:    # path
-                    yield entry.path
-                elif type_id == 1:  # blob
-                    yield Blob(rw_repo, entry.binsha, entry.mode, entry.path)
-                elif type_id == 2:  # BaseIndexEntry
-                    yield BaseIndexEntry(entry[:4])
-                elif type_id == 3:  # IndexEntry
-                    yield entry
-                else:
-                    raise AssertionError("Invalid Type")
-                count += 1
-            # END for each entry
-        # END mixed iterator
-        deleted_files = index.remove(mixed_iterator(), working_tree=False)
-        assert deleted_files
-        assert self._count_existing(rw_repo, deleted_files) == len(deleted_files)
-        assert len(index.entries) == 0
-
-        # reset the index to undo our changes
-        index.reset()
-        assert len(index.entries) == num_entries
-
-        # remove with working copy
-        deleted_files = index.remove(mixed_iterator(), working_tree=True)
-        assert deleted_files
-        assert self._count_existing(rw_repo, deleted_files) == 0
-
-        # reset everything
-        index.reset(working_tree=True)
-        assert self._count_existing(rw_repo, deleted_files) == len(deleted_files)
-
-        # invalid type
-        self.failUnlessRaises(TypeError, index.remove, [1])
-
-        # absolute path
-        deleted_files = index.remove([os.path.join(rw_repo.working_tree_dir, "lib")], r=True)
-        assert len(deleted_files) > 1
-        self.failUnlessRaises(ValueError, index.remove, ["/doesnt/exists"])
-
-        # TEST COMMITTING
-        # commit changed index
-        cur_commit = cur_head.commit
-        commit_message = u"commit default head by Frèderic Çaufl€"
-
-        new_commit = index.commit(commit_message, head=False)
-        assert cur_commit != new_commit
-        assert new_commit.author.name == uname
-        assert new_commit.author.email == umail
-        assert new_commit.committer.name == uname
-        assert new_commit.committer.email == umail
-        assert new_commit.message == commit_message
-        assert new_commit.parents[0] == cur_commit
-        assert len(new_commit.parents) == 1
-        assert cur_head.commit == cur_commit
-
-        # commit with other actor
-        cur_commit = cur_head.commit
-
-        my_author = Actor(u"Frèderic Çaufl€", "author@example.com")
-        my_committer = Actor(u"Committing Frèderic Çaufl€", "committer@example.com")
-        commit_actor = index.commit(commit_message, author=my_author, committer=my_committer)
-        assert cur_commit != commit_actor
-        assert commit_actor.author.name == u"Frèderic Çaufl€"
-        assert commit_actor.author.email == "author@example.com"
-        assert commit_actor.committer.name == u"Committing Frèderic Çaufl€"
-        assert commit_actor.committer.email == "committer@example.com"
-        assert commit_actor.message == commit_message
-        assert commit_actor.parents[0] == cur_commit
-        assert len(new_commit.parents) == 1
-        assert cur_head.commit == commit_actor
-        assert cur_head.log()[-1].actor == my_committer
-
-        # same index, no parents
-        commit_message = "index without parents"
-        commit_no_parents = index.commit(commit_message, parent_commits=list(), head=True)
-        assert commit_no_parents.message == commit_message
-        assert len(commit_no_parents.parents) == 0
-        assert cur_head.commit == commit_no_parents
-
-        # same index, multiple parents
-        commit_message = "Index with multiple parents\n    commit with another line"
-        commit_multi_parent = index.commit(commit_message, parent_commits=(commit_no_parents, new_commit))
-        assert commit_multi_parent.message == commit_message
-        assert len(commit_multi_parent.parents) == 2
-        assert commit_multi_parent.parents[0] == commit_no_parents
-        assert commit_multi_parent.parents[1] == new_commit
-        assert cur_head.commit == commit_multi_parent
-
-        # re-add all files in lib
-        # get the lib folder back on disk, but get an index without it
-        index.reset(new_commit.parents[0], working_tree=True).reset(new_commit, working_tree=False)
-        lib_file_path = os.path.join("lib", "git", "__init__.py")
-        assert (lib_file_path, 0) not in index.entries
-        assert os.path.isfile(os.path.join(rw_repo.working_tree_dir, lib_file_path))
-
-        # directory
-        entries = index.add(['lib'], fprogress=self._fprogress_add)
-        self._assert_entries(entries)
-        self._assert_fprogress(entries)
-        assert len(entries) > 1
-
-        # glob
-        entries = index.reset(new_commit).add([os.path.join('lib', 'git', '*.py')], fprogress=self._fprogress_add)
-        self._assert_entries(entries)
-        self._assert_fprogress(entries)
-        assert len(entries) == 14
-
-        # same file
-        entries = index.reset(new_commit).add(
-            [os.path.join(rw_repo.working_tree_dir, 'lib', 'git', 'head.py')] * 2, fprogress=self._fprogress_add)
-        self._assert_entries(entries)
-        assert entries[0].mode & 0o644 == 0o644
-        # would fail, test is too primitive to handle this case
-        # self._assert_fprogress(entries)
-        self._reset_progress()
-        assert len(entries) == 2
-
-        # missing path
-        self.failUnlessRaises(OSError, index.reset(new_commit).add, ['doesnt/exist/must/raise'])
-
-        # blob from older revision overrides current index revision
-        old_blob = new_commit.parents[0].tree.blobs[0]
-        entries = index.reset(new_commit).add([old_blob], fprogress=self._fprogress_add)
-        self._assert_entries(entries)
-        self._assert_fprogress(entries)
-        assert index.entries[(old_blob.path, 0)].hexsha == old_blob.hexsha and len(entries) == 1
-
-        # mode 0 not allowed
-        null_hex_sha = Diff.NULL_HEX_SHA
-        null_bin_sha = b"\0" * 20
-        self.failUnlessRaises(ValueError, index.reset(
-            new_commit).add, [BaseIndexEntry((0, null_bin_sha, 0, "doesntmatter"))])
-
-        # add new file
-        new_file_relapath = "my_new_file"
-        self._make_file(new_file_relapath, "hello world", rw_repo)
-        entries = index.reset(new_commit).add(
-            [BaseIndexEntry((0o10644, null_bin_sha, 0, new_file_relapath))], fprogress=self._fprogress_add)
-        self._assert_entries(entries)
-        self._assert_fprogress(entries)
-        assert len(entries) == 1 and entries[0].hexsha != null_hex_sha
-
-        # add symlink
-        if sys.platform != "win32":
-            basename = "my_real_symlink"
-            target = "/etc/that"
-            link_file = os.path.join(rw_repo.working_tree_dir, basename)
-            os.symlink(target, link_file)
-            entries = index.reset(new_commit).add([link_file], fprogress=self._fprogress_add)
-            self._assert_entries(entries)
-            self._assert_fprogress(entries)
-            assert len(entries) == 1 and S_ISLNK(entries[0].mode)
-            assert S_ISLNK(index.entries[index.entry_key("my_real_symlink", 0)].mode)
-
-            # we expect only the target to be written
-            assert index.repo.odb.stream(entries[0].binsha).read().decode('ascii') == target
-        # END real symlink test
-
-        # add fake symlink and assure it checks-our as symlink
-        fake_symlink_relapath = "my_fake_symlink"
-        link_target = "/etc/that"
-        fake_symlink_path = self._make_file(fake_symlink_relapath, link_target, rw_repo)
-        fake_entry = BaseIndexEntry((0o120000, null_bin_sha, 0, fake_symlink_relapath))
-        entries = index.reset(new_commit).add([fake_entry], fprogress=self._fprogress_add)
-        self._assert_entries(entries)
-        self._assert_fprogress(entries)
-        assert entries[0].hexsha != null_hex_sha
-        assert len(entries) == 1 and S_ISLNK(entries[0].mode)
-
-        # assure this also works with an alternate method
-        full_index_entry = IndexEntry.from_base(BaseIndexEntry((0o120000, entries[0].binsha, 0, entries[0].path)))
-        entry_key = index.entry_key(full_index_entry)
-        index.reset(new_commit)
-
-        assert entry_key not in index.entries
-        index.entries[entry_key] = full_index_entry
-        index.write()
-        index.update()  # force reread of entries
-        new_entry = index.entries[entry_key]
-        assert S_ISLNK(new_entry.mode)
-
-        # a tree created from this should contain the symlink
-        tree = index.write_tree()
-        assert fake_symlink_relapath in tree
-        index.write()                       # flush our changes for the checkout
-
-        # checkout the fakelink, should be a link then
-        assert not S_ISLNK(os.stat(fake_symlink_path)[ST_MODE])
-        os.remove(fake_symlink_path)
-        index.checkout(fake_symlink_path)
-
-        # on windows we will never get symlinks
-        if os.name == 'nt':
-            # simlinks should contain the link as text ( which is what a
-            # symlink actually is )
-            open(fake_symlink_path, 'rb').read() == link_target
-        else:
-            assert S_ISLNK(os.lstat(fake_symlink_path)[ST_MODE])
-
-        # TEST RENAMING
-        def assert_mv_rval(rval):
-            for source, dest in rval:
-                assert not os.path.exists(source) and os.path.exists(dest)
-            # END for each renamed item
-        # END move assertion utility
-
-        self.failUnlessRaises(ValueError, index.move, ['just_one_path'])
-        # file onto existing file
-        files = ['AUTHORS', 'LICENSE']
-        self.failUnlessRaises(GitCommandError, index.move, files)
-
-        # again, with force
-        assert_mv_rval(index.move(files, f=True))
-
-        # files into directory - dry run
-        paths = ['LICENSE', 'VERSION', 'doc']
-        rval = index.move(paths, dry_run=True)
-        assert len(rval) == 2
-        assert os.path.exists(paths[0])
-
-        # again, no dry run
-        rval = index.move(paths)
-        assert_mv_rval(rval)
-
-        # dir into dir
-        rval = index.move(['doc', 'test'])
-        assert_mv_rval(rval)
-
-        # TEST PATH REWRITING
-        ######################
-        count = [0]
-
-        def rewriter(entry):
-            rval = str(count[0])
-            count[0] += 1
-            return rval
-        # END rewriter
-
-        def make_paths():
-            # two existing ones, one new one
-            yield 'CHANGES'
-            yield 'ez_setup.py'
-            yield index.entries[index.entry_key('README', 0)]
-            yield index.entries[index.entry_key('.gitignore', 0)]
-
-            for fid in range(3):
-                fname = 'newfile%i' % fid
-                open(fname, 'wb').write(b"abcd")
-                yield Blob(rw_repo, Blob.NULL_BIN_SHA, 0o100644, fname)
-            # END for each new file
-        # END path producer
-        paths = list(make_paths())
-        self._assert_entries(index.add(paths, path_rewriter=rewriter))
-
-        for filenum in range(len(paths)):
-            assert index.entry_key(str(filenum), 0) in index.entries
-
-        # TEST RESET ON PATHS
-        ######################
-        arela = "aa"
-        brela = "bb"
-        afile = self._make_file(arela, "adata", rw_repo)
-        bfile = self._make_file(brela, "bdata", rw_repo)
-        akey = index.entry_key(arela, 0)
-        bkey = index.entry_key(brela, 0)
-        keys = (akey, bkey)
-        absfiles = (afile, bfile)
-        files = (arela, brela)
-
-        for fkey in keys:
-            assert fkey not in index.entries
-
-        index.add(files, write=True)
-        if os.name != 'nt':
-            hp = hook_path('pre-commit', index.repo.git_dir)
-            with open(hp, "wt") as fp:
-                fp.write("#!/usr/bin/env sh\necho stdout; echo stderr 1>&2; exit 1")
-            # end
-            os.chmod(hp, 0o544)
-            try:
-                index.commit("This should fail")
-            except HookExecutionError as err:
-                assert err.status == 1
-                assert err.command == hp
-                assert err.stdout == 'stdout\n'
-                assert err.stderr == 'stderr\n'
-                assert str(err)
-            else:
-                raise AssertionError("Should have cought a HookExecutionError")
-            # end exception handling
-            os.remove(hp)
-        # end hook testing
-        nc = index.commit("2 files committed", head=False)
-
-        for fkey in keys:
-            assert fkey in index.entries
-
-        # just the index
-        index.reset(paths=(arela, afile))
-        assert akey not in index.entries
-        assert bkey in index.entries
-
-        # now with working tree - files on disk as well as entries must be recreated
-        rw_repo.head.commit = nc
-        for absfile in absfiles:
-            os.remove(absfile)
-
-        index.reset(working_tree=True, paths=files)
-
-        for fkey in keys:
-            assert fkey in index.entries
-        for absfile in absfiles:
-            assert os.path.isfile(absfile)
-
-    @with_rw_repo('HEAD')
-    def test_compare_write_tree(self, rw_repo):
-        # write all trees and compare them
-        # its important to have a few submodules in there too
-        max_count = 25
-        count = 0
-        for commit in rw_repo.head.commit.traverse():
-            if count >= max_count:
-                break
-            count += 1
-            index = rw_repo.index.reset(commit)
-            orig_tree = commit.tree
-            assert index.write_tree() == orig_tree
-        # END for each commit
-
-    def test_index_new(self):
-        B = self.rorepo.tree("6d9b1f4f9fa8c9f030e3207e7deacc5d5f8bba4e")
-        H = self.rorepo.tree("25dca42bac17d511b7e2ebdd9d1d679e7626db5f")
-        M = self.rorepo.tree("e746f96bcc29238b79118123028ca170adc4ff0f")
-
-        for args in ((B,), (B, H), (B, H, M)):
-            index = IndexFile.new(self.rorepo, *args)
-            assert isinstance(index, IndexFile)
-        # END for each arg tuple
-
-    @with_rw_repo('HEAD', bare=True)
-    def test_index_bare_add(self, rw_bare_repo):
-        # Something is wrong after cloning to a bare repo, reading the
-        # property rw_bare_repo.working_tree_dir will return '/tmp'
-        # instead of throwing the Exception we are expecting. This is
-        # a quick hack to make this test fail when expected.
-        rw_bare_repo._working_tree_dir = None
-        contents = b'This is a BytesIO file'
-        filesize = len(contents)
-        fileobj = BytesIO(contents)
-        filename = 'my-imaginary-file'
-        istream = rw_bare_repo.odb.store(
-            IStream(Blob.type, filesize, fileobj))
-        entry = BaseIndexEntry((0o100644, istream.binsha, 0, filename))
-        try:
-            rw_bare_repo.index.add([entry])
-        except AssertionError:
-            self.fail("Adding to the index of a bare repo is not allowed.")
-
-        # Adding using a path should still require a non-bare repository.
-        asserted = False
-        path = os.path.join('git', 'test', 'test_index.py')
-        try:
-            rw_bare_repo.index.add([path])
-        except Exception as e:
-            asserted = "does not have a working tree" in str(e)
-        assert asserted, "Adding using a filename is not correctly asserted."
diff --git a/git/test/test_reflog.py b/git/test/test_reflog.py
deleted file mode 100644
index 3571e0839..000000000
--- a/git/test/test_reflog.py
+++ /dev/null
@@ -1,107 +0,0 @@
-from git.test.lib import (
-    TestBase,
-    fixture_path
-)
-from git.objects import IndexObject
-from git.refs import (
-    RefLogEntry,
-    RefLog
-)
-from git.util import Actor
-from gitdb.util import hex_to_bin
-
-import tempfile
-import shutil
-import os
-
-
-class TestRefLog(TestBase):
-
-    def test_reflogentry(self):
-        nullhexsha = IndexObject.NULL_HEX_SHA
-        hexsha = 'F' * 40
-        actor = Actor('name', 'email')
-        msg = "message"
-
-        self.failUnlessRaises(ValueError, RefLogEntry.new, nullhexsha, hexsha, 'noactor', 0, 0, "")
-        e = RefLogEntry.new(nullhexsha, hexsha, actor, 0, 1, msg)
-
-        assert e.oldhexsha == nullhexsha
-        assert e.newhexsha == hexsha
-        assert e.actor == actor
-        assert e.time[0] == 0
-        assert e.time[1] == 1
-        assert e.message == msg
-
-        # check representation (roughly)
-        assert repr(e).startswith(nullhexsha)
-
-    def test_base(self):
-        rlp_head = fixture_path('reflog_HEAD')
-        rlp_master = fixture_path('reflog_master')
-        tdir = tempfile.mktemp(suffix="test_reflogs")
-        os.mkdir(tdir)
-
-        rlp_master_ro = RefLog.path(self.rorepo.head)
-        assert os.path.isfile(rlp_master_ro)
-
-        # simple read
-        reflog = RefLog.from_file(rlp_master_ro)
-        assert reflog._path is not None
-        assert isinstance(reflog, RefLog)
-        assert len(reflog)
-
-        # iter_entries works with path and with stream
-        assert len(list(RefLog.iter_entries(open(rlp_master, 'rb'))))
-        assert len(list(RefLog.iter_entries(rlp_master)))
-
-        # raise on invalid revlog
-        # TODO: Try multiple corrupted ones !
-        pp = 'reflog_invalid_'
-        for suffix in ('oldsha', 'newsha', 'email', 'date', 'sep'):
-            self.failUnlessRaises(ValueError, RefLog.from_file, fixture_path(pp + suffix))
-        # END for each invalid file
-
-        # cannot write an uninitialized reflog
-        self.failUnlessRaises(ValueError, RefLog().write)
-
-        # test serialize and deserialize - results must match exactly
-        binsha = hex_to_bin(('f' * 40).encode('ascii'))
-        msg = "my reflog message"
-        cr = self.rorepo.config_reader()
-        for rlp in (rlp_head, rlp_master):
-            reflog = RefLog.from_file(rlp)
-            tfile = os.path.join(tdir, os.path.basename(rlp))
-            reflog.to_file(tfile)
-            assert reflog.write() is reflog
-
-            # parsed result must match ...
-            treflog = RefLog.from_file(tfile)
-            assert treflog == reflog
-
-            # ... as well as each bytes of the written stream
-            assert open(tfile).read() == open(rlp).read()
-
-            # append an entry
-            entry = RefLog.append_entry(cr, tfile, IndexObject.NULL_BIN_SHA, binsha, msg)
-            assert entry.oldhexsha == IndexObject.NULL_HEX_SHA
-            assert entry.newhexsha == 'f' * 40
-            assert entry.message == msg
-            assert RefLog.from_file(tfile)[-1] == entry
-
-            # index entry
-            # raises on invalid index
-            self.failUnlessRaises(IndexError, RefLog.entry_at, rlp, 10000)
-
-            # indices can be positive ...
-            assert isinstance(RefLog.entry_at(rlp, 0), RefLogEntry)
-            RefLog.entry_at(rlp, 23)
-
-            # ... and negative
-            for idx in (-1, -24):
-                RefLog.entry_at(rlp, idx)
-            # END for each index to read
-        # END for each reflog
-
-        # finally remove our temporary data
-        shutil.rmtree(tdir)
diff --git a/git/test/test_remote.py b/git/test/test_remote.py
deleted file mode 100644
index 110f1fa5c..000000000
--- a/git/test/test_remote.py
+++ /dev/null
@@ -1,518 +0,0 @@
-# test_remote.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-from git.test.lib import (
-    TestBase,
-    with_rw_repo,
-    with_rw_and_rw_remote_repo
-)
-from git import (
-    RemoteProgress,
-    FetchInfo,
-    Reference,
-    SymbolicReference,
-    Head,
-    Commit,
-    PushInfo,
-    RemoteReference,
-    TagReference,
-    Remote,
-    GitCommandError
-)
-from git.util import IterableList
-from git.compat import string_types
-import tempfile
-import shutil
-import os
-import random
-
-# assure we have repeatable results
-random.seed(0)
-
-
-class TestRemoteProgress(RemoteProgress):
-    __slots__ = ("_seen_lines", "_stages_per_op", '_num_progress_messages')
-
-    def __init__(self):
-        super(TestRemoteProgress, self).__init__()
-        self._seen_lines = list()
-        self._stages_per_op = dict()
-        self._num_progress_messages = 0
-
-    def _parse_progress_line(self, line):
-        # we may remove the line later if it is dropped
-        # Keep it for debugging
-        self._seen_lines.append(line)
-        rval = super(TestRemoteProgress, self)._parse_progress_line(line)
-        assert len(line) > 1, "line %r too short" % line
-        return rval
-
-    def line_dropped(self, line):
-        try:
-            self._seen_lines.remove(line)
-        except ValueError:
-            pass
-
-    def update(self, op_code, cur_count, max_count=None, message=''):
-        # check each stage only comes once
-        op_id = op_code & self.OP_MASK
-        assert op_id in (self.COUNTING, self.COMPRESSING, self.WRITING)
-
-        self._stages_per_op.setdefault(op_id, 0)
-        self._stages_per_op[op_id] = self._stages_per_op[op_id] | (op_code & self.STAGE_MASK)
-
-        if op_code & (self.WRITING | self.END) == (self.WRITING | self.END):
-            assert message
-        # END check we get message
-
-        self._num_progress_messages += 1
-
-    def make_assertion(self):
-        # we don't always receive messages
-        if not self._seen_lines:
-            return
-
-        # sometimes objects are not compressed which is okay
-        assert len(self._seen_ops) in (2, 3)
-        assert self._stages_per_op
-
-        # must have seen all stages
-        for op, stages in self._stages_per_op.items():
-            assert stages & self.STAGE_MASK == self.STAGE_MASK
-        # END for each op/stage
-
-    def assert_received_message(self):
-        assert self._num_progress_messages
-
-
-class TestRemote(TestBase):
-
-    def _print_fetchhead(self, repo):
-        fp = open(os.path.join(repo.git_dir, "FETCH_HEAD"))
-        fp.close()
-
-    def _do_test_fetch_result(self, results, remote):
-        # self._print_fetchhead(remote.repo)
-        assert len(results) > 0 and isinstance(results[0], FetchInfo)
-        for info in results:
-            assert isinstance(info.note, string_types)
-            if isinstance(info.ref, Reference):
-                assert info.flags != 0
-            # END reference type flags handling
-            assert isinstance(info.ref, (SymbolicReference, Reference))
-            if info.flags & (info.FORCED_UPDATE | info.FAST_FORWARD):
-                assert isinstance(info.old_commit, Commit)
-            else:
-                assert info.old_commit is None
-            # END forced update checking
-        # END for each info
-
-    def _do_test_push_result(self, results, remote):
-        assert len(results) > 0 and isinstance(results[0], PushInfo)
-        for info in results:
-            assert info.flags
-            assert isinstance(info.summary, string_types)
-            if info.old_commit is not None:
-                assert isinstance(info.old_commit, Commit)
-            if info.flags & info.ERROR:
-                has_one = False
-                for bitflag in (info.REJECTED, info.REMOTE_REJECTED, info.REMOTE_FAILURE):
-                    has_one |= bool(info.flags & bitflag)
-                # END for each bitflag
-                assert has_one
-            else:
-                # there must be a remote commit
-                if info.flags & info.DELETED == 0:
-                    assert isinstance(info.local_ref, Reference)
-                else:
-                    assert info.local_ref is None
-                assert type(info.remote_ref) in (TagReference, RemoteReference)
-            # END error checking
-        # END for each info
-
-    def _do_test_fetch_info(self, repo):
-        self.failUnlessRaises(ValueError, FetchInfo._from_line, repo, "nonsense", '')
-        self.failUnlessRaises(
-            ValueError, FetchInfo._from_line, repo, "? [up to date]      0.1.7RC    -> origin/0.1.7RC", '')
-
-    def _commit_random_file(self, repo):
-        # Create a file with a random name and random data and commit it to  repo.
-        # Return the commited absolute file path
-        index = repo.index
-        new_file = self._make_file(os.path.basename(tempfile.mktemp()), str(random.random()), repo)
-        index.add([new_file])
-        index.commit("Committing %s" % new_file)
-        return new_file
-
-    def _do_test_fetch(self, remote, rw_repo, remote_repo):
-        # specialized fetch testing to de-clutter the main test
-        self._do_test_fetch_info(rw_repo)
-
-        def fetch_and_test(remote, **kwargs):
-            progress = TestRemoteProgress()
-            kwargs['progress'] = progress
-            res = remote.fetch(**kwargs)
-            progress.make_assertion()
-            self._do_test_fetch_result(res, remote)
-            return res
-        # END fetch and check
-
-        def get_info(res, remote, name):
-            return res["%s/%s" % (remote, name)]
-
-        # put remote head to master as it is garantueed to exist
-        remote_repo.head.reference = remote_repo.heads.master
-
-        res = fetch_and_test(remote)
-        # all uptodate
-        for info in res:
-            assert info.flags & info.HEAD_UPTODATE
-
-        # rewind remote head to trigger rejection
-        # index must be false as remote is a bare repo
-        rhead = remote_repo.head
-        remote_commit = rhead.commit
-        rhead.reset("HEAD~2", index=False)
-        res = fetch_and_test(remote)
-        mkey = "%s/%s" % (remote, 'master')
-        master_info = res[mkey]
-        assert master_info.flags & FetchInfo.FORCED_UPDATE and master_info.note is not None
-
-        # normal fast forward - set head back to previous one
-        rhead.commit = remote_commit
-        res = fetch_and_test(remote)
-        assert res[mkey].flags & FetchInfo.FAST_FORWARD
-
-        # new remote branch
-        new_remote_branch = Head.create(remote_repo, "new_branch")
-        res = fetch_and_test(remote)
-        new_branch_info = get_info(res, remote, new_remote_branch)
-        assert new_branch_info.flags & FetchInfo.NEW_HEAD
-
-        # remote branch rename ( causes creation of a new one locally )
-        new_remote_branch.rename("other_branch_name")
-        res = fetch_and_test(remote)
-        other_branch_info = get_info(res, remote, new_remote_branch)
-        assert other_branch_info.ref.commit == new_branch_info.ref.commit
-
-        # remove new branch
-        Head.delete(new_remote_branch.repo, new_remote_branch)
-        res = fetch_and_test(remote)
-        # deleted remote will not be fetched
-        self.failUnlessRaises(IndexError, get_info, res, remote, new_remote_branch)
-
-        # prune stale tracking branches
-        stale_refs = remote.stale_refs
-        assert len(stale_refs) == 2 and isinstance(stale_refs[0], RemoteReference)
-        RemoteReference.delete(rw_repo, *stale_refs)
-
-        # test single branch fetch with refspec including target remote
-        res = fetch_and_test(remote, refspec="master:refs/remotes/%s/master" % remote)
-        assert len(res) == 1 and get_info(res, remote, 'master')
-
-        # ... with respec and no target
-        res = fetch_and_test(remote, refspec='master')
-        assert len(res) == 1
-
-        # ... multiple refspecs ... works, but git command returns with error if one ref is wrong without
-        # doing anything. This is new in  later binaries
-        # res = fetch_and_test(remote, refspec=['master', 'fred'])
-        # assert len(res) == 1
-
-        # add new tag reference
-        rtag = TagReference.create(remote_repo, "1.0-RV_hello.there")
-        res = fetch_and_test(remote, tags=True)
-        tinfo = res[str(rtag)]
-        assert isinstance(tinfo.ref, TagReference) and tinfo.ref.commit == rtag.commit
-        assert tinfo.flags & tinfo.NEW_TAG
-
-        # adjust tag commit
-        Reference.set_object(rtag, rhead.commit.parents[0].parents[0])
-        res = fetch_and_test(remote, tags=True)
-        tinfo = res[str(rtag)]
-        assert tinfo.commit == rtag.commit
-        assert tinfo.flags & tinfo.TAG_UPDATE
-
-        # delete remote tag - local one will stay
-        TagReference.delete(remote_repo, rtag)
-        res = fetch_and_test(remote, tags=True)
-        self.failUnlessRaises(IndexError, get_info, res, remote, str(rtag))
-
-        # provoke to receive actual objects to see what kind of output we have to
-        # expect. For that we need a remote transport protocol
-        # Create a new UN-shared repo and fetch into it after we pushed a change
-        # to the shared repo
-        other_repo_dir = tempfile.mktemp("other_repo")
-        # must clone with a local path for the repo implementation not to freak out
-        # as it wants local paths only ( which I can understand )
-        other_repo = remote_repo.clone(other_repo_dir, shared=False)
-        remote_repo_url = "git://localhost%s" % remote_repo.git_dir
-
-        # put origin to git-url
-        other_origin = other_repo.remotes.origin
-        other_origin.config_writer.set("url", remote_repo_url)
-        # it automatically creates alternates as remote_repo is shared as well.
-        # It will use the transport though and ignore alternates when fetching
-        # assert not other_repo.alternates  # this would fail
-
-        # assure we are in the right state
-        rw_repo.head.reset(remote.refs.master, working_tree=True)
-        try:
-            self._commit_random_file(rw_repo)
-            remote.push(rw_repo.head.reference)
-
-            # here I would expect to see remote-information about packing
-            # objects and so on. Unfortunately, this does not happen
-            # if we are redirecting the output - git explicitly checks for this
-            # and only provides progress information to ttys
-            res = fetch_and_test(other_origin)
-        finally:
-            shutil.rmtree(other_repo_dir)
-        # END test and cleanup
-
-    def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
-        # push our changes
-        lhead = rw_repo.head
-        # assure we are on master and it is checked out where the remote is
-        try:
-            lhead.reference = rw_repo.heads.master
-        except AttributeError:
-            # if the author is on a non-master branch, the clones might not have
-            # a local master yet. We simply create it
-            lhead.reference = rw_repo.create_head('master')
-        # END master handling
-        lhead.reset(remote.refs.master, working_tree=True)
-
-        # push without spec should fail ( without further configuration )
-        # well, works nicely
-        # self.failUnlessRaises(GitCommandError, remote.push)
-
-        # simple file push
-        self._commit_random_file(rw_repo)
-        progress = TestRemoteProgress()
-        res = remote.push(lhead.reference, progress)
-        assert isinstance(res, IterableList)
-        self._do_test_push_result(res, remote)
-        progress.make_assertion()
-
-        # rejected - undo last commit
-        lhead.reset("HEAD~1")
-        res = remote.push(lhead.reference)
-        assert res[0].flags & PushInfo.ERROR
-        assert res[0].flags & PushInfo.REJECTED
-        self._do_test_push_result(res, remote)
-
-        # force rejected pull
-        res = remote.push('+%s' % lhead.reference)
-        assert res[0].flags & PushInfo.ERROR == 0
-        assert res[0].flags & PushInfo.FORCED_UPDATE
-        self._do_test_push_result(res, remote)
-
-        # invalid refspec
-        res = remote.push("hellothere")
-        assert len(res) == 0
-
-        # push new tags
-        progress = TestRemoteProgress()
-        to_be_updated = "my_tag.1.0RV"
-        new_tag = TagReference.create(rw_repo, to_be_updated)
-        other_tag = TagReference.create(rw_repo, "my_obj_tag.2.1aRV", message="my message")
-        res = remote.push(progress=progress, tags=True)
-        assert res[-1].flags & PushInfo.NEW_TAG
-        progress.make_assertion()
-        self._do_test_push_result(res, remote)
-
-        # update push new tags
-        # Rejection is default
-        new_tag = TagReference.create(rw_repo, to_be_updated, ref='HEAD~1', force=True)
-        res = remote.push(tags=True)
-        self._do_test_push_result(res, remote)
-        assert res[-1].flags & PushInfo.REJECTED and res[-1].flags & PushInfo.ERROR
-
-        # push force this tag
-        res = remote.push("+%s" % new_tag.path)
-        assert res[-1].flags & PushInfo.ERROR == 0 and res[-1].flags & PushInfo.FORCED_UPDATE
-
-        # delete tag - have to do it using refspec
-        res = remote.push(":%s" % new_tag.path)
-        self._do_test_push_result(res, remote)
-        assert res[0].flags & PushInfo.DELETED
-        # Currently progress is not properly transferred, especially not using
-        # the git daemon
-        # progress.assert_received_message()
-
-        # push new branch
-        new_head = Head.create(rw_repo, "my_new_branch")
-        progress = TestRemoteProgress()
-        res = remote.push(new_head, progress)
-        assert len(res) > 0
-        assert res[0].flags & PushInfo.NEW_HEAD
-        progress.make_assertion()
-        self._do_test_push_result(res, remote)
-
-        # delete new branch on the remote end and locally
-        res = remote.push(":%s" % new_head.path)
-        self._do_test_push_result(res, remote)
-        Head.delete(rw_repo, new_head)
-        assert res[-1].flags & PushInfo.DELETED
-
-        # --all
-        res = remote.push(all=True)
-        self._do_test_push_result(res, remote)
-
-        remote.pull('master')
-
-        # cleanup - delete created tags and branches as we are in an innerloop on
-        # the same repository
-        TagReference.delete(rw_repo, new_tag, other_tag)
-        remote.push(":%s" % other_tag.path)
-
-    @with_rw_and_rw_remote_repo('0.1.6')
-    def test_base(self, rw_repo, remote_repo):
-        num_remotes = 0
-        remote_set = set()
-        ran_fetch_test = False
-
-        for remote in rw_repo.remotes:
-            num_remotes += 1
-            assert remote == remote
-            assert str(remote) != repr(remote)
-            remote_set.add(remote)
-            remote_set.add(remote)  # should already exist
-
-            # REFS
-            refs = remote.refs
-            assert refs
-            for ref in refs:
-                assert ref.remote_name == remote.name
-                assert ref.remote_head
-            # END for each ref
-
-            # OPTIONS
-            # cannot use 'fetch' key anymore as it is now a method
-            for opt in ("url", ):
-                val = getattr(remote, opt)
-                reader = remote.config_reader
-                assert reader.get(opt) == val
-                assert reader.get_value(opt, None) == val
-
-                # unable to write with a reader
-                self.failUnlessRaises(IOError, reader.set, opt, "test")
-
-                # change value
-                writer = remote.config_writer
-                new_val = "myval"
-                writer.set(opt, new_val)
-                assert writer.get(opt) == new_val
-                writer.set(opt, val)
-                assert writer.get(opt) == val
-                del(writer)
-                assert getattr(remote, opt) == val
-            # END for each default option key
-
-            # RENAME
-            other_name = "totally_other_name"
-            prev_name = remote.name
-            assert remote.rename(other_name) == remote
-            assert prev_name != remote.name
-            # multiple times
-            for time in range(2):
-                assert remote.rename(prev_name).name == prev_name
-            # END for each rename ( back to prev_name )
-
-            # PUSH/PULL TESTING
-            self._assert_push_and_pull(remote, rw_repo, remote_repo)
-
-            # FETCH TESTING
-            # Only for remotes - local cases are the same or less complicated
-            # as additional progress information will never be emitted
-            if remote.name == "daemon_origin":
-                self._do_test_fetch(remote, rw_repo, remote_repo)
-                ran_fetch_test = True
-            # END fetch test
-
-            remote.update()
-        # END for each remote
-
-        assert ran_fetch_test
-        assert num_remotes
-        assert num_remotes == len(remote_set)
-
-        origin = rw_repo.remote('origin')
-        assert origin == rw_repo.remotes.origin
-
-    @with_rw_repo('HEAD', bare=True)
-    def test_creation_and_removal(self, bare_rw_repo):
-        new_name = "test_new_one"
-        arg_list = (new_name, "git@server:hello.git")
-        remote = Remote.create(bare_rw_repo, *arg_list)
-        assert remote.name == "test_new_one"
-        assert remote in bare_rw_repo.remotes
-
-        # create same one again
-        self.failUnlessRaises(GitCommandError, Remote.create, bare_rw_repo, *arg_list)
-
-        Remote.remove(bare_rw_repo, new_name)
-
-        for remote in bare_rw_repo.remotes:
-            if remote.name == new_name:
-                raise AssertionError("Remote removal failed")
-            # END if deleted remote matches existing remote's name
-        # END for each remote
-
-    def test_fetch_info(self):
-        # assure we can handle remote-tracking branches
-        fetch_info_line_fmt = "c437ee5deb8d00cf02f03720693e4c802e99f390	not-for-merge	%s '0.3' of "
-        fetch_info_line_fmt += "git://github.com/gitpython-developers/GitPython"
-        remote_info_line_fmt = "* [new branch]      nomatter     -> %s"
-        fi = FetchInfo._from_line(self.rorepo,
-                                  remote_info_line_fmt % "local/master",
-                                  fetch_info_line_fmt % 'remote-tracking branch')
-        assert not fi.ref.is_valid()
-        assert fi.ref.name == "local/master"
-
-        # handles non-default refspecs: One can specify a different path in refs/remotes
-        # or a special path just in refs/something for instance
-
-        fi = FetchInfo._from_line(self.rorepo,
-                                  remote_info_line_fmt % "subdir/tagname",
-                                  fetch_info_line_fmt % 'tag')
-
-        assert isinstance(fi.ref, TagReference)
-        assert fi.ref.path.startswith('refs/tags')
-
-        # it could be in a remote direcftory though
-        fi = FetchInfo._from_line(self.rorepo,
-                                  remote_info_line_fmt % "remotename/tags/tagname",
-                                  fetch_info_line_fmt % 'tag')
-
-        assert isinstance(fi.ref, TagReference)
-        assert fi.ref.path.startswith('refs/remotes/')
-
-        # it can also be anywhere !
-        tag_path = "refs/something/remotename/tags/tagname"
-        fi = FetchInfo._from_line(self.rorepo,
-                                  remote_info_line_fmt % tag_path,
-                                  fetch_info_line_fmt % 'tag')
-
-        assert isinstance(fi.ref, TagReference)
-        assert fi.ref.path == tag_path
-
-        # branches default to refs/remotes
-        fi = FetchInfo._from_line(self.rorepo,
-                                  remote_info_line_fmt % "remotename/branch",
-                                  fetch_info_line_fmt % 'branch')
-
-        assert isinstance(fi.ref, RemoteReference)
-        assert fi.ref.remote_name == 'remotename'
-
-        # but you can force it anywhere, in which case we only have a references
-        fi = FetchInfo._from_line(self.rorepo,
-                                  remote_info_line_fmt % "refs/something/branch",
-                                  fetch_info_line_fmt % 'branch')
-
-        assert type(fi.ref) is Reference
-        assert fi.ref.path == "refs/something/branch"
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
deleted file mode 100644
index 226c1d268..000000000
--- a/git/test/test_repo.py
+++ /dev/null
@@ -1,761 +0,0 @@
-# test_repo.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-from git.test.lib import (
-    patch,
-    TestBase,
-    with_rw_repo,
-    fixture,
-    assert_false,
-    assert_equal,
-    assert_true,
-    raises
-)
-from git import (
-    InvalidGitRepositoryError,
-    Repo,
-    NoSuchPathError,
-    Head,
-    Commit,
-    Tree,
-    IndexFile,
-    Git,
-    Reference,
-    GitDB,
-    Submodule,
-    GitCmdObjectDB,
-    Remote,
-    BadName,
-    GitCommandError
-)
-from git.repo.fun import touch
-from git.util import join_path_native
-from git.exc import BadObject
-from gitdb.util import bin_to_hex
-from git.compat import string_types
-from gitdb.test.lib import with_rw_directory
-
-import os
-import sys
-import tempfile
-import shutil
-from io import BytesIO
-
-
-class TestRepo(TestBase):
-
-    @raises(InvalidGitRepositoryError)
-    def test_new_should_raise_on_invalid_repo_location(self):
-        Repo(tempfile.gettempdir())
-
-    @raises(NoSuchPathError)
-    def test_new_should_raise_on_non_existant_path(self):
-        Repo("repos/foobar")
-
-    @with_rw_repo('0.3.2.1')
-    def test_repo_creation_from_different_paths(self, rw_repo):
-        r_from_gitdir = Repo(rw_repo.git_dir)
-        assert r_from_gitdir.git_dir == rw_repo.git_dir
-        assert r_from_gitdir.git_dir.endswith('.git')
-        assert not rw_repo.git.working_dir.endswith('.git')
-        assert r_from_gitdir.git.working_dir == rw_repo.git.working_dir
-
-    def test_description(self):
-        txt = "Test repository"
-        self.rorepo.description = txt
-        assert_equal(self.rorepo.description, txt)
-
-    def test_heads_should_return_array_of_head_objects(self):
-        for head in self.rorepo.heads:
-            assert_equal(Head, head.__class__)
-
-    def test_heads_should_populate_head_data(self):
-        for head in self.rorepo.heads:
-            assert head.name
-            assert isinstance(head.commit, Commit)
-        # END for each head
-
-        assert isinstance(self.rorepo.heads.master, Head)
-        assert isinstance(self.rorepo.heads['master'], Head)
-
-    def test_tree_from_revision(self):
-        tree = self.rorepo.tree('0.1.6')
-        assert len(tree.hexsha) == 40
-        assert tree.type == "tree"
-        assert self.rorepo.tree(tree) == tree
-
-        # try from invalid revision that does not exist
-        self.failUnlessRaises(BadName, self.rorepo.tree, 'hello world')
-
-    def test_commit_from_revision(self):
-        commit = self.rorepo.commit('0.1.4')
-        assert commit.type == 'commit'
-        assert self.rorepo.commit(commit) == commit
-
-    def test_commits(self):
-        mc = 10
-        commits = list(self.rorepo.iter_commits('0.1.6', max_count=mc))
-        assert len(commits) == mc
-
-        c = commits[0]
-        assert_equal('9a4b1d4d11eee3c5362a4152216376e634bd14cf', c.hexsha)
-        assert_equal(["c76852d0bff115720af3f27acdb084c59361e5f6"], [p.hexsha for p in c.parents])
-        assert_equal("ce41fc29549042f1aa09cc03174896cf23f112e3", c.tree.hexsha)
-        assert_equal("Michael Trier", c.author.name)
-        assert_equal("mtrier@gmail.com", c.author.email)
-        assert_equal(1232829715, c.authored_date)
-        assert_equal(5 * 3600, c.author_tz_offset)
-        assert_equal("Michael Trier", c.committer.name)
-        assert_equal("mtrier@gmail.com", c.committer.email)
-        assert_equal(1232829715, c.committed_date)
-        assert_equal(5 * 3600, c.committer_tz_offset)
-        assert_equal("Bumped version 0.1.6\n", c.message)
-
-        c = commits[1]
-        assert isinstance(c.parents, tuple)
-
-    def test_trees(self):
-        mc = 30
-        num_trees = 0
-        for tree in self.rorepo.iter_trees('0.1.5', max_count=mc):
-            num_trees += 1
-            assert isinstance(tree, Tree)
-        # END for each tree
-        assert num_trees == mc
-
-    def _assert_empty_repo(self, repo):
-        # test all kinds of things with an empty, freshly initialized repo.
-        # It should throw good errors
-
-        # entries should be empty
-        assert len(repo.index.entries) == 0
-
-        # head is accessible
-        assert repo.head
-        assert repo.head.ref
-        assert not repo.head.is_valid()
-
-        # we can change the head to some other ref
-        head_ref = Head.from_path(repo, Head.to_full_path('some_head'))
-        assert not head_ref.is_valid()
-        repo.head.ref = head_ref
-
-        # is_dirty can handle all kwargs
-        for args in ((1, 0, 0), (0, 1, 0), (0, 0, 1)):
-            assert not repo.is_dirty(*args)
-        # END for each arg
-
-        # we can add a file to the index ( if we are not bare )
-        if not repo.bare:
-            pass
-        # END test repos with working tree
-
-    def test_init(self):
-        prev_cwd = os.getcwd()
-        os.chdir(tempfile.gettempdir())
-        git_dir_rela = "repos/foo/bar.git"
-        del_dir_abs = os.path.abspath("repos")
-        git_dir_abs = os.path.abspath(git_dir_rela)
-        try:
-            # with specific path
-            for path in (git_dir_rela, git_dir_abs):
-                r = Repo.init(path=path, bare=True)
-                assert isinstance(r, Repo)
-                assert r.bare is True
-                assert os.path.isdir(r.git_dir)
-
-                self._assert_empty_repo(r)
-
-                # test clone
-                clone_path = path + "_clone"
-                rc = r.clone(clone_path)
-                self._assert_empty_repo(rc)
-
-                try:
-                    shutil.rmtree(clone_path)
-                except OSError:
-                    # when relative paths are used, the clone may actually be inside
-                    # of the parent directory
-                    pass
-                # END exception handling
-
-                # try again, this time with the absolute version
-                rc = Repo.clone_from(r.git_dir, clone_path)
-                self._assert_empty_repo(rc)
-
-                shutil.rmtree(git_dir_abs)
-                try:
-                    shutil.rmtree(clone_path)
-                except OSError:
-                    # when relative paths are used, the clone may actually be inside
-                    # of the parent directory
-                    pass
-                # END exception handling
-
-            # END for each path
-
-            os.makedirs(git_dir_rela)
-            os.chdir(git_dir_rela)
-            r = Repo.init(bare=False)
-            assert r.bare is False
-
-            self._assert_empty_repo(r)
-        finally:
-            try:
-                shutil.rmtree(del_dir_abs)
-            except OSError:
-                pass
-            os.chdir(prev_cwd)
-        # END restore previous state
-
-    def test_bare_property(self):
-        self.rorepo.bare
-
-    def test_daemon_export(self):
-        orig_val = self.rorepo.daemon_export
-        self.rorepo.daemon_export = not orig_val
-        assert self.rorepo.daemon_export == (not orig_val)
-        self.rorepo.daemon_export = orig_val
-        assert self.rorepo.daemon_export == orig_val
-
-    def test_alternates(self):
-        cur_alternates = self.rorepo.alternates
-        # empty alternates
-        self.rorepo.alternates = []
-        assert self.rorepo.alternates == []
-        alts = ["other/location", "this/location"]
-        self.rorepo.alternates = alts
-        assert alts == self.rorepo.alternates
-        self.rorepo.alternates = cur_alternates
-
-    def test_repr(self):
-        assert repr(self.rorepo).startswith('<git.Repo ')
-
-    def test_is_dirty_with_bare_repository(self):
-        orig_value = self.rorepo._bare
-        self.rorepo._bare = True
-        assert_false(self.rorepo.is_dirty())
-        self.rorepo._bare = orig_value
-
-    def test_is_dirty(self):
-        self.rorepo._bare = False
-        for index in (0, 1):
-            for working_tree in (0, 1):
-                for untracked_files in (0, 1):
-                    assert self.rorepo.is_dirty(index, working_tree, untracked_files) in (True, False)
-                # END untracked files
-            # END working tree
-        # END index
-        orig_val = self.rorepo._bare
-        self.rorepo._bare = True
-        assert self.rorepo.is_dirty() is False
-        self.rorepo._bare = orig_val
-
-    def test_head(self):
-        assert self.rorepo.head.reference.object == self.rorepo.active_branch.object
-
-    def test_index(self):
-        index = self.rorepo.index
-        assert isinstance(index, IndexFile)
-
-    def test_tag(self):
-        assert self.rorepo.tag('refs/tags/0.1.5').commit
-
-    def test_archive(self):
-        tmpfile = tempfile.mktemp(suffix='archive-test')
-        stream = open(tmpfile, 'wb')
-        self.rorepo.archive(stream, '0.1.6', path='doc')
-        assert stream.tell()
-        stream.close()
-        os.remove(tmpfile)
-
-    @patch.object(Git, '_call_process')
-    def test_should_display_blame_information(self, git):
-        git.return_value = fixture('blame')
-        b = self.rorepo.blame('master', 'lib/git.py')
-        assert_equal(13, len(b))
-        assert_equal(2, len(b[0]))
-        # assert_equal(25, reduce(lambda acc, x: acc + len(x[-1]), b))
-        assert_equal(hash(b[0][0]), hash(b[9][0]))
-        c = b[0][0]
-        assert_true(git.called)
-
-        assert_equal('634396b2f541a9f2d58b00be1a07f0c358b999b3', c.hexsha)
-        assert_equal('Tom Preston-Werner', c.author.name)
-        assert_equal('tom@mojombo.com', c.author.email)
-        assert_equal(1191997100, c.authored_date)
-        assert_equal('Tom Preston-Werner', c.committer.name)
-        assert_equal('tom@mojombo.com', c.committer.email)
-        assert_equal(1191997100, c.committed_date)
-        assert_equal('initial grit setup', c.message)
-
-        # test the 'lines per commit' entries
-        tlist = b[0][1]
-        assert_true(tlist)
-        assert_true(isinstance(tlist[0], string_types))
-        assert_true(len(tlist) < sum(len(t) for t in tlist))               # test for single-char bug
-
-        # BINARY BLAME
-        git.return_value = fixture('blame_binary')
-        blames = self.rorepo.blame('master', 'rps')
-        assert len(blames) == 2
-
-    def test_blame_real(self):
-        c = 0
-        nml = 0   # amount of multi-lines per blame
-        for item in self.rorepo.head.commit.tree.traverse(
-                predicate=lambda i, d: i.type == 'blob' and i.path.endswith('.py')):
-            c += 1
-
-            for b in self.rorepo.blame(self.rorepo.head, item.path):
-                nml += int(len(b[1]) > 1)
-        # END for each item to traverse
-        assert c, "Should have executed at least one blame command"
-        assert nml, "There should at least be one blame commit that contains multiple lines"
-
-    @patch.object(Git, '_call_process')
-    def test_blame_complex_revision(self, git):
-        git.return_value = fixture('blame_complex_revision')
-        res = self.rorepo.blame("HEAD~10..HEAD", "README.md")
-        assert len(res) == 1
-        assert len(res[0][1]) == 83, "Unexpected amount of parsed blame lines"
-
-    def test_untracked_files(self):
-        base = self.rorepo.working_tree_dir
-        files = (join_path_native(base, "__test_myfile"),
-                 join_path_native(base, "__test_other_file"))
-        num_recently_untracked = 0
-        try:
-            for fpath in files:
-                fd = open(fpath, "wb")
-                fd.close()
-            # END for each filename
-            untracked_files = self.rorepo.untracked_files
-            num_recently_untracked = len(untracked_files)
-
-            # assure we have all names - they are relative to the git-dir
-            num_test_untracked = 0
-            for utfile in untracked_files:
-                num_test_untracked += join_path_native(base, utfile) in files
-            assert len(files) == num_test_untracked
-        finally:
-            for fpath in files:
-                if os.path.isfile(fpath):
-                    os.remove(fpath)
-        # END handle files
-
-        assert len(self.rorepo.untracked_files) == (num_recently_untracked - len(files))
-
-    def test_config_reader(self):
-        reader = self.rorepo.config_reader()                # all config files
-        assert reader.read_only
-        reader = self.rorepo.config_reader("repository")    # single config file
-        assert reader.read_only
-
-    def test_config_writer(self):
-        for config_level in self.rorepo.config_level:
-            try:
-                writer = self.rorepo.config_writer(config_level)
-                assert not writer.read_only
-                writer.release()
-            except IOError:
-                # its okay not to get a writer for some configuration files if we
-                # have no permissions
-                pass
-        # END for each config level
-
-    def test_config_level_paths(self):
-        for config_level in self.rorepo.config_level:
-            assert self.rorepo._get_config_path(config_level)
-        # end for each config level
-
-    def test_creation_deletion(self):
-        # just a very quick test to assure it generally works. There are
-        # specialized cases in the test_refs module
-        head = self.rorepo.create_head("new_head", "HEAD~1")
-        self.rorepo.delete_head(head)
-
-        tag = self.rorepo.create_tag("new_tag", "HEAD~2")
-        self.rorepo.delete_tag(tag)
-        writer = self.rorepo.config_writer()
-        writer.release()
-        remote = self.rorepo.create_remote("new_remote", "git@server:repo.git")
-        self.rorepo.delete_remote(remote)
-
-    def test_comparison_and_hash(self):
-        # this is only a preliminary test, more testing done in test_index
-        assert self.rorepo == self.rorepo and not (self.rorepo != self.rorepo)
-        assert len(set((self.rorepo, self.rorepo))) == 1
-
-    @with_rw_directory
-    def test_tilde_and_env_vars_in_repo_path(self, rw_dir):
-        ph = os.environ['HOME']
-        try:
-            os.environ['HOME'] = rw_dir
-            Repo.init(os.path.join('~', 'test.git'), bare=True)
-
-            os.environ['FOO'] = rw_dir
-            Repo.init(os.path.join('$FOO', 'test.git'), bare=True)
-        finally:
-            os.environ['HOME'] = ph
-            del os.environ['FOO']
-        # end assure HOME gets reset to what it was
-
-    def test_git_cmd(self):
-        # test CatFileContentStream, just to be very sure we have no fencepost errors
-        # last \n is the terminating newline that it expects
-        l1 = b"0123456789\n"
-        l2 = b"abcdefghijklmnopqrstxy\n"
-        l3 = b"z\n"
-        d = l1 + l2 + l3 + b"\n"
-
-        l1p = l1[:5]
-
-        # full size
-        # size is without terminating newline
-        def mkfull():
-            return Git.CatFileContentStream(len(d) - 1, BytesIO(d))
-
-        ts = 5
-
-        def mktiny():
-            return Git.CatFileContentStream(ts, BytesIO(d))
-
-        # readlines no limit
-        s = mkfull()
-        lines = s.readlines()
-        assert len(lines) == 3 and lines[-1].endswith(b'\n')
-        assert s._stream.tell() == len(d)   # must have scrubbed to the end
-
-        # realines line limit
-        s = mkfull()
-        lines = s.readlines(5)
-        assert len(lines) == 1
-
-        # readlines on tiny sections
-        s = mktiny()
-        lines = s.readlines()
-        assert len(lines) == 1 and lines[0] == l1p
-        assert s._stream.tell() == ts + 1
-
-        # readline no limit
-        s = mkfull()
-        assert s.readline() == l1
-        assert s.readline() == l2
-        assert s.readline() == l3
-        assert s.readline() == ''
-        assert s._stream.tell() == len(d)
-
-        # readline limit
-        s = mkfull()
-        assert s.readline(5) == l1p
-        assert s.readline() == l1[5:]
-
-        # readline on tiny section
-        s = mktiny()
-        assert s.readline() == l1p
-        assert s.readline() == ''
-        assert s._stream.tell() == ts + 1
-
-        # read no limit
-        s = mkfull()
-        assert s.read() == d[:-1]
-        assert s.read() == ''
-        assert s._stream.tell() == len(d)
-
-        # read limit
-        s = mkfull()
-        assert s.read(5) == l1p
-        assert s.read(6) == l1[5:]
-        assert s._stream.tell() == 5 + 6    # its not yet done
-
-        # read tiny
-        s = mktiny()
-        assert s.read(2) == l1[:2]
-        assert s._stream.tell() == 2
-        assert s.read() == l1[2:ts]
-        assert s._stream.tell() == ts + 1
-
-    def _assert_rev_parse_types(self, name, rev_obj):
-        rev_parse = self.rorepo.rev_parse
-
-        if rev_obj.type == 'tag':
-            rev_obj = rev_obj.object
-
-        # tree and blob type
-        obj = rev_parse(name + '^{tree}')
-        assert obj == rev_obj.tree
-
-        obj = rev_parse(name + ':CHANGES')
-        assert obj.type == 'blob' and obj.path == 'CHANGES'
-        assert rev_obj.tree['CHANGES'] == obj
-
-    def _assert_rev_parse(self, name):
-        """tries multiple different rev-parse syntaxes with the given name
-        :return: parsed object"""
-        rev_parse = self.rorepo.rev_parse
-        orig_obj = rev_parse(name)
-        if orig_obj.type == 'tag':
-            obj = orig_obj.object
-        else:
-            obj = orig_obj
-        # END deref tags by default
-
-        # try history
-        rev = name + "~"
-        obj2 = rev_parse(rev)
-        assert obj2 == obj.parents[0]
-        self._assert_rev_parse_types(rev, obj2)
-
-        # history with number
-        ni = 11
-        history = [obj.parents[0]]
-        for pn in range(ni):
-            history.append(history[-1].parents[0])
-        # END get given amount of commits
-
-        for pn in range(11):
-            rev = name + "~%i" % (pn + 1)
-            obj2 = rev_parse(rev)
-            assert obj2 == history[pn]
-            self._assert_rev_parse_types(rev, obj2)
-        # END history check
-
-        # parent ( default )
-        rev = name + "^"
-        obj2 = rev_parse(rev)
-        assert obj2 == obj.parents[0]
-        self._assert_rev_parse_types(rev, obj2)
-
-        # parent with number
-        for pn, parent in enumerate(obj.parents):
-            rev = name + "^%i" % (pn + 1)
-            assert rev_parse(rev) == parent
-            self._assert_rev_parse_types(rev, parent)
-        # END for each parent
-
-        return orig_obj
-
-    @with_rw_repo('HEAD', bare=False)
-    def test_rw_rev_parse(self, rwrepo):
-        # verify it does not confuse branches with hexsha ids
-        ahead = rwrepo.create_head('aaaaaaaa')
-        assert(rwrepo.rev_parse(str(ahead)) == ahead.commit)
-
-    def test_rev_parse(self):
-        rev_parse = self.rorepo.rev_parse
-
-        # try special case: This one failed at some point, make sure its fixed
-        assert rev_parse("33ebe").hexsha == "33ebe7acec14b25c5f84f35a664803fcab2f7781"
-
-        # start from reference
-        num_resolved = 0
-
-        for ref in Reference.iter_items(self.rorepo):
-            path_tokens = ref.path.split("/")
-            for pt in range(len(path_tokens)):
-                path_section = '/'.join(path_tokens[-(pt + 1):])
-                try:
-                    obj = self._assert_rev_parse(path_section)
-                    assert obj.type == ref.object.type
-                    num_resolved += 1
-                except (BadName, BadObject):
-                    print("failed on %s" % path_section)
-                    # is fine, in case we have something like 112, which belongs to remotes/rname/merge-requests/112
-                    pass
-                # END exception handling
-            # END for each token
-        # END for each reference
-        assert num_resolved
-
-        # it works with tags !
-        tag = self._assert_rev_parse('0.1.4')
-        assert tag.type == 'tag'
-
-        # try full sha directly ( including type conversion )
-        assert tag.object == rev_parse(tag.object.hexsha)
-        self._assert_rev_parse_types(tag.object.hexsha, tag.object)
-
-        # multiple tree types result in the same tree: HEAD^{tree}^{tree}:CHANGES
-        rev = '0.1.4^{tree}^{tree}'
-        assert rev_parse(rev) == tag.object.tree
-        assert rev_parse(rev + ':CHANGES') == tag.object.tree['CHANGES']
-
-        # try to get parents from first revision - it should fail as no such revision
-        # exists
-        first_rev = "33ebe7acec14b25c5f84f35a664803fcab2f7781"
-        commit = rev_parse(first_rev)
-        assert len(commit.parents) == 0
-        assert commit.hexsha == first_rev
-        self.failUnlessRaises(BadObject, rev_parse, first_rev + "~")
-        self.failUnlessRaises(BadObject, rev_parse, first_rev + "^")
-
-        # short SHA1
-        commit2 = rev_parse(first_rev[:20])
-        assert commit2 == commit
-        commit2 = rev_parse(first_rev[:5])
-        assert commit2 == commit
-
-        # todo: dereference tag into a blob 0.1.7^{blob} - quite a special one
-        # needs a tag which points to a blob
-
-        # ref^0 returns commit being pointed to, same with ref~0, and ^{}
-        tag = rev_parse('0.1.4')
-        for token in (('~0', '^0', '^{}')):
-            assert tag.object == rev_parse('0.1.4%s' % token)
-        # END handle multiple tokens
-
-        # try partial parsing
-        max_items = 40
-        for i, binsha in enumerate(self.rorepo.odb.sha_iter()):
-            assert rev_parse(bin_to_hex(binsha)[:8 - (i % 2)].decode('ascii')).binsha == binsha
-            if i > max_items:
-                # this is rather slow currently, as rev_parse returns an object
-                # which requires accessing packs, it has some additional overhead
-                break
-        # END for each binsha in repo
-
-        # missing closing brace commit^{tree
-        self.failUnlessRaises(ValueError, rev_parse, '0.1.4^{tree')
-
-        # missing starting brace
-        self.failUnlessRaises(ValueError, rev_parse, '0.1.4^tree}')
-
-        # REVLOG
-        #######
-        head = self.rorepo.head
-
-        # need to specify a ref when using the @ syntax
-        self.failUnlessRaises(BadObject, rev_parse, "%s@{0}" % head.commit.hexsha)
-
-        # uses HEAD.ref by default
-        assert rev_parse('@{0}') == head.commit
-        if not head.is_detached:
-            refspec = '%s@{0}' % head.ref.name
-            assert rev_parse(refspec) == head.ref.commit
-            # all additional specs work as well
-            assert rev_parse(refspec + "^{tree}") == head.commit.tree
-            assert rev_parse(refspec + ":CHANGES").type == 'blob'
-        # END operate on non-detached head
-
-        # position doesn't exist
-        self.failUnlessRaises(IndexError, rev_parse, '@{10000}')
-
-        # currently, nothing more is supported
-        self.failUnlessRaises(NotImplementedError, rev_parse, "@{1 week ago}")
-
-        # the last position
-        assert rev_parse('@{1}') != head.commit
-
-    def test_repo_odbtype(self):
-        target_type = GitDB
-        if sys.version_info[:2] < (2, 5):
-            target_type = GitCmdObjectDB
-        assert isinstance(self.rorepo.odb, target_type)
-
-    def test_submodules(self):
-        assert len(self.rorepo.submodules) == 1     # non-recursive
-        assert len(list(self.rorepo.iter_submodules())) >= 2
-
-        assert isinstance(self.rorepo.submodule("gitdb"), Submodule)
-        self.failUnlessRaises(ValueError, self.rorepo.submodule, "doesn't exist")
-
-    @with_rw_repo('HEAD', bare=False)
-    def test_submodule_update(self, rwrepo):
-        # fails in bare mode
-        rwrepo._bare = True
-        self.failUnlessRaises(InvalidGitRepositoryError, rwrepo.submodule_update)
-        rwrepo._bare = False
-
-        # test create submodule
-        sm = rwrepo.submodules[0]
-        sm = rwrepo.create_submodule("my_new_sub", "some_path", join_path_native(self.rorepo.working_tree_dir, sm.path))
-        assert isinstance(sm, Submodule)
-
-        # note: the rest of this functionality is tested in test_submodule
-
-    @with_rw_repo('HEAD')
-    def test_git_file(self, rwrepo):
-        # Move the .git directory to another location and create the .git file.
-        real_path_abs = os.path.abspath(join_path_native(rwrepo.working_tree_dir, '.real'))
-        os.rename(rwrepo.git_dir, real_path_abs)
-        git_file_path = join_path_native(rwrepo.working_tree_dir, '.git')
-        open(git_file_path, 'wb').write(fixture('git_file'))
-
-        # Create a repo and make sure it's pointing to the relocated .git directory.
-        git_file_repo = Repo(rwrepo.working_tree_dir)
-        assert os.path.abspath(git_file_repo.git_dir) == real_path_abs
-
-        # Test using an absolute gitdir path in the .git file.
-        open(git_file_path, 'wb').write(('gitdir: %s\n' % real_path_abs).encode('ascii'))
-        git_file_repo = Repo(rwrepo.working_tree_dir)
-        assert os.path.abspath(git_file_repo.git_dir) == real_path_abs
-
-    def test_file_handle_leaks(self):
-        def last_commit(repo, rev, path):
-            commit = next(repo.iter_commits(rev, path, max_count=1))
-            commit.tree[path]
-
-        # This is based on this comment
-        # https://github.com/gitpython-developers/GitPython/issues/60#issuecomment-23558741
-        # And we expect to set max handles to a low value, like 64
-        # You should set ulimit -n X, see .travis.yml
-        # The loops below would easily create 500 handles if these would leak (4 pipes + multiple mapped files)
-        for i in range(64):
-            for repo_type in (GitCmdObjectDB, GitDB):
-                repo = Repo(self.rorepo.working_tree_dir, odbt=repo_type)
-                last_commit(repo, 'master', 'git/test/test_base.py')
-            # end for each repository type
-        # end for each iteration
-
-    def test_remote_method(self):
-        self.failUnlessRaises(ValueError, self.rorepo.remote, 'foo-blue')
-        assert isinstance(self.rorepo.remote(name='origin'), Remote)
-
-    @with_rw_directory
-    def test_empty_repo(self, rw_dir):
-        """Assure we can handle empty repositories"""
-        r = Repo.init(rw_dir, mkdir=False)
-        # It's ok not to be able to iterate a commit, as there is none
-        self.failUnlessRaises(ValueError, r.iter_commits)
-        assert r.active_branch.name == 'master'
-        assert not r.active_branch.is_valid(), "Branch is yet to be born"
-
-        # actually, when trying to create a new branch without a commit, git itself fails
-        # We should, however, not fail ungracefully
-        self.failUnlessRaises(BadName, r.create_head, 'foo')
-        self.failUnlessRaises(BadName, r.create_head, 'master')
-        # It's expected to not be able to access a tree
-        self.failUnlessRaises(ValueError, r.tree)
-
-        new_file_path = os.path.join(rw_dir, "new_file.ext")
-        touch(new_file_path)
-        r.index.add([new_file_path])
-        r.index.commit("initial commit")
-
-        # Now a branch should be creatable
-        nb = r.create_head('foo')
-        assert nb.is_valid()
-
-    def test_merge_base(self):
-        repo = self.rorepo
-        c1 = 'f6aa8d1'
-        c2 = repo.commit('d46e3fe')
-        c3 = '763ef75'
-        self.failUnlessRaises(ValueError, repo.merge_base)
-        self.failUnlessRaises(ValueError, repo.merge_base, 'foo')
-
-        # two commit merge-base
-        res = repo.merge_base(c1, c2)
-        assert isinstance(res, list) and len(res) == 1 and isinstance(res[0], Commit)
-        assert res[0].hexsha.startswith('3936084')
-
-        for kw in ('a', 'all'):
-            res = repo.merge_base(c1, c2, c3, **{kw: True})
-            assert isinstance(res, list) and len(res) == 1
-        # end for eaech keyword signalling all merge-bases to be returned
-
-        # Test for no merge base - can't do as we have
-        self.failUnlessRaises(GitCommandError, repo.merge_base, c1, 'ffffff')
diff --git a/git/test/test_stats.py b/git/test/test_stats.py
deleted file mode 100644
index 884ab1abd..000000000
--- a/git/test/test_stats.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# test_stats.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-from git.test.lib import (
-    TestBase,
-    fixture,
-    assert_equal
-)
-from git import Stats
-from git.compat import defenc
-
-
-class TestStats(TestBase):
-
-    def test_list_from_string(self):
-        output = fixture('diff_numstat').decode(defenc)
-        stats = Stats._list_from_string(self.rorepo, output)
-
-        assert_equal(2, stats.total['files'])
-        assert_equal(52, stats.total['lines'])
-        assert_equal(29, stats.total['insertions'])
-        assert_equal(23, stats.total['deletions'])
-
-        assert_equal(29, stats.files["a.txt"]['insertions'])
-        assert_equal(18, stats.files["a.txt"]['deletions'])
-
-        assert_equal(0, stats.files["b.txt"]['insertions'])
-        assert_equal(5, stats.files["b.txt"]['deletions'])
diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py
deleted file mode 100644
index 3e3a97d88..000000000
--- a/git/test/test_submodule.py
+++ /dev/null
@@ -1,616 +0,0 @@
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-import shutil
-import sys
-import os
-
-import git
-
-from git.test.lib import (
-    TestBase,
-    with_rw_repo
-)
-from gitdb.test.lib import with_rw_directory
-from git.exc import InvalidGitRepositoryError
-from git.objects.submodule.base import Submodule
-from git.objects.submodule.root import RootModule, RootUpdateProgress
-from git.util import to_native_path_linux, join_path_native
-from git.compat import string_types
-
-from nose import SkipTest
-
-# Change the configuration if possible to prevent the underlying memory manager
-# to keep file handles open. On windows we get problems as they are not properly
-# closed due to mmap bugs on windows (as it appears)
-if sys.platform == 'win32':
-    try:
-        import smmap.util
-        smmap.util.MapRegion._test_read_into_memory = True
-    except ImportError:
-        sys.stderr.write("The submodule tests will fail as some files cannot be removed due to open file handles.\n")
-        sys.stderr.write(
-            "The latest version of gitdb uses a memory map manager which can be configured to work around this problem")
-# END handle windows platform
-
-
-class TestRootProgress(RootUpdateProgress):
-
-    """Just prints messages, for now without checking the correctness of the states"""
-
-    def update(self, op, index, max_count, message=''):
-        print(message)
-
-prog = TestRootProgress()
-
-
-class TestSubmodule(TestBase):
-
-    k_subm_current = "468cad66ff1f80ddaeee4123c24e4d53a032c00d"
-    k_subm_changed = "394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3"
-    k_no_subm_tag = "0.1.6"
-
-    def _do_base_tests(self, rwrepo):
-        """Perform all tests in the given repository, it may be bare or nonbare"""
-        # manual instantiation
-        smm = Submodule(rwrepo, "\0" * 20)
-        # name needs to be set in advance
-        self.failUnlessRaises(AttributeError, getattr, smm, 'name')
-
-        # iterate - 1 submodule
-        sms = Submodule.list_items(rwrepo, self.k_subm_current)
-        assert len(sms) == 1
-        sm = sms[0]
-
-        # at a different time, there is None
-        assert len(Submodule.list_items(rwrepo, self.k_no_subm_tag)) == 0
-
-        assert sm.path == 'git/ext/gitdb'
-        assert sm.path != sm.name                   # in our case, we have ids there, which don't equal the path
-        assert sm.url == 'git://github.com/gitpython-developers/gitdb.git'
-        assert sm.branch_path == 'refs/heads/master'            # the default ...
-        assert sm.branch_name == 'master'
-        assert sm.parent_commit == rwrepo.head.commit
-        # size is always 0
-        assert sm.size == 0
-        # the module is not checked-out yet
-        self.failUnlessRaises(InvalidGitRepositoryError, sm.module)
-
-        # which is why we can't get the branch either - it points into the module() repository
-        self.failUnlessRaises(InvalidGitRepositoryError, getattr, sm, 'branch')
-
-        # branch_path works, as its just a string
-        assert isinstance(sm.branch_path, string_types)
-
-        # some commits earlier we still have a submodule, but its at a different commit
-        smold = next(Submodule.iter_items(rwrepo, self.k_subm_changed))
-        assert smold.binsha != sm.binsha
-        assert smold != sm                  # the name changed
-
-        # force it to reread its information
-        del(smold._url)
-        smold.url == sm.url
-
-        # test config_reader/writer methods
-        sm.config_reader()
-        new_smclone_path = None             # keep custom paths for later
-        new_csmclone_path = None                #
-        if rwrepo.bare:
-            self.failUnlessRaises(InvalidGitRepositoryError, sm.config_writer)
-        else:
-            writer = sm.config_writer()
-            # for faster checkout, set the url to the local path
-            new_smclone_path = to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, sm.path))
-            writer.set_value('url', new_smclone_path)
-            writer.release()
-            assert sm.config_reader().get_value('url') == new_smclone_path
-            assert sm.url == new_smclone_path
-        # END handle bare repo
-        smold.config_reader()
-
-        # cannot get a writer on historical submodules
-        if not rwrepo.bare:
-            self.failUnlessRaises(ValueError, smold.config_writer)
-        # END handle bare repo
-
-        # make the old into a new - this doesn't work as the name changed
-        self.failUnlessRaises(ValueError, smold.set_parent_commit, self.k_subm_current)
-        # the sha is properly updated
-        smold.set_parent_commit(self.k_subm_changed + "~1")
-        assert smold.binsha != sm.binsha
-
-        # raises if the sm didn't exist in new parent - it keeps its
-        # parent_commit unchanged
-        self.failUnlessRaises(ValueError, smold.set_parent_commit, self.k_no_subm_tag)
-
-        # TEST TODO: if a path in the gitmodules file, but not in the index, it raises
-
-        # TEST UPDATE
-        ##############
-        # module retrieval is not always possible
-        if rwrepo.bare:
-            self.failUnlessRaises(InvalidGitRepositoryError, sm.module)
-            self.failUnlessRaises(InvalidGitRepositoryError, sm.remove)
-            self.failUnlessRaises(InvalidGitRepositoryError, sm.add, rwrepo, 'here', 'there')
-        else:
-            # its not checked out in our case
-            self.failUnlessRaises(InvalidGitRepositoryError, sm.module)
-            assert not sm.module_exists()
-
-            # currently there is only one submodule
-            assert len(list(rwrepo.iter_submodules())) == 1
-            assert sm.binsha != "\0" * 20
-
-            # TEST ADD
-            ###########
-            # preliminary tests
-            # adding existing returns exactly the existing
-            sma = Submodule.add(rwrepo, sm.name, sm.path)
-            assert sma.path == sm.path
-
-            # no url and no module at path fails
-            self.failUnlessRaises(ValueError, Submodule.add, rwrepo, "newsubm", "pathtorepo", url=None)
-
-            # CONTINUE UPDATE
-            #################
-
-            # lets update it - its a recursive one too
-            newdir = os.path.join(sm.abspath, 'dir')
-            os.makedirs(newdir)
-
-            # update fails if the path already exists non-empty
-            self.failUnlessRaises(OSError, sm.update)
-            os.rmdir(newdir)
-
-            # dry-run does nothing
-            sm.update(dry_run=True, progress=prog)
-            assert not sm.module_exists()
-
-            assert sm.update() is sm
-            sm_repopath = sm.path               # cache for later
-            assert sm.module_exists()
-            assert isinstance(sm.module(), git.Repo)
-            assert sm.module().working_tree_dir == sm.abspath
-
-            # INTERLEAVE ADD TEST
-            #####################
-            # url must match the one in the existing repository ( if submodule name suggests a new one )
-            # or we raise
-            self.failUnlessRaises(ValueError, Submodule.add, rwrepo, "newsubm", sm.path, "git://someurl/repo.git")
-
-            # CONTINUE UPDATE
-            #################
-            # we should have setup a tracking branch, which is also active
-            assert sm.module().head.ref.tracking_branch() is not None
-
-            # delete the whole directory and re-initialize
-            shutil.rmtree(sm.abspath)
-            assert len(sm.children()) == 0
-            # dry-run does nothing
-            sm.update(dry_run=True, recursive=False, progress=prog)
-            assert len(sm.children()) == 0
-
-            sm.update(recursive=False)
-            assert len(list(rwrepo.iter_submodules())) == 2
-            assert len(sm.children()) == 1          # its not checked out yet
-            csm = sm.children()[0]
-            assert not csm.module_exists()
-            csm_repopath = csm.path
-
-            # adjust the path of the submodules module to point to the local destination
-            new_csmclone_path = to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, sm.path, csm.path))
-            writer = csm.config_writer()
-            writer.set_value('url', new_csmclone_path)
-            writer.release()
-            assert csm.url == new_csmclone_path
-
-            # dry-run does nothing
-            assert not csm.module_exists()
-            sm.update(recursive=True, dry_run=True, progress=prog)
-            assert not csm.module_exists()
-
-            # update recursively again
-            sm.update(recursive=True)
-            assert csm.module_exists()
-
-            # tracking branch once again
-            csm.module().head.ref.tracking_branch() is not None
-
-            # this flushed in a sub-submodule
-            assert len(list(rwrepo.iter_submodules())) == 2
-
-            # reset both heads to the previous version, verify that to_latest_revision works
-            smods = (sm.module(), csm.module())
-            for repo in smods:
-                repo.head.reset('HEAD~2', working_tree=1)
-            # END for each repo to reset
-
-            # dry run does nothing
-            sm.update(recursive=True, dry_run=True, progress=prog)
-            for repo in smods:
-                assert repo.head.commit != repo.head.ref.tracking_branch().commit
-            # END for each repo to check
-
-            sm.update(recursive=True, to_latest_revision=True)
-            for repo in smods:
-                assert repo.head.commit == repo.head.ref.tracking_branch().commit
-            # END for each repo to check
-            del(smods)
-
-            # if the head is detached, it still works ( but warns )
-            smref = sm.module().head.ref
-            sm.module().head.ref = 'HEAD~1'
-            # if there is no tracking branch, we get a warning as well
-            csm_tracking_branch = csm.module().head.ref.tracking_branch()
-            csm.module().head.ref.set_tracking_branch(None)
-            sm.update(recursive=True, to_latest_revision=True)
-
-            # to_latest_revision changes the child submodule's commit, it needs an
-            # update now
-            csm.set_parent_commit(csm.repo.head.commit)
-
-            # undo the changes
-            sm.module().head.ref = smref
-            csm.module().head.ref.set_tracking_branch(csm_tracking_branch)
-
-            # REMOVAL OF REPOSITOTRY
-            ########################
-            # must delete something
-            self.failUnlessRaises(ValueError, csm.remove, module=False, configuration=False)
-            # We have modified the configuration, hence the index is dirty, and the
-            # deletion will fail
-            # NOTE: As we did  a few updates in the meanwhile, the indices were reset
-            # Hence we create some changes
-            csm.set_parent_commit(csm.repo.head.commit)
-            writer = sm.config_writer()
-            writer.set_value("somekey", "somevalue")
-            writer.release()
-            writer = csm.config_writer()
-            writer.set_value("okey", "ovalue")
-            writer.release()
-            self.failUnlessRaises(InvalidGitRepositoryError, sm.remove)
-            # if we remove the dirty index, it would work
-            sm.module().index.reset()
-            # still, we have the file modified
-            self.failUnlessRaises(InvalidGitRepositoryError, sm.remove, dry_run=True)
-            sm.module().index.reset(working_tree=True)
-
-            # enforce the submodule to be checked out at the right spot as well.
-            csm.update()
-
-            # this would work
-            assert sm.remove(dry_run=True) is sm
-            assert sm.module_exists()
-            sm.remove(force=True, dry_run=True)
-            assert sm.module_exists()
-
-            # but ... we have untracked files in the child submodule
-            fn = join_path_native(csm.module().working_tree_dir, "newfile")
-            open(fn, 'w').write("hi")
-            self.failUnlessRaises(InvalidGitRepositoryError, sm.remove)
-
-            # forcibly delete the child repository
-            prev_count = len(sm.children())
-            assert csm.remove(force=True) is csm
-            assert not csm.exists()
-            assert not csm.module_exists()
-            assert len(sm.children()) == prev_count - 1
-            # now we have a changed index, as configuration was altered.
-            # fix this
-            sm.module().index.reset(working_tree=True)
-
-            # now delete only the module of the main submodule
-            assert sm.module_exists()
-            sm.remove(configuration=False)
-            assert sm.exists()
-            assert not sm.module_exists()
-            assert sm.config_reader().get_value('url')
-
-            # delete the rest
-            sm.remove()
-            assert not sm.exists()
-            assert not sm.module_exists()
-
-            assert len(rwrepo.submodules) == 0
-
-            # ADD NEW SUBMODULE
-            ###################
-            # add a simple remote repo - trailing slashes are no problem
-            smid = "newsub"
-            osmid = "othersub"
-            nsm = Submodule.add(rwrepo, smid, sm_repopath, new_smclone_path + "/", None, no_checkout=True)
-            assert nsm.name == smid
-            assert nsm.module_exists()
-            assert nsm.exists()
-            # its not checked out
-            assert not os.path.isfile(join_path_native(nsm.module().working_tree_dir, Submodule.k_modules_file))
-            assert len(rwrepo.submodules) == 1
-
-            # add another submodule, but into the root, not as submodule
-            osm = Submodule.add(rwrepo, osmid, csm_repopath, new_csmclone_path, Submodule.k_head_default)
-            assert osm != nsm
-            assert osm.module_exists()
-            assert osm.exists()
-            assert os.path.isfile(join_path_native(osm.module().working_tree_dir, 'setup.py'))
-
-            assert len(rwrepo.submodules) == 2
-
-            # commit the changes, just to finalize the operation
-            rwrepo.index.commit("my submod commit")
-            assert len(rwrepo.submodules) == 2
-
-            # needs update as the head changed, it thinks its in the history
-            # of the repo otherwise
-            nsm.set_parent_commit(rwrepo.head.commit)
-            osm.set_parent_commit(rwrepo.head.commit)
-
-            # MOVE MODULE
-            #############
-            # invalid inptu
-            self.failUnlessRaises(ValueError, nsm.move, 'doesntmatter', module=False, configuration=False)
-
-            # renaming to the same path does nothing
-            assert nsm.move(sm.path) is nsm
-
-            # rename a module
-            nmp = join_path_native("new", "module", "dir") + "/"  # new module path
-            pmp = nsm.path
-            assert nsm.move(nmp) is nsm
-            nmp = nmp[:-1]          # cut last /
-            nmpl = to_native_path_linux(nmp)
-            assert nsm.path == nmpl
-            assert rwrepo.submodules[0].path == nmpl
-
-            mpath = 'newsubmodule'
-            absmpath = join_path_native(rwrepo.working_tree_dir, mpath)
-            open(absmpath, 'w').write('')
-            self.failUnlessRaises(ValueError, nsm.move, mpath)
-            os.remove(absmpath)
-
-            # now it works, as we just move it back
-            nsm.move(pmp)
-            assert nsm.path == pmp
-            assert rwrepo.submodules[0].path == pmp
-
-            # TODO lowprio: test remaining exceptions ... for now its okay, the code looks right
-
-            # REMOVE 'EM ALL
-            ################
-            # if a submodule's repo has no remotes, it can't be added without an explicit url
-            osmod = osm.module()
-
-            osm.remove(module=False)
-            for remote in osmod.remotes:
-                remote.remove(osmod, remote.name)
-            assert not osm.exists()
-            self.failUnlessRaises(ValueError, Submodule.add, rwrepo, osmid, csm_repopath, url=None)
-        # END handle bare mode
-
-        # Error if there is no submodule file here
-        self.failUnlessRaises(IOError, Submodule._config_parser, rwrepo, rwrepo.commit(self.k_no_subm_tag), True)
-
-    @with_rw_repo(k_subm_current)
-    def test_base_rw(self, rwrepo):
-        raise SkipTest("Disabled as long as it fails and submodule support wasn't overhauled")
-        self._do_base_tests(rwrepo)
-
-    @with_rw_repo(k_subm_current, bare=True)
-    def test_base_bare(self, rwrepo):
-        self._do_base_tests(rwrepo)
-
-    @with_rw_repo(k_subm_current, bare=False)
-    def test_root_module(self, rwrepo):
-        # Can query everything without problems
-        rm = RootModule(self.rorepo)
-        assert rm.module() is self.rorepo
-
-        # try attributes
-        rm.binsha
-        rm.mode
-        rm.path
-        assert rm.name == rm.k_root_name
-        assert rm.parent_commit == self.rorepo.head.commit
-        rm.url
-        rm.branch
-
-        assert len(rm.list_items(rm.module())) == 1
-        rm.config_reader()
-        w = rm.config_writer()
-        w.release()
-
-        # deep traversal gitdb / async
-        rsmsp = [sm.path for sm in rm.traverse()]
-        assert len(rsmsp) >= 2          # gitdb and async [and smmap], async being a child of gitdb
-
-        # cannot set the parent commit as root module's path didn't exist
-        self.failUnlessRaises(ValueError, rm.set_parent_commit, 'HEAD')
-
-        # TEST UPDATE
-        #############
-        # setup commit which remove existing, add new and modify existing submodules
-        rm = RootModule(rwrepo)
-        assert len(rm.children()) == 1
-
-        # modify path without modifying the index entry
-        # ( which is what the move method would do properly )
-        #==================================================
-        sm = rm.children()[0]
-        pp = "path/prefix"
-        fp = join_path_native(pp, sm.path)
-        prep = sm.path
-        assert not sm.module_exists()               # was never updated after rwrepo's clone
-
-        # assure we clone from a local source
-        writer = sm.config_writer()
-        writer.set_value('url', to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, sm.path)))
-        writer.release()
-
-        # dry-run does nothing
-        sm.update(recursive=False, dry_run=True, progress=prog)
-        assert not sm.module_exists()
-
-        sm.update(recursive=False)
-        assert sm.module_exists()
-        writer = sm.config_writer()
-        writer.set_value('path', fp)    # change path to something with prefix AFTER url change
-        writer.release()
-
-        # update fails as list_items in such a situations cannot work, as it cannot
-        # find the entry at the changed path
-        self.failUnlessRaises(InvalidGitRepositoryError, rm.update, recursive=False)
-
-        # move it properly - doesn't work as it its path currently points to an indexentry
-        # which doesn't exist ( move it to some path, it doesn't matter here )
-        self.failUnlessRaises(InvalidGitRepositoryError, sm.move, pp)
-        # reset the path(cache) to where it was, now it works
-        sm.path = prep
-        sm.move(fp, module=False)       # leave it at the old location
-
-        assert not sm.module_exists()
-        cpathchange = rwrepo.index.commit("changed sm path")  # finally we can commit
-
-        # update puts the module into place
-        rm.update(recursive=False, progress=prog)
-        sm.set_parent_commit(cpathchange)
-        assert sm.module_exists()
-
-        # add submodule
-        #================
-        nsmn = "newsubmodule"
-        nsmp = "submrepo"
-        async_url = to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, rsmsp[0], rsmsp[1]))
-        nsm = Submodule.add(rwrepo, nsmn, nsmp, url=async_url)
-        csmadded = rwrepo.index.commit("Added submodule").hexsha    # make sure we don't keep the repo reference
-        nsm.set_parent_commit(csmadded)
-        assert nsm.module_exists()
-        # in our case, the module should not exist, which happens if we update a parent
-        # repo and a new submodule comes into life
-        nsm.remove(configuration=False, module=True)
-        assert not nsm.module_exists() and nsm.exists()
-
-        # dry-run does nothing
-        rm.update(recursive=False, dry_run=True, progress=prog)
-
-        # otherwise it will work
-        rm.update(recursive=False, progress=prog)
-        assert nsm.module_exists()
-
-        # remove submodule - the previous one
-        #====================================
-        sm.set_parent_commit(csmadded)
-        smp = sm.abspath
-        assert not sm.remove(module=False).exists()
-        assert os.path.isdir(smp)           # module still exists
-        csmremoved = rwrepo.index.commit("Removed submodule")
-
-        # an update will remove the module
-        # not in dry_run
-        rm.update(recursive=False, dry_run=True)
-        assert os.path.isdir(smp)
-
-        rm.update(recursive=False)
-        assert not os.path.isdir(smp)
-
-        # change url
-        #=============
-        # to the first repository, this way we have a fast checkout, and a completely different
-        # repository at the different url
-        nsm.set_parent_commit(csmremoved)
-        nsmurl = to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, rsmsp[0]))
-        writer = nsm.config_writer()
-        writer.set_value('url', nsmurl)
-        writer.release()
-        csmpathchange = rwrepo.index.commit("changed url")
-        nsm.set_parent_commit(csmpathchange)
-
-        prev_commit = nsm.module().head.commit
-        # dry-run does nothing
-        rm.update(recursive=False, dry_run=True, progress=prog)
-        assert nsm.module().remotes.origin.url != nsmurl
-
-        rm.update(recursive=False, progress=prog)
-        assert nsm.module().remotes.origin.url == nsmurl
-        # head changed, as the remote url and its commit changed
-        assert prev_commit != nsm.module().head.commit
-
-        # add the submodule's changed commit to the index, which is what the
-        # user would do
-        # beforehand, update our instance's binsha with the new one
-        nsm.binsha = nsm.module().head.commit.binsha
-        rwrepo.index.add([nsm])
-
-        # change branch
-        #=================
-        # we only have one branch, so we switch to a virtual one, and back
-        # to the current one to trigger the difference
-        cur_branch = nsm.branch
-        nsmm = nsm.module()
-        prev_commit = nsmm.head.commit
-        for branch in ("some_virtual_branch", cur_branch.name):
-            writer = nsm.config_writer()
-            writer.set_value(Submodule.k_head_option, git.Head.to_full_path(branch))
-            writer.release()
-            csmbranchchange = rwrepo.index.commit("changed branch to %s" % branch)
-            nsm.set_parent_commit(csmbranchchange)
-        # END for each branch to change
-
-        # Lets remove our tracking branch to simulate some changes
-        nsmmh = nsmm.head
-        assert nsmmh.ref.tracking_branch() is None                  # never set it up until now
-        assert not nsmmh.is_detached
-
-        # dry run does nothing
-        rm.update(recursive=False, dry_run=True, progress=prog)
-        assert nsmmh.ref.tracking_branch() is None
-
-        # the real thing does
-        rm.update(recursive=False, progress=prog)
-
-        assert nsmmh.ref.tracking_branch() is not None
-        assert not nsmmh.is_detached
-
-        # recursive update
-        # =================
-        # finally we recursively update a module, just to run the code at least once
-        # remove the module so that it has more work
-        assert len(nsm.children()) >= 1  # could include smmap
-        assert nsm.exists() and nsm.module_exists() and len(nsm.children()) >= 1
-        # assure we pull locally only
-        nsmc = nsm.children()[0]
-        writer = nsmc.config_writer()
-        writer.set_value('url', async_url)
-        writer.release()
-        rm.update(recursive=True, progress=prog, dry_run=True)      # just to run the code
-        rm.update(recursive=True, progress=prog)
-
-        # gitdb: has either 1 or 2 submodules depending on the version
-        assert len(nsm.children()) >= 1 and nsmc.module_exists()
-
-    @with_rw_repo(k_no_subm_tag, bare=False)
-    def test_first_submodule(self, rwrepo):
-        assert len(list(rwrepo.iter_submodules())) == 0
-
-        for sm_name, sm_path in (('first', 'submodules/first'),
-                                 ('second', os.path.join(rwrepo.working_tree_dir, 'submodules/second'))):
-            sm = rwrepo.create_submodule(sm_name, sm_path, rwrepo.git_dir, no_checkout=True)
-            assert sm.exists() and sm.module_exists()
-            rwrepo.index.commit("Added submodule " + sm_name)
-        # end for each submodule path to add
-
-        self.failUnlessRaises(ValueError, rwrepo.create_submodule, 'fail', os.path.expanduser('~'))
-        self.failUnlessRaises(ValueError, rwrepo.create_submodule, 'fail-too',
-                              rwrepo.working_tree_dir + os.path.sep)
-
-    @with_rw_directory
-    def test_add_empty_repo(self, rwdir):
-        parent_dir = os.path.join(rwdir, 'parent')
-        os.mkdir(parent_dir)
-        empty_repo_dir = os.path.join(rwdir, 'empty-repo')
-
-        parent = git.Repo.init(parent_dir)
-        git.Repo.init(empty_repo_dir)
-
-        for checkout_mode in range(2):
-            name = 'empty' + str(checkout_mode)
-            self.failUnlessRaises(ValueError, parent.create_submodule, name, name,
-                                  url=empty_repo_dir, no_checkout=checkout_mode and True or False)
-        # end for each checkout mode
diff --git a/git/test/test_tree.py b/git/test/test_tree.py
deleted file mode 100644
index 7a16b7776..000000000
--- a/git/test/test_tree.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# test_tree.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-import os
-from git.test.lib import TestBase
-from git import (
-    Tree,
-    Blob
-)
-
-from io import BytesIO
-
-
-class TestTree(TestBase):
-
-    def test_serializable(self):
-        # tree at the given commit contains a submodule as well
-        roottree = self.rorepo.tree('6c1faef799095f3990e9970bc2cb10aa0221cf9c')
-        for item in roottree.traverse(ignore_self=False):
-            if item.type != Tree.type:
-                continue
-            # END skip non-trees
-            tree = item
-            # trees have no dict
-            self.failUnlessRaises(AttributeError, setattr, tree, 'someattr', 1)
-
-            orig_data = tree.data_stream.read()
-            orig_cache = tree._cache
-
-            stream = BytesIO()
-            tree._serialize(stream)
-            assert stream.getvalue() == orig_data
-
-            stream.seek(0)
-            testtree = Tree(self.rorepo, Tree.NULL_BIN_SHA, 0, '')
-            testtree._deserialize(stream)
-            assert testtree._cache == orig_cache
-
-            # TEST CACHE MUTATOR
-            mod = testtree.cache
-            self.failUnlessRaises(ValueError, mod.add, "invalid sha", 0, "name")
-            self.failUnlessRaises(ValueError, mod.add, Tree.NULL_HEX_SHA, 0, "invalid mode")
-            self.failUnlessRaises(ValueError, mod.add, Tree.NULL_HEX_SHA, tree.mode, "invalid/name")
-
-            # add new item
-            name = "fake_dir"
-            mod.add(testtree.NULL_HEX_SHA, tree.mode, name)
-            assert name in testtree
-
-            # its available in the tree immediately
-            assert isinstance(testtree[name], Tree)
-
-            # adding it again will not cause multiple of them to be presents
-            cur_count = len(testtree)
-            mod.add(testtree.NULL_HEX_SHA, tree.mode, name)
-            assert len(testtree) == cur_count
-
-            # fails with a different sha - name exists
-            hexsha = "1" * 40
-            self.failUnlessRaises(ValueError, mod.add, hexsha, tree.mode, name)
-
-            # force it - replace existing one
-            mod.add(hexsha, tree.mode, name, force=True)
-            assert testtree[name].hexsha == hexsha
-            assert len(testtree) == cur_count
-
-            # unchecked addition always works, even with invalid items
-            invalid_name = "hi/there"
-            mod.add_unchecked(hexsha, 0, invalid_name)
-            assert len(testtree) == cur_count + 1
-
-            del(mod[invalid_name])
-            assert len(testtree) == cur_count
-            # del again, its fine
-            del(mod[invalid_name])
-
-            # have added one item, we are done
-            mod.set_done()
-            mod.set_done()      # multiple times are okay
-
-            # serialize, its different now
-            stream = BytesIO()
-            testtree._serialize(stream)
-            stream.seek(0)
-            assert stream.getvalue() != orig_data
-
-            # replaces cache, but we make sure of it
-            del(testtree._cache)
-            testtree._deserialize(stream)
-            assert name in testtree
-            assert invalid_name not in testtree
-        # END for each item in tree
-
-    def test_traverse(self):
-        root = self.rorepo.tree('0.1.6')
-        num_recursive = 0
-        all_items = list()
-        for obj in root.traverse():
-            if "/" in obj.path:
-                num_recursive += 1
-
-            assert isinstance(obj, (Blob, Tree))
-            all_items.append(obj)
-        # END for each object
-        assert all_items == root.list_traverse()
-
-        # limit recursion level to 0 - should be same as default iteration
-        assert all_items
-        assert 'CHANGES' in root
-        assert len(list(root)) == len(list(root.traverse(depth=1)))
-
-        # only choose trees
-        trees_only = lambda i, d: i.type == "tree"
-        trees = list(root.traverse(predicate=trees_only))
-        assert len(trees) == len(list(i for i in root.traverse() if trees_only(i, 0)))
-
-        # test prune
-        lib_folder = lambda t, d: t.path == "lib"
-        pruned_trees = list(root.traverse(predicate=trees_only, prune=lib_folder))
-        assert len(pruned_trees) < len(trees)
-
-        # trees and blobs
-        assert len(set(trees) | set(root.trees)) == len(trees)
-        assert len(set(b for b in root if isinstance(b, Blob)) | set(root.blobs)) == len(root.blobs)
-        subitem = trees[0][0]
-        assert "/" in subitem.path
-        assert subitem.name == os.path.basename(subitem.path)
-
-        # assure that at some point the traversed paths have a slash in them
-        found_slash = False
-        for item in root.traverse():
-            assert os.path.isabs(item.abspath)
-            if '/' in item.path:
-                found_slash = True
-            # END check for slash
-
-            # slashes in paths are supported as well
-            # NOTE: on py3, / doesn't work with strings anymore ...
-            assert root[item.path] == item == root / item.path
-        # END for each item
-        assert found_slash
diff --git a/git/test/test_util.py b/git/test/test_util.py
deleted file mode 100644
index c6ca6920b..000000000
--- a/git/test/test_util.py
+++ /dev/null
@@ -1,179 +0,0 @@
-# test_utils.py
-# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
-#
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-import tempfile
-
-from git.test.lib import (
-    TestBase,
-    assert_equal
-)
-from git.util import (
-    LockFile,
-    BlockingLockFile,
-    get_user_id,
-    Actor,
-    IterableList
-)
-from git.objects.util import (
-    altz_to_utctz_str,
-    utctz_to_altz,
-    verify_utctz,
-    parse_date,
-)
-from git.cmd import dashify
-from git.compat import string_types
-
-import time
-
-
-class TestIterableMember(object):
-
-    """A member of an iterable list"""
-    __slots__ = ("name", "prefix_name")
-
-    def __init__(self, name):
-        self.name = name
-        self.prefix_name = name
-
-
-class TestUtils(TestBase):
-
-    def setup(self):
-        self.testdict = {
-            "string": "42",
-            "int": 42,
-            "array": [42],
-        }
-
-    def test_it_should_dashify(self):
-        assert_equal('this-is-my-argument', dashify('this_is_my_argument'))
-        assert_equal('foo', dashify('foo'))
-
-    def test_lock_file(self):
-        my_file = tempfile.mktemp()
-        lock_file = LockFile(my_file)
-        assert not lock_file._has_lock()
-        # release lock we don't have  - fine
-        lock_file._release_lock()
-
-        # get lock
-        lock_file._obtain_lock_or_raise()
-        assert lock_file._has_lock()
-
-        # concurrent access
-        other_lock_file = LockFile(my_file)
-        assert not other_lock_file._has_lock()
-        self.failUnlessRaises(IOError, other_lock_file._obtain_lock_or_raise)
-
-        lock_file._release_lock()
-        assert not lock_file._has_lock()
-
-        other_lock_file._obtain_lock_or_raise()
-        self.failUnlessRaises(IOError, lock_file._obtain_lock_or_raise)
-
-        # auto-release on destruction
-        del(other_lock_file)
-        lock_file._obtain_lock_or_raise()
-        lock_file._release_lock()
-
-    def test_blocking_lock_file(self):
-        my_file = tempfile.mktemp()
-        lock_file = BlockingLockFile(my_file)
-        lock_file._obtain_lock()
-
-        # next one waits for the lock
-        start = time.time()
-        wait_time = 0.1
-        wait_lock = BlockingLockFile(my_file, 0.05, wait_time)
-        self.failUnlessRaises(IOError, wait_lock._obtain_lock)
-        elapsed = time.time() - start
-        assert elapsed <= wait_time + 0.02  # some extra time it may cost
-
-    def test_user_id(self):
-        assert '@' in get_user_id()
-
-    def test_parse_date(self):
-        # test all supported formats
-        def assert_rval(rval, veri_time, offset=0):
-            assert len(rval) == 2
-            assert isinstance(rval[0], int) and isinstance(rval[1], int)
-            assert rval[0] == veri_time
-            assert rval[1] == offset
-
-            # now that we are here, test our conversion functions as well
-            utctz = altz_to_utctz_str(offset)
-            assert isinstance(utctz, string_types)
-            assert utctz_to_altz(verify_utctz(utctz)) == offset
-        # END assert rval utility
-
-        rfc = ("Thu, 07 Apr 2005 22:13:11 +0000", 0)
-        iso = ("2005-04-07T22:13:11 -0200", 7200)
-        iso2 = ("2005-04-07 22:13:11 +0400", -14400)
-        iso3 = ("2005.04.07 22:13:11 -0000", 0)
-        alt = ("04/07/2005 22:13:11", 0)
-        alt2 = ("07.04.2005 22:13:11", 0)
-        veri_time_utc = 1112911991      # the time this represents, in time since epoch, UTC
-        for date, offset in (rfc, iso, iso2, iso3, alt, alt2):
-            assert_rval(parse_date(date), veri_time_utc, offset)
-        # END for each date type
-
-        # and failure
-        self.failUnlessRaises(ValueError, parse_date, 'invalid format')
-        self.failUnlessRaises(ValueError, parse_date, '123456789 -02000')
-        self.failUnlessRaises(ValueError, parse_date, ' 123456789 -0200')
-
-    def test_actor(self):
-        for cr in (None, self.rorepo.config_reader()):
-            assert isinstance(Actor.committer(cr), Actor)
-            assert isinstance(Actor.author(cr), Actor)
-        # END assure config reader is handled
-
-    def test_iterable_list(self):
-        for args in (('name',), ('name', 'prefix_')):
-            l = IterableList('name')
-
-            m1 = TestIterableMember('one')
-            m2 = TestIterableMember('two')
-
-            l.extend((m1, m2))
-
-            assert len(l) == 2
-
-            # contains works with name and identity
-            assert m1.name in l
-            assert m2.name in l
-            assert m2 in l
-            assert m2 in l
-            assert 'invalid' not in l
-
-            # with string index
-            assert l[m1.name] is m1
-            assert l[m2.name] is m2
-
-            # with int index
-            assert l[0] is m1
-            assert l[1] is m2
-
-            # with getattr
-            assert l.one is m1
-            assert l.two is m2
-
-            # test exceptions
-            self.failUnlessRaises(AttributeError, getattr, l, 'something')
-            self.failUnlessRaises(IndexError, l.__getitem__, 'something')
-
-            # delete by name and index
-            self.failUnlessRaises(IndexError, l.__delitem__, 'something')
-            del(l[m2.name])
-            assert len(l) == 1
-            assert m2.name not in l and m1.name in l
-            del(l[0])
-            assert m1.name not in l
-            assert len(l) == 0
-
-            self.failUnlessRaises(IndexError, l.__delitem__, 0)
-            self.failUnlessRaises(IndexError, l.__delitem__, 'something')
-        # END for each possible mode
diff --git a/git/types.py b/git/types.py
new file mode 100644
index 000000000..cce184530
--- /dev/null
+++ b/git/types.py
@@ -0,0 +1,285 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import os
+import sys
+from typing import (
+    Any,
+    Callable,
+    Dict,
+    List,
+    NoReturn,
+    Optional,
+    Sequence as Sequence,
+    Tuple,
+    TYPE_CHECKING,
+    Type,
+    TypeVar,
+    Union,
+)
+import warnings
+
+if sys.version_info >= (3, 8):
+    from typing import (
+        Literal,
+        Protocol,
+        SupportsIndex as SupportsIndex,
+        TypedDict,
+        runtime_checkable,
+    )
+else:
+    from typing_extensions import (
+        Literal,
+        Protocol,
+        SupportsIndex as SupportsIndex,
+        TypedDict,
+        runtime_checkable,
+    )
+
+if TYPE_CHECKING:
+    from git.objects import Commit, Tree, TagObject, Blob
+    from git.repo import Repo
+
+PathLike = Union[str, "os.PathLike[str]"]
+"""A :class:`str` (Unicode) based file or directory path."""
+
+TBD = Any
+"""Alias of :class:`~typing.Any`, when a type hint is meant to become more specific."""
+
+_T = TypeVar("_T")
+"""Type variable used internally in GitPython."""
+
+AnyGitObject = Union["Commit", "Tree", "TagObject", "Blob"]
+"""Union of the :class:`~git.objects.base.Object`-based types that represent actual git
+object types.
+
+As noted in :class:`~git.objects.base.Object`, which has further details, these are:
+
+* :class:`Blob <git.objects.blob.Blob>`
+* :class:`Tree <git.objects.tree.Tree>`
+* :class:`Commit <git.objects.commit.Commit>`
+* :class:`TagObject <git.objects.tag.TagObject>`
+
+Those GitPython classes represent the four git object types, per
+:manpage:`gitglossary(7)`:
+
+* "blob": https://git-scm.com/docs/gitglossary#def_blob_object
+* "tree object": https://git-scm.com/docs/gitglossary#def_tree_object
+* "commit object": https://git-scm.com/docs/gitglossary#def_commit_object
+* "tag object": https://git-scm.com/docs/gitglossary#def_tag_object
+
+For more general information on git objects and their types as git understands them:
+
+* "object": https://git-scm.com/docs/gitglossary#def_object
+* "object type": https://git-scm.com/docs/gitglossary#def_object_type
+
+:note:
+    See also the :class:`Tree_ish` and :class:`Commit_ish` unions.
+"""
+
+Tree_ish = Union["Commit", "Tree", "TagObject"]
+"""Union of :class:`~git.objects.base.Object`-based types that are typically tree-ish.
+
+See :manpage:`gitglossary(7)` on "tree-ish":
+https://git-scm.com/docs/gitglossary#def_tree-ish
+
+:note:
+    :class:`~git.objects.tree.Tree` and :class:`~git.objects.commit.Commit` are the
+    classes whose instances are all tree-ish. This union includes them, but also
+    :class:`~git.objects.tag.TagObject`, only **most** of whose instances are tree-ish.
+    Whether a particular :class:`~git.objects.tag.TagObject` peels (recursively
+    dereferences) to a tree or commit, rather than a blob, can in general only be known
+    at runtime. In practice, git tag objects are nearly always used for tagging commits,
+    and such tags are tree-ish because commits are tree-ish.
+
+:note:
+    See also the :class:`AnyGitObject` union of all four classes corresponding to git
+    object types.
+"""
+
+Commit_ish = Union["Commit", "TagObject"]
+"""Union of :class:`~git.objects.base.Object`-based types that are typically commit-ish.
+
+See :manpage:`gitglossary(7)` on "commit-ish":
+https://git-scm.com/docs/gitglossary#def_commit-ish
+
+:note:
+    :class:`~git.objects.commit.Commit` is the only class whose instances are all
+    commit-ish. This union type includes :class:`~git.objects.commit.Commit`, but also
+    :class:`~git.objects.tag.TagObject`, only **most** of whose instances are
+    commit-ish. Whether a particular :class:`~git.objects.tag.TagObject` peels
+    (recursively dereferences) to a commit, rather than a tree or blob, can in general
+    only be known at runtime. In practice, git tag objects are nearly always used for
+    tagging commits, and such tags are of course commit-ish.
+
+:note:
+    See also the :class:`AnyGitObject` union of all four classes corresponding to git
+    object types.
+"""
+
+GitObjectTypeString = Literal["commit", "tag", "blob", "tree"]
+"""Literal strings identifying git object types and the
+:class:`~git.objects.base.Object`-based types that represent them.
+
+See the :attr:`Object.type <git.objects.base.Object.type>` attribute. These are its
+values in :class:`~git.objects.base.Object` subclasses that represent git objects. These
+literals therefore correspond to the types in the :class:`AnyGitObject` union.
+
+These are the same strings git itself uses to identify its four object types.
+See :manpage:`gitglossary(7)` on "object type":
+https://git-scm.com/docs/gitglossary#def_object_type
+"""
+
+Lit_commit_ish: Type[Literal["commit", "tag"]]
+"""Deprecated. Type of literal strings identifying typically-commitish git object types.
+
+Prior to a bugfix, this type had been defined more broadly. Any usage is in practice
+ambiguous and likely to be incorrect. This type has therefore been made a static type
+error to appear in annotations. It is preserved, with a deprecated status, to avoid
+introducing runtime errors in code that refers to it, but it should not be used.
+
+Instead of this type:
+
+* For the type of the string literals associated with :class:`Commit_ish`, use
+  ``Literal["commit", "tag"]`` or create a new type alias for it. That is equivalent to
+  this type as currently defined (but usable in statically checked type annotations).
+
+* For the type of all four string literals associated with :class:`AnyGitObject`, use
+  :class:`GitObjectTypeString`. That is equivalent to the old definition of this type
+  prior to the bugfix (and is also usable in statically checked type annotations).
+"""
+
+
+def _getattr(name: str) -> Any:
+    if name != "Lit_commit_ish":
+        raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
+
+    warnings.warn(
+        "Lit_commit_ish is deprecated. It is currently defined as "
+        '`Literal["commit", "tag"]`, which should be used in its place if desired. It '
+        'had previously been defined as `Literal["commit", "tag", "blob", "tree"]`, '
+        "covering all four git object type strings including those that are never "
+        "commit-ish. For that, use the GitObjectTypeString type instead.",
+        DeprecationWarning,
+        stacklevel=2,
+    )
+    return Literal["commit", "tag"]
+
+
+if not TYPE_CHECKING:  # Preserve static checking for undefined/misspelled attributes.
+    __getattr__ = _getattr
+
+
+def __dir__() -> List[str]:
+    return [*globals(), "Lit_commit_ish"]
+
+
+# Config_levels ---------------------------------------------------------
+
+Lit_config_levels = Literal["system", "global", "user", "repository"]
+"""Type of literal strings naming git configuration levels.
+
+These strings relate to which file a git configuration variable is in.
+"""
+
+ConfigLevels_Tup = Tuple[Literal["system"], Literal["user"], Literal["global"], Literal["repository"]]
+"""Static type of a tuple of the four strings representing configuration levels."""
+
+# Progress parameter type alias -----------------------------------------
+
+CallableProgress = Optional[Callable[[int, Union[str, float], Union[str, float, None], str], None]]
+"""General type of a function or other callable used as a progress reporter for cloning.
+
+This is the type of a function or other callable that reports the progress of a clone,
+when passed as a ``progress`` argument to :meth:`Repo.clone <git.repo.base.Repo.clone>`
+or :meth:`Repo.clone_from <git.repo.base.Repo.clone_from>`.
+
+:note:
+    Those :meth:`~git.repo.base.Repo.clone` and :meth:`~git.repo.base.Repo.clone_from`
+    methods also accept :meth:`~git.util.RemoteProgress` instances, including instances
+    of its :meth:`~git.util.CallableRemoteProgress` subclass.
+
+:note:
+    Unlike objects that match this type, :meth:`~git.util.RemoteProgress` instances are
+    not directly callable, not even when they are instances of
+    :meth:`~git.util.CallableRemoteProgress`, which wraps a callable and forwards
+    information to it but is not itself callable.
+
+:note:
+    This type also allows ``None``, for cloning without reporting progress.
+"""
+
+# -----------------------------------------------------------------------------------
+
+
+def assert_never(inp: NoReturn, raise_error: bool = True, exc: Union[Exception, None] = None) -> None:
+    """For use in exhaustive checking of a literal or enum in if/else chains.
+
+    A call to this function should only be reached if not all members are handled, or if
+    an attempt is made to pass non-members through the chain.
+
+    :param inp:
+        If all members are handled, the argument for `inp` will have the
+        :class:`~typing.Never`/:class:`~typing.NoReturn` type.
+        Otherwise, the type will mismatch and cause a mypy error.
+
+    :param raise_error:
+        If ``True``, will also raise :exc:`ValueError` with a general
+        "unhandled literal" message, or the exception object passed as `exc`.
+
+    :param exc:
+        It not ``None``, this should be an already-constructed exception object, to be
+        raised if `raise_error` is ``True``.
+    """
+    if raise_error:
+        if exc is None:
+            raise ValueError(f"An unhandled literal ({inp!r}) in an if/else chain was found")
+        else:
+            raise exc
+
+
+class Files_TD(TypedDict):
+    """Dictionary with stat counts for the diff of a particular file.
+
+    For the :class:`~git.util.Stats.files` attribute of :class:`~git.util.Stats`
+    objects.
+    """
+
+    insertions: int
+    deletions: int
+    lines: int
+    change_type: str
+
+
+class Total_TD(TypedDict):
+    """Dictionary with total stats from any number of files.
+
+    For the :class:`~git.util.Stats.total` attribute of :class:`~git.util.Stats`
+    objects.
+    """
+
+    insertions: int
+    deletions: int
+    lines: int
+    files: int
+
+
+class HSH_TD(TypedDict):
+    """Dictionary carrying the same information as a :class:`~git.util.Stats` object."""
+
+    total: Total_TD
+    files: Dict[PathLike, Files_TD]
+
+
+@runtime_checkable
+class Has_Repo(Protocol):
+    """Protocol for having a :attr:`repo` attribute, the repository to operate on."""
+
+    repo: "Repo"
+
+
+@runtime_checkable
+class Has_id_attribute(Protocol):
+    """Protocol for having :attr:`_id_attribute_` used in iteration and traversal."""
+
+    _id_attribute_: str
diff --git a/git/util.py b/git/util.py
index 010130cbc..0aff5eb64 100644
--- a/git/util.py
+++ b/git/util.py
@@ -1,64 +1,263 @@
-# utils.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
+import sys
+
+__all__ = [
+    "stream_copy",
+    "join_path",
+    "to_native_path_linux",
+    "join_path_native",
+    "Stats",
+    "IndexFileSHA1Writer",
+    "IterableObj",
+    "IterableList",
+    "BlockingLockFile",
+    "LockFile",
+    "Actor",
+    "get_user_id",
+    "assure_directory_exists",
+    "RemoteProgress",
+    "CallableRemoteProgress",
+    "rmtree",
+    "unbare_repo",
+    "HIDE_WINDOWS_KNOWN_ERRORS",
+]
+
+if sys.platform == "win32":
+    __all__.append("to_native_path_windows")
+
+from abc import abstractmethod
+import contextlib
+from functools import wraps
+import getpass
+import logging
 import os
+import os.path as osp
+import pathlib
+import platform
 import re
-import sys
-import time
-import stat
 import shutil
-import platform
-import getpass
-import threading
+import stat
+import subprocess
+import time
+from urllib.parse import urlsplit, urlunsplit
+import warnings
+
+# NOTE: Unused imports can be improved now that CI testing has fully resumed. Some of
+# these be used indirectly through other GitPython modules, which avoids having to write
+# gitdb all the time in their imports. They are not in __all__, at least currently,
+# because they could be removed or changed at any time, and so should not be considered
+# conceptually public to code outside GitPython. Linters of course do not like it.
+from gitdb.util import (
+    LazyMixin,  # noqa: F401
+    LockedFD,  # noqa: F401
+    bin_to_hex,  # noqa: F401
+    file_contents_ro,  # noqa: F401
+    file_contents_ro_filepath,  # noqa: F401
+    hex_to_bin,  # noqa: F401
+    make_sha,
+    to_bin_sha,  # noqa: F401
+    to_hex_sha,  # noqa: F401
+)
 
-# NOTE:  Some of the unused imports might be used/imported by others.
-# Handle once test-cases are back up and running.
-from .exc import GitCommandError
-from .compat import MAXSIZE
+# typing ---------------------------------------------------------
+
+from typing import (
+    Any,
+    AnyStr,
+    BinaryIO,
+    Callable,
+    Dict,
+    Generator,
+    IO,
+    Iterator,
+    List,
+    Optional,
+    Pattern,
+    Sequence,
+    Tuple,
+    TYPE_CHECKING,
+    TypeVar,
+    Union,
+    cast,
+    overload,
+)
 
-# Most of these are unused here, but are for use by git-python modules so these
-# don't see gitdb all the time. Flake of course doesn't like it.
-from gitdb.util import (  # NOQA
-    make_sha,
-    LockedFD,
-    file_contents_ro,
-    LazyMixin,
-    to_hex_sha,
-    to_bin_sha
+if TYPE_CHECKING:
+    from git.cmd import Git
+    from git.config import GitConfigParser, SectionConstraint
+    from git.remote import Remote
+    from git.repo.base import Repo
+
+from git.types import (
+    Files_TD,
+    Has_id_attribute,
+    HSH_TD,
+    Literal,
+    PathLike,
+    Protocol,
+    SupportsIndex,
+    Total_TD,
+    runtime_checkable,
 )
 
-__all__ = ("stream_copy", "join_path", "to_native_path_windows", "to_native_path_linux",
-           "join_path_native", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList",
-           "BlockingLockFile", "LockFile", 'Actor', 'get_user_id', 'assure_directory_exists',
-           'RemoteProgress', 'rmtree', 'WaitGroup')
+# ---------------------------------------------------------------------
+
+T_IterableObj = TypeVar("T_IterableObj", bound=Union["IterableObj", "Has_id_attribute"], covariant=True)
+# So IterableList[Head] is subtype of IterableList[IterableObj].
+
+_logger = logging.getLogger(__name__)
+
+
+def _read_env_flag(name: str, default: bool) -> bool:
+    """Read a boolean flag from an environment variable.
+
+    :return:
+        The flag, or the `default` value if absent or ambiguous.
+    """
+    try:
+        value = os.environ[name]
+    except KeyError:
+        return default
+
+    _logger.warning(
+        "The %s environment variable is deprecated. Its effect has never been documented and changes without warning.",
+        name,
+    )
+
+    adjusted_value = value.strip().lower()
+
+    if adjusted_value in {"", "0", "false", "no"}:
+        return False
+    if adjusted_value in {"1", "true", "yes"}:
+        return True
+    _logger.warning("%s has unrecognized value %r, treating as %r.", name, value, default)
+    return default
+
+
+def _read_win_env_flag(name: str, default: bool) -> bool:
+    """Read a boolean flag from an environment variable on Windows.
+
+    :return:
+        On Windows, the flag, or the `default` value if absent or ambiguous.
+        On all other operating systems, ``False``.
 
-#{ Utility Methods
+    :note:
+        This only accesses the environment on Windows.
+    """
+    return sys.platform == "win32" and _read_env_flag(name, default)
+
+
+#: We need an easy way to see if Appveyor TCs start failing,
+#: so the errors marked with this var are considered "acknowledged" ones, awaiting remedy,
+#: till then, we wish to hide them.
+HIDE_WINDOWS_KNOWN_ERRORS = _read_win_env_flag("HIDE_WINDOWS_KNOWN_ERRORS", True)
+HIDE_WINDOWS_FREEZE_ERRORS = _read_win_env_flag("HIDE_WINDOWS_FREEZE_ERRORS", True)
+
+# { Utility Methods
+
+T = TypeVar("T")
+
+
+def unbare_repo(func: Callable[..., T]) -> Callable[..., T]:
+    """Methods with this decorator raise :exc:`~git.exc.InvalidGitRepositoryError` if
+    they encounter a bare repository."""
+
+    from .exc import InvalidGitRepositoryError
 
+    @wraps(func)
+    def wrapper(self: "Remote", *args: Any, **kwargs: Any) -> T:
+        if self.repo.bare:
+            raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__)
+        # END bare method
+        return func(self, *args, **kwargs)
+
+    # END wrapper
+
+    return wrapper
+
+
+@contextlib.contextmanager
+def cwd(new_dir: PathLike) -> Generator[PathLike, None, None]:
+    """Context manager to temporarily change directory.
+
+    This is similar to :func:`contextlib.chdir` introduced in Python 3.11, but the
+    context manager object returned by a single call to this function is not reentrant.
+    """
+    old_dir = os.getcwd()
+    os.chdir(new_dir)
+    try:
+        yield new_dir
+    finally:
+        os.chdir(old_dir)
 
-def rmtree(path):
-    """Remove the given recursively.
 
-    :note: we use shutil rmtree but adjust its behaviour to see whether files that
-        couldn't be deleted are read-only. Windows will not remove them in that case"""
-    def onerror(func, path, exc_info):
-        if not os.access(path, os.W_OK):
-            # Is the error an access error ?
-            os.chmod(path, stat.S_IWUSR)
-            func(path)
+@contextlib.contextmanager
+def patch_env(name: str, value: str) -> Generator[None, None, None]:
+    """Context manager to temporarily patch an environment variable."""
+    old_value = os.getenv(name)
+    os.environ[name] = value
+    try:
+        yield
+    finally:
+        if old_value is None:
+            del os.environ[name]
         else:
+            os.environ[name] = old_value
+
+
+def rmtree(path: PathLike) -> None:
+    """Remove the given directory tree recursively.
+
+    :note:
+        We use :func:`shutil.rmtree` but adjust its behaviour to see whether files that
+        couldn't be deleted are read-only. Windows will not remove them in that case.
+    """
+
+    def handler(function: Callable, path: PathLike, _excinfo: Any) -> None:
+        """Callback for :func:`shutil.rmtree`.
+
+        This works as either a ``onexc`` or ``onerror`` style callback.
+        """
+        # Is the error an access error?
+        os.chmod(path, stat.S_IWUSR)
+
+        try:
+            function(path)
+        except PermissionError as ex:
+            if HIDE_WINDOWS_KNOWN_ERRORS:
+                from unittest import SkipTest
+
+                raise SkipTest(f"FIXME: fails with: PermissionError\n  {ex}") from ex
             raise
-    # END end onerror
-    return shutil.rmtree(path, False, onerror)
+
+    if sys.platform != "win32":
+        shutil.rmtree(path)
+    elif sys.version_info >= (3, 12):
+        shutil.rmtree(path, onexc=handler)
+    else:
+        shutil.rmtree(path, onerror=handler)
+
+
+def rmfile(path: PathLike) -> None:
+    """Ensure file deleted also on *Windows* where read-only files need special
+    treatment."""
+    if osp.isfile(path):
+        if sys.platform == "win32":
+            os.chmod(path, 0o777)
+        os.remove(path)
 
 
-def stream_copy(source, destination, chunk_size=512 * 1024):
-    """Copy all data from the source stream into the destination stream in chunks
-    of size chunk_size
+def stream_copy(source: BinaryIO, destination: BinaryIO, chunk_size: int = 512 * 1024) -> int:
+    """Copy all data from the `source` stream into the `destination` stream in chunks
+    of size `chunk_size`.
 
-    :return: amount of bytes written"""
+    :return:
+        Number of bytes written
+    """
     br = 0
     while True:
         chunk = source.read(chunk_size)
@@ -70,277 +269,562 @@ def stream_copy(source, destination, chunk_size=512 * 1024):
     return br
 
 
-def join_path(a, *p):
-    """Join path tokens together similar to os.path.join, but always use
-    '/' instead of possibly '\' on windows."""
-    path = a
+def join_path(a: PathLike, *p: PathLike) -> PathLike:
+    R"""Join path tokens together similar to osp.join, but always use ``/`` instead of
+    possibly ``\`` on Windows."""
+    path = str(a)
     for b in p:
-        if len(b) == 0:
+        b = str(b)
+        if not b:
             continue
-        if b.startswith('/'):
+        if b.startswith("/"):
             path += b[1:]
-        elif path == '' or path.endswith('/'):
+        elif path == "" or path.endswith("/"):
             path += b
         else:
-            path += '/' + b
+            path += "/" + b
     # END for each path token to add
     return path
 
 
-if sys.platform.startswith('win'):
-    def to_native_path_windows(path):
-        return path.replace('/', '\\')
+if sys.platform == "win32":
+
+    def to_native_path_windows(path: PathLike) -> PathLike:
+        path = str(path)
+        return path.replace("/", "\\")
 
-    def to_native_path_linux(path):
-        return path.replace('\\', '/')
+    def to_native_path_linux(path: PathLike) -> str:
+        path = str(path)
+        return path.replace("\\", "/")
 
     to_native_path = to_native_path_windows
 else:
-    # no need for any work on linux
-    def to_native_path_linux(path):
-        return path
+    # No need for any work on Linux.
+    def to_native_path_linux(path: PathLike) -> str:
+        return str(path)
+
     to_native_path = to_native_path_linux
 
 
-def join_path_native(a, *p):
+def join_path_native(a: PathLike, *p: PathLike) -> PathLike:
+    R"""Like :func:`join_path`, but makes sure an OS native path is returned.
+
+    This is only needed to play it safe on Windows and to ensure nice paths that only
+    use ``\``.
     """
-    As join path, but makes sure an OS native path is returned. This is only
-        needed to play it safe on my dear windows and to assure nice paths that only
-        use '\'"""
     return to_native_path(join_path(a, *p))
 
 
-def assure_directory_exists(path, is_file=False):
-    """Assure that the directory pointed to by path exists.
+def assure_directory_exists(path: PathLike, is_file: bool = False) -> bool:
+    """Make sure that the directory pointed to by path exists.
 
-    :param is_file: If True, path is assumed to be a file and handled correctly.
-        Otherwise it must be a directory
-    :return: True if the directory was created, False if it already existed"""
+    :param is_file:
+        If ``True``, `path` is assumed to be a file and handled correctly.
+        Otherwise it must be a directory.
+
+    :return:
+        ``True`` if the directory was created, ``False`` if it already existed.
+    """
     if is_file:
-        path = os.path.dirname(path)
+        path = osp.dirname(path)
     # END handle file
-    if not os.path.isdir(path):
-        os.makedirs(path)
+    if not osp.isdir(path):
+        os.makedirs(path, exist_ok=True)
         return True
     return False
 
 
-def get_user_id():
-    """:return: string identifying the currently active system user as name@node"""
+def _get_exe_extensions() -> Sequence[str]:
+    PATHEXT = os.environ.get("PATHEXT", None)
+    if PATHEXT:
+        return tuple(p.upper() for p in PATHEXT.split(os.pathsep))
+    elif sys.platform == "win32":
+        return (".BAT", ".COM", ".EXE")
+    else:
+        return ()
+
+
+def py_where(program: str, path: Optional[PathLike] = None) -> List[str]:
+    """Perform a path search to assist :func:`is_cygwin_git`.
+
+    This is not robust for general use. It is an implementation detail of
+    :func:`is_cygwin_git`. When a search following all shell rules is needed,
+    :func:`shutil.which` can be used instead.
+
+    :note:
+        Neither this function nor :func:`shutil.which` will predict the effect of an
+        executable search on a native Windows system due to a :class:`subprocess.Popen`
+        call without ``shell=True``, because shell and non-shell executable search on
+        Windows differ considerably.
+    """
+    # From: http://stackoverflow.com/a/377028/548792
+    winprog_exts = _get_exe_extensions()
+
+    def is_exec(fpath: str) -> bool:
+        return (
+            osp.isfile(fpath)
+            and os.access(fpath, os.X_OK)
+            and (
+                sys.platform != "win32" or not winprog_exts or any(fpath.upper().endswith(ext) for ext in winprog_exts)
+            )
+        )
+
+    progs = []
+    if not path:
+        path = os.environ["PATH"]
+    for folder in str(path).split(os.pathsep):
+        folder = folder.strip('"')
+        if folder:
+            exe_path = osp.join(folder, program)
+            for f in [exe_path] + ["%s%s" % (exe_path, e) for e in winprog_exts]:
+                if is_exec(f):
+                    progs.append(f)
+    return progs
+
+
+def _cygexpath(drive: Optional[str], path: str) -> str:
+    if osp.isabs(path) and not drive:
+        # Invoked from `cygpath()` directly with `D:Apps\123`?
+        #  It's an error, leave it alone just slashes)
+        p = path  # convert to str if AnyPath given
+    else:
+        p = path and osp.normpath(osp.expandvars(osp.expanduser(path)))
+        if osp.isabs(p):
+            if drive:
+                # Confusing, maybe a remote system should expand vars.
+                p = path
+            else:
+                p = cygpath(p)
+        elif drive:
+            p = "/proc/cygdrive/%s/%s" % (drive.lower(), p)
+    p_str = str(p)  # ensure it is a str and not AnyPath
+    return p_str.replace("\\", "/")
+
+
+_cygpath_parsers: Tuple[Tuple[Pattern[str], Callable, bool], ...] = (
+    # See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
+    # and: https://www.cygwin.com/cygwin-ug-net/using.html#unc-paths
+    (
+        re.compile(r"\\\\\?\\UNC\\([^\\]+)\\([^\\]+)(?:\\(.*))?"),
+        (lambda server, share, rest_path: "//%s/%s/%s" % (server, share, rest_path.replace("\\", "/"))),
+        False,
+    ),
+    (re.compile(r"\\\\\?\\(\w):[/\\](.*)"), (_cygexpath), False),
+    (re.compile(r"(\w):[/\\](.*)"), (_cygexpath), False),
+    (re.compile(r"file:(.*)", re.I), (lambda rest_path: rest_path), True),
+    (re.compile(r"(\w{2,}:.*)"), (lambda url: url), False),  # remote URL, do nothing
+)
+
+
+def cygpath(path: str) -> str:
+    """Use :meth:`git.cmd.Git.polish_url` instead, that works on any environment."""
+    path = str(path)  # Ensure is str and not AnyPath.
+    # Fix to use Paths when 3.5 dropped. Or to be just str if only for URLs?
+    if not path.startswith(("/cygdrive", "//", "/proc/cygdrive")):
+        for regex, parser, recurse in _cygpath_parsers:
+            match = regex.match(path)
+            if match:
+                path = parser(*match.groups())
+                if recurse:
+                    path = cygpath(path)
+                break
+        else:
+            path = _cygexpath(None, path)
+
+    return path
+
+
+_decygpath_regex = re.compile(r"(?:/proc)?/cygdrive/(\w)(/.*)?")
+
+
+def decygpath(path: PathLike) -> str:
+    path = str(path)
+    m = _decygpath_regex.match(path)
+    if m:
+        drive, rest_path = m.groups()
+        path = "%s:%s" % (drive.upper(), rest_path or "")
+
+    return path.replace("/", "\\")
+
+
+#: Store boolean flags denoting if a specific Git executable
+#: is from a Cygwin installation (since `cache_lru()` unsupported on PY2).
+_is_cygwin_cache: Dict[str, Optional[bool]] = {}
+
+
+def _is_cygwin_git(git_executable: str) -> bool:
+    is_cygwin = _is_cygwin_cache.get(git_executable)  # type: Optional[bool]
+    if is_cygwin is None:
+        is_cygwin = False
+        try:
+            git_dir = osp.dirname(git_executable)
+            if not git_dir:
+                res = py_where(git_executable)
+                git_dir = osp.dirname(res[0]) if res else ""
+
+            # Just a name given, not a real path.
+            uname_cmd = osp.join(git_dir, "uname")
+
+            if not (pathlib.Path(uname_cmd).is_file() and os.access(uname_cmd, os.X_OK)):
+                _logger.debug(f"Failed checking if running in CYGWIN: {uname_cmd} is not an executable")
+                _is_cygwin_cache[git_executable] = is_cygwin
+                return is_cygwin
+
+            process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, universal_newlines=True)
+            uname_out, _ = process.communicate()
+            # retcode = process.poll()
+            is_cygwin = "CYGWIN" in uname_out
+        except Exception as ex:
+            _logger.debug("Failed checking if running in CYGWIN due to: %r", ex)
+        _is_cygwin_cache[git_executable] = is_cygwin
+
+    return is_cygwin
+
+
+@overload
+def is_cygwin_git(git_executable: None) -> Literal[False]: ...
+
+
+@overload
+def is_cygwin_git(git_executable: PathLike) -> bool: ...
+
+
+def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:
+    # TODO: when py3.7 support is dropped, use the new interpolation f"{variable=}"
+    _logger.debug(f"sys.platform={sys.platform!r}, git_executable={git_executable!r}")
+    if sys.platform != "cygwin":
+        return False
+    elif git_executable is None:
+        return False
+    else:
+        return _is_cygwin_git(str(git_executable))
+
+
+def get_user_id() -> str:
+    """:return: String identifying the currently active system user as ``name@node``"""
     return "%s@%s" % (getpass.getuser(), platform.node())
 
 
-def finalize_process(proc):
-    """Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
-    try:
-        proc.wait()
-    except GitCommandError:
-        # if a push has rejected items, the command has non-zero return status
-        # a return status of 128 indicates a connection error - reraise the previous one
-        if proc.poll() == 128:
-            raise
-        pass
-    # END exception handling
+def finalize_process(proc: Union[subprocess.Popen, "Git.AutoInterrupt"], **kwargs: Any) -> None:
+    """Wait for the process (clone, fetch, pull or push) and handle its errors
+    accordingly."""
+    # TODO: No close proc-streams??
+    proc.wait(**kwargs)
 
-#} END utilities
 
-#{ Classes
+@overload
+def expand_path(p: None, expand_vars: bool = ...) -> None: ...
 
 
-class RemoteProgress(object):
+@overload
+def expand_path(p: PathLike, expand_vars: bool = ...) -> str:
+    # TODO: Support for Python 3.5 has been dropped, so these overloads can be improved.
+    ...
 
+
+def expand_path(p: Union[None, PathLike], expand_vars: bool = True) -> Optional[PathLike]:
+    if isinstance(p, pathlib.Path):
+        return p.resolve()
+    try:
+        p = osp.expanduser(p)  # type: ignore[arg-type]
+        if expand_vars:
+            p = osp.expandvars(p)
+        return osp.normpath(osp.abspath(p))
+    except Exception:
+        return None
+
+
+def remove_password_if_present(cmdline: Sequence[str]) -> List[str]:
+    """Parse any command line argument and if one of the elements is an URL with a
+    username and/or password, replace them by stars (in-place).
+
+    If nothing is found, this just returns the command line as-is.
+
+    This should be used for every log line that print a command line, as well as
+    exception messages.
     """
-    Handler providing an interface to parse progress information emitted by git-push
-    and git-fetch and to dispatch callbacks allowing subclasses to react to the progress.
-    """
-    _num_op_codes = 7
-    BEGIN, END, COUNTING, COMPRESSING, WRITING, RECEIVING, RESOLVING = [1 << x for x in range(_num_op_codes)]
-    STAGE_MASK = BEGIN | END
-    OP_MASK = ~STAGE_MASK
+    new_cmdline = []
+    for index, to_parse in enumerate(cmdline):
+        new_cmdline.append(to_parse)
+        try:
+            url = urlsplit(to_parse)
+            # Remove password from the URL if present.
+            if url.password is None and url.username is None:
+                continue
+
+            if url.password is not None:
+                url = url._replace(netloc=url.netloc.replace(url.password, "*****"))
+            if url.username is not None:
+                url = url._replace(netloc=url.netloc.replace(url.username, "*****"))
+            new_cmdline[index] = urlunsplit(url)
+        except ValueError:
+            # This is not a valid URL.
+            continue
+    return new_cmdline
 
-    __slots__ = ("_cur_line", "_seen_ops")
-    re_op_absolute = re.compile("(remote: )?([\w\s]+):\s+()(\d+)()(.*)")
-    re_op_relative = re.compile("(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)")
 
-    def __init__(self):
-        self._seen_ops = list()
+# } END utilities
 
-    def _parse_progress_line(self, line):
-        """Parse progress information from the given line as retrieved by git-push
-        or git-fetch
+# { Classes
 
-        :return: list(line, ...) list of lines that could not be processed"""
+
+class RemoteProgress:
+    """Handler providing an interface to parse progress information emitted by
+    :manpage:`git-push(1)` and :manpage:`git-fetch(1)` and to dispatch callbacks
+    allowing subclasses to react to the progress."""
+
+    _num_op_codes: int = 9
+    (
+        BEGIN,
+        END,
+        COUNTING,
+        COMPRESSING,
+        WRITING,
+        RECEIVING,
+        RESOLVING,
+        FINDING_SOURCES,
+        CHECKING_OUT,
+    ) = [1 << x for x in range(_num_op_codes)]
+    STAGE_MASK = BEGIN | END
+    OP_MASK = ~STAGE_MASK
+
+    DONE_TOKEN = "done."
+    TOKEN_SEPARATOR = ", "
+
+    __slots__ = (
+        "_cur_line",
+        "_seen_ops",
+        "error_lines",  # Lines that started with 'error:' or 'fatal:'.
+        "other_lines",  # Lines not denoting progress (i.e.g. push-infos).
+    )
+    re_op_absolute = re.compile(r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)")
+    re_op_relative = re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)")
+
+    def __init__(self) -> None:
+        self._seen_ops: List[int] = []
+        self._cur_line: Optional[str] = None
+        self.error_lines: List[str] = []
+        self.other_lines: List[str] = []
+
+    def _parse_progress_line(self, line: AnyStr) -> None:
+        """Parse progress information from the given line as retrieved by
+        :manpage:`git-push(1)` or :manpage:`git-fetch(1)`.
+
+        - Lines that do not contain progress info are stored in :attr:`other_lines`.
+        - Lines that seem to contain an error (i.e. start with ``error:`` or ``fatal:``)
+          are stored in :attr:`error_lines`.
+        """
         # handle
         # Counting objects: 4, done.
-        # Compressing objects:  50% (1/2)   \rCompressing objects: 100% (2/2)   \rCompressing objects: 100% (2/2), done.
-        self._cur_line = line
-        sub_lines = line.split('\r')
-        failed_lines = list()
-        for sline in sub_lines:
-            # find esacpe characters and cut them away - regex will not work with
-            # them as they are non-ascii. As git might expect a tty, it will send them
-            last_valid_index = None
-            for i, c in enumerate(reversed(sline)):
-                if ord(c) < 32:
-                    # its a slice index
-                    last_valid_index = -i - 1
-                # END character was non-ascii
-            # END for each character in sline
-            if last_valid_index is not None:
-                sline = sline[:last_valid_index]
-            # END cut away invalid part
-            sline = sline.rstrip()
-
-            cur_count, max_count = None, None
-            match = self.re_op_relative.match(sline)
-            if match is None:
-                match = self.re_op_absolute.match(sline)
-
-            if not match:
-                self.line_dropped(sline)
-                failed_lines.append(sline)
-                continue
-            # END could not get match
-
-            op_code = 0
-            remote, op_name, percent, cur_count, max_count, message = match.groups()
-
-            # get operation id
-            if op_name == "Counting objects":
-                op_code |= self.COUNTING
-            elif op_name == "Compressing objects":
-                op_code |= self.COMPRESSING
-            elif op_name == "Writing objects":
-                op_code |= self.WRITING
-            elif op_name == 'Receiving objects':
-                op_code |= self.RECEIVING
-            elif op_name == 'Resolving deltas':
-                op_code |= self.RESOLVING
-            else:
-                # Note: On windows it can happen that partial lines are sent
-                # Hence we get something like "CompreReceiving objects", which is
-                # a blend of "Compressing objects" and "Receiving objects".
-                # This can't really be prevented, so we drop the line verbosely
-                # to make sure we get informed in case the process spits out new
-                # commands at some point.
-                self.line_dropped(sline)
-                sys.stderr.write("Operation name %r unknown - skipping line '%s'" % (op_name, sline))
-                # Note: Don't add this line to the failed lines, as we have to silently
-                # drop it
-                return failed_lines
-            # END handle op code
-
-            # figure out stage
-            if op_code not in self._seen_ops:
-                self._seen_ops.append(op_code)
-                op_code |= self.BEGIN
-            # END begin opcode
-
-            if message is None:
-                message = ''
-            # END message handling
-
-            message = message.strip()
-            done_token = ', done.'
-            if message.endswith(done_token):
-                op_code |= self.END
-                message = message[:-len(done_token)]
-            # END end message handling
-
-            self.update(op_code, cur_count, max_count, message)
-        # END for each sub line
-        return failed_lines
-
-    def new_message_handler(self):
+        # Compressing objects:  50% (1/2)
+        # Compressing objects: 100% (2/2)
+        # Compressing objects: 100% (2/2), done.
+        if isinstance(line, bytes):  # mypy argues about ternary assignment.
+            line_str = line.decode("utf-8")
+        else:
+            line_str = line
+        self._cur_line = line_str
+
+        if self._cur_line.startswith(("error:", "fatal:")):
+            self.error_lines.append(self._cur_line)
+            return
+
+        cur_count, max_count = None, None
+        match = self.re_op_relative.match(line_str)
+        if match is None:
+            match = self.re_op_absolute.match(line_str)
+
+        if not match:
+            self.line_dropped(line_str)
+            self.other_lines.append(line_str)
+            return
+        # END could not get match
+
+        op_code = 0
+        _remote, op_name, _percent, cur_count, max_count, message = match.groups()
+
+        # Get operation ID.
+        if op_name == "Counting objects":
+            op_code |= self.COUNTING
+        elif op_name == "Compressing objects":
+            op_code |= self.COMPRESSING
+        elif op_name == "Writing objects":
+            op_code |= self.WRITING
+        elif op_name == "Receiving objects":
+            op_code |= self.RECEIVING
+        elif op_name == "Resolving deltas":
+            op_code |= self.RESOLVING
+        elif op_name == "Finding sources":
+            op_code |= self.FINDING_SOURCES
+        elif op_name == "Checking out files":
+            op_code |= self.CHECKING_OUT
+        else:
+            # Note: On Windows it can happen that partial lines are sent.
+            # Hence we get something like "CompreReceiving objects", which is
+            # a blend of "Compressing objects" and "Receiving objects".
+            # This can't really be prevented, so we drop the line verbosely
+            # to make sure we get informed in case the process spits out new
+            # commands at some point.
+            self.line_dropped(line_str)
+            # Note: Don't add this line to the other lines, as we have to silently
+            # drop it.
+            return
+        # END handle op code
+
+        # Figure out stage.
+        if op_code not in self._seen_ops:
+            self._seen_ops.append(op_code)
+            op_code |= self.BEGIN
+        # END begin opcode
+
+        if message is None:
+            message = ""
+        # END message handling
+
+        message = message.strip()
+        if message.endswith(self.DONE_TOKEN):
+            op_code |= self.END
+            message = message[: -len(self.DONE_TOKEN)]
+        # END end message handling
+        message = message.strip(self.TOKEN_SEPARATOR)
+
+        self.update(
+            op_code,
+            cur_count and float(cur_count),
+            max_count and float(max_count),
+            message,
+        )
+
+    def new_message_handler(self) -> Callable[[str], None]:
         """
         :return:
-            a progress handler suitable for handle_process_output(), passing lines on to this Progress
-            handler in a suitable format"""
-        def handler(line):
+            A progress handler suitable for :func:`~git.cmd.handle_process_output`,
+            passing lines on to this progress handler in a suitable format.
+        """
+
+        def handler(line: AnyStr) -> None:
             return self._parse_progress_line(line.rstrip())
-        # end
+
+        # END handler
+
         return handler
 
-    def line_dropped(self, line):
+    def line_dropped(self, line: str) -> None:
         """Called whenever a line could not be understood and was therefore dropped."""
         pass
 
-    def update(self, op_code, cur_count, max_count=None, message=''):
-        """Called whenever the progress changes
+    def update(
+        self,
+        op_code: int,
+        cur_count: Union[str, float],
+        max_count: Union[str, float, None] = None,
+        message: str = "",
+    ) -> None:
+        """Called whenever the progress changes.
 
         :param op_code:
             Integer allowing to be compared against Operation IDs and stage IDs.
 
-            Stage IDs are BEGIN and END. BEGIN will only be set once for each Operation
-            ID as well as END. It may be that BEGIN and END are set at once in case only
-            one progress message was emitted due to the speed of the operation.
-            Between BEGIN and END, none of these flags will be set
+            Stage IDs are :const:`BEGIN` and :const:`END`. :const:`BEGIN` will only be
+            set once for each Operation ID as well as :const:`END`. It may be that
+            :const:`BEGIN` and :const:`END` are set at once in case only one progress
+            message was emitted due to the speed of the operation. Between
+            :const:`BEGIN` and :const:`END`, none of these flags will be set.
+
+            Operation IDs are all held within the :const:`OP_MASK`. Only one Operation
+            ID will be active per call.
 
-            Operation IDs are all held within the OP_MASK. Only one Operation ID will
-            be active per call.
-        :param cur_count: Current absolute count of items
+        :param cur_count:
+            Current absolute count of items.
 
         :param max_count:
-            The maximum count of items we expect. It may be None in case there is
-            no maximum number of items or if it is (yet) unknown.
+            The maximum count of items we expect. It may be ``None`` in case there is no
+            maximum number of items or if it is (yet) unknown.
 
         :param message:
-            In case of the 'WRITING' operation, it contains the amount of bytes
+            In case of the :const:`WRITING` operation, it contains the amount of bytes
             transferred. It may possibly be used for other purposes as well.
 
-        You may read the contents of the current line in self._cur_line"""
+        :note:
+            You may read the contents of the current line in
+            :attr:`self._cur_line <_cur_line>`.
+        """
         pass
 
 
-class Actor(object):
+class CallableRemoteProgress(RemoteProgress):
+    """A :class:`RemoteProgress` implementation forwarding updates to any callable.
+
+    :note:
+        Like direct instances of :class:`RemoteProgress`, instances of this
+        :class:`CallableRemoteProgress` class are not themselves directly callable.
+        Rather, instances of this class wrap a callable and forward to it. This should
+        therefore not be confused with :class:`git.types.CallableProgress`.
+    """
+
+    __slots__ = ("_callable",)
+
+    def __init__(self, fn: Callable) -> None:
+        self._callable = fn
+        super().__init__()
+
+    def update(self, *args: Any, **kwargs: Any) -> None:
+        self._callable(*args, **kwargs)
+
+
+class Actor:
+    """Actors hold information about a person acting on the repository. They can be
+    committers and authors or anything with a name and an email as mentioned in the git
+    log entries."""
 
-    """Actors hold information about a person acting on the repository. They
-    can be committers and authors or anything with a name and an email as
-    mentioned in the git log entries."""
     # PRECOMPILED REGEX
-    name_only_regex = re.compile(r'<(.+)>')
-    name_email_regex = re.compile(r'(.*) <(.+?)>')
+    name_only_regex = re.compile(r"<(.*)>")
+    name_email_regex = re.compile(r"(.*) <(.*?)>")
 
     # ENVIRONMENT VARIABLES
-    # read when creating new commits
+    # These are read when creating new commits.
     env_author_name = "GIT_AUTHOR_NAME"
     env_author_email = "GIT_AUTHOR_EMAIL"
     env_committer_name = "GIT_COMMITTER_NAME"
     env_committer_email = "GIT_COMMITTER_EMAIL"
 
     # CONFIGURATION KEYS
-    conf_name = 'name'
-    conf_email = 'email'
+    conf_name = "name"
+    conf_email = "email"
 
-    __slots__ = ('name', 'email')
+    __slots__ = ("name", "email")
 
-    def __init__(self, name, email):
+    def __init__(self, name: Optional[str], email: Optional[str]) -> None:
         self.name = name
         self.email = email
 
-    def __eq__(self, other):
+    def __eq__(self, other: Any) -> bool:
         return self.name == other.name and self.email == other.email
 
-    def __ne__(self, other):
+    def __ne__(self, other: Any) -> bool:
         return not (self == other)
 
-    def __hash__(self):
+    def __hash__(self) -> int:
         return hash((self.name, self.email))
 
-    def __str__(self):
-        return self.name
+    def __str__(self) -> str:
+        return self.name if self.name else ""
 
-    def __repr__(self):
-        return u'<git.Actor "%s <%s>">' % (self.name, self.email)
+    def __repr__(self) -> str:
+        return '<git.Actor "%s <%s>">' % (self.name, self.email)
 
     @classmethod
-    def _from_string(cls, string):
-        """Create an Actor from a string.
-        :param string: is the string, which is expected to be in regular git format
+    def _from_string(cls, string: str) -> "Actor":
+        """Create an :class:`Actor` from a string.
+
+        :param string:
+            The string, which is expected to be in regular git format::
 
                 John Doe <jdoe@example.com>
 
-        :return: Actor """
+        :return:
+            :class:`Actor`
+        """
         m = cls.name_email_regex.search(string)
         if m:
             name, email = m.groups()
@@ -349,57 +833,78 @@ def _from_string(cls, string):
             m = cls.name_only_regex.search(string)
             if m:
                 return Actor(m.group(1), None)
-            else:
-                # assume best and use the whole string as name
-                return Actor(string, None)
+            # Assume the best and use the whole string as name.
+            return Actor(string, None)
             # END special case name
         # END handle name/email matching
 
     @classmethod
-    def _main_actor(cls, env_name, env_email, config_reader=None):
-        actor = Actor('', '')
-        default_email = get_user_id()
-        default_name = default_email.split('@')[0]
-
-        for attr, evar, cvar, default in (('name', env_name, cls.conf_name, default_name),
-                                          ('email', env_email, cls.conf_email, default_email)):
+    def _main_actor(
+        cls,
+        env_name: str,
+        env_email: str,
+        config_reader: Union[None, "GitConfigParser", "SectionConstraint"] = None,
+    ) -> "Actor":
+        actor = Actor("", "")
+        user_id = None  # We use this to avoid multiple calls to getpass.getuser().
+
+        def default_email() -> str:
+            nonlocal user_id
+            if not user_id:
+                user_id = get_user_id()
+            return user_id
+
+        def default_name() -> str:
+            return default_email().split("@")[0]
+
+        for attr, evar, cvar, default in (
+            ("name", env_name, cls.conf_name, default_name),
+            ("email", env_email, cls.conf_email, default_email),
+        ):
             try:
-                setattr(actor, attr, os.environ[evar])
+                val = os.environ[evar]
+                setattr(actor, attr, val)
             except KeyError:
                 if config_reader is not None:
-                    setattr(actor, attr, config_reader.get_value('user', cvar, default))
+                    try:
+                        val = config_reader.get("user", cvar)
+                    except Exception:
+                        val = default()
+                    setattr(actor, attr, val)
                 # END config-reader handling
                 if not getattr(actor, attr):
-                    setattr(actor, attr, default)
+                    setattr(actor, attr, default())
             # END handle name
         # END for each item to retrieve
         return actor
 
     @classmethod
-    def committer(cls, config_reader=None):
+    def committer(cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint"] = None) -> "Actor":
+        """
+        :return:
+            :class:`Actor` instance corresponding to the configured committer. It
+            behaves similar to the git implementation, such that the environment will
+            override configuration values of `config_reader`. If no value is set at all,
+            it will be generated.
+
+        :param config_reader:
+            ConfigReader to use to retrieve the values from in case they are not set in
+            the environment.
         """
-        :return: Actor instance corresponding to the configured committer. It behaves
-            similar to the git implementation, such that the environment will override
-            configuration values of config_reader. If no value is set at all, it will be
-            generated
-        :param config_reader: ConfigReader to use to retrieve the values from in case
-            they are not set in the environment"""
         return cls._main_actor(cls.env_committer_name, cls.env_committer_email, config_reader)
 
     @classmethod
-    def author(cls, config_reader=None):
-        """Same as committer(), but defines the main author. It may be specified in the environment,
-        but defaults to the committer"""
+    def author(cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint"] = None) -> "Actor":
+        """Same as :meth:`committer`, but defines the main author. It may be specified
+        in the environment, but defaults to the committer."""
         return cls._main_actor(cls.env_author_name, cls.env_author_email, config_reader)
 
 
-class Stats(object):
-
-    """
-    Represents stat information as presented by git at the end of a merge. It is
+class Stats:
+    """Represents stat information as presented by git at the end of a merge. It is
     created from the output of a diff operation.
 
-    ``Example``::
+    Example::
 
      c = Commit( sha1 )
      s = c.stats
@@ -413,185 +918,224 @@ class Stats(object):
       deletions = number of deleted lines as int
       insertions = number of inserted lines as int
       lines = total number of lines changed as int, or deletions + insertions
+      change_type = type of change as str, A|C|D|M|R|T|U|X|B
 
     ``full-stat-dict``
 
     In addition to the items in the stat-dict, it features additional information::
 
-     files = number of changed files as int"""
+     files = number of changed files as int
+    """
+
     __slots__ = ("total", "files")
 
-    def __init__(self, total, files):
+    def __init__(self, total: Total_TD, files: Dict[PathLike, Files_TD]) -> None:
         self.total = total
         self.files = files
 
     @classmethod
-    def _list_from_string(cls, repo, text):
-        """Create a Stat object from output retrieved by git-diff.
-
-        :return: git.Stat"""
-        hsh = {'total': {'insertions': 0, 'deletions': 0, 'lines': 0, 'files': 0}, 'files': dict()}
-        for line in text.splitlines():
-            (raw_insertions, raw_deletions, filename) = line.split("\t")
-            insertions = raw_insertions != '-' and int(raw_insertions) or 0
-            deletions = raw_deletions != '-' and int(raw_deletions) or 0
-            hsh['total']['insertions'] += insertions
-            hsh['total']['deletions'] += deletions
-            hsh['total']['lines'] += insertions + deletions
-            hsh['total']['files'] += 1
-            hsh['files'][filename.strip()] = {'insertions': insertions,
-                                              'deletions': deletions,
-                                              'lines': insertions + deletions}
-        return Stats(hsh['total'], hsh['files'])
-
+    def _list_from_string(cls, repo: "Repo", text: str) -> "Stats":
+        """Create a :class:`Stats` object from output retrieved by
+        :manpage:`git-diff(1)`.
 
-class IndexFileSHA1Writer(object):
-
-    """Wrapper around a file-like object that remembers the SHA1 of
-    the data written to it. It will write a sha when the stream is closed
-    or if the asked for explicitly usign write_sha.
+        :return:
+            :class:`git.Stats`
+        """
 
-    Only useful to the indexfile
+        hsh: HSH_TD = {
+            "total": {"insertions": 0, "deletions": 0, "lines": 0, "files": 0},
+            "files": {},
+        }
+        for line in text.splitlines():
+            (change_type, raw_insertions, raw_deletions, filename) = line.split("\t")
+            insertions = raw_insertions != "-" and int(raw_insertions) or 0
+            deletions = raw_deletions != "-" and int(raw_deletions) or 0
+            hsh["total"]["insertions"] += insertions
+            hsh["total"]["deletions"] += deletions
+            hsh["total"]["lines"] += insertions + deletions
+            hsh["total"]["files"] += 1
+            files_dict: Files_TD = {
+                "insertions": insertions,
+                "deletions": deletions,
+                "lines": insertions + deletions,
+                "change_type": change_type,
+            }
+            hsh["files"][filename.strip()] = files_dict
+        return Stats(hsh["total"], hsh["files"])
+
+
+class IndexFileSHA1Writer:
+    """Wrapper around a file-like object that remembers the SHA1 of the data written to
+    it. It will write a sha when the stream is closed or if asked for explicitly using
+    :meth:`write_sha`.
+
+    Only useful to the index file.
+
+    :note:
+        Based on the dulwich project.
+    """
 
-    :note: Based on the dulwich project"""
     __slots__ = ("f", "sha1")
 
-    def __init__(self, f):
+    def __init__(self, f: IO) -> None:
         self.f = f
         self.sha1 = make_sha(b"")
 
-    def write(self, data):
+    def write(self, data: AnyStr) -> int:
         self.sha1.update(data)
         return self.f.write(data)
 
-    def write_sha(self):
+    def write_sha(self) -> bytes:
         sha = self.sha1.digest()
         self.f.write(sha)
         return sha
 
-    def close(self):
+    def close(self) -> bytes:
         sha = self.write_sha()
         self.f.close()
         return sha
 
-    def tell(self):
+    def tell(self) -> int:
         return self.f.tell()
 
 
-class LockFile(object):
-
+class LockFile:
     """Provides methods to obtain, check for, and release a file based lock which
     should be used to handle concurrent access to the same file.
 
     As we are a utility class to be derived from, we only use protected methods.
 
-    Locks will automatically be released on destruction"""
+    Locks will automatically be released on destruction.
+    """
+
     __slots__ = ("_file_path", "_owns_lock")
 
-    def __init__(self, file_path):
+    def __init__(self, file_path: PathLike) -> None:
         self._file_path = file_path
         self._owns_lock = False
 
-    def __del__(self):
+    def __del__(self) -> None:
         self._release_lock()
 
-    def _lock_file_path(self):
+    def _lock_file_path(self) -> str:
         """:return: Path to lockfile"""
         return "%s.lock" % (self._file_path)
 
-    def _has_lock(self):
-        """:return: True if we have a lock and if the lockfile still exists
-        :raise AssertionError: if our lock-file does not exist"""
+    def _has_lock(self) -> bool:
+        """
+        :return:
+            True if we have a lock and if the lockfile still exists
+
+        :raise AssertionError:
+            If our lock-file does not exist.
+        """
         return self._owns_lock
 
-    def _obtain_lock_or_raise(self):
-        """Create a lock file as flag for other instances, mark our instance as lock-holder
+    def _obtain_lock_or_raise(self) -> None:
+        """Create a lock file as flag for other instances, mark our instance as
+        lock-holder.
 
-        :raise IOError: if a lock was already present or a lock file could not be written"""
+        :raise IOError:
+            If a lock was already present or a lock file could not be written.
+        """
         if self._has_lock():
             return
         lock_file = self._lock_file_path()
-        if os.path.isfile(lock_file):
-            raise IOError("Lock for file %r did already exist, delete %r in case the lock is illegal" %
-                          (self._file_path, lock_file))
+        if osp.isfile(lock_file):
+            raise IOError(
+                "Lock for file %r did already exist, delete %r in case the lock is illegal"
+                % (self._file_path, lock_file)
+            )
 
         try:
-            fd = os.open(lock_file, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0)
-            os.close(fd)
+            with open(lock_file, mode="w"):
+                pass
         except OSError as e:
-            raise IOError(str(e))
+            raise IOError(str(e)) from e
 
         self._owns_lock = True
 
-    def _obtain_lock(self):
+    def _obtain_lock(self) -> None:
         """The default implementation will raise if a lock cannot be obtained.
-        Subclasses may override this method to provide a different implementation"""
+
+        Subclasses may override this method to provide a different implementation.
+        """
         return self._obtain_lock_or_raise()
 
-    def _release_lock(self):
-        """Release our lock if we have one"""
+    def _release_lock(self) -> None:
+        """Release our lock if we have one."""
         if not self._has_lock():
             return
 
-        # if someone removed our file beforhand, lets just flag this issue
-        # instead of failing, to make it more usable.
+        # If someone removed our file beforehand, lets just flag this issue instead of
+        # failing, to make it more usable.
         lfp = self._lock_file_path()
         try:
-            # on bloody windows, the file needs write permissions to be removable.
-            # Why ...
-            if os.name == 'nt':
-                os.chmod(lfp, 0o777)
-            # END handle win32
-            os.remove(lfp)
+            rmfile(lfp)
         except OSError:
             pass
         self._owns_lock = False
 
 
 class BlockingLockFile(LockFile):
+    """The lock file will block until a lock could be obtained, or fail after a
+    specified timeout.
 
-    """The lock file will block until a lock could be obtained, or fail after
-    a specified timeout.
+    :note:
+        If the directory containing the lock was removed, an exception will be raised
+        during the blocking period, preventing hangs as the lock can never be obtained.
+    """
 
-    :note: If the directory containing the lock was removed, an exception will
-        be raised during the blocking period, preventing hangs as the lock
-        can never be obtained."""
     __slots__ = ("_check_interval", "_max_block_time")
 
-    def __init__(self, file_path, check_interval_s=0.3, max_block_time_s=MAXSIZE):
-        """Configure the instance
+    def __init__(
+        self,
+        file_path: PathLike,
+        check_interval_s: float = 0.3,
+        max_block_time_s: int = sys.maxsize,
+    ) -> None:
+        """Configure the instance.
 
-        :parm check_interval_s:
+        :param check_interval_s:
             Period of time to sleep until the lock is checked the next time.
-            By default, it waits a nearly unlimited time
+            By default, it waits a nearly unlimited time.
 
-        :parm max_block_time_s: Maximum amount of seconds we may lock"""
-        super(BlockingLockFile, self).__init__(file_path)
+        :param max_block_time_s:
+            Maximum amount of seconds we may lock.
+        """
+        super().__init__(file_path)
         self._check_interval = check_interval_s
         self._max_block_time = max_block_time_s
 
-    def _obtain_lock(self):
-        """This method blocks until it obtained the lock, or raises IOError if
-        it ran out of time or if the parent directory was not available anymore.
-        If this method returns, you are guranteed to own the lock"""
+    def _obtain_lock(self) -> None:
+        """This method blocks until it obtained the lock, or raises :exc:`IOError` if it
+        ran out of time or if the parent directory was not available anymore.
+
+        If this method returns, you are guaranteed to own the lock.
+        """
         starttime = time.time()
         maxtime = starttime + float(self._max_block_time)
         while True:
             try:
-                super(BlockingLockFile, self)._obtain_lock()
-            except IOError:
+                super()._obtain_lock()
+            except IOError as e:
                 # synity check: if the directory leading to the lockfile is not
-                # readable anymore, raise an execption
+                # readable anymore, raise an exception
                 curtime = time.time()
-                if not os.path.isdir(os.path.dirname(self._lock_file_path())):
+                if not osp.isdir(osp.dirname(self._lock_file_path())):
                     msg = "Directory containing the lockfile %r was not readable anymore after waiting %g seconds" % (
-                        self._lock_file_path(), curtime - starttime)
-                    raise IOError(msg)
+                        self._lock_file_path(),
+                        curtime - starttime,
+                    )
+                    raise IOError(msg) from e
                 # END handle missing directory
 
                 if curtime >= maxtime:
-                    msg = "Waited %g seconds for lock at %r" % (maxtime - starttime, self._lock_file_path())
-                    raise IOError(msg)
+                    msg = "Waited %g seconds for lock at %r" % (
+                        maxtime - starttime,
+                        self._lock_file_path(),
+                    )
+                    raise IOError(msg) from e
                 # END abort if we wait too long
                 time.sleep(self._check_interval)
             else:
@@ -599,47 +1143,63 @@ def _obtain_lock(self):
         # END endless loop
 
 
-class IterableList(list):
-
-    """
-    List of iterable objects allowing to query an object by id or by named index::
+class IterableList(List[T_IterableObj]):
+    """List of iterable objects allowing to query an object by id or by named index::
 
      heads = repo.heads
      heads.master
      heads['master']
      heads[0]
 
-    It requires an id_attribute name to be set which will be queried from its
+    Iterable parent objects:
+
+    * :class:`Commit <git.objects.Commit>`
+    * :class:`Submodule <git.objects.submodule.base.Submodule>`
+    * :class:`Reference <git.refs.reference.Reference>`
+    * :class:`FetchInfo <git.remote.FetchInfo>`
+    * :class:`PushInfo <git.remote.PushInfo>`
+
+    Iterable via inheritance:
+
+    * :class:`Head <git.refs.head.Head>`
+    * :class:`TagReference <git.refs.tag.TagReference>`
+    * :class:`RemoteReference <git.refs.remote.RemoteReference>`
+
+    This requires an ``id_attribute`` name to be set which will be queried from its
     contained items to have a means for comparison.
 
-    A prefix can be specified which is to be used in case the id returned by the
-    items always contains a prefix that does not matter to the user, so it
-    can be left out."""
-    __slots__ = ('_id_attr', '_prefix')
+    A prefix can be specified which is to be used in case the id returned by the items
+    always contains a prefix that does not matter to the user, so it can be left out.
+    """
 
-    def __new__(cls, id_attr, prefix=''):
-        return super(IterableList, cls).__new__(cls)
+    __slots__ = ("_id_attr", "_prefix")
 
-    def __init__(self, id_attr, prefix=''):
+    def __new__(cls, id_attr: str, prefix: str = "") -> "IterableList[T_IterableObj]":
+        return super().__new__(cls)
+
+    def __init__(self, id_attr: str, prefix: str = "") -> None:
         self._id_attr = id_attr
         self._prefix = prefix
 
-    def __contains__(self, attr):
-        # first try identy match for performance
-        rval = list.__contains__(self, attr)
-        if rval:
-            return rval
+    def __contains__(self, attr: object) -> bool:
+        # First try identity match for performance.
+        try:
+            rval = list.__contains__(self, attr)
+            if rval:
+                return rval
+        except (AttributeError, TypeError):
+            pass
         # END handle match
 
-        # otherwise make a full name search
+        # Otherwise make a full name search.
         try:
-            getattr(self, attr)
+            getattr(self, cast(str, attr))  # Use cast to silence mypy.
             return True
         except (AttributeError, TypeError):
             return False
         # END handle membership
 
-    def __getattr__(self, attr):
+    def __getattr__(self, attr: str) -> T_IterableObj:
         attr = self._prefix + attr
         for item in self:
             if getattr(item, self._id_attr) == attr:
@@ -647,18 +1207,20 @@ def __getattr__(self, attr):
         # END for each item
         return list.__getattribute__(self, attr)
 
-    def __getitem__(self, index):
+    def __getitem__(self, index: Union[SupportsIndex, int, slice, str]) -> T_IterableObj:  # type: ignore[override]
         if isinstance(index, int):
             return list.__getitem__(self, index)
-
-        try:
-            return getattr(self, index)
-        except AttributeError:
-            raise IndexError("No item found with id %r" % (self._prefix + index))
+        elif isinstance(index, slice):
+            raise ValueError("Index should be an int or str")
+        else:
+            try:
+                return getattr(self, index)
+            except AttributeError as e:
+                raise IndexError("No item found with id %r" % (self._prefix + index)) from e
         # END handle getattr
 
-    def __delitem__(self, index):
-        delindex = index
+    def __delitem__(self, index: Union[SupportsIndex, int, slice, str]) -> None:
+        delindex = cast(int, index)
         if not isinstance(index, int):
             delindex = -1
             name = self._prefix + index
@@ -675,60 +1237,114 @@ def __delitem__(self, index):
         list.__delitem__(self, delindex)
 
 
-class Iterable(object):
+@runtime_checkable
+class IterableObj(Protocol):
+    """Defines an interface for iterable items, so there is a uniform way to retrieve
+    and iterate items within the git repository.
 
-    """Defines an interface for iterable items which is to assure a uniform
-    way to retrieve and iterate items within the git repository"""
-    __slots__ = tuple()
-    _id_attribute_ = "attribute that most suitably identifies your instance"
+    Subclasses:
+
+    * :class:`Submodule <git.objects.submodule.base.Submodule>`
+    * :class:`Commit <git.objects.Commit>`
+    * :class:`Reference <git.refs.reference.Reference>`
+    * :class:`PushInfo <git.remote.PushInfo>`
+    * :class:`FetchInfo <git.remote.FetchInfo>`
+    * :class:`Remote <git.remote.Remote>`
+    """
+
+    __slots__ = ()
+
+    _id_attribute_: str
 
     @classmethod
-    def list_items(cls, repo, *args, **kwargs):
+    @abstractmethod
+    def iter_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> Iterator[T_IterableObj]:
+        # Return-typed to be compatible with subtypes e.g. Remote.
+        """Find (all) items of this type.
+
+        Subclasses can specify `args` and `kwargs` differently, and may use them for
+        filtering. However, when the method is called with no additional positional or
+        keyword arguments, subclasses are obliged to to yield all items.
+
+        :return:
+            Iterator yielding Items
         """
-        Find all items of this type - subclasses can specify args and kwargs differently.
-        If no args are given, subclasses are obliged to return all items if no additional
-        arguments arg given.
+        raise NotImplementedError("To be implemented by Subclass")
 
-        :note: Favor the iter_items method as it will
+    @classmethod
+    def list_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> IterableList[T_IterableObj]:
+        """Find (all) items of this type and collect them into a list.
+
+        For more information about the arguments, see :meth:`iter_items`.
 
-        :return:list(Item,...) list of item instances"""
-        out_list = IterableList(cls._id_attribute_)
+        :note:
+            Favor the :meth:`iter_items` method as it will avoid eagerly collecting all
+            items. When there are many items, that can slow performance and increase
+            memory usage.
+
+        :return:
+            list(Item,...) list of item instances
+        """
+        out_list: IterableList = IterableList(cls._id_attribute_)
         out_list.extend(cls.iter_items(repo, *args, **kwargs))
         return out_list
 
+
+class IterableClassWatcher(type):
+    """Metaclass that issues :exc:`DeprecationWarning` when :class:`git.util.Iterable`
+    is subclassed."""
+
+    def __init__(cls, name: str, bases: Tuple, clsdict: Dict) -> None:
+        for base in bases:
+            if type(base) is IterableClassWatcher:
+                warnings.warn(
+                    f"GitPython Iterable subclassed by {name}."
+                    " Iterable is deprecated due to naming clash since v3.1.18"
+                    " and will be removed in 4.0.0."
+                    " Use IterableObj instead.",
+                    DeprecationWarning,
+                    stacklevel=2,
+                )
+
+
+class Iterable(metaclass=IterableClassWatcher):
+    """Deprecated, use :class:`IterableObj` instead.
+
+    Defines an interface for iterable items, so there is a uniform way to retrieve
+    and iterate items within the git repository.
+    """
+
+    __slots__ = ()
+
+    _id_attribute_ = "attribute that most suitably identifies your instance"
+
     @classmethod
-    def iter_items(cls, repo, *args, **kwargs):
-        """For more information about the arguments, see list_items
-        :return:  iterator yielding Items"""
+    def iter_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> Any:
+        """Deprecated, use :class:`IterableObj` instead.
+
+        Find (all) items of this type.
+
+        See :meth:`IterableObj.iter_items` for details on usage.
+
+        :return:
+            Iterator yielding Items
+        """
         raise NotImplementedError("To be implemented by Subclass")
 
-#} END classes
+    @classmethod
+    def list_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> Any:
+        """Deprecated, use :class:`IterableObj` instead.
+
+        Find (all) items of this type and collect them into a list.
 
+        See :meth:`IterableObj.list_items` for details on usage.
 
-class WaitGroup(object):
-    """WaitGroup is like Go sync.WaitGroup.
+        :return:
+            list(Item,...) list of item instances
+        """
+        out_list: Any = IterableList(cls._id_attribute_)
+        out_list.extend(cls.iter_items(repo, *args, **kwargs))
+        return out_list
 
-    Without all the useful corner cases.
-    By Peter Teichman, taken from https://gist.github.com/pteichman/84b92ae7cef0ab98f5a8
-    """
-    def __init__(self):
-        self.count = 0
-        self.cv = threading.Condition()
-
-    def add(self, n):
-        self.cv.acquire()
-        self.count += n
-        self.cv.release()
-
-    def done(self):
-        self.cv.acquire()
-        self.count -= 1
-        if self.count == 0:
-            self.cv.notify_all()
-        self.cv.release()
-
-    def wait(self):
-        self.cv.acquire()
-        while self.count > 0:
-            self.cv.wait()
-        self.cv.release()
+
+# } END classes
diff --git a/init-tests-after-clone.sh b/init-tests-after-clone.sh
new file mode 100755
index 000000000..bfada01b0
--- /dev/null
+++ b/init-tests-after-clone.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+#
+# This file is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+set -eu
+
+fallback_repo_for_tags='https://github.com/gitpython-developers/GitPython.git'
+
+ci() {
+    # For now, check just these, as a false positive could lead to data loss.
+    test -n "${TRAVIS-}" || test -n "${GITHUB_ACTIONS-}"
+}
+
+no_version_tags() {
+    test -z "$(git tag -l '[0-9]*' 'v[0-9]*')"
+}
+
+warn() {
+    if test -n "${GITHUB_ACTIONS-}"; then
+        printf '::warning ::%s\n' "$*" >&2  # Annotate workflow.
+    else
+        printf '%s\n' "$@" >&2
+    fi
+}
+
+if ! ci; then
+    printf 'This operation will destroy locally modified files. Continue ? [N/y]: ' >&2
+    read -r answer
+    case "$answer" in
+    [yY])
+        ;;
+    *)
+        exit 2 ;;
+    esac
+fi
+
+# Stop if we have run this. (You can delete __testing_point__ to let it rerun.)
+# This also keeps track of where we are, so we can get back here.
+git tag __testing_point__
+
+# The tests need a branch called master.
+git checkout master -- || git checkout -b master
+
+# The tests need a reflog history on the master branch.
+git reset --hard HEAD~1
+git reset --hard HEAD~1
+git reset --hard HEAD~1
+
+# Point the master branch where we started, so we test the correct code.
+git reset --hard __testing_point__
+
+# The tests need submodules, including a submodule with a submodule.
+git submodule update --init --recursive
+
+# The tests need some version tags. Try to get them even in forks. This fetches
+# other objects too. So, locally, we always do it, for a consistent experience.
+if ! ci || no_version_tags; then
+    git fetch --all --tags
+fi
+
+# If we still have no version tags, try to get them from the original repo.
+if no_version_tags; then
+    warn 'No local or remote version tags found. Trying fallback remote:' \
+         "$fallback_repo_for_tags"
+
+    # git fetch supports * but not [], and --no-tags means no *other* tags, so...
+    printf 'refs/tags/%d*:refs/tags/%d*\n' 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 |
+        xargs git fetch --no-tags "$fallback_repo_for_tags"
+
+    if no_version_tags; then
+        warn 'No version tags found anywhere. Some tests will fail.'
+    fi
+fi
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 000000000..58ed81f17
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,87 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
+
+[tool.pytest.ini_options]
+addopts = "--cov=git --cov-report=term -ra"
+filterwarnings = "ignore::DeprecationWarning"
+python_files = "test_*.py"
+tmp_path_retention_policy = "failed"
+testpaths = "test"  # Space separated list of paths from root e.g test tests doc/testing.
+# --cov   coverage
+# --cov-report term  # send report to terminal term-missing -> terminal with line numbers  html  xml
+# --cov-report term-missing # to terminal with line numbers
+# --cov-report html:path  # html file at path
+# --maxfail  # number of errors before giving up
+# -rfE  # default test summary: list fail and error
+# -ra   # test summary: list all non-passing (fail, error, skip, xfail, xpass)
+# --ignore-glob=**/gitdb/*  # ignore glob paths
+# filterwarnings ignore::WarningType  # ignores those warnings
+
+[tool.mypy]
+python_version = "3.8"
+files = ["git/", "test/deprecation/"]
+disallow_untyped_defs = true
+no_implicit_optional = true
+warn_redundant_casts = true
+warn_unused_ignores = true  # Useful in general, but especially in test/deprecation.
+warn_unreachable = true
+implicit_reexport = true
+# strict = true
+# TODO: Remove when 'gitdb' is fully annotated.
+exclude = ["^git/ext/gitdb"]
+[[tool.mypy.overrides]]
+module = "gitdb.*"
+ignore_missing_imports = true
+
+[tool.coverage.run]
+source = ["git"]
+
+[tool.coverage.report]
+include = ["*/git/*"]
+omit = ["*/git/ext/*"]
+
+[tool.ruff]
+target-version = "py37"
+line-length = 120
+# Exclude a variety of commonly ignored directories.
+exclude = [
+    "git/ext/",
+    "build",
+    "dist",
+]
+# Enable Pyflakes `E` and `F` codes by default.
+lint.select = [
+    "E",
+    "W",     # See: https://pypi.org/project/pycodestyle
+    "F",     # See: https://pypi.org/project/pyflakes
+    # "I",   # See: https://pypi.org/project/isort/
+    # "S",   # See: https://pypi.org/project/flake8-bandit
+    # "UP",  # See: https://docs.astral.sh/ruff/rules/#pyupgrade-up
+]
+lint.extend-select = [
+    # "A",    # See: https://pypi.org/project/flake8-builtins
+    "B",      # See: https://pypi.org/project/flake8-bugbear
+    "C4",     # See: https://pypi.org/project/flake8-comprehensions
+    "TC004",  # See: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/
+]
+lint.ignore = [
+    # If it becomes necessary to ignore any rules, list them here.
+]
+lint.unfixable = [
+    "F401",  # Module imported but unused
+]
+
+[tool.ruff.lint.per-file-ignores]
+"test/**" = [
+    "B018",  # useless-expression
+]
+"fuzzing/fuzz-targets/**" = [
+  "E402",  # environment setup must happen before the `git` module is imported, thus cannot happen at top of file
+]
+
+
+[tool.codespell]
+ignore-words-list="afile,assertIn,doesnt,gud,uptodate"
+#count = true
+quiet-level = 3
diff --git a/release-verification-key.asc b/release-verification-key.asc
new file mode 100644
index 000000000..e20fe8b9b
--- /dev/null
+++ b/release-verification-key.asc
@@ -0,0 +1,83 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mQINBF8RDFQBEACvEIpL8Yql7PMEHyJBJMVpGG1n/ZOiPbPMrptERB2kwe6z5Kvc
+hPAQZwL/2z5Mdsr0K+CnW34SxFGS/OMNgq7dtH2C8XmFDy0qnNwBD5wSH8gmVCOs
+TW+6lvbdn1O/Wj96EkmP3QXlerD878SOElfpu9CHmDZeF+v5CUDRPGCri5ztamuv
+D5kjt05K+69pXgshQpCB84yWgiLSLfXocnB+k12xaCz+OLQjBcH9G2xnOAY+n/jn
+84EYuoWnNdMo2lTj+PkgQ3jk57cDKM1hO9VWEKppzvSBr+hFHnoP773DXm2lMGQ2
+bdQHQujWNtj4x7ov9dp04O0IW08Fcm9M/QIoTG8w8oh8mpw+n8Rtx5snr/Ctuti/
+L+wUMrgFLYS03v36zNKOt/7IZEVpU9WUDgdyd01NVwM56vd8tJNpwxka6SAocAa3
+U4Fg64zf0BXvfYZZqHGckwVYzUzB6zSPLki2I+/j4a62h4+Yen/Yxnv6g2hhG77X
+Tly34RHrUjrGcYW9fTcJygZ5h/y2dOl5qBwIRVXSqFg05NB4jFM2sHHxaJik8I+g
+A2Kfhq4/UWDJ5oHmtVTXYkm8JtUNa7lJ9qD+TdKyFzC0ExZEOKsR6yl5a3XlQk+Y
+Sh1BnN2Jl6lugxcageOlp0AFm/QMi9fFeH77ZhgStR/aC5w8/he/IBCTsQARAQAB
+tDRTZWJhc3RpYW4gVGhpZWwgKFl1YmlLZXkgVVNCLUMpIDxieXJvbmltb0BnbWFp
+bC5jb20+iQJOBBMBCAA4FiEEJ8UOf1kJR9cnOnQehRlMCEIZgMkFAl8RDMwCGwMF
+CwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQhRlMCEIZgMn1ig/8D+YobFzW+Twj
+DS3BUogITUGz1h6gks06Rv6IX6snZkgQNo2BsUZVJOZYRNNJJYVckJVP5DdgMVol
+ZFeP6dNBMzfocKeHVTPn2/6brpRSajWKC4QtBwqY6V/R2DfyztFsseqJSgfAs8l3
+pT0KfvSajuiarlLuB/Fx1YJ1gnuj0J7EPM+c7WMvyjKqPO5ysQL7fK0nDZLglOGb
+Vie9W8e7Mi0AVCQSzu/Hw8imBApOU47Sk2ceRvvOTwJlmVOfDfN1eaAiAq08PJlG
+OnVTsXC+D1kypBGFQZt6M3xHn4kgHzQaHtShdCH4WJBrL55t0URw6Di8aS3NwLFB
+YH+7owdAdS/jfqP8vtRa5bvcyviK+MP0slnvC4v46ketm8AVq5XhYsSDLBxOcrOm
+YO29CyJ5TVSvOayO6DEiorvmCuri9275jwHHePBB14mG54MRsh0yjvZraXzBJ2S4
+keZ3vW6rLI5SLIH9LtRlBAOltzIbZysAEq4J6YcAKR6KpM59xN8N902MYIyVH8zu
+eac13oJZ6iKlnF6Yl2oYzosQ40MsLmdonyanMcZ5emSgjihDMXZzh3EE8hb3+8aW
+R8Te/byYL6nlHfGugUpWK8b9HQTjdZKlVh6qS1wRBoeDGhVK9LkzluDGFoXMsSPs
+KW4WBExQ4MK3cgsDLcor2n3HsR3vdj20PlNlYmFzdGlhbiBUaGllbCAoSW4gUnVz
+dCBJIHRydXN0KSA8c2ViYXN0aWFuLnRoaWVsQGljbG91ZC5jb20+iQJOBBMBCAA4
+FiEEJ8UOf1kJR9cnOnQehRlMCEIZgMkFAl8RDFQCGwMFCwkIBwIGFQoJCAsCBBYC
+AwECHgECF4AACgkQhRlMCEIZgMnidA/8C1dg1PuOw4GRUPjn+9lAn6I0zI7o5lqV
+J7pi41iu/zypY6abHgr0yvUceeLEdgxCq7Wx+2CetHC34rDyKZDeNq/zP6b4fS31
+j+pvEDMa1Ss9FFgYZuLuMOELu3tskdUrUGzMTSNxBlxCMxrRsuSRIAoPEntrKizh
+EpNWIh85Ok1kGe7mCXbyO/z3Iqyy3HB7qfdErsTRdcWMJFdwYCZzIN8edfV7m8rX
+iFzUCn9apIIh0MSSB8GLmE1V7xPdYCvMEvZz8DVhMaObRhN+pMK7Wuv38w9IAK6b
+y7Au+1JrYOW07CYf5cOUaJsBIcunyPuTlyt+5zmW7Oh7eTtiX9xyf+dXeN2lLeww
+nltdBfBGAxNxAdmWfukKN4h+JvpIlCJqF9CzBJ2YCyqKgK8lWOGY2msEAZdOweD5
+mi7c0p1RKJb2brZlg3fMPh0fqorBPezOPKi7U3E+4JMCbgpJiu6H8fS9GMbWspge
+8gXuW4mH3pQPY5b0WFMF5jPYCd0Bk5cHl/E1NrAQwOVDNsu/U3Xkt9nm963NOcbs
+WOI094Lt5PQJU8gnI3nC7aZuM12yKBqg0W+/FQCr6CfI3Bm+xq6hNuKdrUTZ+4wo
+IWLOMg/XYYLgmozKaE1UTXKMBOJLg1i5rxmCvwaUz7sQ6gPloNLkQpOqmHpkwoYc
+b95K6YaSmWu5Ag0EXxEMVAEQAKPc3X8q3rTlLJJ3aWHT2oH/IMrkp+oAHiEEytpX
+lrRxnQl5YTYTEmGRBni4Z8jif8ntohqFuzEsMKx2wyws6BlKsVCyTEGYXW6wgOB2
+/oqQ9jF64xhmpbiG6ep3psZ+nsxV9Utb+eqJH9f9Nz2I3TunKXeP2BN2I/3fC2iD
+X0ft9AJfl1hMTM9TgaCFaNm4Z1pdKRbcjE/EECzyBKpj/0HonB6k5W9/TUXUYEXH
+iDq1trV1zbHq6ZnRmBmLaT4eBaceEMPgvdgdjx8WAYhJUOrlRiul5SvlfBsT+4XS
+a6ZqAqD/206qweFDEPfU6sC0go/tVI/zgvT2CX16iNXH+8WJ+Z7xRXhDxbrhmNYM
+vJRyQ+ZVAH1DQuXfblTqfOSyi8tbhZqro8v76himQ8hcPzKv4YVTW2poBe/MSFwf
+0Xm91cs5q8mh/UlG9Gz3/SxEUQWGoOkvkD1X87tc+ScM8K62CsPXx2ZqYLK36Upq
+aNdNX+Uni8pIEknneNkag7b/XaaGl6nfvTWh2DCdXAWJJ9S4FMFIlRgyUq+cL/pu
+gjiPUNdWAJYN76Nmpg5iMC4s7nZ8juSmzXbnphute/SViVEBHB3PU/jdzoCCR/XJ
+T8bxiVqfz79vukIyfZySr2qq6OA8sS6rJPiNgN4ki0dH8OGWrss58gqcydJav2Ac
+1Vu1ABEBAAGJAjYEGAEIACAWIQQnxQ5/WQlH1yc6dB6FGUwIQhmAyQUCXxEMVAIb
+DAAKCRCFGUwIQhmAybgxEACLZucejgXVsAzpOoSlKNi+71cg5hhR0EaPqlgJeYp8
+SeBP9otn7z2qfZTOdYBVhsbZJnoH+M/qMlgfSjZMc+SsyKNsrqcZH8VNFOEGcGG1
+kanK3V81/eBC2I4jdZ/BfFUaJuARiiH/9kn/UX1LYh/aYmFu1EF/CZrkB6JBKsqg
+JHZL345zAvzJUxZ+9rM2FMSkhrDNNmWnGutfAa1e8oJyvVWTJEkJhz+60iIU83Wb
+99tp0F372+CyMg8EYh2KT9eIwLZOuhUXVDkjKO5WIQ0vN+feMMclx9BBre5il4GW
+552WBMgNEhYGwYdMTnPB6r3H+k6KeJxv5MGJtmMe+iblKyGantOXtVMjog3vmXDp
+5TaG5FUy5IQJWPynRsMxSML6qyZwKr+OtRGvgz/QTZMZhzj0OKrWhpPSQZEPSlIX
+9ZqM2vu9/jdT5jzrqkNShs4jXBImoRFIMu0IT9RrrFx3W1iUlcDilsuWZPH8vGX5
+704Q1Wqt7WQ1L6Fqy2UJjVamelPedIK42kEWdir/jSW4JWvffN6UA7E0LtcGFs67
+DJx55D+5IvTLv0V8C+/pfEGb8T2A6AoftED97eQvWAJQZyFikeYr+HaHFFuwc9wG
+jUNSbfkPObp54cTsdQlw3GVaDmKm5a3a5YZ7EGskjO2IrIm3jDNidzA1Y7mINDy5
+Y7kBDQRfEQ3IAQgA2EXKY6Oke+xrkLWw2/nL6aeAp3qo/Gn8MRy8XXRkgT91aHP6
+q8KHF2JoiGrb7xWzm3iRHbcMJbS+NnGWrH+cGHzDynReoPyO0SGVCDBSLKIFJdnk
+l08tHRkp8iMOdDomF+e8Uq5SSTJq9is3b4/6BO5ycBwETYJAs6bEtkOcSY9i0EQI
+T53LxfhVLbsTQbdGhNpN+Ao9Q3Z3TXXNZX96e0JgJMv6FJGL2v8UGF1oiSz9Rhpv
+198/n5TGcEd+hZ6KNBP7lGmHxivlDZpzO+FoKTeePdVLHB6d4zRUmEipE2+QVBo3
+XGZmVgDEs31TwaO4vDecz2tUQAY9TUEX+REpmQARAQABiQI2BBgBCAAgFiEEJ8UO
+f1kJR9cnOnQehRlMCEIZgMkFAl8RDcgCGyAACgkQhRlMCEIZgMlGqw/+Mm7ty3eH
+mS/HurpKCF0B7ds1jnUOfQzf3k9KRUDrIdpSpg6DTIJ5CAkk2NiN5qW6UfISvtPO
+qzxne1llBrbrfMLqXYH/9Pmuk/ObvLVQu2ha5vQhEsy5XWohH6PzqtP/tMuP2oiq
+M2qPH0U3cNsM8rYLMpEl07n9+q5yggaOUnoyRJH6y5xZISGi34+X+WMOmo1ZFP2r
+suvTl/K84ov7TPQdENSFTPjLuo6oTbr9VX/NjXXiYPbmyBiV2fUaHRB98wzhL7SG
+bqwmWXLcQQjlD4RN2E8H4JajuWFnlTHhnd8Sc6iYYg4ckRzaMlpxEs69YPkiZfN+
+jSEe7S33ELwP6Hu4xwFs8I88t7YoVHnIR/S4pS1MxCkDzwSrEq/b3jynFVlhbYKZ
+ZwbPXb1kh0T5frErOScNyUvqvQn/Pg8pgLDOLz5bXO87pzhWe9rk8hiCVeMx5doF
+dLWvorwxvHL7MdsVjR0Z/RG+VslQI2leJDzroB+f6Fr+SPxAq5pvD/JtVMzJq7+G
+OTIk4hqDZbEVQCSgiRjNLw8nMgrpkPDk5pRTuPpMR48OhP35azMq9GvzNpTXxKQs
+/e8u4XkwjKviGmUrgiOAyBlUMWsF9IBRKm5B/STohCT4ZeU4VJdlzB7JHwrr7CJd
+fqxMjx0bDHkiDsZTgmEDJnz6+jK0DmvsFmU=
+=wC+d
+-----END PGP PUBLIC KEY BLOCK-----
diff --git a/requirements-dev.txt b/requirements-dev.txt
new file mode 100644
index 000000000..066b192b8
--- /dev/null
+++ b/requirements-dev.txt
@@ -0,0 +1,8 @@
+-r requirements.txt
+-r test-requirements.txt
+
+# For additional local testing/linting - to be added elsewhere eventually.
+ruff >=0.8
+shellcheck
+pytest-icdiff
+# pytest-profiling
diff --git a/requirements.txt b/requirements.txt
index 19fd5a087..61d8403b0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
-GitPython
-gitdb>=0.6.2
+gitdb>=4.0.1,<5
+typing-extensions>=3.10.0.2;python_version<"3.10"
diff --git a/setup.py b/setup.py
index d35301ae8..a7b1eab00 100755
--- a/setup.py
+++ b/setup.py
@@ -1,31 +1,30 @@
 #!/usr/bin/env python
-from __future__ import print_function
-try:
-    from setuptools import setup, find_packages
-except ImportError:
-    from ez_setup import use_setuptools
-    use_setuptools()
-    from setuptools import setup, find_packages
 
-from distutils.command.build_py import build_py as _build_py
-from setuptools.command.sdist import sdist as _sdist
 import os
+from pathlib import Path
 import sys
-from os import path
+from typing import Sequence
+
+from setuptools import setup, find_packages
+from setuptools.command.build_py import build_py as _build_py
+from setuptools.command.sdist import sdist as _sdist
 
-v = open(path.join(path.dirname(__file__), 'VERSION'))
-VERSION = v.readline().strip()
-v.close()
 
-with open('requirements.txt') as reqs_file:
-    requirements = reqs_file.read().splitlines()
+def _read_content(path: str) -> str:
+    return (Path(__file__).parent / path).read_text(encoding="utf-8")
 
 
-class build_py(_build_py):
+version = _read_content("VERSION").strip()
+requirements = _read_content("requirements.txt").splitlines()
+test_requirements = _read_content("test-requirements.txt").splitlines()
+doc_requirements = _read_content("doc/requirements.txt").splitlines()
+long_description = _read_content("README.md")
 
-    def run(self):
-        init = path.join(self.build_lib, 'git', '__init__.py')
-        if path.exists(init):
+
+class build_py(_build_py):
+    def run(self) -> None:
+        init = os.path.join(self.build_lib, "git", "__init__.py")
+        if os.path.exists(init):
             os.unlink(init)
         _build_py.run(self)
         _stamp_version(init)
@@ -33,64 +32,57 @@ def run(self):
 
 
 class sdist(_sdist):
-
-    def make_release_tree(self, base_dir, files):
+    def make_release_tree(self, base_dir: str, files: Sequence) -> None:
         _sdist.make_release_tree(self, base_dir, files)
-        orig = path.join('git', '__init__.py')
-        assert path.exists(orig), orig
-        dest = path.join(base_dir, orig)
-        if hasattr(os, 'link') and path.exists(dest):
+        orig = os.path.join("git", "__init__.py")
+        assert os.path.exists(orig), orig
+        dest = os.path.join(base_dir, orig)
+        if hasattr(os, "link") and os.path.exists(dest):
             os.unlink(dest)
         self.copy_file(orig, dest)
         _stamp_version(dest)
 
 
-def _stamp_version(filename):
-    found, out = False, list()
+def _stamp_version(filename: str) -> None:
+    found, out = False, []
     try:
-        f = open(filename, 'r')
-    except (IOError, OSError):
+        with open(filename) as f:
+            for line in f:
+                if "__version__ =" in line:
+                    line = line.replace('"git"', "'%s'" % version)
+                    found = True
+                out.append(line)
+    except OSError:
         print("Couldn't find file %s to stamp version" % filename, file=sys.stderr)
-        return
-    # END handle error, usually happens during binary builds
-    for line in f:
-        if '__version__ =' in line:
-            line = line.replace("'git'", "'%s'" % VERSION)
-            found = True
-        out.append(line)
-    f.close()
 
     if found:
-        f = open(filename, 'w')
-        f.writelines(out)
-        f.close()
+        with open(filename, "w") as f:
+            f.writelines(out)
     else:
         print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr)
 
-install_requires = ['gitdb >= 0.6.4']
-if sys.version_info[:2] < (2, 7):
-    install_requires.append('ordereddict')
-# end
 
 setup(
     name="GitPython",
-    cmdclass={'build_py': build_py, 'sdist': sdist},
-    version=VERSION,
-    description="Python Git Library",
+    cmdclass={"build_py": build_py, "sdist": sdist},
+    version=version,
+    description="GitPython is a Python library used to interact with Git repositories",
     author="Sebastian Thiel, Michael Trier",
     author_email="byronimo@gmail.com, mtrier@gmail.com",
+    license="BSD-3-Clause",
     url="https://github.com/gitpython-developers/GitPython",
-    packages=find_packages('.'),
-    py_modules=['git.' + f[:-3] for f in os.listdir('./git') if f.endswith('.py')],
-    package_data={'git.test': ['fixtures/*']},
-    package_dir={'git': 'git'},
-    license="BSD License",
-    requires=['gitdb (>=0.6.4)'],
-    install_requires=install_requires,
-    test_requirements=['mock', 'nose'] + install_requires,
+    packages=find_packages(exclude=["test", "test.*"]),
+    include_package_data=True,
+    package_dir={"git": "git"},
+    python_requires=">=3.7",
+    install_requires=requirements,
+    extras_require={
+        "test": test_requirements,
+        "doc": doc_requirements,
+    },
     zip_safe=False,
-    long_description="""\
-GitPython is a python library used to interact with Git repositories""",
+    long_description=long_description,
+    long_description_content_type="text/markdown",
     classifiers=[
         # Picked from
         #   http://pypi.python.org/pypi?:action=list_classifiers
@@ -103,17 +95,18 @@ def _stamp_version(filename):
         # "Development Status :: 7 - Inactive",
         "Environment :: Console",
         "Intended Audience :: Developers",
-        "License :: OSI Approved :: BSD License",
         "Operating System :: OS Independent",
         "Operating System :: POSIX",
         "Operating System :: Microsoft :: Windows",
         "Operating System :: MacOS :: MacOS X",
+        "Typing :: Typed",
         "Programming Language :: Python",
-        "Programming Language :: Python :: 2",
-        "Programming Language :: Python :: 2.6",
-        "Programming Language :: Python :: 2.7",
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.3",
-        "Programming Language :: Python :: 3.4",
-    ]
+        "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
+        "Programming Language :: Python :: 3.9",
+        "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
+        "Programming Language :: Python :: 3.12",
+    ],
 )
diff --git a/test-requirements.txt b/test-requirements.txt
index d9425c034..75e9e81fa 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,4 +1,11 @@
-coverage
-flake8
-nose
-mock
+coverage[toml]
+ddt >= 1.1.1, != 1.4.3
+mock ; python_version < "3.8"
+mypy
+pre-commit
+pytest >= 7.3.1
+pytest-cov
+pytest-instafail
+pytest-mock
+pytest-sugar
+typing-extensions ; python_version < "3.11"
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644
index 000000000..fbaebcd3b
--- /dev/null
+++ b/test/__init__.py
@@ -0,0 +1,4 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
diff --git a/test/deprecation/__init__.py b/test/deprecation/__init__.py
new file mode 100644
index 000000000..fec3126d2
--- /dev/null
+++ b/test/deprecation/__init__.py
@@ -0,0 +1,19 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Tests of deprecation warnings and possible related attribute bugs.
+
+Most deprecation warnings are "basic" in the sense that there is no special complexity
+to consider, in introducing them. However, to issue deprecation warnings on mere
+attribute access can involve adding new dynamic behavior. This can lead to subtle bugs
+or less useful dynamic metadata. It can also weaken static typing, as happens if a type
+checker sees a method like ``__getattr__`` in a module or class whose attributes it did
+not already judge to be dynamic. This test.deprecation submodule covers all three cases:
+the basic cases, subtle dynamic behavior, and subtle static type checking issues.
+
+Static type checking is "tested" by a combination of code that should not be treated as
+a type error but would be in the presence of particular bugs, and code that *should* be
+treated as a type error and is accordingly marked ``# type: ignore[REASON]`` (for
+specific ``REASON``. The latter will only produce mypy errors when the expectation is
+not met if it is configured with ``warn_unused_ignores = true``.
+"""
diff --git a/test/deprecation/lib.py b/test/deprecation/lib.py
new file mode 100644
index 000000000..9fe623a3a
--- /dev/null
+++ b/test/deprecation/lib.py
@@ -0,0 +1,27 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Support library for deprecation tests."""
+
+__all__ = ["assert_no_deprecation_warning", "suppress_deprecation_warning"]
+
+import contextlib
+import warnings
+
+from typing import Generator
+
+
+@contextlib.contextmanager
+def assert_no_deprecation_warning() -> Generator[None, None, None]:
+    """Context manager to assert that code does not issue any deprecation warnings."""
+    with warnings.catch_warnings():
+        warnings.simplefilter("error", DeprecationWarning)
+        warnings.simplefilter("error", PendingDeprecationWarning)
+        yield
+
+
+@contextlib.contextmanager
+def suppress_deprecation_warning() -> Generator[None, None, None]:
+    with warnings.catch_warnings():
+        warnings.simplefilter("ignore", DeprecationWarning)
+        yield
diff --git a/test/deprecation/test_basic.py b/test/deprecation/test_basic.py
new file mode 100644
index 000000000..3bf0287c7
--- /dev/null
+++ b/test/deprecation/test_basic.py
@@ -0,0 +1,137 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Tests of assorted deprecation warnings when there are no extra subtleties to check.
+
+This tests deprecation warnings where all that needs be verified is that a deprecated
+property, function, or class issues a DeprecationWarning when used and, if applicable,
+that recommended alternatives do not issue the warning.
+
+This is in contrast to other modules within test.deprecation, which test warnings where
+there is a risk of breaking other runtime behavior, or of breaking static type checking
+or making it less useful, by introducing the warning or in plausible future changes to
+how the warning is implemented. That happens when it is necessary to customize attribute
+access on a module or class, in a way it was not customized before, to issue a warning.
+It is inapplicable to the deprecations whose warnings are tested in this module.
+"""
+
+import pytest
+
+from git.diff import NULL_TREE
+from git.objects.util import Traversable
+from git.repo import Repo
+from git.util import Iterable as _Iterable, IterableObj
+
+from .lib import assert_no_deprecation_warning
+
+# typing -----------------------------------------------------------------
+
+from typing import Generator, TYPE_CHECKING
+
+if TYPE_CHECKING:
+    from pathlib import Path
+
+    from git.diff import Diff, DiffIndex
+    from git.objects.commit import Commit
+
+# ------------------------------------------------------------------------
+
+
+@pytest.fixture
+def commit(tmp_path: "Path") -> Generator["Commit", None, None]:
+    """Fixture to supply a one-commit repo's commit, enough for deprecation tests."""
+    (tmp_path / "a.txt").write_text("hello\n", encoding="utf-8")
+    repo = Repo.init(tmp_path)
+    repo.index.add(["a.txt"])
+    yield repo.index.commit("Initial commit")
+    repo.close()
+
+
+@pytest.fixture
+def diff(commit: "Commit") -> Generator["Diff", None, None]:
+    """Fixture to supply a single-file diff."""
+    (diff,) = commit.diff(NULL_TREE)  # Exactly one file in the diff.
+    yield diff
+
+
+@pytest.fixture
+def diffs(commit: "Commit") -> Generator["DiffIndex", None, None]:
+    """Fixture to supply a DiffIndex."""
+    yield commit.diff(NULL_TREE)
+
+
+def test_diff_renamed_warns(diff: "Diff") -> None:
+    """The deprecated Diff.renamed property issues a deprecation warning."""
+    with pytest.deprecated_call():
+        diff.renamed
+
+
+def test_diff_renamed_file_does_not_warn(diff: "Diff") -> None:
+    """The preferred Diff.renamed_file property issues no deprecation warning."""
+    with assert_no_deprecation_warning():
+        diff.renamed_file
+
+
+def test_commit_trailers_warns(commit: "Commit") -> None:
+    """The deprecated Commit.trailers property issues a deprecation warning."""
+    with pytest.deprecated_call():
+        commit.trailers
+
+
+def test_commit_trailers_list_does_not_warn(commit: "Commit") -> None:
+    """The nondeprecated Commit.trailers_list property issues no deprecation warning."""
+    with assert_no_deprecation_warning():
+        commit.trailers_list
+
+
+def test_commit_trailers_dict_does_not_warn(commit: "Commit") -> None:
+    """The nondeprecated Commit.trailers_dict property issues no deprecation warning."""
+    with assert_no_deprecation_warning():
+        commit.trailers_dict
+
+
+def test_traverse_list_traverse_in_base_class_warns(commit: "Commit") -> None:
+    """Traversable.list_traverse's base implementation issues a deprecation warning."""
+    with pytest.deprecated_call():
+        Traversable.list_traverse(commit)
+
+
+def test_traversable_list_traverse_override_does_not_warn(commit: "Commit") -> None:
+    """Calling list_traverse on concrete subclasses is not deprecated, does not warn."""
+    with assert_no_deprecation_warning():
+        commit.list_traverse()
+
+
+def test_traverse_traverse_in_base_class_warns(commit: "Commit") -> None:
+    """Traversable.traverse's base implementation issues a deprecation warning."""
+    with pytest.deprecated_call():
+        Traversable.traverse(commit)
+
+
+def test_traverse_traverse_override_does_not_warn(commit: "Commit") -> None:
+    """Calling traverse on concrete subclasses is not deprecated, does not warn."""
+    with assert_no_deprecation_warning():
+        commit.traverse()
+
+
+def test_iterable_inheriting_warns() -> None:
+    """Subclassing the deprecated git.util.Iterable issues a deprecation warning."""
+    with pytest.deprecated_call():
+
+        class Derived(_Iterable):
+            pass
+
+
+def test_iterable_obj_inheriting_does_not_warn() -> None:
+    """Subclassing git.util.IterableObj is not deprecated, does not warn."""
+    with assert_no_deprecation_warning():
+
+        class Derived(IterableObj):
+            pass
+
+
+def test_diff_iter_change_type(diffs: "DiffIndex") -> None:
+    """The internal DiffIndex.iter_change_type function issues no deprecation warning."""
+    with assert_no_deprecation_warning():
+        for change_type in diffs.change_type:
+            [*diffs.iter_change_type(change_type=change_type)]
diff --git a/test/deprecation/test_cmd_git.py b/test/deprecation/test_cmd_git.py
new file mode 100644
index 000000000..e44490273
--- /dev/null
+++ b/test/deprecation/test_cmd_git.py
@@ -0,0 +1,391 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Tests for dynamic and static characteristics of Git class and instance attributes.
+
+Currently this all relates to the deprecated :attr:`Git.USE_SHELL` class attribute,
+which can also be accessed through instances. Some tests directly verify its behavior,
+including deprecation warnings, while others verify that other aspects of attribute
+access are not inadvertently broken by mechanisms introduced to issue the warnings.
+
+A note on multiprocessing
+=========================
+
+Because USE_SHELL has no instance state, this module does not include tests of pickling
+and multiprocessing:
+
+- Just as with a simple class attribute, when a class attribute with custom logic is set
+  to another value, even before a worker process is created that uses the class, the
+  worker process may see either the initial or new value, depending on the process start
+  method. With "fork", changes are preserved. With "spawn" or "forkserver", re-importing
+  the modules causes initial values to be set. Then the value in the parent at the time
+  it dispatches the task is only set in the children if the parent has the task set it,
+  or if it is set as a side effect of importing needed modules, or of unpickling objects
+  passed to the child (for example, if it is set in a top-level statement of the module
+  that defines the function submitted for the child worker process to call).
+
+- When an attribute gains new logic provided by a property or custom descriptor, and the
+  attribute involves instance-level state, incomplete or corrupted pickling can break
+  multiprocessing. (For example, when an instance attribute is reimplemented using a
+  descriptor that stores data in a global WeakKeyDictionary, pickled instances should be
+  tested to ensure they are still working correctly.) But nothing like that applies
+  here, because instance state is not involved. Although the situation is inherently
+  complex as described above, it is independent of the attribute implementation.
+
+- That USE_SHELL cannot be set on instances, and that when retrieved on instances it
+  always gives the same value as on the class, is covered in the tests here.
+
+A note on metaclass conflicts
+=============================
+
+The most important DeprecationWarning is for code like ``Git.USE_SHELL = True``, which
+is a security risk. But this warning may not be possible to implement without a custom
+metaclass. This is because a descriptor in a class can customize all forms of attribute
+access on its instances, but can only customize getting an attribute on the class.
+Retrieving a descriptor from a class calls its ``__get__`` method (if defined), but
+replacing or deleting it does not call its ``__set__`` or ``__delete__`` methods.
+
+Adding a metaclass is a potentially breaking change. This is because derived classes
+that use an unrelated metaclass, whether directly or by inheriting from a class such as
+abc.ABC that uses one, will raise TypeError when defined. These would have to be
+modified to use a newly introduced metaclass that is a lower bound of both. Subclasses
+remain unbroken in the far more typical case that they use no custom metaclass.
+
+The tests in this module do not establish whether the danger of setting Git.USE_SHELL to
+True is high enough, and applications of deriving from Git and using an unrelated custom
+metaclass marginal enough, to justify introducing a metaclass to issue the warnings.
+"""
+
+import logging
+import sys
+from typing import Generator
+import unittest.mock
+
+if sys.version_info >= (3, 11):
+    from typing import assert_type
+else:
+    from typing_extensions import assert_type
+
+import pytest
+from pytest import WarningsRecorder
+
+from git.cmd import Git, GitMeta
+
+from .lib import assert_no_deprecation_warning, suppress_deprecation_warning
+
+_USE_SHELL_DEPRECATED_FRAGMENT = "Git.USE_SHELL is deprecated"
+"""Text contained in all USE_SHELL deprecation warnings, and starting most of them."""
+
+_USE_SHELL_DANGEROUS_FRAGMENT = "Setting Git.USE_SHELL to True is unsafe and insecure"
+"""Beginning text of USE_SHELL deprecation warnings when USE_SHELL is set True."""
+
+_logger = logging.getLogger(__name__)
+
+
+@pytest.fixture
+def restore_use_shell_state() -> Generator[None, None, None]:
+    """Fixture to attempt to restore state associated with the USE_SHELL attribute.
+
+    This is used to decrease the likelihood of state changes leaking out and affecting
+    other tests. But the goal is not to assert implementation details of USE_SHELL.
+
+    This covers two of the common implementation strategies, for convenience in testing
+    both. USE_SHELL could be implemented in the metaclass:
+
+    * With a separate _USE_SHELL backing attribute. If using a property or other
+      descriptor, this is the natural way to do it, but custom __getattribute__ and
+      __setattr__ logic, if it does more than adding warnings, may also use that.
+    * Like a simple attribute, using USE_SHELL itself, stored as usual in the class
+      dictionary, with custom __getattribute__/__setattr__ logic only to warn.
+
+    This tries to save private state, tries to save the public attribute value, yields
+    to the test case, tries to restore the public attribute value, then tries to restore
+    private state. The idea is that if the getting or setting logic is wrong in the code
+    under test, the state will still most likely be reset successfully.
+    """
+    no_value = object()
+
+    # Try to save the original private state.
+    try:
+        old_private_value = Git._USE_SHELL  # type: ignore[attr-defined]
+    except AttributeError:
+        separate_backing_attribute = False
+        try:
+            old_private_value = type.__getattribute__(Git, "USE_SHELL")
+        except AttributeError:
+            old_private_value = no_value
+            _logger.error("Cannot retrieve old private _USE_SHELL or USE_SHELL value")
+    else:
+        separate_backing_attribute = True
+
+    try:
+        # Try to save the original public value. Rather than attempt to restore a state
+        # where the attribute is not set, if we cannot do this we allow AttributeError
+        # to propagate out of the fixture, erroring the test case before its code runs.
+        with suppress_deprecation_warning():
+            old_public_value = Git.USE_SHELL
+
+        # This doesn't have its own try-finally because pytest catches exceptions raised
+        # during the yield. (The outer try-finally catches exceptions in this fixture.)
+        yield
+
+        # Try to restore the original public value.
+        with suppress_deprecation_warning():
+            Git.USE_SHELL = old_public_value
+    finally:
+        # Try to restore the original private state.
+        if separate_backing_attribute:
+            Git._USE_SHELL = old_private_value  # type: ignore[attr-defined]
+        elif old_private_value is not no_value:
+            type.__setattr__(Git, "USE_SHELL", old_private_value)
+
+
+def test_cannot_access_undefined_on_git_class() -> None:
+    """Accessing a bogus attribute on the Git class remains a dynamic and static error.
+
+    This differs from Git instances, where most attribute names will dynamically
+    synthesize a "bound method" that runs a git subcommand when called.
+    """
+    with pytest.raises(AttributeError):
+        Git.foo  # type: ignore[attr-defined]
+
+
+def test_get_use_shell_on_class_default() -> None:
+    """USE_SHELL can be read as a class attribute, defaulting to False and warning."""
+    with pytest.deprecated_call() as ctx:
+        use_shell = Git.USE_SHELL
+
+    (message,) = [str(entry.message) for entry in ctx]  # Exactly one warning.
+    assert message.startswith(_USE_SHELL_DEPRECATED_FRAGMENT)
+
+    assert_type(use_shell, bool)
+
+    # This comes after the static assertion, just in case it would affect the inference.
+    assert not use_shell
+
+
+def test_get_use_shell_on_instance_default() -> None:
+    """USE_SHELL can be read as an instance attribute, defaulting to False and warning.
+
+    This is the same as test_get_use_shell_on_class_default above, but for instances.
+    The test is repeated, instead of using parametrization, for clearer static analysis.
+    """
+    instance = Git()
+
+    with pytest.deprecated_call() as ctx:
+        use_shell = instance.USE_SHELL
+
+    (message,) = [str(entry.message) for entry in ctx]  # Exactly one warning.
+    assert message.startswith(_USE_SHELL_DEPRECATED_FRAGMENT)
+
+    assert_type(use_shell, bool)
+
+    # This comes after the static assertion, just in case it would affect the inference.
+    assert not use_shell
+
+
+def _assert_use_shell_full_results(
+    set_value: bool,
+    reset_value: bool,
+    setting: WarningsRecorder,
+    checking: WarningsRecorder,
+    resetting: WarningsRecorder,
+    rechecking: WarningsRecorder,
+) -> None:
+    # The attribute should take on the values set to it.
+    assert set_value is True
+    assert reset_value is False
+
+    # Each access should warn exactly once.
+    (set_message,) = [str(entry.message) for entry in setting]
+    (check_message,) = [str(entry.message) for entry in checking]
+    (reset_message,) = [str(entry.message) for entry in resetting]
+    (recheck_message,) = [str(entry.message) for entry in rechecking]
+
+    # Setting it to True should produce the special warning for that.
+    assert _USE_SHELL_DEPRECATED_FRAGMENT in set_message
+    assert set_message.startswith(_USE_SHELL_DANGEROUS_FRAGMENT)
+
+    # All other operations should produce a usual warning.
+    assert check_message.startswith(_USE_SHELL_DEPRECATED_FRAGMENT)
+    assert reset_message.startswith(_USE_SHELL_DEPRECATED_FRAGMENT)
+    assert recheck_message.startswith(_USE_SHELL_DEPRECATED_FRAGMENT)
+
+
+def test_use_shell_set_and_get_on_class(restore_use_shell_state: None) -> None:
+    """USE_SHELL can be set and re-read as a class attribute, always warning."""
+    with pytest.deprecated_call() as setting:
+        Git.USE_SHELL = True
+    with pytest.deprecated_call() as checking:
+        set_value = Git.USE_SHELL
+    with pytest.deprecated_call() as resetting:
+        Git.USE_SHELL = False
+    with pytest.deprecated_call() as rechecking:
+        reset_value = Git.USE_SHELL
+
+    _assert_use_shell_full_results(
+        set_value,
+        reset_value,
+        setting,
+        checking,
+        resetting,
+        rechecking,
+    )
+
+
+def test_use_shell_set_on_class_get_on_instance(restore_use_shell_state: None) -> None:
+    """USE_SHELL can be set on the class and read on an instance, always warning.
+
+    This is like test_use_shell_set_and_get_on_class but it performs reads on an
+    instance. There is some redundancy here in assertions about warnings when the
+    attribute is set, but it is a separate test so that any bugs where a read on the
+    class (or an instance) is needed first before a read on an instance (or the class)
+    are detected.
+    """
+    instance = Git()
+
+    with pytest.deprecated_call() as setting:
+        Git.USE_SHELL = True
+    with pytest.deprecated_call() as checking:
+        set_value = instance.USE_SHELL
+    with pytest.deprecated_call() as resetting:
+        Git.USE_SHELL = False
+    with pytest.deprecated_call() as rechecking:
+        reset_value = instance.USE_SHELL
+
+    _assert_use_shell_full_results(
+        set_value,
+        reset_value,
+        setting,
+        checking,
+        resetting,
+        rechecking,
+    )
+
+
+@pytest.mark.parametrize("value", [False, True])
+def test_use_shell_cannot_set_on_instance(
+    value: bool,
+    restore_use_shell_state: None,  # In case of a bug where it does set USE_SHELL.
+) -> None:
+    instance = Git()
+    with pytest.raises(AttributeError):
+        instance.USE_SHELL = value  # type: ignore[misc]  # Name not in __slots__.
+
+
+@pytest.mark.filterwarnings("ignore::DeprecationWarning")
+@pytest.mark.parametrize("original_value", [False, True])
+def test_use_shell_is_mock_patchable_on_class_as_object_attribute(
+    original_value: bool,
+    restore_use_shell_state: None,
+) -> None:
+    """Asymmetric patching looking up USE_SHELL in ``__dict__`` doesn't corrupt state.
+
+    Code using GitPython may temporarily set Git.USE_SHELL to a different value. Ideally
+    it does not use unittest.mock.patch to do so, because that makes subtle assumptions
+    about the relationship between attributes and dictionaries. If the attribute can be
+    retrieved from the ``__dict__`` rather than directly, that value is assumed the
+    correct one to restore, even by a normal setattr.
+
+    The effect is that some ways of simulating a class attribute with added behavior can
+    cause a descriptor, such as a property, to be set as the value of its own backing
+    attribute during unpatching; then subsequent reads raise RecursionError. This
+    happens if both (a) setting it on the class is customized in a metaclass and (b)
+    getting it on instances is customized with a descriptor (such as a property) in the
+    class itself.
+
+    Although ideally code outside GitPython would not rely on being able to patch
+    Git.USE_SHELL with unittest.mock.patch, the technique is widespread. Thus, USE_SHELL
+    should be implemented in some way compatible with it. This test checks for that.
+    """
+    Git.USE_SHELL = original_value
+    if Git.USE_SHELL is not original_value:
+        raise RuntimeError("Can't set up the test")
+    new_value = not original_value
+
+    with unittest.mock.patch.object(Git, "USE_SHELL", new_value):
+        assert Git.USE_SHELL is new_value
+
+    assert Git.USE_SHELL is original_value
+
+
+def test_execute_without_shell_arg_does_not_warn() -> None:
+    """No deprecation warning is issued from operations implemented using Git.execute().
+
+    When no ``shell`` argument is passed to Git.execute, which is when the value of
+    USE_SHELL is to be used, the way Git.execute itself accesses USE_SHELL does not
+    issue a deprecation warning.
+    """
+    with assert_no_deprecation_warning():
+        Git().version()
+
+
+_EXPECTED_DIR_SUBSET = {
+    "cat_file_all",
+    "cat_file_header",
+    "GIT_PYTHON_TRACE",
+    "USE_SHELL",  # The attribute we get deprecation warnings for.
+    "GIT_PYTHON_GIT_EXECUTABLE",
+    "refresh",
+    "is_cygwin",
+    "polish_url",
+    "check_unsafe_protocols",
+    "check_unsafe_options",
+    "AutoInterrupt",
+    "CatFileContentStream",
+    "__init__",
+    "__getattr__",
+    "set_persistent_git_options",
+    "working_dir",
+    "version_info",
+    "execute",
+    "environment",
+    "update_environment",
+    "custom_environment",
+    "transform_kwarg",
+    "transform_kwargs",
+    "__call__",
+    "_call_process",  # Not currently considered public, but unlikely to change.
+    "get_object_header",
+    "get_object_data",
+    "stream_object_data",
+    "clear_cache",
+}
+"""Some stable attributes dir() should include on the Git class and its instances.
+
+This is intentionally incomplete, but includes substantial variety. Most importantly, it
+includes both ``USE_SHELL`` and a wide sampling of other attributes.
+"""
+
+
+def test_class_dir() -> None:
+    """dir() on the Git class includes its statically known attributes.
+
+    This tests that the mechanism that adds dynamic behavior to USE_SHELL accesses so
+    that all accesses issue warnings does not break dir() for the class, neither for
+    USE_SHELL nor for ordinary (non-deprecated) attributes.
+    """
+    actual = set(dir(Git))
+    assert _EXPECTED_DIR_SUBSET <= actual
+
+
+def test_instance_dir() -> None:
+    """dir() on Git objects includes its statically known attributes.
+
+    This is like test_class_dir, but for Git instances rather than the class itself.
+    """
+    instance = Git()
+    actual = set(dir(instance))
+    assert _EXPECTED_DIR_SUBSET <= actual
+
+
+def test_metaclass_alias() -> None:
+    """GitMeta aliases Git's metaclass, whether that is type or a custom metaclass."""
+
+    def accept_metaclass_instance(cls: GitMeta) -> None:
+        """Check that cls is statically recognizable as an instance of GitMeta."""
+
+    accept_metaclass_instance(Git)  # assert_type would expect Type[Git], not GitMeta.
+
+    # This comes after the static check, just in case it would affect the inference.
+    assert type(Git) is GitMeta
diff --git a/test/deprecation/test_compat.py b/test/deprecation/test_compat.py
new file mode 100644
index 000000000..2d7805e61
--- /dev/null
+++ b/test/deprecation/test_compat.py
@@ -0,0 +1,84 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Tests for dynamic and static characteristics of git.compat module attributes.
+
+These tests verify that the is_<platform> attributes are available, and are even listed
+in the output of dir(), but issue warnings, and that bogus (misspelled or unrecognized)
+attribute access is still an error both at runtime and with mypy. This is similar to
+some of the tests in test_toplevel, but the situation being tested here is simpler
+because it does not involve unintuitive module aliasing or import behavior. So this only
+tests attribute access, not "from" imports (whose behavior can be intuitively inferred).
+"""
+
+import os
+import sys
+
+if sys.version_info >= (3, 11):
+    from typing import assert_type
+else:
+    from typing_extensions import assert_type
+
+import pytest
+
+import git.compat
+
+_MESSAGE_LEADER = "{} and other is_<platform> aliases are deprecated."
+"""Form taken by the beginning of the warnings issued for is_<platform> access."""
+
+
+def test_cannot_access_undefined() -> None:
+    """Accessing a bogus attribute in git.compat remains a dynamic and static error."""
+    with pytest.raises(AttributeError):
+        git.compat.foo  # type: ignore[attr-defined]
+
+
+def test_is_platform() -> None:
+    """The is_<platform> attributes work, warn, and mypy accepts code accessing them."""
+    fully_qualified_names = [
+        "git.compat.is_win",
+        "git.compat.is_posix",
+        "git.compat.is_darwin",
+    ]
+
+    with pytest.deprecated_call() as ctx:
+        is_win = git.compat.is_win
+        is_posix = git.compat.is_posix
+        is_darwin = git.compat.is_darwin
+
+    assert_type(is_win, bool)
+    assert_type(is_posix, bool)
+    assert_type(is_darwin, bool)
+
+    messages = [str(entry.message) for entry in ctx]
+    assert len(messages) == 3
+
+    for fullname, message in zip(fully_qualified_names, messages):
+        assert message.startswith(_MESSAGE_LEADER.format(fullname))
+
+    # These assertions exactly reproduce the expressions in the code under test, so they
+    # are not good for testing that the values are correct. Instead, their purpose is to
+    # ensure that any dynamic machinery put in place in git.compat to cause warnings to
+    # be issued does not get in the way of the intended values being accessed.
+    assert is_win == (os.name == "nt")
+    assert is_posix == (os.name == "posix")
+    assert is_darwin == (sys.platform == "darwin")
+
+
+def test_dir() -> None:
+    """dir() on git.compat includes all public attributes, even if deprecated.
+
+    As dir() usually does, it also has nonpublic attributes, which should also not be
+    removed by a custom __dir__ function, but those are less important to test.
+    """
+    expected_subset = {
+        "is_win",
+        "is_posix",
+        "is_darwin",
+        "defenc",
+        "safe_decode",
+        "safe_encode",
+        "win_encode",
+    }
+    actual = set(dir(git.compat))
+    assert expected_subset <= actual
diff --git a/test/deprecation/test_toplevel.py b/test/deprecation/test_toplevel.py
new file mode 100644
index 000000000..740408193
--- /dev/null
+++ b/test/deprecation/test_toplevel.py
@@ -0,0 +1,233 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Tests for dynamic and static characteristics of top-level git module attributes.
+
+Provided mypy has ``warn_unused_ignores = true`` set, running mypy on these test cases
+checks static typing of the code under test. This is the reason for the many separate
+single-line attr-defined suppressions, so those should not be replaced with a smaller
+number of more broadly scoped suppressions, even where it is feasible to do so.
+
+Running pytest checks dynamic behavior as usual.
+"""
+
+import itertools
+import sys
+from typing import Type
+
+if sys.version_info >= (3, 11):
+    from typing import assert_type
+else:
+    from typing_extensions import assert_type
+
+import pytest
+
+import git
+import git.index.base
+import git.index.fun
+import git.index.typ
+import git.refs.head
+import git.refs.log
+import git.refs.reference
+import git.refs.symbolic
+import git.refs.tag
+
+
+def test_cannot_access_undefined() -> None:
+    """Accessing a bogus attribute in git remains a dynamic and static error."""
+    with pytest.raises(AttributeError):
+        git.foo  # type: ignore[attr-defined]
+
+
+def test_cannot_import_undefined() -> None:
+    """Importing a bogus attribute from git remains a dynamic and static error."""
+    with pytest.raises(ImportError):
+        from git import foo  # type: ignore[attr-defined]  # noqa: F401
+
+
+def test_util_alias_access() -> None:
+    """Accessing util in git works, warns, and mypy verifies it and its attributes."""
+    # The attribute access should succeed.
+    with pytest.deprecated_call() as ctx:
+        util = git.util
+
+    # There should be exactly one warning and it should have our util-specific message.
+    (message,) = [str(entry.message) for entry in ctx]
+    assert "git.util" in message
+    assert "git.index.util" in message
+    assert "should not be relied on" in message
+
+    # We check access through the util alias to the TemporaryFileSwap member, since it
+    # is slightly simpler to validate and reason about than the other public members,
+    # which are functions (specifically, higher-order functions for use as decorators).
+    from git.index.util import TemporaryFileSwap
+
+    assert_type(util.TemporaryFileSwap, Type[TemporaryFileSwap])
+
+    # This comes after the static assertion, just in case it would affect the inference.
+    assert util.TemporaryFileSwap is TemporaryFileSwap
+
+
+def test_util_alias_import() -> None:
+    """Importing util from git works, warns, and mypy verifies it and its attributes."""
+    # The import should succeed.
+    with pytest.deprecated_call() as ctx:
+        from git import util
+
+    # There may be multiple warnings. In CPython there will be currently always be
+    # exactly two, possibly due to the equivalent of calling hasattr to do a pre-check
+    # prior to retrieving the attribute for actual use. However, all warnings should
+    # have the same message, and it should be our util-specific message.
+    (message,) = {str(entry.message) for entry in ctx}
+    assert "git.util" in message, "Has alias."
+    assert "git.index.util" in message, "Has target."
+    assert "should not be relied on" in message, "Distinct from other messages."
+
+    # As above, we check access through the util alias to the TemporaryFileSwap member.
+    from git.index.util import TemporaryFileSwap
+
+    assert_type(util.TemporaryFileSwap, Type[TemporaryFileSwap])
+
+    # This comes after the static assertion, just in case it would affect the inference.
+    assert util.TemporaryFileSwap is TemporaryFileSwap
+
+
+_PRIVATE_MODULE_ALIAS_TARGETS = (
+    git.refs.head,
+    git.refs.log,
+    git.refs.reference,
+    git.refs.symbolic,
+    git.refs.tag,
+    git.index.base,
+    git.index.fun,
+    git.index.typ,
+)
+"""Targets of private aliases in the git module to some modules, not including util."""
+
+
+_PRIVATE_MODULE_ALIAS_TARGET_NAMES = (
+    "git.refs.head",
+    "git.refs.log",
+    "git.refs.reference",
+    "git.refs.symbolic",
+    "git.refs.tag",
+    "git.index.base",
+    "git.index.fun",
+    "git.index.typ",
+)
+"""Expected ``__name__`` attributes of targets of private aliases in the git module."""
+
+
+def test_alias_target_module_names_are_by_location() -> None:
+    """The aliases are weird, but their targets are normal, even in ``__name__``."""
+    actual = [module.__name__ for module in _PRIVATE_MODULE_ALIAS_TARGETS]
+    expected = list(_PRIVATE_MODULE_ALIAS_TARGET_NAMES)
+    assert actual == expected
+
+
+def test_private_module_alias_access() -> None:
+    """Non-util private alias access works but warns and is a deliberate mypy error."""
+    with pytest.deprecated_call() as ctx:
+        assert (
+            git.head,  # type: ignore[attr-defined]
+            git.log,  # type: ignore[attr-defined]
+            git.reference,  # type: ignore[attr-defined]
+            git.symbolic,  # type: ignore[attr-defined]
+            git.tag,  # type: ignore[attr-defined]
+            git.base,  # type: ignore[attr-defined]
+            git.fun,  # type: ignore[attr-defined]
+            git.typ,  # type: ignore[attr-defined]
+        ) == _PRIVATE_MODULE_ALIAS_TARGETS
+
+    # Each should have warned exactly once, and note what to use instead.
+    messages = [str(w.message) for w in ctx]
+
+    assert len(messages) == len(_PRIVATE_MODULE_ALIAS_TARGETS)
+
+    for fullname, message in zip(_PRIVATE_MODULE_ALIAS_TARGET_NAMES, messages):
+        assert message.endswith(f"Use {fullname} instead.")
+
+
+def test_private_module_alias_import() -> None:
+    """Non-util private alias import works but warns and is a deliberate mypy error."""
+    with pytest.deprecated_call() as ctx:
+        from git import head  # type: ignore[attr-defined]
+        from git import log  # type: ignore[attr-defined]
+        from git import reference  # type: ignore[attr-defined]
+        from git import symbolic  # type: ignore[attr-defined]
+        from git import tag  # type: ignore[attr-defined]
+        from git import base  # type: ignore[attr-defined]
+        from git import fun  # type: ignore[attr-defined]
+        from git import typ  # type: ignore[attr-defined]
+
+    assert (
+        head,
+        log,
+        reference,
+        symbolic,
+        tag,
+        base,
+        fun,
+        typ,
+    ) == _PRIVATE_MODULE_ALIAS_TARGETS
+
+    # Each import may warn multiple times. In CPython there will be currently always be
+    # exactly two warnings per import, possibly due to the equivalent of calling hasattr
+    # to do a pre-check prior to retrieving the attribute for actual use. However, for
+    # each import, all messages should be the same and should note what to use instead.
+    messages_with_duplicates = [str(w.message) for w in ctx]
+    messages = [message for message, _ in itertools.groupby(messages_with_duplicates)]
+
+    assert len(messages) == len(_PRIVATE_MODULE_ALIAS_TARGETS)
+
+    for fullname, message in zip(_PRIVATE_MODULE_ALIAS_TARGET_NAMES, messages):
+        assert message.endswith(f"Use {fullname} instead.")
+
+
+def test_dir_contains_public_attributes() -> None:
+    """All public attributes of the git module are present when dir() is called on it.
+
+    This is naturally the case, but some ways of adding dynamic attribute access
+    behavior can change it, especially if __dir__ is defined but care is not taken to
+    preserve the contents that should already be present.
+
+    Note that dir() should usually automatically list non-public attributes if they are
+    actually "physically" present as well, so the approach taken here to test it should
+    not be reproduced if __dir__ is added (instead, a call to globals() could be used,
+    as its keys list the automatic values).
+    """
+    expected_subset = set(git.__all__)
+    actual = set(dir(git))
+    assert expected_subset <= actual
+
+
+def test_dir_does_not_contain_util() -> None:
+    """The util attribute is absent from the dir() of git.
+
+    Because this behavior is less confusing than including it, where its meaning would
+    be assumed by users examining the dir() for what is available.
+    """
+    assert "util" not in dir(git)
+
+
+def test_dir_does_not_contain_private_module_aliases() -> None:
+    """Names from inside index and refs only pretend to be there and are not in dir().
+
+    The reason for omitting these is not that they are private, since private members
+    are usually included in dir() when actually present. Instead, these are only sort
+    of even there, no longer being imported and only being resolved dynamically for the
+    time being. In addition, it would be confusing to list these because doing so would
+    obscure the module structure of GitPython.
+    """
+    expected_absent = {
+        "head",
+        "log",
+        "reference",
+        "symbolic",
+        "tag",
+        "base",
+        "fun",
+        "typ",
+    }
+    actual = set(dir(git))
+    assert not (expected_absent & actual), "They should be completely disjoint."
diff --git a/test/deprecation/test_types.py b/test/deprecation/test_types.py
new file mode 100644
index 000000000..f97375a85
--- /dev/null
+++ b/test/deprecation/test_types.py
@@ -0,0 +1,69 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Tests for dynamic and static characteristics of git.types module attributes."""
+
+import sys
+
+if sys.version_info >= (3, 8):
+    from typing import Literal
+else:
+    from typing_extensions import Literal
+
+import pytest
+
+import git.types
+
+
+def test_cannot_access_undefined() -> None:
+    """Accessing a bogus attribute in git.types remains a dynamic and static error."""
+    with pytest.raises(AttributeError):
+        git.types.foo  # type: ignore[attr-defined]
+
+
+def test_can_access_lit_commit_ish_but_it_is_not_usable() -> None:
+    """Lit_commit_ish_can be accessed, but warns and is an invalid type annotation."""
+    # It would be fine to test attribute access rather than a "from" import. But a
+    # "from" import is more likely to appear in actual usage, so it is used here.
+    with pytest.deprecated_call() as ctx:
+        from git.types import Lit_commit_ish
+
+    # As noted in test_toplevel.test_util_alias_import, there may be multiple warnings,
+    # but all with the same message.
+    (message,) = {str(entry.message) for entry in ctx}
+    assert "Lit_commit_ish is deprecated." in message
+    assert 'Literal["commit", "tag", "blob", "tree"]' in message, "Has old definition."
+    assert 'Literal["commit", "tag"]' in message, "Has new definition."
+    assert "GitObjectTypeString" in message, "Has new type name for old definition."
+
+    _: Lit_commit_ish = "commit"  # type: ignore[valid-type]
+
+    # It should be as documented (even though deliberately unusable in static checks).
+    assert Lit_commit_ish == Literal["commit", "tag"]
+
+
+def test_dir() -> None:
+    """dir() on git.types includes public names, even ``Lit_commit_ish``.
+
+    It also contains private names that we don't test. See test_compat.test_dir.
+    """
+    expected_subset = {
+        "PathLike",
+        "TBD",
+        "AnyGitObject",
+        "Tree_ish",
+        "Commit_ish",
+        "GitObjectTypeString",
+        "Lit_commit_ish",
+        "Lit_config_levels",
+        "ConfigLevels_Tup",
+        "CallableProgress",
+        "assert_never",
+        "Files_TD",
+        "Total_TD",
+        "HSH_TD",
+        "Has_Repo",
+        "Has_id_attribute",
+    }
+    actual = set(dir(git.types))
+    assert expected_subset <= actual
diff --git a/test/fixtures/.gitconfig b/test/fixtures/.gitconfig
new file mode 100644
index 000000000..6a0459f6b
--- /dev/null
+++ b/test/fixtures/.gitconfig
@@ -0,0 +1,3 @@
+[alias]
+    rbi = "!g() { git rebase -i origin/${1:-master} ; } ; g"
+    expush = "!f() { git branch -f tmp ; { git rbi $1 && git push ; } ; git reset --hard tmp ; git rebase origin/${1:-master}; } ; f"
\ No newline at end of file
diff --git a/git/test/fixtures/blame b/test/fixtures/blame
similarity index 100%
rename from git/test/fixtures/blame
rename to test/fixtures/blame
diff --git a/git/test/fixtures/blame_binary b/test/fixtures/blame_binary
similarity index 100%
rename from git/test/fixtures/blame_binary
rename to test/fixtures/blame_binary
diff --git a/git/test/fixtures/blame_complex_revision b/test/fixtures/blame_complex_revision
similarity index 100%
rename from git/test/fixtures/blame_complex_revision
rename to test/fixtures/blame_complex_revision
diff --git a/test/fixtures/blame_incremental b/test/fixtures/blame_incremental
new file mode 100644
index 000000000..67310aec0
--- /dev/null
+++ b/test/fixtures/blame_incremental
@@ -0,0 +1,30 @@
+82b8902e033430000481eb355733cd7065342037 2 2 1
+author Sebastian Thiel
+author-mail <byronimo@gmail.com>
+author-time 1270634931
+author-tz +0200
+committer Sebastian Thiel
+committer-mail <byronimo@gmail.com>
+committer-time 1270634931
+committer-tz +0200
+summary Used this release

 for a first beta of the 0.2 branch of development
+previous 501bf602abea7d21c3dbb409b435976e92033145 AUTHORS
+filename AUTHORS
+82b8902e033430000481eb355733cd7065342037 14 14 1
+filename AUTHORS
+c76852d0bff115720af3f27acdb084c59361e5f6 1 1 1
+author Michael Trier
+author-mail <mtrier@gmail.com>
+author-time 1232829627
+author-tz -0500
+committer Michael Trier
+committer-mail <mtrier@gmail.com>
+committer-time 1232829627
+committer-tz -0500
+summary Lots of spring cleaning and added in Sphinx documentation.
+previous bcd57e349c08bd7f076f8d6d2f39b702015358c1 AUTHORS
+filename AUTHORS
+c76852d0bff115720af3f27acdb084c59361e5f6 2 3 11
+filename AUTHORS
+c76852d0bff115720af3f27acdb084c59361e5f6 13 15 2
+filename AUTHORS
diff --git a/test/fixtures/blame_incremental_2.11.1_plus b/test/fixtures/blame_incremental_2.11.1_plus
new file mode 100644
index 000000000..beee7011f
--- /dev/null
+++ b/test/fixtures/blame_incremental_2.11.1_plus
@@ -0,0 +1,33 @@
+82b8902e033430000481eb355733cd7065342037 2 2 1
+author Sebastian Thiel
+author-mail <byronimo@gmail.com>
+author-time 1270634931
+author-tz +0200
+committer Sebastian Thiel
+committer-mail <byronimo@gmail.com>
+committer-time 1270634931
+committer-tz +0200
+summary Used this release for a first beta of the 0.2 branch of development
+previous 501bf602abea7d21c3dbb409b435976e92033145 AUTHORS
+filename AUTHORS
+82b8902e033430000481eb355733cd7065342037 14 14 1
+previous 501bf602abea7d21c3dbb409b435976e92033145 AUTHORS
+filename AUTHORS
+c76852d0bff115720af3f27acdb084c59361e5f6 1 1 1
+author Michael Trier
+author-mail <mtrier@gmail.com>
+author-time 1232829627
+author-tz -0500
+committer Michael Trier
+committer-mail <mtrier@gmail.com>
+committer-time 1232829627
+committer-tz -0500
+summary Lots of spring cleaning and added in Sphinx documentation.
+previous bcd57e349c08bd7f076f8d6d2f39b702015358c1 AUTHORS
+filename AUTHORS
+c76852d0bff115720af3f27acdb084c59361e5f6 2 3 11
+previous bcd57e349c08bd7f076f8d6d2f39b702015358c1 AUTHORS
+filename AUTHORS
+c76852d0bff115720af3f27acdb084c59361e5f6 13 15 2
+previous bcd57e349c08bd7f076f8d6d2f39b702015358c1 AUTHORS
+filename AUTHORS
diff --git a/test/fixtures/cat_file.py b/test/fixtures/cat_file.py
new file mode 100644
index 000000000..5480e6282
--- /dev/null
+++ b/test/fixtures/cat_file.py
@@ -0,0 +1,6 @@
+import sys
+
+with open(sys.argv[1]) as fd:
+    for line in fd.readlines():
+        sys.stdout.write(line)
+        sys.stderr.write(line)
diff --git a/git/test/fixtures/cat_file_blob b/test/fixtures/cat_file_blob
similarity index 100%
rename from git/test/fixtures/cat_file_blob
rename to test/fixtures/cat_file_blob
diff --git a/git/test/fixtures/cat_file_blob_nl b/test/fixtures/cat_file_blob_nl
similarity index 100%
rename from git/test/fixtures/cat_file_blob_nl
rename to test/fixtures/cat_file_blob_nl
diff --git a/git/test/fixtures/cat_file_blob_size b/test/fixtures/cat_file_blob_size
similarity index 100%
rename from git/test/fixtures/cat_file_blob_size
rename to test/fixtures/cat_file_blob_size
diff --git a/test/fixtures/commit_invalid_data b/test/fixtures/commit_invalid_data
new file mode 100644
index 000000000..d112bf2d5
--- /dev/null
+++ b/test/fixtures/commit_invalid_data
@@ -0,0 +1,6 @@
+tree 9f1a495d7d9692d24f5caedaa89f5c2c32d59368
+parent 492ace2ffce0e426ebeb55e364e987bcf024dd3b
+author E.Azer Ko�o�o�oculu <azer@kodfabrik.com> 1306710073 +0300
+committer E.Azer Ko�o�o�oculu <azer@kodfabrik.com> 1306710073 +0300
+
+add environjs
diff --git a/git/test/fixtures/commit_with_gpgsig b/test/fixtures/commit_with_gpgsig
similarity index 100%
rename from git/test/fixtures/commit_with_gpgsig
rename to test/fixtures/commit_with_gpgsig
diff --git a/git/test/fixtures/diff_2 b/test/fixtures/diff_2
similarity index 100%
rename from git/test/fixtures/diff_2
rename to test/fixtures/diff_2
diff --git a/git/test/fixtures/diff_2f b/test/fixtures/diff_2f
similarity index 100%
rename from git/test/fixtures/diff_2f
rename to test/fixtures/diff_2f
diff --git a/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color b/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color
new file mode 100644
index 000000000..dad85c68e
--- /dev/null
+++ b/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color
@@ -0,0 +1 @@
+:100644 100644 739bc65220ad90e9ebfa2d6af1723b97555569a4 0000000000000000000000000000000000000000 M	README.md
diff --git a/test/fixtures/diff_change_in_type b/test/fixtures/diff_change_in_type
new file mode 100644
index 000000000..e0ca73890
--- /dev/null
+++ b/test/fixtures/diff_change_in_type
@@ -0,0 +1,10 @@
+diff --git a/this b/this
+deleted file mode 100644
+index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
+diff --git a/this b/this
+new file mode 120000
+index 0000000000000000000000000000000000000000..42061c01a1c70097d1e4579f29a5adf40abdec95
+--- /dev/null
++++ b/this
+@@ -0,0 +1 @@
++that
diff --git a/test/fixtures/diff_change_in_type_raw b/test/fixtures/diff_change_in_type_raw
new file mode 100644
index 000000000..0793e1bbe
--- /dev/null
+++ b/test/fixtures/diff_change_in_type_raw
@@ -0,0 +1 @@
+:100644 120000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 42061c01a1c70097d1e4579f29a5adf40abdec95 T     this
diff --git a/test/fixtures/diff_copied_mode b/test/fixtures/diff_copied_mode
new file mode 100644
index 000000000..60707afc8
--- /dev/null
+++ b/test/fixtures/diff_copied_mode
@@ -0,0 +1,4 @@
+diff --git a/test1.txt b/test2.txt
+similarity index 100%
+copy from test1.txt
+copy to test2.txt
diff --git a/test/fixtures/diff_copied_mode_raw b/test/fixtures/diff_copied_mode_raw
new file mode 100644
index 000000000..7640f3ab7
--- /dev/null
+++ b/test/fixtures/diff_copied_mode_raw
@@ -0,0 +1 @@
+:100644 100644 cfe9deac6e10683917e80f877566b58644aa21df cfe9deac6e10683917e80f877566b58644aa21df C100	test1.txt	test2.txt
diff --git a/git/test/fixtures/diff_f b/test/fixtures/diff_f
similarity index 100%
rename from git/test/fixtures/diff_f
rename to test/fixtures/diff_f
diff --git a/test/fixtures/diff_file_with_colon b/test/fixtures/diff_file_with_colon
new file mode 100644
index 000000000..4058b1715
Binary files /dev/null and b/test/fixtures/diff_file_with_colon differ
diff --git a/test/fixtures/diff_file_with_spaces b/test/fixtures/diff_file_with_spaces
new file mode 100644
index 000000000..a9f0b06c4
--- /dev/null
+++ b/test/fixtures/diff_file_with_spaces
@@ -0,0 +1,7 @@
+diff --git a/file with spaces b/file with spaces
+new file mode 100644
+index 0000000000000000000000000000000000000000..75c620d7b0d3b0100415421a97f553c979d75174
+--- /dev/null
++++ b/file with spaces
+@@ -0,0 +1 @@
++ohai
diff --git a/git/test/fixtures/diff_i b/test/fixtures/diff_i
similarity index 100%
rename from git/test/fixtures/diff_i
rename to test/fixtures/diff_i
diff --git a/git/test/fixtures/diff_index_patch b/test/fixtures/diff_index_patch
similarity index 90%
rename from git/test/fixtures/diff_index_patch
rename to test/fixtures/diff_index_patch
index a5a8cff24..97b824e0a 100644
--- a/git/test/fixtures/diff_index_patch
+++ b/test/fixtures/diff_index_patch
@@ -56,26 +56,26 @@ index f2233fbf40f3f69309ce5cc714e99fcbdcd33ec3..a88a777df3909a61be97f1a7b1194dad
 @@ -1 +1 @@
 -Subproject commit f2233fbf40f3f69309ce5cc714e99fcbdcd33ec3
 +Subproject commit a88a777df3909a61be97f1a7b1194dad6de25702-dirty
-diff --git a/git/test/fixtures/diff_patch_binary b/git/test/fixtures/diff_patch_binary
+diff --git a/test/fixtures/diff_patch_binary b/test/fixtures/diff_patch_binary
 new file mode 100644
 index 0000000000000000000000000000000000000000..c92ccd6ebc92a871d38ad7cb8a48bcdb1a5dbc33
 --- /dev/null
-+++ b/git/test/fixtures/diff_patch_binary
++++ b/test/fixtures/diff_patch_binary
 @@ -0,0 +1,3 @@
 +diff --git a/rps b/rps
 +index f4567df37451b230b1381b1bc9c2bcad76e08a3c..736bd596a36924d30b480942e9475ce0d734fa0d 100755
 +Binary files a/rps and b/rps differ
-diff --git a/git/test/fixtures/diff_raw_binary b/git/test/fixtures/diff_raw_binary
+diff --git a/test/fixtures/diff_raw_binary b/test/fixtures/diff_raw_binary
 new file mode 100644
 index 0000000000000000000000000000000000000000..d4673fa41ee8413384167fc7b9f25e4daf18a53a
 --- /dev/null
-+++ b/git/test/fixtures/diff_raw_binary
++++ b/test/fixtures/diff_raw_binary
 @@ -0,0 +1 @@
 +:100755 100755 f4567df37451b230b1381b1bc9c2bcad76e08a3c 736bd596a36924d30b480942e9475ce0d734fa0d M	rps
-diff --git a/git/test/test_diff.py b/git/test/test_diff.py
+diff --git a/test/test_diff.py b/test/test_diff.py
 index ce0f64f2261bd8de063233108caac1f26742c1fd..4de26f8884fd048ac7f10007f2bf7c7fa3fa60f4 100644
---- a/git/test/test_diff.py
-+++ b/git/test/test_diff.py
+--- a/test/test_diff.py
++++ b/test/test_diff.py
 @@ -65,6 +65,21 @@ class TestDiff(TestBase):
          assert diff.rename_to == 'that'
          assert len(list(diffs.iter_change_type('R'))) == 1
@@ -96,5 +96,5 @@ index ce0f64f2261bd8de063233108caac1f26742c1fd..4de26f8884fd048ac7f10007f2bf7c7f
 +        assert len(res) == 3
 +
      def test_diff_patch_format(self):
-         # test all of the 'old' format diffs for completness - it should at least
+         # test all of the 'old' format diffs for completeness - it should at least
          # be able to deal with it
diff --git a/test/fixtures/diff_index_raw b/test/fixtures/diff_index_raw
new file mode 100644
index 000000000..c25f380d3
--- /dev/null
+++ b/test/fixtures/diff_index_raw
@@ -0,0 +1 @@
+:100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D	 
diff --git a/test/fixtures/diff_initial b/test/fixtures/diff_initial
new file mode 100644
index 000000000..648d70437
--- /dev/null
+++ b/test/fixtures/diff_initial
@@ -0,0 +1,8 @@
+@@ -0,0 +1,7 @@
++=======
++CHANGES
++=======
++
++0.1.0
++=====
++initial release
diff --git a/git/test/fixtures/diff_mode_only b/test/fixtures/diff_mode_only
old mode 100755
new mode 100644
similarity index 100%
rename from git/test/fixtures/diff_mode_only
rename to test/fixtures/diff_mode_only
diff --git a/git/test/fixtures/diff_new_mode b/test/fixtures/diff_new_mode
similarity index 100%
rename from git/test/fixtures/diff_new_mode
rename to test/fixtures/diff_new_mode
diff --git a/test/fixtures/diff_numstat b/test/fixtures/diff_numstat
new file mode 100644
index 000000000..b76e467eb
--- /dev/null
+++ b/test/fixtures/diff_numstat
@@ -0,0 +1,3 @@
+M	29	18	a.txt
+M	0	5	b.txt
+A	7	0	c.txt
\ No newline at end of file
diff --git a/git/test/fixtures/diff_p b/test/fixtures/diff_p
similarity index 99%
rename from git/test/fixtures/diff_p
rename to test/fixtures/diff_p
index af4759e50..76242b58c 100644
--- a/git/test/fixtures/diff_p
+++ b/test/fixtures/diff_p
@@ -397,7 +397,7 @@ index 1d5251d40fb65ac89184ec662a3e1b04d0c24861..98eeddda5ed2b0e215e21128112393bd
        self.git_dir = git_dir
      end
      
--    # Converstion hash from Ruby style options to git command line
+-    # Conversion hash from Ruby style options to git command line
 -    # style options
 -    TRANSFORM = {:max_count => "--max-count=",
 -                 :skip => "--skip=",
diff --git a/git/test/fixtures/diff_patch_binary b/test/fixtures/diff_patch_binary
similarity index 100%
rename from git/test/fixtures/diff_patch_binary
rename to test/fixtures/diff_patch_binary
diff --git a/test/fixtures/diff_patch_unsafe_paths b/test/fixtures/diff_patch_unsafe_paths
new file mode 100644
index 000000000..1aad67545
--- /dev/null
+++ b/test/fixtures/diff_patch_unsafe_paths
@@ -0,0 +1,89 @@
+diff --git a/path/ starting with a space b/path/ starting with a space
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ b/path/ starting with a space
+@@ -0,0 +1 @@
++dummy content
+diff --git "a/path/\"with-quotes\"" "b/path/\"with-quotes\""
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ "b/path/\"with-quotes\""
+@@ -0,0 +1 @@
++dummy content
+diff --git a/path/'with-single-quotes' b/path/'with-single-quotes'
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ b/path/'with-single-quotes'
+@@ -0,0 +1 @@
++dummy content
+diff --git a/path/ending in a space  b/path/ending in a space 
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ b/path/ending in a space 
+@@ -0,0 +1 @@
++dummy content
+diff --git "a/path/with\ttab" "b/path/with\ttab"
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ "b/path/with\ttab"
+@@ -0,0 +1 @@
++dummy content
+diff --git "a/path/with\nnewline" "b/path/with\nnewline"
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ "b/path/with\nnewline"
+@@ -0,0 +1 @@
++dummy content
+diff --git a/path/with spaces b/path/with spaces
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ b/path/with spaces
+@@ -0,0 +1 @@
++dummy content
+diff --git a/path/with-question-mark? b/path/with-question-mark?
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ b/path/with-question-mark?
+@@ -0,0 +1 @@
++dummy content
+diff --git "a/path/¯\\_(ツ)_|¯" "b/path/¯\\_(ツ)_|¯"
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ "b/path/¯\\_(ツ)_|¯"
+@@ -0,0 +1 @@
++dummy content
+diff --git "a/path/\360\237\222\251.txt" "b/path/\360\237\222\251.txt"
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ "b/path/\360\237\222\251.txt"
+@@ -0,0 +1 @@
++dummy content
+diff --git "a/path/\200-invalid-unicode-path.txt" "b/path/\200-invalid-unicode-path.txt"
+new file mode 100644
+index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54
+--- /dev/null
++++ "b/path/\200-invalid-unicode-path.txt"
+@@ -0,0 +1 @@
++dummy content
+diff --git a/a/with spaces b/b/with some spaces
+similarity index 100%
+rename from a/with spaces
+rename to b/with some spaces
+diff --git a/a/ending in a space  b/b/ending with space 
+similarity index 100%
+rename from a/ending in a space 
+rename to b/ending with space 
+diff --git "a/a/\"with-quotes\"" "b/b/\"with even more quotes\""
+similarity index 100%
+rename from "a/\"with-quotes\""
+rename to "b/\"with even more quotes\""
diff --git a/git/test/fixtures/diff_raw_binary b/test/fixtures/diff_raw_binary
similarity index 100%
rename from git/test/fixtures/diff_raw_binary
rename to test/fixtures/diff_raw_binary
diff --git a/git/test/fixtures/diff_rename b/test/fixtures/diff_rename
similarity index 89%
rename from git/test/fixtures/diff_rename
rename to test/fixtures/diff_rename
index 13abae0ea..2d5241e33 100644
--- a/git/test/fixtures/diff_rename
+++ b/test/fixtures/diff_rename
@@ -8,5 +8,5 @@ committer Michael Trier <mtrier@gmail.com> 1229389391 -0500
 
 diff --git a/AUTHORS b/CONTRIBUTORS
 similarity index 100%
-rename from AUTHORS
-rename to CONTRIBUTORS
+rename from Jérôme
+rename to müller
diff --git a/git/test/fixtures/diff_rename_raw b/test/fixtures/diff_rename_raw
similarity index 100%
rename from git/test/fixtures/diff_rename_raw
rename to test/fixtures/diff_rename_raw
diff --git a/git/test/fixtures/diff_tree_numstat_root b/test/fixtures/diff_tree_numstat_root
similarity index 100%
rename from git/test/fixtures/diff_tree_numstat_root
rename to test/fixtures/diff_tree_numstat_root
diff --git a/test/fixtures/env_case.py b/test/fixtures/env_case.py
new file mode 100644
index 000000000..03b4df222
--- /dev/null
+++ b/test/fixtures/env_case.py
@@ -0,0 +1,18 @@
+"""Steps 3 and 4 for test_it_avoids_upcasing_unrelated_environment_variable_names."""
+
+import subprocess
+import sys
+
+# Step 3a: Import the module, in case that upcases the environment variable name.
+import git
+
+
+_, working_dir, env_var_name = sys.argv
+
+# Step 3b: Use Git.execute explicitly, in case that upcases the environment variable.
+#          (Importing git should be enough, but this ensures Git.execute is called.)
+repo = git.Repo(working_dir)  # Hold the reference.
+git.Git(repo.working_dir).execute(["git", "version"])
+
+# Step 4: Create the non-Python grandchild that accesses the variable case-sensitively.
+print(subprocess.check_output(["set", env_var_name], shell=True, text=True))
diff --git a/git/test/fixtures/for_each_ref_with_path_component b/test/fixtures/for_each_ref_with_path_component
similarity index 100%
rename from git/test/fixtures/for_each_ref_with_path_component
rename to test/fixtures/for_each_ref_with_path_component
diff --git a/git/test/fixtures/git_config b/test/fixtures/git_config
similarity index 62%
rename from git/test/fixtures/git_config
rename to test/fixtures/git_config
index c9945cd50..a8cad56e8 100644
--- a/git/test/fixtures/git_config
+++ b/test/fixtures/git_config
@@ -22,11 +22,25 @@
 	url = git://gitorious.org/~martin.marcher/git-python/serverhorror.git
 	fetch = +refs/heads/*:refs/remotes/MartinMarcher/*
     # can handle comments - the section name is supposed to be stripped
+# causes stock git-config puke
 [  gui ]
 	geometry = 1316x820+219+243 207 192
 [branch "mainline_performance"]
 	remote = mainline
 	merge = refs/heads/master
+# section with value defined before include to be overridden
+[sec]
+    var0 = value0_main
 [include]
-	path = doesntexist.cfg
-	abspath = /usr/bin/foodoesntexist.bar
\ No newline at end of file
+    path = doesntexist.cfg
+    # field should be 'path' so abspath should be ignored
+    abspath = /usr/bin/foodoesntexist.bar
+    path = /usr/bin/foodoesntexist.bar
+    # should be relative to the path of this config file
+    path = ./git_config-inc.cfg
+# and defined after include.  According to the documentation
+# and behavior of git config, this should be the value since
+# inclusions should be processed immediately
+[sec]
+    var1 = value1_main
+
diff --git a/test/fixtures/git_config-inc.cfg b/test/fixtures/git_config-inc.cfg
new file mode 100644
index 000000000..2368ec20c
--- /dev/null
+++ b/test/fixtures/git_config-inc.cfg
@@ -0,0 +1,5 @@
+[sec]
+    var0 = value0_included
+    var1 = value1_included
+[diff]
+    tool = diff_included
diff --git a/git/test/fixtures/git_config_global b/test/fixtures/git_config_global
similarity index 100%
rename from git/test/fixtures/git_config_global
rename to test/fixtures/git_config_global
diff --git a/test/fixtures/git_config_multiple b/test/fixtures/git_config_multiple
new file mode 100644
index 000000000..03a975680
--- /dev/null
+++ b/test/fixtures/git_config_multiple
@@ -0,0 +1,7 @@
+[section0]
+    option0 = value0
+
+[section1]
+    option1 = value1a
+    option1 = value1b
+    other_option1 = other_value1
diff --git a/git/test/fixtures/git_config_with_comments b/test/fixtures/git_config_with_comments
similarity index 100%
rename from git/test/fixtures/git_config_with_comments
rename to test/fixtures/git_config_with_comments
diff --git a/test/fixtures/git_config_with_empty_quotes b/test/fixtures/git_config_with_empty_quotes
new file mode 100644
index 000000000..f11fe4248
--- /dev/null
+++ b/test/fixtures/git_config_with_empty_quotes
@@ -0,0 +1,2 @@
+[core]
+  filemode = ""
diff --git a/test/fixtures/git_config_with_empty_value b/test/fixtures/git_config_with_empty_value
new file mode 100644
index 000000000..0427caea5
--- /dev/null
+++ b/test/fixtures/git_config_with_empty_value
@@ -0,0 +1,4 @@
+[color]
+	ui
+[core]
+	filemode = true
\ No newline at end of file
diff --git a/test/fixtures/git_config_with_extra_whitespace b/test/fixtures/git_config_with_extra_whitespace
new file mode 100644
index 000000000..0f727cb5d
--- /dev/null
+++ b/test/fixtures/git_config_with_extra_whitespace
@@ -0,0 +1,2 @@
+[init]
+  defaultBranch =  trunk  
diff --git a/test/fixtures/git_config_with_quotes b/test/fixtures/git_config_with_quotes
new file mode 100644
index 000000000..40e6710d9
--- /dev/null
+++ b/test/fixtures/git_config_with_quotes
@@ -0,0 +1,3 @@
+[user]
+  name = "Cody Veal"
+  email = "cveal05@gmail.com"
diff --git a/test/fixtures/git_config_with_quotes_escapes b/test/fixtures/git_config_with_quotes_escapes
new file mode 100644
index 000000000..33332c221
--- /dev/null
+++ b/test/fixtures/git_config_with_quotes_escapes
@@ -0,0 +1,9 @@
+[custom]
+  hasnewline = "first\nsecond"
+  hasbackslash = "foo\\bar"
+  hasquote = "ab\"cd"
+  hastrailingbackslash = "word\\"
+  hasunrecognized = "p\qrs"
+  hasunescapedquotes = "ab"cd"e"
+  ordinary = "hello world"
+  unquoted = good evening
diff --git a/test/fixtures/git_config_with_quotes_whitespace_inside b/test/fixtures/git_config_with_quotes_whitespace_inside
new file mode 100644
index 000000000..c6014cc61
--- /dev/null
+++ b/test/fixtures/git_config_with_quotes_whitespace_inside
@@ -0,0 +1,2 @@
+[core]
+  commentString = "# "
diff --git a/test/fixtures/git_config_with_quotes_whitespace_outside b/test/fixtures/git_config_with_quotes_whitespace_outside
new file mode 100644
index 000000000..4b1615a51
--- /dev/null
+++ b/test/fixtures/git_config_with_quotes_whitespace_outside
@@ -0,0 +1,2 @@
+[init]
+  defaultBranch =  "trunk"  
diff --git a/git/test/fixtures/git_file b/test/fixtures/git_file
similarity index 100%
rename from git/test/fixtures/git_file
rename to test/fixtures/git_file
diff --git a/git/test/fixtures/index b/test/fixtures/index
similarity index 100%
rename from git/test/fixtures/index
rename to test/fixtures/index
diff --git a/git/test/fixtures/index_merge b/test/fixtures/index_merge
similarity index 100%
rename from git/test/fixtures/index_merge
rename to test/fixtures/index_merge
diff --git a/test/fixtures/issue-301_stderr b/test/fixtures/issue-301_stderr
new file mode 100644
index 000000000..3da0ed157
--- /dev/null
+++ b/test/fixtures/issue-301_stderr
@@ -0,0 +1,5002 @@
+From github.com:jantman/gitpython_issue_301
+ = [up to date]      master     -> origin/master
+ = [up to date]      testcommit1 -> origin/testcommit1
+ = [up to date]      testcommit10 -> origin/testcommit10
+ = [up to date]      testcommit100 -> origin/testcommit100
+ = [up to date]      testcommit1000 -> origin/testcommit1000
+ = [up to date]      testcommit1001 -> origin/testcommit1001
+ = [up to date]      testcommit1002 -> origin/testcommit1002
+ = [up to date]      testcommit1003 -> origin/testcommit1003
+ = [up to date]      testcommit1004 -> origin/testcommit1004
+ = [up to date]      testcommit1005 -> origin/testcommit1005
+ = [up to date]      testcommit1006 -> origin/testcommit1006
+ = [up to date]      testcommit1007 -> origin/testcommit1007
+ = [up to date]      testcommit1008 -> origin/testcommit1008
+ = [up to date]      testcommit1009 -> origin/testcommit1009
+ = [up to date]      testcommit101 -> origin/testcommit101
+ = [up to date]      testcommit1010 -> origin/testcommit1010
+ = [up to date]      testcommit1011 -> origin/testcommit1011
+ = [up to date]      testcommit1012 -> origin/testcommit1012
+ = [up to date]      testcommit1013 -> origin/testcommit1013
+ = [up to date]      testcommit1014 -> origin/testcommit1014
+ = [up to date]      testcommit1015 -> origin/testcommit1015
+ = [up to date]      testcommit1016 -> origin/testcommit1016
+ = [up to date]      testcommit1017 -> origin/testcommit1017
+ = [up to date]      testcommit1018 -> origin/testcommit1018
+ = [up to date]      testcommit1019 -> origin/testcommit1019
+ = [up to date]      testcommit102 -> origin/testcommit102
+ = [up to date]      testcommit1020 -> origin/testcommit1020
+ = [up to date]      testcommit1021 -> origin/testcommit1021
+ = [up to date]      testcommit1022 -> origin/testcommit1022
+ = [up to date]      testcommit1023 -> origin/testcommit1023
+ = [up to date]      testcommit1024 -> origin/testcommit1024
+ = [up to date]      testcommit1025 -> origin/testcommit1025
+ = [up to date]      testcommit1026 -> origin/testcommit1026
+ = [up to date]      testcommit1027 -> origin/testcommit1027
+ = [up to date]      testcommit1028 -> origin/testcommit1028
+ = [up to date]      testcommit1029 -> origin/testcommit1029
+ = [up to date]      testcommit103 -> origin/testcommit103
+ = [up to date]      testcommit1030 -> origin/testcommit1030
+ = [up to date]      testcommit1031 -> origin/testcommit1031
+ = [up to date]      testcommit1032 -> origin/testcommit1032
+ = [up to date]      testcommit1033 -> origin/testcommit1033
+ = [up to date]      testcommit1034 -> origin/testcommit1034
+ = [up to date]      testcommit1035 -> origin/testcommit1035
+ = [up to date]      testcommit1036 -> origin/testcommit1036
+ = [up to date]      testcommit1037 -> origin/testcommit1037
+ = [up to date]      testcommit1038 -> origin/testcommit1038
+ = [up to date]      testcommit1039 -> origin/testcommit1039
+ = [up to date]      testcommit104 -> origin/testcommit104
+ = [up to date]      testcommit1040 -> origin/testcommit1040
+ = [up to date]      testcommit1041 -> origin/testcommit1041
+ = [up to date]      testcommit1042 -> origin/testcommit1042
+ = [up to date]      testcommit1043 -> origin/testcommit1043
+ = [up to date]      testcommit1044 -> origin/testcommit1044
+ = [up to date]      testcommit1045 -> origin/testcommit1045
+ = [up to date]      testcommit1046 -> origin/testcommit1046
+ = [up to date]      testcommit1047 -> origin/testcommit1047
+ = [up to date]      testcommit1048 -> origin/testcommit1048
+ = [up to date]      testcommit1049 -> origin/testcommit1049
+ = [up to date]      testcommit105 -> origin/testcommit105
+ = [up to date]      testcommit1050 -> origin/testcommit1050
+ = [up to date]      testcommit1051 -> origin/testcommit1051
+ = [up to date]      testcommit1052 -> origin/testcommit1052
+ = [up to date]      testcommit1053 -> origin/testcommit1053
+ = [up to date]      testcommit1054 -> origin/testcommit1054
+ = [up to date]      testcommit1055 -> origin/testcommit1055
+ = [up to date]      testcommit1056 -> origin/testcommit1056
+ = [up to date]      testcommit1057 -> origin/testcommit1057
+ = [up to date]      testcommit1058 -> origin/testcommit1058
+ = [up to date]      testcommit1059 -> origin/testcommit1059
+ = [up to date]      testcommit106 -> origin/testcommit106
+ = [up to date]      testcommit1060 -> origin/testcommit1060
+ = [up to date]      testcommit1061 -> origin/testcommit1061
+ = [up to date]      testcommit1062 -> origin/testcommit1062
+ = [up to date]      testcommit1063 -> origin/testcommit1063
+ = [up to date]      testcommit1064 -> origin/testcommit1064
+ = [up to date]      testcommit1065 -> origin/testcommit1065
+ = [up to date]      testcommit1066 -> origin/testcommit1066
+ = [up to date]      testcommit1067 -> origin/testcommit1067
+ = [up to date]      testcommit1068 -> origin/testcommit1068
+ = [up to date]      testcommit1069 -> origin/testcommit1069
+ = [up to date]      testcommit107 -> origin/testcommit107
+ = [up to date]      testcommit1070 -> origin/testcommit1070
+ = [up to date]      testcommit1071 -> origin/testcommit1071
+ = [up to date]      testcommit1072 -> origin/testcommit1072
+ = [up to date]      testcommit1073 -> origin/testcommit1073
+ = [up to date]      testcommit1074 -> origin/testcommit1074
+ = [up to date]      testcommit1075 -> origin/testcommit1075
+ = [up to date]      testcommit1076 -> origin/testcommit1076
+ = [up to date]      testcommit1077 -> origin/testcommit1077
+ = [up to date]      testcommit1078 -> origin/testcommit1078
+ = [up to date]      testcommit1079 -> origin/testcommit1079
+ = [up to date]      testcommit108 -> origin/testcommit108
+ = [up to date]      testcommit1080 -> origin/testcommit1080
+ = [up to date]      testcommit1081 -> origin/testcommit1081
+ = [up to date]      testcommit1082 -> origin/testcommit1082
+ = [up to date]      testcommit1083 -> origin/testcommit1083
+ = [up to date]      testcommit1084 -> origin/testcommit1084
+ = [up to date]      testcommit1085 -> origin/testcommit1085
+ = [up to date]      testcommit1086 -> origin/testcommit1086
+ = [up to date]      testcommit1087 -> origin/testcommit1087
+ = [up to date]      testcommit1088 -> origin/testcommit1088
+ = [up to date]      testcommit1089 -> origin/testcommit1089
+ = [up to date]      testcommit109 -> origin/testcommit109
+ = [up to date]      testcommit1090 -> origin/testcommit1090
+ = [up to date]      testcommit1091 -> origin/testcommit1091
+ = [up to date]      testcommit1092 -> origin/testcommit1092
+ = [up to date]      testcommit1093 -> origin/testcommit1093
+ = [up to date]      testcommit1094 -> origin/testcommit1094
+ = [up to date]      testcommit1095 -> origin/testcommit1095
+ = [up to date]      testcommit1096 -> origin/testcommit1096
+ = [up to date]      testcommit1097 -> origin/testcommit1097
+ = [up to date]      testcommit1098 -> origin/testcommit1098
+ = [up to date]      testcommit1099 -> origin/testcommit1099
+ = [up to date]      testcommit11 -> origin/testcommit11
+ = [up to date]      testcommit110 -> origin/testcommit110
+ = [up to date]      testcommit1100 -> origin/testcommit1100
+ = [up to date]      testcommit1101 -> origin/testcommit1101
+ = [up to date]      testcommit1102 -> origin/testcommit1102
+ = [up to date]      testcommit1103 -> origin/testcommit1103
+ = [up to date]      testcommit1104 -> origin/testcommit1104
+ = [up to date]      testcommit1105 -> origin/testcommit1105
+ = [up to date]      testcommit1106 -> origin/testcommit1106
+ = [up to date]      testcommit1107 -> origin/testcommit1107
+ = [up to date]      testcommit1108 -> origin/testcommit1108
+ = [up to date]      testcommit1109 -> origin/testcommit1109
+ = [up to date]      testcommit111 -> origin/testcommit111
+ = [up to date]      testcommit1110 -> origin/testcommit1110
+ = [up to date]      testcommit1111 -> origin/testcommit1111
+ = [up to date]      testcommit1112 -> origin/testcommit1112
+ = [up to date]      testcommit1113 -> origin/testcommit1113
+ = [up to date]      testcommit1114 -> origin/testcommit1114
+ = [up to date]      testcommit1115 -> origin/testcommit1115
+ = [up to date]      testcommit1116 -> origin/testcommit1116
+ = [up to date]      testcommit1117 -> origin/testcommit1117
+ = [up to date]      testcommit1118 -> origin/testcommit1118
+ = [up to date]      testcommit1119 -> origin/testcommit1119
+ = [up to date]      testcommit112 -> origin/testcommit112
+ = [up to date]      testcommit1120 -> origin/testcommit1120
+ = [up to date]      testcommit1121 -> origin/testcommit1121
+ = [up to date]      testcommit1122 -> origin/testcommit1122
+ = [up to date]      testcommit1123 -> origin/testcommit1123
+ = [up to date]      testcommit1124 -> origin/testcommit1124
+ = [up to date]      testcommit1125 -> origin/testcommit1125
+ = [up to date]      testcommit1126 -> origin/testcommit1126
+ = [up to date]      testcommit1127 -> origin/testcommit1127
+ = [up to date]      testcommit1128 -> origin/testcommit1128
+ = [up to date]      testcommit1129 -> origin/testcommit1129
+ = [up to date]      testcommit113 -> origin/testcommit113
+ = [up to date]      testcommit1130 -> origin/testcommit1130
+ = [up to date]      testcommit1131 -> origin/testcommit1131
+ = [up to date]      testcommit1132 -> origin/testcommit1132
+ = [up to date]      testcommit1133 -> origin/testcommit1133
+ = [up to date]      testcommit1134 -> origin/testcommit1134
+ = [up to date]      testcommit1135 -> origin/testcommit1135
+ = [up to date]      testcommit1136 -> origin/testcommit1136
+ = [up to date]      testcommit1137 -> origin/testcommit1137
+ = [up to date]      testcommit1138 -> origin/testcommit1138
+ = [up to date]      testcommit1139 -> origin/testcommit1139
+ = [up to date]      testcommit114 -> origin/testcommit114
+ = [up to date]      testcommit1140 -> origin/testcommit1140
+ = [up to date]      testcommit1141 -> origin/testcommit1141
+ = [up to date]      testcommit1142 -> origin/testcommit1142
+ = [up to date]      testcommit1143 -> origin/testcommit1143
+ = [up to date]      testcommit1144 -> origin/testcommit1144
+ = [up to date]      testcommit1145 -> origin/testcommit1145
+ = [up to date]      testcommit1146 -> origin/testcommit1146
+ = [up to date]      testcommit1147 -> origin/testcommit1147
+ = [up to date]      testcommit1148 -> origin/testcommit1148
+ = [up to date]      testcommit1149 -> origin/testcommit1149
+ = [up to date]      testcommit115 -> origin/testcommit115
+ = [up to date]      testcommit1150 -> origin/testcommit1150
+ = [up to date]      testcommit1151 -> origin/testcommit1151
+ = [up to date]      testcommit1152 -> origin/testcommit1152
+ = [up to date]      testcommit1153 -> origin/testcommit1153
+ = [up to date]      testcommit1154 -> origin/testcommit1154
+ = [up to date]      testcommit1155 -> origin/testcommit1155
+ = [up to date]      testcommit1156 -> origin/testcommit1156
+ = [up to date]      testcommit1157 -> origin/testcommit1157
+ = [up to date]      testcommit1158 -> origin/testcommit1158
+ = [up to date]      testcommit1159 -> origin/testcommit1159
+ = [up to date]      testcommit116 -> origin/testcommit116
+ = [up to date]      testcommit1160 -> origin/testcommit1160
+ = [up to date]      testcommit1161 -> origin/testcommit1161
+ = [up to date]      testcommit1162 -> origin/testcommit1162
+ = [up to date]      testcommit1163 -> origin/testcommit1163
+ = [up to date]      testcommit1164 -> origin/testcommit1164
+ = [up to date]      testcommit1165 -> origin/testcommit1165
+ = [up to date]      testcommit1166 -> origin/testcommit1166
+ = [up to date]      testcommit1167 -> origin/testcommit1167
+ = [up to date]      testcommit1168 -> origin/testcommit1168
+ = [up to date]      testcommit1169 -> origin/testcommit1169
+ = [up to date]      testcommit117 -> origin/testcommit117
+ = [up to date]      testcommit1170 -> origin/testcommit1170
+ = [up to date]      testcommit1171 -> origin/testcommit1171
+ = [up to date]      testcommit1172 -> origin/testcommit1172
+ = [up to date]      testcommit1173 -> origin/testcommit1173
+ = [up to date]      testcommit1174 -> origin/testcommit1174
+ = [up to date]      testcommit1175 -> origin/testcommit1175
+ = [up to date]      testcommit1176 -> origin/testcommit1176
+ = [up to date]      testcommit1177 -> origin/testcommit1177
+ = [up to date]      testcommit1178 -> origin/testcommit1178
+ = [up to date]      testcommit1179 -> origin/testcommit1179
+ = [up to date]      testcommit118 -> origin/testcommit118
+ = [up to date]      testcommit1180 -> origin/testcommit1180
+ = [up to date]      testcommit1181 -> origin/testcommit1181
+ = [up to date]      testcommit1182 -> origin/testcommit1182
+ = [up to date]      testcommit1183 -> origin/testcommit1183
+ = [up to date]      testcommit1184 -> origin/testcommit1184
+ = [up to date]      testcommit1185 -> origin/testcommit1185
+ = [up to date]      testcommit1186 -> origin/testcommit1186
+ = [up to date]      testcommit1187 -> origin/testcommit1187
+ = [up to date]      testcommit1188 -> origin/testcommit1188
+ = [up to date]      testcommit1189 -> origin/testcommit1189
+ = [up to date]      testcommit119 -> origin/testcommit119
+ = [up to date]      testcommit1190 -> origin/testcommit1190
+ = [up to date]      testcommit1191 -> origin/testcommit1191
+ = [up to date]      testcommit1192 -> origin/testcommit1192
+ = [up to date]      testcommit1193 -> origin/testcommit1193
+ = [up to date]      testcommit1194 -> origin/testcommit1194
+ = [up to date]      testcommit1195 -> origin/testcommit1195
+ = [up to date]      testcommit1196 -> origin/testcommit1196
+ = [up to date]      testcommit1197 -> origin/testcommit1197
+ = [up to date]      testcommit1198 -> origin/testcommit1198
+ = [up to date]      testcommit1199 -> origin/testcommit1199
+ = [up to date]      testcommit12 -> origin/testcommit12
+ = [up to date]      testcommit120 -> origin/testcommit120
+ = [up to date]      testcommit1200 -> origin/testcommit1200
+ = [up to date]      testcommit1201 -> origin/testcommit1201
+ = [up to date]      testcommit1202 -> origin/testcommit1202
+ = [up to date]      testcommit1203 -> origin/testcommit1203
+ = [up to date]      testcommit1204 -> origin/testcommit1204
+ = [up to date]      testcommit1205 -> origin/testcommit1205
+ = [up to date]      testcommit1206 -> origin/testcommit1206
+ = [up to date]      testcommit1207 -> origin/testcommit1207
+ = [up to date]      testcommit1208 -> origin/testcommit1208
+ = [up to date]      testcommit1209 -> origin/testcommit1209
+ = [up to date]      testcommit121 -> origin/testcommit121
+ = [up to date]      testcommit1210 -> origin/testcommit1210
+ = [up to date]      testcommit1211 -> origin/testcommit1211
+ = [up to date]      testcommit1212 -> origin/testcommit1212
+ = [up to date]      testcommit1213 -> origin/testcommit1213
+ = [up to date]      testcommit1214 -> origin/testcommit1214
+ = [up to date]      testcommit1215 -> origin/testcommit1215
+ = [up to date]      testcommit1216 -> origin/testcommit1216
+ = [up to date]      testcommit1217 -> origin/testcommit1217
+ = [up to date]      testcommit1218 -> origin/testcommit1218
+ = [up to date]      testcommit1219 -> origin/testcommit1219
+ = [up to date]      testcommit122 -> origin/testcommit122
+ = [up to date]      testcommit1220 -> origin/testcommit1220
+ = [up to date]      testcommit1221 -> origin/testcommit1221
+ = [up to date]      testcommit1222 -> origin/testcommit1222
+ = [up to date]      testcommit1223 -> origin/testcommit1223
+ = [up to date]      testcommit1224 -> origin/testcommit1224
+ = [up to date]      testcommit1225 -> origin/testcommit1225
+ = [up to date]      testcommit1226 -> origin/testcommit1226
+ = [up to date]      testcommit1227 -> origin/testcommit1227
+ = [up to date]      testcommit1228 -> origin/testcommit1228
+ = [up to date]      testcommit1229 -> origin/testcommit1229
+ = [up to date]      testcommit123 -> origin/testcommit123
+ = [up to date]      testcommit1230 -> origin/testcommit1230
+ = [up to date]      testcommit1231 -> origin/testcommit1231
+ = [up to date]      testcommit1232 -> origin/testcommit1232
+ = [up to date]      testcommit1233 -> origin/testcommit1233
+ = [up to date]      testcommit1234 -> origin/testcommit1234
+ = [up to date]      testcommit1235 -> origin/testcommit1235
+ = [up to date]      testcommit1236 -> origin/testcommit1236
+ = [up to date]      testcommit1237 -> origin/testcommit1237
+ = [up to date]      testcommit1238 -> origin/testcommit1238
+ = [up to date]      testcommit1239 -> origin/testcommit1239
+ = [up to date]      testcommit124 -> origin/testcommit124
+ = [up to date]      testcommit1240 -> origin/testcommit1240
+ = [up to date]      testcommit1241 -> origin/testcommit1241
+ = [up to date]      testcommit1242 -> origin/testcommit1242
+ = [up to date]      testcommit1243 -> origin/testcommit1243
+ = [up to date]      testcommit1244 -> origin/testcommit1244
+ = [up to date]      testcommit1245 -> origin/testcommit1245
+ = [up to date]      testcommit1246 -> origin/testcommit1246
+ = [up to date]      testcommit1247 -> origin/testcommit1247
+ = [up to date]      testcommit1248 -> origin/testcommit1248
+ = [up to date]      testcommit1249 -> origin/testcommit1249
+ = [up to date]      testcommit125 -> origin/testcommit125
+ = [up to date]      testcommit1250 -> origin/testcommit1250
+ = [up to date]      testcommit1251 -> origin/testcommit1251
+ = [up to date]      testcommit1252 -> origin/testcommit1252
+ = [up to date]      testcommit1253 -> origin/testcommit1253
+ = [up to date]      testcommit1254 -> origin/testcommit1254
+ = [up to date]      testcommit1255 -> origin/testcommit1255
+ = [up to date]      testcommit1256 -> origin/testcommit1256
+ = [up to date]      testcommit1257 -> origin/testcommit1257
+ = [up to date]      testcommit1258 -> origin/testcommit1258
+ = [up to date]      testcommit1259 -> origin/testcommit1259
+ = [up to date]      testcommit126 -> origin/testcommit126
+ = [up to date]      testcommit1260 -> origin/testcommit1260
+ = [up to date]      testcommit1261 -> origin/testcommit1261
+ = [up to date]      testcommit1262 -> origin/testcommit1262
+ = [up to date]      testcommit1263 -> origin/testcommit1263
+ = [up to date]      testcommit1264 -> origin/testcommit1264
+ = [up to date]      testcommit1265 -> origin/testcommit1265
+ = [up to date]      testcommit1266 -> origin/testcommit1266
+ = [up to date]      testcommit1267 -> origin/testcommit1267
+ = [up to date]      testcommit1268 -> origin/testcommit1268
+ = [up to date]      testcommit1269 -> origin/testcommit1269
+ = [up to date]      testcommit127 -> origin/testcommit127
+ = [up to date]      testcommit1270 -> origin/testcommit1270
+ = [up to date]      testcommit1271 -> origin/testcommit1271
+ = [up to date]      testcommit1272 -> origin/testcommit1272
+ = [up to date]      testcommit1273 -> origin/testcommit1273
+ = [up to date]      testcommit1274 -> origin/testcommit1274
+ = [up to date]      testcommit1275 -> origin/testcommit1275
+ = [up to date]      testcommit1276 -> origin/testcommit1276
+ = [up to date]      testcommit1277 -> origin/testcommit1277
+ = [up to date]      testcommit1278 -> origin/testcommit1278
+ = [up to date]      testcommit1279 -> origin/testcommit1279
+ = [up to date]      testcommit128 -> origin/testcommit128
+ = [up to date]      testcommit1280 -> origin/testcommit1280
+ = [up to date]      testcommit1281 -> origin/testcommit1281
+ = [up to date]      testcommit1282 -> origin/testcommit1282
+ = [up to date]      testcommit1283 -> origin/testcommit1283
+ = [up to date]      testcommit1284 -> origin/testcommit1284
+ = [up to date]      testcommit1285 -> origin/testcommit1285
+ = [up to date]      testcommit1286 -> origin/testcommit1286
+ = [up to date]      testcommit1287 -> origin/testcommit1287
+ = [up to date]      testcommit1288 -> origin/testcommit1288
+ = [up to date]      testcommit1289 -> origin/testcommit1289
+ = [up to date]      testcommit129 -> origin/testcommit129
+ = [up to date]      testcommit1290 -> origin/testcommit1290
+ = [up to date]      testcommit1291 -> origin/testcommit1291
+ = [up to date]      testcommit1292 -> origin/testcommit1292
+ = [up to date]      testcommit1293 -> origin/testcommit1293
+ = [up to date]      testcommit1294 -> origin/testcommit1294
+ = [up to date]      testcommit1295 -> origin/testcommit1295
+ = [up to date]      testcommit1296 -> origin/testcommit1296
+ = [up to date]      testcommit1297 -> origin/testcommit1297
+ = [up to date]      testcommit1298 -> origin/testcommit1298
+ = [up to date]      testcommit1299 -> origin/testcommit1299
+ = [up to date]      testcommit13 -> origin/testcommit13
+ = [up to date]      testcommit130 -> origin/testcommit130
+ = [up to date]      testcommit1300 -> origin/testcommit1300
+ = [up to date]      testcommit1301 -> origin/testcommit1301
+ = [up to date]      testcommit1302 -> origin/testcommit1302
+ = [up to date]      testcommit1303 -> origin/testcommit1303
+ = [up to date]      testcommit1304 -> origin/testcommit1304
+ = [up to date]      testcommit1305 -> origin/testcommit1305
+ = [up to date]      testcommit1306 -> origin/testcommit1306
+ = [up to date]      testcommit1307 -> origin/testcommit1307
+ = [up to date]      testcommit1308 -> origin/testcommit1308
+ = [up to date]      testcommit1309 -> origin/testcommit1309
+ = [up to date]      testcommit131 -> origin/testcommit131
+ = [up to date]      testcommit1310 -> origin/testcommit1310
+ = [up to date]      testcommit1311 -> origin/testcommit1311
+ = [up to date]      testcommit1312 -> origin/testcommit1312
+ = [up to date]      testcommit1313 -> origin/testcommit1313
+ = [up to date]      testcommit1314 -> origin/testcommit1314
+ = [up to date]      testcommit1315 -> origin/testcommit1315
+ = [up to date]      testcommit1316 -> origin/testcommit1316
+ = [up to date]      testcommit1317 -> origin/testcommit1317
+ = [up to date]      testcommit1318 -> origin/testcommit1318
+ = [up to date]      testcommit1319 -> origin/testcommit1319
+ = [up to date]      testcommit132 -> origin/testcommit132
+ = [up to date]      testcommit1320 -> origin/testcommit1320
+ = [up to date]      testcommit1321 -> origin/testcommit1321
+ = [up to date]      testcommit1322 -> origin/testcommit1322
+ = [up to date]      testcommit1323 -> origin/testcommit1323
+ = [up to date]      testcommit1324 -> origin/testcommit1324
+ = [up to date]      testcommit1325 -> origin/testcommit1325
+ = [up to date]      testcommit1326 -> origin/testcommit1326
+ = [up to date]      testcommit1327 -> origin/testcommit1327
+ = [up to date]      testcommit1328 -> origin/testcommit1328
+ = [up to date]      testcommit1329 -> origin/testcommit1329
+ = [up to date]      testcommit133 -> origin/testcommit133
+ = [up to date]      testcommit1330 -> origin/testcommit1330
+ = [up to date]      testcommit1331 -> origin/testcommit1331
+ = [up to date]      testcommit1332 -> origin/testcommit1332
+ = [up to date]      testcommit1333 -> origin/testcommit1333
+ = [up to date]      testcommit1334 -> origin/testcommit1334
+ = [up to date]      testcommit1335 -> origin/testcommit1335
+ = [up to date]      testcommit1336 -> origin/testcommit1336
+ = [up to date]      testcommit1337 -> origin/testcommit1337
+ = [up to date]      testcommit1338 -> origin/testcommit1338
+ = [up to date]      testcommit1339 -> origin/testcommit1339
+ = [up to date]      testcommit134 -> origin/testcommit134
+ = [up to date]      testcommit1340 -> origin/testcommit1340
+ = [up to date]      testcommit1341 -> origin/testcommit1341
+ = [up to date]      testcommit1342 -> origin/testcommit1342
+ = [up to date]      testcommit1343 -> origin/testcommit1343
+ = [up to date]      testcommit1344 -> origin/testcommit1344
+ = [up to date]      testcommit1345 -> origin/testcommit1345
+ = [up to date]      testcommit1346 -> origin/testcommit1346
+ = [up to date]      testcommit1347 -> origin/testcommit1347
+ = [up to date]      testcommit1348 -> origin/testcommit1348
+ = [up to date]      testcommit1349 -> origin/testcommit1349
+ = [up to date]      testcommit135 -> origin/testcommit135
+ = [up to date]      testcommit1350 -> origin/testcommit1350
+ = [up to date]      testcommit1351 -> origin/testcommit1351
+ = [up to date]      testcommit1352 -> origin/testcommit1352
+ = [up to date]      testcommit1353 -> origin/testcommit1353
+ = [up to date]      testcommit1354 -> origin/testcommit1354
+ = [up to date]      testcommit1355 -> origin/testcommit1355
+ = [up to date]      testcommit1356 -> origin/testcommit1356
+ = [up to date]      testcommit1357 -> origin/testcommit1357
+ = [up to date]      testcommit1358 -> origin/testcommit1358
+ = [up to date]      testcommit1359 -> origin/testcommit1359
+ = [up to date]      testcommit136 -> origin/testcommit136
+ = [up to date]      testcommit1360 -> origin/testcommit1360
+ = [up to date]      testcommit1361 -> origin/testcommit1361
+ = [up to date]      testcommit1362 -> origin/testcommit1362
+ = [up to date]      testcommit1363 -> origin/testcommit1363
+ = [up to date]      testcommit1364 -> origin/testcommit1364
+ = [up to date]      testcommit1365 -> origin/testcommit1365
+ = [up to date]      testcommit1366 -> origin/testcommit1366
+ = [up to date]      testcommit1367 -> origin/testcommit1367
+ = [up to date]      testcommit1368 -> origin/testcommit1368
+ = [up to date]      testcommit1369 -> origin/testcommit1369
+ = [up to date]      testcommit137 -> origin/testcommit137
+ = [up to date]      testcommit1370 -> origin/testcommit1370
+ = [up to date]      testcommit1371 -> origin/testcommit1371
+ = [up to date]      testcommit1372 -> origin/testcommit1372
+ = [up to date]      testcommit1373 -> origin/testcommit1373
+ = [up to date]      testcommit1374 -> origin/testcommit1374
+ = [up to date]      testcommit1375 -> origin/testcommit1375
+ = [up to date]      testcommit1376 -> origin/testcommit1376
+ = [up to date]      testcommit1377 -> origin/testcommit1377
+ = [up to date]      testcommit1378 -> origin/testcommit1378
+ = [up to date]      testcommit1379 -> origin/testcommit1379
+ = [up to date]      testcommit138 -> origin/testcommit138
+ = [up to date]      testcommit1380 -> origin/testcommit1380
+ = [up to date]      testcommit1381 -> origin/testcommit1381
+ = [up to date]      testcommit1382 -> origin/testcommit1382
+ = [up to date]      testcommit1383 -> origin/testcommit1383
+ = [up to date]      testcommit1384 -> origin/testcommit1384
+ = [up to date]      testcommit1385 -> origin/testcommit1385
+ = [up to date]      testcommit1386 -> origin/testcommit1386
+ = [up to date]      testcommit1387 -> origin/testcommit1387
+ = [up to date]      testcommit1388 -> origin/testcommit1388
+ = [up to date]      testcommit1389 -> origin/testcommit1389
+ = [up to date]      testcommit139 -> origin/testcommit139
+ = [up to date]      testcommit1390 -> origin/testcommit1390
+ = [up to date]      testcommit1391 -> origin/testcommit1391
+ = [up to date]      testcommit1392 -> origin/testcommit1392
+ = [up to date]      testcommit1393 -> origin/testcommit1393
+ = [up to date]      testcommit1394 -> origin/testcommit1394
+ = [up to date]      testcommit1395 -> origin/testcommit1395
+ = [up to date]      testcommit1396 -> origin/testcommit1396
+ = [up to date]      testcommit1397 -> origin/testcommit1397
+ = [up to date]      testcommit1398 -> origin/testcommit1398
+ = [up to date]      testcommit1399 -> origin/testcommit1399
+ = [up to date]      testcommit14 -> origin/testcommit14
+ = [up to date]      testcommit140 -> origin/testcommit140
+ = [up to date]      testcommit1400 -> origin/testcommit1400
+ = [up to date]      testcommit1401 -> origin/testcommit1401
+ = [up to date]      testcommit1402 -> origin/testcommit1402
+ = [up to date]      testcommit1403 -> origin/testcommit1403
+ = [up to date]      testcommit1404 -> origin/testcommit1404
+ = [up to date]      testcommit1405 -> origin/testcommit1405
+ = [up to date]      testcommit1406 -> origin/testcommit1406
+ = [up to date]      testcommit1407 -> origin/testcommit1407
+ = [up to date]      testcommit1408 -> origin/testcommit1408
+ = [up to date]      testcommit1409 -> origin/testcommit1409
+ = [up to date]      testcommit141 -> origin/testcommit141
+ = [up to date]      testcommit1410 -> origin/testcommit1410
+ = [up to date]      testcommit1411 -> origin/testcommit1411
+ = [up to date]      testcommit1412 -> origin/testcommit1412
+ = [up to date]      testcommit1413 -> origin/testcommit1413
+ = [up to date]      testcommit1414 -> origin/testcommit1414
+ = [up to date]      testcommit1415 -> origin/testcommit1415
+ = [up to date]      testcommit1416 -> origin/testcommit1416
+ = [up to date]      testcommit1417 -> origin/testcommit1417
+ = [up to date]      testcommit1418 -> origin/testcommit1418
+ = [up to date]      testcommit1419 -> origin/testcommit1419
+ = [up to date]      testcommit142 -> origin/testcommit142
+ = [up to date]      testcommit1420 -> origin/testcommit1420
+ = [up to date]      testcommit1421 -> origin/testcommit1421
+ = [up to date]      testcommit1422 -> origin/testcommit1422
+ = [up to date]      testcommit1423 -> origin/testcommit1423
+ = [up to date]      testcommit1424 -> origin/testcommit1424
+ = [up to date]      testcommit1425 -> origin/testcommit1425
+ = [up to date]      testcommit1426 -> origin/testcommit1426
+ = [up to date]      testcommit1427 -> origin/testcommit1427
+ = [up to date]      testcommit1428 -> origin/testcommit1428
+ = [up to date]      testcommit1429 -> origin/testcommit1429
+ = [up to date]      testcommit143 -> origin/testcommit143
+ = [up to date]      testcommit1430 -> origin/testcommit1430
+ = [up to date]      testcommit1431 -> origin/testcommit1431
+ = [up to date]      testcommit1432 -> origin/testcommit1432
+ = [up to date]      testcommit1433 -> origin/testcommit1433
+ = [up to date]      testcommit1434 -> origin/testcommit1434
+ = [up to date]      testcommit1435 -> origin/testcommit1435
+ = [up to date]      testcommit1436 -> origin/testcommit1436
+ = [up to date]      testcommit1437 -> origin/testcommit1437
+ = [up to date]      testcommit1438 -> origin/testcommit1438
+ = [up to date]      testcommit1439 -> origin/testcommit1439
+ = [up to date]      testcommit144 -> origin/testcommit144
+ = [up to date]      testcommit1440 -> origin/testcommit1440
+ = [up to date]      testcommit1441 -> origin/testcommit1441
+ = [up to date]      testcommit1442 -> origin/testcommit1442
+ = [up to date]      testcommit1443 -> origin/testcommit1443
+ = [up to date]      testcommit1444 -> origin/testcommit1444
+ = [up to date]      testcommit1445 -> origin/testcommit1445
+ = [up to date]      testcommit1446 -> origin/testcommit1446
+ = [up to date]      testcommit1447 -> origin/testcommit1447
+ = [up to date]      testcommit1448 -> origin/testcommit1448
+ = [up to date]      testcommit1449 -> origin/testcommit1449
+ = [up to date]      testcommit145 -> origin/testcommit145
+ = [up to date]      testcommit1450 -> origin/testcommit1450
+ = [up to date]      testcommit1451 -> origin/testcommit1451
+ = [up to date]      testcommit1452 -> origin/testcommit1452
+ = [up to date]      testcommit1453 -> origin/testcommit1453
+ = [up to date]      testcommit1454 -> origin/testcommit1454
+ = [up to date]      testcommit1455 -> origin/testcommit1455
+ = [up to date]      testcommit1456 -> origin/testcommit1456
+ = [up to date]      testcommit1457 -> origin/testcommit1457
+ = [up to date]      testcommit1458 -> origin/testcommit1458
+ = [up to date]      testcommit1459 -> origin/testcommit1459
+ = [up to date]      testcommit146 -> origin/testcommit146
+ = [up to date]      testcommit1460 -> origin/testcommit1460
+ = [up to date]      testcommit1461 -> origin/testcommit1461
+ = [up to date]      testcommit1462 -> origin/testcommit1462
+ = [up to date]      testcommit1463 -> origin/testcommit1463
+ = [up to date]      testcommit1464 -> origin/testcommit1464
+ = [up to date]      testcommit1465 -> origin/testcommit1465
+ = [up to date]      testcommit1466 -> origin/testcommit1466
+ = [up to date]      testcommit1467 -> origin/testcommit1467
+ = [up to date]      testcommit1468 -> origin/testcommit1468
+ = [up to date]      testcommit1469 -> origin/testcommit1469
+ = [up to date]      testcommit147 -> origin/testcommit147
+ = [up to date]      testcommit1470 -> origin/testcommit1470
+ = [up to date]      testcommit1471 -> origin/testcommit1471
+ = [up to date]      testcommit1472 -> origin/testcommit1472
+ = [up to date]      testcommit1473 -> origin/testcommit1473
+ = [up to date]      testcommit1474 -> origin/testcommit1474
+ = [up to date]      testcommit1475 -> origin/testcommit1475
+ = [up to date]      testcommit1476 -> origin/testcommit1476
+ = [up to date]      testcommit1477 -> origin/testcommit1477
+ = [up to date]      testcommit1478 -> origin/testcommit1478
+ = [up to date]      testcommit1479 -> origin/testcommit1479
+ = [up to date]      testcommit148 -> origin/testcommit148
+ = [up to date]      testcommit1480 -> origin/testcommit1480
+ = [up to date]      testcommit1481 -> origin/testcommit1481
+ = [up to date]      testcommit1482 -> origin/testcommit1482
+ = [up to date]      testcommit1483 -> origin/testcommit1483
+ = [up to date]      testcommit1484 -> origin/testcommit1484
+ = [up to date]      testcommit1485 -> origin/testcommit1485
+ = [up to date]      testcommit1486 -> origin/testcommit1486
+ = [up to date]      testcommit1487 -> origin/testcommit1487
+ = [up to date]      testcommit1488 -> origin/testcommit1488
+ = [up to date]      testcommit1489 -> origin/testcommit1489
+ = [up to date]      testcommit149 -> origin/testcommit149
+ = [up to date]      testcommit1490 -> origin/testcommit1490
+ = [up to date]      testcommit1491 -> origin/testcommit1491
+ = [up to date]      testcommit1492 -> origin/testcommit1492
+ = [up to date]      testcommit1493 -> origin/testcommit1493
+ = [up to date]      testcommit1494 -> origin/testcommit1494
+ = [up to date]      testcommit1495 -> origin/testcommit1495
+ = [up to date]      testcommit1496 -> origin/testcommit1496
+ = [up to date]      testcommit1497 -> origin/testcommit1497
+ = [up to date]      testcommit1498 -> origin/testcommit1498
+ = [up to date]      testcommit1499 -> origin/testcommit1499
+ = [up to date]      testcommit15 -> origin/testcommit15
+ = [up to date]      testcommit150 -> origin/testcommit150
+ = [up to date]      testcommit1500 -> origin/testcommit1500
+ = [up to date]      testcommit1501 -> origin/testcommit1501
+ = [up to date]      testcommit1502 -> origin/testcommit1502
+ = [up to date]      testcommit1503 -> origin/testcommit1503
+ = [up to date]      testcommit1504 -> origin/testcommit1504
+ = [up to date]      testcommit1505 -> origin/testcommit1505
+ = [up to date]      testcommit1506 -> origin/testcommit1506
+ = [up to date]      testcommit1507 -> origin/testcommit1507
+ = [up to date]      testcommit1508 -> origin/testcommit1508
+ = [up to date]      testcommit1509 -> origin/testcommit1509
+ = [up to date]      testcommit151 -> origin/testcommit151
+ = [up to date]      testcommit1510 -> origin/testcommit1510
+ = [up to date]      testcommit1511 -> origin/testcommit1511
+ = [up to date]      testcommit1512 -> origin/testcommit1512
+ = [up to date]      testcommit1513 -> origin/testcommit1513
+ = [up to date]      testcommit1514 -> origin/testcommit1514
+ = [up to date]      testcommit1515 -> origin/testcommit1515
+ = [up to date]      testcommit1516 -> origin/testcommit1516
+ = [up to date]      testcommit1517 -> origin/testcommit1517
+ = [up to date]      testcommit1518 -> origin/testcommit1518
+ = [up to date]      testcommit1519 -> origin/testcommit1519
+ = [up to date]      testcommit152 -> origin/testcommit152
+ = [up to date]      testcommit1520 -> origin/testcommit1520
+ = [up to date]      testcommit1521 -> origin/testcommit1521
+ = [up to date]      testcommit1522 -> origin/testcommit1522
+ = [up to date]      testcommit1523 -> origin/testcommit1523
+ = [up to date]      testcommit1524 -> origin/testcommit1524
+ = [up to date]      testcommit1525 -> origin/testcommit1525
+ = [up to date]      testcommit1526 -> origin/testcommit1526
+ = [up to date]      testcommit1527 -> origin/testcommit1527
+ = [up to date]      testcommit1528 -> origin/testcommit1528
+ = [up to date]      testcommit1529 -> origin/testcommit1529
+ = [up to date]      testcommit153 -> origin/testcommit153
+ = [up to date]      testcommit1530 -> origin/testcommit1530
+ = [up to date]      testcommit1531 -> origin/testcommit1531
+ = [up to date]      testcommit1532 -> origin/testcommit1532
+ = [up to date]      testcommit1533 -> origin/testcommit1533
+ = [up to date]      testcommit1534 -> origin/testcommit1534
+ = [up to date]      testcommit1535 -> origin/testcommit1535
+ = [up to date]      testcommit1536 -> origin/testcommit1536
+ = [up to date]      testcommit1537 -> origin/testcommit1537
+ = [up to date]      testcommit1538 -> origin/testcommit1538
+ = [up to date]      testcommit1539 -> origin/testcommit1539
+ = [up to date]      testcommit154 -> origin/testcommit154
+ = [up to date]      testcommit1540 -> origin/testcommit1540
+ = [up to date]      testcommit1541 -> origin/testcommit1541
+ = [up to date]      testcommit1542 -> origin/testcommit1542
+ = [up to date]      testcommit1543 -> origin/testcommit1543
+ = [up to date]      testcommit1544 -> origin/testcommit1544
+ = [up to date]      testcommit1545 -> origin/testcommit1545
+ = [up to date]      testcommit1546 -> origin/testcommit1546
+ = [up to date]      testcommit1547 -> origin/testcommit1547
+ = [up to date]      testcommit1548 -> origin/testcommit1548
+ = [up to date]      testcommit1549 -> origin/testcommit1549
+ = [up to date]      testcommit155 -> origin/testcommit155
+ = [up to date]      testcommit1550 -> origin/testcommit1550
+ = [up to date]      testcommit1551 -> origin/testcommit1551
+ = [up to date]      testcommit1552 -> origin/testcommit1552
+ = [up to date]      testcommit1553 -> origin/testcommit1553
+ = [up to date]      testcommit1554 -> origin/testcommit1554
+ = [up to date]      testcommit1555 -> origin/testcommit1555
+ = [up to date]      testcommit1556 -> origin/testcommit1556
+ = [up to date]      testcommit1557 -> origin/testcommit1557
+ = [up to date]      testcommit1558 -> origin/testcommit1558
+ = [up to date]      testcommit1559 -> origin/testcommit1559
+ = [up to date]      testcommit156 -> origin/testcommit156
+ = [up to date]      testcommit1560 -> origin/testcommit1560
+ = [up to date]      testcommit1561 -> origin/testcommit1561
+ = [up to date]      testcommit1562 -> origin/testcommit1562
+ = [up to date]      testcommit1563 -> origin/testcommit1563
+ = [up to date]      testcommit1564 -> origin/testcommit1564
+ = [up to date]      testcommit1565 -> origin/testcommit1565
+ = [up to date]      testcommit1566 -> origin/testcommit1566
+ = [up to date]      testcommit1567 -> origin/testcommit1567
+ = [up to date]      testcommit1568 -> origin/testcommit1568
+ = [up to date]      testcommit1569 -> origin/testcommit1569
+ = [up to date]      testcommit157 -> origin/testcommit157
+ = [up to date]      testcommit1570 -> origin/testcommit1570
+ = [up to date]      testcommit1571 -> origin/testcommit1571
+ = [up to date]      testcommit1572 -> origin/testcommit1572
+ = [up to date]      testcommit1573 -> origin/testcommit1573
+ = [up to date]      testcommit1574 -> origin/testcommit1574
+ = [up to date]      testcommit1575 -> origin/testcommit1575
+ = [up to date]      testcommit1576 -> origin/testcommit1576
+ = [up to date]      testcommit1577 -> origin/testcommit1577
+ = [up to date]      testcommit1578 -> origin/testcommit1578
+ = [up to date]      testcommit1579 -> origin/testcommit1579
+ = [up to date]      testcommit158 -> origin/testcommit158
+ = [up to date]      testcommit1580 -> origin/testcommit1580
+ = [up to date]      testcommit1581 -> origin/testcommit1581
+ = [up to date]      testcommit1582 -> origin/testcommit1582
+ = [up to date]      testcommit1583 -> origin/testcommit1583
+ = [up to date]      testcommit1584 -> origin/testcommit1584
+ = [up to date]      testcommit1585 -> origin/testcommit1585
+ = [up to date]      testcommit1586 -> origin/testcommit1586
+ = [up to date]      testcommit1587 -> origin/testcommit1587
+ = [up to date]      testcommit1588 -> origin/testcommit1588
+ = [up to date]      testcommit1589 -> origin/testcommit1589
+ = [up to date]      testcommit159 -> origin/testcommit159
+ = [up to date]      testcommit1590 -> origin/testcommit1590
+ = [up to date]      testcommit1591 -> origin/testcommit1591
+ = [up to date]      testcommit1592 -> origin/testcommit1592
+ = [up to date]      testcommit1593 -> origin/testcommit1593
+ = [up to date]      testcommit1594 -> origin/testcommit1594
+ = [up to date]      testcommit1595 -> origin/testcommit1595
+ = [up to date]      testcommit1596 -> origin/testcommit1596
+ = [up to date]      testcommit1597 -> origin/testcommit1597
+ = [up to date]      testcommit1598 -> origin/testcommit1598
+ = [up to date]      testcommit1599 -> origin/testcommit1599
+ = [up to date]      testcommit16 -> origin/testcommit16
+ = [up to date]      testcommit160 -> origin/testcommit160
+ = [up to date]      testcommit1600 -> origin/testcommit1600
+ = [up to date]      testcommit1601 -> origin/testcommit1601
+ = [up to date]      testcommit1602 -> origin/testcommit1602
+ = [up to date]      testcommit1603 -> origin/testcommit1603
+ = [up to date]      testcommit1604 -> origin/testcommit1604
+ = [up to date]      testcommit1605 -> origin/testcommit1605
+ = [up to date]      testcommit1606 -> origin/testcommit1606
+ = [up to date]      testcommit1607 -> origin/testcommit1607
+ = [up to date]      testcommit1608 -> origin/testcommit1608
+ = [up to date]      testcommit1609 -> origin/testcommit1609
+ = [up to date]      testcommit161 -> origin/testcommit161
+ = [up to date]      testcommit1610 -> origin/testcommit1610
+ = [up to date]      testcommit1611 -> origin/testcommit1611
+ = [up to date]      testcommit1612 -> origin/testcommit1612
+ = [up to date]      testcommit1613 -> origin/testcommit1613
+ = [up to date]      testcommit1614 -> origin/testcommit1614
+ = [up to date]      testcommit1615 -> origin/testcommit1615
+ = [up to date]      testcommit1616 -> origin/testcommit1616
+ = [up to date]      testcommit1617 -> origin/testcommit1617
+ = [up to date]      testcommit1618 -> origin/testcommit1618
+ = [up to date]      testcommit1619 -> origin/testcommit1619
+ = [up to date]      testcommit162 -> origin/testcommit162
+ = [up to date]      testcommit1620 -> origin/testcommit1620
+ = [up to date]      testcommit1621 -> origin/testcommit1621
+ = [up to date]      testcommit1622 -> origin/testcommit1622
+ = [up to date]      testcommit1623 -> origin/testcommit1623
+ = [up to date]      testcommit1624 -> origin/testcommit1624
+ = [up to date]      testcommit1625 -> origin/testcommit1625
+ = [up to date]      testcommit1626 -> origin/testcommit1626
+ = [up to date]      testcommit1627 -> origin/testcommit1627
+ = [up to date]      testcommit1628 -> origin/testcommit1628
+ = [up to date]      testcommit1629 -> origin/testcommit1629
+ = [up to date]      testcommit163 -> origin/testcommit163
+ = [up to date]      testcommit1630 -> origin/testcommit1630
+ = [up to date]      testcommit1631 -> origin/testcommit1631
+ = [up to date]      testcommit1632 -> origin/testcommit1632
+ = [up to date]      testcommit1633 -> origin/testcommit1633
+ = [up to date]      testcommit1634 -> origin/testcommit1634
+ = [up to date]      testcommit1635 -> origin/testcommit1635
+ = [up to date]      testcommit1636 -> origin/testcommit1636
+ = [up to date]      testcommit1637 -> origin/testcommit1637
+ = [up to date]      testcommit1638 -> origin/testcommit1638
+ = [up to date]      testcommit1639 -> origin/testcommit1639
+ = [up to date]      testcommit164 -> origin/testcommit164
+ = [up to date]      testcommit1640 -> origin/testcommit1640
+ = [up to date]      testcommit1641 -> origin/testcommit1641
+ = [up to date]      testcommit1642 -> origin/testcommit1642
+ = [up to date]      testcommit1643 -> origin/testcommit1643
+ = [up to date]      testcommit1644 -> origin/testcommit1644
+ = [up to date]      testcommit1645 -> origin/testcommit1645
+ = [up to date]      testcommit1646 -> origin/testcommit1646
+ = [up to date]      testcommit1647 -> origin/testcommit1647
+ = [up to date]      testcommit1648 -> origin/testcommit1648
+ = [up to date]      testcommit1649 -> origin/testcommit1649
+ = [up to date]      testcommit165 -> origin/testcommit165
+ = [up to date]      testcommit1650 -> origin/testcommit1650
+ = [up to date]      testcommit1651 -> origin/testcommit1651
+ = [up to date]      testcommit1652 -> origin/testcommit1652
+ = [up to date]      testcommit1653 -> origin/testcommit1653
+ = [up to date]      testcommit1654 -> origin/testcommit1654
+ = [up to date]      testcommit1655 -> origin/testcommit1655
+ = [up to date]      testcommit1656 -> origin/testcommit1656
+ = [up to date]      testcommit1657 -> origin/testcommit1657
+ = [up to date]      testcommit1658 -> origin/testcommit1658
+ = [up to date]      testcommit1659 -> origin/testcommit1659
+ = [up to date]      testcommit166 -> origin/testcommit166
+ = [up to date]      testcommit1660 -> origin/testcommit1660
+ = [up to date]      testcommit1661 -> origin/testcommit1661
+ = [up to date]      testcommit1662 -> origin/testcommit1662
+ = [up to date]      testcommit1663 -> origin/testcommit1663
+ = [up to date]      testcommit1664 -> origin/testcommit1664
+ = [up to date]      testcommit1665 -> origin/testcommit1665
+ = [up to date]      testcommit1666 -> origin/testcommit1666
+ = [up to date]      testcommit1667 -> origin/testcommit1667
+ = [up to date]      testcommit1668 -> origin/testcommit1668
+ = [up to date]      testcommit1669 -> origin/testcommit1669
+ = [up to date]      testcommit167 -> origin/testcommit167
+ = [up to date]      testcommit1670 -> origin/testcommit1670
+ = [up to date]      testcommit1671 -> origin/testcommit1671
+ = [up to date]      testcommit1672 -> origin/testcommit1672
+ = [up to date]      testcommit1673 -> origin/testcommit1673
+ = [up to date]      testcommit1674 -> origin/testcommit1674
+ = [up to date]      testcommit1675 -> origin/testcommit1675
+ = [up to date]      testcommit1676 -> origin/testcommit1676
+ = [up to date]      testcommit1677 -> origin/testcommit1677
+ = [up to date]      testcommit1678 -> origin/testcommit1678
+ = [up to date]      testcommit1679 -> origin/testcommit1679
+ = [up to date]      testcommit168 -> origin/testcommit168
+ = [up to date]      testcommit1680 -> origin/testcommit1680
+ = [up to date]      testcommit1681 -> origin/testcommit1681
+ = [up to date]      testcommit1682 -> origin/testcommit1682
+ = [up to date]      testcommit1683 -> origin/testcommit1683
+ = [up to date]      testcommit1684 -> origin/testcommit1684
+ = [up to date]      testcommit1685 -> origin/testcommit1685
+ = [up to date]      testcommit1686 -> origin/testcommit1686
+ = [up to date]      testcommit1687 -> origin/testcommit1687
+ = [up to date]      testcommit1688 -> origin/testcommit1688
+ = [up to date]      testcommit1689 -> origin/testcommit1689
+ = [up to date]      testcommit169 -> origin/testcommit169
+ = [up to date]      testcommit1690 -> origin/testcommit1690
+ = [up to date]      testcommit1691 -> origin/testcommit1691
+ = [up to date]      testcommit1692 -> origin/testcommit1692
+ = [up to date]      testcommit1693 -> origin/testcommit1693
+ = [up to date]      testcommit1694 -> origin/testcommit1694
+ = [up to date]      testcommit1695 -> origin/testcommit1695
+ = [up to date]      testcommit1696 -> origin/testcommit1696
+ = [up to date]      testcommit1697 -> origin/testcommit1697
+ = [up to date]      testcommit1698 -> origin/testcommit1698
+ = [up to date]      testcommit1699 -> origin/testcommit1699
+ = [up to date]      testcommit17 -> origin/testcommit17
+ = [up to date]      testcommit170 -> origin/testcommit170
+ = [up to date]      testcommit1700 -> origin/testcommit1700
+ = [up to date]      testcommit1701 -> origin/testcommit1701
+ = [up to date]      testcommit1702 -> origin/testcommit1702
+ = [up to date]      testcommit1703 -> origin/testcommit1703
+ = [up to date]      testcommit1704 -> origin/testcommit1704
+ = [up to date]      testcommit1705 -> origin/testcommit1705
+ = [up to date]      testcommit1706 -> origin/testcommit1706
+ = [up to date]      testcommit1707 -> origin/testcommit1707
+ = [up to date]      testcommit1708 -> origin/testcommit1708
+ = [up to date]      testcommit1709 -> origin/testcommit1709
+ = [up to date]      testcommit171 -> origin/testcommit171
+ = [up to date]      testcommit1710 -> origin/testcommit1710
+ = [up to date]      testcommit1711 -> origin/testcommit1711
+ = [up to date]      testcommit1712 -> origin/testcommit1712
+ = [up to date]      testcommit1713 -> origin/testcommit1713
+ = [up to date]      testcommit1714 -> origin/testcommit1714
+ = [up to date]      testcommit1715 -> origin/testcommit1715
+ = [up to date]      testcommit1716 -> origin/testcommit1716
+ = [up to date]      testcommit1717 -> origin/testcommit1717
+ = [up to date]      testcommit1718 -> origin/testcommit1718
+ = [up to date]      testcommit1719 -> origin/testcommit1719
+ = [up to date]      testcommit172 -> origin/testcommit172
+ = [up to date]      testcommit1720 -> origin/testcommit1720
+ = [up to date]      testcommit1721 -> origin/testcommit1721
+ = [up to date]      testcommit1722 -> origin/testcommit1722
+ = [up to date]      testcommit1723 -> origin/testcommit1723
+ = [up to date]      testcommit1724 -> origin/testcommit1724
+ = [up to date]      testcommit1725 -> origin/testcommit1725
+ = [up to date]      testcommit1726 -> origin/testcommit1726
+ = [up to date]      testcommit1727 -> origin/testcommit1727
+ = [up to date]      testcommit1728 -> origin/testcommit1728
+ = [up to date]      testcommit1729 -> origin/testcommit1729
+ = [up to date]      testcommit173 -> origin/testcommit173
+ = [up to date]      testcommit1730 -> origin/testcommit1730
+ = [up to date]      testcommit1731 -> origin/testcommit1731
+ = [up to date]      testcommit1732 -> origin/testcommit1732
+ = [up to date]      testcommit1733 -> origin/testcommit1733
+ = [up to date]      testcommit1734 -> origin/testcommit1734
+ = [up to date]      testcommit1735 -> origin/testcommit1735
+ = [up to date]      testcommit1736 -> origin/testcommit1736
+ = [up to date]      testcommit1737 -> origin/testcommit1737
+ = [up to date]      testcommit1738 -> origin/testcommit1738
+ = [up to date]      testcommit1739 -> origin/testcommit1739
+ = [up to date]      testcommit174 -> origin/testcommit174
+ = [up to date]      testcommit1740 -> origin/testcommit1740
+ = [up to date]      testcommit1741 -> origin/testcommit1741
+ = [up to date]      testcommit1742 -> origin/testcommit1742
+ = [up to date]      testcommit1743 -> origin/testcommit1743
+ = [up to date]      testcommit1744 -> origin/testcommit1744
+ = [up to date]      testcommit1745 -> origin/testcommit1745
+ = [up to date]      testcommit1746 -> origin/testcommit1746
+ = [up to date]      testcommit1747 -> origin/testcommit1747
+ = [up to date]      testcommit1748 -> origin/testcommit1748
+ = [up to date]      testcommit1749 -> origin/testcommit1749
+ = [up to date]      testcommit175 -> origin/testcommit175
+ = [up to date]      testcommit1750 -> origin/testcommit1750
+ = [up to date]      testcommit1751 -> origin/testcommit1751
+ = [up to date]      testcommit1752 -> origin/testcommit1752
+ = [up to date]      testcommit1753 -> origin/testcommit1753
+ = [up to date]      testcommit1754 -> origin/testcommit1754
+ = [up to date]      testcommit1755 -> origin/testcommit1755
+ = [up to date]      testcommit1756 -> origin/testcommit1756
+ = [up to date]      testcommit1757 -> origin/testcommit1757
+ = [up to date]      testcommit1758 -> origin/testcommit1758
+ = [up to date]      testcommit1759 -> origin/testcommit1759
+ = [up to date]      testcommit176 -> origin/testcommit176
+ = [up to date]      testcommit1760 -> origin/testcommit1760
+ = [up to date]      testcommit1761 -> origin/testcommit1761
+ = [up to date]      testcommit1762 -> origin/testcommit1762
+ = [up to date]      testcommit1763 -> origin/testcommit1763
+ = [up to date]      testcommit1764 -> origin/testcommit1764
+ = [up to date]      testcommit1765 -> origin/testcommit1765
+ = [up to date]      testcommit1766 -> origin/testcommit1766
+ = [up to date]      testcommit1767 -> origin/testcommit1767
+ = [up to date]      testcommit1768 -> origin/testcommit1768
+ = [up to date]      testcommit1769 -> origin/testcommit1769
+ = [up to date]      testcommit177 -> origin/testcommit177
+ = [up to date]      testcommit1770 -> origin/testcommit1770
+ = [up to date]      testcommit1771 -> origin/testcommit1771
+ = [up to date]      testcommit1772 -> origin/testcommit1772
+ = [up to date]      testcommit1773 -> origin/testcommit1773
+ = [up to date]      testcommit1774 -> origin/testcommit1774
+ = [up to date]      testcommit1775 -> origin/testcommit1775
+ = [up to date]      testcommit1776 -> origin/testcommit1776
+ = [up to date]      testcommit1777 -> origin/testcommit1777
+ = [up to date]      testcommit1778 -> origin/testcommit1778
+ = [up to date]      testcommit1779 -> origin/testcommit1779
+ = [up to date]      testcommit178 -> origin/testcommit178
+ = [up to date]      testcommit1780 -> origin/testcommit1780
+ = [up to date]      testcommit1781 -> origin/testcommit1781
+ = [up to date]      testcommit1782 -> origin/testcommit1782
+ = [up to date]      testcommit1783 -> origin/testcommit1783
+ = [up to date]      testcommit1784 -> origin/testcommit1784
+ = [up to date]      testcommit1785 -> origin/testcommit1785
+ = [up to date]      testcommit1786 -> origin/testcommit1786
+ = [up to date]      testcommit1787 -> origin/testcommit1787
+ = [up to date]      testcommit1788 -> origin/testcommit1788
+ = [up to date]      testcommit1789 -> origin/testcommit1789
+ = [up to date]      testcommit179 -> origin/testcommit179
+ = [up to date]      testcommit1790 -> origin/testcommit1790
+ = [up to date]      testcommit1791 -> origin/testcommit1791
+ = [up to date]      testcommit1792 -> origin/testcommit1792
+ = [up to date]      testcommit1793 -> origin/testcommit1793
+ = [up to date]      testcommit1794 -> origin/testcommit1794
+ = [up to date]      testcommit1795 -> origin/testcommit1795
+ = [up to date]      testcommit1796 -> origin/testcommit1796
+ = [up to date]      testcommit1797 -> origin/testcommit1797
+ = [up to date]      testcommit1798 -> origin/testcommit1798
+ = [up to date]      testcommit1799 -> origin/testcommit1799
+ = [up to date]      testcommit18 -> origin/testcommit18
+ = [up to date]      testcommit180 -> origin/testcommit180
+ = [up to date]      testcommit1800 -> origin/testcommit1800
+ = [up to date]      testcommit1801 -> origin/testcommit1801
+ = [up to date]      testcommit1802 -> origin/testcommit1802
+ = [up to date]      testcommit1803 -> origin/testcommit1803
+ = [up to date]      testcommit1804 -> origin/testcommit1804
+ = [up to date]      testcommit1805 -> origin/testcommit1805
+ = [up to date]      testcommit1806 -> origin/testcommit1806
+ = [up to date]      testcommit1807 -> origin/testcommit1807
+ = [up to date]      testcommit1808 -> origin/testcommit1808
+ = [up to date]      testcommit1809 -> origin/testcommit1809
+ = [up to date]      testcommit181 -> origin/testcommit181
+ = [up to date]      testcommit1810 -> origin/testcommit1810
+ = [up to date]      testcommit1811 -> origin/testcommit1811
+ = [up to date]      testcommit1812 -> origin/testcommit1812
+ = [up to date]      testcommit1813 -> origin/testcommit1813
+ = [up to date]      testcommit1814 -> origin/testcommit1814
+ = [up to date]      testcommit1815 -> origin/testcommit1815
+ = [up to date]      testcommit1816 -> origin/testcommit1816
+ = [up to date]      testcommit1817 -> origin/testcommit1817
+ = [up to date]      testcommit1818 -> origin/testcommit1818
+ = [up to date]      testcommit1819 -> origin/testcommit1819
+ = [up to date]      testcommit182 -> origin/testcommit182
+ = [up to date]      testcommit1820 -> origin/testcommit1820
+ = [up to date]      testcommit1821 -> origin/testcommit1821
+ = [up to date]      testcommit1822 -> origin/testcommit1822
+ = [up to date]      testcommit1823 -> origin/testcommit1823
+ = [up to date]      testcommit1824 -> origin/testcommit1824
+ = [up to date]      testcommit1825 -> origin/testcommit1825
+ = [up to date]      testcommit1826 -> origin/testcommit1826
+ = [up to date]      testcommit1827 -> origin/testcommit1827
+ = [up to date]      testcommit1828 -> origin/testcommit1828
+ = [up to date]      testcommit1829 -> origin/testcommit1829
+ = [up to date]      testcommit183 -> origin/testcommit183
+ = [up to date]      testcommit1830 -> origin/testcommit1830
+ = [up to date]      testcommit1831 -> origin/testcommit1831
+ = [up to date]      testcommit1832 -> origin/testcommit1832
+ = [up to date]      testcommit1833 -> origin/testcommit1833
+ = [up to date]      testcommit1834 -> origin/testcommit1834
+ = [up to date]      testcommit1835 -> origin/testcommit1835
+ = [up to date]      testcommit1836 -> origin/testcommit1836
+ = [up to date]      testcommit1837 -> origin/testcommit1837
+ = [up to date]      testcommit1838 -> origin/testcommit1838
+ = [up to date]      testcommit1839 -> origin/testcommit1839
+ = [up to date]      testcommit184 -> origin/testcommit184
+ = [up to date]      testcommit1840 -> origin/testcommit1840
+ = [up to date]      testcommit1841 -> origin/testcommit1841
+ = [up to date]      testcommit1842 -> origin/testcommit1842
+ = [up to date]      testcommit1843 -> origin/testcommit1843
+ = [up to date]      testcommit1844 -> origin/testcommit1844
+ = [up to date]      testcommit1845 -> origin/testcommit1845
+ = [up to date]      testcommit1846 -> origin/testcommit1846
+ = [up to date]      testcommit1847 -> origin/testcommit1847
+ = [up to date]      testcommit1848 -> origin/testcommit1848
+ = [up to date]      testcommit1849 -> origin/testcommit1849
+ = [up to date]      testcommit185 -> origin/testcommit185
+ = [up to date]      testcommit1850 -> origin/testcommit1850
+ = [up to date]      testcommit1851 -> origin/testcommit1851
+ = [up to date]      testcommit1852 -> origin/testcommit1852
+ = [up to date]      testcommit1853 -> origin/testcommit1853
+ = [up to date]      testcommit1854 -> origin/testcommit1854
+ = [up to date]      testcommit1855 -> origin/testcommit1855
+ = [up to date]      testcommit1856 -> origin/testcommit1856
+ = [up to date]      testcommit1857 -> origin/testcommit1857
+ = [up to date]      testcommit1858 -> origin/testcommit1858
+ = [up to date]      testcommit1859 -> origin/testcommit1859
+ = [up to date]      testcommit186 -> origin/testcommit186
+ = [up to date]      testcommit1860 -> origin/testcommit1860
+ = [up to date]      testcommit1861 -> origin/testcommit1861
+ = [up to date]      testcommit1862 -> origin/testcommit1862
+ = [up to date]      testcommit1863 -> origin/testcommit1863
+ = [up to date]      testcommit1864 -> origin/testcommit1864
+ = [up to date]      testcommit1865 -> origin/testcommit1865
+ = [up to date]      testcommit1866 -> origin/testcommit1866
+ = [up to date]      testcommit1867 -> origin/testcommit1867
+ = [up to date]      testcommit1868 -> origin/testcommit1868
+ = [up to date]      testcommit1869 -> origin/testcommit1869
+ = [up to date]      testcommit187 -> origin/testcommit187
+ = [up to date]      testcommit1870 -> origin/testcommit1870
+ = [up to date]      testcommit1871 -> origin/testcommit1871
+ = [up to date]      testcommit1872 -> origin/testcommit1872
+ = [up to date]      testcommit1873 -> origin/testcommit1873
+ = [up to date]      testcommit1874 -> origin/testcommit1874
+ = [up to date]      testcommit1875 -> origin/testcommit1875
+ = [up to date]      testcommit1876 -> origin/testcommit1876
+ = [up to date]      testcommit1877 -> origin/testcommit1877
+ = [up to date]      testcommit1878 -> origin/testcommit1878
+ = [up to date]      testcommit1879 -> origin/testcommit1879
+ = [up to date]      testcommit188 -> origin/testcommit188
+ = [up to date]      testcommit1880 -> origin/testcommit1880
+ = [up to date]      testcommit1881 -> origin/testcommit1881
+ = [up to date]      testcommit1882 -> origin/testcommit1882
+ = [up to date]      testcommit1883 -> origin/testcommit1883
+ = [up to date]      testcommit1884 -> origin/testcommit1884
+ = [up to date]      testcommit1885 -> origin/testcommit1885
+ = [up to date]      testcommit1886 -> origin/testcommit1886
+ = [up to date]      testcommit1887 -> origin/testcommit1887
+ = [up to date]      testcommit1888 -> origin/testcommit1888
+ = [up to date]      testcommit1889 -> origin/testcommit1889
+ = [up to date]      testcommit189 -> origin/testcommit189
+ = [up to date]      testcommit1890 -> origin/testcommit1890
+ = [up to date]      testcommit1891 -> origin/testcommit1891
+ = [up to date]      testcommit1892 -> origin/testcommit1892
+ = [up to date]      testcommit1893 -> origin/testcommit1893
+ = [up to date]      testcommit1894 -> origin/testcommit1894
+ = [up to date]      testcommit1895 -> origin/testcommit1895
+ = [up to date]      testcommit1896 -> origin/testcommit1896
+ = [up to date]      testcommit1897 -> origin/testcommit1897
+ = [up to date]      testcommit1898 -> origin/testcommit1898
+ = [up to date]      testcommit1899 -> origin/testcommit1899
+ = [up to date]      testcommit19 -> origin/testcommit19
+ = [up to date]      testcommit190 -> origin/testcommit190
+ = [up to date]      testcommit1900 -> origin/testcommit1900
+ = [up to date]      testcommit1901 -> origin/testcommit1901
+ = [up to date]      testcommit1902 -> origin/testcommit1902
+ = [up to date]      testcommit1903 -> origin/testcommit1903
+ = [up to date]      testcommit1904 -> origin/testcommit1904
+ = [up to date]      testcommit1905 -> origin/testcommit1905
+ = [up to date]      testcommit1906 -> origin/testcommit1906
+ = [up to date]      testcommit1907 -> origin/testcommit1907
+ = [up to date]      testcommit1908 -> origin/testcommit1908
+ = [up to date]      testcommit1909 -> origin/testcommit1909
+ = [up to date]      testcommit191 -> origin/testcommit191
+ = [up to date]      testcommit1910 -> origin/testcommit1910
+ = [up to date]      testcommit1911 -> origin/testcommit1911
+ = [up to date]      testcommit1912 -> origin/testcommit1912
+ = [up to date]      testcommit1913 -> origin/testcommit1913
+ = [up to date]      testcommit1914 -> origin/testcommit1914
+ = [up to date]      testcommit1915 -> origin/testcommit1915
+ = [up to date]      testcommit1916 -> origin/testcommit1916
+ = [up to date]      testcommit1917 -> origin/testcommit1917
+ = [up to date]      testcommit1918 -> origin/testcommit1918
+ = [up to date]      testcommit1919 -> origin/testcommit1919
+ = [up to date]      testcommit192 -> origin/testcommit192
+ = [up to date]      testcommit1920 -> origin/testcommit1920
+ = [up to date]      testcommit1921 -> origin/testcommit1921
+ = [up to date]      testcommit1922 -> origin/testcommit1922
+ = [up to date]      testcommit1923 -> origin/testcommit1923
+ = [up to date]      testcommit1924 -> origin/testcommit1924
+ = [up to date]      testcommit1925 -> origin/testcommit1925
+ = [up to date]      testcommit1926 -> origin/testcommit1926
+ = [up to date]      testcommit1927 -> origin/testcommit1927
+ = [up to date]      testcommit1928 -> origin/testcommit1928
+ = [up to date]      testcommit1929 -> origin/testcommit1929
+ = [up to date]      testcommit193 -> origin/testcommit193
+ = [up to date]      testcommit1930 -> origin/testcommit1930
+ = [up to date]      testcommit1931 -> origin/testcommit1931
+ = [up to date]      testcommit1932 -> origin/testcommit1932
+ = [up to date]      testcommit1933 -> origin/testcommit1933
+ = [up to date]      testcommit1934 -> origin/testcommit1934
+ = [up to date]      testcommit1935 -> origin/testcommit1935
+ = [up to date]      testcommit1936 -> origin/testcommit1936
+ = [up to date]      testcommit1937 -> origin/testcommit1937
+ = [up to date]      testcommit1938 -> origin/testcommit1938
+ = [up to date]      testcommit1939 -> origin/testcommit1939
+ = [up to date]      testcommit194 -> origin/testcommit194
+ = [up to date]      testcommit1940 -> origin/testcommit1940
+ = [up to date]      testcommit1941 -> origin/testcommit1941
+ = [up to date]      testcommit1942 -> origin/testcommit1942
+ = [up to date]      testcommit1943 -> origin/testcommit1943
+ = [up to date]      testcommit1944 -> origin/testcommit1944
+ = [up to date]      testcommit1945 -> origin/testcommit1945
+ = [up to date]      testcommit1946 -> origin/testcommit1946
+ = [up to date]      testcommit1947 -> origin/testcommit1947
+ = [up to date]      testcommit1948 -> origin/testcommit1948
+ = [up to date]      testcommit1949 -> origin/testcommit1949
+ = [up to date]      testcommit195 -> origin/testcommit195
+ = [up to date]      testcommit1950 -> origin/testcommit1950
+ = [up to date]      testcommit1951 -> origin/testcommit1951
+ = [up to date]      testcommit1952 -> origin/testcommit1952
+ = [up to date]      testcommit1953 -> origin/testcommit1953
+ = [up to date]      testcommit1954 -> origin/testcommit1954
+ = [up to date]      testcommit1955 -> origin/testcommit1955
+ = [up to date]      testcommit1956 -> origin/testcommit1956
+ = [up to date]      testcommit1957 -> origin/testcommit1957
+ = [up to date]      testcommit1958 -> origin/testcommit1958
+ = [up to date]      testcommit1959 -> origin/testcommit1959
+ = [up to date]      testcommit196 -> origin/testcommit196
+ = [up to date]      testcommit1960 -> origin/testcommit1960
+ = [up to date]      testcommit1961 -> origin/testcommit1961
+ = [up to date]      testcommit1962 -> origin/testcommit1962
+ = [up to date]      testcommit1963 -> origin/testcommit1963
+ = [up to date]      testcommit1964 -> origin/testcommit1964
+ = [up to date]      testcommit1965 -> origin/testcommit1965
+ = [up to date]      testcommit1966 -> origin/testcommit1966
+ = [up to date]      testcommit1967 -> origin/testcommit1967
+ = [up to date]      testcommit1968 -> origin/testcommit1968
+ = [up to date]      testcommit1969 -> origin/testcommit1969
+ = [up to date]      testcommit197 -> origin/testcommit197
+ = [up to date]      testcommit1970 -> origin/testcommit1970
+ = [up to date]      testcommit1971 -> origin/testcommit1971
+ = [up to date]      testcommit1972 -> origin/testcommit1972
+ = [up to date]      testcommit1973 -> origin/testcommit1973
+ = [up to date]      testcommit1974 -> origin/testcommit1974
+ = [up to date]      testcommit1975 -> origin/testcommit1975
+ = [up to date]      testcommit1976 -> origin/testcommit1976
+ = [up to date]      testcommit1977 -> origin/testcommit1977
+ = [up to date]      testcommit1978 -> origin/testcommit1978
+ = [up to date]      testcommit1979 -> origin/testcommit1979
+ = [up to date]      testcommit198 -> origin/testcommit198
+ = [up to date]      testcommit1980 -> origin/testcommit1980
+ = [up to date]      testcommit1981 -> origin/testcommit1981
+ = [up to date]      testcommit1982 -> origin/testcommit1982
+ = [up to date]      testcommit1983 -> origin/testcommit1983
+ = [up to date]      testcommit1984 -> origin/testcommit1984
+ = [up to date]      testcommit1985 -> origin/testcommit1985
+ = [up to date]      testcommit1986 -> origin/testcommit1986
+ = [up to date]      testcommit1987 -> origin/testcommit1987
+ = [up to date]      testcommit1988 -> origin/testcommit1988
+ = [up to date]      testcommit1989 -> origin/testcommit1989
+ = [up to date]      testcommit199 -> origin/testcommit199
+ = [up to date]      testcommit1990 -> origin/testcommit1990
+ = [up to date]      testcommit1991 -> origin/testcommit1991
+ = [up to date]      testcommit1992 -> origin/testcommit1992
+ = [up to date]      testcommit1993 -> origin/testcommit1993
+ = [up to date]      testcommit1994 -> origin/testcommit1994
+ = [up to date]      testcommit1995 -> origin/testcommit1995
+ = [up to date]      testcommit1996 -> origin/testcommit1996
+ = [up to date]      testcommit1997 -> origin/testcommit1997
+ = [up to date]      testcommit1998 -> origin/testcommit1998
+ = [up to date]      testcommit1999 -> origin/testcommit1999
+ = [up to date]      testcommit2 -> origin/testcommit2
+ = [up to date]      testcommit20 -> origin/testcommit20
+ = [up to date]      testcommit200 -> origin/testcommit200
+ = [up to date]      testcommit2000 -> origin/testcommit2000
+ = [up to date]      testcommit2001 -> origin/testcommit2001
+ = [up to date]      testcommit2002 -> origin/testcommit2002
+ = [up to date]      testcommit2003 -> origin/testcommit2003
+ = [up to date]      testcommit2004 -> origin/testcommit2004
+ = [up to date]      testcommit2005 -> origin/testcommit2005
+ = [up to date]      testcommit2006 -> origin/testcommit2006
+ = [up to date]      testcommit2007 -> origin/testcommit2007
+ = [up to date]      testcommit2008 -> origin/testcommit2008
+ = [up to date]      testcommit2009 -> origin/testcommit2009
+ = [up to date]      testcommit201 -> origin/testcommit201
+ = [up to date]      testcommit2010 -> origin/testcommit2010
+ = [up to date]      testcommit2011 -> origin/testcommit2011
+ = [up to date]      testcommit2012 -> origin/testcommit2012
+ = [up to date]      testcommit2013 -> origin/testcommit2013
+ = [up to date]      testcommit2014 -> origin/testcommit2014
+ = [up to date]      testcommit2015 -> origin/testcommit2015
+ = [up to date]      testcommit2016 -> origin/testcommit2016
+ = [up to date]      testcommit2017 -> origin/testcommit2017
+ = [up to date]      testcommit2018 -> origin/testcommit2018
+ = [up to date]      testcommit2019 -> origin/testcommit2019
+ = [up to date]      testcommit202 -> origin/testcommit202
+ = [up to date]      testcommit2020 -> origin/testcommit2020
+ = [up to date]      testcommit2021 -> origin/testcommit2021
+ = [up to date]      testcommit2022 -> origin/testcommit2022
+ = [up to date]      testcommit2023 -> origin/testcommit2023
+ = [up to date]      testcommit2024 -> origin/testcommit2024
+ = [up to date]      testcommit2025 -> origin/testcommit2025
+ = [up to date]      testcommit2026 -> origin/testcommit2026
+ = [up to date]      testcommit2027 -> origin/testcommit2027
+ = [up to date]      testcommit2028 -> origin/testcommit2028
+ = [up to date]      testcommit2029 -> origin/testcommit2029
+ = [up to date]      testcommit203 -> origin/testcommit203
+ = [up to date]      testcommit2030 -> origin/testcommit2030
+ = [up to date]      testcommit2031 -> origin/testcommit2031
+ = [up to date]      testcommit2032 -> origin/testcommit2032
+ = [up to date]      testcommit2033 -> origin/testcommit2033
+ = [up to date]      testcommit2034 -> origin/testcommit2034
+ = [up to date]      testcommit2035 -> origin/testcommit2035
+ = [up to date]      testcommit2036 -> origin/testcommit2036
+ = [up to date]      testcommit2037 -> origin/testcommit2037
+ = [up to date]      testcommit2038 -> origin/testcommit2038
+ = [up to date]      testcommit2039 -> origin/testcommit2039
+ = [up to date]      testcommit204 -> origin/testcommit204
+ = [up to date]      testcommit2040 -> origin/testcommit2040
+ = [up to date]      testcommit2041 -> origin/testcommit2041
+ = [up to date]      testcommit2042 -> origin/testcommit2042
+ = [up to date]      testcommit2043 -> origin/testcommit2043
+ = [up to date]      testcommit2044 -> origin/testcommit2044
+ = [up to date]      testcommit2045 -> origin/testcommit2045
+ = [up to date]      testcommit2046 -> origin/testcommit2046
+ = [up to date]      testcommit2047 -> origin/testcommit2047
+ = [up to date]      testcommit2048 -> origin/testcommit2048
+ = [up to date]      testcommit2049 -> origin/testcommit2049
+ = [up to date]      testcommit205 -> origin/testcommit205
+ = [up to date]      testcommit2050 -> origin/testcommit2050
+ = [up to date]      testcommit2051 -> origin/testcommit2051
+ = [up to date]      testcommit2052 -> origin/testcommit2052
+ = [up to date]      testcommit2053 -> origin/testcommit2053
+ = [up to date]      testcommit2054 -> origin/testcommit2054
+ = [up to date]      testcommit2055 -> origin/testcommit2055
+ = [up to date]      testcommit2056 -> origin/testcommit2056
+ = [up to date]      testcommit2057 -> origin/testcommit2057
+ = [up to date]      testcommit2058 -> origin/testcommit2058
+ = [up to date]      testcommit2059 -> origin/testcommit2059
+ = [up to date]      testcommit206 -> origin/testcommit206
+ = [up to date]      testcommit2060 -> origin/testcommit2060
+ = [up to date]      testcommit2061 -> origin/testcommit2061
+ = [up to date]      testcommit2062 -> origin/testcommit2062
+ = [up to date]      testcommit2063 -> origin/testcommit2063
+ = [up to date]      testcommit2064 -> origin/testcommit2064
+ = [up to date]      testcommit2065 -> origin/testcommit2065
+ = [up to date]      testcommit2066 -> origin/testcommit2066
+ = [up to date]      testcommit2067 -> origin/testcommit2067
+ = [up to date]      testcommit2068 -> origin/testcommit2068
+ = [up to date]      testcommit2069 -> origin/testcommit2069
+ = [up to date]      testcommit207 -> origin/testcommit207
+ = [up to date]      testcommit2070 -> origin/testcommit2070
+ = [up to date]      testcommit2071 -> origin/testcommit2071
+ = [up to date]      testcommit2072 -> origin/testcommit2072
+ = [up to date]      testcommit2073 -> origin/testcommit2073
+ = [up to date]      testcommit2074 -> origin/testcommit2074
+ = [up to date]      testcommit2075 -> origin/testcommit2075
+ = [up to date]      testcommit2076 -> origin/testcommit2076
+ = [up to date]      testcommit2077 -> origin/testcommit2077
+ = [up to date]      testcommit2078 -> origin/testcommit2078
+ = [up to date]      testcommit2079 -> origin/testcommit2079
+ = [up to date]      testcommit208 -> origin/testcommit208
+ = [up to date]      testcommit2080 -> origin/testcommit2080
+ = [up to date]      testcommit2081 -> origin/testcommit2081
+ = [up to date]      testcommit2082 -> origin/testcommit2082
+ = [up to date]      testcommit2083 -> origin/testcommit2083
+ = [up to date]      testcommit2084 -> origin/testcommit2084
+ = [up to date]      testcommit2085 -> origin/testcommit2085
+ = [up to date]      testcommit2086 -> origin/testcommit2086
+ = [up to date]      testcommit2087 -> origin/testcommit2087
+ = [up to date]      testcommit2088 -> origin/testcommit2088
+ = [up to date]      testcommit2089 -> origin/testcommit2089
+ = [up to date]      testcommit209 -> origin/testcommit209
+ = [up to date]      testcommit2090 -> origin/testcommit2090
+ = [up to date]      testcommit2091 -> origin/testcommit2091
+ = [up to date]      testcommit2092 -> origin/testcommit2092
+ = [up to date]      testcommit2093 -> origin/testcommit2093
+ = [up to date]      testcommit2094 -> origin/testcommit2094
+ = [up to date]      testcommit2095 -> origin/testcommit2095
+ = [up to date]      testcommit2096 -> origin/testcommit2096
+ = [up to date]      testcommit2097 -> origin/testcommit2097
+ = [up to date]      testcommit2098 -> origin/testcommit2098
+ = [up to date]      testcommit2099 -> origin/testcommit2099
+ = [up to date]      testcommit21 -> origin/testcommit21
+ = [up to date]      testcommit210 -> origin/testcommit210
+ = [up to date]      testcommit2100 -> origin/testcommit2100
+ = [up to date]      testcommit2101 -> origin/testcommit2101
+ = [up to date]      testcommit2102 -> origin/testcommit2102
+ = [up to date]      testcommit2103 -> origin/testcommit2103
+ = [up to date]      testcommit2104 -> origin/testcommit2104
+ = [up to date]      testcommit2105 -> origin/testcommit2105
+ = [up to date]      testcommit2106 -> origin/testcommit2106
+ = [up to date]      testcommit2107 -> origin/testcommit2107
+ = [up to date]      testcommit2108 -> origin/testcommit2108
+ = [up to date]      testcommit2109 -> origin/testcommit2109
+ = [up to date]      testcommit211 -> origin/testcommit211
+ = [up to date]      testcommit2110 -> origin/testcommit2110
+ = [up to date]      testcommit2111 -> origin/testcommit2111
+ = [up to date]      testcommit2112 -> origin/testcommit2112
+ = [up to date]      testcommit2113 -> origin/testcommit2113
+ = [up to date]      testcommit2114 -> origin/testcommit2114
+ = [up to date]      testcommit2115 -> origin/testcommit2115
+ = [up to date]      testcommit2116 -> origin/testcommit2116
+ = [up to date]      testcommit2117 -> origin/testcommit2117
+ = [up to date]      testcommit2118 -> origin/testcommit2118
+ = [up to date]      testcommit2119 -> origin/testcommit2119
+ = [up to date]      testcommit212 -> origin/testcommit212
+ = [up to date]      testcommit2120 -> origin/testcommit2120
+ = [up to date]      testcommit2121 -> origin/testcommit2121
+ = [up to date]      testcommit2122 -> origin/testcommit2122
+ = [up to date]      testcommit2123 -> origin/testcommit2123
+ = [up to date]      testcommit2124 -> origin/testcommit2124
+ = [up to date]      testcommit2125 -> origin/testcommit2125
+ = [up to date]      testcommit2126 -> origin/testcommit2126
+ = [up to date]      testcommit2127 -> origin/testcommit2127
+ = [up to date]      testcommit2128 -> origin/testcommit2128
+ = [up to date]      testcommit2129 -> origin/testcommit2129
+ = [up to date]      testcommit213 -> origin/testcommit213
+ = [up to date]      testcommit2130 -> origin/testcommit2130
+ = [up to date]      testcommit2131 -> origin/testcommit2131
+ = [up to date]      testcommit2132 -> origin/testcommit2132
+ = [up to date]      testcommit2133 -> origin/testcommit2133
+ = [up to date]      testcommit2134 -> origin/testcommit2134
+ = [up to date]      testcommit2135 -> origin/testcommit2135
+ = [up to date]      testcommit2136 -> origin/testcommit2136
+ = [up to date]      testcommit2137 -> origin/testcommit2137
+ = [up to date]      testcommit2138 -> origin/testcommit2138
+ = [up to date]      testcommit2139 -> origin/testcommit2139
+ = [up to date]      testcommit214 -> origin/testcommit214
+ = [up to date]      testcommit2140 -> origin/testcommit2140
+ = [up to date]      testcommit2141 -> origin/testcommit2141
+ = [up to date]      testcommit2142 -> origin/testcommit2142
+ = [up to date]      testcommit2143 -> origin/testcommit2143
+ = [up to date]      testcommit2144 -> origin/testcommit2144
+ = [up to date]      testcommit2145 -> origin/testcommit2145
+ = [up to date]      testcommit2146 -> origin/testcommit2146
+ = [up to date]      testcommit2147 -> origin/testcommit2147
+ = [up to date]      testcommit2148 -> origin/testcommit2148
+ = [up to date]      testcommit2149 -> origin/testcommit2149
+ = [up to date]      testcommit215 -> origin/testcommit215
+ = [up to date]      testcommit2150 -> origin/testcommit2150
+ = [up to date]      testcommit2151 -> origin/testcommit2151
+ = [up to date]      testcommit2152 -> origin/testcommit2152
+ = [up to date]      testcommit2153 -> origin/testcommit2153
+ = [up to date]      testcommit2154 -> origin/testcommit2154
+ = [up to date]      testcommit2155 -> origin/testcommit2155
+ = [up to date]      testcommit2156 -> origin/testcommit2156
+ = [up to date]      testcommit2157 -> origin/testcommit2157
+ = [up to date]      testcommit2158 -> origin/testcommit2158
+ = [up to date]      testcommit2159 -> origin/testcommit2159
+ = [up to date]      testcommit216 -> origin/testcommit216
+ = [up to date]      testcommit2160 -> origin/testcommit2160
+ = [up to date]      testcommit2161 -> origin/testcommit2161
+ = [up to date]      testcommit2162 -> origin/testcommit2162
+ = [up to date]      testcommit2163 -> origin/testcommit2163
+ = [up to date]      testcommit2164 -> origin/testcommit2164
+ = [up to date]      testcommit2165 -> origin/testcommit2165
+ = [up to date]      testcommit2166 -> origin/testcommit2166
+ = [up to date]      testcommit2167 -> origin/testcommit2167
+ = [up to date]      testcommit2168 -> origin/testcommit2168
+ = [up to date]      testcommit2169 -> origin/testcommit2169
+ = [up to date]      testcommit217 -> origin/testcommit217
+ = [up to date]      testcommit2170 -> origin/testcommit2170
+ = [up to date]      testcommit2171 -> origin/testcommit2171
+ = [up to date]      testcommit2172 -> origin/testcommit2172
+ = [up to date]      testcommit2173 -> origin/testcommit2173
+ = [up to date]      testcommit2174 -> origin/testcommit2174
+ = [up to date]      testcommit2175 -> origin/testcommit2175
+ = [up to date]      testcommit2176 -> origin/testcommit2176
+ = [up to date]      testcommit2177 -> origin/testcommit2177
+ = [up to date]      testcommit2178 -> origin/testcommit2178
+ = [up to date]      testcommit2179 -> origin/testcommit2179
+ = [up to date]      testcommit218 -> origin/testcommit218
+ = [up to date]      testcommit2180 -> origin/testcommit2180
+ = [up to date]      testcommit2181 -> origin/testcommit2181
+ = [up to date]      testcommit2182 -> origin/testcommit2182
+ = [up to date]      testcommit2183 -> origin/testcommit2183
+ = [up to date]      testcommit2184 -> origin/testcommit2184
+ = [up to date]      testcommit2185 -> origin/testcommit2185
+ = [up to date]      testcommit2186 -> origin/testcommit2186
+ = [up to date]      testcommit2187 -> origin/testcommit2187
+ = [up to date]      testcommit2188 -> origin/testcommit2188
+ = [up to date]      testcommit2189 -> origin/testcommit2189
+ = [up to date]      testcommit219 -> origin/testcommit219
+ = [up to date]      testcommit2190 -> origin/testcommit2190
+ = [up to date]      testcommit2191 -> origin/testcommit2191
+ = [up to date]      testcommit2192 -> origin/testcommit2192
+ = [up to date]      testcommit2193 -> origin/testcommit2193
+ = [up to date]      testcommit2194 -> origin/testcommit2194
+ = [up to date]      testcommit2195 -> origin/testcommit2195
+ = [up to date]      testcommit2196 -> origin/testcommit2196
+ = [up to date]      testcommit2197 -> origin/testcommit2197
+ = [up to date]      testcommit2198 -> origin/testcommit2198
+ = [up to date]      testcommit2199 -> origin/testcommit2199
+ = [up to date]      testcommit22 -> origin/testcommit22
+ = [up to date]      testcommit220 -> origin/testcommit220
+ = [up to date]      testcommit2200 -> origin/testcommit2200
+ = [up to date]      testcommit2201 -> origin/testcommit2201
+ = [up to date]      testcommit2202 -> origin/testcommit2202
+ = [up to date]      testcommit2203 -> origin/testcommit2203
+ = [up to date]      testcommit2204 -> origin/testcommit2204
+ = [up to date]      testcommit2205 -> origin/testcommit2205
+ = [up to date]      testcommit2206 -> origin/testcommit2206
+ = [up to date]      testcommit2207 -> origin/testcommit2207
+ = [up to date]      testcommit2208 -> origin/testcommit2208
+ = [up to date]      testcommit2209 -> origin/testcommit2209
+ = [up to date]      testcommit221 -> origin/testcommit221
+ = [up to date]      testcommit2210 -> origin/testcommit2210
+ = [up to date]      testcommit2211 -> origin/testcommit2211
+ = [up to date]      testcommit2212 -> origin/testcommit2212
+ = [up to date]      testcommit2213 -> origin/testcommit2213
+ = [up to date]      testcommit2214 -> origin/testcommit2214
+ = [up to date]      testcommit2215 -> origin/testcommit2215
+ = [up to date]      testcommit2216 -> origin/testcommit2216
+ = [up to date]      testcommit2217 -> origin/testcommit2217
+ = [up to date]      testcommit2218 -> origin/testcommit2218
+ = [up to date]      testcommit2219 -> origin/testcommit2219
+ = [up to date]      testcommit222 -> origin/testcommit222
+ = [up to date]      testcommit2220 -> origin/testcommit2220
+ = [up to date]      testcommit2221 -> origin/testcommit2221
+ = [up to date]      testcommit2222 -> origin/testcommit2222
+ = [up to date]      testcommit2223 -> origin/testcommit2223
+ = [up to date]      testcommit2224 -> origin/testcommit2224
+ = [up to date]      testcommit2225 -> origin/testcommit2225
+ = [up to date]      testcommit2226 -> origin/testcommit2226
+ = [up to date]      testcommit2227 -> origin/testcommit2227
+ = [up to date]      testcommit2228 -> origin/testcommit2228
+ = [up to date]      testcommit2229 -> origin/testcommit2229
+ = [up to date]      testcommit223 -> origin/testcommit223
+ = [up to date]      testcommit2230 -> origin/testcommit2230
+ = [up to date]      testcommit2231 -> origin/testcommit2231
+ = [up to date]      testcommit2232 -> origin/testcommit2232
+ = [up to date]      testcommit2233 -> origin/testcommit2233
+ = [up to date]      testcommit2234 -> origin/testcommit2234
+ = [up to date]      testcommit2235 -> origin/testcommit2235
+ = [up to date]      testcommit2236 -> origin/testcommit2236
+ = [up to date]      testcommit2237 -> origin/testcommit2237
+ = [up to date]      testcommit2238 -> origin/testcommit2238
+ = [up to date]      testcommit2239 -> origin/testcommit2239
+ = [up to date]      testcommit224 -> origin/testcommit224
+ = [up to date]      testcommit2240 -> origin/testcommit2240
+ = [up to date]      testcommit2241 -> origin/testcommit2241
+ = [up to date]      testcommit2242 -> origin/testcommit2242
+ = [up to date]      testcommit2243 -> origin/testcommit2243
+ = [up to date]      testcommit2244 -> origin/testcommit2244
+ = [up to date]      testcommit2245 -> origin/testcommit2245
+ = [up to date]      testcommit2246 -> origin/testcommit2246
+ = [up to date]      testcommit2247 -> origin/testcommit2247
+ = [up to date]      testcommit2248 -> origin/testcommit2248
+ = [up to date]      testcommit2249 -> origin/testcommit2249
+ = [up to date]      testcommit225 -> origin/testcommit225
+ = [up to date]      testcommit2250 -> origin/testcommit2250
+ = [up to date]      testcommit2251 -> origin/testcommit2251
+ = [up to date]      testcommit2252 -> origin/testcommit2252
+ = [up to date]      testcommit2253 -> origin/testcommit2253
+ = [up to date]      testcommit2254 -> origin/testcommit2254
+ = [up to date]      testcommit2255 -> origin/testcommit2255
+ = [up to date]      testcommit2256 -> origin/testcommit2256
+ = [up to date]      testcommit2257 -> origin/testcommit2257
+ = [up to date]      testcommit2258 -> origin/testcommit2258
+ = [up to date]      testcommit2259 -> origin/testcommit2259
+ = [up to date]      testcommit226 -> origin/testcommit226
+ = [up to date]      testcommit2260 -> origin/testcommit2260
+ = [up to date]      testcommit2261 -> origin/testcommit2261
+ = [up to date]      testcommit2262 -> origin/testcommit2262
+ = [up to date]      testcommit2263 -> origin/testcommit2263
+ = [up to date]      testcommit2264 -> origin/testcommit2264
+ = [up to date]      testcommit2265 -> origin/testcommit2265
+ = [up to date]      testcommit2266 -> origin/testcommit2266
+ = [up to date]      testcommit2267 -> origin/testcommit2267
+ = [up to date]      testcommit2268 -> origin/testcommit2268
+ = [up to date]      testcommit2269 -> origin/testcommit2269
+ = [up to date]      testcommit227 -> origin/testcommit227
+ = [up to date]      testcommit2270 -> origin/testcommit2270
+ = [up to date]      testcommit2271 -> origin/testcommit2271
+ = [up to date]      testcommit2272 -> origin/testcommit2272
+ = [up to date]      testcommit2273 -> origin/testcommit2273
+ = [up to date]      testcommit2274 -> origin/testcommit2274
+ = [up to date]      testcommit2275 -> origin/testcommit2275
+ = [up to date]      testcommit2276 -> origin/testcommit2276
+ = [up to date]      testcommit2277 -> origin/testcommit2277
+ = [up to date]      testcommit2278 -> origin/testcommit2278
+ = [up to date]      testcommit2279 -> origin/testcommit2279
+ = [up to date]      testcommit228 -> origin/testcommit228
+ = [up to date]      testcommit2280 -> origin/testcommit2280
+ = [up to date]      testcommit2281 -> origin/testcommit2281
+ = [up to date]      testcommit2282 -> origin/testcommit2282
+ = [up to date]      testcommit2283 -> origin/testcommit2283
+ = [up to date]      testcommit2284 -> origin/testcommit2284
+ = [up to date]      testcommit2285 -> origin/testcommit2285
+ = [up to date]      testcommit2286 -> origin/testcommit2286
+ = [up to date]      testcommit2287 -> origin/testcommit2287
+ = [up to date]      testcommit2288 -> origin/testcommit2288
+ = [up to date]      testcommit2289 -> origin/testcommit2289
+ = [up to date]      testcommit229 -> origin/testcommit229
+ = [up to date]      testcommit2290 -> origin/testcommit2290
+ = [up to date]      testcommit2291 -> origin/testcommit2291
+ = [up to date]      testcommit2292 -> origin/testcommit2292
+ = [up to date]      testcommit2293 -> origin/testcommit2293
+ = [up to date]      testcommit2294 -> origin/testcommit2294
+ = [up to date]      testcommit2295 -> origin/testcommit2295
+ = [up to date]      testcommit2296 -> origin/testcommit2296
+ = [up to date]      testcommit2297 -> origin/testcommit2297
+ = [up to date]      testcommit2298 -> origin/testcommit2298
+ = [up to date]      testcommit2299 -> origin/testcommit2299
+ = [up to date]      testcommit23 -> origin/testcommit23
+ = [up to date]      testcommit230 -> origin/testcommit230
+ = [up to date]      testcommit2300 -> origin/testcommit2300
+ = [up to date]      testcommit2301 -> origin/testcommit2301
+ = [up to date]      testcommit2302 -> origin/testcommit2302
+ = [up to date]      testcommit2303 -> origin/testcommit2303
+ = [up to date]      testcommit2304 -> origin/testcommit2304
+ = [up to date]      testcommit2305 -> origin/testcommit2305
+ = [up to date]      testcommit2306 -> origin/testcommit2306
+ = [up to date]      testcommit2307 -> origin/testcommit2307
+ = [up to date]      testcommit2308 -> origin/testcommit2308
+ = [up to date]      testcommit2309 -> origin/testcommit2309
+ = [up to date]      testcommit231 -> origin/testcommit231
+ = [up to date]      testcommit2310 -> origin/testcommit2310
+ = [up to date]      testcommit2311 -> origin/testcommit2311
+ = [up to date]      testcommit2312 -> origin/testcommit2312
+ = [up to date]      testcommit2313 -> origin/testcommit2313
+ = [up to date]      testcommit2314 -> origin/testcommit2314
+ = [up to date]      testcommit2315 -> origin/testcommit2315
+ = [up to date]      testcommit2316 -> origin/testcommit2316
+ = [up to date]      testcommit2317 -> origin/testcommit2317
+ = [up to date]      testcommit2318 -> origin/testcommit2318
+ = [up to date]      testcommit2319 -> origin/testcommit2319
+ = [up to date]      testcommit232 -> origin/testcommit232
+ = [up to date]      testcommit2320 -> origin/testcommit2320
+ = [up to date]      testcommit2321 -> origin/testcommit2321
+ = [up to date]      testcommit2322 -> origin/testcommit2322
+ = [up to date]      testcommit2323 -> origin/testcommit2323
+ = [up to date]      testcommit2324 -> origin/testcommit2324
+ = [up to date]      testcommit2325 -> origin/testcommit2325
+ = [up to date]      testcommit2326 -> origin/testcommit2326
+ = [up to date]      testcommit2327 -> origin/testcommit2327
+ = [up to date]      testcommit2328 -> origin/testcommit2328
+ = [up to date]      testcommit2329 -> origin/testcommit2329
+ = [up to date]      testcommit233 -> origin/testcommit233
+ = [up to date]      testcommit2330 -> origin/testcommit2330
+ = [up to date]      testcommit2331 -> origin/testcommit2331
+ = [up to date]      testcommit2332 -> origin/testcommit2332
+ = [up to date]      testcommit2333 -> origin/testcommit2333
+ = [up to date]      testcommit2334 -> origin/testcommit2334
+ = [up to date]      testcommit2335 -> origin/testcommit2335
+ = [up to date]      testcommit2336 -> origin/testcommit2336
+ = [up to date]      testcommit2337 -> origin/testcommit2337
+ = [up to date]      testcommit2338 -> origin/testcommit2338
+ = [up to date]      testcommit2339 -> origin/testcommit2339
+ = [up to date]      testcommit234 -> origin/testcommit234
+ = [up to date]      testcommit2340 -> origin/testcommit2340
+ = [up to date]      testcommit2341 -> origin/testcommit2341
+ = [up to date]      testcommit2342 -> origin/testcommit2342
+ = [up to date]      testcommit2343 -> origin/testcommit2343
+ = [up to date]      testcommit2344 -> origin/testcommit2344
+ = [up to date]      testcommit2345 -> origin/testcommit2345
+ = [up to date]      testcommit2346 -> origin/testcommit2346
+ = [up to date]      testcommit2347 -> origin/testcommit2347
+ = [up to date]      testcommit2348 -> origin/testcommit2348
+ = [up to date]      testcommit2349 -> origin/testcommit2349
+ = [up to date]      testcommit235 -> origin/testcommit235
+ = [up to date]      testcommit2350 -> origin/testcommit2350
+ = [up to date]      testcommit2351 -> origin/testcommit2351
+ = [up to date]      testcommit2352 -> origin/testcommit2352
+ = [up to date]      testcommit2353 -> origin/testcommit2353
+ = [up to date]      testcommit2354 -> origin/testcommit2354
+ = [up to date]      testcommit2355 -> origin/testcommit2355
+ = [up to date]      testcommit2356 -> origin/testcommit2356
+ = [up to date]      testcommit2357 -> origin/testcommit2357
+ = [up to date]      testcommit2358 -> origin/testcommit2358
+ = [up to date]      testcommit2359 -> origin/testcommit2359
+ = [up to date]      testcommit236 -> origin/testcommit236
+ = [up to date]      testcommit2360 -> origin/testcommit2360
+ = [up to date]      testcommit2361 -> origin/testcommit2361
+ = [up to date]      testcommit2362 -> origin/testcommit2362
+ = [up to date]      testcommit2363 -> origin/testcommit2363
+ = [up to date]      testcommit2364 -> origin/testcommit2364
+ = [up to date]      testcommit2365 -> origin/testcommit2365
+ = [up to date]      testcommit2366 -> origin/testcommit2366
+ = [up to date]      testcommit2367 -> origin/testcommit2367
+ = [up to date]      testcommit2368 -> origin/testcommit2368
+ = [up to date]      testcommit2369 -> origin/testcommit2369
+ = [up to date]      testcommit237 -> origin/testcommit237
+ = [up to date]      testcommit2370 -> origin/testcommit2370
+ = [up to date]      testcommit2371 -> origin/testcommit2371
+ = [up to date]      testcommit2372 -> origin/testcommit2372
+ = [up to date]      testcommit2373 -> origin/testcommit2373
+ = [up to date]      testcommit2374 -> origin/testcommit2374
+ = [up to date]      testcommit2375 -> origin/testcommit2375
+ = [up to date]      testcommit2376 -> origin/testcommit2376
+ = [up to date]      testcommit2377 -> origin/testcommit2377
+ = [up to date]      testcommit2378 -> origin/testcommit2378
+ = [up to date]      testcommit2379 -> origin/testcommit2379
+ = [up to date]      testcommit238 -> origin/testcommit238
+ = [up to date]      testcommit2380 -> origin/testcommit2380
+ = [up to date]      testcommit2381 -> origin/testcommit2381
+ = [up to date]      testcommit2382 -> origin/testcommit2382
+ = [up to date]      testcommit2383 -> origin/testcommit2383
+ = [up to date]      testcommit2384 -> origin/testcommit2384
+ = [up to date]      testcommit2385 -> origin/testcommit2385
+ = [up to date]      testcommit2386 -> origin/testcommit2386
+ = [up to date]      testcommit2387 -> origin/testcommit2387
+ = [up to date]      testcommit2388 -> origin/testcommit2388
+ = [up to date]      testcommit2389 -> origin/testcommit2389
+ = [up to date]      testcommit239 -> origin/testcommit239
+ = [up to date]      testcommit2390 -> origin/testcommit2390
+ = [up to date]      testcommit2391 -> origin/testcommit2391
+ = [up to date]      testcommit2392 -> origin/testcommit2392
+ = [up to date]      testcommit2393 -> origin/testcommit2393
+ = [up to date]      testcommit2394 -> origin/testcommit2394
+ = [up to date]      testcommit2395 -> origin/testcommit2395
+ = [up to date]      testcommit2396 -> origin/testcommit2396
+ = [up to date]      testcommit2397 -> origin/testcommit2397
+ = [up to date]      testcommit2398 -> origin/testcommit2398
+ = [up to date]      testcommit2399 -> origin/testcommit2399
+ = [up to date]      testcommit24 -> origin/testcommit24
+ = [up to date]      testcommit240 -> origin/testcommit240
+ = [up to date]      testcommit2400 -> origin/testcommit2400
+ = [up to date]      testcommit2401 -> origin/testcommit2401
+ = [up to date]      testcommit2402 -> origin/testcommit2402
+ = [up to date]      testcommit2403 -> origin/testcommit2403
+ = [up to date]      testcommit2404 -> origin/testcommit2404
+ = [up to date]      testcommit2405 -> origin/testcommit2405
+ = [up to date]      testcommit2406 -> origin/testcommit2406
+ = [up to date]      testcommit2407 -> origin/testcommit2407
+ = [up to date]      testcommit2408 -> origin/testcommit2408
+ = [up to date]      testcommit2409 -> origin/testcommit2409
+ = [up to date]      testcommit241 -> origin/testcommit241
+ = [up to date]      testcommit2410 -> origin/testcommit2410
+ = [up to date]      testcommit2411 -> origin/testcommit2411
+ = [up to date]      testcommit2412 -> origin/testcommit2412
+ = [up to date]      testcommit2413 -> origin/testcommit2413
+ = [up to date]      testcommit2414 -> origin/testcommit2414
+ = [up to date]      testcommit2415 -> origin/testcommit2415
+ = [up to date]      testcommit2416 -> origin/testcommit2416
+ = [up to date]      testcommit2417 -> origin/testcommit2417
+ = [up to date]      testcommit2418 -> origin/testcommit2418
+ = [up to date]      testcommit2419 -> origin/testcommit2419
+ = [up to date]      testcommit242 -> origin/testcommit242
+ = [up to date]      testcommit2420 -> origin/testcommit2420
+ = [up to date]      testcommit2421 -> origin/testcommit2421
+ = [up to date]      testcommit2422 -> origin/testcommit2422
+ = [up to date]      testcommit2423 -> origin/testcommit2423
+ = [up to date]      testcommit2424 -> origin/testcommit2424
+ = [up to date]      testcommit2425 -> origin/testcommit2425
+ = [up to date]      testcommit2426 -> origin/testcommit2426
+ = [up to date]      testcommit2427 -> origin/testcommit2427
+ = [up to date]      testcommit2428 -> origin/testcommit2428
+ = [up to date]      testcommit2429 -> origin/testcommit2429
+ = [up to date]      testcommit243 -> origin/testcommit243
+ = [up to date]      testcommit2430 -> origin/testcommit2430
+ = [up to date]      testcommit2431 -> origin/testcommit2431
+ = [up to date]      testcommit2432 -> origin/testcommit2432
+ = [up to date]      testcommit2433 -> origin/testcommit2433
+ = [up to date]      testcommit2434 -> origin/testcommit2434
+ = [up to date]      testcommit2435 -> origin/testcommit2435
+ = [up to date]      testcommit2436 -> origin/testcommit2436
+ = [up to date]      testcommit2437 -> origin/testcommit2437
+ = [up to date]      testcommit2438 -> origin/testcommit2438
+ = [up to date]      testcommit2439 -> origin/testcommit2439
+ = [up to date]      testcommit244 -> origin/testcommit244
+ = [up to date]      testcommit2440 -> origin/testcommit2440
+ = [up to date]      testcommit2441 -> origin/testcommit2441
+ = [up to date]      testcommit2442 -> origin/testcommit2442
+ = [up to date]      testcommit2443 -> origin/testcommit2443
+ = [up to date]      testcommit2444 -> origin/testcommit2444
+ = [up to date]      testcommit2445 -> origin/testcommit2445
+ = [up to date]      testcommit2446 -> origin/testcommit2446
+ = [up to date]      testcommit2447 -> origin/testcommit2447
+ = [up to date]      testcommit2448 -> origin/testcommit2448
+ = [up to date]      testcommit2449 -> origin/testcommit2449
+ = [up to date]      testcommit245 -> origin/testcommit245
+ = [up to date]      testcommit2450 -> origin/testcommit2450
+ = [up to date]      testcommit2451 -> origin/testcommit2451
+ = [up to date]      testcommit2452 -> origin/testcommit2452
+ = [up to date]      testcommit2453 -> origin/testcommit2453
+ = [up to date]      testcommit2454 -> origin/testcommit2454
+ = [up to date]      testcommit2455 -> origin/testcommit2455
+ = [up to date]      testcommit2456 -> origin/testcommit2456
+ = [up to date]      testcommit2457 -> origin/testcommit2457
+ = [up to date]      testcommit2458 -> origin/testcommit2458
+ = [up to date]      testcommit2459 -> origin/testcommit2459
+ = [up to date]      testcommit246 -> origin/testcommit246
+ = [up to date]      testcommit2460 -> origin/testcommit2460
+ = [up to date]      testcommit2461 -> origin/testcommit2461
+ = [up to date]      testcommit2462 -> origin/testcommit2462
+ = [up to date]      testcommit2463 -> origin/testcommit2463
+ = [up to date]      testcommit2464 -> origin/testcommit2464
+ = [up to date]      testcommit2465 -> origin/testcommit2465
+ = [up to date]      testcommit2466 -> origin/testcommit2466
+ = [up to date]      testcommit2467 -> origin/testcommit2467
+ = [up to date]      testcommit2468 -> origin/testcommit2468
+ = [up to date]      testcommit2469 -> origin/testcommit2469
+ = [up to date]      testcommit247 -> origin/testcommit247
+ = [up to date]      testcommit2470 -> origin/testcommit2470
+ = [up to date]      testcommit2471 -> origin/testcommit2471
+ = [up to date]      testcommit2472 -> origin/testcommit2472
+ = [up to date]      testcommit2473 -> origin/testcommit2473
+ = [up to date]      testcommit2474 -> origin/testcommit2474
+ = [up to date]      testcommit2475 -> origin/testcommit2475
+ = [up to date]      testcommit2476 -> origin/testcommit2476
+ = [up to date]      testcommit2477 -> origin/testcommit2477
+ = [up to date]      testcommit2478 -> origin/testcommit2478
+ = [up to date]      testcommit2479 -> origin/testcommit2479
+ = [up to date]      testcommit248 -> origin/testcommit248
+ = [up to date]      testcommit2480 -> origin/testcommit2480
+ = [up to date]      testcommit2481 -> origin/testcommit2481
+ = [up to date]      testcommit2482 -> origin/testcommit2482
+ = [up to date]      testcommit2483 -> origin/testcommit2483
+ = [up to date]      testcommit2484 -> origin/testcommit2484
+ = [up to date]      testcommit2485 -> origin/testcommit2485
+ = [up to date]      testcommit2486 -> origin/testcommit2486
+ = [up to date]      testcommit2487 -> origin/testcommit2487
+ = [up to date]      testcommit2488 -> origin/testcommit2488
+ = [up to date]      testcommit2489 -> origin/testcommit2489
+ = [up to date]      testcommit249 -> origin/testcommit249
+ = [up to date]      testcommit2490 -> origin/testcommit2490
+ = [up to date]      testcommit2491 -> origin/testcommit2491
+ = [up to date]      testcommit2492 -> origin/testcommit2492
+ = [up to date]      testcommit2493 -> origin/testcommit2493
+ = [up to date]      testcommit2494 -> origin/testcommit2494
+ = [up to date]      testcommit2495 -> origin/testcommit2495
+ = [up to date]      testcommit2496 -> origin/testcommit2496
+ = [up to date]      testcommit2497 -> origin/testcommit2497
+ = [up to date]      testcommit2498 -> origin/testcommit2498
+ = [up to date]      testcommit2499 -> origin/testcommit2499
+ = [up to date]      testcommit25 -> origin/testcommit25
+ = [up to date]      testcommit250 -> origin/testcommit250
+ = [up to date]      testcommit2500 -> origin/testcommit2500
+ = [up to date]      testcommit2501 -> origin/testcommit2501
+ = [up to date]      testcommit2502 -> origin/testcommit2502
+ = [up to date]      testcommit2503 -> origin/testcommit2503
+ = [up to date]      testcommit2504 -> origin/testcommit2504
+ = [up to date]      testcommit2505 -> origin/testcommit2505
+ = [up to date]      testcommit2506 -> origin/testcommit2506
+ = [up to date]      testcommit2507 -> origin/testcommit2507
+ = [up to date]      testcommit2508 -> origin/testcommit2508
+ = [up to date]      testcommit2509 -> origin/testcommit2509
+ = [up to date]      testcommit251 -> origin/testcommit251
+ = [up to date]      testcommit2510 -> origin/testcommit2510
+ = [up to date]      testcommit2511 -> origin/testcommit2511
+ = [up to date]      testcommit2512 -> origin/testcommit2512
+ = [up to date]      testcommit2513 -> origin/testcommit2513
+ = [up to date]      testcommit2514 -> origin/testcommit2514
+ = [up to date]      testcommit2515 -> origin/testcommit2515
+ = [up to date]      testcommit2516 -> origin/testcommit2516
+ = [up to date]      testcommit2517 -> origin/testcommit2517
+ = [up to date]      testcommit2518 -> origin/testcommit2518
+ = [up to date]      testcommit2519 -> origin/testcommit2519
+ = [up to date]      testcommit252 -> origin/testcommit252
+ = [up to date]      testcommit2520 -> origin/testcommit2520
+ = [up to date]      testcommit2521 -> origin/testcommit2521
+ = [up to date]      testcommit2522 -> origin/testcommit2522
+ = [up to date]      testcommit2523 -> origin/testcommit2523
+ = [up to date]      testcommit2524 -> origin/testcommit2524
+ = [up to date]      testcommit2525 -> origin/testcommit2525
+ = [up to date]      testcommit2526 -> origin/testcommit2526
+ = [up to date]      testcommit2527 -> origin/testcommit2527
+ = [up to date]      testcommit2528 -> origin/testcommit2528
+ = [up to date]      testcommit2529 -> origin/testcommit2529
+ = [up to date]      testcommit253 -> origin/testcommit253
+ = [up to date]      testcommit2530 -> origin/testcommit2530
+ = [up to date]      testcommit2531 -> origin/testcommit2531
+ = [up to date]      testcommit2532 -> origin/testcommit2532
+ = [up to date]      testcommit2533 -> origin/testcommit2533
+ = [up to date]      testcommit2534 -> origin/testcommit2534
+ = [up to date]      testcommit2535 -> origin/testcommit2535
+ = [up to date]      testcommit2536 -> origin/testcommit2536
+ = [up to date]      testcommit2537 -> origin/testcommit2537
+ = [up to date]      testcommit2538 -> origin/testcommit2538
+ = [up to date]      testcommit2539 -> origin/testcommit2539
+ = [up to date]      testcommit254 -> origin/testcommit254
+ = [up to date]      testcommit2540 -> origin/testcommit2540
+ = [up to date]      testcommit2541 -> origin/testcommit2541
+ = [up to date]      testcommit2542 -> origin/testcommit2542
+ = [up to date]      testcommit2543 -> origin/testcommit2543
+ = [up to date]      testcommit2544 -> origin/testcommit2544
+ = [up to date]      testcommit2545 -> origin/testcommit2545
+ = [up to date]      testcommit2546 -> origin/testcommit2546
+ = [up to date]      testcommit2547 -> origin/testcommit2547
+ = [up to date]      testcommit2548 -> origin/testcommit2548
+ = [up to date]      testcommit2549 -> origin/testcommit2549
+ = [up to date]      testcommit255 -> origin/testcommit255
+ = [up to date]      testcommit2550 -> origin/testcommit2550
+ = [up to date]      testcommit2551 -> origin/testcommit2551
+ = [up to date]      testcommit2552 -> origin/testcommit2552
+ = [up to date]      testcommit2553 -> origin/testcommit2553
+ = [up to date]      testcommit2554 -> origin/testcommit2554
+ = [up to date]      testcommit2555 -> origin/testcommit2555
+ = [up to date]      testcommit2556 -> origin/testcommit2556
+ = [up to date]      testcommit2557 -> origin/testcommit2557
+ = [up to date]      testcommit2558 -> origin/testcommit2558
+ = [up to date]      testcommit2559 -> origin/testcommit2559
+ = [up to date]      testcommit256 -> origin/testcommit256
+ = [up to date]      testcommit2560 -> origin/testcommit2560
+ = [up to date]      testcommit2561 -> origin/testcommit2561
+ = [up to date]      testcommit2562 -> origin/testcommit2562
+ = [up to date]      testcommit2563 -> origin/testcommit2563
+ = [up to date]      testcommit2564 -> origin/testcommit2564
+ = [up to date]      testcommit2565 -> origin/testcommit2565
+ = [up to date]      testcommit2566 -> origin/testcommit2566
+ = [up to date]      testcommit2567 -> origin/testcommit2567
+ = [up to date]      testcommit2568 -> origin/testcommit2568
+ = [up to date]      testcommit2569 -> origin/testcommit2569
+ = [up to date]      testcommit257 -> origin/testcommit257
+ = [up to date]      testcommit2570 -> origin/testcommit2570
+ = [up to date]      testcommit2571 -> origin/testcommit2571
+ = [up to date]      testcommit2572 -> origin/testcommit2572
+ = [up to date]      testcommit2573 -> origin/testcommit2573
+ = [up to date]      testcommit2574 -> origin/testcommit2574
+ = [up to date]      testcommit2575 -> origin/testcommit2575
+ = [up to date]      testcommit2576 -> origin/testcommit2576
+ = [up to date]      testcommit2577 -> origin/testcommit2577
+ = [up to date]      testcommit2578 -> origin/testcommit2578
+ = [up to date]      testcommit2579 -> origin/testcommit2579
+ = [up to date]      testcommit258 -> origin/testcommit258
+ = [up to date]      testcommit2580 -> origin/testcommit2580
+ = [up to date]      testcommit2581 -> origin/testcommit2581
+ = [up to date]      testcommit2582 -> origin/testcommit2582
+ = [up to date]      testcommit2583 -> origin/testcommit2583
+ = [up to date]      testcommit2584 -> origin/testcommit2584
+ = [up to date]      testcommit2585 -> origin/testcommit2585
+ = [up to date]      testcommit2586 -> origin/testcommit2586
+ = [up to date]      testcommit2587 -> origin/testcommit2587
+ = [up to date]      testcommit2588 -> origin/testcommit2588
+ = [up to date]      testcommit2589 -> origin/testcommit2589
+ = [up to date]      testcommit259 -> origin/testcommit259
+ = [up to date]      testcommit2590 -> origin/testcommit2590
+ = [up to date]      testcommit2591 -> origin/testcommit2591
+ = [up to date]      testcommit2592 -> origin/testcommit2592
+ = [up to date]      testcommit2593 -> origin/testcommit2593
+ = [up to date]      testcommit2594 -> origin/testcommit2594
+ = [up to date]      testcommit2595 -> origin/testcommit2595
+ = [up to date]      testcommit2596 -> origin/testcommit2596
+ = [up to date]      testcommit2597 -> origin/testcommit2597
+ = [up to date]      testcommit2598 -> origin/testcommit2598
+ = [up to date]      testcommit2599 -> origin/testcommit2599
+ = [up to date]      testcommit26 -> origin/testcommit26
+ = [up to date]      testcommit260 -> origin/testcommit260
+ = [up to date]      testcommit2600 -> origin/testcommit2600
+ = [up to date]      testcommit2601 -> origin/testcommit2601
+ = [up to date]      testcommit2602 -> origin/testcommit2602
+ = [up to date]      testcommit2603 -> origin/testcommit2603
+ = [up to date]      testcommit2604 -> origin/testcommit2604
+ = [up to date]      testcommit2605 -> origin/testcommit2605
+ = [up to date]      testcommit2606 -> origin/testcommit2606
+ = [up to date]      testcommit2607 -> origin/testcommit2607
+ = [up to date]      testcommit2608 -> origin/testcommit2608
+ = [up to date]      testcommit2609 -> origin/testcommit2609
+ = [up to date]      testcommit261 -> origin/testcommit261
+ = [up to date]      testcommit2610 -> origin/testcommit2610
+ = [up to date]      testcommit2611 -> origin/testcommit2611
+ = [up to date]      testcommit2612 -> origin/testcommit2612
+ = [up to date]      testcommit2613 -> origin/testcommit2613
+ = [up to date]      testcommit2614 -> origin/testcommit2614
+ = [up to date]      testcommit2615 -> origin/testcommit2615
+ = [up to date]      testcommit2616 -> origin/testcommit2616
+ = [up to date]      testcommit2617 -> origin/testcommit2617
+ = [up to date]      testcommit2618 -> origin/testcommit2618
+ = [up to date]      testcommit2619 -> origin/testcommit2619
+ = [up to date]      testcommit262 -> origin/testcommit262
+ = [up to date]      testcommit2620 -> origin/testcommit2620
+ = [up to date]      testcommit2621 -> origin/testcommit2621
+ = [up to date]      testcommit2622 -> origin/testcommit2622
+ = [up to date]      testcommit2623 -> origin/testcommit2623
+ = [up to date]      testcommit2624 -> origin/testcommit2624
+ = [up to date]      testcommit2625 -> origin/testcommit2625
+ = [up to date]      testcommit2626 -> origin/testcommit2626
+ = [up to date]      testcommit2627 -> origin/testcommit2627
+ = [up to date]      testcommit2628 -> origin/testcommit2628
+ = [up to date]      testcommit2629 -> origin/testcommit2629
+ = [up to date]      testcommit263 -> origin/testcommit263
+ = [up to date]      testcommit2630 -> origin/testcommit2630
+ = [up to date]      testcommit2631 -> origin/testcommit2631
+ = [up to date]      testcommit2632 -> origin/testcommit2632
+ = [up to date]      testcommit2633 -> origin/testcommit2633
+ = [up to date]      testcommit2634 -> origin/testcommit2634
+ = [up to date]      testcommit2635 -> origin/testcommit2635
+ = [up to date]      testcommit2636 -> origin/testcommit2636
+ = [up to date]      testcommit2637 -> origin/testcommit2637
+ = [up to date]      testcommit2638 -> origin/testcommit2638
+ = [up to date]      testcommit2639 -> origin/testcommit2639
+ = [up to date]      testcommit264 -> origin/testcommit264
+ = [up to date]      testcommit2640 -> origin/testcommit2640
+ = [up to date]      testcommit2641 -> origin/testcommit2641
+ = [up to date]      testcommit2642 -> origin/testcommit2642
+ = [up to date]      testcommit2643 -> origin/testcommit2643
+ = [up to date]      testcommit2644 -> origin/testcommit2644
+ = [up to date]      testcommit2645 -> origin/testcommit2645
+ = [up to date]      testcommit2646 -> origin/testcommit2646
+ = [up to date]      testcommit2647 -> origin/testcommit2647
+ = [up to date]      testcommit2648 -> origin/testcommit2648
+ = [up to date]      testcommit2649 -> origin/testcommit2649
+ = [up to date]      testcommit265 -> origin/testcommit265
+ = [up to date]      testcommit2650 -> origin/testcommit2650
+ = [up to date]      testcommit2651 -> origin/testcommit2651
+ = [up to date]      testcommit2652 -> origin/testcommit2652
+ = [up to date]      testcommit2653 -> origin/testcommit2653
+ = [up to date]      testcommit2654 -> origin/testcommit2654
+ = [up to date]      testcommit2655 -> origin/testcommit2655
+ = [up to date]      testcommit2656 -> origin/testcommit2656
+ = [up to date]      testcommit2657 -> origin/testcommit2657
+ = [up to date]      testcommit2658 -> origin/testcommit2658
+ = [up to date]      testcommit2659 -> origin/testcommit2659
+ = [up to date]      testcommit266 -> origin/testcommit266
+ = [up to date]      testcommit2660 -> origin/testcommit2660
+ = [up to date]      testcommit2661 -> origin/testcommit2661
+ = [up to date]      testcommit2662 -> origin/testcommit2662
+ = [up to date]      testcommit2663 -> origin/testcommit2663
+ = [up to date]      testcommit2664 -> origin/testcommit2664
+ = [up to date]      testcommit2665 -> origin/testcommit2665
+ = [up to date]      testcommit2666 -> origin/testcommit2666
+ = [up to date]      testcommit2667 -> origin/testcommit2667
+ = [up to date]      testcommit2668 -> origin/testcommit2668
+ = [up to date]      testcommit2669 -> origin/testcommit2669
+ = [up to date]      testcommit267 -> origin/testcommit267
+ = [up to date]      testcommit2670 -> origin/testcommit2670
+ = [up to date]      testcommit2671 -> origin/testcommit2671
+ = [up to date]      testcommit2672 -> origin/testcommit2672
+ = [up to date]      testcommit2673 -> origin/testcommit2673
+ = [up to date]      testcommit2674 -> origin/testcommit2674
+ = [up to date]      testcommit2675 -> origin/testcommit2675
+ = [up to date]      testcommit2676 -> origin/testcommit2676
+ = [up to date]      testcommit2677 -> origin/testcommit2677
+ = [up to date]      testcommit2678 -> origin/testcommit2678
+ = [up to date]      testcommit2679 -> origin/testcommit2679
+ = [up to date]      testcommit268 -> origin/testcommit268
+ = [up to date]      testcommit2680 -> origin/testcommit2680
+ = [up to date]      testcommit2681 -> origin/testcommit2681
+ = [up to date]      testcommit2682 -> origin/testcommit2682
+ = [up to date]      testcommit2683 -> origin/testcommit2683
+ = [up to date]      testcommit2684 -> origin/testcommit2684
+ = [up to date]      testcommit2685 -> origin/testcommit2685
+ = [up to date]      testcommit2686 -> origin/testcommit2686
+ = [up to date]      testcommit2687 -> origin/testcommit2687
+ = [up to date]      testcommit2688 -> origin/testcommit2688
+ = [up to date]      testcommit2689 -> origin/testcommit2689
+ = [up to date]      testcommit269 -> origin/testcommit269
+ = [up to date]      testcommit2690 -> origin/testcommit2690
+ = [up to date]      testcommit2691 -> origin/testcommit2691
+ = [up to date]      testcommit2692 -> origin/testcommit2692
+ = [up to date]      testcommit2693 -> origin/testcommit2693
+ = [up to date]      testcommit2694 -> origin/testcommit2694
+ = [up to date]      testcommit2695 -> origin/testcommit2695
+ = [up to date]      testcommit2696 -> origin/testcommit2696
+ = [up to date]      testcommit2697 -> origin/testcommit2697
+ = [up to date]      testcommit2698 -> origin/testcommit2698
+ = [up to date]      testcommit2699 -> origin/testcommit2699
+ = [up to date]      testcommit27 -> origin/testcommit27
+ = [up to date]      testcommit270 -> origin/testcommit270
+ = [up to date]      testcommit2700 -> origin/testcommit2700
+ = [up to date]      testcommit2701 -> origin/testcommit2701
+ = [up to date]      testcommit2702 -> origin/testcommit2702
+ = [up to date]      testcommit2703 -> origin/testcommit2703
+ = [up to date]      testcommit2704 -> origin/testcommit2704
+ = [up to date]      testcommit2705 -> origin/testcommit2705
+ = [up to date]      testcommit2706 -> origin/testcommit2706
+ = [up to date]      testcommit2707 -> origin/testcommit2707
+ = [up to date]      testcommit2708 -> origin/testcommit2708
+ = [up to date]      testcommit2709 -> origin/testcommit2709
+ = [up to date]      testcommit271 -> origin/testcommit271
+ = [up to date]      testcommit2710 -> origin/testcommit2710
+ = [up to date]      testcommit2711 -> origin/testcommit2711
+ = [up to date]      testcommit2712 -> origin/testcommit2712
+ = [up to date]      testcommit2713 -> origin/testcommit2713
+ = [up to date]      testcommit2714 -> origin/testcommit2714
+ = [up to date]      testcommit2715 -> origin/testcommit2715
+ = [up to date]      testcommit2716 -> origin/testcommit2716
+ = [up to date]      testcommit2717 -> origin/testcommit2717
+ = [up to date]      testcommit2718 -> origin/testcommit2718
+ = [up to date]      testcommit2719 -> origin/testcommit2719
+ = [up to date]      testcommit272 -> origin/testcommit272
+ = [up to date]      testcommit2720 -> origin/testcommit2720
+ = [up to date]      testcommit2721 -> origin/testcommit2721
+ = [up to date]      testcommit2722 -> origin/testcommit2722
+ = [up to date]      testcommit2723 -> origin/testcommit2723
+ = [up to date]      testcommit2724 -> origin/testcommit2724
+ = [up to date]      testcommit2725 -> origin/testcommit2725
+ = [up to date]      testcommit2726 -> origin/testcommit2726
+ = [up to date]      testcommit2727 -> origin/testcommit2727
+ = [up to date]      testcommit2728 -> origin/testcommit2728
+ = [up to date]      testcommit2729 -> origin/testcommit2729
+ = [up to date]      testcommit273 -> origin/testcommit273
+ = [up to date]      testcommit2730 -> origin/testcommit2730
+ = [up to date]      testcommit2731 -> origin/testcommit2731
+ = [up to date]      testcommit2732 -> origin/testcommit2732
+ = [up to date]      testcommit2733 -> origin/testcommit2733
+ = [up to date]      testcommit2734 -> origin/testcommit2734
+ = [up to date]      testcommit2735 -> origin/testcommit2735
+ = [up to date]      testcommit2736 -> origin/testcommit2736
+ = [up to date]      testcommit2737 -> origin/testcommit2737
+ = [up to date]      testcommit2738 -> origin/testcommit2738
+ = [up to date]      testcommit2739 -> origin/testcommit2739
+ = [up to date]      testcommit274 -> origin/testcommit274
+ = [up to date]      testcommit2740 -> origin/testcommit2740
+ = [up to date]      testcommit2741 -> origin/testcommit2741
+ = [up to date]      testcommit2742 -> origin/testcommit2742
+ = [up to date]      testcommit2743 -> origin/testcommit2743
+ = [up to date]      testcommit2744 -> origin/testcommit2744
+ = [up to date]      testcommit2745 -> origin/testcommit2745
+ = [up to date]      testcommit2746 -> origin/testcommit2746
+ = [up to date]      testcommit2747 -> origin/testcommit2747
+ = [up to date]      testcommit2748 -> origin/testcommit2748
+ = [up to date]      testcommit2749 -> origin/testcommit2749
+ = [up to date]      testcommit275 -> origin/testcommit275
+ = [up to date]      testcommit2750 -> origin/testcommit2750
+ = [up to date]      testcommit2751 -> origin/testcommit2751
+ = [up to date]      testcommit2752 -> origin/testcommit2752
+ = [up to date]      testcommit2753 -> origin/testcommit2753
+ = [up to date]      testcommit2754 -> origin/testcommit2754
+ = [up to date]      testcommit2755 -> origin/testcommit2755
+ = [up to date]      testcommit2756 -> origin/testcommit2756
+ = [up to date]      testcommit2757 -> origin/testcommit2757
+ = [up to date]      testcommit2758 -> origin/testcommit2758
+ = [up to date]      testcommit2759 -> origin/testcommit2759
+ = [up to date]      testcommit276 -> origin/testcommit276
+ = [up to date]      testcommit2760 -> origin/testcommit2760
+ = [up to date]      testcommit2761 -> origin/testcommit2761
+ = [up to date]      testcommit2762 -> origin/testcommit2762
+ = [up to date]      testcommit2763 -> origin/testcommit2763
+ = [up to date]      testcommit2764 -> origin/testcommit2764
+ = [up to date]      testcommit2765 -> origin/testcommit2765
+ = [up to date]      testcommit2766 -> origin/testcommit2766
+ = [up to date]      testcommit2767 -> origin/testcommit2767
+ = [up to date]      testcommit2768 -> origin/testcommit2768
+ = [up to date]      testcommit2769 -> origin/testcommit2769
+ = [up to date]      testcommit277 -> origin/testcommit277
+ = [up to date]      testcommit2770 -> origin/testcommit2770
+ = [up to date]      testcommit2771 -> origin/testcommit2771
+ = [up to date]      testcommit2772 -> origin/testcommit2772
+ = [up to date]      testcommit2773 -> origin/testcommit2773
+ = [up to date]      testcommit2774 -> origin/testcommit2774
+ = [up to date]      testcommit2775 -> origin/testcommit2775
+ = [up to date]      testcommit2776 -> origin/testcommit2776
+ = [up to date]      testcommit2777 -> origin/testcommit2777
+ = [up to date]      testcommit2778 -> origin/testcommit2778
+ = [up to date]      testcommit2779 -> origin/testcommit2779
+ = [up to date]      testcommit278 -> origin/testcommit278
+ = [up to date]      testcommit2780 -> origin/testcommit2780
+ = [up to date]      testcommit2781 -> origin/testcommit2781
+ = [up to date]      testcommit2782 -> origin/testcommit2782
+ = [up to date]      testcommit2783 -> origin/testcommit2783
+ = [up to date]      testcommit2784 -> origin/testcommit2784
+ = [up to date]      testcommit2785 -> origin/testcommit2785
+ = [up to date]      testcommit2786 -> origin/testcommit2786
+ = [up to date]      testcommit2787 -> origin/testcommit2787
+ = [up to date]      testcommit2788 -> origin/testcommit2788
+ = [up to date]      testcommit2789 -> origin/testcommit2789
+ = [up to date]      testcommit279 -> origin/testcommit279
+ = [up to date]      testcommit2790 -> origin/testcommit2790
+ = [up to date]      testcommit2791 -> origin/testcommit2791
+ = [up to date]      testcommit2792 -> origin/testcommit2792
+ = [up to date]      testcommit2793 -> origin/testcommit2793
+ = [up to date]      testcommit2794 -> origin/testcommit2794
+ = [up to date]      testcommit2795 -> origin/testcommit2795
+ = [up to date]      testcommit2796 -> origin/testcommit2796
+ = [up to date]      testcommit2797 -> origin/testcommit2797
+ = [up to date]      testcommit2798 -> origin/testcommit2798
+ = [up to date]      testcommit2799 -> origin/testcommit2799
+ = [up to date]      testcommit28 -> origin/testcommit28
+ = [up to date]      testcommit280 -> origin/testcommit280
+ = [up to date]      testcommit2800 -> origin/testcommit2800
+ = [up to date]      testcommit2801 -> origin/testcommit2801
+ = [up to date]      testcommit2802 -> origin/testcommit2802
+ = [up to date]      testcommit2803 -> origin/testcommit2803
+ = [up to date]      testcommit2804 -> origin/testcommit2804
+ = [up to date]      testcommit2805 -> origin/testcommit2805
+ = [up to date]      testcommit2806 -> origin/testcommit2806
+ = [up to date]      testcommit2807 -> origin/testcommit2807
+ = [up to date]      testcommit2808 -> origin/testcommit2808
+ = [up to date]      testcommit2809 -> origin/testcommit2809
+ = [up to date]      testcommit281 -> origin/testcommit281
+ = [up to date]      testcommit2810 -> origin/testcommit2810
+ = [up to date]      testcommit2811 -> origin/testcommit2811
+ = [up to date]      testcommit2812 -> origin/testcommit2812
+ = [up to date]      testcommit2813 -> origin/testcommit2813
+ = [up to date]      testcommit2814 -> origin/testcommit2814
+ = [up to date]      testcommit2815 -> origin/testcommit2815
+ = [up to date]      testcommit2816 -> origin/testcommit2816
+ = [up to date]      testcommit2817 -> origin/testcommit2817
+ = [up to date]      testcommit2818 -> origin/testcommit2818
+ = [up to date]      testcommit2819 -> origin/testcommit2819
+ = [up to date]      testcommit282 -> origin/testcommit282
+ = [up to date]      testcommit2820 -> origin/testcommit2820
+ = [up to date]      testcommit2821 -> origin/testcommit2821
+ = [up to date]      testcommit2822 -> origin/testcommit2822
+ = [up to date]      testcommit2823 -> origin/testcommit2823
+ = [up to date]      testcommit2824 -> origin/testcommit2824
+ = [up to date]      testcommit2825 -> origin/testcommit2825
+ = [up to date]      testcommit2826 -> origin/testcommit2826
+ = [up to date]      testcommit2827 -> origin/testcommit2827
+ = [up to date]      testcommit2828 -> origin/testcommit2828
+ = [up to date]      testcommit2829 -> origin/testcommit2829
+ = [up to date]      testcommit283 -> origin/testcommit283
+ = [up to date]      testcommit2830 -> origin/testcommit2830
+ = [up to date]      testcommit2831 -> origin/testcommit2831
+ = [up to date]      testcommit2832 -> origin/testcommit2832
+ = [up to date]      testcommit2833 -> origin/testcommit2833
+ = [up to date]      testcommit2834 -> origin/testcommit2834
+ = [up to date]      testcommit2835 -> origin/testcommit2835
+ = [up to date]      testcommit2836 -> origin/testcommit2836
+ = [up to date]      testcommit2837 -> origin/testcommit2837
+ = [up to date]      testcommit2838 -> origin/testcommit2838
+ = [up to date]      testcommit2839 -> origin/testcommit2839
+ = [up to date]      testcommit284 -> origin/testcommit284
+ = [up to date]      testcommit2840 -> origin/testcommit2840
+ = [up to date]      testcommit2841 -> origin/testcommit2841
+ = [up to date]      testcommit2842 -> origin/testcommit2842
+ = [up to date]      testcommit2843 -> origin/testcommit2843
+ = [up to date]      testcommit2844 -> origin/testcommit2844
+ = [up to date]      testcommit2845 -> origin/testcommit2845
+ = [up to date]      testcommit2846 -> origin/testcommit2846
+ = [up to date]      testcommit2847 -> origin/testcommit2847
+ = [up to date]      testcommit2848 -> origin/testcommit2848
+ = [up to date]      testcommit2849 -> origin/testcommit2849
+ = [up to date]      testcommit285 -> origin/testcommit285
+ = [up to date]      testcommit2850 -> origin/testcommit2850
+ = [up to date]      testcommit2851 -> origin/testcommit2851
+ = [up to date]      testcommit2852 -> origin/testcommit2852
+ = [up to date]      testcommit2853 -> origin/testcommit2853
+ = [up to date]      testcommit2854 -> origin/testcommit2854
+ = [up to date]      testcommit2855 -> origin/testcommit2855
+ = [up to date]      testcommit2856 -> origin/testcommit2856
+ = [up to date]      testcommit2857 -> origin/testcommit2857
+ = [up to date]      testcommit2858 -> origin/testcommit2858
+ = [up to date]      testcommit2859 -> origin/testcommit2859
+ = [up to date]      testcommit286 -> origin/testcommit286
+ = [up to date]      testcommit2860 -> origin/testcommit2860
+ = [up to date]      testcommit2861 -> origin/testcommit2861
+ = [up to date]      testcommit2862 -> origin/testcommit2862
+ = [up to date]      testcommit2863 -> origin/testcommit2863
+ = [up to date]      testcommit2864 -> origin/testcommit2864
+ = [up to date]      testcommit2865 -> origin/testcommit2865
+ = [up to date]      testcommit2866 -> origin/testcommit2866
+ = [up to date]      testcommit2867 -> origin/testcommit2867
+ = [up to date]      testcommit2868 -> origin/testcommit2868
+ = [up to date]      testcommit2869 -> origin/testcommit2869
+ = [up to date]      testcommit287 -> origin/testcommit287
+ = [up to date]      testcommit2870 -> origin/testcommit2870
+ = [up to date]      testcommit2871 -> origin/testcommit2871
+ = [up to date]      testcommit2872 -> origin/testcommit2872
+ = [up to date]      testcommit2873 -> origin/testcommit2873
+ = [up to date]      testcommit2874 -> origin/testcommit2874
+ = [up to date]      testcommit2875 -> origin/testcommit2875
+ = [up to date]      testcommit2876 -> origin/testcommit2876
+ = [up to date]      testcommit2877 -> origin/testcommit2877
+ = [up to date]      testcommit2878 -> origin/testcommit2878
+ = [up to date]      testcommit2879 -> origin/testcommit2879
+ = [up to date]      testcommit288 -> origin/testcommit288
+ = [up to date]      testcommit2880 -> origin/testcommit2880
+ = [up to date]      testcommit2881 -> origin/testcommit2881
+ = [up to date]      testcommit2882 -> origin/testcommit2882
+ = [up to date]      testcommit2883 -> origin/testcommit2883
+ = [up to date]      testcommit2884 -> origin/testcommit2884
+ = [up to date]      testcommit2885 -> origin/testcommit2885
+ = [up to date]      testcommit2886 -> origin/testcommit2886
+ = [up to date]      testcommit2887 -> origin/testcommit2887
+ = [up to date]      testcommit2888 -> origin/testcommit2888
+ = [up to date]      testcommit2889 -> origin/testcommit2889
+ = [up to date]      testcommit289 -> origin/testcommit289
+ = [up to date]      testcommit2890 -> origin/testcommit2890
+ = [up to date]      testcommit2891 -> origin/testcommit2891
+ = [up to date]      testcommit2892 -> origin/testcommit2892
+ = [up to date]      testcommit2893 -> origin/testcommit2893
+ = [up to date]      testcommit2894 -> origin/testcommit2894
+ = [up to date]      testcommit2895 -> origin/testcommit2895
+ = [up to date]      testcommit2896 -> origin/testcommit2896
+ = [up to date]      testcommit2897 -> origin/testcommit2897
+ = [up to date]      testcommit2898 -> origin/testcommit2898
+ = [up to date]      testcommit2899 -> origin/testcommit2899
+ = [up to date]      testcommit29 -> origin/testcommit29
+ = [up to date]      testcommit290 -> origin/testcommit290
+ = [up to date]      testcommit2900 -> origin/testcommit2900
+ = [up to date]      testcommit2901 -> origin/testcommit2901
+ = [up to date]      testcommit2902 -> origin/testcommit2902
+ = [up to date]      testcommit2903 -> origin/testcommit2903
+ = [up to date]      testcommit2904 -> origin/testcommit2904
+ = [up to date]      testcommit2905 -> origin/testcommit2905
+ = [up to date]      testcommit2906 -> origin/testcommit2906
+ = [up to date]      testcommit2907 -> origin/testcommit2907
+ = [up to date]      testcommit2908 -> origin/testcommit2908
+ = [up to date]      testcommit2909 -> origin/testcommit2909
+ = [up to date]      testcommit291 -> origin/testcommit291
+ = [up to date]      testcommit2910 -> origin/testcommit2910
+ = [up to date]      testcommit2911 -> origin/testcommit2911
+ = [up to date]      testcommit2912 -> origin/testcommit2912
+ = [up to date]      testcommit2913 -> origin/testcommit2913
+ = [up to date]      testcommit2914 -> origin/testcommit2914
+ = [up to date]      testcommit2915 -> origin/testcommit2915
+ = [up to date]      testcommit2916 -> origin/testcommit2916
+ = [up to date]      testcommit2917 -> origin/testcommit2917
+ = [up to date]      testcommit2918 -> origin/testcommit2918
+ = [up to date]      testcommit2919 -> origin/testcommit2919
+ = [up to date]      testcommit292 -> origin/testcommit292
+ = [up to date]      testcommit2920 -> origin/testcommit2920
+ = [up to date]      testcommit2921 -> origin/testcommit2921
+ = [up to date]      testcommit2922 -> origin/testcommit2922
+ = [up to date]      testcommit2923 -> origin/testcommit2923
+ = [up to date]      testcommit2924 -> origin/testcommit2924
+ = [up to date]      testcommit2925 -> origin/testcommit2925
+ = [up to date]      testcommit2926 -> origin/testcommit2926
+ = [up to date]      testcommit2927 -> origin/testcommit2927
+ = [up to date]      testcommit2928 -> origin/testcommit2928
+ = [up to date]      testcommit2929 -> origin/testcommit2929
+ = [up to date]      testcommit293 -> origin/testcommit293
+ = [up to date]      testcommit2930 -> origin/testcommit2930
+ = [up to date]      testcommit2931 -> origin/testcommit2931
+ = [up to date]      testcommit2932 -> origin/testcommit2932
+ = [up to date]      testcommit2933 -> origin/testcommit2933
+ = [up to date]      testcommit2934 -> origin/testcommit2934
+ = [up to date]      testcommit2935 -> origin/testcommit2935
+ = [up to date]      testcommit2936 -> origin/testcommit2936
+ = [up to date]      testcommit2937 -> origin/testcommit2937
+ = [up to date]      testcommit2938 -> origin/testcommit2938
+ = [up to date]      testcommit2939 -> origin/testcommit2939
+ = [up to date]      testcommit294 -> origin/testcommit294
+ = [up to date]      testcommit2940 -> origin/testcommit2940
+ = [up to date]      testcommit2941 -> origin/testcommit2941
+ = [up to date]      testcommit2942 -> origin/testcommit2942
+ = [up to date]      testcommit2943 -> origin/testcommit2943
+ = [up to date]      testcommit2944 -> origin/testcommit2944
+ = [up to date]      testcommit2945 -> origin/testcommit2945
+ = [up to date]      testcommit2946 -> origin/testcommit2946
+ = [up to date]      testcommit2947 -> origin/testcommit2947
+ = [up to date]      testcommit2948 -> origin/testcommit2948
+ = [up to date]      testcommit2949 -> origin/testcommit2949
+ = [up to date]      testcommit295 -> origin/testcommit295
+ = [up to date]      testcommit2950 -> origin/testcommit2950
+ = [up to date]      testcommit2951 -> origin/testcommit2951
+ = [up to date]      testcommit2952 -> origin/testcommit2952
+ = [up to date]      testcommit2953 -> origin/testcommit2953
+ = [up to date]      testcommit2954 -> origin/testcommit2954
+ = [up to date]      testcommit2955 -> origin/testcommit2955
+ = [up to date]      testcommit2956 -> origin/testcommit2956
+ = [up to date]      testcommit2957 -> origin/testcommit2957
+ = [up to date]      testcommit2958 -> origin/testcommit2958
+ = [up to date]      testcommit2959 -> origin/testcommit2959
+ = [up to date]      testcommit296 -> origin/testcommit296
+ = [up to date]      testcommit2960 -> origin/testcommit2960
+ = [up to date]      testcommit2961 -> origin/testcommit2961
+ = [up to date]      testcommit2962 -> origin/testcommit2962
+ = [up to date]      testcommit2963 -> origin/testcommit2963
+ = [up to date]      testcommit2964 -> origin/testcommit2964
+ = [up to date]      testcommit2965 -> origin/testcommit2965
+ = [up to date]      testcommit2966 -> origin/testcommit2966
+ = [up to date]      testcommit2967 -> origin/testcommit2967
+ = [up to date]      testcommit2968 -> origin/testcommit2968
+ = [up to date]      testcommit2969 -> origin/testcommit2969
+ = [up to date]      testcommit297 -> origin/testcommit297
+ = [up to date]      testcommit2970 -> origin/testcommit2970
+ = [up to date]      testcommit2971 -> origin/testcommit2971
+ = [up to date]      testcommit2972 -> origin/testcommit2972
+ = [up to date]      testcommit2973 -> origin/testcommit2973
+ = [up to date]      testcommit2974 -> origin/testcommit2974
+ = [up to date]      testcommit2975 -> origin/testcommit2975
+ = [up to date]      testcommit2976 -> origin/testcommit2976
+ = [up to date]      testcommit2977 -> origin/testcommit2977
+ = [up to date]      testcommit2978 -> origin/testcommit2978
+ = [up to date]      testcommit2979 -> origin/testcommit2979
+ = [up to date]      testcommit298 -> origin/testcommit298
+ = [up to date]      testcommit2980 -> origin/testcommit2980
+ = [up to date]      testcommit2981 -> origin/testcommit2981
+ = [up to date]      testcommit2982 -> origin/testcommit2982
+ = [up to date]      testcommit2983 -> origin/testcommit2983
+ = [up to date]      testcommit2984 -> origin/testcommit2984
+ = [up to date]      testcommit2985 -> origin/testcommit2985
+ = [up to date]      testcommit2986 -> origin/testcommit2986
+ = [up to date]      testcommit2987 -> origin/testcommit2987
+ = [up to date]      testcommit2988 -> origin/testcommit2988
+ = [up to date]      testcommit2989 -> origin/testcommit2989
+ = [up to date]      testcommit299 -> origin/testcommit299
+ = [up to date]      testcommit2990 -> origin/testcommit2990
+ = [up to date]      testcommit2991 -> origin/testcommit2991
+ = [up to date]      testcommit2992 -> origin/testcommit2992
+ = [up to date]      testcommit2993 -> origin/testcommit2993
+ = [up to date]      testcommit2994 -> origin/testcommit2994
+ = [up to date]      testcommit2995 -> origin/testcommit2995
+ = [up to date]      testcommit2996 -> origin/testcommit2996
+ = [up to date]      testcommit2997 -> origin/testcommit2997
+ = [up to date]      testcommit2998 -> origin/testcommit2998
+ = [up to date]      testcommit2999 -> origin/testcommit2999
+ = [up to date]      testcommit3 -> origin/testcommit3
+ = [up to date]      testcommit30 -> origin/testcommit30
+ = [up to date]      testcommit300 -> origin/testcommit300
+ = [up to date]      testcommit3000 -> origin/testcommit3000
+ = [up to date]      testcommit3001 -> origin/testcommit3001
+ = [up to date]      testcommit3002 -> origin/testcommit3002
+ = [up to date]      testcommit3003 -> origin/testcommit3003
+ = [up to date]      testcommit3004 -> origin/testcommit3004
+ = [up to date]      testcommit3005 -> origin/testcommit3005
+ = [up to date]      testcommit3006 -> origin/testcommit3006
+ = [up to date]      testcommit3007 -> origin/testcommit3007
+ = [up to date]      testcommit3008 -> origin/testcommit3008
+ = [up to date]      testcommit3009 -> origin/testcommit3009
+ = [up to date]      testcommit301 -> origin/testcommit301
+ = [up to date]      testcommit3010 -> origin/testcommit3010
+ = [up to date]      testcommit3011 -> origin/testcommit3011
+ = [up to date]      testcommit3012 -> origin/testcommit3012
+ = [up to date]      testcommit3013 -> origin/testcommit3013
+ = [up to date]      testcommit3014 -> origin/testcommit3014
+ = [up to date]      testcommit3015 -> origin/testcommit3015
+ = [up to date]      testcommit3016 -> origin/testcommit3016
+ = [up to date]      testcommit3017 -> origin/testcommit3017
+ = [up to date]      testcommit3018 -> origin/testcommit3018
+ = [up to date]      testcommit3019 -> origin/testcommit3019
+ = [up to date]      testcommit302 -> origin/testcommit302
+ = [up to date]      testcommit3020 -> origin/testcommit3020
+ = [up to date]      testcommit3021 -> origin/testcommit3021
+ = [up to date]      testcommit3022 -> origin/testcommit3022
+ = [up to date]      testcommit3023 -> origin/testcommit3023
+ = [up to date]      testcommit3024 -> origin/testcommit3024
+ = [up to date]      testcommit3025 -> origin/testcommit3025
+ = [up to date]      testcommit3026 -> origin/testcommit3026
+ = [up to date]      testcommit3027 -> origin/testcommit3027
+ = [up to date]      testcommit3028 -> origin/testcommit3028
+ = [up to date]      testcommit3029 -> origin/testcommit3029
+ = [up to date]      testcommit303 -> origin/testcommit303
+ = [up to date]      testcommit3030 -> origin/testcommit3030
+ = [up to date]      testcommit3031 -> origin/testcommit3031
+ = [up to date]      testcommit3032 -> origin/testcommit3032
+ = [up to date]      testcommit3033 -> origin/testcommit3033
+ = [up to date]      testcommit3034 -> origin/testcommit3034
+ = [up to date]      testcommit3035 -> origin/testcommit3035
+ = [up to date]      testcommit3036 -> origin/testcommit3036
+ = [up to date]      testcommit3037 -> origin/testcommit3037
+ = [up to date]      testcommit3038 -> origin/testcommit3038
+ = [up to date]      testcommit3039 -> origin/testcommit3039
+ = [up to date]      testcommit304 -> origin/testcommit304
+ = [up to date]      testcommit3040 -> origin/testcommit3040
+ = [up to date]      testcommit3041 -> origin/testcommit3041
+ = [up to date]      testcommit3042 -> origin/testcommit3042
+ = [up to date]      testcommit3043 -> origin/testcommit3043
+ = [up to date]      testcommit3044 -> origin/testcommit3044
+ = [up to date]      testcommit3045 -> origin/testcommit3045
+ = [up to date]      testcommit3046 -> origin/testcommit3046
+ = [up to date]      testcommit3047 -> origin/testcommit3047
+ = [up to date]      testcommit3048 -> origin/testcommit3048
+ = [up to date]      testcommit3049 -> origin/testcommit3049
+ = [up to date]      testcommit305 -> origin/testcommit305
+ = [up to date]      testcommit3050 -> origin/testcommit3050
+ = [up to date]      testcommit3051 -> origin/testcommit3051
+ = [up to date]      testcommit3052 -> origin/testcommit3052
+ = [up to date]      testcommit3053 -> origin/testcommit3053
+ = [up to date]      testcommit3054 -> origin/testcommit3054
+ = [up to date]      testcommit3055 -> origin/testcommit3055
+ = [up to date]      testcommit3056 -> origin/testcommit3056
+ = [up to date]      testcommit3057 -> origin/testcommit3057
+ = [up to date]      testcommit3058 -> origin/testcommit3058
+ = [up to date]      testcommit3059 -> origin/testcommit3059
+ = [up to date]      testcommit306 -> origin/testcommit306
+ = [up to date]      testcommit3060 -> origin/testcommit3060
+ = [up to date]      testcommit3061 -> origin/testcommit3061
+ = [up to date]      testcommit3062 -> origin/testcommit3062
+ = [up to date]      testcommit3063 -> origin/testcommit3063
+ = [up to date]      testcommit3064 -> origin/testcommit3064
+ = [up to date]      testcommit3065 -> origin/testcommit3065
+ = [up to date]      testcommit3066 -> origin/testcommit3066
+ = [up to date]      testcommit3067 -> origin/testcommit3067
+ = [up to date]      testcommit3068 -> origin/testcommit3068
+ = [up to date]      testcommit3069 -> origin/testcommit3069
+ = [up to date]      testcommit307 -> origin/testcommit307
+ = [up to date]      testcommit3070 -> origin/testcommit3070
+ = [up to date]      testcommit3071 -> origin/testcommit3071
+ = [up to date]      testcommit3072 -> origin/testcommit3072
+ = [up to date]      testcommit3073 -> origin/testcommit3073
+ = [up to date]      testcommit3074 -> origin/testcommit3074
+ = [up to date]      testcommit3075 -> origin/testcommit3075
+ = [up to date]      testcommit3076 -> origin/testcommit3076
+ = [up to date]      testcommit3077 -> origin/testcommit3077
+ = [up to date]      testcommit3078 -> origin/testcommit3078
+ = [up to date]      testcommit3079 -> origin/testcommit3079
+ = [up to date]      testcommit308 -> origin/testcommit308
+ = [up to date]      testcommit3080 -> origin/testcommit3080
+ = [up to date]      testcommit3081 -> origin/testcommit3081
+ = [up to date]      testcommit3082 -> origin/testcommit3082
+ = [up to date]      testcommit3083 -> origin/testcommit3083
+ = [up to date]      testcommit3084 -> origin/testcommit3084
+ = [up to date]      testcommit3085 -> origin/testcommit3085
+ = [up to date]      testcommit3086 -> origin/testcommit3086
+ = [up to date]      testcommit3087 -> origin/testcommit3087
+ = [up to date]      testcommit3088 -> origin/testcommit3088
+ = [up to date]      testcommit3089 -> origin/testcommit3089
+ = [up to date]      testcommit309 -> origin/testcommit309
+ = [up to date]      testcommit3090 -> origin/testcommit3090
+ = [up to date]      testcommit3091 -> origin/testcommit3091
+ = [up to date]      testcommit3092 -> origin/testcommit3092
+ = [up to date]      testcommit3093 -> origin/testcommit3093
+ = [up to date]      testcommit3094 -> origin/testcommit3094
+ = [up to date]      testcommit3095 -> origin/testcommit3095
+ = [up to date]      testcommit3096 -> origin/testcommit3096
+ = [up to date]      testcommit3097 -> origin/testcommit3097
+ = [up to date]      testcommit3098 -> origin/testcommit3098
+ = [up to date]      testcommit3099 -> origin/testcommit3099
+ = [up to date]      testcommit31 -> origin/testcommit31
+ = [up to date]      testcommit310 -> origin/testcommit310
+ = [up to date]      testcommit3100 -> origin/testcommit3100
+ = [up to date]      testcommit3101 -> origin/testcommit3101
+ = [up to date]      testcommit3102 -> origin/testcommit3102
+ = [up to date]      testcommit3103 -> origin/testcommit3103
+ = [up to date]      testcommit3104 -> origin/testcommit3104
+ = [up to date]      testcommit3105 -> origin/testcommit3105
+ = [up to date]      testcommit3106 -> origin/testcommit3106
+ = [up to date]      testcommit3107 -> origin/testcommit3107
+ = [up to date]      testcommit3108 -> origin/testcommit3108
+ = [up to date]      testcommit3109 -> origin/testcommit3109
+ = [up to date]      testcommit311 -> origin/testcommit311
+ = [up to date]      testcommit3110 -> origin/testcommit3110
+ = [up to date]      testcommit3111 -> origin/testcommit3111
+ = [up to date]      testcommit3112 -> origin/testcommit3112
+ = [up to date]      testcommit3113 -> origin/testcommit3113
+ = [up to date]      testcommit3114 -> origin/testcommit3114
+ = [up to date]      testcommit3115 -> origin/testcommit3115
+ = [up to date]      testcommit3116 -> origin/testcommit3116
+ = [up to date]      testcommit3117 -> origin/testcommit3117
+ = [up to date]      testcommit3118 -> origin/testcommit3118
+ = [up to date]      testcommit3119 -> origin/testcommit3119
+ = [up to date]      testcommit312 -> origin/testcommit312
+ = [up to date]      testcommit3120 -> origin/testcommit3120
+ = [up to date]      testcommit3121 -> origin/testcommit3121
+ = [up to date]      testcommit3122 -> origin/testcommit3122
+ = [up to date]      testcommit3123 -> origin/testcommit3123
+ = [up to date]      testcommit3124 -> origin/testcommit3124
+ = [up to date]      testcommit3125 -> origin/testcommit3125
+ = [up to date]      testcommit3126 -> origin/testcommit3126
+ = [up to date]      testcommit3127 -> origin/testcommit3127
+ = [up to date]      testcommit3128 -> origin/testcommit3128
+ = [up to date]      testcommit3129 -> origin/testcommit3129
+ = [up to date]      testcommit313 -> origin/testcommit313
+ = [up to date]      testcommit3130 -> origin/testcommit3130
+ = [up to date]      testcommit3131 -> origin/testcommit3131
+ = [up to date]      testcommit3132 -> origin/testcommit3132
+ = [up to date]      testcommit3133 -> origin/testcommit3133
+ = [up to date]      testcommit3134 -> origin/testcommit3134
+ = [up to date]      testcommit3135 -> origin/testcommit3135
+ = [up to date]      testcommit3136 -> origin/testcommit3136
+ = [up to date]      testcommit3137 -> origin/testcommit3137
+ = [up to date]      testcommit3138 -> origin/testcommit3138
+ = [up to date]      testcommit3139 -> origin/testcommit3139
+ = [up to date]      testcommit314 -> origin/testcommit314
+ = [up to date]      testcommit3140 -> origin/testcommit3140
+ = [up to date]      testcommit3141 -> origin/testcommit3141
+ = [up to date]      testcommit3142 -> origin/testcommit3142
+ = [up to date]      testcommit3143 -> origin/testcommit3143
+ = [up to date]      testcommit3144 -> origin/testcommit3144
+ = [up to date]      testcommit3145 -> origin/testcommit3145
+ = [up to date]      testcommit3146 -> origin/testcommit3146
+ = [up to date]      testcommit3147 -> origin/testcommit3147
+ = [up to date]      testcommit3148 -> origin/testcommit3148
+ = [up to date]      testcommit3149 -> origin/testcommit3149
+ = [up to date]      testcommit315 -> origin/testcommit315
+ = [up to date]      testcommit3150 -> origin/testcommit3150
+ = [up to date]      testcommit3151 -> origin/testcommit3151
+ = [up to date]      testcommit3152 -> origin/testcommit3152
+ = [up to date]      testcommit3153 -> origin/testcommit3153
+ = [up to date]      testcommit3154 -> origin/testcommit3154
+ = [up to date]      testcommit3155 -> origin/testcommit3155
+ = [up to date]      testcommit3156 -> origin/testcommit3156
+ = [up to date]      testcommit3157 -> origin/testcommit3157
+ = [up to date]      testcommit3158 -> origin/testcommit3158
+ = [up to date]      testcommit3159 -> origin/testcommit3159
+ = [up to date]      testcommit316 -> origin/testcommit316
+ = [up to date]      testcommit3160 -> origin/testcommit3160
+ = [up to date]      testcommit3161 -> origin/testcommit3161
+ = [up to date]      testcommit3162 -> origin/testcommit3162
+ = [up to date]      testcommit3163 -> origin/testcommit3163
+ = [up to date]      testcommit3164 -> origin/testcommit3164
+ = [up to date]      testcommit3165 -> origin/testcommit3165
+ = [up to date]      testcommit3166 -> origin/testcommit3166
+ = [up to date]      testcommit3167 -> origin/testcommit3167
+ = [up to date]      testcommit3168 -> origin/testcommit3168
+ = [up to date]      testcommit3169 -> origin/testcommit3169
+ = [up to date]      testcommit317 -> origin/testcommit317
+ = [up to date]      testcommit3170 -> origin/testcommit3170
+ = [up to date]      testcommit3171 -> origin/testcommit3171
+ = [up to date]      testcommit3172 -> origin/testcommit3172
+ = [up to date]      testcommit3173 -> origin/testcommit3173
+ = [up to date]      testcommit3174 -> origin/testcommit3174
+ = [up to date]      testcommit3175 -> origin/testcommit3175
+ = [up to date]      testcommit3176 -> origin/testcommit3176
+ = [up to date]      testcommit3177 -> origin/testcommit3177
+ = [up to date]      testcommit3178 -> origin/testcommit3178
+ = [up to date]      testcommit3179 -> origin/testcommit3179
+ = [up to date]      testcommit318 -> origin/testcommit318
+ = [up to date]      testcommit3180 -> origin/testcommit3180
+ = [up to date]      testcommit3181 -> origin/testcommit3181
+ = [up to date]      testcommit3182 -> origin/testcommit3182
+ = [up to date]      testcommit3183 -> origin/testcommit3183
+ = [up to date]      testcommit3184 -> origin/testcommit3184
+ = [up to date]      testcommit3185 -> origin/testcommit3185
+ = [up to date]      testcommit3186 -> origin/testcommit3186
+ = [up to date]      testcommit3187 -> origin/testcommit3187
+ = [up to date]      testcommit3188 -> origin/testcommit3188
+ = [up to date]      testcommit3189 -> origin/testcommit3189
+ = [up to date]      testcommit319 -> origin/testcommit319
+ = [up to date]      testcommit3190 -> origin/testcommit3190
+ = [up to date]      testcommit3191 -> origin/testcommit3191
+ = [up to date]      testcommit3192 -> origin/testcommit3192
+ = [up to date]      testcommit3193 -> origin/testcommit3193
+ = [up to date]      testcommit3194 -> origin/testcommit3194
+ = [up to date]      testcommit3195 -> origin/testcommit3195
+ = [up to date]      testcommit3196 -> origin/testcommit3196
+ = [up to date]      testcommit3197 -> origin/testcommit3197
+ = [up to date]      testcommit3198 -> origin/testcommit3198
+ = [up to date]      testcommit3199 -> origin/testcommit3199
+ = [up to date]      testcommit32 -> origin/testcommit32
+ = [up to date]      testcommit320 -> origin/testcommit320
+ = [up to date]      testcommit3200 -> origin/testcommit3200
+ = [up to date]      testcommit3201 -> origin/testcommit3201
+ = [up to date]      testcommit3202 -> origin/testcommit3202
+ = [up to date]      testcommit3203 -> origin/testcommit3203
+ = [up to date]      testcommit3204 -> origin/testcommit3204
+ = [up to date]      testcommit3205 -> origin/testcommit3205
+ = [up to date]      testcommit3206 -> origin/testcommit3206
+ = [up to date]      testcommit3207 -> origin/testcommit3207
+ = [up to date]      testcommit3208 -> origin/testcommit3208
+ = [up to date]      testcommit3209 -> origin/testcommit3209
+ = [up to date]      testcommit321 -> origin/testcommit321
+ = [up to date]      testcommit3210 -> origin/testcommit3210
+ = [up to date]      testcommit3211 -> origin/testcommit3211
+ = [up to date]      testcommit3212 -> origin/testcommit3212
+ = [up to date]      testcommit3213 -> origin/testcommit3213
+ = [up to date]      testcommit3214 -> origin/testcommit3214
+ = [up to date]      testcommit3215 -> origin/testcommit3215
+ = [up to date]      testcommit3216 -> origin/testcommit3216
+ = [up to date]      testcommit3217 -> origin/testcommit3217
+ = [up to date]      testcommit3218 -> origin/testcommit3218
+ = [up to date]      testcommit3219 -> origin/testcommit3219
+ = [up to date]      testcommit322 -> origin/testcommit322
+ = [up to date]      testcommit3220 -> origin/testcommit3220
+ = [up to date]      testcommit3221 -> origin/testcommit3221
+ = [up to date]      testcommit3222 -> origin/testcommit3222
+ = [up to date]      testcommit3223 -> origin/testcommit3223
+ = [up to date]      testcommit3224 -> origin/testcommit3224
+ = [up to date]      testcommit3225 -> origin/testcommit3225
+ = [up to date]      testcommit3226 -> origin/testcommit3226
+ = [up to date]      testcommit3227 -> origin/testcommit3227
+ = [up to date]      testcommit3228 -> origin/testcommit3228
+ = [up to date]      testcommit3229 -> origin/testcommit3229
+ = [up to date]      testcommit323 -> origin/testcommit323
+ = [up to date]      testcommit3230 -> origin/testcommit3230
+ = [up to date]      testcommit3231 -> origin/testcommit3231
+ = [up to date]      testcommit3232 -> origin/testcommit3232
+ = [up to date]      testcommit3233 -> origin/testcommit3233
+ = [up to date]      testcommit3234 -> origin/testcommit3234
+ = [up to date]      testcommit3235 -> origin/testcommit3235
+ = [up to date]      testcommit3236 -> origin/testcommit3236
+ = [up to date]      testcommit3237 -> origin/testcommit3237
+ = [up to date]      testcommit3238 -> origin/testcommit3238
+ = [up to date]      testcommit3239 -> origin/testcommit3239
+ = [up to date]      testcommit324 -> origin/testcommit324
+ = [up to date]      testcommit3240 -> origin/testcommit3240
+ = [up to date]      testcommit3241 -> origin/testcommit3241
+ = [up to date]      testcommit3242 -> origin/testcommit3242
+ = [up to date]      testcommit3243 -> origin/testcommit3243
+ = [up to date]      testcommit3244 -> origin/testcommit3244
+ = [up to date]      testcommit3245 -> origin/testcommit3245
+ = [up to date]      testcommit3246 -> origin/testcommit3246
+ = [up to date]      testcommit3247 -> origin/testcommit3247
+ = [up to date]      testcommit3248 -> origin/testcommit3248
+ = [up to date]      testcommit3249 -> origin/testcommit3249
+ = [up to date]      testcommit325 -> origin/testcommit325
+ = [up to date]      testcommit3250 -> origin/testcommit3250
+ = [up to date]      testcommit3251 -> origin/testcommit3251
+ = [up to date]      testcommit3252 -> origin/testcommit3252
+ = [up to date]      testcommit3253 -> origin/testcommit3253
+ = [up to date]      testcommit3254 -> origin/testcommit3254
+ = [up to date]      testcommit3255 -> origin/testcommit3255
+ = [up to date]      testcommit3256 -> origin/testcommit3256
+ = [up to date]      testcommit3257 -> origin/testcommit3257
+ = [up to date]      testcommit3258 -> origin/testcommit3258
+ = [up to date]      testcommit3259 -> origin/testcommit3259
+ = [up to date]      testcommit326 -> origin/testcommit326
+ = [up to date]      testcommit3260 -> origin/testcommit3260
+ = [up to date]      testcommit3261 -> origin/testcommit3261
+ = [up to date]      testcommit3262 -> origin/testcommit3262
+ = [up to date]      testcommit3263 -> origin/testcommit3263
+ = [up to date]      testcommit3264 -> origin/testcommit3264
+ = [up to date]      testcommit3265 -> origin/testcommit3265
+ = [up to date]      testcommit3266 -> origin/testcommit3266
+ = [up to date]      testcommit3267 -> origin/testcommit3267
+ = [up to date]      testcommit3268 -> origin/testcommit3268
+ = [up to date]      testcommit3269 -> origin/testcommit3269
+ = [up to date]      testcommit327 -> origin/testcommit327
+ = [up to date]      testcommit3270 -> origin/testcommit3270
+ = [up to date]      testcommit3271 -> origin/testcommit3271
+ = [up to date]      testcommit3272 -> origin/testcommit3272
+ = [up to date]      testcommit3273 -> origin/testcommit3273
+ = [up to date]      testcommit3274 -> origin/testcommit3274
+ = [up to date]      testcommit3275 -> origin/testcommit3275
+ = [up to date]      testcommit3276 -> origin/testcommit3276
+ = [up to date]      testcommit3277 -> origin/testcommit3277
+ = [up to date]      testcommit3278 -> origin/testcommit3278
+ = [up to date]      testcommit3279 -> origin/testcommit3279
+ = [up to date]      testcommit328 -> origin/testcommit328
+ = [up to date]      testcommit3280 -> origin/testcommit3280
+ = [up to date]      testcommit3281 -> origin/testcommit3281
+ = [up to date]      testcommit3282 -> origin/testcommit3282
+ = [up to date]      testcommit3283 -> origin/testcommit3283
+ = [up to date]      testcommit3284 -> origin/testcommit3284
+ = [up to date]      testcommit3285 -> origin/testcommit3285
+ = [up to date]      testcommit3286 -> origin/testcommit3286
+ = [up to date]      testcommit3287 -> origin/testcommit3287
+ = [up to date]      testcommit3288 -> origin/testcommit3288
+ = [up to date]      testcommit3289 -> origin/testcommit3289
+ = [up to date]      testcommit329 -> origin/testcommit329
+ = [up to date]      testcommit3290 -> origin/testcommit3290
+ = [up to date]      testcommit3291 -> origin/testcommit3291
+ = [up to date]      testcommit3292 -> origin/testcommit3292
+ = [up to date]      testcommit3293 -> origin/testcommit3293
+ = [up to date]      testcommit3294 -> origin/testcommit3294
+ = [up to date]      testcommit3295 -> origin/testcommit3295
+ = [up to date]      testcommit3296 -> origin/testcommit3296
+ = [up to date]      testcommit3297 -> origin/testcommit3297
+ = [up to date]      testcommit3298 -> origin/testcommit3298
+ = [up to date]      testcommit3299 -> origin/testcommit3299
+ = [up to date]      testcommit33 -> origin/testcommit33
+ = [up to date]      testcommit330 -> origin/testcommit330
+ = [up to date]      testcommit3300 -> origin/testcommit3300
+ = [up to date]      testcommit3301 -> origin/testcommit3301
+ = [up to date]      testcommit3302 -> origin/testcommit3302
+ = [up to date]      testcommit3303 -> origin/testcommit3303
+ = [up to date]      testcommit3304 -> origin/testcommit3304
+ = [up to date]      testcommit3305 -> origin/testcommit3305
+ = [up to date]      testcommit3306 -> origin/testcommit3306
+ = [up to date]      testcommit3307 -> origin/testcommit3307
+ = [up to date]      testcommit3308 -> origin/testcommit3308
+ = [up to date]      testcommit3309 -> origin/testcommit3309
+ = [up to date]      testcommit331 -> origin/testcommit331
+ = [up to date]      testcommit3310 -> origin/testcommit3310
+ = [up to date]      testcommit3311 -> origin/testcommit3311
+ = [up to date]      testcommit3312 -> origin/testcommit3312
+ = [up to date]      testcommit3313 -> origin/testcommit3313
+ = [up to date]      testcommit3314 -> origin/testcommit3314
+ = [up to date]      testcommit3315 -> origin/testcommit3315
+ = [up to date]      testcommit3316 -> origin/testcommit3316
+ = [up to date]      testcommit3317 -> origin/testcommit3317
+ = [up to date]      testcommit3318 -> origin/testcommit3318
+ = [up to date]      testcommit3319 -> origin/testcommit3319
+ = [up to date]      testcommit332 -> origin/testcommit332
+ = [up to date]      testcommit3320 -> origin/testcommit3320
+ = [up to date]      testcommit3321 -> origin/testcommit3321
+ = [up to date]      testcommit3322 -> origin/testcommit3322
+ = [up to date]      testcommit3323 -> origin/testcommit3323
+ = [up to date]      testcommit3324 -> origin/testcommit3324
+ = [up to date]      testcommit3325 -> origin/testcommit3325
+ = [up to date]      testcommit3326 -> origin/testcommit3326
+ = [up to date]      testcommit3327 -> origin/testcommit3327
+ = [up to date]      testcommit3328 -> origin/testcommit3328
+ = [up to date]      testcommit3329 -> origin/testcommit3329
+ = [up to date]      testcommit333 -> origin/testcommit333
+ = [up to date]      testcommit3330 -> origin/testcommit3330
+ = [up to date]      testcommit3331 -> origin/testcommit3331
+ = [up to date]      testcommit3332 -> origin/testcommit3332
+ = [up to date]      testcommit3333 -> origin/testcommit3333
+ = [up to date]      testcommit3334 -> origin/testcommit3334
+ = [up to date]      testcommit3335 -> origin/testcommit3335
+ = [up to date]      testcommit3336 -> origin/testcommit3336
+ = [up to date]      testcommit3337 -> origin/testcommit3337
+ = [up to date]      testcommit3338 -> origin/testcommit3338
+ = [up to date]      testcommit3339 -> origin/testcommit3339
+ = [up to date]      testcommit334 -> origin/testcommit334
+ = [up to date]      testcommit3340 -> origin/testcommit3340
+ = [up to date]      testcommit3341 -> origin/testcommit3341
+ = [up to date]      testcommit3342 -> origin/testcommit3342
+ = [up to date]      testcommit3343 -> origin/testcommit3343
+ = [up to date]      testcommit3344 -> origin/testcommit3344
+ = [up to date]      testcommit3345 -> origin/testcommit3345
+ = [up to date]      testcommit3346 -> origin/testcommit3346
+ = [up to date]      testcommit3347 -> origin/testcommit3347
+ = [up to date]      testcommit3348 -> origin/testcommit3348
+ = [up to date]      testcommit3349 -> origin/testcommit3349
+ = [up to date]      testcommit335 -> origin/testcommit335
+ = [up to date]      testcommit3350 -> origin/testcommit3350
+ = [up to date]      testcommit3351 -> origin/testcommit3351
+ = [up to date]      testcommit3352 -> origin/testcommit3352
+ = [up to date]      testcommit3353 -> origin/testcommit3353
+ = [up to date]      testcommit3354 -> origin/testcommit3354
+ = [up to date]      testcommit3355 -> origin/testcommit3355
+ = [up to date]      testcommit3356 -> origin/testcommit3356
+ = [up to date]      testcommit3357 -> origin/testcommit3357
+ = [up to date]      testcommit3358 -> origin/testcommit3358
+ = [up to date]      testcommit3359 -> origin/testcommit3359
+ = [up to date]      testcommit336 -> origin/testcommit336
+ = [up to date]      testcommit3360 -> origin/testcommit3360
+ = [up to date]      testcommit3361 -> origin/testcommit3361
+ = [up to date]      testcommit3362 -> origin/testcommit3362
+ = [up to date]      testcommit3363 -> origin/testcommit3363
+ = [up to date]      testcommit3364 -> origin/testcommit3364
+ = [up to date]      testcommit3365 -> origin/testcommit3365
+ = [up to date]      testcommit3366 -> origin/testcommit3366
+ = [up to date]      testcommit3367 -> origin/testcommit3367
+ = [up to date]      testcommit3368 -> origin/testcommit3368
+ = [up to date]      testcommit3369 -> origin/testcommit3369
+ = [up to date]      testcommit337 -> origin/testcommit337
+ = [up to date]      testcommit3370 -> origin/testcommit3370
+ = [up to date]      testcommit3371 -> origin/testcommit3371
+ = [up to date]      testcommit3372 -> origin/testcommit3372
+ = [up to date]      testcommit3373 -> origin/testcommit3373
+ = [up to date]      testcommit3374 -> origin/testcommit3374
+ = [up to date]      testcommit3375 -> origin/testcommit3375
+ = [up to date]      testcommit3376 -> origin/testcommit3376
+ = [up to date]      testcommit3377 -> origin/testcommit3377
+ = [up to date]      testcommit3378 -> origin/testcommit3378
+ = [up to date]      testcommit3379 -> origin/testcommit3379
+ = [up to date]      testcommit338 -> origin/testcommit338
+ = [up to date]      testcommit3380 -> origin/testcommit3380
+ = [up to date]      testcommit3381 -> origin/testcommit3381
+ = [up to date]      testcommit3382 -> origin/testcommit3382
+ = [up to date]      testcommit3383 -> origin/testcommit3383
+ = [up to date]      testcommit3384 -> origin/testcommit3384
+ = [up to date]      testcommit3385 -> origin/testcommit3385
+ = [up to date]      testcommit3386 -> origin/testcommit3386
+ = [up to date]      testcommit3387 -> origin/testcommit3387
+ = [up to date]      testcommit3388 -> origin/testcommit3388
+ = [up to date]      testcommit3389 -> origin/testcommit3389
+ = [up to date]      testcommit339 -> origin/testcommit339
+ = [up to date]      testcommit3390 -> origin/testcommit3390
+ = [up to date]      testcommit3391 -> origin/testcommit3391
+ = [up to date]      testcommit3392 -> origin/testcommit3392
+ = [up to date]      testcommit3393 -> origin/testcommit3393
+ = [up to date]      testcommit3394 -> origin/testcommit3394
+ = [up to date]      testcommit3395 -> origin/testcommit3395
+ = [up to date]      testcommit3396 -> origin/testcommit3396
+ = [up to date]      testcommit3397 -> origin/testcommit3397
+ = [up to date]      testcommit3398 -> origin/testcommit3398
+ = [up to date]      testcommit3399 -> origin/testcommit3399
+ = [up to date]      testcommit34 -> origin/testcommit34
+ = [up to date]      testcommit340 -> origin/testcommit340
+ = [up to date]      testcommit3400 -> origin/testcommit3400
+ = [up to date]      testcommit3401 -> origin/testcommit3401
+ = [up to date]      testcommit3402 -> origin/testcommit3402
+ = [up to date]      testcommit3403 -> origin/testcommit3403
+ = [up to date]      testcommit3404 -> origin/testcommit3404
+ = [up to date]      testcommit3405 -> origin/testcommit3405
+ = [up to date]      testcommit3406 -> origin/testcommit3406
+ = [up to date]      testcommit3407 -> origin/testcommit3407
+ = [up to date]      testcommit3408 -> origin/testcommit3408
+ = [up to date]      testcommit3409 -> origin/testcommit3409
+ = [up to date]      testcommit341 -> origin/testcommit341
+ = [up to date]      testcommit3410 -> origin/testcommit3410
+ = [up to date]      testcommit3411 -> origin/testcommit3411
+ = [up to date]      testcommit3412 -> origin/testcommit3412
+ = [up to date]      testcommit3413 -> origin/testcommit3413
+ = [up to date]      testcommit3414 -> origin/testcommit3414
+ = [up to date]      testcommit3415 -> origin/testcommit3415
+ = [up to date]      testcommit3416 -> origin/testcommit3416
+ = [up to date]      testcommit3417 -> origin/testcommit3417
+ = [up to date]      testcommit3418 -> origin/testcommit3418
+ = [up to date]      testcommit3419 -> origin/testcommit3419
+ = [up to date]      testcommit342 -> origin/testcommit342
+ = [up to date]      testcommit3420 -> origin/testcommit3420
+ = [up to date]      testcommit3421 -> origin/testcommit3421
+ = [up to date]      testcommit3422 -> origin/testcommit3422
+ = [up to date]      testcommit3423 -> origin/testcommit3423
+ = [up to date]      testcommit3424 -> origin/testcommit3424
+ = [up to date]      testcommit3425 -> origin/testcommit3425
+ = [up to date]      testcommit3426 -> origin/testcommit3426
+ = [up to date]      testcommit3427 -> origin/testcommit3427
+ = [up to date]      testcommit3428 -> origin/testcommit3428
+ = [up to date]      testcommit3429 -> origin/testcommit3429
+ = [up to date]      testcommit343 -> origin/testcommit343
+ = [up to date]      testcommit3430 -> origin/testcommit3430
+ = [up to date]      testcommit3431 -> origin/testcommit3431
+ = [up to date]      testcommit3432 -> origin/testcommit3432
+ = [up to date]      testcommit3433 -> origin/testcommit3433
+ = [up to date]      testcommit3434 -> origin/testcommit3434
+ = [up to date]      testcommit3435 -> origin/testcommit3435
+ = [up to date]      testcommit3436 -> origin/testcommit3436
+ = [up to date]      testcommit3437 -> origin/testcommit3437
+ = [up to date]      testcommit3438 -> origin/testcommit3438
+ = [up to date]      testcommit3439 -> origin/testcommit3439
+ = [up to date]      testcommit344 -> origin/testcommit344
+ = [up to date]      testcommit3440 -> origin/testcommit3440
+ = [up to date]      testcommit3441 -> origin/testcommit3441
+ = [up to date]      testcommit3442 -> origin/testcommit3442
+ = [up to date]      testcommit3443 -> origin/testcommit3443
+ = [up to date]      testcommit3444 -> origin/testcommit3444
+ = [up to date]      testcommit3445 -> origin/testcommit3445
+ = [up to date]      testcommit3446 -> origin/testcommit3446
+ = [up to date]      testcommit3447 -> origin/testcommit3447
+ = [up to date]      testcommit3448 -> origin/testcommit3448
+ = [up to date]      testcommit3449 -> origin/testcommit3449
+ = [up to date]      testcommit345 -> origin/testcommit345
+ = [up to date]      testcommit3450 -> origin/testcommit3450
+ = [up to date]      testcommit3451 -> origin/testcommit3451
+ = [up to date]      testcommit3452 -> origin/testcommit3452
+ = [up to date]      testcommit3453 -> origin/testcommit3453
+ = [up to date]      testcommit3454 -> origin/testcommit3454
+ = [up to date]      testcommit3455 -> origin/testcommit3455
+ = [up to date]      testcommit3456 -> origin/testcommit3456
+ = [up to date]      testcommit3457 -> origin/testcommit3457
+ = [up to date]      testcommit3458 -> origin/testcommit3458
+ = [up to date]      testcommit3459 -> origin/testcommit3459
+ = [up to date]      testcommit346 -> origin/testcommit346
+ = [up to date]      testcommit3460 -> origin/testcommit3460
+ = [up to date]      testcommit3461 -> origin/testcommit3461
+ = [up to date]      testcommit3462 -> origin/testcommit3462
+ = [up to date]      testcommit3463 -> origin/testcommit3463
+ = [up to date]      testcommit3464 -> origin/testcommit3464
+ = [up to date]      testcommit3465 -> origin/testcommit3465
+ = [up to date]      testcommit3466 -> origin/testcommit3466
+ = [up to date]      testcommit3467 -> origin/testcommit3467
+ = [up to date]      testcommit3468 -> origin/testcommit3468
+ = [up to date]      testcommit3469 -> origin/testcommit3469
+ = [up to date]      testcommit347 -> origin/testcommit347
+ = [up to date]      testcommit3470 -> origin/testcommit3470
+ = [up to date]      testcommit3471 -> origin/testcommit3471
+ = [up to date]      testcommit3472 -> origin/testcommit3472
+ = [up to date]      testcommit3473 -> origin/testcommit3473
+ = [up to date]      testcommit3474 -> origin/testcommit3474
+ = [up to date]      testcommit3475 -> origin/testcommit3475
+ = [up to date]      testcommit3476 -> origin/testcommit3476
+ = [up to date]      testcommit3477 -> origin/testcommit3477
+ = [up to date]      testcommit3478 -> origin/testcommit3478
+ = [up to date]      testcommit3479 -> origin/testcommit3479
+ = [up to date]      testcommit348 -> origin/testcommit348
+ = [up to date]      testcommit3480 -> origin/testcommit3480
+ = [up to date]      testcommit3481 -> origin/testcommit3481
+ = [up to date]      testcommit3482 -> origin/testcommit3482
+ = [up to date]      testcommit3483 -> origin/testcommit3483
+ = [up to date]      testcommit3484 -> origin/testcommit3484
+ = [up to date]      testcommit3485 -> origin/testcommit3485
+ = [up to date]      testcommit3486 -> origin/testcommit3486
+ = [up to date]      testcommit3487 -> origin/testcommit3487
+ = [up to date]      testcommit3488 -> origin/testcommit3488
+ = [up to date]      testcommit3489 -> origin/testcommit3489
+ = [up to date]      testcommit349 -> origin/testcommit349
+ = [up to date]      testcommit3490 -> origin/testcommit3490
+ = [up to date]      testcommit3491 -> origin/testcommit3491
+ = [up to date]      testcommit3492 -> origin/testcommit3492
+ = [up to date]      testcommit3493 -> origin/testcommit3493
+ = [up to date]      testcommit3494 -> origin/testcommit3494
+ = [up to date]      testcommit3495 -> origin/testcommit3495
+ = [up to date]      testcommit3496 -> origin/testcommit3496
+ = [up to date]      testcommit3497 -> origin/testcommit3497
+ = [up to date]      testcommit3498 -> origin/testcommit3498
+ = [up to date]      testcommit3499 -> origin/testcommit3499
+ = [up to date]      testcommit35 -> origin/testcommit35
+ = [up to date]      testcommit350 -> origin/testcommit350
+ = [up to date]      testcommit3500 -> origin/testcommit3500
+ = [up to date]      testcommit3501 -> origin/testcommit3501
+ = [up to date]      testcommit3502 -> origin/testcommit3502
+ = [up to date]      testcommit3503 -> origin/testcommit3503
+ = [up to date]      testcommit3504 -> origin/testcommit3504
+ = [up to date]      testcommit3505 -> origin/testcommit3505
+ = [up to date]      testcommit3506 -> origin/testcommit3506
+ = [up to date]      testcommit3507 -> origin/testcommit3507
+ = [up to date]      testcommit3508 -> origin/testcommit3508
+ = [up to date]      testcommit3509 -> origin/testcommit3509
+ = [up to date]      testcommit351 -> origin/testcommit351
+ = [up to date]      testcommit3510 -> origin/testcommit3510
+ = [up to date]      testcommit3511 -> origin/testcommit3511
+ = [up to date]      testcommit3512 -> origin/testcommit3512
+ = [up to date]      testcommit3513 -> origin/testcommit3513
+ = [up to date]      testcommit3514 -> origin/testcommit3514
+ = [up to date]      testcommit3515 -> origin/testcommit3515
+ = [up to date]      testcommit3516 -> origin/testcommit3516
+ = [up to date]      testcommit3517 -> origin/testcommit3517
+ = [up to date]      testcommit3518 -> origin/testcommit3518
+ = [up to date]      testcommit3519 -> origin/testcommit3519
+ = [up to date]      testcommit352 -> origin/testcommit352
+ = [up to date]      testcommit3520 -> origin/testcommit3520
+ = [up to date]      testcommit3521 -> origin/testcommit3521
+ = [up to date]      testcommit3522 -> origin/testcommit3522
+ = [up to date]      testcommit3523 -> origin/testcommit3523
+ = [up to date]      testcommit3524 -> origin/testcommit3524
+ = [up to date]      testcommit3525 -> origin/testcommit3525
+ = [up to date]      testcommit3526 -> origin/testcommit3526
+ = [up to date]      testcommit3527 -> origin/testcommit3527
+ = [up to date]      testcommit3528 -> origin/testcommit3528
+ = [up to date]      testcommit3529 -> origin/testcommit3529
+ = [up to date]      testcommit353 -> origin/testcommit353
+ = [up to date]      testcommit3530 -> origin/testcommit3530
+ = [up to date]      testcommit3531 -> origin/testcommit3531
+ = [up to date]      testcommit3532 -> origin/testcommit3532
+ = [up to date]      testcommit3533 -> origin/testcommit3533
+ = [up to date]      testcommit3534 -> origin/testcommit3534
+ = [up to date]      testcommit3535 -> origin/testcommit3535
+ = [up to date]      testcommit3536 -> origin/testcommit3536
+ = [up to date]      testcommit3537 -> origin/testcommit3537
+ = [up to date]      testcommit3538 -> origin/testcommit3538
+ = [up to date]      testcommit3539 -> origin/testcommit3539
+ = [up to date]      testcommit354 -> origin/testcommit354
+ = [up to date]      testcommit3540 -> origin/testcommit3540
+ = [up to date]      testcommit3541 -> origin/testcommit3541
+ = [up to date]      testcommit3542 -> origin/testcommit3542
+ = [up to date]      testcommit3543 -> origin/testcommit3543
+ = [up to date]      testcommit3544 -> origin/testcommit3544
+ = [up to date]      testcommit3545 -> origin/testcommit3545
+ = [up to date]      testcommit3546 -> origin/testcommit3546
+ = [up to date]      testcommit3547 -> origin/testcommit3547
+ = [up to date]      testcommit3548 -> origin/testcommit3548
+ = [up to date]      testcommit3549 -> origin/testcommit3549
+ = [up to date]      testcommit355 -> origin/testcommit355
+ = [up to date]      testcommit3550 -> origin/testcommit3550
+ = [up to date]      testcommit3551 -> origin/testcommit3551
+ = [up to date]      testcommit3552 -> origin/testcommit3552
+ = [up to date]      testcommit3553 -> origin/testcommit3553
+ = [up to date]      testcommit3554 -> origin/testcommit3554
+ = [up to date]      testcommit3555 -> origin/testcommit3555
+ = [up to date]      testcommit3556 -> origin/testcommit3556
+ = [up to date]      testcommit3557 -> origin/testcommit3557
+ = [up to date]      testcommit3558 -> origin/testcommit3558
+ = [up to date]      testcommit3559 -> origin/testcommit3559
+ = [up to date]      testcommit356 -> origin/testcommit356
+ = [up to date]      testcommit3560 -> origin/testcommit3560
+ = [up to date]      testcommit3561 -> origin/testcommit3561
+ = [up to date]      testcommit3562 -> origin/testcommit3562
+ = [up to date]      testcommit3563 -> origin/testcommit3563
+ = [up to date]      testcommit3564 -> origin/testcommit3564
+ = [up to date]      testcommit3565 -> origin/testcommit3565
+ = [up to date]      testcommit3566 -> origin/testcommit3566
+ = [up to date]      testcommit3567 -> origin/testcommit3567
+ = [up to date]      testcommit3568 -> origin/testcommit3568
+ = [up to date]      testcommit3569 -> origin/testcommit3569
+ = [up to date]      testcommit357 -> origin/testcommit357
+ = [up to date]      testcommit3570 -> origin/testcommit3570
+ = [up to date]      testcommit3571 -> origin/testcommit3571
+ = [up to date]      testcommit3572 -> origin/testcommit3572
+ = [up to date]      testcommit3573 -> origin/testcommit3573
+ = [up to date]      testcommit3574 -> origin/testcommit3574
+ = [up to date]      testcommit3575 -> origin/testcommit3575
+ = [up to date]      testcommit3576 -> origin/testcommit3576
+ = [up to date]      testcommit3577 -> origin/testcommit3577
+ = [up to date]      testcommit3578 -> origin/testcommit3578
+ = [up to date]      testcommit3579 -> origin/testcommit3579
+ = [up to date]      testcommit358 -> origin/testcommit358
+ = [up to date]      testcommit3580 -> origin/testcommit3580
+ = [up to date]      testcommit3581 -> origin/testcommit3581
+ = [up to date]      testcommit3582 -> origin/testcommit3582
+ = [up to date]      testcommit3583 -> origin/testcommit3583
+ = [up to date]      testcommit3584 -> origin/testcommit3584
+ = [up to date]      testcommit3585 -> origin/testcommit3585
+ = [up to date]      testcommit3586 -> origin/testcommit3586
+ = [up to date]      testcommit3587 -> origin/testcommit3587
+ = [up to date]      testcommit3588 -> origin/testcommit3588
+ = [up to date]      testcommit3589 -> origin/testcommit3589
+ = [up to date]      testcommit359 -> origin/testcommit359
+ = [up to date]      testcommit3590 -> origin/testcommit3590
+ = [up to date]      testcommit3591 -> origin/testcommit3591
+ = [up to date]      testcommit3592 -> origin/testcommit3592
+ = [up to date]      testcommit3593 -> origin/testcommit3593
+ = [up to date]      testcommit3594 -> origin/testcommit3594
+ = [up to date]      testcommit3595 -> origin/testcommit3595
+ = [up to date]      testcommit3596 -> origin/testcommit3596
+ = [up to date]      testcommit3597 -> origin/testcommit3597
+ = [up to date]      testcommit3598 -> origin/testcommit3598
+ = [up to date]      testcommit3599 -> origin/testcommit3599
+ = [up to date]      testcommit36 -> origin/testcommit36
+ = [up to date]      testcommit360 -> origin/testcommit360
+ = [up to date]      testcommit3600 -> origin/testcommit3600
+ = [up to date]      testcommit3601 -> origin/testcommit3601
+ = [up to date]      testcommit3602 -> origin/testcommit3602
+ = [up to date]      testcommit3603 -> origin/testcommit3603
+ = [up to date]      testcommit3604 -> origin/testcommit3604
+ = [up to date]      testcommit3605 -> origin/testcommit3605
+ = [up to date]      testcommit3606 -> origin/testcommit3606
+ = [up to date]      testcommit3607 -> origin/testcommit3607
+ = [up to date]      testcommit3608 -> origin/testcommit3608
+ = [up to date]      testcommit3609 -> origin/testcommit3609
+ = [up to date]      testcommit361 -> origin/testcommit361
+ = [up to date]      testcommit3610 -> origin/testcommit3610
+ = [up to date]      testcommit3611 -> origin/testcommit3611
+ = [up to date]      testcommit3612 -> origin/testcommit3612
+ = [up to date]      testcommit3613 -> origin/testcommit3613
+ = [up to date]      testcommit3614 -> origin/testcommit3614
+ = [up to date]      testcommit3615 -> origin/testcommit3615
+ = [up to date]      testcommit3616 -> origin/testcommit3616
+ = [up to date]      testcommit3617 -> origin/testcommit3617
+ = [up to date]      testcommit3618 -> origin/testcommit3618
+ = [up to date]      testcommit3619 -> origin/testcommit3619
+ = [up to date]      testcommit362 -> origin/testcommit362
+ = [up to date]      testcommit3620 -> origin/testcommit3620
+ = [up to date]      testcommit3621 -> origin/testcommit3621
+ = [up to date]      testcommit3622 -> origin/testcommit3622
+ = [up to date]      testcommit3623 -> origin/testcommit3623
+ = [up to date]      testcommit3624 -> origin/testcommit3624
+ = [up to date]      testcommit3625 -> origin/testcommit3625
+ = [up to date]      testcommit3626 -> origin/testcommit3626
+ = [up to date]      testcommit3627 -> origin/testcommit3627
+ = [up to date]      testcommit3628 -> origin/testcommit3628
+ = [up to date]      testcommit3629 -> origin/testcommit3629
+ = [up to date]      testcommit363 -> origin/testcommit363
+ = [up to date]      testcommit3630 -> origin/testcommit3630
+ = [up to date]      testcommit3631 -> origin/testcommit3631
+ = [up to date]      testcommit3632 -> origin/testcommit3632
+ = [up to date]      testcommit3633 -> origin/testcommit3633
+ = [up to date]      testcommit3634 -> origin/testcommit3634
+ = [up to date]      testcommit3635 -> origin/testcommit3635
+ = [up to date]      testcommit3636 -> origin/testcommit3636
+ = [up to date]      testcommit3637 -> origin/testcommit3637
+ = [up to date]      testcommit3638 -> origin/testcommit3638
+ = [up to date]      testcommit3639 -> origin/testcommit3639
+ = [up to date]      testcommit364 -> origin/testcommit364
+ = [up to date]      testcommit3640 -> origin/testcommit3640
+ = [up to date]      testcommit3641 -> origin/testcommit3641
+ = [up to date]      testcommit3642 -> origin/testcommit3642
+ = [up to date]      testcommit3643 -> origin/testcommit3643
+ = [up to date]      testcommit3644 -> origin/testcommit3644
+ = [up to date]      testcommit3645 -> origin/testcommit3645
+ = [up to date]      testcommit3646 -> origin/testcommit3646
+ = [up to date]      testcommit3647 -> origin/testcommit3647
+ = [up to date]      testcommit3648 -> origin/testcommit3648
+ = [up to date]      testcommit3649 -> origin/testcommit3649
+ = [up to date]      testcommit365 -> origin/testcommit365
+ = [up to date]      testcommit3650 -> origin/testcommit3650
+ = [up to date]      testcommit3651 -> origin/testcommit3651
+ = [up to date]      testcommit3652 -> origin/testcommit3652
+ = [up to date]      testcommit3653 -> origin/testcommit3653
+ = [up to date]      testcommit3654 -> origin/testcommit3654
+ = [up to date]      testcommit3655 -> origin/testcommit3655
+ = [up to date]      testcommit3656 -> origin/testcommit3656
+ = [up to date]      testcommit3657 -> origin/testcommit3657
+ = [up to date]      testcommit3658 -> origin/testcommit3658
+ = [up to date]      testcommit3659 -> origin/testcommit3659
+ = [up to date]      testcommit366 -> origin/testcommit366
+ = [up to date]      testcommit3660 -> origin/testcommit3660
+ = [up to date]      testcommit3661 -> origin/testcommit3661
+ = [up to date]      testcommit3662 -> origin/testcommit3662
+ = [up to date]      testcommit3663 -> origin/testcommit3663
+ = [up to date]      testcommit3664 -> origin/testcommit3664
+ = [up to date]      testcommit3665 -> origin/testcommit3665
+ = [up to date]      testcommit3666 -> origin/testcommit3666
+ = [up to date]      testcommit3667 -> origin/testcommit3667
+ = [up to date]      testcommit3668 -> origin/testcommit3668
+ = [up to date]      testcommit3669 -> origin/testcommit3669
+ = [up to date]      testcommit367 -> origin/testcommit367
+ = [up to date]      testcommit3670 -> origin/testcommit3670
+ = [up to date]      testcommit3671 -> origin/testcommit3671
+ = [up to date]      testcommit3672 -> origin/testcommit3672
+ = [up to date]      testcommit3673 -> origin/testcommit3673
+ = [up to date]      testcommit3674 -> origin/testcommit3674
+ = [up to date]      testcommit3675 -> origin/testcommit3675
+ = [up to date]      testcommit3676 -> origin/testcommit3676
+ = [up to date]      testcommit3677 -> origin/testcommit3677
+ = [up to date]      testcommit3678 -> origin/testcommit3678
+ = [up to date]      testcommit3679 -> origin/testcommit3679
+ = [up to date]      testcommit368 -> origin/testcommit368
+ = [up to date]      testcommit3680 -> origin/testcommit3680
+ = [up to date]      testcommit3681 -> origin/testcommit3681
+ = [up to date]      testcommit3682 -> origin/testcommit3682
+ = [up to date]      testcommit3683 -> origin/testcommit3683
+ = [up to date]      testcommit3684 -> origin/testcommit3684
+ = [up to date]      testcommit3685 -> origin/testcommit3685
+ = [up to date]      testcommit3686 -> origin/testcommit3686
+ = [up to date]      testcommit3687 -> origin/testcommit3687
+ = [up to date]      testcommit3688 -> origin/testcommit3688
+ = [up to date]      testcommit3689 -> origin/testcommit3689
+ = [up to date]      testcommit369 -> origin/testcommit369
+ = [up to date]      testcommit3690 -> origin/testcommit3690
+ = [up to date]      testcommit3691 -> origin/testcommit3691
+ = [up to date]      testcommit3692 -> origin/testcommit3692
+ = [up to date]      testcommit3693 -> origin/testcommit3693
+ = [up to date]      testcommit3694 -> origin/testcommit3694
+ = [up to date]      testcommit3695 -> origin/testcommit3695
+ = [up to date]      testcommit3696 -> origin/testcommit3696
+ = [up to date]      testcommit3697 -> origin/testcommit3697
+ = [up to date]      testcommit3698 -> origin/testcommit3698
+ = [up to date]      testcommit3699 -> origin/testcommit3699
+ = [up to date]      testcommit37 -> origin/testcommit37
+ = [up to date]      testcommit370 -> origin/testcommit370
+ = [up to date]      testcommit3700 -> origin/testcommit3700
+ = [up to date]      testcommit3701 -> origin/testcommit3701
+ = [up to date]      testcommit3702 -> origin/testcommit3702
+ = [up to date]      testcommit3703 -> origin/testcommit3703
+ = [up to date]      testcommit3704 -> origin/testcommit3704
+ = [up to date]      testcommit3705 -> origin/testcommit3705
+ = [up to date]      testcommit3706 -> origin/testcommit3706
+ = [up to date]      testcommit3707 -> origin/testcommit3707
+ = [up to date]      testcommit3708 -> origin/testcommit3708
+ = [up to date]      testcommit3709 -> origin/testcommit3709
+ = [up to date]      testcommit371 -> origin/testcommit371
+ = [up to date]      testcommit3710 -> origin/testcommit3710
+ = [up to date]      testcommit3711 -> origin/testcommit3711
+ = [up to date]      testcommit3712 -> origin/testcommit3712
+ = [up to date]      testcommit3713 -> origin/testcommit3713
+ = [up to date]      testcommit3714 -> origin/testcommit3714
+ = [up to date]      testcommit3715 -> origin/testcommit3715
+ = [up to date]      testcommit3716 -> origin/testcommit3716
+ = [up to date]      testcommit3717 -> origin/testcommit3717
+ = [up to date]      testcommit3718 -> origin/testcommit3718
+ = [up to date]      testcommit3719 -> origin/testcommit3719
+ = [up to date]      testcommit372 -> origin/testcommit372
+ = [up to date]      testcommit3720 -> origin/testcommit3720
+ = [up to date]      testcommit3721 -> origin/testcommit3721
+ = [up to date]      testcommit3722 -> origin/testcommit3722
+ = [up to date]      testcommit3723 -> origin/testcommit3723
+ = [up to date]      testcommit3724 -> origin/testcommit3724
+ = [up to date]      testcommit3725 -> origin/testcommit3725
+ = [up to date]      testcommit3726 -> origin/testcommit3726
+ = [up to date]      testcommit3727 -> origin/testcommit3727
+ = [up to date]      testcommit3728 -> origin/testcommit3728
+ = [up to date]      testcommit3729 -> origin/testcommit3729
+ = [up to date]      testcommit373 -> origin/testcommit373
+ = [up to date]      testcommit3730 -> origin/testcommit3730
+ = [up to date]      testcommit3731 -> origin/testcommit3731
+ = [up to date]      testcommit3732 -> origin/testcommit3732
+ = [up to date]      testcommit3733 -> origin/testcommit3733
+ = [up to date]      testcommit3734 -> origin/testcommit3734
+ = [up to date]      testcommit3735 -> origin/testcommit3735
+ = [up to date]      testcommit3736 -> origin/testcommit3736
+ = [up to date]      testcommit3737 -> origin/testcommit3737
+ = [up to date]      testcommit3738 -> origin/testcommit3738
+ = [up to date]      testcommit3739 -> origin/testcommit3739
+ = [up to date]      testcommit374 -> origin/testcommit374
+ = [up to date]      testcommit3740 -> origin/testcommit3740
+ = [up to date]      testcommit3741 -> origin/testcommit3741
+ = [up to date]      testcommit3742 -> origin/testcommit3742
+ = [up to date]      testcommit3743 -> origin/testcommit3743
+ = [up to date]      testcommit3744 -> origin/testcommit3744
+ = [up to date]      testcommit3745 -> origin/testcommit3745
+ = [up to date]      testcommit3746 -> origin/testcommit3746
+ = [up to date]      testcommit3747 -> origin/testcommit3747
+ = [up to date]      testcommit3748 -> origin/testcommit3748
+ = [up to date]      testcommit3749 -> origin/testcommit3749
+ = [up to date]      testcommit375 -> origin/testcommit375
+ = [up to date]      testcommit3750 -> origin/testcommit3750
+ = [up to date]      testcommit3751 -> origin/testcommit3751
+ = [up to date]      testcommit3752 -> origin/testcommit3752
+ = [up to date]      testcommit3753 -> origin/testcommit3753
+ = [up to date]      testcommit3754 -> origin/testcommit3754
+ = [up to date]      testcommit3755 -> origin/testcommit3755
+ = [up to date]      testcommit3756 -> origin/testcommit3756
+ = [up to date]      testcommit3757 -> origin/testcommit3757
+ = [up to date]      testcommit3758 -> origin/testcommit3758
+ = [up to date]      testcommit3759 -> origin/testcommit3759
+ = [up to date]      testcommit376 -> origin/testcommit376
+ = [up to date]      testcommit3760 -> origin/testcommit3760
+ = [up to date]      testcommit3761 -> origin/testcommit3761
+ = [up to date]      testcommit3762 -> origin/testcommit3762
+ = [up to date]      testcommit3763 -> origin/testcommit3763
+ = [up to date]      testcommit3764 -> origin/testcommit3764
+ = [up to date]      testcommit3765 -> origin/testcommit3765
+ = [up to date]      testcommit3766 -> origin/testcommit3766
+ = [up to date]      testcommit3767 -> origin/testcommit3767
+ = [up to date]      testcommit3768 -> origin/testcommit3768
+ = [up to date]      testcommit3769 -> origin/testcommit3769
+ = [up to date]      testcommit377 -> origin/testcommit377
+ = [up to date]      testcommit3770 -> origin/testcommit3770
+ = [up to date]      testcommit3771 -> origin/testcommit3771
+ = [up to date]      testcommit3772 -> origin/testcommit3772
+ = [up to date]      testcommit3773 -> origin/testcommit3773
+ = [up to date]      testcommit3774 -> origin/testcommit3774
+ = [up to date]      testcommit3775 -> origin/testcommit3775
+ = [up to date]      testcommit3776 -> origin/testcommit3776
+ = [up to date]      testcommit3777 -> origin/testcommit3777
+ = [up to date]      testcommit3778 -> origin/testcommit3778
+ = [up to date]      testcommit3779 -> origin/testcommit3779
+ = [up to date]      testcommit378 -> origin/testcommit378
+ = [up to date]      testcommit3780 -> origin/testcommit3780
+ = [up to date]      testcommit3781 -> origin/testcommit3781
+ = [up to date]      testcommit3782 -> origin/testcommit3782
+ = [up to date]      testcommit3783 -> origin/testcommit3783
+ = [up to date]      testcommit3784 -> origin/testcommit3784
+ = [up to date]      testcommit3785 -> origin/testcommit3785
+ = [up to date]      testcommit3786 -> origin/testcommit3786
+ = [up to date]      testcommit3787 -> origin/testcommit3787
+ = [up to date]      testcommit3788 -> origin/testcommit3788
+ = [up to date]      testcommit3789 -> origin/testcommit3789
+ = [up to date]      testcommit379 -> origin/testcommit379
+ = [up to date]      testcommit3790 -> origin/testcommit3790
+ = [up to date]      testcommit3791 -> origin/testcommit3791
+ = [up to date]      testcommit3792 -> origin/testcommit3792
+ = [up to date]      testcommit3793 -> origin/testcommit3793
+ = [up to date]      testcommit3794 -> origin/testcommit3794
+ = [up to date]      testcommit3795 -> origin/testcommit3795
+ = [up to date]      testcommit3796 -> origin/testcommit3796
+ = [up to date]      testcommit3797 -> origin/testcommit3797
+ = [up to date]      testcommit3798 -> origin/testcommit3798
+ = [up to date]      testcommit3799 -> origin/testcommit3799
+ = [up to date]      testcommit38 -> origin/testcommit38
+ = [up to date]      testcommit380 -> origin/testcommit380
+ = [up to date]      testcommit3800 -> origin/testcommit3800
+ = [up to date]      testcommit3801 -> origin/testcommit3801
+ = [up to date]      testcommit3802 -> origin/testcommit3802
+ = [up to date]      testcommit3803 -> origin/testcommit3803
+ = [up to date]      testcommit3804 -> origin/testcommit3804
+ = [up to date]      testcommit3805 -> origin/testcommit3805
+ = [up to date]      testcommit3806 -> origin/testcommit3806
+ = [up to date]      testcommit3807 -> origin/testcommit3807
+ = [up to date]      testcommit3808 -> origin/testcommit3808
+ = [up to date]      testcommit3809 -> origin/testcommit3809
+ = [up to date]      testcommit381 -> origin/testcommit381
+ = [up to date]      testcommit3810 -> origin/testcommit3810
+ = [up to date]      testcommit3811 -> origin/testcommit3811
+ = [up to date]      testcommit3812 -> origin/testcommit3812
+ = [up to date]      testcommit3813 -> origin/testcommit3813
+ = [up to date]      testcommit3814 -> origin/testcommit3814
+ = [up to date]      testcommit3815 -> origin/testcommit3815
+ = [up to date]      testcommit3816 -> origin/testcommit3816
+ = [up to date]      testcommit3817 -> origin/testcommit3817
+ = [up to date]      testcommit3818 -> origin/testcommit3818
+ = [up to date]      testcommit3819 -> origin/testcommit3819
+ = [up to date]      testcommit382 -> origin/testcommit382
+ = [up to date]      testcommit3820 -> origin/testcommit3820
+ = [up to date]      testcommit3821 -> origin/testcommit3821
+ = [up to date]      testcommit3822 -> origin/testcommit3822
+ = [up to date]      testcommit3823 -> origin/testcommit3823
+ = [up to date]      testcommit3824 -> origin/testcommit3824
+ = [up to date]      testcommit3825 -> origin/testcommit3825
+ = [up to date]      testcommit3826 -> origin/testcommit3826
+ = [up to date]      testcommit3827 -> origin/testcommit3827
+ = [up to date]      testcommit3828 -> origin/testcommit3828
+ = [up to date]      testcommit3829 -> origin/testcommit3829
+ = [up to date]      testcommit383 -> origin/testcommit383
+ = [up to date]      testcommit3830 -> origin/testcommit3830
+ = [up to date]      testcommit3831 -> origin/testcommit3831
+ = [up to date]      testcommit3832 -> origin/testcommit3832
+ = [up to date]      testcommit3833 -> origin/testcommit3833
+ = [up to date]      testcommit3834 -> origin/testcommit3834
+ = [up to date]      testcommit3835 -> origin/testcommit3835
+ = [up to date]      testcommit3836 -> origin/testcommit3836
+ = [up to date]      testcommit3837 -> origin/testcommit3837
+ = [up to date]      testcommit3838 -> origin/testcommit3838
+ = [up to date]      testcommit3839 -> origin/testcommit3839
+ = [up to date]      testcommit384 -> origin/testcommit384
+ = [up to date]      testcommit3840 -> origin/testcommit3840
+ = [up to date]      testcommit3841 -> origin/testcommit3841
+ = [up to date]      testcommit3842 -> origin/testcommit3842
+ = [up to date]      testcommit3843 -> origin/testcommit3843
+ = [up to date]      testcommit3844 -> origin/testcommit3844
+ = [up to date]      testcommit3845 -> origin/testcommit3845
+ = [up to date]      testcommit3846 -> origin/testcommit3846
+ = [up to date]      testcommit3847 -> origin/testcommit3847
+ = [up to date]      testcommit3848 -> origin/testcommit3848
+ = [up to date]      testcommit3849 -> origin/testcommit3849
+ = [up to date]      testcommit385 -> origin/testcommit385
+ = [up to date]      testcommit3850 -> origin/testcommit3850
+ = [up to date]      testcommit3851 -> origin/testcommit3851
+ = [up to date]      testcommit3852 -> origin/testcommit3852
+ = [up to date]      testcommit3853 -> origin/testcommit3853
+ = [up to date]      testcommit3854 -> origin/testcommit3854
+ = [up to date]      testcommit3855 -> origin/testcommit3855
+ = [up to date]      testcommit3856 -> origin/testcommit3856
+ = [up to date]      testcommit3857 -> origin/testcommit3857
+ = [up to date]      testcommit3858 -> origin/testcommit3858
+ = [up to date]      testcommit3859 -> origin/testcommit3859
+ = [up to date]      testcommit386 -> origin/testcommit386
+ = [up to date]      testcommit3860 -> origin/testcommit3860
+ = [up to date]      testcommit3861 -> origin/testcommit3861
+ = [up to date]      testcommit3862 -> origin/testcommit3862
+ = [up to date]      testcommit3863 -> origin/testcommit3863
+ = [up to date]      testcommit3864 -> origin/testcommit3864
+ = [up to date]      testcommit3865 -> origin/testcommit3865
+ = [up to date]      testcommit3866 -> origin/testcommit3866
+ = [up to date]      testcommit3867 -> origin/testcommit3867
+ = [up to date]      testcommit3868 -> origin/testcommit3868
+ = [up to date]      testcommit3869 -> origin/testcommit3869
+ = [up to date]      testcommit387 -> origin/testcommit387
+ = [up to date]      testcommit3870 -> origin/testcommit3870
+ = [up to date]      testcommit3871 -> origin/testcommit3871
+ = [up to date]      testcommit3872 -> origin/testcommit3872
+ = [up to date]      testcommit3873 -> origin/testcommit3873
+ = [up to date]      testcommit3874 -> origin/testcommit3874
+ = [up to date]      testcommit3875 -> origin/testcommit3875
+ = [up to date]      testcommit3876 -> origin/testcommit3876
+ = [up to date]      testcommit3877 -> origin/testcommit3877
+ = [up to date]      testcommit3878 -> origin/testcommit3878
+ = [up to date]      testcommit3879 -> origin/testcommit3879
+ = [up to date]      testcommit388 -> origin/testcommit388
+ = [up to date]      testcommit3880 -> origin/testcommit3880
+ = [up to date]      testcommit3881 -> origin/testcommit3881
+ = [up to date]      testcommit3882 -> origin/testcommit3882
+ = [up to date]      testcommit3883 -> origin/testcommit3883
+ = [up to date]      testcommit3884 -> origin/testcommit3884
+ = [up to date]      testcommit3885 -> origin/testcommit3885
+ = [up to date]      testcommit3886 -> origin/testcommit3886
+ = [up to date]      testcommit3887 -> origin/testcommit3887
+ = [up to date]      testcommit3888 -> origin/testcommit3888
+ = [up to date]      testcommit3889 -> origin/testcommit3889
+ = [up to date]      testcommit389 -> origin/testcommit389
+ = [up to date]      testcommit3890 -> origin/testcommit3890
+ = [up to date]      testcommit3891 -> origin/testcommit3891
+ = [up to date]      testcommit3892 -> origin/testcommit3892
+ = [up to date]      testcommit3893 -> origin/testcommit3893
+ = [up to date]      testcommit3894 -> origin/testcommit3894
+ = [up to date]      testcommit3895 -> origin/testcommit3895
+ = [up to date]      testcommit3896 -> origin/testcommit3896
+ = [up to date]      testcommit3897 -> origin/testcommit3897
+ = [up to date]      testcommit3898 -> origin/testcommit3898
+ = [up to date]      testcommit3899 -> origin/testcommit3899
+ = [up to date]      testcommit39 -> origin/testcommit39
+ = [up to date]      testcommit390 -> origin/testcommit390
+ = [up to date]      testcommit3900 -> origin/testcommit3900
+ = [up to date]      testcommit3901 -> origin/testcommit3901
+ = [up to date]      testcommit3902 -> origin/testcommit3902
+ = [up to date]      testcommit3903 -> origin/testcommit3903
+ = [up to date]      testcommit3904 -> origin/testcommit3904
+ = [up to date]      testcommit3905 -> origin/testcommit3905
+ = [up to date]      testcommit3906 -> origin/testcommit3906
+ = [up to date]      testcommit3907 -> origin/testcommit3907
+ = [up to date]      testcommit3908 -> origin/testcommit3908
+ = [up to date]      testcommit3909 -> origin/testcommit3909
+ = [up to date]      testcommit391 -> origin/testcommit391
+ = [up to date]      testcommit3910 -> origin/testcommit3910
+ = [up to date]      testcommit3911 -> origin/testcommit3911
+ = [up to date]      testcommit3912 -> origin/testcommit3912
+ = [up to date]      testcommit3913 -> origin/testcommit3913
+ = [up to date]      testcommit3914 -> origin/testcommit3914
+ = [up to date]      testcommit3915 -> origin/testcommit3915
+ = [up to date]      testcommit3916 -> origin/testcommit3916
+ = [up to date]      testcommit3917 -> origin/testcommit3917
+ = [up to date]      testcommit3918 -> origin/testcommit3918
+ = [up to date]      testcommit3919 -> origin/testcommit3919
+ = [up to date]      testcommit392 -> origin/testcommit392
+ = [up to date]      testcommit3920 -> origin/testcommit3920
+ = [up to date]      testcommit3921 -> origin/testcommit3921
+ = [up to date]      testcommit3922 -> origin/testcommit3922
+ = [up to date]      testcommit3923 -> origin/testcommit3923
+ = [up to date]      testcommit3924 -> origin/testcommit3924
+ = [up to date]      testcommit3925 -> origin/testcommit3925
+ = [up to date]      testcommit3926 -> origin/testcommit3926
+ = [up to date]      testcommit3927 -> origin/testcommit3927
+ = [up to date]      testcommit3928 -> origin/testcommit3928
+ = [up to date]      testcommit3929 -> origin/testcommit3929
+ = [up to date]      testcommit393 -> origin/testcommit393
+ = [up to date]      testcommit3930 -> origin/testcommit3930
+ = [up to date]      testcommit3931 -> origin/testcommit3931
+ = [up to date]      testcommit3932 -> origin/testcommit3932
+ = [up to date]      testcommit3933 -> origin/testcommit3933
+ = [up to date]      testcommit3934 -> origin/testcommit3934
+ = [up to date]      testcommit3935 -> origin/testcommit3935
+ = [up to date]      testcommit3936 -> origin/testcommit3936
+ = [up to date]      testcommit3937 -> origin/testcommit3937
+ = [up to date]      testcommit3938 -> origin/testcommit3938
+ = [up to date]      testcommit3939 -> origin/testcommit3939
+ = [up to date]      testcommit394 -> origin/testcommit394
+ = [up to date]      testcommit3940 -> origin/testcommit3940
+ = [up to date]      testcommit3941 -> origin/testcommit3941
+ = [up to date]      testcommit3942 -> origin/testcommit3942
+ = [up to date]      testcommit3943 -> origin/testcommit3943
+ = [up to date]      testcommit3944 -> origin/testcommit3944
+ = [up to date]      testcommit3945 -> origin/testcommit3945
+ = [up to date]      testcommit3946 -> origin/testcommit3946
+ = [up to date]      testcommit3947 -> origin/testcommit3947
+ = [up to date]      testcommit3948 -> origin/testcommit3948
+ = [up to date]      testcommit3949 -> origin/testcommit3949
+ = [up to date]      testcommit395 -> origin/testcommit395
+ = [up to date]      testcommit3950 -> origin/testcommit3950
+ = [up to date]      testcommit3951 -> origin/testcommit3951
+ = [up to date]      testcommit3952 -> origin/testcommit3952
+ = [up to date]      testcommit3953 -> origin/testcommit3953
+ = [up to date]      testcommit3954 -> origin/testcommit3954
+ = [up to date]      testcommit3955 -> origin/testcommit3955
+ = [up to date]      testcommit3956 -> origin/testcommit3956
+ = [up to date]      testcommit3957 -> origin/testcommit3957
+ = [up to date]      testcommit3958 -> origin/testcommit3958
+ = [up to date]      testcommit3959 -> origin/testcommit3959
+ = [up to date]      testcommit396 -> origin/testcommit396
+ = [up to date]      testcommit3960 -> origin/testcommit3960
+ = [up to date]      testcommit3961 -> origin/testcommit3961
+ = [up to date]      testcommit3962 -> origin/testcommit3962
+ = [up to date]      testcommit3963 -> origin/testcommit3963
+ = [up to date]      testcommit3964 -> origin/testcommit3964
+ = [up to date]      testcommit3965 -> origin/testcommit3965
+ = [up to date]      testcommit3966 -> origin/testcommit3966
+ = [up to date]      testcommit3967 -> origin/testcommit3967
+ = [up to date]      testcommit3968 -> origin/testcommit3968
+ = [up to date]      testcommit3969 -> origin/testcommit3969
+ = [up to date]      testcommit397 -> origin/testcommit397
+ = [up to date]      testcommit3970 -> origin/testcommit3970
+ = [up to date]      testcommit3971 -> origin/testcommit3971
+ = [up to date]      testcommit3972 -> origin/testcommit3972
+ = [up to date]      testcommit3973 -> origin/testcommit3973
+ = [up to date]      testcommit3974 -> origin/testcommit3974
+ = [up to date]      testcommit3975 -> origin/testcommit3975
+ = [up to date]      testcommit3976 -> origin/testcommit3976
+ = [up to date]      testcommit3977 -> origin/testcommit3977
+ = [up to date]      testcommit3978 -> origin/testcommit3978
+ = [up to date]      testcommit3979 -> origin/testcommit3979
+ = [up to date]      testcommit398 -> origin/testcommit398
+ = [up to date]      testcommit3980 -> origin/testcommit3980
+ = [up to date]      testcommit3981 -> origin/testcommit3981
+ = [up to date]      testcommit3982 -> origin/testcommit3982
+ = [up to date]      testcommit3983 -> origin/testcommit3983
+ = [up to date]      testcommit3984 -> origin/testcommit3984
+ = [up to date]      testcommit3985 -> origin/testcommit3985
+ = [up to date]      testcommit3986 -> origin/testcommit3986
+ = [up to date]      testcommit3987 -> origin/testcommit3987
+ = [up to date]      testcommit3988 -> origin/testcommit3988
+ = [up to date]      testcommit3989 -> origin/testcommit3989
+ = [up to date]      testcommit399 -> origin/testcommit399
+ = [up to date]      testcommit3990 -> origin/testcommit3990
+ = [up to date]      testcommit3991 -> origin/testcommit3991
+ = [up to date]      testcommit3992 -> origin/testcommit3992
+ = [up to date]      testcommit3993 -> origin/testcommit3993
+ = [up to date]      testcommit3994 -> origin/testcommit3994
+ = [up to date]      testcommit3995 -> origin/testcommit3995
+ = [up to date]      testcommit3996 -> origin/testcommit3996
+ = [up to date]      testcommit3997 -> origin/testcommit3997
+ = [up to date]      testcommit3998 -> origin/testcommit3998
+ = [up to date]      testcommit3999 -> origin/testcommit3999
+ = [up to date]      testcommit4 -> origin/testcommit4
+ = [up to date]      testcommit40 -> origin/testcommit40
+ = [up to date]      testcommit400 -> origin/testcommit400
+ = [up to date]      testcommit4000 -> origin/testcommit4000
+ = [up to date]      testcommit4001 -> origin/testcommit4001
+ = [up to date]      testcommit4002 -> origin/testcommit4002
+ = [up to date]      testcommit4003 -> origin/testcommit4003
+ = [up to date]      testcommit4004 -> origin/testcommit4004
+ = [up to date]      testcommit4005 -> origin/testcommit4005
+ = [up to date]      testcommit4006 -> origin/testcommit4006
+ = [up to date]      testcommit4007 -> origin/testcommit4007
+ = [up to date]      testcommit4008 -> origin/testcommit4008
+ = [up to date]      testcommit4009 -> origin/testcommit4009
+ = [up to date]      testcommit401 -> origin/testcommit401
+ = [up to date]      testcommit4010 -> origin/testcommit4010
+ = [up to date]      testcommit4011 -> origin/testcommit4011
+ = [up to date]      testcommit4012 -> origin/testcommit4012
+ = [up to date]      testcommit4013 -> origin/testcommit4013
+ = [up to date]      testcommit4014 -> origin/testcommit4014
+ = [up to date]      testcommit4015 -> origin/testcommit4015
+ = [up to date]      testcommit4016 -> origin/testcommit4016
+ = [up to date]      testcommit4017 -> origin/testcommit4017
+ = [up to date]      testcommit4018 -> origin/testcommit4018
+ = [up to date]      testcommit4019 -> origin/testcommit4019
+ = [up to date]      testcommit402 -> origin/testcommit402
+ = [up to date]      testcommit4020 -> origin/testcommit4020
+ = [up to date]      testcommit4021 -> origin/testcommit4021
+ = [up to date]      testcommit4022 -> origin/testcommit4022
+ = [up to date]      testcommit4023 -> origin/testcommit4023
+ = [up to date]      testcommit4024 -> origin/testcommit4024
+ = [up to date]      testcommit4025 -> origin/testcommit4025
+ = [up to date]      testcommit4026 -> origin/testcommit4026
+ = [up to date]      testcommit4027 -> origin/testcommit4027
+ = [up to date]      testcommit4028 -> origin/testcommit4028
+ = [up to date]      testcommit4029 -> origin/testcommit4029
+ = [up to date]      testcommit403 -> origin/testcommit403
+ = [up to date]      testcommit4030 -> origin/testcommit4030
+ = [up to date]      testcommit4031 -> origin/testcommit4031
+ = [up to date]      testcommit4032 -> origin/testcommit4032
+ = [up to date]      testcommit4033 -> origin/testcommit4033
+ = [up to date]      testcommit4034 -> origin/testcommit4034
+ = [up to date]      testcommit4035 -> origin/testcommit4035
+ = [up to date]      testcommit4036 -> origin/testcommit4036
+ = [up to date]      testcommit4037 -> origin/testcommit4037
+ = [up to date]      testcommit4038 -> origin/testcommit4038
+ = [up to date]      testcommit4039 -> origin/testcommit4039
+ = [up to date]      testcommit404 -> origin/testcommit404
+ = [up to date]      testcommit4040 -> origin/testcommit4040
+ = [up to date]      testcommit4041 -> origin/testcommit4041
+ = [up to date]      testcommit4042 -> origin/testcommit4042
+ = [up to date]      testcommit4043 -> origin/testcommit4043
+ = [up to date]      testcommit4044 -> origin/testcommit4044
+ = [up to date]      testcommit4045 -> origin/testcommit4045
+ = [up to date]      testcommit4046 -> origin/testcommit4046
+ = [up to date]      testcommit4047 -> origin/testcommit4047
+ = [up to date]      testcommit4048 -> origin/testcommit4048
+ = [up to date]      testcommit4049 -> origin/testcommit4049
+ = [up to date]      testcommit405 -> origin/testcommit405
+ = [up to date]      testcommit4050 -> origin/testcommit4050
+ = [up to date]      testcommit4051 -> origin/testcommit4051
+ = [up to date]      testcommit4052 -> origin/testcommit4052
+ = [up to date]      testcommit4053 -> origin/testcommit4053
+ = [up to date]      testcommit4054 -> origin/testcommit4054
+ = [up to date]      testcommit4055 -> origin/testcommit4055
+ = [up to date]      testcommit4056 -> origin/testcommit4056
+ = [up to date]      testcommit4057 -> origin/testcommit4057
+ = [up to date]      testcommit4058 -> origin/testcommit4058
+ = [up to date]      testcommit4059 -> origin/testcommit4059
+ = [up to date]      testcommit406 -> origin/testcommit406
+ = [up to date]      testcommit4060 -> origin/testcommit4060
+ = [up to date]      testcommit4061 -> origin/testcommit4061
+ = [up to date]      testcommit4062 -> origin/testcommit4062
+ = [up to date]      testcommit4063 -> origin/testcommit4063
+ = [up to date]      testcommit4064 -> origin/testcommit4064
+ = [up to date]      testcommit4065 -> origin/testcommit4065
+ = [up to date]      testcommit4066 -> origin/testcommit4066
+ = [up to date]      testcommit4067 -> origin/testcommit4067
+ = [up to date]      testcommit4068 -> origin/testcommit4068
+ = [up to date]      testcommit4069 -> origin/testcommit4069
+ = [up to date]      testcommit407 -> origin/testcommit407
+ = [up to date]      testcommit4070 -> origin/testcommit4070
+ = [up to date]      testcommit4071 -> origin/testcommit4071
+ = [up to date]      testcommit4072 -> origin/testcommit4072
+ = [up to date]      testcommit4073 -> origin/testcommit4073
+ = [up to date]      testcommit4074 -> origin/testcommit4074
+ = [up to date]      testcommit4075 -> origin/testcommit4075
+ = [up to date]      testcommit4076 -> origin/testcommit4076
+ = [up to date]      testcommit4077 -> origin/testcommit4077
+ = [up to date]      testcommit4078 -> origin/testcommit4078
+ = [up to date]      testcommit4079 -> origin/testcommit4079
+ = [up to date]      testcommit408 -> origin/testcommit408
+ = [up to date]      testcommit4080 -> origin/testcommit4080
+ = [up to date]      testcommit4081 -> origin/testcommit4081
+ = [up to date]      testcommit4082 -> origin/testcommit4082
+ = [up to date]      testcommit4083 -> origin/testcommit4083
+ = [up to date]      testcommit4084 -> origin/testcommit4084
+ = [up to date]      testcommit4085 -> origin/testcommit4085
+ = [up to date]      testcommit4086 -> origin/testcommit4086
+ = [up to date]      testcommit4087 -> origin/testcommit4087
+ = [up to date]      testcommit4088 -> origin/testcommit4088
+ = [up to date]      testcommit4089 -> origin/testcommit4089
+ = [up to date]      testcommit409 -> origin/testcommit409
+ = [up to date]      testcommit4090 -> origin/testcommit4090
+ = [up to date]      testcommit4091 -> origin/testcommit4091
+ = [up to date]      testcommit4092 -> origin/testcommit4092
+ = [up to date]      testcommit4093 -> origin/testcommit4093
+ = [up to date]      testcommit4094 -> origin/testcommit4094
+ = [up to date]      testcommit4095 -> origin/testcommit4095
+ = [up to date]      testcommit4096 -> origin/testcommit4096
+ = [up to date]      testcommit4097 -> origin/testcommit4097
+ = [up to date]      testcommit4098 -> origin/testcommit4098
+ = [up to date]      testcommit4099 -> origin/testcommit4099
+ = [up to date]      testcommit41 -> origin/testcommit41
+ = [up to date]      testcommit410 -> origin/testcommit410
+ = [up to date]      testcommit4100 -> origin/testcommit4100
+ = [up to date]      testcommit4101 -> origin/testcommit4101
+ = [up to date]      testcommit4102 -> origin/testcommit4102
+ = [up to date]      testcommit4103 -> origin/testcommit4103
+ = [up to date]      testcommit4104 -> origin/testcommit4104
+ = [up to date]      testcommit4105 -> origin/testcommit4105
+ = [up to date]      testcommit4106 -> origin/testcommit4106
+ = [up to date]      testcommit4107 -> origin/testcommit4107
+ = [up to date]      testcommit4108 -> origin/testcommit4108
+ = [up to date]      testcommit4109 -> origin/testcommit4109
+ = [up to date]      testcommit411 -> origin/testcommit411
+ = [up to date]      testcommit4110 -> origin/testcommit4110
+ = [up to date]      testcommit4111 -> origin/testcommit4111
+ = [up to date]      testcommit4112 -> origin/testcommit4112
+ = [up to date]      testcommit4113 -> origin/testcommit4113
+ = [up to date]      testcommit4114 -> origin/testcommit4114
+ = [up to date]      testcommit4115 -> origin/testcommit4115
+ = [up to date]      testcommit4116 -> origin/testcommit4116
+ = [up to date]      testcommit4117 -> origin/testcommit4117
+ = [up to date]      testcommit4118 -> origin/testcommit4118
+ = [up to date]      testcommit4119 -> origin/testcommit4119
+ = [up to date]      testcommit412 -> origin/testcommit412
+ = [up to date]      testcommit4120 -> origin/testcommit4120
+ = [up to date]      testcommit4121 -> origin/testcommit4121
+ = [up to date]      testcommit4122 -> origin/testcommit4122
+ = [up to date]      testcommit4123 -> origin/testcommit4123
+ = [up to date]      testcommit4124 -> origin/testcommit4124
+ = [up to date]      testcommit4125 -> origin/testcommit4125
+ = [up to date]      testcommit4126 -> origin/testcommit4126
+ = [up to date]      testcommit4127 -> origin/testcommit4127
+ = [up to date]      testcommit4128 -> origin/testcommit4128
+ = [up to date]      testcommit4129 -> origin/testcommit4129
+ = [up to date]      testcommit413 -> origin/testcommit413
+ = [up to date]      testcommit4130 -> origin/testcommit4130
+ = [up to date]      testcommit4131 -> origin/testcommit4131
+ = [up to date]      testcommit4132 -> origin/testcommit4132
+ = [up to date]      testcommit4133 -> origin/testcommit4133
+ = [up to date]      testcommit4134 -> origin/testcommit4134
+ = [up to date]      testcommit4135 -> origin/testcommit4135
+ = [up to date]      testcommit4136 -> origin/testcommit4136
+ = [up to date]      testcommit4137 -> origin/testcommit4137
+ = [up to date]      testcommit4138 -> origin/testcommit4138
+ = [up to date]      testcommit4139 -> origin/testcommit4139
+ = [up to date]      testcommit414 -> origin/testcommit414
+ = [up to date]      testcommit4140 -> origin/testcommit4140
+ = [up to date]      testcommit4141 -> origin/testcommit4141
+ = [up to date]      testcommit4142 -> origin/testcommit4142
+ = [up to date]      testcommit4143 -> origin/testcommit4143
+ = [up to date]      testcommit4144 -> origin/testcommit4144
+ = [up to date]      testcommit4145 -> origin/testcommit4145
+ = [up to date]      testcommit4146 -> origin/testcommit4146
+ = [up to date]      testcommit4147 -> origin/testcommit4147
+ = [up to date]      testcommit4148 -> origin/testcommit4148
+ = [up to date]      testcommit4149 -> origin/testcommit4149
+ = [up to date]      testcommit415 -> origin/testcommit415
+ = [up to date]      testcommit4150 -> origin/testcommit4150
+ = [up to date]      testcommit4151 -> origin/testcommit4151
+ = [up to date]      testcommit4152 -> origin/testcommit4152
+ = [up to date]      testcommit4153 -> origin/testcommit4153
+ = [up to date]      testcommit4154 -> origin/testcommit4154
+ = [up to date]      testcommit4155 -> origin/testcommit4155
+ = [up to date]      testcommit4156 -> origin/testcommit4156
+ = [up to date]      testcommit4157 -> origin/testcommit4157
+ = [up to date]      testcommit4158 -> origin/testcommit4158
+ = [up to date]      testcommit4159 -> origin/testcommit4159
+ = [up to date]      testcommit416 -> origin/testcommit416
+ = [up to date]      testcommit4160 -> origin/testcommit4160
+ = [up to date]      testcommit4161 -> origin/testcommit4161
+ = [up to date]      testcommit4162 -> origin/testcommit4162
+ = [up to date]      testcommit4163 -> origin/testcommit4163
+ = [up to date]      testcommit4164 -> origin/testcommit4164
+ = [up to date]      testcommit4165 -> origin/testcommit4165
+ = [up to date]      testcommit4166 -> origin/testcommit4166
+ = [up to date]      testcommit4167 -> origin/testcommit4167
+ = [up to date]      testcommit4168 -> origin/testcommit4168
+ = [up to date]      testcommit4169 -> origin/testcommit4169
+ = [up to date]      testcommit417 -> origin/testcommit417
+ = [up to date]      testcommit4170 -> origin/testcommit4170
+ = [up to date]      testcommit4171 -> origin/testcommit4171
+ = [up to date]      testcommit4172 -> origin/testcommit4172
+ = [up to date]      testcommit4173 -> origin/testcommit4173
+ = [up to date]      testcommit4174 -> origin/testcommit4174
+ = [up to date]      testcommit4175 -> origin/testcommit4175
+ = [up to date]      testcommit4176 -> origin/testcommit4176
+ = [up to date]      testcommit4177 -> origin/testcommit4177
+ = [up to date]      testcommit4178 -> origin/testcommit4178
+ = [up to date]      testcommit4179 -> origin/testcommit4179
+ = [up to date]      testcommit418 -> origin/testcommit418
+ = [up to date]      testcommit4180 -> origin/testcommit4180
+ = [up to date]      testcommit4181 -> origin/testcommit4181
+ = [up to date]      testcommit4182 -> origin/testcommit4182
+ = [up to date]      testcommit4183 -> origin/testcommit4183
+ = [up to date]      testcommit4184 -> origin/testcommit4184
+ = [up to date]      testcommit4185 -> origin/testcommit4185
+ = [up to date]      testcommit4186 -> origin/testcommit4186
+ = [up to date]      testcommit4187 -> origin/testcommit4187
+ = [up to date]      testcommit4188 -> origin/testcommit4188
+ = [up to date]      testcommit4189 -> origin/testcommit4189
+ = [up to date]      testcommit419 -> origin/testcommit419
+ = [up to date]      testcommit4190 -> origin/testcommit4190
+ = [up to date]      testcommit4191 -> origin/testcommit4191
+ = [up to date]      testcommit4192 -> origin/testcommit4192
+ = [up to date]      testcommit4193 -> origin/testcommit4193
+ = [up to date]      testcommit4194 -> origin/testcommit4194
+ = [up to date]      testcommit4195 -> origin/testcommit4195
+ = [up to date]      testcommit4196 -> origin/testcommit4196
+ = [up to date]      testcommit4197 -> origin/testcommit4197
+ = [up to date]      testcommit4198 -> origin/testcommit4198
+ = [up to date]      testcommit4199 -> origin/testcommit4199
+ = [up to date]      testcommit42 -> origin/testcommit42
+ = [up to date]      testcommit420 -> origin/testcommit420
+ = [up to date]      testcommit4200 -> origin/testcommit4200
+ = [up to date]      testcommit4201 -> origin/testcommit4201
+ = [up to date]      testcommit4202 -> origin/testcommit4202
+ = [up to date]      testcommit4203 -> origin/testcommit4203
+ = [up to date]      testcommit4204 -> origin/testcommit4204
+ = [up to date]      testcommit4205 -> origin/testcommit4205
+ = [up to date]      testcommit4206 -> origin/testcommit4206
+ = [up to date]      testcommit4207 -> origin/testcommit4207
+ = [up to date]      testcommit4208 -> origin/testcommit4208
+ = [up to date]      testcommit4209 -> origin/testcommit4209
+ = [up to date]      testcommit421 -> origin/testcommit421
+ = [up to date]      testcommit4210 -> origin/testcommit4210
+ = [up to date]      testcommit4211 -> origin/testcommit4211
+ = [up to date]      testcommit4212 -> origin/testcommit4212
+ = [up to date]      testcommit4213 -> origin/testcommit4213
+ = [up to date]      testcommit4214 -> origin/testcommit4214
+ = [up to date]      testcommit4215 -> origin/testcommit4215
+ = [up to date]      testcommit4216 -> origin/testcommit4216
+ = [up to date]      testcommit4217 -> origin/testcommit4217
+ = [up to date]      testcommit4218 -> origin/testcommit4218
+ = [up to date]      testcommit4219 -> origin/testcommit4219
+ = [up to date]      testcommit422 -> origin/testcommit422
+ = [up to date]      testcommit4220 -> origin/testcommit4220
+ = [up to date]      testcommit4221 -> origin/testcommit4221
+ = [up to date]      testcommit4222 -> origin/testcommit4222
+ = [up to date]      testcommit4223 -> origin/testcommit4223
+ = [up to date]      testcommit4224 -> origin/testcommit4224
+ = [up to date]      testcommit4225 -> origin/testcommit4225
+ = [up to date]      testcommit4226 -> origin/testcommit4226
+ = [up to date]      testcommit4227 -> origin/testcommit4227
+ = [up to date]      testcommit4228 -> origin/testcommit4228
+ = [up to date]      testcommit4229 -> origin/testcommit4229
+ = [up to date]      testcommit423 -> origin/testcommit423
+ = [up to date]      testcommit4230 -> origin/testcommit4230
+ = [up to date]      testcommit4231 -> origin/testcommit4231
+ = [up to date]      testcommit4232 -> origin/testcommit4232
+ = [up to date]      testcommit4233 -> origin/testcommit4233
+ = [up to date]      testcommit4234 -> origin/testcommit4234
+ = [up to date]      testcommit4235 -> origin/testcommit4235
+ = [up to date]      testcommit4236 -> origin/testcommit4236
+ = [up to date]      testcommit4237 -> origin/testcommit4237
+ = [up to date]      testcommit4238 -> origin/testcommit4238
+ = [up to date]      testcommit4239 -> origin/testcommit4239
+ = [up to date]      testcommit424 -> origin/testcommit424
+ = [up to date]      testcommit4240 -> origin/testcommit4240
+ = [up to date]      testcommit4241 -> origin/testcommit4241
+ = [up to date]      testcommit4242 -> origin/testcommit4242
+ = [up to date]      testcommit4243 -> origin/testcommit4243
+ = [up to date]      testcommit4244 -> origin/testcommit4244
+ = [up to date]      testcommit4245 -> origin/testcommit4245
+ = [up to date]      testcommit4246 -> origin/testcommit4246
+ = [up to date]      testcommit4247 -> origin/testcommit4247
+ = [up to date]      testcommit4248 -> origin/testcommit4248
+ = [up to date]      testcommit4249 -> origin/testcommit4249
+ = [up to date]      testcommit425 -> origin/testcommit425
+ = [up to date]      testcommit4250 -> origin/testcommit4250
+ = [up to date]      testcommit4251 -> origin/testcommit4251
+ = [up to date]      testcommit4252 -> origin/testcommit4252
+ = [up to date]      testcommit4253 -> origin/testcommit4253
+ = [up to date]      testcommit4254 -> origin/testcommit4254
+ = [up to date]      testcommit4255 -> origin/testcommit4255
+ = [up to date]      testcommit4256 -> origin/testcommit4256
+ = [up to date]      testcommit4257 -> origin/testcommit4257
+ = [up to date]      testcommit4258 -> origin/testcommit4258
+ = [up to date]      testcommit4259 -> origin/testcommit4259
+ = [up to date]      testcommit426 -> origin/testcommit426
+ = [up to date]      testcommit4260 -> origin/testcommit4260
+ = [up to date]      testcommit4261 -> origin/testcommit4261
+ = [up to date]      testcommit4262 -> origin/testcommit4262
+ = [up to date]      testcommit4263 -> origin/testcommit4263
+ = [up to date]      testcommit4264 -> origin/testcommit4264
+ = [up to date]      testcommit4265 -> origin/testcommit4265
+ = [up to date]      testcommit4266 -> origin/testcommit4266
+ = [up to date]      testcommit4267 -> origin/testcommit4267
+ = [up to date]      testcommit4268 -> origin/testcommit4268
+ = [up to date]      testcommit4269 -> origin/testcommit4269
+ = [up to date]      testcommit427 -> origin/testcommit427
+ = [up to date]      testcommit4270 -> origin/testcommit4270
+ = [up to date]      testcommit4271 -> origin/testcommit4271
+ = [up to date]      testcommit4272 -> origin/testcommit4272
+ = [up to date]      testcommit4273 -> origin/testcommit4273
+ = [up to date]      testcommit4274 -> origin/testcommit4274
+ = [up to date]      testcommit4275 -> origin/testcommit4275
+ = [up to date]      testcommit4276 -> origin/testcommit4276
+ = [up to date]      testcommit4277 -> origin/testcommit4277
+ = [up to date]      testcommit4278 -> origin/testcommit4278
+ = [up to date]      testcommit4279 -> origin/testcommit4279
+ = [up to date]      testcommit428 -> origin/testcommit428
+ = [up to date]      testcommit4280 -> origin/testcommit4280
+ = [up to date]      testcommit4281 -> origin/testcommit4281
+ = [up to date]      testcommit4282 -> origin/testcommit4282
+ = [up to date]      testcommit4283 -> origin/testcommit4283
+ = [up to date]      testcommit4284 -> origin/testcommit4284
+ = [up to date]      testcommit4285 -> origin/testcommit4285
+ = [up to date]      testcommit4286 -> origin/testcommit4286
+ = [up to date]      testcommit4287 -> origin/testcommit4287
+ = [up to date]      testcommit4288 -> origin/testcommit4288
+ = [up to date]      testcommit4289 -> origin/testcommit4289
+ = [up to date]      testcommit429 -> origin/testcommit429
+ = [up to date]      testcommit4290 -> origin/testcommit4290
+ = [up to date]      testcommit4291 -> origin/testcommit4291
+ = [up to date]      testcommit4292 -> origin/testcommit4292
+ = [up to date]      testcommit4293 -> origin/testcommit4293
+ = [up to date]      testcommit4294 -> origin/testcommit4294
+ = [up to date]      testcommit4295 -> origin/testcommit4295
+ = [up to date]      testcommit4296 -> origin/testcommit4296
+ = [up to date]      testcommit4297 -> origin/testcommit4297
+ = [up to date]      testcommit4298 -> origin/testcommit4298
+ = [up to date]      testcommit4299 -> origin/testcommit4299
+ = [up to date]      testcommit43 -> origin/testcommit43
+ = [up to date]      testcommit430 -> origin/testcommit430
+ = [up to date]      testcommit4300 -> origin/testcommit4300
+ = [up to date]      testcommit4301 -> origin/testcommit4301
+ = [up to date]      testcommit4302 -> origin/testcommit4302
+ = [up to date]      testcommit4303 -> origin/testcommit4303
+ = [up to date]      testcommit4304 -> origin/testcommit4304
+ = [up to date]      testcommit4305 -> origin/testcommit4305
+ = [up to date]      testcommit4306 -> origin/testcommit4306
+ = [up to date]      testcommit4307 -> origin/testcommit4307
+ = [up to date]      testcommit4308 -> origin/testcommit4308
+ = [up to date]      testcommit4309 -> origin/testcommit4309
+ = [up to date]      testcommit431 -> origin/testcommit431
+ = [up to date]      testcommit4310 -> origin/testcommit4310
+ = [up to date]      testcommit4311 -> origin/testcommit4311
+ = [up to date]      testcommit4312 -> origin/testcommit4312
+ = [up to date]      testcommit4313 -> origin/testcommit4313
+ = [up to date]      testcommit4314 -> origin/testcommit4314
+ = [up to date]      testcommit4315 -> origin/testcommit4315
+ = [up to date]      testcommit4316 -> origin/testcommit4316
+ = [up to date]      testcommit4317 -> origin/testcommit4317
+ = [up to date]      testcommit4318 -> origin/testcommit4318
+ = [up to date]      testcommit4319 -> origin/testcommit4319
+ = [up to date]      testcommit432 -> origin/testcommit432
+ = [up to date]      testcommit4320 -> origin/testcommit4320
+ = [up to date]      testcommit4321 -> origin/testcommit4321
+ = [up to date]      testcommit4322 -> origin/testcommit4322
+ = [up to date]      testcommit4323 -> origin/testcommit4323
+ = [up to date]      testcommit4324 -> origin/testcommit4324
+ = [up to date]      testcommit4325 -> origin/testcommit4325
+ = [up to date]      testcommit4326 -> origin/testcommit4326
+ = [up to date]      testcommit4327 -> origin/testcommit4327
+ = [up to date]      testcommit4328 -> origin/testcommit4328
+ = [up to date]      testcommit4329 -> origin/testcommit4329
+ = [up to date]      testcommit433 -> origin/testcommit433
+ = [up to date]      testcommit4330 -> origin/testcommit4330
+ = [up to date]      testcommit4331 -> origin/testcommit4331
+ = [up to date]      testcommit4332 -> origin/testcommit4332
+ = [up to date]      testcommit4333 -> origin/testcommit4333
+ = [up to date]      testcommit4334 -> origin/testcommit4334
+ = [up to date]      testcommit4335 -> origin/testcommit4335
+ = [up to date]      testcommit4336 -> origin/testcommit4336
+ = [up to date]      testcommit4337 -> origin/testcommit4337
+ = [up to date]      testcommit4338 -> origin/testcommit4338
+ = [up to date]      testcommit4339 -> origin/testcommit4339
+ = [up to date]      testcommit434 -> origin/testcommit434
+ = [up to date]      testcommit4340 -> origin/testcommit4340
+ = [up to date]      testcommit4341 -> origin/testcommit4341
+ = [up to date]      testcommit4342 -> origin/testcommit4342
+ = [up to date]      testcommit4343 -> origin/testcommit4343
+ = [up to date]      testcommit4344 -> origin/testcommit4344
+ = [up to date]      testcommit4345 -> origin/testcommit4345
+ = [up to date]      testcommit4346 -> origin/testcommit4346
+ = [up to date]      testcommit4347 -> origin/testcommit4347
+ = [up to date]      testcommit4348 -> origin/testcommit4348
+ = [up to date]      testcommit4349 -> origin/testcommit4349
+ = [up to date]      testcommit435 -> origin/testcommit435
+ = [up to date]      testcommit4350 -> origin/testcommit4350
+ = [up to date]      testcommit4351 -> origin/testcommit4351
+ = [up to date]      testcommit4352 -> origin/testcommit4352
+ = [up to date]      testcommit4353 -> origin/testcommit4353
+ = [up to date]      testcommit4354 -> origin/testcommit4354
+ = [up to date]      testcommit4355 -> origin/testcommit4355
+ = [up to date]      testcommit4356 -> origin/testcommit4356
+ = [up to date]      testcommit4357 -> origin/testcommit4357
+ = [up to date]      testcommit4358 -> origin/testcommit4358
+ = [up to date]      testcommit4359 -> origin/testcommit4359
+ = [up to date]      testcommit436 -> origin/testcommit436
+ = [up to date]      testcommit4360 -> origin/testcommit4360
+ = [up to date]      testcommit4361 -> origin/testcommit4361
+ = [up to date]      testcommit4362 -> origin/testcommit4362
+ = [up to date]      testcommit4363 -> origin/testcommit4363
+ = [up to date]      testcommit4364 -> origin/testcommit4364
+ = [up to date]      testcommit4365 -> origin/testcommit4365
+ = [up to date]      testcommit4366 -> origin/testcommit4366
+ = [up to date]      testcommit4367 -> origin/testcommit4367
+ = [up to date]      testcommit4368 -> origin/testcommit4368
+ = [up to date]      testcommit4369 -> origin/testcommit4369
+ = [up to date]      testcommit437 -> origin/testcommit437
+ = [up to date]      testcommit4370 -> origin/testcommit4370
+ = [up to date]      testcommit4371 -> origin/testcommit4371
+ = [up to date]      testcommit4372 -> origin/testcommit4372
+ = [up to date]      testcommit4373 -> origin/testcommit4373
+ = [up to date]      testcommit4374 -> origin/testcommit4374
+ = [up to date]      testcommit4375 -> origin/testcommit4375
+ = [up to date]      testcommit4376 -> origin/testcommit4376
+ = [up to date]      testcommit4377 -> origin/testcommit4377
+ = [up to date]      testcommit4378 -> origin/testcommit4378
+ = [up to date]      testcommit4379 -> origin/testcommit4379
+ = [up to date]      testcommit438 -> origin/testcommit438
+ = [up to date]      testcommit4380 -> origin/testcommit4380
+ = [up to date]      testcommit4381 -> origin/testcommit4381
+ = [up to date]      testcommit4382 -> origin/testcommit4382
+ = [up to date]      testcommit4383 -> origin/testcommit4383
+ = [up to date]      testcommit4384 -> origin/testcommit4384
+ = [up to date]      testcommit4385 -> origin/testcommit4385
+ = [up to date]      testcommit4386 -> origin/testcommit4386
+ = [up to date]      testcommit4387 -> origin/testcommit4387
+ = [up to date]      testcommit4388 -> origin/testcommit4388
+ = [up to date]      testcommit4389 -> origin/testcommit4389
+ = [up to date]      testcommit439 -> origin/testcommit439
+ = [up to date]      testcommit4390 -> origin/testcommit4390
+ = [up to date]      testcommit4391 -> origin/testcommit4391
+ = [up to date]      testcommit4392 -> origin/testcommit4392
+ = [up to date]      testcommit4393 -> origin/testcommit4393
+ = [up to date]      testcommit4394 -> origin/testcommit4394
+ = [up to date]      testcommit4395 -> origin/testcommit4395
+ = [up to date]      testcommit4396 -> origin/testcommit4396
+ = [up to date]      testcommit4397 -> origin/testcommit4397
+ = [up to date]      testcommit4398 -> origin/testcommit4398
+ = [up to date]      testcommit4399 -> origin/testcommit4399
+ = [up to date]      testcommit44 -> origin/testcommit44
+ = [up to date]      testcommit440 -> origin/testcommit440
+ = [up to date]      testcommit4400 -> origin/testcommit4400
+ = [up to date]      testcommit4401 -> origin/testcommit4401
+ = [up to date]      testcommit4402 -> origin/testcommit4402
+ = [up to date]      testcommit4403 -> origin/testcommit4403
+ = [up to date]      testcommit4404 -> origin/testcommit4404
+ = [up to date]      testcommit4405 -> origin/testcommit4405
+ = [up to date]      testcommit4406 -> origin/testcommit4406
+ = [up to date]      testcommit4407 -> origin/testcommit4407
+ = [up to date]      testcommit4408 -> origin/testcommit4408
+ = [up to date]      testcommit4409 -> origin/testcommit4409
+ = [up to date]      testcommit441 -> origin/testcommit441
+ = [up to date]      testcommit4410 -> origin/testcommit4410
+ = [up to date]      testcommit4411 -> origin/testcommit4411
+ = [up to date]      testcommit4412 -> origin/testcommit4412
+ = [up to date]      testcommit4413 -> origin/testcommit4413
+ = [up to date]      testcommit4414 -> origin/testcommit4414
+ = [up to date]      testcommit4415 -> origin/testcommit4415
+ = [up to date]      testcommit4416 -> origin/testcommit4416
+ = [up to date]      testcommit4417 -> origin/testcommit4417
+ = [up to date]      testcommit4418 -> origin/testcommit4418
+ = [up to date]      testcommit4419 -> origin/testcommit4419
+ = [up to date]      testcommit442 -> origin/testcommit442
+ = [up to date]      testcommit4420 -> origin/testcommit4420
+ = [up to date]      testcommit4421 -> origin/testcommit4421
+ = [up to date]      testcommit4422 -> origin/testcommit4422
+ = [up to date]      testcommit4423 -> origin/testcommit4423
+ = [up to date]      testcommit4424 -> origin/testcommit4424
+ = [up to date]      testcommit4425 -> origin/testcommit4425
+ = [up to date]      testcommit4426 -> origin/testcommit4426
+ = [up to date]      testcommit4427 -> origin/testcommit4427
+ = [up to date]      testcommit4428 -> origin/testcommit4428
+ = [up to date]      testcommit4429 -> origin/testcommit4429
+ = [up to date]      testcommit443 -> origin/testcommit443
+ = [up to date]      testcommit4430 -> origin/testcommit4430
+ = [up to date]      testcommit4431 -> origin/testcommit4431
+ = [up to date]      testcommit4432 -> origin/testcommit4432
+ = [up to date]      testcommit4433 -> origin/testcommit4433
+ = [up to date]      testcommit4434 -> origin/testcommit4434
+ = [up to date]      testcommit4435 -> origin/testcommit4435
+ = [up to date]      testcommit4436 -> origin/testcommit4436
+ = [up to date]      testcommit4437 -> origin/testcommit4437
+ = [up to date]      testcommit4438 -> origin/testcommit4438
+ = [up to date]      testcommit4439 -> origin/testcommit4439
+ = [up to date]      testcommit444 -> origin/testcommit444
+ = [up to date]      testcommit4440 -> origin/testcommit4440
+ = [up to date]      testcommit4441 -> origin/testcommit4441
+ = [up to date]      testcommit4442 -> origin/testcommit4442
+ = [up to date]      testcommit4443 -> origin/testcommit4443
+ = [up to date]      testcommit4444 -> origin/testcommit4444
+ = [up to date]      testcommit4445 -> origin/testcommit4445
+ = [up to date]      testcommit4446 -> origin/testcommit4446
+ = [up to date]      testcommit4447 -> origin/testcommit4447
+ = [up to date]      testcommit4448 -> origin/testcommit4448
+ = [up to date]      testcommit4449 -> origin/testcommit4449
+ = [up to date]      testcommit445 -> origin/testcommit445
+ = [up to date]      testcommit4450 -> origin/testcommit4450
+ = [up to date]      testcommit4451 -> origin/testcommit4451
+ = [up to date]      testcommit4452 -> origin/testcommit4452
+ = [up to date]      testcommit4453 -> origin/testcommit4453
+ = [up to date]      testcommit4454 -> origin/testcommit4454
+ = [up to date]      testcommit4455 -> origin/testcommit4455
+ = [up to date]      testcommit4456 -> origin/testcommit4456
+ = [up to date]      testcommit4457 -> origin/testcommit4457
+ = [up to date]      testcommit4458 -> origin/testcommit4458
+ = [up to date]      testcommit4459 -> origin/testcommit4459
+ = [up to date]      testcommit446 -> origin/testcommit446
+ = [up to date]      testcommit4460 -> origin/testcommit4460
+ = [up to date]      testcommit4461 -> origin/testcommit4461
+ = [up to date]      testcommit4462 -> origin/testcommit4462
+ = [up to date]      testcommit4463 -> origin/testcommit4463
+ = [up to date]      testcommit4464 -> origin/testcommit4464
+ = [up to date]      testcommit4465 -> origin/testcommit4465
+ = [up to date]      testcommit4466 -> origin/testcommit4466
+ = [up to date]      testcommit4467 -> origin/testcommit4467
+ = [up to date]      testcommit4468 -> origin/testcommit4468
+ = [up to date]      testcommit4469 -> origin/testcommit4469
+ = [up to date]      testcommit447 -> origin/testcommit447
+ = [up to date]      testcommit4470 -> origin/testcommit4470
+ = [up to date]      testcommit4471 -> origin/testcommit4471
+ = [up to date]      testcommit4472 -> origin/testcommit4472
+ = [up to date]      testcommit4473 -> origin/testcommit4473
+ = [up to date]      testcommit4474 -> origin/testcommit4474
+ = [up to date]      testcommit4475 -> origin/testcommit4475
+ = [up to date]      testcommit4476 -> origin/testcommit4476
+ = [up to date]      testcommit4477 -> origin/testcommit4477
+ = [up to date]      testcommit4478 -> origin/testcommit4478
+ = [up to date]      testcommit4479 -> origin/testcommit4479
+ = [up to date]      testcommit448 -> origin/testcommit448
+ = [up to date]      testcommit4480 -> origin/testcommit4480
+ = [up to date]      testcommit4481 -> origin/testcommit4481
+ = [up to date]      testcommit4482 -> origin/testcommit4482
+ = [up to date]      testcommit4483 -> origin/testcommit4483
+ = [up to date]      testcommit4484 -> origin/testcommit4484
+ = [up to date]      testcommit4485 -> origin/testcommit4485
+ = [up to date]      testcommit4486 -> origin/testcommit4486
+ = [up to date]      testcommit4487 -> origin/testcommit4487
+ = [up to date]      testcommit4488 -> origin/testcommit4488
+ = [up to date]      testcommit4489 -> origin/testcommit4489
+ = [up to date]      testcommit449 -> origin/testcommit449
+ = [up to date]      testcommit4490 -> origin/testcommit4490
+ = [up to date]      testcommit4491 -> origin/testcommit4491
+ = [up to date]      testcommit4492 -> origin/testcommit4492
+ = [up to date]      testcommit4493 -> origin/testcommit4493
+ = [up to date]      testcommit4494 -> origin/testcommit4494
+ = [up to date]      testcommit4495 -> origin/testcommit4495
+ = [up to date]      testcommit4496 -> origin/testcommit4496
+ = [up to date]      testcommit4497 -> origin/testcommit4497
+ = [up to date]      testcommit4498 -> origin/testcommit4498
+ = [up to date]      testcommit4499 -> origin/testcommit4499
+ = [up to date]      testcommit45 -> origin/testcommit45
+ = [up to date]      testcommit450 -> origin/testcommit450
+ = [up to date]      testcommit4500 -> origin/testcommit4500
+ = [up to date]      testcommit4501 -> origin/testcommit4501
+ = [up to date]      testcommit4502 -> origin/testcommit4502
+ = [up to date]      testcommit4503 -> origin/testcommit4503
+ = [up to date]      testcommit4504 -> origin/testcommit4504
+ = [up to date]      testcommit4505 -> origin/testcommit4505
+ = [up to date]      testcommit4506 -> origin/testcommit4506
+ = [up to date]      testcommit4507 -> origin/testcommit4507
+ = [up to date]      testcommit4508 -> origin/testcommit4508
+ = [up to date]      testcommit4509 -> origin/testcommit4509
+ = [up to date]      testcommit451 -> origin/testcommit451
+ = [up to date]      testcommit4510 -> origin/testcommit4510
+ = [up to date]      testcommit4511 -> origin/testcommit4511
+ = [up to date]      testcommit4512 -> origin/testcommit4512
+ = [up to date]      testcommit4513 -> origin/testcommit4513
+ = [up to date]      testcommit4514 -> origin/testcommit4514
+ = [up to date]      testcommit4515 -> origin/testcommit4515
+ = [up to date]      testcommit4516 -> origin/testcommit4516
+ = [up to date]      testcommit4517 -> origin/testcommit4517
+ = [up to date]      testcommit4518 -> origin/testcommit4518
+ = [up to date]      testcommit4519 -> origin/testcommit4519
+ = [up to date]      testcommit452 -> origin/testcommit452
+ = [up to date]      testcommit4520 -> origin/testcommit4520
+ = [up to date]      testcommit4521 -> origin/testcommit4521
+ = [up to date]      testcommit4522 -> origin/testcommit4522
+ = [up to date]      testcommit4523 -> origin/testcommit4523
+ = [up to date]      testcommit4524 -> origin/testcommit4524
+ = [up to date]      testcommit4525 -> origin/testcommit4525
+ = [up to date]      testcommit4526 -> origin/testcommit4526
+ = [up to date]      testcommit4527 -> origin/testcommit4527
+ = [up to date]      testcommit4528 -> origin/testcommit4528
+ = [up to date]      testcommit4529 -> origin/testcommit4529
+ = [up to date]      testcommit453 -> origin/testcommit453
+ = [up to date]      testcommit4530 -> origin/testcommit4530
+ = [up to date]      testcommit4531 -> origin/testcommit4531
+ = [up to date]      testcommit4532 -> origin/testcommit4532
+ = [up to date]      testcommit4533 -> origin/testcommit4533
+ = [up to date]      testcommit4534 -> origin/testcommit4534
+ = [up to date]      testcommit4535 -> origin/testcommit4535
+ = [up to date]      testcommit4536 -> origin/testcommit4536
+ = [up to date]      testcommit4537 -> origin/testcommit4537
+ = [up to date]      testcommit4538 -> origin/testcommit4538
+ = [up to date]      testcommit4539 -> origin/testcommit4539
+ = [up to date]      testcommit454 -> origin/testcommit454
+ = [up to date]      testcommit4540 -> origin/testcommit4540
+ = [up to date]      testcommit4541 -> origin/testcommit4541
+ = [up to date]      testcommit4542 -> origin/testcommit4542
+ = [up to date]      testcommit4543 -> origin/testcommit4543
+ = [up to date]      testcommit4544 -> origin/testcommit4544
+ = [up to date]      testcommit4545 -> origin/testcommit4545
+ = [up to date]      testcommit4546 -> origin/testcommit4546
+ = [up to date]      testcommit4547 -> origin/testcommit4547
+ = [up to date]      testcommit4548 -> origin/testcommit4548
+ = [up to date]      testcommit4549 -> origin/testcommit4549
+ = [up to date]      testcommit455 -> origin/testcommit455
+ = [up to date]      testcommit4550 -> origin/testcommit4550
+ = [up to date]      testcommit4551 -> origin/testcommit4551
+ = [up to date]      testcommit4552 -> origin/testcommit4552
+ = [up to date]      testcommit4553 -> origin/testcommit4553
+ = [up to date]      testcommit4554 -> origin/testcommit4554
+ = [up to date]      testcommit4555 -> origin/testcommit4555
+ = [up to date]      testcommit4556 -> origin/testcommit4556
+ = [up to date]      testcommit4557 -> origin/testcommit4557
+ = [up to date]      testcommit4558 -> origin/testcommit4558
+ = [up to date]      testcommit4559 -> origin/testcommit4559
+ = [up to date]      testcommit456 -> origin/testcommit456
+ = [up to date]      testcommit4560 -> origin/testcommit4560
+ = [up to date]      testcommit4561 -> origin/testcommit4561
+ = [up to date]      testcommit4562 -> origin/testcommit4562
+ = [up to date]      testcommit4563 -> origin/testcommit4563
+ = [up to date]      testcommit4564 -> origin/testcommit4564
+ = [up to date]      testcommit4565 -> origin/testcommit4565
+ = [up to date]      testcommit4566 -> origin/testcommit4566
+ = [up to date]      testcommit4567 -> origin/testcommit4567
+ = [up to date]      testcommit4568 -> origin/testcommit4568
+ = [up to date]      testcommit4569 -> origin/testcommit4569
+ = [up to date]      testcommit457 -> origin/testcommit457
+ = [up to date]      testcommit4570 -> origin/testcommit4570
+ = [up to date]      testcommit4571 -> origin/testcommit4571
+ = [up to date]      testcommit4572 -> origin/testcommit4572
+ = [up to date]      testcommit4573 -> origin/testcommit4573
+ = [up to date]      testcommit4574 -> origin/testcommit4574
+ = [up to date]      testcommit4575 -> origin/testcommit4575
+ = [up to date]      testcommit4576 -> origin/testcommit4576
+ = [up to date]      testcommit4577 -> origin/testcommit4577
+ = [up to date]      testcommit4578 -> origin/testcommit4578
+ = [up to date]      testcommit4579 -> origin/testcommit4579
+ = [up to date]      testcommit458 -> origin/testcommit458
+ = [up to date]      testcommit4580 -> origin/testcommit4580
+ = [up to date]      testcommit4581 -> origin/testcommit4581
+ = [up to date]      testcommit4582 -> origin/testcommit4582
+ = [up to date]      testcommit4583 -> origin/testcommit4583
+ = [up to date]      testcommit4584 -> origin/testcommit4584
+ = [up to date]      testcommit4585 -> origin/testcommit4585
+ = [up to date]      testcommit4586 -> origin/testcommit4586
+ = [up to date]      testcommit4587 -> origin/testcommit4587
+ = [up to date]      testcommit4588 -> origin/testcommit4588
+ = [up to date]      testcommit4589 -> origin/testcommit4589
+ = [up to date]      testcommit459 -> origin/testcommit459
+ = [up to date]      testcommit4590 -> origin/testcommit4590
+ = [up to date]      testcommit4591 -> origin/testcommit4591
+ = [up to date]      testcommit4592 -> origin/testcommit4592
+ = [up to date]      testcommit4593 -> origin/testcommit4593
+ = [up to date]      testcommit4594 -> origin/testcommit4594
+ = [up to date]      testcommit4595 -> origin/testcommit4595
+ = [up to date]      testcommit4596 -> origin/testcommit4596
+ = [up to date]      testcommit4597 -> origin/testcommit4597
+ = [up to date]      testcommit4598 -> origin/testcommit4598
+ = [up to date]      testcommit4599 -> origin/testcommit4599
+ = [up to date]      testcommit46 -> origin/testcommit46
+ = [up to date]      testcommit460 -> origin/testcommit460
+ = [up to date]      testcommit4600 -> origin/testcommit4600
+ = [up to date]      testcommit4601 -> origin/testcommit4601
+ = [up to date]      testcommit4602 -> origin/testcommit4602
+ = [up to date]      testcommit4603 -> origin/testcommit4603
+ = [up to date]      testcommit4604 -> origin/testcommit4604
+ = [up to date]      testcommit4605 -> origin/testcommit4605
+ = [up to date]      testcommit4606 -> origin/testcommit4606
+ = [up to date]      testcommit4607 -> origin/testcommit4607
+ = [up to date]      testcommit4608 -> origin/testcommit4608
+ = [up to date]      testcommit4609 -> origin/testcommit4609
+ = [up to date]      testcommit461 -> origin/testcommit461
+ = [up to date]      testcommit4610 -> origin/testcommit4610
+ = [up to date]      testcommit4611 -> origin/testcommit4611
+ = [up to date]      testcommit4612 -> origin/testcommit4612
+ = [up to date]      testcommit4613 -> origin/testcommit4613
+ = [up to date]      testcommit4614 -> origin/testcommit4614
+ = [up to date]      testcommit4615 -> origin/testcommit4615
+ = [up to date]      testcommit4616 -> origin/testcommit4616
+ = [up to date]      testcommit4617 -> origin/testcommit4617
+ = [up to date]      testcommit4618 -> origin/testcommit4618
+ = [up to date]      testcommit4619 -> origin/testcommit4619
+ = [up to date]      testcommit462 -> origin/testcommit462
+ = [up to date]      testcommit4620 -> origin/testcommit4620
+ = [up to date]      testcommit4621 -> origin/testcommit4621
+ = [up to date]      testcommit4622 -> origin/testcommit4622
+ = [up to date]      testcommit4623 -> origin/testcommit4623
+ = [up to date]      testcommit4624 -> origin/testcommit4624
+ = [up to date]      testcommit4625 -> origin/testcommit4625
+ = [up to date]      testcommit4626 -> origin/testcommit4626
+ = [up to date]      testcommit4627 -> origin/testcommit4627
+ = [up to date]      testcommit4628 -> origin/testcommit4628
+ = [up to date]      testcommit4629 -> origin/testcommit4629
+ = [up to date]      testcommit463 -> origin/testcommit463
+ = [up to date]      testcommit4630 -> origin/testcommit4630
+ = [up to date]      testcommit4631 -> origin/testcommit4631
+ = [up to date]      testcommit4632 -> origin/testcommit4632
+ = [up to date]      testcommit4633 -> origin/testcommit4633
+ = [up to date]      testcommit4634 -> origin/testcommit4634
+ = [up to date]      testcommit4635 -> origin/testcommit4635
+ = [up to date]      testcommit4636 -> origin/testcommit4636
+ = [up to date]      testcommit4637 -> origin/testcommit4637
+ = [up to date]      testcommit4638 -> origin/testcommit4638
+ = [up to date]      testcommit4639 -> origin/testcommit4639
+ = [up to date]      testcommit464 -> origin/testcommit464
+ = [up to date]      testcommit4640 -> origin/testcommit4640
+ = [up to date]      testcommit4641 -> origin/testcommit4641
+ = [up to date]      testcommit4642 -> origin/testcommit4642
+ = [up to date]      testcommit4643 -> origin/testcommit4643
+ = [up to date]      testcommit4644 -> origin/testcommit4644
+ = [up to date]      testcommit4645 -> origin/testcommit4645
+ = [up to date]      testcommit4646 -> origin/testcommit4646
+ = [up to date]      testcommit4647 -> origin/testcommit4647
+ = [up to date]      testcommit4648 -> origin/testcommit4648
+ = [up to date]      testcommit4649 -> origin/testcommit4649
+ = [up to date]      testcommit465 -> origin/testcommit465
+ = [up to date]      testcommit4650 -> origin/testcommit4650
+ = [up to date]      testcommit4651 -> origin/testcommit4651
+ = [up to date]      testcommit4652 -> origin/testcommit4652
+ = [up to date]      testcommit4653 -> origin/testcommit4653
+ = [up to date]      testcommit4654 -> origin/testcommit4654
+ = [up to date]      testcommit4655 -> origin/testcommit4655
+ = [up to date]      testcommit4656 -> origin/testcommit4656
+ = [up to date]      testcommit4657 -> origin/testcommit4657
+ = [up to date]      testcommit4658 -> origin/testcommit4658
+ = [up to date]      testcommit4659 -> origin/testcommit4659
+ = [up to date]      testcommit466 -> origin/testcommit466
+ = [up to date]      testcommit4660 -> origin/testcommit4660
+ = [up to date]      testcommit4661 -> origin/testcommit4661
+ = [up to date]      testcommit4662 -> origin/testcommit4662
+ = [up to date]      testcommit4663 -> origin/testcommit4663
+ = [up to date]      testcommit4664 -> origin/testcommit4664
+ = [up to date]      testcommit4665 -> origin/testcommit4665
+ = [up to date]      testcommit4666 -> origin/testcommit4666
+ = [up to date]      testcommit4667 -> origin/testcommit4667
+ = [up to date]      testcommit4668 -> origin/testcommit4668
+ = [up to date]      testcommit4669 -> origin/testcommit4669
+ = [up to date]      testcommit467 -> origin/testcommit467
+ = [up to date]      testcommit4670 -> origin/testcommit4670
+ = [up to date]      testcommit4671 -> origin/testcommit4671
+ = [up to date]      testcommit4672 -> origin/testcommit4672
+ = [up to date]      testcommit4673 -> origin/testcommit4673
+ = [up to date]      testcommit4674 -> origin/testcommit4674
+ = [up to date]      testcommit4675 -> origin/testcommit4675
+ = [up to date]      testcommit4676 -> origin/testcommit4676
+ = [up to date]      testcommit4677 -> origin/testcommit4677
+ = [up to date]      testcommit4678 -> origin/testcommit4678
+ = [up to date]      testcommit4679 -> origin/testcommit4679
+ = [up to date]      testcommit468 -> origin/testcommit468
+ = [up to date]      testcommit4680 -> origin/testcommit4680
+ = [up to date]      testcommit4681 -> origin/testcommit4681
+ = [up to date]      testcommit4682 -> origin/testcommit4682
+ = [up to date]      testcommit4683 -> origin/testcommit4683
+ = [up to date]      testcommit4684 -> origin/testcommit4684
+ = [up to date]      testcommit4685 -> origin/testcommit4685
+ = [up to date]      testcommit4686 -> origin/testcommit4686
+ = [up to date]      testcommit4687 -> origin/testcommit4687
+ = [up to date]      testcommit4688 -> origin/testcommit4688
+ = [up to date]      testcommit4689 -> origin/testcommit4689
+ = [up to date]      testcommit469 -> origin/testcommit469
+ = [up to date]      testcommit4690 -> origin/testcommit4690
+ = [up to date]      testcommit4691 -> origin/testcommit4691
+ = [up to date]      testcommit4692 -> origin/testcommit4692
+ = [up to date]      testcommit4693 -> origin/testcommit4693
+ = [up to date]      testcommit4694 -> origin/testcommit4694
+ = [up to date]      testcommit4695 -> origin/testcommit4695
+ = [up to date]      testcommit4696 -> origin/testcommit4696
+ = [up to date]      testcommit4697 -> origin/testcommit4697
+ = [up to date]      testcommit4698 -> origin/testcommit4698
+ = [up to date]      testcommit4699 -> origin/testcommit4699
+ = [up to date]      testcommit47 -> origin/testcommit47
+ = [up to date]      testcommit470 -> origin/testcommit470
+ = [up to date]      testcommit4700 -> origin/testcommit4700
+ = [up to date]      testcommit4701 -> origin/testcommit4701
+ = [up to date]      testcommit4702 -> origin/testcommit4702
+ = [up to date]      testcommit4703 -> origin/testcommit4703
+ = [up to date]      testcommit4704 -> origin/testcommit4704
+ = [up to date]      testcommit4705 -> origin/testcommit4705
+ = [up to date]      testcommit4706 -> origin/testcommit4706
+ = [up to date]      testcommit4707 -> origin/testcommit4707
+ = [up to date]      testcommit4708 -> origin/testcommit4708
+ = [up to date]      testcommit4709 -> origin/testcommit4709
+ = [up to date]      testcommit471 -> origin/testcommit471
+ = [up to date]      testcommit4710 -> origin/testcommit4710
+ = [up to date]      testcommit4711 -> origin/testcommit4711
+ = [up to date]      testcommit4712 -> origin/testcommit4712
+ = [up to date]      testcommit4713 -> origin/testcommit4713
+ = [up to date]      testcommit4714 -> origin/testcommit4714
+ = [up to date]      testcommit4715 -> origin/testcommit4715
+ = [up to date]      testcommit4716 -> origin/testcommit4716
+ = [up to date]      testcommit4717 -> origin/testcommit4717
+ = [up to date]      testcommit4718 -> origin/testcommit4718
+ = [up to date]      testcommit4719 -> origin/testcommit4719
+ = [up to date]      testcommit472 -> origin/testcommit472
+ = [up to date]      testcommit4720 -> origin/testcommit4720
+ = [up to date]      testcommit4721 -> origin/testcommit4721
+ = [up to date]      testcommit4722 -> origin/testcommit4722
+ = [up to date]      testcommit4723 -> origin/testcommit4723
+ = [up to date]      testcommit4724 -> origin/testcommit4724
+ = [up to date]      testcommit4725 -> origin/testcommit4725
+ = [up to date]      testcommit4726 -> origin/testcommit4726
+ = [up to date]      testcommit4727 -> origin/testcommit4727
+ = [up to date]      testcommit4728 -> origin/testcommit4728
+ = [up to date]      testcommit4729 -> origin/testcommit4729
+ = [up to date]      testcommit473 -> origin/testcommit473
+ = [up to date]      testcommit4730 -> origin/testcommit4730
+ = [up to date]      testcommit4731 -> origin/testcommit4731
+ = [up to date]      testcommit4732 -> origin/testcommit4732
+ = [up to date]      testcommit4733 -> origin/testcommit4733
+ = [up to date]      testcommit4734 -> origin/testcommit4734
+ = [up to date]      testcommit4735 -> origin/testcommit4735
+ = [up to date]      testcommit4736 -> origin/testcommit4736
+ = [up to date]      testcommit4737 -> origin/testcommit4737
+ = [up to date]      testcommit4738 -> origin/testcommit4738
+ = [up to date]      testcommit4739 -> origin/testcommit4739
+ = [up to date]      testcommit474 -> origin/testcommit474
+ = [up to date]      testcommit4740 -> origin/testcommit4740
+ = [up to date]      testcommit4741 -> origin/testcommit4741
+ = [up to date]      testcommit4742 -> origin/testcommit4742
+ = [up to date]      testcommit4743 -> origin/testcommit4743
+ = [up to date]      testcommit4744 -> origin/testcommit4744
+ = [up to date]      testcommit4745 -> origin/testcommit4745
+ = [up to date]      testcommit4746 -> origin/testcommit4746
+ = [up to date]      testcommit4747 -> origin/testcommit4747
+ = [up to date]      testcommit4748 -> origin/testcommit4748
+ = [up to date]      testcommit4749 -> origin/testcommit4749
+ = [up to date]      testcommit475 -> origin/testcommit475
+ = [up to date]      testcommit4750 -> origin/testcommit4750
+ = [up to date]      testcommit4751 -> origin/testcommit4751
+ = [up to date]      testcommit4752 -> origin/testcommit4752
+ = [up to date]      testcommit4753 -> origin/testcommit4753
+ = [up to date]      testcommit4754 -> origin/testcommit4754
+ = [up to date]      testcommit4755 -> origin/testcommit4755
+ = [up to date]      testcommit4756 -> origin/testcommit4756
+ = [up to date]      testcommit4757 -> origin/testcommit4757
+ = [up to date]      testcommit4758 -> origin/testcommit4758
+ = [up to date]      testcommit4759 -> origin/testcommit4759
+ = [up to date]      testcommit476 -> origin/testcommit476
+ = [up to date]      testcommit4760 -> origin/testcommit4760
+ = [up to date]      testcommit4761 -> origin/testcommit4761
+ = [up to date]      testcommit4762 -> origin/testcommit4762
+ = [up to date]      testcommit4763 -> origin/testcommit4763
+ = [up to date]      testcommit4764 -> origin/testcommit4764
+ = [up to date]      testcommit4765 -> origin/testcommit4765
+ = [up to date]      testcommit4766 -> origin/testcommit4766
+ = [up to date]      testcommit4767 -> origin/testcommit4767
+ = [up to date]      testcommit4768 -> origin/testcommit4768
+ = [up to date]      testcommit4769 -> origin/testcommit4769
+ = [up to date]      testcommit477 -> origin/testcommit477
+ = [up to date]      testcommit4770 -> origin/testcommit4770
+ = [up to date]      testcommit4771 -> origin/testcommit4771
+ = [up to date]      testcommit4772 -> origin/testcommit4772
+ = [up to date]      testcommit4773 -> origin/testcommit4773
+ = [up to date]      testcommit4774 -> origin/testcommit4774
+ = [up to date]      testcommit4775 -> origin/testcommit4775
+ = [up to date]      testcommit4776 -> origin/testcommit4776
+ = [up to date]      testcommit4777 -> origin/testcommit4777
+ = [up to date]      testcommit4778 -> origin/testcommit4778
+ = [up to date]      testcommit4779 -> origin/testcommit4779
+ = [up to date]      testcommit478 -> origin/testcommit478
+ = [up to date]      testcommit4780 -> origin/testcommit4780
+ = [up to date]      testcommit4781 -> origin/testcommit4781
+ = [up to date]      testcommit4782 -> origin/testcommit4782
+ = [up to date]      testcommit4783 -> origin/testcommit4783
+ = [up to date]      testcommit4784 -> origin/testcommit4784
+ = [up to date]      testcommit4785 -> origin/testcommit4785
+ = [up to date]      testcommit4786 -> origin/testcommit4786
+ = [up to date]      testcommit4787 -> origin/testcommit4787
+ = [up to date]      testcommit4788 -> origin/testcommit4788
+ = [up to date]      testcommit4789 -> origin/testcommit4789
+ = [up to date]      testcommit479 -> origin/testcommit479
+ = [up to date]      testcommit4790 -> origin/testcommit4790
+ = [up to date]      testcommit4791 -> origin/testcommit4791
+ = [up to date]      testcommit4792 -> origin/testcommit4792
+ = [up to date]      testcommit4793 -> origin/testcommit4793
+ = [up to date]      testcommit4794 -> origin/testcommit4794
+ = [up to date]      testcommit4795 -> origin/testcommit4795
+ = [up to date]      testcommit4796 -> origin/testcommit4796
+ = [up to date]      testcommit4797 -> origin/testcommit4797
+ = [up to date]      testcommit4798 -> origin/testcommit4798
+ = [up to date]      testcommit4799 -> origin/testcommit4799
+ = [up to date]      testcommit48 -> origin/testcommit48
+ = [up to date]      testcommit480 -> origin/testcommit480
+ = [up to date]      testcommit4800 -> origin/testcommit4800
+ = [up to date]      testcommit4801 -> origin/testcommit4801
+ = [up to date]      testcommit4802 -> origin/testcommit4802
+ = [up to date]      testcommit4803 -> origin/testcommit4803
+ = [up to date]      testcommit4804 -> origin/testcommit4804
+ = [up to date]      testcommit4805 -> origin/testcommit4805
+ = [up to date]      testcommit4806 -> origin/testcommit4806
+ = [up to date]      testcommit4807 -> origin/testcommit4807
+ = [up to date]      testcommit4808 -> origin/testcommit4808
+ = [up to date]      testcommit4809 -> origin/testcommit4809
+ = [up to date]      testcommit481 -> origin/testcommit481
+ = [up to date]      testcommit4810 -> origin/testcommit4810
+ = [up to date]      testcommit4811 -> origin/testcommit4811
+ = [up to date]      testcommit4812 -> origin/testcommit4812
+ = [up to date]      testcommit4813 -> origin/testcommit4813
+ = [up to date]      testcommit4814 -> origin/testcommit4814
+ = [up to date]      testcommit4815 -> origin/testcommit4815
+ = [up to date]      testcommit4816 -> origin/testcommit4816
+ = [up to date]      testcommit4817 -> origin/testcommit4817
+ = [up to date]      testcommit4818 -> origin/testcommit4818
+ = [up to date]      testcommit4819 -> origin/testcommit4819
+ = [up to date]      testcommit482 -> origin/testcommit482
+ = [up to date]      testcommit4820 -> origin/testcommit4820
+ = [up to date]      testcommit4821 -> origin/testcommit4821
+ = [up to date]      testcommit4822 -> origin/testcommit4822
+ = [up to date]      testcommit4823 -> origin/testcommit4823
+ = [up to date]      testcommit4824 -> origin/testcommit4824
+ = [up to date]      testcommit4825 -> origin/testcommit4825
+ = [up to date]      testcommit4826 -> origin/testcommit4826
+ = [up to date]      testcommit4827 -> origin/testcommit4827
+ = [up to date]      testcommit4828 -> origin/testcommit4828
+ = [up to date]      testcommit4829 -> origin/testcommit4829
+ = [up to date]      testcommit483 -> origin/testcommit483
+ = [up to date]      testcommit4830 -> origin/testcommit4830
+ = [up to date]      testcommit4831 -> origin/testcommit4831
+ = [up to date]      testcommit4832 -> origin/testcommit4832
+ = [up to date]      testcommit4833 -> origin/testcommit4833
+ = [up to date]      testcommit4834 -> origin/testcommit4834
+ = [up to date]      testcommit4835 -> origin/testcommit4835
+ = [up to date]      testcommit4836 -> origin/testcommit4836
+ = [up to date]      testcommit4837 -> origin/testcommit4837
+ = [up to date]      testcommit4838 -> origin/testcommit4838
+ = [up to date]      testcommit4839 -> origin/testcommit4839
+ = [up to date]      testcommit484 -> origin/testcommit484
+ = [up to date]      testcommit4840 -> origin/testcommit4840
+ = [up to date]      testcommit4841 -> origin/testcommit4841
+ = [up to date]      testcommit4842 -> origin/testcommit4842
+ = [up to date]      testcommit4843 -> origin/testcommit4843
+ = [up to date]      testcommit4844 -> origin/testcommit4844
+ = [up to date]      testcommit4845 -> origin/testcommit4845
+ = [up to date]      testcommit4846 -> origin/testcommit4846
+ = [up to date]      testcommit4847 -> origin/testcommit4847
+ = [up to date]      testcommit4848 -> origin/testcommit4848
+ = [up to date]      testcommit4849 -> origin/testcommit4849
+ = [up to date]      testcommit485 -> origin/testcommit485
+ = [up to date]      testcommit4850 -> origin/testcommit4850
+ = [up to date]      testcommit4851 -> origin/testcommit4851
+ = [up to date]      testcommit4852 -> origin/testcommit4852
+ = [up to date]      testcommit4853 -> origin/testcommit4853
+ = [up to date]      testcommit4854 -> origin/testcommit4854
+ = [up to date]      testcommit4855 -> origin/testcommit4855
+ = [up to date]      testcommit4856 -> origin/testcommit4856
+ = [up to date]      testcommit4857 -> origin/testcommit4857
+ = [up to date]      testcommit4858 -> origin/testcommit4858
+ = [up to date]      testcommit4859 -> origin/testcommit4859
+ = [up to date]      testcommit486 -> origin/testcommit486
+ = [up to date]      testcommit4860 -> origin/testcommit4860
+ = [up to date]      testcommit4861 -> origin/testcommit4861
+ = [up to date]      testcommit4862 -> origin/testcommit4862
+ = [up to date]      testcommit4863 -> origin/testcommit4863
+ = [up to date]      testcommit4864 -> origin/testcommit4864
+ = [up to date]      testcommit4865 -> origin/testcommit4865
+ = [up to date]      testcommit4866 -> origin/testcommit4866
+ = [up to date]      testcommit4867 -> origin/testcommit4867
+ = [up to date]      testcommit4868 -> origin/testcommit4868
+ = [up to date]      testcommit4869 -> origin/testcommit4869
+ = [up to date]      testcommit487 -> origin/testcommit487
+ = [up to date]      testcommit4870 -> origin/testcommit4870
+ = [up to date]      testcommit4871 -> origin/testcommit4871
+ = [up to date]      testcommit4872 -> origin/testcommit4872
+ = [up to date]      testcommit4873 -> origin/testcommit4873
+ = [up to date]      testcommit4874 -> origin/testcommit4874
+ = [up to date]      testcommit4875 -> origin/testcommit4875
+ = [up to date]      testcommit4876 -> origin/testcommit4876
+ = [up to date]      testcommit4877 -> origin/testcommit4877
+ = [up to date]      testcommit4878 -> origin/testcommit4878
+ = [up to date]      testcommit4879 -> origin/testcommit4879
+ = [up to date]      testcommit488 -> origin/testcommit488
+ = [up to date]      testcommit4880 -> origin/testcommit4880
+ = [up to date]      testcommit4881 -> origin/testcommit4881
+ = [up to date]      testcommit4882 -> origin/testcommit4882
+ = [up to date]      testcommit4883 -> origin/testcommit4883
+ = [up to date]      testcommit4884 -> origin/testcommit4884
+ = [up to date]      testcommit4885 -> origin/testcommit4885
+ = [up to date]      testcommit4886 -> origin/testcommit4886
+ = [up to date]      testcommit4887 -> origin/testcommit4887
+ = [up to date]      testcommit4888 -> origin/testcommit4888
+ = [up to date]      testcommit4889 -> origin/testcommit4889
+ = [up to date]      testcommit489 -> origin/testcommit489
+ = [up to date]      testcommit4890 -> origin/testcommit4890
+ = [up to date]      testcommit4891 -> origin/testcommit4891
+ = [up to date]      testcommit4892 -> origin/testcommit4892
+ = [up to date]      testcommit4893 -> origin/testcommit4893
+ = [up to date]      testcommit4894 -> origin/testcommit4894
+ = [up to date]      testcommit4895 -> origin/testcommit4895
+ = [up to date]      testcommit4896 -> origin/testcommit4896
+ = [up to date]      testcommit4897 -> origin/testcommit4897
+ = [up to date]      testcommit4898 -> origin/testcommit4898
+ = [up to date]      testcommit4899 -> origin/testcommit4899
+ = [up to date]      testcommit49 -> origin/testcommit49
+ = [up to date]      testcommit490 -> origin/testcommit490
+ = [up to date]      testcommit4900 -> origin/testcommit4900
+ = [up to date]      testcommit4901 -> origin/testcommit4901
+ = [up to date]      testcommit4902 -> origin/testcommit4902
+ = [up to date]      testcommit4903 -> origin/testcommit4903
+ = [up to date]      testcommit4904 -> origin/testcommit4904
+ = [up to date]      testcommit4905 -> origin/testcommit4905
+ = [up to date]      testcommit4906 -> origin/testcommit4906
+ = [up to date]      testcommit4907 -> origin/testcommit4907
+ = [up to date]      testcommit4908 -> origin/testcommit4908
+ = [up to date]      testcommit4909 -> origin/testcommit4909
+ = [up to date]      testcommit491 -> origin/testcommit491
+ = [up to date]      testcommit4910 -> origin/testcommit4910
+ = [up to date]      testcommit4911 -> origin/testcommit4911
+ = [up to date]      testcommit4912 -> origin/testcommit4912
+ = [up to date]      testcommit4913 -> origin/testcommit4913
+ = [up to date]      testcommit4914 -> origin/testcommit4914
+ = [up to date]      testcommit4915 -> origin/testcommit4915
+ = [up to date]      testcommit4916 -> origin/testcommit4916
+ = [up to date]      testcommit4917 -> origin/testcommit4917
+ = [up to date]      testcommit4918 -> origin/testcommit4918
+ = [up to date]      testcommit4919 -> origin/testcommit4919
+ = [up to date]      testcommit492 -> origin/testcommit492
+ = [up to date]      testcommit4920 -> origin/testcommit4920
+ = [up to date]      testcommit4921 -> origin/testcommit4921
+ = [up to date]      testcommit4922 -> origin/testcommit4922
+ = [up to date]      testcommit4923 -> origin/testcommit4923
+ = [up to date]      testcommit4924 -> origin/testcommit4924
+ = [up to date]      testcommit4925 -> origin/testcommit4925
+ = [up to date]      testcommit4926 -> origin/testcommit4926
+ = [up to date]      testcommit4927 -> origin/testcommit4927
+ = [up to date]      testcommit4928 -> origin/testcommit4928
+ = [up to date]      testcommit4929 -> origin/testcommit4929
+ = [up to date]      testcommit493 -> origin/testcommit493
+ = [up to date]      testcommit4930 -> origin/testcommit4930
+ = [up to date]      testcommit4931 -> origin/testcommit4931
+ = [up to date]      testcommit4932 -> origin/testcommit4932
+ = [up to date]      testcommit4933 -> origin/testcommit4933
+ = [up to date]      testcommit4934 -> origin/testcommit4934
+ = [up to date]      testcommit4935 -> origin/testcommit4935
+ = [up to date]      testcommit4936 -> origin/testcommit4936
+ = [up to date]      testcommit4937 -> origin/testcommit4937
+ = [up to date]      testcommit4938 -> origin/testcommit4938
+ = [up to date]      testcommit4939 -> origin/testcommit4939
+ = [up to date]      testcommit494 -> origin/testcommit494
+ = [up to date]      testcommit4940 -> origin/testcommit4940
+ = [up to date]      testcommit4941 -> origin/testcommit4941
+ = [up to date]      testcommit4942 -> origin/testcommit4942
+ = [up to date]      testcommit4943 -> origin/testcommit4943
+ = [up to date]      testcommit4944 -> origin/testcommit4944
+ = [up to date]      testcommit4945 -> origin/testcommit4945
+ = [up to date]      testcommit4946 -> origin/testcommit4946
+ = [up to date]      testcommit4947 -> origin/testcommit4947
+ = [up to date]      testcommit4948 -> origin/testcommit4948
+ = [up to date]      testcommit4949 -> origin/testcommit4949
+ = [up to date]      testcommit495 -> origin/testcommit495
+ = [up to date]      testcommit4950 -> origin/testcommit4950
+ = [up to date]      testcommit4951 -> origin/testcommit4951
+ = [up to date]      testcommit4952 -> origin/testcommit4952
+ = [up to date]      testcommit4953 -> origin/testcommit4953
+ = [up to date]      testcommit4954 -> origin/testcommit4954
+ = [up to date]      testcommit4955 -> origin/testcommit4955
+ = [up to date]      testcommit4956 -> origin/testcommit4956
+ = [up to date]      testcommit4957 -> origin/testcommit4957
+ = [up to date]      testcommit4958 -> origin/testcommit4958
+ = [up to date]      testcommit4959 -> origin/testcommit4959
+ = [up to date]      testcommit496 -> origin/testcommit496
+ = [up to date]      testcommit4960 -> origin/testcommit4960
+ = [up to date]      testcommit4961 -> origin/testcommit4961
+ = [up to date]      testcommit4962 -> origin/testcommit4962
+ = [up to date]      testcommit4963 -> origin/testcommit4963
+ = [up to date]      testcommit4964 -> origin/testcommit4964
+ = [up to date]      testcommit4965 -> origin/testcommit4965
+ = [up to date]      testcommit4966 -> origin/testcommit4966
+ = [up to date]      testcommit4967 -> origin/testcommit4967
+ = [up to date]      testcommit4968 -> origin/testcommit4968
+ = [up to date]      testcommit4969 -> origin/testcommit4969
+ = [up to date]      testcommit497 -> origin/testcommit497
+ = [up to date]      testcommit4970 -> origin/testcommit4970
+ = [up to date]      testcommit4971 -> origin/testcommit4971
+ = [up to date]      testcommit4972 -> origin/testcommit4972
+ = [up to date]      testcommit4973 -> origin/testcommit4973
+ = [up to date]      testcommit4974 -> origin/testcommit4974
+ = [up to date]      testcommit4975 -> origin/testcommit4975
+ = [up to date]      testcommit4976 -> origin/testcommit4976
+ = [up to date]      testcommit4977 -> origin/testcommit4977
+ = [up to date]      testcommit4978 -> origin/testcommit4978
+ = [up to date]      testcommit4979 -> origin/testcommit4979
+ = [up to date]      testcommit498 -> origin/testcommit498
+ = [up to date]      testcommit4980 -> origin/testcommit4980
+ = [up to date]      testcommit4981 -> origin/testcommit4981
+ = [up to date]      testcommit4982 -> origin/testcommit4982
+ = [up to date]      testcommit4983 -> origin/testcommit4983
+ = [up to date]      testcommit4984 -> origin/testcommit4984
+ = [up to date]      testcommit4985 -> origin/testcommit4985
+ = [up to date]      testcommit4986 -> origin/testcommit4986
+ = [up to date]      testcommit4987 -> origin/testcommit4987
+ = [up to date]      testcommit4988 -> origin/testcommit4988
+ = [up to date]      testcommit4989 -> origin/testcommit4989
+ = [up to date]      testcommit499 -> origin/testcommit499
+ = [up to date]      testcommit4990 -> origin/testcommit4990
+ = [up to date]      testcommit4991 -> origin/testcommit4991
+ = [up to date]      testcommit4992 -> origin/testcommit4992
+ = [up to date]      testcommit4993 -> origin/testcommit4993
+ = [up to date]      testcommit4994 -> origin/testcommit4994
+ = [up to date]      testcommit4995 -> origin/testcommit4995
+ = [up to date]      testcommit4996 -> origin/testcommit4996
+ = [up to date]      testcommit4997 -> origin/testcommit4997
+ = [up to date]      testcommit4998 -> origin/testcommit4998
+ = [up to date]      testcommit4999 -> origin/testcommit4999
+ = [up to date]      testcommit5 -> origin/testcommit5
+ = [up to date]      testcommit50 -> origin/testcommit50
+ = [up to date]      testcommit500 -> origin/testcommit500
+ = [up to date]      testcommit5000 -> origin/testcommit5000
+ = [up to date]      testcommit501 -> origin/testcommit501
+ = [up to date]      testcommit502 -> origin/testcommit502
+ = [up to date]      testcommit503 -> origin/testcommit503
+ = [up to date]      testcommit504 -> origin/testcommit504
+ = [up to date]      testcommit505 -> origin/testcommit505
+ = [up to date]      testcommit506 -> origin/testcommit506
+ = [up to date]      testcommit507 -> origin/testcommit507
+ = [up to date]      testcommit508 -> origin/testcommit508
+ = [up to date]      testcommit509 -> origin/testcommit509
+ = [up to date]      testcommit51 -> origin/testcommit51
+ = [up to date]      testcommit510 -> origin/testcommit510
+ = [up to date]      testcommit511 -> origin/testcommit511
+ = [up to date]      testcommit512 -> origin/testcommit512
+ = [up to date]      testcommit513 -> origin/testcommit513
+ = [up to date]      testcommit514 -> origin/testcommit514
+ = [up to date]      testcommit515 -> origin/testcommit515
+ = [up to date]      testcommit516 -> origin/testcommit516
+ = [up to date]      testcommit517 -> origin/testcommit517
+ = [up to date]      testcommit518 -> origin/testcommit518
+ = [up to date]      testcommit519 -> origin/testcommit519
+ = [up to date]      testcommit52 -> origin/testcommit52
+ = [up to date]      testcommit520 -> origin/testcommit520
+ = [up to date]      testcommit521 -> origin/testcommit521
+ = [up to date]      testcommit522 -> origin/testcommit522
+ = [up to date]      testcommit523 -> origin/testcommit523
+ = [up to date]      testcommit524 -> origin/testcommit524
+ = [up to date]      testcommit525 -> origin/testcommit525
+ = [up to date]      testcommit526 -> origin/testcommit526
+ = [up to date]      testcommit527 -> origin/testcommit527
+ = [up to date]      testcommit528 -> origin/testcommit528
+ = [up to date]      testcommit529 -> origin/testcommit529
+ = [up to date]      testcommit53 -> origin/testcommit53
+ = [up to date]      testcommit530 -> origin/testcommit530
+ = [up to date]      testcommit531 -> origin/testcommit531
+ = [up to date]      testcommit532 -> origin/testcommit532
+ = [up to date]      testcommit533 -> origin/testcommit533
+ = [up to date]      testcommit534 -> origin/testcommit534
+ = [up to date]      testcommit535 -> origin/testcommit535
+ = [up to date]      testcommit536 -> origin/testcommit536
+ = [up to date]      testcommit537 -> origin/testcommit537
+ = [up to date]      testcommit538 -> origin/testcommit538
+ = [up to date]      testcommit539 -> origin/testcommit539
+ = [up to date]      testcommit54 -> origin/testcommit54
+ = [up to date]      testcommit540 -> origin/testcommit540
+ = [up to date]      testcommit541 -> origin/testcommit541
+ = [up to date]      testcommit542 -> origin/testcommit542
+ = [up to date]      testcommit543 -> origin/testcommit543
+ = [up to date]      testcommit544 -> origin/testcommit544
+ = [up to date]      testcommit545 -> origin/testcommit545
+ = [up to date]      testcommit546 -> origin/testcommit546
+ = [up to date]      testcommit547 -> origin/testcommit547
+ = [up to date]      testcommit548 -> origin/testcommit548
+ = [up to date]      testcommit549 -> origin/testcommit549
+ = [up to date]      testcommit55 -> origin/testcommit55
+ = [up to date]      testcommit550 -> origin/testcommit550
+ = [up to date]      testcommit551 -> origin/testcommit551
+ = [up to date]      testcommit552 -> origin/testcommit552
+ = [up to date]      testcommit553 -> origin/testcommit553
+ = [up to date]      testcommit554 -> origin/testcommit554
+ = [up to date]      testcommit555 -> origin/testcommit555
+ = [up to date]      testcommit556 -> origin/testcommit556
+ = [up to date]      testcommit557 -> origin/testcommit557
+ = [up to date]      testcommit558 -> origin/testcommit558
+ = [up to date]      testcommit559 -> origin/testcommit559
+ = [up to date]      testcommit56 -> origin/testcommit56
+ = [up to date]      testcommit560 -> origin/testcommit560
+ = [up to date]      testcommit561 -> origin/testcommit561
+ = [up to date]      testcommit562 -> origin/testcommit562
+ = [up to date]      testcommit563 -> origin/testcommit563
+ = [up to date]      testcommit564 -> origin/testcommit564
+ = [up to date]      testcommit565 -> origin/testcommit565
+ = [up to date]      testcommit566 -> origin/testcommit566
+ = [up to date]      testcommit567 -> origin/testcommit567
+ = [up to date]      testcommit568 -> origin/testcommit568
+ = [up to date]      testcommit569 -> origin/testcommit569
+ = [up to date]      testcommit57 -> origin/testcommit57
+ = [up to date]      testcommit570 -> origin/testcommit570
+ = [up to date]      testcommit571 -> origin/testcommit571
+ = [up to date]      testcommit572 -> origin/testcommit572
+ = [up to date]      testcommit573 -> origin/testcommit573
+ = [up to date]      testcommit574 -> origin/testcommit574
+ = [up to date]      testcommit575 -> origin/testcommit575
+ = [up to date]      testcommit576 -> origin/testcommit576
+ = [up to date]      testcommit577 -> origin/testcommit577
+ = [up to date]      testcommit578 -> origin/testcommit578
+ = [up to date]      testcommit579 -> origin/testcommit579
+ = [up to date]      testcommit58 -> origin/testcommit58
+ = [up to date]      testcommit580 -> origin/testcommit580
+ = [up to date]      testcommit581 -> origin/testcommit581
+ = [up to date]      testcommit582 -> origin/testcommit582
+ = [up to date]      testcommit583 -> origin/testcommit583
+ = [up to date]      testcommit584 -> origin/testcommit584
+ = [up to date]      testcommit585 -> origin/testcommit585
+ = [up to date]      testcommit586 -> origin/testcommit586
+ = [up to date]      testcommit587 -> origin/testcommit587
+ = [up to date]      testcommit588 -> origin/testcommit588
+ = [up to date]      testcommit589 -> origin/testcommit589
+ = [up to date]      testcommit59 -> origin/testcommit59
+ = [up to date]      testcommit590 -> origin/testcommit590
+ = [up to date]      testcommit591 -> origin/testcommit591
+ = [up to date]      testcommit592 -> origin/testcommit592
+ = [up to date]      testcommit593 -> origin/testcommit593
+ = [up to date]      testcommit594 -> origin/testcommit594
+ = [up to date]      testcommit595 -> origin/testcommit595
+ = [up to date]      testcommit596 -> origin/testcommit596
+ = [up to date]      testcommit597 -> origin/testcommit597
+ = [up to date]      testcommit598 -> origin/testcommit598
+ = [up to date]      testcommit599 -> origin/testcommit599
+ = [up to date]      testcommit6 -> origin/testcommit6
+ = [up to date]      testcommit60 -> origin/testcommit60
+ = [up to date]      testcommit600 -> origin/testcommit600
+ = [up to date]      testcommit601 -> origin/testcommit601
+ = [up to date]      testcommit602 -> origin/testcommit602
+ = [up to date]      testcommit603 -> origin/testcommit603
+ = [up to date]      testcommit604 -> origin/testcommit604
+ = [up to date]      testcommit605 -> origin/testcommit605
+ = [up to date]      testcommit606 -> origin/testcommit606
+ = [up to date]      testcommit607 -> origin/testcommit607
+ = [up to date]      testcommit608 -> origin/testcommit608
+ = [up to date]      testcommit609 -> origin/testcommit609
+ = [up to date]      testcommit61 -> origin/testcommit61
+ = [up to date]      testcommit610 -> origin/testcommit610
+ = [up to date]      testcommit611 -> origin/testcommit611
+ = [up to date]      testcommit612 -> origin/testcommit612
+ = [up to date]      testcommit613 -> origin/testcommit613
+ = [up to date]      testcommit614 -> origin/testcommit614
+ = [up to date]      testcommit615 -> origin/testcommit615
+ = [up to date]      testcommit616 -> origin/testcommit616
+ = [up to date]      testcommit617 -> origin/testcommit617
+ = [up to date]      testcommit618 -> origin/testcommit618
+ = [up to date]      testcommit619 -> origin/testcommit619
+ = [up to date]      testcommit62 -> origin/testcommit62
+ = [up to date]      testcommit620 -> origin/testcommit620
+ = [up to date]      testcommit621 -> origin/testcommit621
+ = [up to date]      testcommit622 -> origin/testcommit622
+ = [up to date]      testcommit623 -> origin/testcommit623
+ = [up to date]      testcommit624 -> origin/testcommit624
+ = [up to date]      testcommit625 -> origin/testcommit625
+ = [up to date]      testcommit626 -> origin/testcommit626
+ = [up to date]      testcommit627 -> origin/testcommit627
+ = [up to date]      testcommit628 -> origin/testcommit628
+ = [up to date]      testcommit629 -> origin/testcommit629
+ = [up to date]      testcommit63 -> origin/testcommit63
+ = [up to date]      testcommit630 -> origin/testcommit630
+ = [up to date]      testcommit631 -> origin/testcommit631
+ = [up to date]      testcommit632 -> origin/testcommit632
+ = [up to date]      testcommit633 -> origin/testcommit633
+ = [up to date]      testcommit634 -> origin/testcommit634
+ = [up to date]      testcommit635 -> origin/testcommit635
+ = [up to date]      testcommit636 -> origin/testcommit636
+ = [up to date]      testcommit637 -> origin/testcommit637
+ = [up to date]      testcommit638 -> origin/testcommit638
+ = [up to date]      testcommit639 -> origin/testcommit639
+ = [up to date]      testcommit64 -> origin/testcommit64
+ = [up to date]      testcommit640 -> origin/testcommit640
+ = [up to date]      testcommit641 -> origin/testcommit641
+ = [up to date]      testcommit642 -> origin/testcommit642
+ = [up to date]      testcommit643 -> origin/testcommit643
+ = [up to date]      testcommit644 -> origin/testcommit644
+ = [up to date]      testcommit645 -> origin/testcommit645
+ = [up to date]      testcommit646 -> origin/testcommit646
+ = [up to date]      testcommit647 -> origin/testcommit647
+ = [up to date]      testcommit648 -> origin/testcommit648
+ = [up to date]      testcommit649 -> origin/testcommit649
+ = [up to date]      testcommit65 -> origin/testcommit65
+ = [up to date]      testcommit650 -> origin/testcommit650
+ = [up to date]      testcommit651 -> origin/testcommit651
+ = [up to date]      testcommit652 -> origin/testcommit652
+ = [up to date]      testcommit653 -> origin/testcommit653
+ = [up to date]      testcommit654 -> origin/testcommit654
+ = [up to date]      testcommit655 -> origin/testcommit655
+ = [up to date]      testcommit656 -> origin/testcommit656
+ = [up to date]      testcommit657 -> origin/testcommit657
+ = [up to date]      testcommit658 -> origin/testcommit658
+ = [up to date]      testcommit659 -> origin/testcommit659
+ = [up to date]      testcommit66 -> origin/testcommit66
+ = [up to date]      testcommit660 -> origin/testcommit660
+ = [up to date]      testcommit661 -> origin/testcommit661
+ = [up to date]      testcommit662 -> origin/testcommit662
+ = [up to date]      testcommit663 -> origin/testcommit663
+ = [up to date]      testcommit664 -> origin/testcommit664
+ = [up to date]      testcommit665 -> origin/testcommit665
+ = [up to date]      testcommit666 -> origin/testcommit666
+ = [up to date]      testcommit667 -> origin/testcommit667
+ = [up to date]      testcommit668 -> origin/testcommit668
+ = [up to date]      testcommit669 -> origin/testcommit669
+ = [up to date]      testcommit67 -> origin/testcommit67
+ = [up to date]      testcommit670 -> origin/testcommit670
+ = [up to date]      testcommit671 -> origin/testcommit671
+ = [up to date]      testcommit672 -> origin/testcommit672
+ = [up to date]      testcommit673 -> origin/testcommit673
+ = [up to date]      testcommit674 -> origin/testcommit674
+ = [up to date]      testcommit675 -> origin/testcommit675
+ = [up to date]      testcommit676 -> origin/testcommit676
+ = [up to date]      testcommit677 -> origin/testcommit677
+ = [up to date]      testcommit678 -> origin/testcommit678
+ = [up to date]      testcommit679 -> origin/testcommit679
+ = [up to date]      testcommit68 -> origin/testcommit68
+ = [up to date]      testcommit680 -> origin/testcommit680
+ = [up to date]      testcommit681 -> origin/testcommit681
+ = [up to date]      testcommit682 -> origin/testcommit682
+ = [up to date]      testcommit683 -> origin/testcommit683
+ = [up to date]      testcommit684 -> origin/testcommit684
+ = [up to date]      testcommit685 -> origin/testcommit685
+ = [up to date]      testcommit686 -> origin/testcommit686
+ = [up to date]      testcommit687 -> origin/testcommit687
+ = [up to date]      testcommit688 -> origin/testcommit688
+ = [up to date]      testcommit689 -> origin/testcommit689
+ = [up to date]      testcommit69 -> origin/testcommit69
+ = [up to date]      testcommit690 -> origin/testcommit690
+ = [up to date]      testcommit691 -> origin/testcommit691
+ = [up to date]      testcommit692 -> origin/testcommit692
+ = [up to date]      testcommit693 -> origin/testcommit693
+ = [up to date]      testcommit694 -> origin/testcommit694
+ = [up to date]      testcommit695 -> origin/testcommit695
+ = [up to date]      testcommit696 -> origin/testcommit696
+ = [up to date]      testcommit697 -> origin/testcommit697
+ = [up to date]      testcommit698 -> origin/testcommit698
+ = [up to date]      testcommit699 -> origin/testcommit699
+ = [up to date]      testcommit7 -> origin/testcommit7
+ = [up to date]      testcommit70 -> origin/testcommit70
+ = [up to date]      testcommit700 -> origin/testcommit700
+ = [up to date]      testcommit701 -> origin/testcommit701
+ = [up to date]      testcommit702 -> origin/testcommit702
+ = [up to date]      testcommit703 -> origin/testcommit703
+ = [up to date]      testcommit704 -> origin/testcommit704
+ = [up to date]      testcommit705 -> origin/testcommit705
+ = [up to date]      testcommit706 -> origin/testcommit706
+ = [up to date]      testcommit707 -> origin/testcommit707
+ = [up to date]      testcommit708 -> origin/testcommit708
+ = [up to date]      testcommit709 -> origin/testcommit709
+ = [up to date]      testcommit71 -> origin/testcommit71
+ = [up to date]      testcommit710 -> origin/testcommit710
+ = [up to date]      testcommit711 -> origin/testcommit711
+ = [up to date]      testcommit712 -> origin/testcommit712
+ = [up to date]      testcommit713 -> origin/testcommit713
+ = [up to date]      testcommit714 -> origin/testcommit714
+ = [up to date]      testcommit715 -> origin/testcommit715
+ = [up to date]      testcommit716 -> origin/testcommit716
+ = [up to date]      testcommit717 -> origin/testcommit717
+ = [up to date]      testcommit718 -> origin/testcommit718
+ = [up to date]      testcommit719 -> origin/testcommit719
+ = [up to date]      testcommit72 -> origin/testcommit72
+ = [up to date]      testcommit720 -> origin/testcommit720
+ = [up to date]      testcommit721 -> origin/testcommit721
+ = [up to date]      testcommit722 -> origin/testcommit722
+ = [up to date]      testcommit723 -> origin/testcommit723
+ = [up to date]      testcommit724 -> origin/testcommit724
+ = [up to date]      testcommit725 -> origin/testcommit725
+ = [up to date]      testcommit726 -> origin/testcommit726
+ = [up to date]      testcommit727 -> origin/testcommit727
+ = [up to date]      testcommit728 -> origin/testcommit728
+ = [up to date]      testcommit729 -> origin/testcommit729
+ = [up to date]      testcommit73 -> origin/testcommit73
+ = [up to date]      testcommit730 -> origin/testcommit730
+ = [up to date]      testcommit731 -> origin/testcommit731
+ = [up to date]      testcommit732 -> origin/testcommit732
+ = [up to date]      testcommit733 -> origin/testcommit733
+ = [up to date]      testcommit734 -> origin/testcommit734
+ = [up to date]      testcommit735 -> origin/testcommit735
+ = [up to date]      testcommit736 -> origin/testcommit736
+ = [up to date]      testcommit737 -> origin/testcommit737
+ = [up to date]      testcommit738 -> origin/testcommit738
+ = [up to date]      testcommit739 -> origin/testcommit739
+ = [up to date]      testcommit74 -> origin/testcommit74
+ = [up to date]      testcommit740 -> origin/testcommit740
+ = [up to date]      testcommit741 -> origin/testcommit741
+ = [up to date]      testcommit742 -> origin/testcommit742
+ = [up to date]      testcommit743 -> origin/testcommit743
+ = [up to date]      testcommit744 -> origin/testcommit744
+ = [up to date]      testcommit745 -> origin/testcommit745
+ = [up to date]      testcommit746 -> origin/testcommit746
+ = [up to date]      testcommit747 -> origin/testcommit747
+ = [up to date]      testcommit748 -> origin/testcommit748
+ = [up to date]      testcommit749 -> origin/testcommit749
+ = [up to date]      testcommit75 -> origin/testcommit75
+ = [up to date]      testcommit750 -> origin/testcommit750
+ = [up to date]      testcommit751 -> origin/testcommit751
+ = [up to date]      testcommit752 -> origin/testcommit752
+ = [up to date]      testcommit753 -> origin/testcommit753
+ = [up to date]      testcommit754 -> origin/testcommit754
+ = [up to date]      testcommit755 -> origin/testcommit755
+ = [up to date]      testcommit756 -> origin/testcommit756
+ = [up to date]      testcommit757 -> origin/testcommit757
+ = [up to date]      testcommit758 -> origin/testcommit758
+ = [up to date]      testcommit759 -> origin/testcommit759
+ = [up to date]      testcommit76 -> origin/testcommit76
+ = [up to date]      testcommit760 -> origin/testcommit760
+ = [up to date]      testcommit761 -> origin/testcommit761
+ = [up to date]      testcommit762 -> origin/testcommit762
+ = [up to date]      testcommit763 -> origin/testcommit763
+ = [up to date]      testcommit764 -> origin/testcommit764
+ = [up to date]      testcommit765 -> origin/testcommit765
+ = [up to date]      testcommit766 -> origin/testcommit766
+ = [up to date]      testcommit767 -> origin/testcommit767
+ = [up to date]      testcommit768 -> origin/testcommit768
+ = [up to date]      testcommit769 -> origin/testcommit769
+ = [up to date]      testcommit77 -> origin/testcommit77
+ = [up to date]      testcommit770 -> origin/testcommit770
+ = [up to date]      testcommit771 -> origin/testcommit771
+ = [up to date]      testcommit772 -> origin/testcommit772
+ = [up to date]      testcommit773 -> origin/testcommit773
+ = [up to date]      testcommit774 -> origin/testcommit774
+ = [up to date]      testcommit775 -> origin/testcommit775
+ = [up to date]      testcommit776 -> origin/testcommit776
+ = [up to date]      testcommit777 -> origin/testcommit777
+ = [up to date]      testcommit778 -> origin/testcommit778
+ = [up to date]      testcommit779 -> origin/testcommit779
+ = [up to date]      testcommit78 -> origin/testcommit78
+ = [up to date]      testcommit780 -> origin/testcommit780
+ = [up to date]      testcommit781 -> origin/testcommit781
+ = [up to date]      testcommit782 -> origin/testcommit782
+ = [up to date]      testcommit783 -> origin/testcommit783
+ = [up to date]      testcommit784 -> origin/testcommit784
+ = [up to date]      testcommit785 -> origin/testcommit785
+ = [up to date]      testcommit786 -> origin/testcommit786
+ = [up to date]      testcommit787 -> origin/testcommit787
+ = [up to date]      testcommit788 -> origin/testcommit788
+ = [up to date]      testcommit789 -> origin/testcommit789
+ = [up to date]      testcommit79 -> origin/testcommit79
+ = [up to date]      testcommit790 -> origin/testcommit790
+ = [up to date]      testcommit791 -> origin/testcommit791
+ = [up to date]      testcommit792 -> origin/testcommit792
+ = [up to date]      testcommit793 -> origin/testcommit793
+ = [up to date]      testcommit794 -> origin/testcommit794
+ = [up to date]      testcommit795 -> origin/testcommit795
+ = [up to date]      testcommit796 -> origin/testcommit796
+ = [up to date]      testcommit797 -> origin/testcommit797
+ = [up to date]      testcommit798 -> origin/testcommit798
+ = [up to date]      testcommit799 -> origin/testcommit799
+ = [up to date]      testcommit8 -> origin/testcommit8
+ = [up to date]      testcommit80 -> origin/testcommit80
+ = [up to date]      testcommit800 -> origin/testcommit800
+ = [up to date]      testcommit801 -> origin/testcommit801
+ = [up to date]      testcommit802 -> origin/testcommit802
+ = [up to date]      testcommit803 -> origin/testcommit803
+ = [up to date]      testcommit804 -> origin/testcommit804
+ = [up to date]      testcommit805 -> origin/testcommit805
+ = [up to date]      testcommit806 -> origin/testcommit806
+ = [up to date]      testcommit807 -> origin/testcommit807
+ = [up to date]      testcommit808 -> origin/testcommit808
+ = [up to date]      testcommit809 -> origin/testcommit809
+ = [up to date]      testcommit81 -> origin/testcommit81
+ = [up to date]      testcommit810 -> origin/testcommit810
+ = [up to date]      testcommit811 -> origin/testcommit811
+ = [up to date]      testcommit812 -> origin/testcommit812
+ = [up to date]      testcommit813 -> origin/testcommit813
+ = [up to date]      testcommit814 -> origin/testcommit814
+ = [up to date]      testcommit815 -> origin/testcommit815
+ = [up to date]      testcommit816 -> origin/testcommit816
+ = [up to date]      testcommit817 -> origin/testcommit817
+ = [up to date]      testcommit818 -> origin/testcommit818
+ = [up to date]      testcommit819 -> origin/testcommit819
+ = [up to date]      testcommit82 -> origin/testcommit82
+ = [up to date]      testcommit820 -> origin/testcommit820
+ = [up to date]      testcommit821 -> origin/testcommit821
+ = [up to date]      testcommit822 -> origin/testcommit822
+ = [up to date]      testcommit823 -> origin/testcommit823
+ = [up to date]      testcommit824 -> origin/testcommit824
+ = [up to date]      testcommit825 -> origin/testcommit825
+ = [up to date]      testcommit826 -> origin/testcommit826
+ = [up to date]      testcommit827 -> origin/testcommit827
+ = [up to date]      testcommit828 -> origin/testcommit828
+ = [up to date]      testcommit829 -> origin/testcommit829
+ = [up to date]      testcommit83 -> origin/testcommit83
+ = [up to date]      testcommit830 -> origin/testcommit830
+ = [up to date]      testcommit831 -> origin/testcommit831
+ = [up to date]      testcommit832 -> origin/testcommit832
+ = [up to date]      testcommit833 -> origin/testcommit833
+ = [up to date]      testcommit834 -> origin/testcommit834
+ = [up to date]      testcommit835 -> origin/testcommit835
+ = [up to date]      testcommit836 -> origin/testcommit836
+ = [up to date]      testcommit837 -> origin/testcommit837
+ = [up to date]      testcommit838 -> origin/testcommit838
+ = [up to date]      testcommit839 -> origin/testcommit839
+ = [up to date]      testcommit84 -> origin/testcommit84
+ = [up to date]      testcommit840 -> origin/testcommit840
+ = [up to date]      testcommit841 -> origin/testcommit841
+ = [up to date]      testcommit842 -> origin/testcommit842
+ = [up to date]      testcommit843 -> origin/testcommit843
+ = [up to date]      testcommit844 -> origin/testcommit844
+ = [up to date]      testcommit845 -> origin/testcommit845
+ = [up to date]      testcommit846 -> origin/testcommit846
+ = [up to date]      testcommit847 -> origin/testcommit847
+ = [up to date]      testcommit848 -> origin/testcommit848
+ = [up to date]      testcommit849 -> origin/testcommit849
+ = [up to date]      testcommit85 -> origin/testcommit85
+ = [up to date]      testcommit850 -> origin/testcommit850
+ = [up to date]      testcommit851 -> origin/testcommit851
+ = [up to date]      testcommit852 -> origin/testcommit852
+ = [up to date]      testcommit853 -> origin/testcommit853
+ = [up to date]      testcommit854 -> origin/testcommit854
+ = [up to date]      testcommit855 -> origin/testcommit855
+ = [up to date]      testcommit856 -> origin/testcommit856
+ = [up to date]      testcommit857 -> origin/testcommit857
+ = [up to date]      testcommit858 -> origin/testcommit858
+ = [up to date]      testcommit859 -> origin/testcommit859
+ = [up to date]      testcommit86 -> origin/testcommit86
+ = [up to date]      testcommit860 -> origin/testcommit860
+ = [up to date]      testcommit861 -> origin/testcommit861
+ = [up to date]      testcommit862 -> origin/testcommit862
+ = [up to date]      testcommit863 -> origin/testcommit863
+ = [up to date]      testcommit864 -> origin/testcommit864
+ = [up to date]      testcommit865 -> origin/testcommit865
+ = [up to date]      testcommit866 -> origin/testcommit866
+ = [up to date]      testcommit867 -> origin/testcommit867
+ = [up to date]      testcommit868 -> origin/testcommit868
+ = [up to date]      testcommit869 -> origin/testcommit869
+ = [up to date]      testcommit87 -> origin/testcommit87
+ = [up to date]      testcommit870 -> origin/testcommit870
+ = [up to date]      testcommit871 -> origin/testcommit871
+ = [up to date]      testcommit872 -> origin/testcommit872
+ = [up to date]      testcommit873 -> origin/testcommit873
+ = [up to date]      testcommit874 -> origin/testcommit874
+ = [up to date]      testcommit875 -> origin/testcommit875
+ = [up to date]      testcommit876 -> origin/testcommit876
+ = [up to date]      testcommit877 -> origin/testcommit877
+ = [up to date]      testcommit878 -> origin/testcommit878
+ = [up to date]      testcommit879 -> origin/testcommit879
+ = [up to date]      testcommit88 -> origin/testcommit88
+ = [up to date]      testcommit880 -> origin/testcommit880
+ = [up to date]      testcommit881 -> origin/testcommit881
+ = [up to date]      testcommit882 -> origin/testcommit882
+ = [up to date]      testcommit883 -> origin/testcommit883
+ = [up to date]      testcommit884 -> origin/testcommit884
+ = [up to date]      testcommit885 -> origin/testcommit885
+ = [up to date]      testcommit886 -> origin/testcommit886
+ = [up to date]      testcommit887 -> origin/testcommit887
+ = [up to date]      testcommit888 -> origin/testcommit888
+ = [up to date]      testcommit889 -> origin/testcommit889
+ = [up to date]      testcommit89 -> origin/testcommit89
+ = [up to date]      testcommit890 -> origin/testcommit890
+ = [up to date]      testcommit891 -> origin/testcommit891
+ = [up to date]      testcommit892 -> origin/testcommit892
+ = [up to date]      testcommit893 -> origin/testcommit893
+ = [up to date]      testcommit894 -> origin/testcommit894
+ = [up to date]      testcommit895 -> origin/testcommit895
+ = [up to date]      testcommit896 -> origin/testcommit896
+ = [up to date]      testcommit897 -> origin/testcommit897
+ = [up to date]      testcommit898 -> origin/testcommit898
+ = [up to date]      testcommit899 -> origin/testcommit899
+ = [up to date]      testcommit9 -> origin/testcommit9
+ = [up to date]      testcommit90 -> origin/testcommit90
+ = [up to date]      testcommit900 -> origin/testcommit900
+ = [up to date]      testcommit901 -> origin/testcommit901
+ = [up to date]      testcommit902 -> origin/testcommit902
+ = [up to date]      testcommit903 -> origin/testcommit903
+ = [up to date]      testcommit904 -> origin/testcommit904
+ = [up to date]      testcommit905 -> origin/testcommit905
+ = [up to date]      testcommit906 -> origin/testcommit906
+ = [up to date]      testcommit907 -> origin/testcommit907
+ = [up to date]      testcommit908 -> origin/testcommit908
+ = [up to date]      testcommit909 -> origin/testcommit909
+ = [up to date]      testcommit91 -> origin/testcommit91
+ = [up to date]      testcommit910 -> origin/testcommit910
+ = [up to date]      testcommit911 -> origin/testcommit911
+ = [up to date]      testcommit912 -> origin/testcommit912
+ = [up to date]      testcommit913 -> origin/testcommit913
+ = [up to date]      testcommit914 -> origin/testcommit914
+ = [up to date]      testcommit915 -> origin/testcommit915
+ = [up to date]      testcommit916 -> origin/testcommit916
+ = [up to date]      testcommit917 -> origin/testcommit917
+ = [up to date]      testcommit918 -> origin/testcommit918
+ = [up to date]      testcommit919 -> origin/testcommit919
+ = [up to date]      testcommit92 -> origin/testcommit92
+ = [up to date]      testcommit920 -> origin/testcommit920
+ = [up to date]      testcommit921 -> origin/testcommit921
+ = [up to date]      testcommit922 -> origin/testcommit922
+ = [up to date]      testcommit923 -> origin/testcommit923
+ = [up to date]      testcommit924 -> origin/testcommit924
+ = [up to date]      testcommit925 -> origin/testcommit925
+ = [up to date]      testcommit926 -> origin/testcommit926
+ = [up to date]      testcommit927 -> origin/testcommit927
+ = [up to date]      testcommit928 -> origin/testcommit928
+ = [up to date]      testcommit929 -> origin/testcommit929
+ = [up to date]      testcommit93 -> origin/testcommit93
+ = [up to date]      testcommit930 -> origin/testcommit930
+ = [up to date]      testcommit931 -> origin/testcommit931
+ = [up to date]      testcommit932 -> origin/testcommit932
+ = [up to date]      testcommit933 -> origin/testcommit933
+ = [up to date]      testcommit934 -> origin/testcommit934
+ = [up to date]      testcommit935 -> origin/testcommit935
+ = [up to date]      testcommit936 -> origin/testcommit936
+ = [up to date]      testcommit937 -> origin/testcommit937
+ = [up to date]      testcommit938 -> origin/testcommit938
+ = [up to date]      testcommit939 -> origin/testcommit939
+ = [up to date]      testcommit94 -> origin/testcommit94
+ = [up to date]      testcommit940 -> origin/testcommit940
+ = [up to date]      testcommit941 -> origin/testcommit941
+ = [up to date]      testcommit942 -> origin/testcommit942
+ = [up to date]      testcommit943 -> origin/testcommit943
+ = [up to date]      testcommit944 -> origin/testcommit944
+ = [up to date]      testcommit945 -> origin/testcommit945
+ = [up to date]      testcommit946 -> origin/testcommit946
+ = [up to date]      testcommit947 -> origin/testcommit947
+ = [up to date]      testcommit948 -> origin/testcommit948
+ = [up to date]      testcommit949 -> origin/testcommit949
+ = [up to date]      testcommit95 -> origin/testcommit95
+ = [up to date]      testcommit950 -> origin/testcommit950
+ = [up to date]      testcommit951 -> origin/testcommit951
+ = [up to date]      testcommit952 -> origin/testcommit952
+ = [up to date]      testcommit953 -> origin/testcommit953
+ = [up to date]      testcommit954 -> origin/testcommit954
+ = [up to date]      testcommit955 -> origin/testcommit955
+ = [up to date]      testcommit956 -> origin/testcommit956
+ = [up to date]      testcommit957 -> origin/testcommit957
+ = [up to date]      testcommit958 -> origin/testcommit958
+ = [up to date]      testcommit959 -> origin/testcommit959
+ = [up to date]      testcommit96 -> origin/testcommit96
+ = [up to date]      testcommit960 -> origin/testcommit960
+ = [up to date]      testcommit961 -> origin/testcommit961
+ = [up to date]      testcommit962 -> origin/testcommit962
+ = [up to date]      testcommit963 -> origin/testcommit963
+ = [up to date]      testcommit964 -> origin/testcommit964
+ = [up to date]      testcommit965 -> origin/testcommit965
+ = [up to date]      testcommit966 -> origin/testcommit966
+ = [up to date]      testcommit967 -> origin/testcommit967
+ = [up to date]      testcommit968 -> origin/testcommit968
+ = [up to date]      testcommit969 -> origin/testcommit969
+ = [up to date]      testcommit97 -> origin/testcommit97
+ = [up to date]      testcommit970 -> origin/testcommit970
+ = [up to date]      testcommit971 -> origin/testcommit971
+ = [up to date]      testcommit972 -> origin/testcommit972
+ = [up to date]      testcommit973 -> origin/testcommit973
+ = [up to date]      testcommit974 -> origin/testcommit974
+ = [up to date]      testcommit975 -> origin/testcommit975
+ = [up to date]      testcommit976 -> origin/testcommit976
+ = [up to date]      testcommit977 -> origin/testcommit977
+ = [up to date]      testcommit978 -> origin/testcommit978
+ = [up to date]      testcommit979 -> origin/testcommit979
+ = [up to date]      testcommit98 -> origin/testcommit98
+ = [up to date]      testcommit980 -> origin/testcommit980
+ = [up to date]      testcommit981 -> origin/testcommit981
+ = [up to date]      testcommit982 -> origin/testcommit982
+ = [up to date]      testcommit983 -> origin/testcommit983
+ = [up to date]      testcommit984 -> origin/testcommit984
+ = [up to date]      testcommit985 -> origin/testcommit985
+ = [up to date]      testcommit986 -> origin/testcommit986
+ = [up to date]      testcommit987 -> origin/testcommit987
+ = [up to date]      testcommit988 -> origin/testcommit988
+ = [up to date]      testcommit989 -> origin/testcommit989
+ = [up to date]      testcommit99 -> origin/testcommit99
+ = [up to date]      testcommit990 -> origin/testcommit990
+ = [up to date]      testcommit991 -> origin/testcommit991
+ = [up to date]      testcommit992 -> origin/testcommit992
+ = [up to date]      testcommit993 -> origin/testcommit993
+ = [up to date]      testcommit994 -> origin/testcommit994
+ = [up to date]      testcommit995 -> origin/testcommit995
+ = [up to date]      testcommit996 -> origin/testcommit996
+ = [up to date]      testcommit997 -> origin/testcommit997
+ = [up to date]      testcommit998 -> origin/testcommit998
+ = [up to date]      testcommit999 -> origin/testcommit999
diff --git a/git/test/fixtures/ls_tree_a b/test/fixtures/ls_tree_a
similarity index 100%
rename from git/test/fixtures/ls_tree_a
rename to test/fixtures/ls_tree_a
diff --git a/git/test/fixtures/ls_tree_b b/test/fixtures/ls_tree_b
similarity index 100%
rename from git/test/fixtures/ls_tree_b
rename to test/fixtures/ls_tree_b
diff --git a/git/test/fixtures/ls_tree_commit b/test/fixtures/ls_tree_commit
similarity index 100%
rename from git/test/fixtures/ls_tree_commit
rename to test/fixtures/ls_tree_commit
diff --git a/test/fixtures/ls_tree_empty b/test/fixtures/ls_tree_empty
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/fixtures/polyglot b/test/fixtures/polyglot
new file mode 100755
index 000000000..f1dd56b26
--- /dev/null
+++ b/test/fixtures/polyglot
@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+# Valid script in both Bash and Python, but with different behavior.
+""":"
+echo 'Ran intended hook.' >output.txt
+exit
+" """
+from pathlib import Path
+Path('payload.txt').write_text('Ran impostor hook!', encoding='utf-8')
diff --git a/git/test/fixtures/reflog_HEAD b/test/fixtures/reflog_HEAD
similarity index 100%
rename from git/test/fixtures/reflog_HEAD
rename to test/fixtures/reflog_HEAD
diff --git a/git/test/fixtures/reflog_invalid_date b/test/fixtures/reflog_invalid_date
similarity index 100%
rename from git/test/fixtures/reflog_invalid_date
rename to test/fixtures/reflog_invalid_date
diff --git a/git/test/fixtures/reflog_invalid_email b/test/fixtures/reflog_invalid_email
similarity index 100%
rename from git/test/fixtures/reflog_invalid_email
rename to test/fixtures/reflog_invalid_email
diff --git a/git/test/fixtures/reflog_invalid_newsha b/test/fixtures/reflog_invalid_newsha
similarity index 100%
rename from git/test/fixtures/reflog_invalid_newsha
rename to test/fixtures/reflog_invalid_newsha
diff --git a/git/test/fixtures/reflog_invalid_oldsha b/test/fixtures/reflog_invalid_oldsha
similarity index 100%
rename from git/test/fixtures/reflog_invalid_oldsha
rename to test/fixtures/reflog_invalid_oldsha
diff --git a/git/test/fixtures/reflog_invalid_sep b/test/fixtures/reflog_invalid_sep
similarity index 100%
rename from git/test/fixtures/reflog_invalid_sep
rename to test/fixtures/reflog_invalid_sep
diff --git a/git/test/fixtures/reflog_master b/test/fixtures/reflog_master
similarity index 100%
rename from git/test/fixtures/reflog_master
rename to test/fixtures/reflog_master
diff --git a/git/test/fixtures/rev_list b/test/fixtures/rev_list
similarity index 100%
rename from git/test/fixtures/rev_list
rename to test/fixtures/rev_list
diff --git a/git/test/fixtures/rev_list_bisect_all b/test/fixtures/rev_list_bisect_all
similarity index 99%
rename from git/test/fixtures/rev_list_bisect_all
rename to test/fixtures/rev_list_bisect_all
index 810b66093..342ea94ae 100644
--- a/git/test/fixtures/rev_list_bisect_all
+++ b/test/fixtures/rev_list_bisect_all
@@ -40,7 +40,7 @@ committer David Aguilar <davvid@gmail.com> 1220418344 -0700
     commit: handle --bisect-all output in Commit.list_from_string
     
     Rui Abreu Ferrerira pointed out that "git rev-list --bisect-all"
-    returns a slightly different format which we can easily accomodate
+    returns a slightly different format which we can easily accommodate
     by changing the way we parse rev-list output.
     
     http://groups.google.com/group/git-python/browse_thread/thread/aed1d5c4b31d5027
diff --git a/git/test/fixtures/rev_list_commit_diffs b/test/fixtures/rev_list_commit_diffs
similarity index 100%
rename from git/test/fixtures/rev_list_commit_diffs
rename to test/fixtures/rev_list_commit_diffs
diff --git a/git/test/fixtures/rev_list_commit_idabbrev b/test/fixtures/rev_list_commit_idabbrev
similarity index 100%
rename from git/test/fixtures/rev_list_commit_idabbrev
rename to test/fixtures/rev_list_commit_idabbrev
diff --git a/git/test/fixtures/rev_list_commit_stats b/test/fixtures/rev_list_commit_stats
similarity index 100%
rename from git/test/fixtures/rev_list_commit_stats
rename to test/fixtures/rev_list_commit_stats
diff --git a/git/test/fixtures/rev_list_count b/test/fixtures/rev_list_count
similarity index 100%
rename from git/test/fixtures/rev_list_count
rename to test/fixtures/rev_list_count
diff --git a/git/test/fixtures/rev_list_delta_a b/test/fixtures/rev_list_delta_a
similarity index 100%
rename from git/test/fixtures/rev_list_delta_a
rename to test/fixtures/rev_list_delta_a
diff --git a/git/test/fixtures/rev_list_delta_b b/test/fixtures/rev_list_delta_b
similarity index 100%
rename from git/test/fixtures/rev_list_delta_b
rename to test/fixtures/rev_list_delta_b
diff --git a/git/test/fixtures/rev_list_single b/test/fixtures/rev_list_single
similarity index 100%
rename from git/test/fixtures/rev_list_single
rename to test/fixtures/rev_list_single
diff --git a/git/test/fixtures/rev_parse b/test/fixtures/rev_parse
similarity index 100%
rename from git/test/fixtures/rev_parse
rename to test/fixtures/rev_parse
diff --git a/git/test/fixtures/show_empty_commit b/test/fixtures/show_empty_commit
similarity index 100%
rename from git/test/fixtures/show_empty_commit
rename to test/fixtures/show_empty_commit
diff --git a/test/fixtures/uncommon_branch_prefix_FETCH_HEAD b/test/fixtures/uncommon_branch_prefix_FETCH_HEAD
new file mode 100644
index 000000000..7df36f246
--- /dev/null
+++ b/test/fixtures/uncommon_branch_prefix_FETCH_HEAD
@@ -0,0 +1,6 @@
+c2e3c20affa3e2b61a05fdc9ee3061dd416d915e		'refs/pull/1/head' of http://github.com/loic-bot/testrepo
+fd8695d980e2c6df62b7785f93fd6292d1e283fb		'refs/pull/1/merge' of http://github.com/loic-bot/testrepo
+bb46faf089720d1a3f9e4dc3b11ed5ff77d7e764		'refs/pull/2/head' of http://github.com/loic-bot/testrepo
+5faa366d58454eceea811e0e34c502bdd7b37e4b		'refs/pull/2/merge' of http://github.com/loic-bot/testrepo
+b3ad3c4f1864b50d4d3e09320947a1a3c34c9ea2		'refs/pull/3/head' of http://github.com/loic-bot/testrepo
+71fe57e511776042b009ed4bb281b62b0522b434		'refs/pull/3/merge' of http://github.com/loic-bot/testrepo
diff --git a/test/fixtures/uncommon_branch_prefix_stderr b/test/fixtures/uncommon_branch_prefix_stderr
new file mode 100644
index 000000000..5a6aca653
--- /dev/null
+++ b/test/fixtures/uncommon_branch_prefix_stderr
@@ -0,0 +1,6 @@
+ = [up to date]      refs/pull/1/head -> pull/1/head
+ = [up to date]      refs/pull/1/merge -> pull/1/merge
+ = [up to date]      refs/pull/2/head -> pull/2/head
+ = [up to date]      refs/pull/2/merge -> pull/2/merge
+ = [up to date]      refs/pull/3/head -> pull/3/head
+ = [up to date]      refs/pull/3/merge -> pull/3/merge
diff --git a/test/lib/__init__.py b/test/lib/__init__.py
new file mode 100644
index 000000000..f96072cb5
--- /dev/null
+++ b/test/lib/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import inspect
+
+from .helper import *  # noqa: F401 F403
+
+__all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))]
diff --git a/test/lib/helper.py b/test/lib/helper.py
new file mode 100644
index 000000000..241d27341
--- /dev/null
+++ b/test/lib/helper.py
@@ -0,0 +1,456 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+__all__ = [
+    "fixture_path",
+    "fixture",
+    "StringProcessAdapter",
+    "with_rw_directory",
+    "with_rw_repo",
+    "with_rw_and_rw_remote_repo",
+    "TestBase",
+    "VirtualEnvironment",
+    "TestCase",
+    "SkipTest",
+    "skipIf",
+    "GIT_REPO",
+    "GIT_DAEMON_PORT",
+]
+
+import contextlib
+from functools import wraps
+import gc
+import io
+import logging
+import os
+import os.path as osp
+import subprocess
+import sys
+import tempfile
+import textwrap
+import time
+import unittest
+import venv
+
+import gitdb
+
+from git.util import rmtree, cwd
+
+TestCase = unittest.TestCase
+SkipTest = unittest.SkipTest
+skipIf = unittest.skipIf
+
+ospd = osp.dirname
+
+GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", ospd(ospd(ospd(__file__))))
+GIT_DAEMON_PORT = os.environ.get("GIT_PYTHON_TEST_GIT_DAEMON_PORT", "19418")
+
+_logger = logging.getLogger(__name__)
+
+# { Routines
+
+
+def fixture_path(name):
+    return osp.join(ospd(ospd(__file__)), "fixtures", name)
+
+
+def fixture(name):
+    with open(fixture_path(name), "rb") as fd:
+        return fd.read()
+
+
+# } END routines
+
+# { Adapters
+
+
+class StringProcessAdapter:
+    """Allows strings to be used as process objects returned by subprocess.Popen.
+
+    This is tailored to work with the test system only.
+    """
+
+    def __init__(self, input_string):
+        self.stdout = io.BytesIO(input_string)
+        self.stderr = io.BytesIO()
+
+    def wait(self):
+        return 0
+
+    poll = wait
+
+
+# } END adapters
+
+# { Decorators
+
+
+def with_rw_directory(func):
+    """Create a temporary directory which can be written to, remove it if the
+    test succeeds, but leave it otherwise to aid additional debugging."""
+
+    @wraps(func)
+    def wrapper(self, *args, **kwargs):
+        path = tempfile.mkdtemp(prefix=func.__name__)
+        keep = False
+        try:
+            return func(self, path, *args, **kwargs)
+        except Exception:
+            _logger.info(
+                "%s %s.%s failed, output is at %r\n",
+                "Test" if func.__name__.startswith("test_") else "Helper",
+                type(self).__name__,
+                func.__name__,
+                path,
+            )
+            keep = True
+            raise
+        finally:
+            # Need to collect here to be sure all handles have been closed. It appears
+            # a Windows-only issue. In fact things should be deleted, as well as
+            # memory maps closed, once objects go out of scope. For some reason
+            # though this is not the case here unless we collect explicitly.
+            gc.collect()
+            if not keep:
+                rmtree(path)
+
+    return wrapper
+
+
+def with_rw_repo(working_tree_ref, bare=False):
+    """Same as with_bare_repo, but clones the rorepo as non-bare repository, checking
+    out the working tree at the given working_tree_ref.
+
+    This repository type is more costly due to the working copy checkout.
+
+    To make working with relative paths easier, the cwd will be set to the working
+    dir of the repository.
+    """
+    assert isinstance(working_tree_ref, str), "Decorator requires ref name for working tree checkout"
+
+    def argument_passer(func):
+        @wraps(func)
+        def repo_creator(self):
+            prefix = "non_"
+            if bare:
+                prefix = ""
+            # END handle prefix
+            repo_dir = tempfile.mktemp(prefix="%sbare_%s" % (prefix, func.__name__))
+            rw_repo = self.rorepo.clone(repo_dir, shared=True, bare=bare, n=True)
+
+            rw_repo.head.commit = rw_repo.commit(working_tree_ref)
+            if not bare:
+                rw_repo.head.reference.checkout()
+            # END handle checkout
+
+            prev_cwd = os.getcwd()
+            os.chdir(rw_repo.working_dir)
+            try:
+                return func(self, rw_repo)
+            except:  # noqa: E722 B001
+                _logger.info("Keeping repo after failure: %s", repo_dir)
+                repo_dir = None
+                raise
+            finally:
+                os.chdir(prev_cwd)
+                rw_repo.git.clear_cache()
+                rw_repo = None
+                if repo_dir is not None:
+                    gc.collect()
+                    gitdb.util.mman.collect()
+                    gc.collect()
+                    rmtree(repo_dir)
+                # END rm test repo if possible
+            # END cleanup
+
+        # END rw repo creator
+        return repo_creator
+
+    # END argument passer
+    return argument_passer
+
+
+@contextlib.contextmanager
+def git_daemon_launched(base_path, ip, port):
+    from git import Git  # Avoid circular deps.
+
+    gd = None
+    try:
+        if sys.platform == "win32":
+            # On MINGW-git, daemon exists in Git\mingw64\libexec\git-core\,
+            # but if invoked as 'git daemon', it detaches from parent `git` cmd,
+            # and then CANNOT DIE!
+            # So, invoke it as a single command.
+            daemon_cmd = [
+                osp.join(Git()._call_process("--exec-path"), "git-daemon"),
+                "--enable=receive-pack",
+                "--listen=%s" % ip,
+                "--port=%s" % port,
+                "--base-path=%s" % base_path,
+                base_path,
+            ]
+            gd = Git().execute(daemon_cmd, as_process=True)
+        else:
+            gd = Git().daemon(
+                base_path,
+                enable="receive-pack",
+                listen=ip,
+                port=port,
+                base_path=base_path,
+                as_process=True,
+            )
+        # Yes, I know... fortunately, this is always going to work if sleep time is just large enough.
+        time.sleep(1.0 if sys.platform == "win32" else 0.5)
+    except Exception as ex:
+        msg = textwrap.dedent(
+            """
+        Launching git-daemon failed due to: %s
+          Probably test will fail subsequently.
+
+          BUT you may start *git-daemon* manually with this command:"
+                git daemon --enable=receive-pack  --listen=%s --port=%s --base-path=%s  %s
+          You may also run the daemon on a different port by passing --port=<port>"
+          and setting the environment variable GIT_PYTHON_TEST_GIT_DAEMON_PORT to <port>
+        """
+        )
+        _logger.warning(msg, ex, ip, port, base_path, base_path, exc_info=1)
+
+        yield  # OK, assume daemon started manually.
+
+    else:
+        yield  # Yield outside try, to avoid catching
+    finally:
+        if gd:
+            try:
+                _logger.debug("Killing git-daemon...")
+                gd.proc.kill()
+            except Exception as ex:
+                # Either it has died (and we're here), or it won't die, again here...
+                _logger.debug("Hidden error while Killing git-daemon: %s", ex, exc_info=1)
+
+
+def with_rw_and_rw_remote_repo(working_tree_ref):
+    """Same as with_rw_repo, but also provides a writable remote repository from which
+    the rw_repo has been forked as well as a handle for a git-daemon that may be started
+    to run the remote_repo.
+
+    The remote repository was cloned as bare repository from the ro repo, whereas the rw
+    repo has a working tree and was cloned from the remote repository.
+
+    remote_repo has two remotes: origin and daemon_origin. One uses a local url, the
+    other uses a server url. The daemon setup must be done on system level and should be
+    an inetd service that serves tempdir.gettempdir() and all directories in it.
+
+    The following sketch demonstrates this::
+
+        rorepo ---<bare clone>---> rw_remote_repo ---<clone>---> rw_repo
+
+    The test case needs to support the following signature::
+
+        def case(self, rw_repo, rw_daemon_repo)
+
+    This setup allows you to test push and pull scenarios and hooks nicely.
+
+    See working dir info in :func:`with_rw_repo`.
+
+    :note: We attempt to launch our own invocation of git-daemon, which will be shut
+        down at the end of the test.
+    """
+    from git import Git, Remote  # To avoid circular deps.
+
+    assert isinstance(working_tree_ref, str), "Decorator requires ref name for working tree checkout"
+
+    def argument_passer(func):
+        @wraps(func)
+        def remote_repo_creator(self):
+            rw_daemon_repo_dir = tempfile.mktemp(prefix="daemon_repo-%s-" % func.__name__)
+            rw_repo_dir = tempfile.mktemp(prefix="daemon_cloned_repo-%s-" % func.__name__)
+
+            rw_daemon_repo = self.rorepo.clone(rw_daemon_repo_dir, shared=True, bare=True)
+            # Recursive alternates info?
+            rw_repo = rw_daemon_repo.clone(rw_repo_dir, shared=True, bare=False, n=True)
+            try:
+                rw_repo.head.commit = working_tree_ref
+                rw_repo.head.reference.checkout()
+
+                # Prepare for git-daemon.
+                rw_daemon_repo.daemon_export = True
+
+                # This thing is just annoying!
+                with rw_daemon_repo.config_writer() as crw:
+                    section = "daemon"
+                    try:
+                        crw.add_section(section)
+                    except Exception:
+                        pass
+                    crw.set(section, "receivepack", True)
+
+                # Initialize the remote - first do it as local remote and pull, then
+                # we change the url to point to the daemon.
+                d_remote = Remote.create(rw_repo, "daemon_origin", rw_daemon_repo_dir)
+                d_remote.fetch()
+
+                base_daemon_path, rel_repo_dir = osp.split(rw_daemon_repo_dir)
+
+                remote_repo_url = Git.polish_url("git://localhost:%s/%s" % (GIT_DAEMON_PORT, rel_repo_dir))
+                with d_remote.config_writer as cw:
+                    cw.set("url", remote_repo_url)
+
+                with git_daemon_launched(
+                    Git.polish_url(base_daemon_path),
+                    "127.0.0.1",
+                    GIT_DAEMON_PORT,
+                ):
+                    # Try listing remotes, to diagnose whether the daemon is up.
+                    rw_repo.git.ls_remote(d_remote)
+
+                    with cwd(rw_repo.working_dir):
+                        try:
+                            return func(self, rw_repo, rw_daemon_repo)
+                        except:  # noqa: E722 B001
+                            _logger.info(
+                                "Keeping repos after failure: \n  rw_repo_dir: %s \n  rw_daemon_repo_dir: %s",
+                                rw_repo_dir,
+                                rw_daemon_repo_dir,
+                            )
+                            rw_repo_dir = rw_daemon_repo_dir = None
+                            raise
+
+            finally:
+                rw_repo.git.clear_cache()
+                rw_daemon_repo.git.clear_cache()
+                del rw_repo
+                del rw_daemon_repo
+                gc.collect()
+                gitdb.util.mman.collect()
+                gc.collect()
+                if rw_repo_dir:
+                    rmtree(rw_repo_dir)
+                if rw_daemon_repo_dir:
+                    rmtree(rw_daemon_repo_dir)
+            # END cleanup
+
+        # END bare repo creator
+        return remote_repo_creator
+        # END remote repo creator
+
+    # END argument parser
+
+    return argument_passer
+
+
+# } END decorators
+
+
+class TestBase(TestCase):
+    """Base class providing default functionality to all tests such as:
+
+    - Utility functions provided by the TestCase base of the unittest method such as::
+
+        self.fail("todo")
+        self.assertRaises(...)
+
+    - Class level repository which is considered read-only as it is shared among
+      all test cases in your type.
+
+      Access it using::
+
+        self.rorepo  # 'ro' stands for read-only
+
+      The rorepo is in fact your current project's git repo. If you refer to specific
+      shas for your objects, be sure you choose some that are part of the immutable
+      portion of the project history (so that tests don't fail for others).
+    """
+
+    def _small_repo_url(self):
+        """:return: A path to a small, clonable repository"""
+        from git.cmd import Git
+
+        return Git.polish_url(osp.join(self.rorepo.working_tree_dir, "git/ext/gitdb/gitdb/ext/smmap"))
+
+    @classmethod
+    def setUpClass(cls):
+        """Dynamically add a read-only repository to our actual type.
+
+        This way, each test type has its own repository.
+        """
+        from git import Repo
+
+        gc.collect()
+        cls.rorepo = Repo(GIT_REPO)
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.rorepo.git.clear_cache()
+        cls.rorepo.git = None
+
+    def _make_file(self, rela_path, data, repo=None):
+        """
+        Create a file at the given path relative to our repository, filled with the
+        given data.
+
+        :return: An absolute path to the created file.
+        """
+        repo = repo or self.rorepo
+        abs_path = osp.join(repo.working_tree_dir, rela_path)
+        with open(abs_path, "w") as fp:
+            fp.write(data)
+        return abs_path
+
+
+class VirtualEnvironment:
+    """A newly created Python virtual environment for use in a test."""
+
+    __slots__ = ("_env_dir",)
+
+    def __init__(self, env_dir, *, with_pip):
+        if sys.platform == "win32":
+            self._env_dir = osp.realpath(env_dir)
+            venv.create(self.env_dir, symlinks=False, with_pip=with_pip)
+        else:
+            self._env_dir = env_dir
+            venv.create(self.env_dir, symlinks=True, with_pip=with_pip)
+
+        if with_pip:
+            # The upgrade_deps parameter to venv.create is 3.9+ only, so do it this way.
+            command = [
+                self.python,
+                "-m",
+                "pip",
+                "install",
+                "--upgrade",
+                "pip",
+                'setuptools; python_version<"3.12"',
+            ]
+            subprocess.check_output(command)
+
+    @property
+    def env_dir(self):
+        """The top-level directory of the environment."""
+        return self._env_dir
+
+    @property
+    def python(self):
+        """Path to the Python executable in the environment."""
+        return self._executable("python")
+
+    @property
+    def pip(self):
+        """Path to the pip executable in the environment, or RuntimeError if absent."""
+        return self._executable("pip")
+
+    @property
+    def sources(self):
+        """Path to a src directory in the environment, which may not exist yet."""
+        return os.path.join(self.env_dir, "src")
+
+    def _executable(self, basename):
+        if sys.platform == "win32":
+            path = osp.join(self.env_dir, "Scripts", basename + ".exe")
+        else:
+            path = osp.join(self.env_dir, "bin", basename)
+        if osp.isfile(path) or osp.islink(path):
+            return path
+        raise RuntimeError(f"no regular file or symlink {path!r}")
diff --git a/test/performance/__init__.py b/test/performance/__init__.py
new file mode 100644
index 000000000..56b5d89db
--- /dev/null
+++ b/test/performance/__init__.py
@@ -0,0 +1,2 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
diff --git a/test/performance/lib.py b/test/performance/lib.py
new file mode 100644
index 000000000..c24599986
--- /dev/null
+++ b/test/performance/lib.py
@@ -0,0 +1,83 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Support library for performance tests."""
+
+import logging
+import os
+import os.path as osp
+import tempfile
+
+from git import Repo
+from git.db import GitCmdObjectDB, GitDB
+from git.util import rmtree
+
+from test.lib import TestBase
+
+# { Invariants
+
+k_env_git_repo = "GIT_PYTHON_TEST_GIT_REPO_BASE"
+
+# } END invariants
+
+
+# { Base Classes
+
+
+class TestBigRepoR(TestBase):
+    """TestCase providing access to readonly 'big' repositories using the following
+    member variables:
+
+    * gitrorepo:
+      Read-Only git repository - actually (by default) the repo of GitPython itself.
+
+    * puregitrorepo:
+      Like gitrorepo, but uses a pure Python implementation for its object database.
+    """
+
+    def setUp(self):
+        super().setUp()
+
+        repo_path = os.environ.get(k_env_git_repo)
+        if repo_path is None:
+            logging.info(
+                "You can set the %s environment variable to a .git repository of your"
+                " choice - defaulting to the GitPython repository",
+                k_env_git_repo,
+            )
+            repo_path = osp.dirname(__file__)
+        # END set some repo path
+        self.gitrorepo = Repo(repo_path, odbt=GitCmdObjectDB, search_parent_directories=True)
+        self.puregitrorepo = Repo(repo_path, odbt=GitDB, search_parent_directories=True)
+
+    def tearDown(self):
+        self.gitrorepo.git.clear_cache()
+        self.gitrorepo = None
+        self.puregitrorepo.git.clear_cache()
+        self.puregitrorepo = None
+
+
+class TestBigRepoRW(TestBigRepoR):
+    """Like :class:`TestBigRepoR`, but provides a big repository that we can write to.
+
+    Provides ``self.gitrwrepo`` and ``self.puregitrwrepo``.
+    """
+
+    def setUp(self):
+        self.gitrwrepo = None
+        super().setUp()
+        dirname = tempfile.mkdtemp()
+        self.gitrwrepo = self.gitrorepo.clone(dirname, shared=True, bare=True, odbt=GitCmdObjectDB)
+        self.puregitrwrepo = Repo(dirname, odbt=GitDB)
+
+    def tearDown(self):
+        super().tearDown()
+        if self.gitrwrepo is not None:
+            rmtree(self.gitrwrepo.working_dir)
+            self.gitrwrepo.git.clear_cache()
+        self.gitrwrepo = None
+        self.puregitrwrepo.git.clear_cache()
+        self.puregitrwrepo = None
+
+
+# } END base classes
diff --git a/test/performance/test_commit.py b/test/performance/test_commit.py
new file mode 100644
index 000000000..b943f1975
--- /dev/null
+++ b/test/performance/test_commit.py
@@ -0,0 +1,129 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Performance tests for commits (iteration, traversal, and serialization)."""
+
+import gc
+from io import BytesIO
+from time import time
+import sys
+
+from gitdb import IStream
+
+from git import Commit
+
+from test.performance.lib import TestBigRepoRW
+from test.test_commit import TestCommitSerialization
+
+
+class TestPerformance(TestBigRepoRW, TestCommitSerialization):
+    def tearDown(self):
+        gc.collect()
+
+    # ref with about 100 commits in its history.
+    ref_100 = "0.1.6"
+
+    def _query_commit_info(self, c):
+        c.author
+        c.authored_date
+        c.author_tz_offset
+        c.committer
+        c.committed_date
+        c.committer_tz_offset
+        c.message
+        c.parents
+
+    def test_iteration(self):
+        no = 0
+        nc = 0
+
+        # Find the first commit containing the given path. Always do a full iteration
+        # (restricted to the path in question). This should return quite a lot of
+        # commits. We just take one and hence abort the operation.
+
+        st = time()
+        for c in self.rorepo.iter_commits(self.ref_100):
+            nc += 1
+            self._query_commit_info(c)
+            for obj in c.tree.traverse():
+                obj.size
+                no += 1
+            # END for each object
+        # END for each commit
+        elapsed_time = time() - st
+        print(
+            "Traversed %i Trees and a total of %i uncached objects in %s [s] ( %f objs/s )"
+            % (nc, no, elapsed_time, no / elapsed_time),
+            file=sys.stderr,
+        )
+
+    def test_commit_traversal(self):
+        # Bound to cat-file parsing performance.
+        nc = 0
+        st = time()
+        for c in self.gitrorepo.commit().traverse(branch_first=False):
+            nc += 1
+            self._query_commit_info(c)
+        # END for each traversed commit
+        elapsed_time = time() - st
+        print(
+            "Traversed %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time),
+            file=sys.stderr,
+        )
+
+    def test_commit_iteration(self):
+        # Bound to stream parsing performance.
+        nc = 0
+        st = time()
+        for c in Commit.iter_items(self.gitrorepo, self.gitrorepo.head):
+            nc += 1
+            self._query_commit_info(c)
+        # END for each traversed commit
+        elapsed_time = time() - st
+        print(
+            "Iterated %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time),
+            file=sys.stderr,
+        )
+
+    def test_commit_serialization(self):
+        self.assert_commit_serialization(self.gitrwrepo, "58c78e6", True)
+
+        rwrepo = self.gitrwrepo
+        make_object = rwrepo.odb.store
+        # Direct serialization - deserialization can be tested afterwards.
+        # Serialization is probably limited on IO.
+        hc = rwrepo.commit(rwrepo.head)
+
+        nc = 5000
+        st = time()
+        for i in range(nc):
+            cm = Commit(
+                rwrepo,
+                Commit.NULL_BIN_SHA,
+                hc.tree,
+                hc.author,
+                hc.authored_date,
+                hc.author_tz_offset,
+                hc.committer,
+                hc.committed_date,
+                hc.committer_tz_offset,
+                str(i),
+                parents=hc.parents,
+                encoding=hc.encoding,
+            )
+
+            stream = BytesIO()
+            cm._serialize(stream)
+            slen = stream.tell()
+            stream.seek(0)
+
+            cm.binsha = make_object(IStream(Commit.type, slen, stream)).binsha
+        # END commit creation
+        elapsed = time() - st
+
+        print(
+            "Serialized %i commits to loose objects in %f s ( %f commits / s )" % (nc, elapsed, nc / elapsed),
+            file=sys.stderr,
+        )
diff --git a/git/test/performance/test_odb.py b/test/performance/test_odb.py
similarity index 56%
rename from git/test/performance/test_odb.py
rename to test/performance/test_odb.py
index b14e6db08..fdbbeb8c3 100644
--- a/git/test/performance/test_odb.py
+++ b/test/performance/test_odb.py
@@ -1,15 +1,15 @@
-"""Performance tests for object store"""
-from __future__ import print_function
-from time import time
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Performance tests for object store."""
+
 import sys
+from time import time
 
-from .lib import (
-    TestBigRepoR
-)
+from test.performance.lib import TestBigRepoR
 
 
 class TestObjDBPerformance(TestBigRepoR):
-
     def test_random_access(self):
         results = [["Iterate Commits"], ["Iterate Blobs"], ["Retrieve Blob Data"]]
         for repo in (self.gitrorepo, self.puregitrorepo):
@@ -20,30 +20,36 @@ def test_random_access(self):
             nc = len(commits)
             elapsed = time() - st
 
-            print("%s: Retrieved %i commits from ObjectStore in %g s ( %f commits / s )"
-                  % (type(repo.odb), nc, elapsed, nc / elapsed), file=sys.stderr)
+            print(
+                "%s: Retrieved %i commits from ObjectStore in %g s ( %f commits / s )"
+                % (type(repo.odb), nc, elapsed, nc / elapsed),
+                file=sys.stderr,
+            )
             results[0].append(elapsed)
 
             # GET TREES
-            # walk all trees of all commits
+            # Walk all trees of all commits.
             st = time()
-            blobs_per_commit = list()
+            blobs_per_commit = []
             nt = 0
             for commit in commits:
                 tree = commit.tree
-                blobs = list()
+                blobs = []
                 for item in tree.traverse():
                     nt += 1
-                    if item.type == 'blob':
+                    if item.type == "blob":
                         blobs.append(item)
-                    # direct access for speed
+                    # Direct access for speed.
                 # END while trees are there for walking
                 blobs_per_commit.append(blobs)
             # END for each commit
             elapsed = time() - st
 
-            print("%s: Retrieved %i objects from %i commits in %g s ( %f objects / s )"
-                  % (type(repo.odb), nt, len(commits), elapsed, nt / elapsed), file=sys.stderr)
+            print(
+                "%s: Retrieved %i objects from %i commits in %g s ( %f objects / s )"
+                % (type(repo.odb), nt, len(commits), elapsed, nt / elapsed),
+                file=sys.stderr,
+            )
             results[1].append(elapsed)
 
             # GET BLOBS
@@ -61,13 +67,22 @@ def test_random_access(self):
             # END for each bloblist
             elapsed = time() - st
 
-            msg = "%s: Retrieved %i blob (%i KiB) and their data in %g s ( %f blobs / s, %f KiB / s )"\
-                % (type(repo.odb), nb, data_bytes / 1000, elapsed, nb / elapsed, (data_bytes / 1000) / elapsed)
+            msg = "%s: Retrieved %i blob (%i KiB) and their data in %g s ( %f blobs / s, %f KiB / s )" % (
+                type(repo.odb),
+                nb,
+                data_bytes / 1000,
+                elapsed,
+                nb / elapsed,
+                (data_bytes / 1000) / elapsed,
+            )
             print(msg, file=sys.stderr)
             results[2].append(elapsed)
         # END for each repo type
 
-        # final results
+        # Final results.
         for test_name, a, b in results:
-            print("%s: %f s vs %f s, pure is %f times slower" % (test_name, a, b, b / a), file=sys.stderr)
+            print(
+                "%s: %f s vs %f s, pure is %f times slower" % (test_name, a, b, b / a),
+                file=sys.stderr,
+            )
         # END for each result
diff --git a/test/performance/test_streams.py b/test/performance/test_streams.py
new file mode 100644
index 000000000..f6ffeba8e
--- /dev/null
+++ b/test/performance/test_streams.py
@@ -0,0 +1,170 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Performance tests for data streaming."""
+
+import gc
+import os
+import os.path as osp
+import subprocess
+import sys
+from time import time
+
+from gitdb import LooseObjectDB, IStream
+from gitdb.test.lib import make_memory_file
+
+from git.util import bin_to_hex
+
+from test.lib import with_rw_repo
+from test.performance.lib import TestBigRepoR
+
+
+class TestObjDBPerformance(TestBigRepoR):
+    large_data_size_bytes = 1000 * 1000 * 10  # Some MiB should do it.
+    moderate_data_size_bytes = 1000 * 1000 * 1  # Just 1 MiB.
+
+    @with_rw_repo("HEAD", bare=True)
+    def test_large_data_streaming(self, rwrepo):
+        # TODO: This part overlaps with the same file in
+        # gitdb.test.performance.test_stream. It should be shared if possible.
+        ldb = LooseObjectDB(osp.join(rwrepo.git_dir, "objects"))
+
+        for randomize in range(2):
+            desc = (randomize and "random ") or ""
+            print("Creating %s data ..." % desc, file=sys.stderr)
+            st = time()
+            size, stream = make_memory_file(self.large_data_size_bytes, randomize)
+            elapsed = time() - st
+            print("Done (in %f s)" % elapsed, file=sys.stderr)
+
+            # Writing - due to the compression it will seem faster than it is.
+            st = time()
+            binsha = ldb.store(IStream("blob", size, stream)).binsha
+            elapsed_add = time() - st
+            assert ldb.has_object(binsha)
+            db_file = ldb.readable_db_object_path(bin_to_hex(binsha))
+            fsize_kib = osp.getsize(db_file) / 1000
+
+            size_kib = size / 1000
+            msg = "Added %i KiB (filesize = %i KiB) of %s data to loose odb in %f s ( %f Write KiB / s)"
+            msg %= (size_kib, fsize_kib, desc, elapsed_add, size_kib / elapsed_add)
+            print(msg, file=sys.stderr)
+
+            # Reading all at once.
+            st = time()
+            ostream = ldb.stream(binsha)
+            shadata = ostream.read()
+            elapsed_readall = time() - st
+
+            stream.seek(0)
+            assert shadata == stream.getvalue()
+            msg = "Read %i KiB of %s data at once from loose odb in %f s ( %f Read KiB / s)"
+            msg %= (size_kib, desc, elapsed_readall, size_kib / elapsed_readall)
+            print(msg, file=sys.stderr)
+
+            # Reading in chunks of 1 MiB.
+            cs = 512 * 1000
+            chunks = []
+            st = time()
+            ostream = ldb.stream(binsha)
+            while True:
+                data = ostream.read(cs)
+                chunks.append(data)
+                if len(data) < cs:
+                    break
+            # END read in chunks
+            elapsed_readchunks = time() - st
+
+            stream.seek(0)
+            assert b"".join(chunks) == stream.getvalue()
+
+            cs_kib = cs / 1000
+            print(
+                "Read %i KiB of %s data in %i KiB chunks from loose odb in %f s ( %f Read KiB / s)"
+                % (
+                    size_kib,
+                    desc,
+                    cs_kib,
+                    elapsed_readchunks,
+                    size_kib / elapsed_readchunks,
+                ),
+                file=sys.stderr,
+            )
+
+            # del db file so git has something to do.
+            ostream = None
+            gc.collect()
+            os.remove(db_file)
+
+            # VS. CGIT
+            ##########
+            # CGIT! Can using the cgit programs be faster?
+            proc = rwrepo.git.hash_object("-w", "--stdin", as_process=True, istream=subprocess.PIPE)
+
+            # Write file - pump everything in at once to be a fast as possible.
+            data = stream.getvalue()  # Cache it.
+            st = time()
+            proc.stdin.write(data)
+            proc.stdin.close()
+            gitsha = proc.stdout.read().strip()
+            proc.wait()
+            gelapsed_add = time() - st
+            del data
+            assert gitsha == bin_to_hex(binsha)  # We do it the same way, right?
+
+            # As it's the same sha, we reuse our path.
+            fsize_kib = osp.getsize(db_file) / 1000
+            msg = "Added %i KiB (filesize = %i KiB) of %s data to using git-hash-object in %f s ( %f Write KiB / s)"
+            msg %= (size_kib, fsize_kib, desc, gelapsed_add, size_kib / gelapsed_add)
+            print(msg, file=sys.stderr)
+
+            # Compare.
+            print(
+                "Git-Python is %f %% faster than git when adding big %s files"
+                % (100.0 - (elapsed_add / gelapsed_add) * 100, desc),
+                file=sys.stderr,
+            )
+
+            # Read all.
+            st = time()
+            _hexsha, _typename, size, data = rwrepo.git.get_object_data(gitsha)
+            gelapsed_readall = time() - st
+            print(
+                "Read %i KiB of %s data at once using git-cat-file in %f s ( %f Read KiB / s)"
+                % (size_kib, desc, gelapsed_readall, size_kib / gelapsed_readall),
+                file=sys.stderr,
+            )
+
+            # Compare.
+            print(
+                "Git-Python is %f %% faster than git when reading big %sfiles"
+                % (100.0 - (elapsed_readall / gelapsed_readall) * 100, desc),
+                file=sys.stderr,
+            )
+
+            # Read chunks.
+            st = time()
+            _hexsha, _typename, size, stream = rwrepo.git.stream_object_data(gitsha)
+            while True:
+                data = stream.read(cs)
+                if len(data) < cs:
+                    break
+            # END read stream
+            gelapsed_readchunks = time() - st
+            msg = "Read %i KiB of %s data in %i KiB chunks from git-cat-file in %f s ( %f Read KiB / s)"
+            msg %= (
+                size_kib,
+                desc,
+                cs_kib,
+                gelapsed_readchunks,
+                size_kib / gelapsed_readchunks,
+            )
+            print(msg, file=sys.stderr)
+
+            # Compare.
+            print(
+                "Git-Python is %f %% faster than git when reading big %s files in chunks"
+                % (100.0 - (elapsed_readchunks / gelapsed_readchunks) * 100, desc),
+                file=sys.stderr,
+            )
+        # END for each randomization factor
diff --git a/git/test/test_actor.py b/test/test_actor.py
similarity index 56%
rename from git/test/test_actor.py
rename to test/test_actor.py
index 9ba0aeba7..5e6635709 100644
--- a/git/test/test_actor.py
+++ b/test/test_actor.py
@@ -1,21 +1,20 @@
-# test_actor.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-from git.test.lib import assert_equal
 from git import Actor
 
+from test.lib import TestBase
 
-class TestActor(object):
 
+class TestActor(TestBase):
     def test_from_string_should_separate_name_and_email(self):
         a = Actor._from_string("Michael Trier <mtrier@example.com>")
-        assert_equal("Michael Trier", a.name)
-        assert_equal("mtrier@example.com", a.email)
+        self.assertEqual("Michael Trier", a.name)
+        self.assertEqual("mtrier@example.com", a.email)
 
-        # base type capabilities
+        # Base type capabilities
         assert a == a
         assert not (a != a)
         m = set()
@@ -25,13 +24,13 @@ def test_from_string_should_separate_name_and_email(self):
 
     def test_from_string_should_handle_just_name(self):
         a = Actor._from_string("Michael Trier")
-        assert_equal("Michael Trier", a.name)
-        assert_equal(None, a.email)
+        self.assertEqual("Michael Trier", a.name)
+        self.assertEqual(None, a.email)
 
     def test_should_display_representation(self):
         a = Actor._from_string("Michael Trier <mtrier@example.com>")
-        assert_equal('<git.Actor "Michael Trier <mtrier@example.com>">', repr(a))
+        self.assertEqual('<git.Actor "Michael Trier <mtrier@example.com>">', repr(a))
 
     def test_str_should_alias_name(self):
         a = Actor._from_string("Michael Trier <mtrier@example.com>")
-        assert_equal(a.name, str(a))
+        self.assertEqual(a.name, str(a))
diff --git a/test/test_base.py b/test/test_base.py
new file mode 100644
index 000000000..86bcc5c79
--- /dev/null
+++ b/test/test_base.py
@@ -0,0 +1,144 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import gc
+import os
+import os.path as osp
+import sys
+import tempfile
+from unittest import skipIf
+
+from git import Repo
+from git.objects import Blob, Commit, TagObject, Tree
+import git.objects.base as base
+from git.objects.util import get_object_type_by_name
+from git.util import HIDE_WINDOWS_FREEZE_ERRORS, hex_to_bin
+
+from test.lib import TestBase as _TestBase, with_rw_and_rw_remote_repo, with_rw_repo
+
+
+class TestBase(_TestBase):
+    def tearDown(self):
+        gc.collect()
+
+    type_tuples = (
+        ("blob", "8741fc1d09d61f02ffd8cded15ff603eff1ec070", "blob.py"),
+        ("tree", "3a6a5e3eeed3723c09f1ef0399f81ed6b8d82e79", "directory"),
+        ("commit", "4251bd59fb8e11e40c40548cba38180a9536118c", None),
+        ("tag", "e56a60e8e9cd333cfba0140a77cd12b0d9398f10", None),
+    )
+
+    def test_base_object(self):
+        # Test interface of base object classes.
+        types = (Blob, Tree, Commit, TagObject)
+        self.assertEqual(len(types), len(self.type_tuples))
+
+        s = set()
+        num_objs = 0
+        num_index_objs = 0
+        for obj_type, (typename, hexsha, path) in zip(types, self.type_tuples):
+            binsha = hex_to_bin(hexsha)
+            item = None
+            if path is None:
+                item = obj_type(self.rorepo, binsha)
+            else:
+                item = obj_type(self.rorepo, binsha, 0, path)
+            # END handle index objects
+            num_objs += 1
+            self.assertEqual(item.hexsha, hexsha)
+            self.assertEqual(item.type, typename)
+            assert item.size
+            self.assertEqual(item, item)
+            self.assertNotEqual(not item, item)
+            self.assertEqual(str(item), item.hexsha)
+            assert repr(item)
+            s.add(item)
+
+            if isinstance(item, base.IndexObject):
+                num_index_objs += 1
+                if hasattr(item, "path"):  # Never runs here.
+                    assert not item.path.startswith("/")  # Must be relative.
+                    assert isinstance(item.mode, int)
+            # END index object check
+
+            # Read from stream.
+            data_stream = item.data_stream
+            data = data_stream.read()
+            assert data
+
+            with tempfile.NamedTemporaryFile(suffix="test-stream", delete=False) as tmpfile:
+                self.assertEqual(item, item.stream_data(tmpfile))
+                tmpfile.seek(0)
+                self.assertEqual(tmpfile.read(), data)
+
+            # Remove the file this way, instead of with a context manager or "finally",
+            # so it is only removed on success, and we can inspect the file on failure.
+            os.remove(tmpfile.name)
+        # END for each object type to create
+
+        # Each has a unique sha.
+        self.assertEqual(len(s), num_objs)
+        self.assertEqual(len(s | s), num_objs)
+        self.assertEqual(num_index_objs, 2)
+
+    def test_get_object_type_by_name(self):
+        for tname in base.Object.TYPES:
+            assert base.Object in get_object_type_by_name(tname).mro()
+        # END for each known type
+
+        self.assertRaises(ValueError, get_object_type_by_name, b"doesntexist")
+
+    def test_object_resolution(self):
+        # Objects must be resolved to shas so they compare equal.
+        self.assertEqual(self.rorepo.head.reference.object, self.rorepo.active_branch.object)
+
+    @with_rw_repo("HEAD", bare=True)
+    def test_with_bare_rw_repo(self, bare_rw_repo: Repo):
+        assert bare_rw_repo.config_reader("repository").getboolean("core", "bare")
+        assert osp.isfile(osp.join(bare_rw_repo.git_dir, "HEAD"))
+        assert osp.isdir(bare_rw_repo.working_dir)
+        assert bare_rw_repo.working_tree_dir is None
+
+    @with_rw_repo("0.1.6")
+    def test_with_rw_repo(self, rw_repo: Repo):
+        assert not rw_repo.config_reader("repository").getboolean("core", "bare")
+        assert osp.isdir(rw_repo.working_tree_dir)
+        assert osp.isdir(osp.join(rw_repo.working_tree_dir, "lib"))
+        assert osp.isdir(rw_repo.working_dir)
+
+    @skipIf(HIDE_WINDOWS_FREEZE_ERRORS, "FIXME: Freezes!  sometimes...")
+    @with_rw_and_rw_remote_repo("0.1.6")
+    def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
+        assert not rw_repo.config_reader("repository").getboolean("core", "bare")
+        assert rw_remote_repo.config_reader("repository").getboolean("core", "bare")
+        assert osp.isdir(osp.join(rw_repo.working_tree_dir, "lib"))
+
+    @with_rw_repo("0.1.6")
+    def test_add_unicode(self, rw_repo):
+        filename = "שלום.txt"
+
+        file_path = osp.join(rw_repo.working_dir, filename)
+
+        # Verify first that we could encode file name in this environment.
+        try:
+            file_path.encode(sys.getfilesystemencoding())
+        except UnicodeEncodeError as e:
+            raise RuntimeError("Environment doesn't support unicode filenames") from e
+
+        with open(file_path, "wb") as fp:
+            fp.write(b"something")
+
+        if sys.platform == "win32":
+            # On Windows, there is no way this works, see images on:
+            # https://github.com/gitpython-developers/GitPython/issues/147#issuecomment-68881897
+            # Therefore, it must be added using the Python implementation.
+            rw_repo.index.add([file_path])
+            # However, when the test winds down, rmtree fails to delete this file, which
+            # is recognized as ??? only.
+        else:
+            # On POSIX, we can just add Unicode files without problems.
+            rw_repo.git.add(rw_repo.working_dir)
+
+        rw_repo.index.commit("message")
diff --git a/test/test_blob.py b/test/test_blob.py
new file mode 100644
index 000000000..affaa60fc
--- /dev/null
+++ b/test/test_blob.py
@@ -0,0 +1,21 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+from git import Blob
+
+from test.lib import TestBase
+
+
+class TestBlob(TestBase):
+    def test_mime_type_should_return_mime_type_for_known_types(self):
+        blob = Blob(self.rorepo, **{"binsha": Blob.NULL_BIN_SHA, "path": "foo.png"})
+        self.assertEqual("image/png", blob.mime_type)
+
+    def test_mime_type_should_return_text_plain_for_unknown_types(self):
+        blob = Blob(self.rorepo, **{"binsha": Blob.NULL_BIN_SHA, "path": "something"})
+        self.assertEqual("text/plain", blob.mime_type)
+
+    def test_nodict(self):
+        self.assertRaises(AttributeError, setattr, self.rorepo.tree()["AUTHORS"], "someattr", 2)
diff --git a/test/test_blob_filter.py b/test/test_blob_filter.py
new file mode 100644
index 000000000..ddd83079a
--- /dev/null
+++ b/test/test_blob_filter.py
@@ -0,0 +1,37 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Tests for the blob filter."""
+
+from pathlib import Path
+from typing import Sequence, Tuple
+from unittest.mock import MagicMock
+
+import pytest
+
+from git.index.typ import BlobFilter, StageType
+from git.objects import Blob
+from git.types import PathLike
+
+
+@pytest.mark.parametrize(
+    "paths, path, expected_result",
+    [
+        ((Path("foo"),), Path("foo"), True),
+        ((Path("foo"),), Path("foo/bar"), True),
+        ((Path("foo/bar"),), Path("foo"), False),
+        ((Path("foo"), Path("bar")), Path("foo"), True),
+    ],
+)
+def test_blob_filter(paths: Sequence[PathLike], path: PathLike, expected_result: bool) -> None:
+    """Test the blob filter."""
+    blob_filter = BlobFilter(paths)
+
+    binsha = MagicMock(__len__=lambda self: 20)
+    stage_type: StageType = 0
+    blob: Blob = Blob(repo=MagicMock(), binsha=binsha, path=path)
+    stage_blob: Tuple[StageType, Blob] = (stage_type, blob)
+
+    result = blob_filter(stage_blob)
+
+    assert result == expected_result
diff --git a/test/test_clone.py b/test/test_clone.py
new file mode 100644
index 000000000..126ef0063
--- /dev/null
+++ b/test/test_clone.py
@@ -0,0 +1,31 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+from pathlib import Path
+import re
+
+import git
+
+from test.lib import TestBase, with_rw_directory
+
+
+class TestClone(TestBase):
+    @with_rw_directory
+    def test_checkout_in_non_empty_dir(self, rw_dir):
+        non_empty_dir = Path(rw_dir)
+        garbage_file = non_empty_dir / "not-empty"
+        garbage_file.write_text("Garbage!")
+
+        # Verify that cloning into the non-empty dir fails while complaining about the
+        # target directory not being empty/non-existent.
+        try:
+            self.rorepo.clone(non_empty_dir)
+        except git.GitCommandError as exc:
+            self.assertTrue(exc.stderr, "GitCommandError's 'stderr' is unexpectedly empty")
+            expr = re.compile(r"(?is).*\bfatal:\s+destination\s+path\b.*\bexists\b.*\bnot\b.*\bempty\s+directory\b")
+            self.assertTrue(
+                expr.search(exc.stderr),
+                '"%s" does not match "%s"' % (expr.pattern, exc.stderr),
+            )
+        else:
+            self.fail("GitCommandError not raised")
diff --git a/test/test_commit.py b/test/test_commit.py
new file mode 100644
index 000000000..37c66e3e7
--- /dev/null
+++ b/test/test_commit.py
@@ -0,0 +1,568 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import copy
+from datetime import datetime
+from io import BytesIO
+import os.path as osp
+import re
+import sys
+import time
+from unittest.mock import Mock
+
+from gitdb import IStream
+
+from git import Actor, Commit, Repo
+from git.objects.util import tzoffset, utc
+from git.repo.fun import touch
+
+from test.lib import (
+    StringProcessAdapter,
+    TestBase,
+    fixture_path,
+    with_rw_directory,
+    with_rw_repo,
+)
+
+
+class TestCommitSerialization(TestBase):
+    def assert_commit_serialization(self, rwrepo, commit_id, print_performance_info=False):
+        """Traverse all commits in the history of commit identified by commit_id and
+        check if the serialization works.
+
+        :param print_performance_info: If True, we will show how fast we are.
+        """
+        ns = 0  # Number of serializations.
+        nds = 0  # Number of deserializations.
+
+        st = time.time()
+        for cm in rwrepo.commit(commit_id).traverse():
+            nds += 1
+
+            # Assert that we deserialize commits correctly, hence we get the same
+            # sha on serialization.
+            stream = BytesIO()
+            cm._serialize(stream)
+            ns += 1
+            streamlen = stream.tell()
+            stream.seek(0)
+
+            istream = rwrepo.odb.store(IStream(Commit.type, streamlen, stream))
+            self.assertEqual(istream.hexsha, cm.hexsha.encode("ascii"))
+
+            nc = Commit(
+                rwrepo,
+                Commit.NULL_BIN_SHA,
+                cm.tree,
+                cm.author,
+                cm.authored_date,
+                cm.author_tz_offset,
+                cm.committer,
+                cm.committed_date,
+                cm.committer_tz_offset,
+                cm.message,
+                cm.parents,
+                cm.encoding,
+            )
+
+            self.assertEqual(nc.parents, cm.parents)
+            stream = BytesIO()
+            nc._serialize(stream)
+            ns += 1
+            streamlen = stream.tell()
+            stream.seek(0)
+
+            # Reuse istream.
+            istream.size = streamlen
+            istream.stream = stream
+            istream.binsha = None
+            nc.binsha = rwrepo.odb.store(istream).binsha
+
+            # If it worked, we have exactly the same contents!
+            self.assertEqual(nc.hexsha, cm.hexsha)
+        # END check commits
+        elapsed = time.time() - st
+
+        if print_performance_info:
+            print(
+                "Serialized %i and deserialized %i commits in %f s ( (%f, %f) commits / s"
+                % (ns, nds, elapsed, ns / elapsed, nds / elapsed),
+                file=sys.stderr,
+            )
+        # END handle performance info
+
+
+class TestCommit(TestCommitSerialization):
+    def test_bake(self):
+        commit = self.rorepo.commit("2454ae89983a4496a445ce347d7a41c0bb0ea7ae")
+        # Commits have no dict.
+        self.assertRaises(AttributeError, setattr, commit, "someattr", 1)
+        commit.author  # bake
+
+        self.assertEqual("Sebastian Thiel", commit.author.name)
+        self.assertEqual("byronimo@gmail.com", commit.author.email)
+        self.assertEqual(commit.author, commit.committer)
+        assert isinstance(commit.authored_date, int) and isinstance(commit.committed_date, int)
+        assert isinstance(commit.author_tz_offset, int) and isinstance(commit.committer_tz_offset, int)
+        self.assertEqual(
+            commit.message,
+            "Added missing information to docstrings of commit and stats module\n",
+        )
+
+    def test_replace_no_changes(self):
+        old_commit = self.rorepo.commit("2454ae89983a4496a445ce347d7a41c0bb0ea7ae")
+        new_commit = old_commit.replace()
+
+        for attr in old_commit.__slots__:
+            assert getattr(new_commit, attr) == getattr(old_commit, attr)
+
+    def test_replace_new_sha(self):
+        commit = self.rorepo.commit("2454ae89983a4496a445ce347d7a41c0bb0ea7ae")
+        new_commit = commit.replace(message="Added replace method")
+
+        assert new_commit.hexsha == "fc84cbecac1bd4ba4deaac07c1044889edd536e6"
+        assert new_commit.message == "Added replace method"
+
+    def test_replace_invalid_attribute(self):
+        commit = self.rorepo.commit("2454ae89983a4496a445ce347d7a41c0bb0ea7ae")
+
+        with self.assertRaises(ValueError):
+            commit.replace(badattr="This will never work")
+
+    def test_stats(self):
+        commit = self.rorepo.commit("33ebe7acec14b25c5f84f35a664803fcab2f7781")
+        stats = commit.stats
+
+        def check_entries(d, has_change_type=False):
+            assert isinstance(d, dict)
+            keys = ("insertions", "deletions", "lines")
+            if has_change_type:
+                keys += ("change_type",)
+            for key in keys:
+                assert key in d
+
+        # END assertion helper
+        assert stats.files
+        assert stats.total
+
+        check_entries(stats.total)
+        assert "files" in stats.total
+
+        for _filepath, d in stats.files.items():
+            check_entries(d, True)
+        # END for each stated file
+
+        # Check that data is parsed properly.
+        michael = Actor._from_string("Michael Trier <mtrier@gmail.com>")
+        self.assertEqual(commit.author, michael)
+        self.assertEqual(commit.committer, michael)
+        self.assertEqual(commit.authored_date, 1210193388)
+        self.assertEqual(commit.committed_date, 1210193388)
+        self.assertEqual(commit.author_tz_offset, 14400, commit.author_tz_offset)
+        self.assertEqual(commit.committer_tz_offset, 14400, commit.committer_tz_offset)
+        self.assertEqual(commit.message, "initial project\n")
+
+    def test_renames(self):
+        commit = self.rorepo.commit("185d847ec7647fd2642a82d9205fb3d07ea71715")
+        files = commit.stats.files
+
+        # When a file is renamed, the output of git diff is like "dir/{old => new}"
+        # unless we disable rename with --no-renames, which produces two lines,
+        # one with the old path deletes and another with the new added.
+        self.assertEqual(len(files), 2)
+
+        def check_entries(path, changes):
+            expected = {
+                ".github/workflows/Future.yml": {
+                    "insertions": 57,
+                    "deletions": 0,
+                    "lines": 57,
+                },
+                ".github/workflows/test_pytest.yml": {
+                    "insertions": 0,
+                    "deletions": 55,
+                    "lines": 55,
+                },
+            }
+            assert path in expected
+            assert isinstance(changes, dict)
+            for key in ("insertions", "deletions", "lines"):
+                assert changes[key] == expected[path][key]
+
+        for path, changes in files.items():
+            check_entries(path, changes)
+        # END for each stated file
+
+    def test_unicode_actor(self):
+        # Check that we can parse Unicode actors correctly.
+        name = "Üäöß ÄußÉ"
+        self.assertEqual(len(name), 9)
+        special = Actor._from_string("%s <something@this.com>" % name)
+        self.assertEqual(special.name, name)
+        assert isinstance(special.name, str)
+
+    def test_traversal(self):
+        start = self.rorepo.commit("a4d06724202afccd2b5c54f81bcf2bf26dea7fff")
+        first = self.rorepo.commit("33ebe7acec14b25c5f84f35a664803fcab2f7781")
+        p0 = start.parents[0]
+        p1 = start.parents[1]
+        p00 = p0.parents[0]
+        p10 = p1.parents[0]
+
+        # Basic branch first, depth first.
+        dfirst = start.traverse(branch_first=False)
+        bfirst = start.traverse(branch_first=True)
+        self.assertEqual(next(dfirst), p0)
+        self.assertEqual(next(dfirst), p00)
+
+        self.assertEqual(next(bfirst), p0)
+        self.assertEqual(next(bfirst), p1)
+        self.assertEqual(next(bfirst), p00)
+        self.assertEqual(next(bfirst), p10)
+
+        # At some point, both iterations should stop.
+        self.assertEqual(list(bfirst)[-1], first)
+
+        stoptraverse = self.rorepo.commit("254d04aa3180eb8b8daf7b7ff25f010cd69b4e7d").traverse(
+            ignore_self=0, as_edge=True
+        )
+        stoptraverse_list = list(stoptraverse)
+        for itemtup in stoptraverse_list:
+            self.assertIsInstance(itemtup, (tuple)) and self.assertEqual(len(itemtup), 2)  # as_edge=True -> tuple
+            src, item = itemtup
+            self.assertIsInstance(item, Commit)
+            if src:
+                self.assertIsInstance(src, Commit)
+            else:
+                self.assertIsNone(src)  # ignore_self=0 -> first is (None, Commit)
+
+        stoptraverse = self.rorepo.commit("254d04aa3180eb8b8daf7b7ff25f010cd69b4e7d").traverse(as_edge=True)
+        self.assertEqual(len(next(stoptraverse)), 2)
+
+        # Ignore self
+        self.assertEqual(next(start.traverse(ignore_self=False)), start)
+
+        # Depth
+        self.assertEqual(len(list(start.traverse(ignore_self=False, depth=0))), 1)
+
+        # Prune
+        self.assertEqual(next(start.traverse(branch_first=1, prune=lambda i, d: i == p0)), p1)
+
+        # Predicate
+        self.assertEqual(next(start.traverse(branch_first=1, predicate=lambda i, d: i == p1)), p1)
+
+        # Traversal should stop when the beginning is reached.
+        self.assertRaises(StopIteration, next, first.traverse())
+
+        # Parents of the first commit should be empty (as the only parent has a null sha)
+        self.assertEqual(len(first.parents), 0)
+
+    def test_iteration(self):
+        # We can iterate commits.
+        all_commits = Commit.list_items(self.rorepo, self.rorepo.head)
+        assert all_commits
+        self.assertEqual(all_commits, list(self.rorepo.iter_commits()))
+
+        # This includes merge commits.
+        mcomit = self.rorepo.commit("d884adc80c80300b4cc05321494713904ef1df2d")
+        assert mcomit in all_commits
+
+        # We can limit the result to paths.
+        ltd_commits = list(self.rorepo.iter_commits(paths="CHANGES"))
+        assert ltd_commits and len(ltd_commits) < len(all_commits)
+
+        # Show commits of multiple paths, resulting in a union of commits.
+        less_ltd_commits = list(Commit.iter_items(self.rorepo, "master", paths=("CHANGES", "AUTHORS")))
+        assert len(ltd_commits) < len(less_ltd_commits)
+
+        class Child(Commit):
+            def __init__(self, *args, **kwargs):
+                super().__init__(*args, **kwargs)
+
+        child_commits = list(Child.iter_items(self.rorepo, "master", paths=("CHANGES", "AUTHORS")))
+        assert type(child_commits[0]) is Child
+
+    def test_iter_items(self):
+        # pretty not allowed.
+        self.assertRaises(ValueError, Commit.iter_items, self.rorepo, "master", pretty="raw")
+
+    def test_rev_list_bisect_all(self):
+        """
+        'git rev-list --bisect-all' returns additional information
+        in the commit header.  This test ensures that we properly parse it.
+        """
+        revs = self.rorepo.git.rev_list(
+            "933d23bf95a5bd1624fbcdf328d904e1fa173474",
+            first_parent=True,
+            bisect_all=True,
+        )
+
+        commits = Commit._iter_from_process_or_stream(self.rorepo, StringProcessAdapter(revs.encode("ascii")))
+        expected_ids = (
+            "7156cece3c49544abb6bf7a0c218eb36646fad6d",
+            "1f66cfbbce58b4b552b041707a12d437cc5f400a",
+            "33ebe7acec14b25c5f84f35a664803fcab2f7781",
+            "933d23bf95a5bd1624fbcdf328d904e1fa173474",
+        )
+        for sha1, commit in zip(expected_ids, commits):
+            self.assertEqual(sha1, commit.hexsha)
+
+    @with_rw_directory
+    def test_ambiguous_arg_iteration(self, rw_dir):
+        rw_repo = Repo.init(osp.join(rw_dir, "test_ambiguous_arg"))
+        path = osp.join(str(rw_repo.working_tree_dir), "master")
+        touch(path)
+        rw_repo.index.add([path])
+        rw_repo.index.commit("initial commit")
+        list(rw_repo.iter_commits(rw_repo.head.ref))  # Should fail unless bug is fixed.
+
+    def test_count(self):
+        self.assertEqual(self.rorepo.tag("refs/tags/0.1.5").commit.count(), 143)
+
+    def test_list(self):
+        # This doesn't work anymore, as we will either attempt getattr with bytes, or
+        # compare 20 byte string with actual 20 byte bytes. This usage makes no sense
+        # anyway.
+        assert isinstance(
+            Commit.list_items(self.rorepo, "0.1.5", max_count=5)["5117c9c8a4d3af19a9958677e45cda9269de1541"],
+            Commit,
+        )
+
+    def test_str(self):
+        commit = Commit(self.rorepo, Commit.NULL_BIN_SHA)
+        self.assertEqual(Commit.NULL_HEX_SHA, str(commit))
+
+    def test_repr(self):
+        commit = Commit(self.rorepo, Commit.NULL_BIN_SHA)
+        self.assertEqual('<git.Commit "%s">' % Commit.NULL_HEX_SHA, repr(commit))
+
+    def test_equality(self):
+        commit1 = Commit(self.rorepo, Commit.NULL_BIN_SHA)
+        commit2 = Commit(self.rorepo, Commit.NULL_BIN_SHA)
+        commit3 = Commit(self.rorepo, "\1" * 20)
+        self.assertEqual(commit1, commit2)
+        self.assertNotEqual(commit2, commit3)
+
+    def test_iter_parents(self):
+        # Should return all but ourselves, even if skip is defined.
+        c = self.rorepo.commit("0.1.5")
+        for skip in (0, 1):
+            piter = c.iter_parents(skip=skip)
+            first_parent = next(piter)
+            assert first_parent != c
+            self.assertEqual(first_parent, c.parents[0])
+        # END for each
+
+    def test_name_rev(self):
+        name_rev = self.rorepo.head.commit.name_rev
+        assert isinstance(name_rev, str)
+
+    @with_rw_repo("HEAD", bare=True)
+    def test_serialization(self, rwrepo):
+        # Create all commits of our repo.
+        self.assert_commit_serialization(rwrepo, "0.1.6")
+
+    def test_serialization_unicode_support(self):
+        self.assertEqual(Commit.default_encoding.lower(), "utf-8")
+
+        # Create a commit with Unicode in the message, and the author's name.
+        # Verify its serialization and deserialization.
+        cmt = self.rorepo.commit("0.1.6")
+        assert isinstance(cmt.message, str)  # It automatically decodes it as such.
+        assert isinstance(cmt.author.name, str)  # Same here.
+
+        cmt.message = "üäêèß"
+        self.assertEqual(len(cmt.message), 5)
+
+        cmt.author.name = "äüß"
+        self.assertEqual(len(cmt.author.name), 3)
+
+        cstream = BytesIO()
+        cmt._serialize(cstream)
+        cstream.seek(0)
+        assert len(cstream.getvalue())
+
+        ncmt = Commit(self.rorepo, cmt.binsha)
+        ncmt._deserialize(cstream)
+
+        self.assertEqual(cmt.author.name, ncmt.author.name)
+        self.assertEqual(cmt.message, ncmt.message)
+        # Actually, it can't be printed in a shell as repr wants to have ascii only it
+        # appears.
+        cmt.author.__repr__()
+
+    def test_invalid_commit(self):
+        cmt = self.rorepo.commit()
+        with open(fixture_path("commit_invalid_data"), "rb") as fd:
+            cmt._deserialize(fd)
+
+        self.assertEqual(cmt.author.name, "E.Azer Ko�o�o�oculu", cmt.author.name)
+        self.assertEqual(cmt.author.email, "azer@kodfabrik.com", cmt.author.email)
+
+    def test_gpgsig(self):
+        cmt = self.rorepo.commit()
+        with open(fixture_path("commit_with_gpgsig"), "rb") as fd:
+            cmt._deserialize(fd)
+
+        fixture_sig = """-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.11 (GNU/Linux)
+
+iQIcBAABAgAGBQJRk8zMAAoJEG5mS6x6i9IjsTEP/0v2Wx/i7dqyKban6XMIhVdj
+uI0DycfXqnCCZmejidzeao+P+cuK/ZAA/b9fU4MtwkDm2USvnIOrB00W0isxsrED
+sdv6uJNa2ybGjxBolLrfQcWutxGXLZ1FGRhEvkPTLMHHvVriKoNFXcS7ewxP9MBf
+NH97K2wauqA+J4BDLDHQJgADCOmLrGTAU+G1eAXHIschDqa6PZMH5nInetYZONDh
+3SkOOv8VKFIF7gu8X7HC+7+Y8k8U0TW0cjlQ2icinwCc+KFoG6GwXS7u/VqIo1Yp
+Tack6sxIdK7NXJhV5gAeAOMJBGhO0fHl8UUr96vGEKwtxyZhWf8cuIPOWLk06jA0
+g9DpLqmy/pvyRfiPci+24YdYRBua/vta+yo/Lp85N7Hu/cpIh+q5WSLvUlv09Dmo
+TTTG8Hf6s3lEej7W8z2xcNZoB6GwXd8buSDU8cu0I6mEO9sNtAuUOHp2dBvTA6cX
+PuQW8jg3zofnx7CyNcd3KF3nh2z8mBcDLgh0Q84srZJCPRuxRcp9ylggvAG7iaNd
+XMNvSK8IZtWLkx7k3A3QYt1cN4y1zdSHLR2S+BVCEJea1mvUE+jK5wiB9S4XNtKm
+BX/otlTa8pNE3fWYBxURvfHnMY4i3HQT7Bc1QjImAhMnyo2vJk4ORBJIZ1FTNIhJ
+JzJMZDRLQLFvnzqZuCjE
+=przd
+-----END PGP SIGNATURE-----"""
+        self.assertEqual(cmt.gpgsig, fixture_sig)
+
+        cmt.gpgsig = "<test\ndummy\nsig>"
+        assert cmt.gpgsig != fixture_sig
+
+        cstream = BytesIO()
+        cmt._serialize(cstream)
+        assert re.search(
+            r"^gpgsig <test\n dummy\n sig>$",
+            cstream.getvalue().decode("ascii"),
+            re.MULTILINE,
+        )
+
+        self.assert_gpgsig_deserialization(cstream)
+
+        cstream.seek(0)
+        cmt.gpgsig = None
+        cmt._deserialize(cstream)
+        self.assertEqual(cmt.gpgsig, "<test\ndummy\nsig>")
+
+        cmt.gpgsig = None
+        cstream = BytesIO()
+        cmt._serialize(cstream)
+        assert not re.search(r"^gpgsig ", cstream.getvalue().decode("ascii"), re.MULTILINE)
+
+    def assert_gpgsig_deserialization(self, cstream):
+        assert "gpgsig" in "precondition: need gpgsig"
+
+        class RepoMock:
+            def __init__(self, bytestr):
+                self.bytestr = bytestr
+
+            @property
+            def odb(self):
+                class ODBMock:
+                    def __init__(self, bytestr):
+                        self.bytestr = bytestr
+
+                    def stream(self, *args):
+                        stream = Mock(spec_set=["read"], return_value=self.bytestr)
+                        stream.read.return_value = self.bytestr
+                        return ("binsha", "typename", "size", stream)
+
+                return ODBMock(self.bytestr)
+
+        repo_mock = RepoMock(cstream.getvalue())
+        for field in Commit.__slots__:
+            c = Commit(repo_mock, b"x" * 20)
+            assert getattr(c, field) is not None
+
+    def test_datetimes(self):
+        commit = self.rorepo.commit("4251bd5")
+        self.assertEqual(commit.authored_date, 1255018625)
+        self.assertEqual(commit.committed_date, 1255026171)
+        self.assertEqual(
+            commit.authored_datetime,
+            datetime(2009, 10, 8, 18, 17, 5, tzinfo=tzoffset(-7200)),
+            commit.authored_datetime,
+        )
+        self.assertEqual(
+            commit.authored_datetime,
+            datetime(2009, 10, 8, 16, 17, 5, tzinfo=utc),
+            commit.authored_datetime,
+        )
+        self.assertEqual(
+            commit.committed_datetime,
+            datetime(2009, 10, 8, 20, 22, 51, tzinfo=tzoffset(-7200)),
+        )
+        self.assertEqual(
+            commit.committed_datetime,
+            datetime(2009, 10, 8, 18, 22, 51, tzinfo=utc),
+            commit.committed_datetime,
+        )
+
+    def test_trailers(self):
+        KEY_1 = "Hello"
+        VALUE_1_1 = "World"
+        VALUE_1_2 = "Another-World"
+        KEY_2 = "Key"
+        VALUE_2 = "Value with inner spaces"
+
+        # Check that the following trailer example is extracted from multiple msg
+        # variations.
+        TRAILER = f"{KEY_1}: {VALUE_1_1}\n{KEY_2}: {VALUE_2}\n{KEY_1}: {VALUE_1_2}"
+        msgs = [
+            f"Subject\n\n{TRAILER}\n",
+            f"Subject\n  \nSome body of a function\n \n{TRAILER}\n",
+            f"Subject\n  \nSome body of a function\n\nnon-key: non-value\n\n{TRAILER}\n",
+            (
+                # Check when trailer has inconsistent whitespace.
+                f"Subject\n  \nSome multiline\n body of a function\n\nnon-key: non-value\n\n"
+                f"{KEY_1}:{VALUE_1_1}\n{KEY_2} :      {VALUE_2}\n{KEY_1}:    {VALUE_1_2}\n"
+            ),
+        ]
+        for msg in msgs:
+            commit = copy.copy(self.rorepo.commit("master"))
+            commit.message = msg
+            assert commit.trailers_list == [
+                (KEY_1, VALUE_1_1),
+                (KEY_2, VALUE_2),
+                (KEY_1, VALUE_1_2),
+            ]
+            assert commit.trailers_dict == {
+                KEY_1: [VALUE_1_1, VALUE_1_2],
+                KEY_2: [VALUE_2],
+            }
+
+        # Check that the trailer stays empty for multiple msg combinations.
+        msgs = [
+            "Subject\n",
+            "Subject\n\nBody with some\nText\n",
+            "Subject\n\nBody with\nText\n\nContinuation but\n doesn't contain colon\n",
+            "Subject\n\nBody with\nText\n\nContinuation but\n only contains one :\n",
+            "Subject\n\nBody with\nText\n\nKey: Value\nLine without colon\n",
+            "Subject\n\nBody with\nText\n\nLine without colon\nKey: Value\n",
+        ]
+
+        for msg in msgs:
+            commit = copy.copy(self.rorepo.commit("master"))
+            commit.message = msg
+            assert commit.trailers_list == []
+            assert commit.trailers_dict == {}
+
+        # Check that only the last key value paragraph is evaluated.
+        commit = copy.copy(self.rorepo.commit("master"))
+        commit.message = f"Subject\n\nMultiline\nBody\n\n{KEY_1}: {VALUE_1_1}\n\n{KEY_2}: {VALUE_2}\n"
+        assert commit.trailers_list == [(KEY_2, VALUE_2)]
+        assert commit.trailers_dict == {KEY_2: [VALUE_2]}
+
+    def test_commit_co_authors(self):
+        commit = copy.copy(self.rorepo.commit("4251bd5"))
+        commit.message = """Commit message
+
+Co-authored-by: Test User 1 <602352+test@users.noreply.github.com>
+Co-authored-by: test_user_2 <another_user-email@github.com>
+Co_authored_by: test_user_x <test@github.com>
+Co-authored-by: test_user_y <test@github.com> text
+Co-authored-by: test_user_3 <test_user_3@github.com>"""
+        assert commit.co_authors == [
+            Actor("Test User 1", "602352+test@users.noreply.github.com"),
+            Actor("test_user_2", "another_user-email@github.com"),
+            Actor("test_user_3", "test_user_3@github.com"),
+        ]
diff --git a/test/test_config.py b/test/test_config.py
new file mode 100644
index 000000000..8e1007d9e
--- /dev/null
+++ b/test/test_config.py
@@ -0,0 +1,585 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import glob
+import io
+import os
+import os.path as osp
+import sys
+from unittest import mock
+
+import pytest
+
+from git import GitConfigParser
+from git.config import _OMD, cp
+from git.util import rmfile
+
+from test.lib import SkipTest, TestCase, fixture_path, with_rw_directory
+
+_tc_lock_fpaths = osp.join(osp.dirname(__file__), "fixtures/*.lock")
+
+
+def _rm_lock_files():
+    for lfp in glob.glob(_tc_lock_fpaths):
+        rmfile(lfp)
+
+
+class TestBase(TestCase):
+    def setUp(self):
+        _rm_lock_files()
+
+    def tearDown(self):
+        for lfp in glob.glob(_tc_lock_fpaths):
+            if osp.isfile(lfp):
+                raise AssertionError("Previous TC left hanging git-lock file: {}".format(lfp))
+
+    def _to_memcache(self, file_path):
+        with open(file_path, "rb") as fp:
+            sio = io.BytesIO(fp.read())
+        sio.name = file_path
+        return sio
+
+    def test_read_write(self):
+        # The writer must create the exact same file as the one read before.
+        for filename in ("git_config", "git_config_global"):
+            file_obj = self._to_memcache(fixture_path(filename))
+            with GitConfigParser(file_obj, read_only=False) as w_config:
+                w_config.read()  # Enforce reading.
+                assert w_config._sections
+                w_config.write()  # Enforce writing.
+
+                # We stripped lines when reading, so the results differ.
+                assert file_obj.getvalue()
+                self.assertEqual(
+                    file_obj.getvalue(),
+                    self._to_memcache(fixture_path(filename)).getvalue(),
+                )
+
+                # Creating an additional config writer must fail due to exclusive
+                # access.
+                with self.assertRaises(IOError):
+                    GitConfigParser(file_obj, read_only=False)
+
+                # Should still have a lock and be able to make changes.
+                assert w_config._lock._has_lock()
+
+                # Changes should be written right away.
+                sname = "my_section"
+                oname = "mykey"
+                val = "myvalue"
+                w_config.add_section(sname)
+                assert w_config.has_section(sname)
+                w_config.set(sname, oname, val)
+                assert w_config.has_option(sname, oname)
+                assert w_config.get(sname, oname) == val
+
+                sname_new = "new_section"
+                oname_new = "new_key"
+                ival = 10
+                w_config.set_value(sname_new, oname_new, ival)
+                assert w_config.get_value(sname_new, oname_new) == ival
+
+                file_obj.seek(0)
+                r_config = GitConfigParser(file_obj, read_only=True)
+                assert r_config.has_section(sname)
+                assert r_config.has_option(sname, oname)
+                assert r_config.get(sname, oname) == val
+        # END for each filename
+
+    def test_includes_order(self):
+        with GitConfigParser(list(map(fixture_path, ("git_config", "git_config_global")))) as r_config:
+            r_config.read()  # Enforce reading.
+            # Simple inclusions, again checking them taking precedence.
+            assert r_config.get_value("sec", "var0") == "value0_included"
+            # This one should take the git_config_global value since included values
+            # must be considered as soon as they get them.
+            assert r_config.get_value("diff", "tool") == "meld"
+            try:
+                # FIXME: Split this assertion out somehow and mark it xfail (or fix it).
+                assert r_config.get_value("sec", "var1") == "value1_main"
+            except AssertionError as e:
+                raise SkipTest("Known failure -- included values are not in effect right away") from e
+
+    @with_rw_directory
+    def test_lock_reentry(self, rw_dir):
+        fpl = osp.join(rw_dir, "l")
+        gcp = GitConfigParser(fpl, read_only=False)
+        with gcp as cw:
+            cw.set_value("include", "some_value", "a")
+        # Entering again locks the file again...
+        with gcp as cw:
+            cw.set_value("include", "some_other_value", "b")
+            # ...so creating an additional config writer must fail due to exclusive
+            # access.
+            with self.assertRaises(IOError):
+                GitConfigParser(fpl, read_only=False)
+        # but work when the lock is removed
+        with GitConfigParser(fpl, read_only=False):
+            assert osp.exists(fpl)
+            # Reentering with an existing lock must fail due to exclusive access.
+            with self.assertRaises(IOError):
+                gcp.__enter__()
+
+    def test_multi_line_config(self):
+        file_obj = self._to_memcache(fixture_path("git_config_with_comments"))
+        with GitConfigParser(file_obj, read_only=False) as config:
+            ev = "ruby -e '\n"
+            ev += "		system %(git), %(merge-file), %(--marker-size=%L), %(%A), %(%O), %(%B)\n"
+            ev += "		b = File.read(%(%A))\n"
+            ev += "		b.sub!(/^<+ .*\\nActiveRecord::Schema\\.define.:version => (\\d+). do\\n=+\\nActiveRecord::Schema\\."  # noqa: E501
+            ev += "define.:version => (\\d+). do\\n>+ .*/) do\n"
+            ev += "		  %(ActiveRecord::Schema.define(:version => #{[$1, $2].max}) do)\n"
+            ev += "		end\n"
+            ev += "		File.open(%(%A), %(w)) {|f| f.write(b)}\n"
+            ev += "		exit 1 if b.include?(%(<)*%L)'"
+            self.assertEqual(config.get('merge "railsschema"', "driver"), ev)
+            self.assertEqual(
+                config.get("alias", "lg"),
+                "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset'"
+                " --abbrev-commit --date=relative",
+            )
+            self.assertEqual(len(config.sections()), 23)
+
+    def test_config_value_with_trailing_new_line(self):
+        config_content = b'[section-header]\nkey:"value\n"'
+        config_file = io.BytesIO(config_content)
+        config_file.name = "multiline_value.config"
+
+        git_config = GitConfigParser(config_file)
+        git_config.read()  # This should not throw an exception
+
+    def test_base(self):
+        path_repo = fixture_path("git_config")
+        path_global = fixture_path("git_config_global")
+        r_config = GitConfigParser([path_repo, path_global], read_only=True)
+        assert r_config.read_only
+        num_sections = 0
+        num_options = 0
+
+        # Test reader methods.
+        assert r_config._is_initialized is False
+        for section in r_config.sections():
+            num_sections += 1
+            for option in r_config.options(section):
+                num_options += 1
+                val = r_config.get(section, option)
+                val_typed = r_config.get_value(section, option)
+                assert isinstance(val_typed, (bool, int, float, str))
+                assert val
+                assert "\n" not in option
+                assert "\n" not in val
+
+                # Writing must fail.
+                with self.assertRaises(IOError):
+                    r_config.set(section, option, None)
+                with self.assertRaises(IOError):
+                    r_config.remove_option(section, option)
+            # END for each option
+            with self.assertRaises(IOError):
+                r_config.remove_section(section)
+        # END for each section
+        assert num_sections and num_options
+        assert r_config._is_initialized is True
+
+        # Get value which doesn't exist, with default.
+        default = "my default value"
+        assert r_config.get_value("doesnt", "exist", default) == default
+
+        # It raises if there is no default though.
+        with self.assertRaises(cp.NoSectionError):
+            r_config.get_value("doesnt", "exist")
+
+    @with_rw_directory
+    def test_config_include(self, rw_dir):
+        def write_test_value(cw, value):
+            cw.set_value(value, "value", value)
+
+        def check_test_value(cr, value):
+            assert cr.get_value(value, "value") == value
+
+        # PREPARE CONFIG FILE A
+        fpa = osp.join(rw_dir, "a")
+        with GitConfigParser(fpa, read_only=False) as cw:
+            write_test_value(cw, "a")
+
+            fpb = osp.join(rw_dir, "b")
+            fpc = osp.join(rw_dir, "c")
+            cw.set_value("include", "relative_path_b", "b")
+            cw.set_value("include", "doesntexist", "foobar")
+            cw.set_value("include", "relative_cycle_a_a", "a")
+            cw.set_value("include", "absolute_cycle_a_a", fpa)
+        assert osp.exists(fpa)
+
+        # PREPARE CONFIG FILE B
+        with GitConfigParser(fpb, read_only=False) as cw:
+            write_test_value(cw, "b")
+            cw.set_value("include", "relative_cycle_b_a", "a")
+            cw.set_value("include", "absolute_cycle_b_a", fpa)
+            cw.set_value("include", "relative_path_c", "c")
+            cw.set_value("include", "absolute_path_c", fpc)
+
+        # PREPARE CONFIG FILE C
+        with GitConfigParser(fpc, read_only=False) as cw:
+            write_test_value(cw, "c")
+
+        with GitConfigParser(fpa, read_only=True) as cr:
+            for tv in ("a", "b", "c"):
+                check_test_value(cr, tv)
+            # END for each test to verify
+            assert len(cr.items("include")) == 8, "Expected all include sections to be merged"
+
+        # Test writable config writers - assure write-back doesn't involve includes.
+        with GitConfigParser(fpa, read_only=False, merge_includes=True) as cw:
+            tv = "x"
+            write_test_value(cw, tv)
+
+        with GitConfigParser(fpa, read_only=True) as cr:
+            with self.assertRaises(cp.NoSectionError):
+                check_test_value(cr, tv)
+
+        # But can make it skip includes altogether, and thus allow write-backs.
+        with GitConfigParser(fpa, read_only=False, merge_includes=False) as cw:
+            write_test_value(cw, tv)
+
+        with GitConfigParser(fpa, read_only=True) as cr:
+            check_test_value(cr, tv)
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason='Second config._has_includes() assertion fails (for "config is included if path is matching git_dir")',
+        raises=AssertionError,
+    )
+    @with_rw_directory
+    def test_conditional_includes_from_git_dir(self, rw_dir):
+        # Initiate repository path.
+        git_dir = osp.join(rw_dir, "target1", "repo1")
+        os.makedirs(git_dir)
+
+        # Initiate mocked repository.
+        repo = mock.Mock(git_dir=git_dir)
+
+        # Initiate config files.
+        path1 = osp.join(rw_dir, "config1")
+        path2 = osp.join(rw_dir, "config2")
+        template = '[includeIf "{}:{}"]\n    path={}\n'
+
+        with open(path1, "w") as stream:
+            stream.write(template.format("gitdir", git_dir, path2))
+
+        # Ensure that config is ignored if no repo is set.
+        with GitConfigParser(path1) as config:
+            assert not config._has_includes()
+            assert config._included_paths() == []
+
+        # Ensure that config is included if path is matching git_dir.
+        with GitConfigParser(path1, repo=repo) as config:
+            assert config._has_includes()
+            assert config._included_paths() == [("path", path2)]
+
+        # Ensure that config is ignored if case is incorrect.
+        with open(path1, "w") as stream:
+            stream.write(template.format("gitdir", git_dir.upper(), path2))
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert not config._has_includes()
+            assert config._included_paths() == []
+
+        # Ensure that config is included if case is ignored.
+        with open(path1, "w") as stream:
+            stream.write(template.format("gitdir/i", git_dir.upper(), path2))
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert config._has_includes()
+            assert config._included_paths() == [("path", path2)]
+
+        # Ensure that config is included with path using glob pattern.
+        with open(path1, "w") as stream:
+            stream.write(template.format("gitdir", "**/repo1", path2))
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert config._has_includes()
+            assert config._included_paths() == [("path", path2)]
+
+        # Ensure that config is ignored if path is not matching git_dir.
+        with open(path1, "w") as stream:
+            stream.write(template.format("gitdir", "incorrect", path2))
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert not config._has_includes()
+            assert config._included_paths() == []
+
+        # Ensure that config is included if path in hierarchy.
+        with open(path1, "w") as stream:
+            stream.write(template.format("gitdir", "target1/", path2))
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert config._has_includes()
+            assert config._included_paths() == [("path", path2)]
+
+    @with_rw_directory
+    def test_conditional_includes_from_branch_name(self, rw_dir):
+        # Initiate mocked branch.
+        branch = mock.Mock()
+        type(branch).name = mock.PropertyMock(return_value="/foo/branch")
+
+        # Initiate mocked repository.
+        repo = mock.Mock(active_branch=branch)
+
+        # Initiate config files.
+        path1 = osp.join(rw_dir, "config1")
+        path2 = osp.join(rw_dir, "config2")
+        template = '[includeIf "onbranch:{}"]\n    path={}\n'
+
+        # Ensure that config is included is branch is correct.
+        with open(path1, "w") as stream:
+            stream.write(template.format("/foo/branch", path2))
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert config._has_includes()
+            assert config._included_paths() == [("path", path2)]
+
+        # Ensure that config is included is branch is incorrect.
+        with open(path1, "w") as stream:
+            stream.write(template.format("incorrect", path2))
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert not config._has_includes()
+            assert config._included_paths() == []
+
+        # Ensure that config is included with branch using glob pattern.
+        with open(path1, "w") as stream:
+            stream.write(template.format("/foo/**", path2))
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert config._has_includes()
+            assert config._included_paths() == [("path", path2)]
+
+    @with_rw_directory
+    def test_conditional_includes_from_branch_name_error(self, rw_dir):
+        # Initiate mocked repository to raise an error if HEAD is detached.
+        repo = mock.Mock()
+        type(repo).active_branch = mock.PropertyMock(side_effect=TypeError)
+
+        # Initiate config file.
+        path1 = osp.join(rw_dir, "config1")
+
+        # Ensure that config is ignored when active branch cannot be found.
+        with open(path1, "w") as stream:
+            stream.write('[includeIf "onbranch:foo"]\n    path=/path\n')
+
+        with GitConfigParser(path1, repo=repo) as config:
+            assert not config._has_includes()
+            assert config._included_paths() == []
+
+    def test_rename(self):
+        file_obj = self._to_memcache(fixture_path("git_config"))
+        with GitConfigParser(file_obj, read_only=False, merge_includes=False) as cw:
+            with self.assertRaises(ValueError):
+                cw.rename_section("doesntexist", "foo")
+            with self.assertRaises(ValueError):
+                cw.rename_section("core", "include")
+
+            nn = "bee"
+            assert cw.rename_section("core", nn) is cw
+            assert not cw.has_section("core")
+            assert len(cw.items(nn)) == 4
+
+    def test_complex_aliases(self):
+        file_obj = self._to_memcache(fixture_path(".gitconfig"))
+        with GitConfigParser(file_obj, read_only=False) as w_config:
+            self.assertEqual(
+                w_config.get("alias", "rbi"),
+                "!g() { git rebase -i origin/${1:-master} ; } ; g",
+            )
+        self.assertEqual(
+            file_obj.getvalue(),
+            self._to_memcache(fixture_path(".gitconfig")).getvalue(),
+        )
+
+    def test_config_with_extra_whitespace(self):
+        cr = GitConfigParser(fixture_path("git_config_with_extra_whitespace"), read_only=True)
+        self.assertEqual(cr.get("init", "defaultBranch"), "trunk")
+
+    def test_empty_config_value(self):
+        cr = GitConfigParser(fixture_path("git_config_with_empty_value"), read_only=True)
+
+        assert cr.get_value("core", "filemode"), "Should read keys with values"
+
+        with self.assertRaises(cp.NoOptionError):
+            cr.get_value("color", "ui")
+
+    def test_config_with_quotes(self):
+        cr = GitConfigParser(fixture_path("git_config_with_quotes"), read_only=True)
+
+        self.assertEqual(cr.get("user", "name"), "Cody Veal")
+        self.assertEqual(cr.get("user", "email"), "cveal05@gmail.com")
+
+    def test_config_with_empty_quotes(self):
+        cr = GitConfigParser(fixture_path("git_config_with_empty_quotes"), read_only=True)
+        self.assertEqual(cr.get("core", "filemode"), "", "quotes can form a literal empty string as value")
+
+    def test_config_with_quotes_with_literal_whitespace(self):
+        cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace_inside"), read_only=True)
+        self.assertEqual(cr.get("core", "commentString"), "# ")
+
+    def test_config_with_quotes_with_whitespace_outside_value(self):
+        cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace_outside"), read_only=True)
+        self.assertEqual(cr.get("init", "defaultBranch"), "trunk")
+
+    def test_config_with_quotes_containing_escapes(self):
+        """For now just suppress quote removal. But it would be good to interpret most of these."""
+        cr = GitConfigParser(fixture_path("git_config_with_quotes_escapes"), read_only=True)
+
+        # These can eventually be supported by substituting the represented character.
+        self.assertEqual(cr.get("custom", "hasnewline"), R'"first\nsecond"')
+        self.assertEqual(cr.get("custom", "hasbackslash"), R'"foo\\bar"')
+        self.assertEqual(cr.get("custom", "hasquote"), R'"ab\"cd"')
+        self.assertEqual(cr.get("custom", "hastrailingbackslash"), R'"word\\"')
+        self.assertEqual(cr.get("custom", "hasunrecognized"), R'"p\qrs"')
+
+        # It is less obvious whether and what to eventually do with this.
+        self.assertEqual(cr.get("custom", "hasunescapedquotes"), '"ab"cd"e"')
+
+        # Cases where quote removal is clearly safe should happen even after those.
+        self.assertEqual(cr.get("custom", "ordinary"), "hello world")
+
+        # Cases without quotes should still parse correctly even after those, too.
+        self.assertEqual(cr.get("custom", "unquoted"), "good evening")
+
+    def test_get_values_works_without_requiring_any_other_calls_first(self):
+        file_obj = self._to_memcache(fixture_path("git_config_multiple"))
+        cr = GitConfigParser(file_obj, read_only=True)
+        self.assertEqual(cr.get_values("section0", "option0"), ["value0"])
+        file_obj.seek(0)
+        cr = GitConfigParser(file_obj, read_only=True)
+        self.assertEqual(cr.get_values("section1", "option1"), ["value1a", "value1b"])
+        file_obj.seek(0)
+        cr = GitConfigParser(file_obj, read_only=True)
+        self.assertEqual(cr.get_values("section1", "other_option1"), ["other_value1"])
+
+    def test_multiple_values(self):
+        file_obj = self._to_memcache(fixture_path("git_config_multiple"))
+        with GitConfigParser(file_obj, read_only=False) as cw:
+            self.assertEqual(cw.get("section0", "option0"), "value0")
+            self.assertEqual(cw.get_values("section0", "option0"), ["value0"])
+            self.assertEqual(cw.items("section0"), [("option0", "value0")])
+
+            # Where there are multiple values, "get" returns the last.
+            self.assertEqual(cw.get("section1", "option1"), "value1b")
+            self.assertEqual(cw.get_values("section1", "option1"), ["value1a", "value1b"])
+            self.assertEqual(
+                cw.items("section1"),
+                [("option1", "value1b"), ("other_option1", "other_value1")],
+            )
+            self.assertEqual(
+                cw.items_all("section1"),
+                [
+                    ("option1", ["value1a", "value1b"]),
+                    ("other_option1", ["other_value1"]),
+                ],
+            )
+            with self.assertRaises(KeyError):
+                cw.get_values("section1", "missing")
+
+            self.assertEqual(cw.get_values("section1", "missing", 1), [1])
+            self.assertEqual(cw.get_values("section1", "missing", "s"), ["s"])
+
+    def test_multiple_values_rename(self):
+        file_obj = self._to_memcache(fixture_path("git_config_multiple"))
+        with GitConfigParser(file_obj, read_only=False) as cw:
+            cw.rename_section("section1", "section2")
+            cw.write()
+            file_obj.seek(0)
+            cr = GitConfigParser(file_obj, read_only=True)
+            self.assertEqual(cr.get_value("section2", "option1"), "value1b")
+            self.assertEqual(cr.get_values("section2", "option1"), ["value1a", "value1b"])
+            self.assertEqual(
+                cr.items("section2"),
+                [("option1", "value1b"), ("other_option1", "other_value1")],
+            )
+            self.assertEqual(
+                cr.items_all("section2"),
+                [
+                    ("option1", ["value1a", "value1b"]),
+                    ("other_option1", ["other_value1"]),
+                ],
+            )
+
+    def test_multiple_to_single(self):
+        file_obj = self._to_memcache(fixture_path("git_config_multiple"))
+        with GitConfigParser(file_obj, read_only=False) as cw:
+            cw.set_value("section1", "option1", "value1c")
+
+            cw.write()
+            file_obj.seek(0)
+            cr = GitConfigParser(file_obj, read_only=True)
+            self.assertEqual(cr.get_value("section1", "option1"), "value1c")
+            self.assertEqual(cr.get_values("section1", "option1"), ["value1c"])
+            self.assertEqual(
+                cr.items("section1"),
+                [("option1", "value1c"), ("other_option1", "other_value1")],
+            )
+            self.assertEqual(
+                cr.items_all("section1"),
+                [("option1", ["value1c"]), ("other_option1", ["other_value1"])],
+            )
+
+    def test_single_to_multiple(self):
+        file_obj = self._to_memcache(fixture_path("git_config_multiple"))
+        with GitConfigParser(file_obj, read_only=False) as cw:
+            cw.add_value("section1", "other_option1", "other_value1a")
+
+            cw.write()
+            file_obj.seek(0)
+            cr = GitConfigParser(file_obj, read_only=True)
+            self.assertEqual(cr.get_value("section1", "option1"), "value1b")
+            self.assertEqual(cr.get_values("section1", "option1"), ["value1a", "value1b"])
+            self.assertEqual(cr.get_value("section1", "other_option1"), "other_value1a")
+            self.assertEqual(
+                cr.get_values("section1", "other_option1"),
+                ["other_value1", "other_value1a"],
+            )
+            self.assertEqual(
+                cr.items("section1"),
+                [("option1", "value1b"), ("other_option1", "other_value1a")],
+            )
+            self.assertEqual(
+                cr.items_all("section1"),
+                [
+                    ("option1", ["value1a", "value1b"]),
+                    ("other_option1", ["other_value1", "other_value1a"]),
+                ],
+            )
+
+    def test_add_to_multiple(self):
+        file_obj = self._to_memcache(fixture_path("git_config_multiple"))
+        with GitConfigParser(file_obj, read_only=False) as cw:
+            cw.add_value("section1", "option1", "value1c")
+            cw.write()
+            file_obj.seek(0)
+            cr = GitConfigParser(file_obj, read_only=True)
+            self.assertEqual(cr.get_value("section1", "option1"), "value1c")
+            self.assertEqual(cr.get_values("section1", "option1"), ["value1a", "value1b", "value1c"])
+            self.assertEqual(
+                cr.items("section1"),
+                [("option1", "value1c"), ("other_option1", "other_value1")],
+            )
+            self.assertEqual(
+                cr.items_all("section1"),
+                [
+                    ("option1", ["value1a", "value1b", "value1c"]),
+                    ("other_option1", ["other_value1"]),
+                ],
+            )
+
+    def test_setlast(self):
+        # Test directly, not covered by higher-level tests.
+        omd = _OMD()
+        omd.setlast("key", "value1")
+        self.assertEqual(omd["key"], "value1")
+        self.assertEqual(omd.getall("key"), ["value1"])
+        omd.setlast("key", "value2")
+        self.assertEqual(omd["key"], "value2")
+        self.assertEqual(omd.getall("key"), ["value2"])
diff --git a/test/test_db.py b/test/test_db.py
new file mode 100644
index 000000000..72d63b44b
--- /dev/null
+++ b/test/test_db.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import os.path as osp
+
+from git.db import GitCmdObjectDB
+from git.exc import BadObject
+from git.util import bin_to_hex
+
+from test.lib import TestBase
+
+
+class TestDB(TestBase):
+    def test_base(self):
+        gdb = GitCmdObjectDB(osp.join(self.rorepo.git_dir, "objects"), self.rorepo.git)
+
+        # Partial to complete - works with everything.
+        hexsha = bin_to_hex(gdb.partial_to_complete_sha_hex("0.1.6"))
+        assert len(hexsha) == 40
+
+        assert bin_to_hex(gdb.partial_to_complete_sha_hex(hexsha[:20])) == hexsha
+
+        # Fails with BadObject.
+        for invalid_rev in ("0000", "bad/ref", "super bad"):
+            self.assertRaises(BadObject, gdb.partial_to_complete_sha_hex, invalid_rev)
diff --git a/test/test_diff.py b/test/test_diff.py
new file mode 100644
index 000000000..612fbd9e0
--- /dev/null
+++ b/test/test_diff.py
@@ -0,0 +1,550 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import gc
+import os.path as osp
+import shutil
+import sys
+import tempfile
+
+import ddt
+import pytest
+
+from git import NULL_TREE, Diff, DiffIndex, Diffable, GitCommandError, Repo, Submodule
+from git.cmd import Git
+
+from test.lib import StringProcessAdapter, TestBase, fixture, with_rw_directory
+
+
+def to_raw(input):
+    return input.replace(b"\t", b"\x00")
+
+
+@ddt.ddt
+class TestDiff(TestBase):
+    def setUp(self):
+        self.repo_dir = tempfile.mkdtemp()
+        self.submodule_dir = tempfile.mkdtemp()
+
+    def tearDown(self):
+        gc.collect()
+        shutil.rmtree(self.repo_dir)
+        shutil.rmtree(self.submodule_dir)
+
+    def _assert_diff_format(self, diffs):
+        # Verify that the format of the diff is sane.
+        for diff in diffs:
+            if diff.a_mode:
+                assert isinstance(diff.a_mode, int)
+            if diff.b_mode:
+                assert isinstance(diff.b_mode, int)
+
+            if diff.a_blob:
+                assert not diff.a_blob.path.endswith("\n")
+            if diff.b_blob:
+                assert not diff.b_blob.path.endswith("\n")
+        # END for each diff
+        return diffs
+
+    @with_rw_directory
+    def test_diff_with_staged_file(self, rw_dir):
+        # SET UP INDEX WITH MULTIPLE STAGES
+        r = Repo.init(rw_dir)
+        fp = osp.join(rw_dir, "hello.txt")
+        with open(fp, "w") as fs:
+            fs.write("hello world")
+        r.git.add(Git.polish_url(fp))
+        r.git.commit(message="init")
+
+        with open(fp, "w") as fs:
+            fs.write("Hola Mundo")
+        r.git.add(Git.polish_url(fp))
+        self.assertEqual(
+            len(r.index.diff("HEAD", create_patch=True)),
+            1,
+            "create_patch should generate patch of diff to HEAD",
+        )
+        r.git.commit(message="change on master")
+        self.assertEqual(
+            len(r.index.diff("HEAD", create_patch=True)),
+            0,
+            "create_patch should generate no patch, already on HEAD",
+        )
+
+        r.git.checkout("HEAD~1", b="topic")
+        with open(fp, "w") as fs:
+            fs.write("Hallo Welt")
+        r.git.commit(all=True, message="change on topic branch")
+
+        # There must be a merge conflict.
+        with self.assertRaises(GitCommandError):
+            r.git.cherry_pick("master")
+
+        # Now do the actual testing - this should just work.
+        self.assertEqual(len(r.index.diff(None)), 2)
+
+        self.assertEqual(
+            len(r.index.diff(None, create_patch=True)),
+            0,
+            "This should work, but doesn't right now ... it's OK",
+        )
+
+    def test_list_from_string_new_mode(self):
+        output = StringProcessAdapter(fixture("diff_new_mode"))
+        diffs = Diff._index_from_patch_format(self.rorepo, output)
+        self._assert_diff_format(diffs)
+
+        self.assertEqual(1, len(diffs))
+        self.assertEqual(8, len(diffs[0].diff.splitlines()))
+
+    def test_diff_with_rename(self):
+        output = StringProcessAdapter(fixture("diff_rename"))
+        diffs = Diff._index_from_patch_format(self.rorepo, output)
+        self._assert_diff_format(diffs)
+
+        self.assertEqual(1, len(diffs))
+
+        diff = diffs[0]
+        self.assertTrue(diff.renamed_file)
+        self.assertTrue(diff.renamed)
+        self.assertEqual(diff.rename_from, "Jérôme")
+        self.assertEqual(diff.rename_to, "müller")
+        self.assertEqual(diff.raw_rename_from, b"J\xc3\xa9r\xc3\xb4me")
+        self.assertEqual(diff.raw_rename_to, b"m\xc3\xbcller")
+        assert isinstance(str(diff), str)
+
+        output = StringProcessAdapter(to_raw(fixture("diff_rename_raw")))
+        diffs = Diff._index_from_raw_format(self.rorepo, output)
+        self.assertEqual(len(diffs), 1)
+        diff = diffs[0]
+        self.assertIsNotNone(diff.renamed_file)
+        self.assertIsNotNone(diff.renamed)
+        self.assertEqual(diff.rename_from, "this")
+        self.assertEqual(diff.rename_to, "that")
+        self.assertEqual(diff.change_type, "R")
+        self.assertEqual(diff.score, 100)
+        self.assertEqual(len(list(diffs.iter_change_type("R"))), 1)
+
+    def test_diff_with_copied_file(self):
+        output = StringProcessAdapter(fixture("diff_copied_mode"))
+        diffs = Diff._index_from_patch_format(self.rorepo, output)
+        self._assert_diff_format(diffs)
+
+        self.assertEqual(1, len(diffs))
+
+        diff = diffs[0]
+        self.assertTrue(diff.copied_file)
+        self.assertTrue(diff.a_path, "test1.txt")
+        self.assertTrue(diff.b_path, "test2.txt")
+        assert isinstance(str(diff), str)
+
+        output = StringProcessAdapter(to_raw(fixture("diff_copied_mode_raw")))
+        diffs = Diff._index_from_raw_format(self.rorepo, output)
+        self.assertEqual(len(diffs), 1)
+        diff = diffs[0]
+        self.assertEqual(diff.change_type, "C")
+        self.assertEqual(diff.score, 100)
+        self.assertEqual(diff.a_path, "test1.txt")
+        self.assertEqual(diff.b_path, "test2.txt")
+        self.assertEqual(len(list(diffs.iter_change_type("C"))), 1)
+
+    def test_diff_with_change_in_type(self):
+        output = StringProcessAdapter(fixture("diff_change_in_type"))
+        diffs = Diff._index_from_patch_format(self.rorepo, output)
+        self._assert_diff_format(diffs)
+        self.assertEqual(2, len(diffs))
+
+        diff = diffs[0]
+        self.assertIsNotNone(diff.deleted_file)
+        self.assertEqual(diff.a_path, "this")
+        self.assertEqual(diff.b_path, "this")
+        assert isinstance(str(diff), str)
+
+        diff = diffs[1]
+        self.assertEqual(diff.a_path, None)
+        self.assertEqual(diff.b_path, "this")
+        self.assertIsNotNone(diff.new_file)
+        assert isinstance(str(diff), str)
+
+        output = StringProcessAdapter(to_raw(fixture("diff_change_in_type_raw")))
+        diffs = Diff._index_from_raw_format(self.rorepo, output)
+        self.assertEqual(len(diffs), 1)
+        diff = diffs[0]
+        self.assertEqual(diff.rename_from, None)
+        self.assertEqual(diff.rename_to, None)
+        self.assertEqual(diff.change_type, "T")
+        self.assertEqual(len(list(diffs.iter_change_type("T"))), 1)
+
+    def test_diff_of_modified_files_not_added_to_the_index(self):
+        output = StringProcessAdapter(to_raw(fixture("diff_abbrev-40_full-index_M_raw_no-color")))
+        diffs = Diff._index_from_raw_format(self.rorepo, output)
+
+        self.assertEqual(len(diffs), 1, "one modification")
+        self.assertEqual(len(list(diffs.iter_change_type("M"))), 1, "one modification")
+        self.assertEqual(diffs[0].change_type, "M")
+        self.assertIsNone(
+            diffs[0].b_blob,
+        )
+
+    @ddt.data(
+        (Diff._index_from_patch_format, "diff_patch_binary"),
+        (Diff._index_from_raw_format, "diff_raw_binary"),
+    )
+    def test_binary_diff(self, case):
+        method, file_name = case
+        res = method(None, StringProcessAdapter(fixture(file_name)))
+        self.assertEqual(len(res), 1)
+        self.assertEqual(len(list(res.iter_change_type("M"))), 1)
+        if res[0].diff:
+            self.assertEqual(
+                res[0].diff,
+                b"Binary files a/rps and b/rps differ\n",
+                "in patch mode, we get a diff text",
+            )
+            self.assertIsNotNone(str(res[0]), "This call should just work")
+
+    def test_diff_index(self):
+        output = StringProcessAdapter(fixture("diff_index_patch"))
+        res = Diff._index_from_patch_format(None, output)
+        self.assertEqual(len(res), 6)
+        for dr in res:
+            self.assertTrue(dr.diff.startswith(b"@@"), dr)
+            self.assertIsNotNone(str(dr), "Diff to string conversion should be possible")
+        # END for each diff
+
+        dr = res[3]
+        assert dr.diff.endswith(b"+Binary files a/rps and b/rps differ\n")
+
+    def test_diff_index_raw_format(self):
+        output = StringProcessAdapter(fixture("diff_index_raw"))
+        res = Diff._index_from_raw_format(None, output)
+        self.assertIsNotNone(res[0].deleted_file)
+        self.assertIsNone(
+            res[0].b_path,
+        )
+
+    def test_diff_file_with_colon(self):
+        output = fixture("diff_file_with_colon")
+        res = []
+        Diff._handle_diff_line(output, None, res)
+        self.assertEqual(len(res), 3)
+
+    def test_empty_diff(self):
+        res = []
+        Diff._handle_diff_line(b"", None, res)
+        self.assertEqual(res, [])
+
+    def test_diff_initial_commit(self):
+        initial_commit = self.rorepo.commit("33ebe7acec14b25c5f84f35a664803fcab2f7781")
+
+        # Without creating a patch...
+        diff_index = initial_commit.diff(NULL_TREE)
+        self.assertEqual(diff_index[0].b_path, "CHANGES")
+        self.assertIsNotNone(diff_index[0].new_file)
+        self.assertEqual(diff_index[0].diff, "")
+
+        # ...and with creating a patch.
+        diff_index = initial_commit.diff(NULL_TREE, create_patch=True)
+        self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path))
+        self.assertEqual(diff_index[0].b_path, "CHANGES", repr(diff_index[0].b_path))
+        self.assertIsNotNone(diff_index[0].new_file)
+        self.assertEqual(diff_index[0].diff, fixture("diff_initial"))
+
+    def test_diff_unsafe_paths(self):
+        output = StringProcessAdapter(fixture("diff_patch_unsafe_paths"))
+        res = Diff._index_from_patch_format(None, output)
+
+        # The "Additions"
+        self.assertEqual(res[0].b_path, "path/ starting with a space")
+        self.assertEqual(res[1].b_path, 'path/"with-quotes"')
+        self.assertEqual(res[2].b_path, "path/'with-single-quotes'")
+        self.assertEqual(res[3].b_path, "path/ending in a space ")
+        self.assertEqual(res[4].b_path, "path/with\ttab")
+        self.assertEqual(res[5].b_path, "path/with\nnewline")
+        self.assertEqual(res[6].b_path, "path/with spaces")
+        self.assertEqual(res[7].b_path, "path/with-question-mark?")
+        self.assertEqual(res[8].b_path, "path/¯\\_(ツ)_|¯")
+        self.assertEqual(res[9].b_path, "path/💩.txt")
+        self.assertEqual(res[9].b_rawpath, b"path/\xf0\x9f\x92\xa9.txt")
+        self.assertEqual(res[10].b_path, "path/�-invalid-unicode-path.txt")
+        self.assertEqual(res[10].b_rawpath, b"path/\x80-invalid-unicode-path.txt")
+
+        # The "Moves"
+        # NOTE: The path prefixes "a/" and "b/" here are legit! We're actually verifying
+        # that it's not "a/a/" that shows up; see the fixture data.
+        self.assertEqual(res[11].a_path, "a/with spaces")  # NOTE: path "a/"" legit!
+        self.assertEqual(res[11].b_path, "b/with some spaces")  # NOTE: path "b/"" legit!
+        self.assertEqual(res[12].a_path, "a/ending in a space ")
+        self.assertEqual(res[12].b_path, "b/ending with space ")
+        self.assertEqual(res[13].a_path, 'a/"with-quotes"')
+        self.assertEqual(res[13].b_path, 'b/"with even more quotes"')
+
+    def test_diff_patch_format(self):
+        # Test all of the 'old' format diffs for completeness - it should at least be
+        # able to deal with it.
+        fixtures = (
+            "diff_2",
+            "diff_2f",
+            "diff_f",
+            "diff_i",
+            "diff_mode_only",
+            "diff_new_mode",
+            "diff_numstat",
+            "diff_p",
+            "diff_rename",
+            "diff_tree_numstat_root",
+            "diff_patch_unsafe_paths",
+        )
+
+        for fixture_name in fixtures:
+            diff_proc = StringProcessAdapter(fixture(fixture_name))
+            Diff._index_from_patch_format(self.rorepo, diff_proc)
+        # END for each fixture
+
+    def test_diff_with_spaces(self):
+        data = StringProcessAdapter(fixture("diff_file_with_spaces"))
+        diff_index = Diff._index_from_patch_format(self.rorepo, data)
+        self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path))
+        self.assertEqual(diff_index[0].b_path, "file with spaces", repr(diff_index[0].b_path))
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason='"Access is denied" when tearDown calls shutil.rmtree',
+        raises=PermissionError,
+    )
+    def test_diff_submodule(self):
+        """Test that diff is able to correctly diff commits that cover submodule changes"""
+        # Init a temp git repo that will be referenced as a submodule.
+        sub = Repo.init(self.submodule_dir)
+        with open(self.submodule_dir + "/subfile", "w") as sub_subfile:
+            sub_subfile.write("")
+        sub.index.add(["subfile"])
+        sub.index.commit("first commit")
+
+        # Init a temp git repo that will incorporate the submodule.
+        repo = Repo.init(self.repo_dir)
+        with open(self.repo_dir + "/test", "w") as foo_test:
+            foo_test.write("")
+        repo.index.add(["test"])
+        Submodule.add(repo, "subtest", "sub", url="file://" + self.submodule_dir)
+        repo.index.commit("first commit")
+        repo.create_tag("1")
+
+        # Add a commit to the submodule.
+        submodule = repo.submodule("subtest")
+        with open(self.repo_dir + "/sub/subfile", "w") as foo_sub_subfile:
+            foo_sub_subfile.write("blub")
+        submodule.module().index.add(["subfile"])
+        submodule.module().index.commit("changed subfile")
+        submodule.binsha = submodule.module().head.commit.binsha
+
+        # Commit submodule updates in parent repo.
+        repo.index.add([submodule])
+        repo.index.commit("submodule changed")
+        repo.create_tag("2")
+
+        diff = repo.commit("1").diff(repo.commit("2"))[0]
+        # If diff is unable to find the commit hashes (looks in wrong repo) the
+        # *_blob.size property will be a string containing exception text, an int
+        # indicates success.
+        self.assertIsInstance(diff.a_blob.size, int)
+        self.assertIsInstance(diff.b_blob.size, int)
+
+    def test_diff_interface(self):
+        """Test a few variations of the main diff routine."""
+        assertion_map = {}
+        for i, commit in enumerate(self.rorepo.iter_commits("0.1.6", max_count=2)):
+            diff_item = commit
+            if i % 2 == 0:
+                diff_item = commit.tree
+            # END use tree every second item
+
+            for other in (None, NULL_TREE, commit.INDEX, commit.parents[0]):
+                for paths in (None, "CHANGES", ("CHANGES", "lib")):
+                    for create_patch in range(2):
+                        diff_index = diff_item.diff(other=other, paths=paths, create_patch=create_patch)
+                        assert isinstance(diff_index, DiffIndex)
+
+                        if diff_index:
+                            self._assert_diff_format(diff_index)
+                            for ct in DiffIndex.change_type:
+                                key = "ct_%s" % ct
+                                assertion_map.setdefault(key, 0)
+                                assertion_map[key] = assertion_map[key] + len(list(diff_index.iter_change_type(ct)))
+                            # END for each changetype
+
+                            # Check entries.
+                            diff_set = set()
+                            diff_set.add(diff_index[0])
+                            diff_set.add(diff_index[0])
+                            self.assertEqual(len(diff_set), 1)
+                            self.assertEqual(diff_index[0], diff_index[0])
+                            self.assertFalse(diff_index[0] != diff_index[0])
+
+                            for dr in diff_index:
+                                self.assertIsNotNone(
+                                    str(dr),
+                                    "Diff to string conversion should be possible",
+                                )
+                        # END diff index checking
+                    # END for each patch option
+                # END for each path option
+            # END for each other side
+        # END for each commit
+
+        # Assert that we could always find at least one instance of the members we can
+        # iterate in the diff index - if not this indicates its not working correctly or
+        # our test does not span the whole range of possibilities.
+        for key, value in assertion_map.items():
+            self.assertIsNotNone(value, "Did not find diff for %s" % key)
+        # END for each iteration type
+
+        # Test path not existing in the index - should be ignored.
+        c = self.rorepo.head.commit
+        cp = c.parents[0]
+        diff_index = c.diff(cp, ["does/not/exist"])
+        self.assertEqual(len(diff_index), 0)
+
+    def test_diff_interface_stability(self):
+        """Test that the Diffable.Index redefinition should not break compatibility."""
+        self.assertIs(
+            Diffable.Index,
+            Diffable.INDEX,
+            "The old and new class attribute names must be aliases.",
+        )
+        self.assertIs(
+            type(Diffable.INDEX).__eq__,
+            object.__eq__,
+            "Equality comparison must be reference-based.",
+        )
+
+    @with_rw_directory
+    def test_rename_override(self, rw_dir):
+        """Test disabling of diff rename detection."""
+        # Create and commit file_a.txt.
+        repo = Repo.init(rw_dir)
+        file_a = osp.join(rw_dir, "file_a.txt")
+        with open(file_a, "w", encoding="utf-8") as outfile:
+            outfile.write("hello world\n")
+        repo.git.add(Git.polish_url(file_a))
+        repo.git.commit(message="Added file_a.txt")
+
+        # Remove file_a.txt.
+        repo.git.rm(Git.polish_url(file_a))
+
+        # Create and commit file_b.txt with similarity index of 52.
+        file_b = osp.join(rw_dir, "file_b.txt")
+        with open(file_b, "w", encoding="utf-8") as outfile:
+            outfile.write("hello world\nhello world")
+        repo.git.add(Git.polish_url(file_b))
+        repo.git.commit(message="Removed file_a.txt. Added file_b.txt")
+
+        commit_a = repo.commit("HEAD")
+        commit_b = repo.commit("HEAD~1")
+
+        # Check default diff command with renamed files enabled.
+        diffs = commit_b.diff(commit_a)
+        self.assertEqual(1, len(diffs))
+        diff = diffs[0]
+        self.assertEqual(True, diff.renamed_file)
+        self.assertEqual("file_a.txt", diff.rename_from)
+        self.assertEqual("file_b.txt", diff.rename_to)
+
+        # Check diff with rename files disabled.
+        diffs = commit_b.diff(commit_a, no_renames=True)
+        self.assertEqual(2, len(diffs))
+
+        # Check fileA.txt deleted.
+        diff = diffs[0]
+        self.assertEqual(True, diff.deleted_file)
+        self.assertEqual("file_a.txt", diff.a_path)
+
+        # Check fileB.txt added.
+        diff = diffs[1]
+        self.assertEqual(True, diff.new_file)
+        self.assertEqual("file_b.txt", diff.a_path)
+
+        # Check diff with high similarity index.
+        diffs = commit_b.diff(commit_a, split_single_char_options=False, M="75%")
+        self.assertEqual(2, len(diffs))
+
+        # Check fileA.txt deleted.
+        diff = diffs[0]
+        self.assertEqual(True, diff.deleted_file)
+        self.assertEqual("file_a.txt", diff.a_path)
+
+        # Check fileB.txt added.
+        diff = diffs[1]
+        self.assertEqual(True, diff.new_file)
+        self.assertEqual("file_b.txt", diff.a_path)
+
+        # Check diff with low similarity index.
+        diffs = commit_b.diff(commit_a, split_single_char_options=False, M="40%")
+        self.assertEqual(1, len(diffs))
+        diff = diffs[0]
+        self.assertEqual(True, diff.renamed_file)
+        self.assertEqual("file_a.txt", diff.rename_from)
+        self.assertEqual("file_b.txt", diff.rename_to)
+
+    @with_rw_directory
+    def test_diff_patch_with_external_engine(self, rw_dir):
+        repo = Repo.init(rw_dir)
+        gitignore = osp.join(rw_dir, ".gitignore")
+
+        # First commit
+        with open(gitignore, "w") as f:
+            f.write("first_line\n")
+        repo.git.add(".gitignore")
+        repo.index.commit("first commit")
+
+        # Adding second line and committing
+        with open(gitignore, "a") as f:
+            f.write("second_line\n")
+        repo.git.add(".gitignore")
+        repo.index.commit("second commit")
+
+        # Adding third line and staging
+        with open(gitignore, "a") as f:
+            f.write("third_line\n")
+        repo.git.add(".gitignore")
+
+        # Adding fourth line
+        with open(gitignore, "a") as f:
+            f.write("fourth_line\n")
+
+        # Set the external diff engine
+        with repo.config_writer(config_level="repository") as writer:
+            writer.set_value("diff", "external", "bogus_diff_engine")
+
+        head_against_head = repo.head.commit.diff("HEAD^", create_patch=True)
+        self.assertEqual(len(head_against_head), 1)
+        head_against_index = repo.head.commit.diff(create_patch=True)
+        self.assertEqual(len(head_against_index), 1)
+        head_against_working_tree = repo.head.commit.diff(None, create_patch=True)
+        self.assertEqual(len(head_against_working_tree), 1)
+
+        index_against_head = repo.index.diff("HEAD", create_patch=True)
+        self.assertEqual(len(index_against_head), 1)
+        index_against_working_tree = repo.index.diff(None, create_patch=True)
+        self.assertEqual(len(index_against_working_tree), 1)
+
+    @with_rw_directory
+    def test_beginning_space(self, rw_dir):
+        # Create a file beginning by a whitespace
+        repo = Repo.init(rw_dir)
+        file = osp.join(rw_dir, " file.txt")
+        with open(file, "w") as f:
+            f.write("hello world")
+        repo.git.add(Git.polish_url(file))
+        repo.index.commit("first commit")
+
+        # Diff the commit with an empty tree
+        # and check the paths
+        diff_index = repo.head.commit.diff(NULL_TREE)
+        d = diff_index[0]
+        a_path = d.a_path
+        b_path = d.b_path
+        self.assertEqual(a_path, " file.txt")
+        self.assertEqual(b_path, " file.txt")
diff --git a/test/test_docs.py b/test/test_docs.py
new file mode 100644
index 000000000..cc0bbf26a
--- /dev/null
+++ b/test/test_docs.py
@@ -0,0 +1,521 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import gc
+import os
+import os.path
+import sys
+
+import pytest
+
+from test.lib import TestBase
+from test.lib.helper import with_rw_directory
+
+
+class Tutorials(TestBase):
+    def tearDown(self):
+        gc.collect()
+
+    # ACTUALLY skipped by git.util.rmtree (in local onerror function), from the last
+    # call to it via git.objects.submodule.base.Submodule.remove
+    # (at "handle separate bare repository"), line 1062.
+    #
+    # @skipIf(HIDE_WINDOWS_KNOWN_ERRORS,
+    #         "FIXME: helper.wrapper fails with: PermissionError: [WinError 5] Access is denied: "
+    #         "'C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\test_work_tree_unsupportedryfa60di\\master_repo\\.git\\objects\\pack\\pack-bc9e0787aef9f69e1591ef38ea0a6f566ec66fe3.idx")  # noqa: E501
+    @with_rw_directory
+    def test_init_repo_object(self, rw_dir):
+        # [1-test_init_repo_object]
+        from git import Repo
+
+        # rorepo is a Repo instance pointing to the git-python repository.
+        # For all you know, the first argument to Repo is a path to the repository you
+        # want to work with.
+        repo = Repo(self.rorepo.working_tree_dir)
+        assert not repo.bare
+        # ![1-test_init_repo_object]
+
+        # [2-test_init_repo_object]
+        bare_repo = Repo.init(os.path.join(rw_dir, "bare-repo"), bare=True)
+        assert bare_repo.bare
+        # ![2-test_init_repo_object]
+
+        # [3-test_init_repo_object]
+        repo.config_reader()  # Get a config reader for read-only access.
+        with repo.config_writer():  # Get a config writer to change configuration.
+            pass  # Call release() to be sure changes are written and locks are released.
+        # ![3-test_init_repo_object]
+
+        # [4-test_init_repo_object]
+        assert not bare_repo.is_dirty()  # Check the dirty state.
+        repo.untracked_files  # Retrieve a list of untracked files.
+        # ['my_untracked_file']
+        # ![4-test_init_repo_object]
+
+        # [5-test_init_repo_object]
+        cloned_repo = repo.clone(os.path.join(rw_dir, "to/this/path"))
+        assert cloned_repo.__class__ is Repo  # Clone an existing repository.
+        assert Repo.init(os.path.join(rw_dir, "path/for/new/repo")).__class__ is Repo
+        # ![5-test_init_repo_object]
+
+        # [6-test_init_repo_object]
+        with open(os.path.join(rw_dir, "repo.tar"), "wb") as fp:
+            repo.archive(fp)
+        # ![6-test_init_repo_object]
+
+        # repository paths
+        # [7-test_init_repo_object]
+        assert os.path.isdir(cloned_repo.working_tree_dir)  # Directory with your work files.
+        assert cloned_repo.git_dir.startswith(cloned_repo.working_tree_dir)  # Directory containing the git repository.
+        assert bare_repo.working_tree_dir is None  # Bare repositories have no working tree.
+        # ![7-test_init_repo_object]
+
+        # heads, tags and references
+        # heads are branches in git-speak
+        # [8-test_init_repo_object]
+        self.assertEqual(
+            repo.head.ref,
+            repo.heads.master,  # head is a sym-ref pointing to master.
+            "It's ok if TC not running from `master`.",
+        )
+        self.assertEqual(repo.tags["0.3.5"], repo.tag("refs/tags/0.3.5"))  # You can access tags in various ways too.
+        self.assertEqual(repo.refs.master, repo.heads["master"])  # .refs provides all refs, i.e. heads...
+
+        if "TRAVIS" not in os.environ:
+            self.assertEqual(repo.refs["origin/master"], repo.remotes.origin.refs.master)  # ... remotes ...
+        self.assertEqual(repo.refs["0.3.5"], repo.tags["0.3.5"])  # ... and tags.
+        # ![8-test_init_repo_object]
+
+        # Create a new head/branch.
+        # [9-test_init_repo_object]
+        new_branch = cloned_repo.create_head("feature")  # Create a new branch ...
+        assert cloned_repo.active_branch != new_branch  # which wasn't checked out yet ...
+        self.assertEqual(new_branch.commit, cloned_repo.active_branch.commit)  # pointing to the checked-out commit.
+        # It's easy to let a branch point to the previous commit, without affecting anything else.
+        # Each reference provides access to the git object it points to, usually commits.
+        assert new_branch.set_commit("HEAD~1").commit == cloned_repo.active_branch.commit.parents[0]
+        # ![9-test_init_repo_object]
+
+        # Create a new tag reference.
+        # [10-test_init_repo_object]
+        past = cloned_repo.create_tag(
+            "past",
+            ref=new_branch,
+            message="This is a tag-object pointing to %s" % new_branch.name,
+        )
+        self.assertEqual(past.commit, new_branch.commit)  # The tag points to the specified commit
+        assert past.tag.message.startswith("This is")  # and its object carries the message provided.
+
+        now = cloned_repo.create_tag("now")  # This is a tag-reference. It may not carry meta-data.
+        assert now.tag is None
+        # ![10-test_init_repo_object]
+
+        # Object handling
+        # [11-test_init_repo_object]
+        assert now.commit.message != past.commit.message
+        # You can read objects directly through binary streams, no working tree required.
+        assert (now.commit.tree / "VERSION").data_stream.read().decode("ascii").startswith("3")
+
+        # You can traverse trees as well to handle all contained files of a particular commit.
+        file_count = 0
+        tree_count = 0
+        tree = past.commit.tree
+        for item in tree.traverse():
+            file_count += item.type == "blob"
+            tree_count += item.type == "tree"
+        assert file_count and tree_count  # We have accumulated all directories and files.
+        self.assertEqual(len(tree.blobs) + len(tree.trees), len(tree))  # A tree is iterable on its children.
+        # ![11-test_init_repo_object]
+
+        # Remotes allow handling push, pull and fetch operations.
+        # [12-test_init_repo_object]
+        from git import RemoteProgress
+
+        class MyProgressPrinter(RemoteProgress):
+            def update(self, op_code, cur_count, max_count=None, message=""):
+                print(
+                    op_code,
+                    cur_count,
+                    max_count,
+                    cur_count / (max_count or 100.0),
+                    message or "NO MESSAGE",
+                )
+
+        self.assertEqual(len(cloned_repo.remotes), 1)  # We have been cloned, so should be one remote.
+        self.assertEqual(len(bare_repo.remotes), 0)  # This one was just initialized.
+        origin = bare_repo.create_remote("origin", url=cloned_repo.working_tree_dir)
+        assert origin.exists()
+        for fetch_info in origin.fetch(progress=MyProgressPrinter()):
+            print("Updated %s to %s" % (fetch_info.ref, fetch_info.commit))
+        # Create a local branch at the latest fetched master. We specify the name
+        # statically, but you have all information to do it programmatically as well.
+        bare_master = bare_repo.create_head("master", origin.refs.master)
+        bare_repo.head.set_reference(bare_master)
+        assert not bare_repo.delete_remote(origin).exists()
+        # push and pull behave very similarly.
+        # ![12-test_init_repo_object]
+
+        # index
+        # [13-test_init_repo_object]
+        self.assertEqual(new_branch.checkout(), cloned_repo.active_branch)  # Checking out branch adjusts the wtree.
+        self.assertEqual(new_branch.commit, past.commit)  # Now the past is checked out.
+
+        new_file_path = os.path.join(cloned_repo.working_tree_dir, "my-new-file")
+        open(new_file_path, "wb").close()  # Create new file in working tree.
+        cloned_repo.index.add([new_file_path])  # Add it to the index.
+        # Commit the changes to deviate masters history.
+        cloned_repo.index.commit("Added a new file in the past - for later merge")
+
+        # Prepare a merge.
+        master = cloned_repo.heads.master  # Right-hand side is ahead of us, in the future.
+        merge_base = cloned_repo.merge_base(new_branch, master)  # Allows for a three-way merge.
+        cloned_repo.index.merge_tree(master, base=merge_base)  # Write the merge result into index.
+        cloned_repo.index.commit(
+            "Merged past and now into future ;)",
+            parent_commits=(new_branch.commit, master.commit),
+        )
+
+        # Now new_branch is ahead of master, which probably should be checked out and reset softly.
+        # Note that all these operations didn't touch the working tree, as we managed it ourselves.
+        # This definitely requires you to know what you are doing! :)
+        assert os.path.basename(new_file_path) in new_branch.commit.tree  # New file is now in tree.
+        master.commit = new_branch.commit  # Let master point to most recent commit.
+        cloned_repo.head.reference = master  # We adjusted just the reference, not the working tree or index.
+        # ![13-test_init_repo_object]
+
+        # submodules
+
+        # [14-test_init_repo_object]
+        # Create a new submodule and check it out on the spot, setup to track master
+        # branch of `bare_repo`. As our GitPython repository has submodules already that
+        # point to GitHub, make sure we don't interact with them.
+        for sm in cloned_repo.submodules:
+            assert not sm.remove().exists()  # after removal, the sm doesn't exist anymore
+        sm = cloned_repo.create_submodule("mysubrepo", "path/to/subrepo", url=bare_repo.git_dir, branch="master")
+
+        # .gitmodules was written and added to the index, which is now being committed.
+        cloned_repo.index.commit("Added submodule")
+        assert sm.exists() and sm.module_exists()  # This submodule is definitely available.
+        sm.remove(module=True, configuration=False)  # Remove the working tree.
+        assert sm.exists() and not sm.module_exists()  # The submodule itself is still available.
+
+        # Update all submodules, non-recursively to save time. This method is very powerful, go have a look.
+        cloned_repo.submodule_update(recursive=False)
+        assert sm.module_exists()  # The submodule's working tree was checked out by update.
+        # ![14-test_init_repo_object]
+
+    @with_rw_directory
+    def test_references_and_objects(self, rw_dir):
+        # [1-test_references_and_objects]
+        import git
+
+        repo = git.Repo.clone_from(self._small_repo_url(), os.path.join(rw_dir, "repo"), branch="master")
+
+        heads = repo.heads
+        master = heads.master  # Lists can be accessed by name for convenience.
+        master.commit  # the commit pointed to by head called master.
+        master.rename("new_name")  # Rename heads.
+        master.rename("master")
+        # ![1-test_references_and_objects]
+
+        # [2-test_references_and_objects]
+        tags = repo.tags
+        tagref = tags[0]
+        tagref.tag  # Tags may have tag objects carrying additional information
+        tagref.commit  # but they always point to commits.
+        repo.delete_tag(tagref)  # Delete or
+        repo.create_tag("my_tag")  # create tags using the repo for convenience.
+        # ![2-test_references_and_objects]
+
+        # [3-test_references_and_objects]
+        head = repo.head  # The head points to the active branch/ref.
+        master = head.reference  # Retrieve the reference the head points to.
+        master.commit  # From here you use it as any other reference.
+        # ![3-test_references_and_objects]
+        #
+        # [4-test_references_and_objects]
+        log = master.log()
+        log[0]  # first (i.e. oldest) reflog entry
+        log[-1]  # last (i.e. most recent) reflog entry
+        # ![4-test_references_and_objects]
+
+        # [5-test_references_and_objects]
+        new_branch = repo.create_head("new")  # Create a new one.
+        new_branch.commit = "HEAD~10"  # Set branch to another commit without changing index or working trees.
+        repo.delete_head(new_branch)  # Delete an existing head - only works if it is not checked out.
+        # ![5-test_references_and_objects]
+
+        # [6-test_references_and_objects]
+        new_tag = repo.create_tag("my_new_tag", message="my message")
+        # You cannot change the commit a tag points to. Tags need to be re-created.
+        self.assertRaises(AttributeError, setattr, new_tag, "commit", repo.commit("HEAD~1"))
+        repo.delete_tag(new_tag)
+        # ![6-test_references_and_objects]
+
+        # [7-test_references_and_objects]
+        new_branch = repo.create_head("another-branch")
+        repo.head.reference = new_branch
+        # ![7-test_references_and_objects]
+
+        # [8-test_references_and_objects]
+        hc = repo.head.commit
+        hct = hc.tree
+        assert hc != hct
+        assert hc != repo.tags[0]
+        assert hc == repo.head.reference.commit
+        # ![8-test_references_and_objects]
+
+        # [9-test_references_and_objects]
+        self.assertEqual(hct.type, "tree")  # Preset string type, being a class attribute.
+        assert hct.size > 0  # size in bytes
+        assert len(hct.hexsha) == 40
+        assert len(hct.binsha) == 20
+        # ![9-test_references_and_objects]
+
+        # [10-test_references_and_objects]
+        self.assertEqual(hct.path, "")  # Root tree has no path.
+        assert hct.trees[0].path != ""  # The first contained item has one though.
+        self.assertEqual(hct.mode, 0o40000)  # Trees have the mode of a Linux directory.
+        self.assertEqual(hct.blobs[0].mode, 0o100644)  # Blobs have specific mode, comparable to a standard Linux fs.
+        # ![10-test_references_and_objects]
+
+        # [11-test_references_and_objects]
+        hct.blobs[0].data_stream.read()  # Stream object to read data from.
+        hct.blobs[0].stream_data(open(os.path.join(rw_dir, "blob_data"), "wb"))  # Write data to a given stream.
+        # ![11-test_references_and_objects]
+
+        # [12-test_references_and_objects]
+        repo.commit("master")
+        repo.commit("v0.8.1")
+        repo.commit("HEAD~10")
+        # ![12-test_references_and_objects]
+
+        # [13-test_references_and_objects]
+        fifty_first_commits = list(repo.iter_commits("master", max_count=50))
+        assert len(fifty_first_commits) == 50
+        # This will return commits 21-30 from the commit list as traversed backwards master.
+        ten_commits_past_twenty = list(repo.iter_commits("master", max_count=10, skip=20))
+        assert len(ten_commits_past_twenty) == 10
+        assert fifty_first_commits[20:30] == ten_commits_past_twenty
+        # ![13-test_references_and_objects]
+
+        # [14-test_references_and_objects]
+        headcommit = repo.head.commit
+        assert len(headcommit.hexsha) == 40
+        assert len(headcommit.parents) > 0
+        assert headcommit.tree.type == "tree"
+        assert len(headcommit.author.name) != 0
+        assert isinstance(headcommit.authored_date, int)
+        assert len(headcommit.committer.name) != 0
+        assert isinstance(headcommit.committed_date, int)
+        assert headcommit.message != ""
+        # ![14-test_references_and_objects]
+
+        # [15-test_references_and_objects]
+        import time
+
+        time.asctime(time.gmtime(headcommit.committed_date))
+        time.strftime("%a, %d %b %Y %H:%M", time.gmtime(headcommit.committed_date))
+        # ![15-test_references_and_objects]
+
+        # [16-test_references_and_objects]
+        assert headcommit.parents[0].parents[0].parents[0] == repo.commit("master^^^")
+        # ![16-test_references_and_objects]
+
+        # [17-test_references_and_objects]
+        tree = repo.heads.master.commit.tree
+        assert len(tree.hexsha) == 40
+        # ![17-test_references_and_objects]
+
+        # [18-test_references_and_objects]
+        assert len(tree.trees) > 0  # Trees are subdirectories.
+        assert len(tree.blobs) > 0  # Blobs are files.
+        assert len(tree.blobs) + len(tree.trees) == len(tree)
+        # ![18-test_references_and_objects]
+
+        # [19-test_references_and_objects]
+        self.assertEqual(tree["smmap"], tree / "smmap")  # Access by index and by sub-path.
+        for entry in tree:  # Intuitive iteration of tree members.
+            print(entry)
+        blob = tree.trees[1].blobs[0]  # Let's get a blob in a sub-tree.
+        assert blob.name
+        assert len(blob.path) < len(blob.abspath)
+        self.assertEqual(tree.trees[1].name + "/" + blob.name, blob.path)  # This is how relative blob path generated.
+        self.assertEqual(tree[blob.path], blob)  # You can use paths like 'dir/file' in tree,
+        # ![19-test_references_and_objects]
+
+        # [20-test_references_and_objects]
+        assert tree / "smmap" == tree["smmap"]
+        assert tree / blob.path == tree[blob.path]
+        # ![20-test_references_and_objects]
+
+        # [21-test_references_and_objects]
+        # This example shows the various types of allowed ref-specs.
+        assert repo.tree() == repo.head.commit.tree
+        past = repo.commit("HEAD~5")
+        assert repo.tree(past) == repo.tree(past.hexsha)
+        self.assertEqual(repo.tree("v0.8.1").type, "tree")  # Yes, you can provide any refspec - works everywhere.
+        # ![21-test_references_and_objects]
+
+        # [22-test_references_and_objects]
+        assert len(tree) < len(list(tree.traverse()))
+        # ![22-test_references_and_objects]
+
+        # [23-test_references_and_objects]
+        index = repo.index
+        # The index contains all blobs in a flat list.
+        assert len(list(index.iter_blobs())) == len([o for o in repo.head.commit.tree.traverse() if o.type == "blob"])
+        # Access blob objects.
+        for (_path, _stage), _entry in index.entries.items():
+            pass
+        new_file_path = os.path.join(repo.working_tree_dir, "new-file-name")
+        open(new_file_path, "w").close()
+        index.add([new_file_path])  # Add a new file to the index.
+        index.remove(["LICENSE"])  # Remove an existing one.
+        assert os.path.isfile(os.path.join(repo.working_tree_dir, "LICENSE"))  # Working tree is untouched.
+
+        self.assertEqual(index.commit("my commit message").type, "commit")  # Commit changed index.
+        repo.active_branch.commit = repo.commit("HEAD~1")  # Forget last commit.
+
+        from git import Actor
+
+        author = Actor("An author", "author@example.com")
+        committer = Actor("A committer", "committer@example.com")
+        # Commit with a commit message, author, and committer.
+        index.commit("my commit message", author=author, committer=committer)
+        # ![23-test_references_and_objects]
+
+        # [24-test_references_and_objects]
+        from git import IndexFile
+
+        # Load a tree into a temporary index, which exists just in memory.
+        IndexFile.from_tree(repo, "HEAD~1")
+        # Merge two trees three-way into memory...
+        merge_index = IndexFile.from_tree(repo, "HEAD~10", "HEAD", repo.merge_base("HEAD~10", "HEAD"))
+        # ...and persist it.
+        merge_index.write(os.path.join(rw_dir, "merged_index"))
+        # ![24-test_references_and_objects]
+
+        # [25-test_references_and_objects]
+        empty_repo = git.Repo.init(os.path.join(rw_dir, "empty"))
+        origin = empty_repo.create_remote("origin", repo.remotes.origin.url)
+        assert origin.exists()
+        assert origin == empty_repo.remotes.origin == empty_repo.remotes["origin"]
+        origin.fetch()  # Ensure we actually have data. fetch() returns useful information.
+        # Set up a local tracking branch of a remote branch.
+        empty_repo.create_head("master", origin.refs.master)  # Create local branch "master" from remote "master".
+        empty_repo.heads.master.set_tracking_branch(origin.refs.master)  # Set local "master" to track remote "master.
+        empty_repo.heads.master.checkout()  # Check out local "master" to working tree.
+        # Three above commands in one:
+        empty_repo.create_head("master", origin.refs.master).set_tracking_branch(origin.refs.master).checkout()
+        # Rename remotes.
+        origin.rename("new_origin")
+        # Push and pull behaves similarly to `git push|pull`.
+        origin.pull()
+        origin.push()  # Attempt push, ignore errors.
+        origin.push().raise_if_error()  # Push and raise error if it fails.
+        # assert not empty_repo.delete_remote(origin).exists()     # Create and delete remotes.
+        # ![25-test_references_and_objects]
+
+        # [26-test_references_and_objects]
+        assert origin.url == repo.remotes.origin.url
+        with origin.config_writer as cw:
+            cw.set("pushurl", "other_url")
+
+        # Please note that in Python 2, writing origin.config_writer.set(...) is totally
+        # safe. In py3 __del__ calls can be delayed, thus not writing changes in time.
+        # ![26-test_references_and_objects]
+
+        # [27-test_references_and_objects]
+        hcommit = repo.head.commit
+        hcommit.diff()  # diff tree against index.
+        hcommit.diff("HEAD~1")  # diff tree against previous tree.
+        hcommit.diff(None)  # diff tree against working tree.
+
+        index = repo.index
+        index.diff()  # diff index against itself yielding empty diff.
+        index.diff(None)  # diff index against working copy.
+        index.diff("HEAD")  # diff index against current HEAD tree.
+        # ![27-test_references_and_objects]
+
+        # [28-test_references_and_objects]
+        # Traverse added Diff objects only
+        for diff_added in hcommit.diff("HEAD~1").iter_change_type("A"):
+            print(diff_added)
+        # ![28-test_references_and_objects]
+
+        # [29-test_references_and_objects]
+        # Reset our working tree 10 commits into the past.
+        past_branch = repo.create_head("past_branch", "HEAD~10")
+        repo.head.reference = past_branch
+        assert not repo.head.is_detached
+        # Reset the index and working tree to match the pointed-to commit.
+        repo.head.reset(index=True, working_tree=True)
+
+        # To detach your head, you have to point to a commit directly.
+        repo.head.reference = repo.commit("HEAD~5")
+        assert repo.head.is_detached
+        # Now our head points 15 commits into the past, whereas the working tree
+        # and index are 10 commits in the past.
+        # ![29-test_references_and_objects]
+
+        # [30-test_references_and_objects]
+        # Check out the branch using git-checkout.
+        # It will fail as the working tree appears dirty.
+        self.assertRaises(git.GitCommandError, repo.heads.master.checkout)
+        repo.heads.past_branch.checkout()
+        # ![30-test_references_and_objects]
+
+        # [31-test_references_and_objects]
+        git_cmd = repo.git
+        git_cmd.checkout("HEAD", b="my_new_branch")  # Create a new branch.
+        git_cmd.branch("another-new-one")
+        git_cmd.branch("-D", "another-new-one")  # Pass strings for full control over argument order.
+        git_cmd.for_each_ref()  # '-' becomes '_' when calling it.
+        # ![31-test_references_and_objects]
+
+        repo.git.clear_cache()
+
+    @pytest.mark.xfail(
+        sys.platform == "cygwin",
+        reason="Cygwin GitPython can't find SHA for submodule",
+        raises=ValueError,
+    )
+    def test_submodules(self):
+        # [1-test_submodules]
+        repo = self.rorepo
+        sms = repo.submodules
+
+        assert len(sms) == 1
+        sm = sms[0]
+        self.assertEqual(sm.name, "gitdb")  # GitPython has gitdb as its one and only (direct) submodule...
+        self.assertEqual(sm.children()[0].name, "smmap")  # ...which has smmap as its one and only submodule.
+
+        # The module is the repository referenced by the submodule.
+        assert sm.module_exists()  # The module is available, which doesn't have to be the case.
+        assert sm.module().working_tree_dir.endswith("gitdb")
+        # The submodule's absolute path is the module's path.
+        assert sm.abspath == sm.module().working_tree_dir
+        self.assertEqual(len(sm.hexsha), 40)  # Its sha defines the commit to check out.
+        assert sm.exists()  # Yes, this submodule is valid and exists.
+        # Read its configuration conveniently.
+        assert sm.config_reader().get_value("path") == sm.path
+        self.assertEqual(len(sm.children()), 1)  # Query the submodule hierarchy.
+        # ![1-test_submodules]
+
+    @with_rw_directory
+    def test_add_file_and_commit(self, rw_dir):
+        import git
+
+        repo_dir = os.path.join(rw_dir, "my-new-repo")
+        file_name = os.path.join(repo_dir, "new-file")
+
+        r = git.Repo.init(repo_dir)
+        # This function just creates an empty file.
+        open(file_name, "wb").close()
+        r.index.add([file_name])
+        r.index.commit("initial commit")
+
+        # ![test_add_file_and_commit]
diff --git a/test/test_exc.py b/test/test_exc.py
new file mode 100644
index 000000000..2e979f5a1
--- /dev/null
+++ b/test/test_exc.py
@@ -0,0 +1,179 @@
+# Copyright (C) 2008, 2009, 2016 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+from itertools import product
+import re
+
+import ddt
+
+from git.exc import (
+    InvalidGitRepositoryError,
+    WorkTreeRepositoryUnsupported,
+    NoSuchPathError,
+    CommandError,
+    GitCommandNotFound,
+    GitCommandError,
+    CheckoutError,
+    CacheError,
+    UnmergedEntriesError,
+    HookExecutionError,
+    RepositoryDirtyError,
+)
+from git.util import remove_password_if_present
+
+from test.lib import TestBase
+
+
+_cmd_argvs = (
+    ("cmd",),
+    ("θνιψοδε",),
+    ("θνιψοδε", "normal", "argvs"),
+    ("cmd", "ελληνικα", "args"),
+    ("θνιψοδε", "κι", "αλλα", "strange", "args"),
+    ("θνιψοδε", "κι", "αλλα", "non-unicode", "args"),
+    (
+        "git",
+        "clone",
+        "-v",
+        "https://fakeuser:fakepassword1234@fakerepo.example.com/testrepo",
+    ),
+)
+_causes_n_substrings = (
+    (None, None),
+    (7, "exit code(7)"),
+    ("Some string", "'Some string'"),
+    ("παλιο string", "'παλιο string'"),
+    (Exception("An exc."), "Exception('An exc.')"),
+    (Exception("Κακια exc."), "Exception('Κακια exc.')"),
+    (object(), "<object object at "),
+)
+
+_streams_n_substrings = (
+    None,
+    "stream",
+    "ομορφο stream",
+)
+
+
+@ddt.ddt
+class TExc(TestBase):
+    def test_ExceptionsHaveBaseClass(self):
+        from git.exc import GitError
+
+        self.assertIsInstance(GitError(), Exception)
+
+        exception_classes = [
+            InvalidGitRepositoryError,
+            WorkTreeRepositoryUnsupported,
+            NoSuchPathError,
+            CommandError,
+            GitCommandNotFound,
+            GitCommandError,
+            CheckoutError,
+            CacheError,
+            UnmergedEntriesError,
+            HookExecutionError,
+            RepositoryDirtyError,
+        ]
+        for ex_class in exception_classes:
+            self.assertTrue(issubclass(ex_class, GitError))
+
+    @ddt.data(*list(product(_cmd_argvs, _causes_n_substrings, _streams_n_substrings)))
+    def test_CommandError_unicode(self, case):
+        argv, (cause, subs), stream = case
+        cls = CommandError
+        c = cls(argv, cause)
+        s = str(c)
+
+        self.assertIsNotNone(c._msg)
+        self.assertIn("  cmdline: ", s)
+
+        for a in remove_password_if_present(argv):
+            self.assertIn(a, s)
+
+        if not cause:
+            self.assertIn("failed!", s)
+        else:
+            self.assertIn(" failed due to:", s)
+
+            if subs is not None:
+                # Substrings (must) already contain opening `'`.
+                subs = r"(?<!')%s(?!')" % re.escape(subs)
+                self.assertRegex(s, subs)
+
+        if not stream:
+            c = cls(argv, cause)
+            s = str(c)
+            self.assertNotIn("  stdout:", s)
+            self.assertNotIn("  stderr:", s)
+        else:
+            c = cls(argv, cause, stream)
+            s = str(c)
+            self.assertIn("  stderr:", s)
+            self.assertIn(stream, s)
+
+            c = cls(argv, cause, None, stream)
+            s = str(c)
+            self.assertIn("  stdout:", s)
+            self.assertIn(stream, s)
+
+            c = cls(argv, cause, stream, stream + "no2")
+            s = str(c)
+            self.assertIn("  stderr:", s)
+            self.assertIn(stream, s)
+            self.assertIn("  stdout:", s)
+            self.assertIn(stream + "no2", s)
+
+    @ddt.data(
+        (["cmd1"], None),
+        (["cmd1"], "some cause"),
+        (["cmd1"], Exception()),
+    )
+    def test_GitCommandNotFound(self, init_args):
+        argv, cause = init_args
+        c = GitCommandNotFound(argv, cause)
+        s = str(c)
+
+        self.assertIn(argv[0], s)
+        if cause:
+            self.assertIn(" not found due to: ", s)
+            self.assertIn(str(cause), s)
+        else:
+            self.assertIn(" not found!", s)
+
+    @ddt.data(
+        (["cmd1"], None),
+        (["cmd1"], "some cause"),
+        (["cmd1", "https://fakeuser@fakerepo.example.com/testrepo"], Exception()),
+    )
+    def test_GitCommandError(self, init_args):
+        argv, cause = init_args
+        c = GitCommandError(argv, cause)
+        s = str(c)
+
+        for arg in remove_password_if_present(argv):
+            self.assertIn(arg, s)
+        if cause:
+            self.assertIn(" failed due to: ", s)
+            self.assertIn(str(cause), s)
+        else:
+            self.assertIn(" failed!", s)
+
+    @ddt.data(
+        (["cmd1"], None),
+        (["cmd1"], "some cause"),
+        (["cmd1"], Exception()),
+    )
+    def test_HookExecutionError(self, init_args):
+        argv, cause = init_args
+        c = HookExecutionError(argv, cause)
+        s = str(c)
+
+        self.assertIn(argv[0], s)
+        if cause:
+            self.assertTrue(s.startswith("Hook("), s)
+            self.assertIn(str(cause), s)
+        else:
+            self.assertIn(" failed!", s)
diff --git a/git/test/test_fun.py b/test/test_fun.py
similarity index 55%
rename from git/test/test_fun.py
rename to test/test_fun.py
index 40d040b97..a456b8aab 100644
--- a/git/test/test_fun.py
+++ b/test/test_fun.py
@@ -1,36 +1,32 @@
-from git.test.lib import (
-    TestBase,
-    with_rw_repo
-)
-from git.objects.fun import (
-    traverse_tree_recursive,
-    traverse_trees_recursive,
-    tree_to_stream,
-    tree_entries_from_data
-)
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
 
-from git.index.fun import (
-    aggressive_tree_merge
-)
+from io import BytesIO
+from stat import S_IFDIR, S_IFLNK, S_IFREG, S_IXUSR
+from os import stat
+import os.path as osp
 
-from gitdb.util import bin_to_hex
 from gitdb.base import IStream
 from gitdb.typ import str_tree_type
 
-from stat import (
-    S_IFDIR,
-    S_IFREG,
-    S_IFLNK
+from git import Git
+from git.index import IndexFile
+from git.index.fun import aggressive_tree_merge, stat_mode_to_index_mode
+from git.objects.fun import (
+    traverse_tree_recursive,
+    traverse_trees_recursive,
+    tree_entries_from_data,
+    tree_to_stream,
 )
+from git.repo.fun import find_worktree_git_dir
+from git.util import bin_to_hex, cygpath, join_path_native
 
-from git.index import IndexFile
-from io import BytesIO
+from test.lib import TestBase, with_rw_directory, with_rw_repo
 
 
 class TestFun(TestBase):
-
     def _assert_index_entries(self, entries, trees):
-        index = IndexFile.from_tree(self.rorepo, *[self.rorepo.tree(bin_to_hex(t).decode('ascii')) for t in trees])
+        index = IndexFile.from_tree(self.rorepo, *[self.rorepo.tree(bin_to_hex(t).decode("ascii")) for t in trees])
         assert entries
         assert len(index.entries) == len(entries)
         for entry in entries:
@@ -38,21 +34,22 @@ def _assert_index_entries(self, entries, trees):
         # END assert entry matches fully
 
     def test_aggressive_tree_merge(self):
-        # head tree with additions, removals and modification compared to its predecessor
+        # Head tree with additions, removals and modification compared to its
+        # predecessor.
         odb = self.rorepo.odb
         HC = self.rorepo.commit("6c1faef799095f3990e9970bc2cb10aa0221cf9c")
         H = HC.tree
         B = HC.parents[0].tree
 
-        # entries from single tree
+        # Entries from single tree.
         trees = [H.binsha]
         self._assert_index_entries(aggressive_tree_merge(odb, trees), trees)
 
-        # from multiple trees
+        # From multiple trees.
         trees = [B.binsha, H.binsha]
         self._assert_index_entries(aggressive_tree_merge(odb, trees), trees)
 
-        # three way, no conflict
+        # Three way, no conflict.
         tree = self.rorepo.tree
         B = tree("35a09c0534e89b2d43ec4101a5fb54576b577905")
         H = tree("4fe5cfa0e063a8d51a1eb6f014e2aaa994e5e7d4")
@@ -60,25 +57,25 @@ def test_aggressive_tree_merge(self):
         trees = [B.binsha, H.binsha, M.binsha]
         self._assert_index_entries(aggressive_tree_merge(odb, trees), trees)
 
-        # three-way, conflict in at least one file, both modified
+        # Three-way, conflict in at least one file, both modified.
         B = tree("a7a4388eeaa4b6b94192dce67257a34c4a6cbd26")
         H = tree("f9cec00938d9059882bb8eabdaf2f775943e00e5")
         M = tree("44a601a068f4f543f73fd9c49e264c931b1e1652")
         trees = [B.binsha, H.binsha, M.binsha]
         self._assert_index_entries(aggressive_tree_merge(odb, trees), trees)
 
-        # too many trees
-        self.failUnlessRaises(ValueError, aggressive_tree_merge, odb, trees * 2)
+        # Too many trees.
+        self.assertRaises(ValueError, aggressive_tree_merge, odb, trees * 2)
 
     def mktree(self, odb, entries):
-        """create a tree from the given tree entries and safe it to the database"""
+        """Create a tree from the given tree entries and safe it to the database."""
         sio = BytesIO()
         tree_to_stream(entries, sio.write)
         sio.seek(0)
         istream = odb.store(IStream(str_tree_type, len(sio.getvalue()), sio))
         return istream.binsha
 
-    @with_rw_repo('0.1.6')
+    @with_rw_repo("0.1.6")
     def test_three_way_merge(self, rwrepo):
         def mkfile(name, sha, executable=0):
             return (sha, S_IFREG | 0o644 | executable * 0o111, name)
@@ -89,6 +86,7 @@ def mkcommit(name, sha):
         def assert_entries(entries, num_entries, has_conflict=False):
             assert len(entries) == num_entries
             assert has_conflict == (len([e for e in entries if e.stage != 0]) > 0)
+
         mktree = self.mktree
 
         shaa = b"\1" * 20
@@ -97,84 +95,84 @@ def assert_entries(entries, num_entries, has_conflict=False):
 
         odb = rwrepo.odb
 
-        # base tree
-        bfn = 'basefile'
+        # Base tree.
+        bfn = "basefile"
         fbase = mkfile(bfn, shaa)
         tb = mktree(odb, [fbase])
 
-        # non-conflicting new files, same data
-        fa = mkfile('1', shab)
+        # Non-conflicting new files, same data.
+        fa = mkfile("1", shab)
         th = mktree(odb, [fbase, fa])
-        fb = mkfile('2', shac)
+        fb = mkfile("2", shac)
         tm = mktree(odb, [fbase, fb])
 
-        # two new files, same base file
+        # Two new files, same base file.
         trees = [tb, th, tm]
         assert_entries(aggressive_tree_merge(odb, trees), 3)
 
-        # both delete same file, add own one
-        fa = mkfile('1', shab)
+        # Both delete same file, add own one.
+        fa = mkfile("1", shab)
         th = mktree(odb, [fa])
-        fb = mkfile('2', shac)
+        fb = mkfile("2", shac)
         tm = mktree(odb, [fb])
 
-        # two new files
+        # Two new files.
         trees = [tb, th, tm]
         assert_entries(aggressive_tree_merge(odb, trees), 2)
 
-        # same file added in both, differently
-        fa = mkfile('1', shab)
+        # Same file added in both, differently.
+        fa = mkfile("1", shab)
         th = mktree(odb, [fa])
-        fb = mkfile('1', shac)
+        fb = mkfile("1", shac)
         tm = mktree(odb, [fb])
 
-        # expect conflict
+        # Expect conflict.
         trees = [tb, th, tm]
         assert_entries(aggressive_tree_merge(odb, trees), 2, True)
 
-        # same file added, different mode
-        fa = mkfile('1', shab)
+        # Same file added, different mode.
+        fa = mkfile("1", shab)
         th = mktree(odb, [fa])
-        fb = mkcommit('1', shab)
+        fb = mkcommit("1", shab)
         tm = mktree(odb, [fb])
 
-        # expect conflict
+        # Expect conflict.
         trees = [tb, th, tm]
         assert_entries(aggressive_tree_merge(odb, trees), 2, True)
 
-        # same file added in both
-        fa = mkfile('1', shab)
+        # Same file added in both.
+        fa = mkfile("1", shab)
         th = mktree(odb, [fa])
-        fb = mkfile('1', shab)
+        fb = mkfile("1", shab)
         tm = mktree(odb, [fb])
 
-        # expect conflict
+        # Expect conflict.
         trees = [tb, th, tm]
         assert_entries(aggressive_tree_merge(odb, trees), 1)
 
-        # modify same base file, differently
+        # Modify same base file, differently.
         fa = mkfile(bfn, shab)
         th = mktree(odb, [fa])
         fb = mkfile(bfn, shac)
         tm = mktree(odb, [fb])
 
-        # conflict, 3 versions on 3 stages
+        # Conflict, 3 versions on 3 stages.
         trees = [tb, th, tm]
         assert_entries(aggressive_tree_merge(odb, trees), 3, True)
 
-        # change mode on same base file, by making one a commit, the other executable
-        # no content change ( this is totally unlikely to happen in the real world )
+        # Change mode on same base file, by making one a commit, the other executable,
+        # no content change (this is totally unlikely to happen in the real world).
         fa = mkcommit(bfn, shaa)
         th = mktree(odb, [fa])
         fb = mkfile(bfn, shaa, executable=1)
         tm = mktree(odb, [fb])
 
-        # conflict, 3 versions on 3 stages, because of different mode
+        # Conflict, 3 versions on 3 stages, because of different mode.
         trees = [tb, th, tm]
         assert_entries(aggressive_tree_merge(odb, trees), 3, True)
 
         for is_them in range(2):
-            # only we/they change contents
+            # Only we/they change contents.
             fa = mkfile(bfn, shab)
             th = mktree(odb, [fa])
 
@@ -184,7 +182,7 @@ def assert_entries(entries, num_entries, has_conflict=False):
             entries = aggressive_tree_merge(odb, trees)
             assert len(entries) == 1 and entries[0].binsha == shab
 
-            # only we/they change the mode
+            # Only we/they change the mode.
             fa = mkcommit(bfn, shaa)
             th = mktree(odb, [fa])
 
@@ -194,54 +192,80 @@ def assert_entries(entries, num_entries, has_conflict=False):
             entries = aggressive_tree_merge(odb, trees)
             assert len(entries) == 1 and entries[0].binsha == shaa and entries[0].mode == fa[1]
 
-            # one side deletes, the other changes = conflict
+            # One side deletes, the other changes = conflict.
             fa = mkfile(bfn, shab)
             th = mktree(odb, [fa])
             tm = mktree(odb, [])
             trees = [tb, th, tm]
             if is_them:
                 trees = [tb, tm, th]
-            # as one is deleted, there are only 2 entries
+            # As one is deleted, there are only 2 entries.
             assert_entries(aggressive_tree_merge(odb, trees), 2, True)
         # END handle ours, theirs
 
+    def test_stat_mode_to_index_mode(self):
+        modes = (
+            0o600,
+            0o611,
+            0o640,
+            0o641,
+            0o644,
+            0o650,
+            0o651,
+            0o700,
+            0o711,
+            0o740,
+            0o744,
+            0o750,
+            0o751,
+            0o755,
+        )
+        for mode in modes:
+            expected_mode = S_IFREG | (mode & S_IXUSR and 0o755 or 0o644)
+            assert stat_mode_to_index_mode(mode) == expected_mode
+        # END for each mode
+
     def _assert_tree_entries(self, entries, num_trees):
         for entry in entries:
             assert len(entry) == num_trees
-            paths = set(e[2] for e in entry if e)
+            paths = {e[2] for e in entry if e}
 
-            # only one path per set of entries
+            # Only one path per set of entries.
             assert len(paths) == 1
         # END verify entry
 
     def test_tree_traversal(self):
-        # low level tree tarversal
+        # Low level tree traversal.
         odb = self.rorepo.odb
-        H = self.rorepo.tree('29eb123beb1c55e5db4aa652d843adccbd09ae18')    # head tree
-        M = self.rorepo.tree('e14e3f143e7260de9581aee27e5a9b2645db72de')    # merge tree
-        B = self.rorepo.tree('f606937a7a21237c866efafcad33675e6539c103')    # base tree
-        B_old = self.rorepo.tree('1f66cfbbce58b4b552b041707a12d437cc5f400a')    # old base tree
+        H = self.rorepo.tree("29eb123beb1c55e5db4aa652d843adccbd09ae18")  # head tree
+        M = self.rorepo.tree("e14e3f143e7260de9581aee27e5a9b2645db72de")  # merge tree
+        B = self.rorepo.tree("f606937a7a21237c866efafcad33675e6539c103")  # base tree
+        B_old = self.rorepo.tree("1f66cfbbce58b4b552b041707a12d437cc5f400a")  # old base tree
+
+        # Two very different trees.
 
-        # two very different trees
-        entries = traverse_trees_recursive(odb, [B_old.binsha, H.binsha], '')
+        entries = traverse_trees_recursive(odb, [B_old.binsha, H.binsha], "")
         self._assert_tree_entries(entries, 2)
 
-        oentries = traverse_trees_recursive(odb, [H.binsha, B_old.binsha], '')
+        oentries = traverse_trees_recursive(odb, [H.binsha, B_old.binsha], "")
         assert len(oentries) == len(entries)
         self._assert_tree_entries(oentries, 2)
 
-        # single tree
-        is_no_tree = lambda i, d: i.type != 'tree'
-        entries = traverse_trees_recursive(odb, [B.binsha], '')
+        # Single tree.
+
+        def is_no_tree(i, _d):
+            return i.type != "tree"
+
+        entries = traverse_trees_recursive(odb, [B.binsha], "")
         assert len(entries) == len(list(B.traverse(predicate=is_no_tree)))
         self._assert_tree_entries(entries, 1)
 
-        # two trees
-        entries = traverse_trees_recursive(odb, [B.binsha, H.binsha], '')
+        # Two trees.
+        entries = traverse_trees_recursive(odb, [B.binsha, H.binsha], "")
         self._assert_tree_entries(entries, 2)
 
-        # tree trees
-        entries = traverse_trees_recursive(odb, [B.binsha, H.binsha, M.binsha], '')
+        # Three trees.
+        entries = traverse_trees_recursive(odb, [B.binsha, H.binsha, M.binsha], "")
         self._assert_tree_entries(entries, 3)
 
     def test_tree_traversal_single(self):
@@ -252,10 +276,33 @@ def test_tree_traversal_single(self):
             if count >= max_count:
                 break
             count += 1
-            entries = traverse_tree_recursive(odb, commit.tree.binsha, '')
+            entries = traverse_tree_recursive(odb, commit.tree.binsha, "")
             assert entries
         # END for each commit
 
-    def test_tree_entries_from_data_with_failing_name_decode(self):
-        r = tree_entries_from_data(b'100644 \x9f\0aaa')
-        assert r == [(b'aaa', 33188, b'\x9f')], r
+    @with_rw_directory
+    def test_linked_worktree_traversal(self, rw_dir):
+        """Check that we can identify a linked worktree based on a .git file."""
+        git = Git(rw_dir)
+        if git.version_info[:3] < (2, 5, 1):
+            raise RuntimeError("worktree feature unsupported (test needs git 2.5.1 or later)")
+
+        rw_master = self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
+        branch = rw_master.create_head("aaaaaaaa")
+        worktree_path = join_path_native(rw_dir, "worktree_repo")
+        if Git.is_cygwin():
+            worktree_path = cygpath(worktree_path)
+        rw_master.git.worktree("add", worktree_path, branch.name)
+
+        dotgit = osp.join(worktree_path, ".git")
+        statbuf = stat(dotgit)
+        self.assertTrue(statbuf.st_mode & S_IFREG)
+
+        gitdir = find_worktree_git_dir(dotgit)
+        self.assertIsNotNone(gitdir)
+        statbuf = stat(gitdir)
+        self.assertTrue(statbuf.st_mode & S_IFDIR)
+
+    def test_tree_entries_from_data_with_failing_name_decode_py3(self):
+        r = tree_entries_from_data(b"100644 \x9f\0aaa")
+        assert r == [(b"aaa", 33188, "\udc9f")], r
diff --git a/test/test_git.py b/test/test_git.py
new file mode 100644
index 000000000..4a54d0d9b
--- /dev/null
+++ b/test/test_git.py
@@ -0,0 +1,799 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import contextlib
+import gc
+import inspect
+import logging
+import os
+import os.path as osp
+from pathlib import Path
+import pickle
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from unittest import skipUnless
+
+if sys.version_info >= (3, 8):
+    from unittest import mock
+else:
+    import mock  # To be able to examine call_args.kwargs on a mock.
+
+import ddt
+
+from git import Git, GitCommandError, GitCommandNotFound, Repo, cmd, refresh
+from git.util import cwd, finalize_process
+
+from test.lib import TestBase, fixture_path, with_rw_directory
+
+
+@contextlib.contextmanager
+def _patch_out_env(name):
+    try:
+        old_value = os.environ[name]
+    except KeyError:
+        old_value = None
+    else:
+        del os.environ[name]
+    try:
+        yield
+    finally:
+        if old_value is not None:
+            os.environ[name] = old_value
+
+
+@contextlib.contextmanager
+def _rollback_refresh():
+    old_git_executable = Git.GIT_PYTHON_GIT_EXECUTABLE
+
+    if old_git_executable is None:
+        raise RuntimeError("no executable string (need initial refresh before test)")
+
+    try:
+        yield old_git_executable  # Provide the old value for convenience.
+    finally:
+        # The cleanup refresh should always raise an exception if it fails, since if it
+        # fails then previously discovered test results could be misleading and, more
+        # importantly, subsequent tests may be unable to run or give misleading results.
+        # So pre-set a non-None value, so that the cleanup will be a "second" refresh.
+        # This covers cases where a test has set it to None to test a "first" refresh.
+        Git.GIT_PYTHON_GIT_EXECUTABLE = Git.git_exec_name
+
+        # Do the cleanup refresh. This sets Git.GIT_PYTHON_GIT_EXECUTABLE to old_value
+        # in most cases. The reason to call it is to achieve other associated state
+        # changes as well, which include updating attributes of the FetchInfo class.
+        refresh()
+
+
+@contextlib.contextmanager
+def _fake_git(*version_info):
+    fake_version = ".".join(map(str, version_info))
+    fake_output = f"git version {fake_version} (fake)"
+
+    with tempfile.TemporaryDirectory() as tdir:
+        if sys.platform == "win32":
+            fake_git = Path(tdir, "fake-git.cmd")
+            script = f"@echo {fake_output}\n"
+            fake_git.write_text(script, encoding="utf-8")
+        else:
+            fake_git = Path(tdir, "fake-git")
+            script = f"#!/bin/sh\necho '{fake_output}'\n"
+            fake_git.write_text(script, encoding="utf-8")
+            fake_git.chmod(0o755)
+
+        yield str(fake_git.absolute())
+
+
+def _rename_with_stem(path, new_stem):
+    if sys.version_info >= (3, 9):
+        path.rename(path.with_stem(new_stem))
+    else:
+        path.rename(path.with_name(new_stem + path.suffix))
+
+
+@ddt.ddt
+class TestGit(TestBase):
+    @classmethod
+    def setUpClass(cls):
+        super().setUpClass()
+        cls.git = Git(cls.rorepo.working_dir)
+
+    def tearDown(self):
+        gc.collect()
+
+    def _assert_logged_for_popen(self, log_watcher, name, value):
+        re_name = re.escape(name)
+        re_value = re.escape(str(value))
+        re_line = re.compile(rf"DEBUG:git.cmd:Popen\(.*\b{re_name}={re_value}[,)]")
+        match_attempts = [re_line.match(message) for message in log_watcher.output]
+        self.assertTrue(any(match_attempts), repr(log_watcher.output))
+
+    @mock.patch.object(Git, "execute")
+    def test_call_process_calls_execute(self, git):
+        git.return_value = ""
+        self.git.version()
+        self.assertTrue(git.called)
+        self.assertEqual(git.call_args, ((["git", "version"],), {}))
+
+    def test_call_unpack_args_unicode(self):
+        args = Git._unpack_args("Unicode€™")
+        mangled_value = "Unicode\u20ac\u2122"
+        self.assertEqual(args, [mangled_value])
+
+    def test_call_unpack_args(self):
+        args = Git._unpack_args(["git", "log", "--", "Unicode€™"])
+        mangled_value = "Unicode\u20ac\u2122"
+        self.assertEqual(args, ["git", "log", "--", mangled_value])
+
+    def test_it_raises_errors(self):
+        self.assertRaises(GitCommandError, self.git.this_does_not_exist)
+
+    def test_it_transforms_kwargs_into_git_command_arguments(self):
+        self.assertEqual(["-s"], self.git.transform_kwargs(**{"s": True}))
+        self.assertEqual(["-s", "5"], self.git.transform_kwargs(**{"s": 5}))
+        self.assertEqual([], self.git.transform_kwargs(**{"s": None}))
+
+        self.assertEqual(["--max-count"], self.git.transform_kwargs(**{"max_count": True}))
+        self.assertEqual(["--max-count=5"], self.git.transform_kwargs(**{"max_count": 5}))
+        self.assertEqual(["--max-count=0"], self.git.transform_kwargs(**{"max_count": 0}))
+        self.assertEqual([], self.git.transform_kwargs(**{"max_count": None}))
+
+        # Multiple args are supported by using lists/tuples.
+        self.assertEqual(
+            ["-L", "1-3", "-L", "12-18"],
+            self.git.transform_kwargs(**{"L": ("1-3", "12-18")}),
+        )
+        self.assertEqual(["-C", "-C"], self.git.transform_kwargs(**{"C": [True, True, None, False]}))
+
+        # Order is undefined.
+        res = self.git.transform_kwargs(**{"s": True, "t": True})
+        self.assertEqual({"-s", "-t"}, set(res))
+
+    _shell_cases = (
+        # value_in_call, value_from_class, expected_popen_arg
+        (None, False, False),
+        (None, True, True),
+        (False, True, False),
+        (False, False, False),
+        (True, False, True),
+        (True, True, True),
+    )
+
+    def _do_shell_combo(self, value_in_call, value_from_class):
+        with mock.patch.object(Git, "USE_SHELL", value_from_class):
+            with mock.patch.object(cmd, "safer_popen", wraps=cmd.safer_popen) as mock_safer_popen:
+                # Use a command with no arguments (besides the program name), so it runs
+                # with or without a shell, on all OSes, with the same effect.
+                self.git.execute(["git"], with_exceptions=False, shell=value_in_call)
+
+        return mock_safer_popen
+
+    @ddt.idata(_shell_cases)
+    def test_it_uses_shell_or_not_as_specified(self, case):
+        """A bool passed as ``shell=`` takes precedence over `Git.USE_SHELL`."""
+        value_in_call, value_from_class, expected_popen_arg = case
+        mock_safer_popen = self._do_shell_combo(value_in_call, value_from_class)
+        mock_safer_popen.assert_called_once()
+        self.assertIs(mock_safer_popen.call_args.kwargs["shell"], expected_popen_arg)
+
+    @ddt.idata(full_case[:2] for full_case in _shell_cases)
+    def test_it_logs_if_it_uses_a_shell(self, case):
+        """``shell=`` in the log message agrees with what is passed to `Popen`."""
+        value_in_call, value_from_class = case
+        with self.assertLogs(cmd.__name__, level=logging.DEBUG) as log_watcher:
+            mock_safer_popen = self._do_shell_combo(value_in_call, value_from_class)
+        self._assert_logged_for_popen(log_watcher, "shell", mock_safer_popen.call_args.kwargs["shell"])
+
+    @ddt.data(
+        ("None", None),
+        ("<valid stream>", subprocess.PIPE),
+    )
+    def test_it_logs_istream_summary_for_stdin(self, case):
+        expected_summary, istream_argument = case
+        with self.assertLogs(cmd.__name__, level=logging.DEBUG) as log_watcher:
+            self.git.execute(["git", "version"], istream=istream_argument)
+        self._assert_logged_for_popen(log_watcher, "stdin", expected_summary)
+
+    def test_it_executes_git_and_returns_result(self):
+        self.assertRegex(self.git.execute(["git", "version"]), r"^git version [\d\.]{2}.*$")
+
+    @ddt.data(
+        # chdir_to_repo, shell, command, use_shell_impostor
+        (False, False, ["git", "version"], False),
+        (False, True, "git version", False),
+        (False, True, "git version", True),
+        (True, False, ["git", "version"], False),
+        (True, True, "git version", False),
+        (True, True, "git version", True),
+    )
+    @with_rw_directory
+    def test_it_executes_git_not_from_cwd(self, rw_dir, case):
+        chdir_to_repo, shell, command, use_shell_impostor = case
+
+        repo = Repo.init(rw_dir)
+
+        if sys.platform == "win32":
+            # Copy an actual binary executable that is not git. (On Windows, running
+            # "hostname" only displays the hostname, it never tries to change it.)
+            other_exe_path = Path(os.environ["SystemRoot"], "system32", "hostname.exe")
+            impostor_path = Path(rw_dir, "git.exe")
+            shutil.copy(other_exe_path, impostor_path)
+        else:
+            # Create a shell script that doesn't do anything.
+            impostor_path = Path(rw_dir, "git")
+            impostor_path.write_text("#!/bin/sh\n", encoding="utf-8")
+            os.chmod(impostor_path, 0o755)
+
+        if use_shell_impostor:
+            shell_name = "cmd.exe" if sys.platform == "win32" else "sh"
+            shutil.copy(impostor_path, Path(rw_dir, shell_name))
+
+        with contextlib.ExitStack() as stack:
+            if chdir_to_repo:
+                stack.enter_context(cwd(rw_dir))
+            if use_shell_impostor:
+                stack.enter_context(_patch_out_env("ComSpec"))
+
+            # Run the command without raising an exception on failure, as the exception
+            # message is currently misleading when the command is a string rather than a
+            # sequence of strings (it really runs "git", but then wrongly reports "g").
+            output = repo.git.execute(command, with_exceptions=False, shell=shell)
+
+        self.assertRegex(output, r"^git version\b")
+
+    @skipUnless(
+        sys.platform == "win32",
+        "The regression only affected Windows, and this test logic is OS-specific.",
+    )
+    def test_it_avoids_upcasing_unrelated_environment_variable_names(self):
+        old_name = "28f425ca_d5d8_4257_b013_8d63166c8158"
+        if old_name == old_name.upper():
+            raise RuntimeError("test bug or strange locale: old_name invariant under upcasing")
+
+        # Step 1
+        #
+        # Set the environment variable in this parent process. Because os.putenv is a
+        # thin wrapper around a system API, os.environ never sees the variable in this
+        # parent process, so the name is not upcased even on Windows.
+        os.putenv(old_name, "1")
+
+        # Step 2
+        #
+        # Create the child process that inherits the environment variable. The child
+        # uses GitPython, and we are testing that it passes the variable with the exact
+        # original name to its own child process (the grandchild).
+        cmdline = [
+            sys.executable,
+            fixture_path("env_case.py"),  # Contains steps 3 and 4.
+            self.rorepo.working_dir,
+            old_name,
+        ]
+
+        # Run steps 3 and 4.
+        pair_text = subprocess.check_output(cmdline, shell=False, text=True)
+
+        new_name = pair_text.split("=")[0]
+        self.assertEqual(new_name, old_name)
+
+    def test_it_accepts_stdin(self):
+        filename = fixture_path("cat_file_blob")
+        with open(filename, "r") as fh:
+            self.assertEqual(
+                "70c379b63ffa0795fdbfbc128e5a2818397b7ef8",
+                self.git.hash_object(istream=fh, stdin=True),
+            )
+
+    @mock.patch.object(Git, "execute")
+    def test_it_ignores_false_kwargs(self, git):
+        # this_should_not_be_ignored=False implies it *should* be ignored.
+        self.git.version(pass_this_kwarg=False)
+        self.assertTrue("pass_this_kwarg" not in git.call_args[1])
+
+    def test_it_raises_proper_exception_with_output_stream(self):
+        with tempfile.TemporaryFile() as tmp_file:
+            with self.assertRaises(GitCommandError):
+                self.git.checkout("non-existent-branch", output_stream=tmp_file)
+
+    def test_it_accepts_environment_variables(self):
+        filename = fixture_path("ls_tree_empty")
+        with open(filename, "r") as fh:
+            tree = self.git.mktree(istream=fh)
+            env = {
+                "GIT_AUTHOR_NAME": "Author Name",
+                "GIT_AUTHOR_EMAIL": "author@example.com",
+                "GIT_AUTHOR_DATE": "1400000000+0000",
+                "GIT_COMMITTER_NAME": "Committer Name",
+                "GIT_COMMITTER_EMAIL": "committer@example.com",
+                "GIT_COMMITTER_DATE": "1500000000+0000",
+            }
+            commit = self.git.commit_tree(tree, m="message", env=env)
+            self.assertEqual(commit, "4cfd6b0314682d5a58f80be39850bad1640e9241")
+
+    def test_persistent_cat_file_command(self):
+        # Read header only.
+        hexsha = "b2339455342180c7cc1e9bba3e9f181f7baa5167"
+        g = self.git.cat_file(batch_check=True, istream=subprocess.PIPE, as_process=True)
+        g.stdin.write(b"b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
+        g.stdin.flush()
+        obj_info = g.stdout.readline()
+
+        # Read header + data.
+        g = self.git.cat_file(batch=True, istream=subprocess.PIPE, as_process=True)
+        g.stdin.write(b"b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
+        g.stdin.flush()
+        obj_info_two = g.stdout.readline()
+        self.assertEqual(obj_info, obj_info_two)
+
+        # Read data - have to read it in one large chunk.
+        size = int(obj_info.split()[2])
+        g.stdout.read(size)
+        g.stdout.read(1)
+
+        # Now we should be able to read a new object.
+        g.stdin.write(b"b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
+        g.stdin.flush()
+        self.assertEqual(g.stdout.readline(), obj_info)
+
+        # Same can be achieved using the respective command functions.
+        hexsha, typename, size = self.git.get_object_header(hexsha)
+        hexsha, typename_two, size_two, _ = self.git.get_object_data(hexsha)
+        self.assertEqual(typename, typename_two)
+        self.assertEqual(size, size_two)
+
+    def test_version_info(self):
+        """The version_info attribute is a tuple of up to four ints."""
+        v = self.git.version_info
+        self.assertIsInstance(v, tuple)
+        self.assertLessEqual(len(v), 4)
+        for n in v:
+            self.assertIsInstance(n, int)
+
+    def test_version_info_pickleable(self):
+        """The version_info attribute is usable on unpickled Git instances."""
+        deserialized = pickle.loads(pickle.dumps(self.git))
+        v = deserialized.version_info
+        self.assertIsInstance(v, tuple)
+        self.assertLessEqual(len(v), 4)
+        for n in v:
+            self.assertIsInstance(n, int)
+
+    @ddt.data(
+        (("123", "456", "789"), (123, 456, 789)),
+        (("12", "34", "56", "78"), (12, 34, 56, 78)),
+        (("12", "34", "56", "78", "90"), (12, 34, 56, 78)),
+        (("1", "2", "a", "3"), (1, 2)),
+        (("1", "-2", "3"), (1,)),
+        (("1", "2a", "3"), (1,)),  # Subject to change.
+    )
+    def test_version_info_is_leading_numbers(self, case):
+        fake_fields, expected_version_info = case
+        with _rollback_refresh():
+            with _fake_git(*fake_fields) as path:
+                refresh(path)
+                new_git = Git()
+                self.assertEqual(new_git.version_info, expected_version_info)
+
+    def test_git_exc_name_is_git(self):
+        self.assertEqual(self.git.git_exec_name, "git")
+
+    def test_cmd_override(self):
+        """Directly set bad GIT_PYTHON_GIT_EXECUTABLE causes git operations to raise."""
+        bad_path = osp.join("some", "path", "which", "doesn't", "exist", "gitbinary")
+        with mock.patch.object(Git, "GIT_PYTHON_GIT_EXECUTABLE", bad_path):
+            with self.assertRaises(GitCommandNotFound) as ctx:
+                self.git.version()
+            self.assertEqual(ctx.exception.command, [bad_path, "version"])
+
+    @ddt.data(("0",), ("q",), ("quiet",), ("s",), ("silence",), ("silent",), ("n",), ("none",))
+    def test_initial_refresh_from_bad_git_path_env_quiet(self, case):
+        """In "q" mode, bad initial path sets "git" and is quiet."""
+        (mode,) = case
+        set_vars = {
+            "GIT_PYTHON_GIT_EXECUTABLE": str(Path("yada").absolute()),  # Any bad path.
+            "GIT_PYTHON_REFRESH": mode,
+        }
+        with _rollback_refresh():
+            Git.GIT_PYTHON_GIT_EXECUTABLE = None  # Simulate startup.
+
+            with mock.patch.dict(os.environ, set_vars):
+                refresh()
+                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, "git")
+
+    @ddt.data(("1",), ("w",), ("warn",), ("warning",), ("l",), ("log",))
+    def test_initial_refresh_from_bad_git_path_env_warn(self, case):
+        """In "w" mode, bad initial path sets "git" and warns, by logging."""
+        (mode,) = case
+        env_vars = {
+            "GIT_PYTHON_GIT_EXECUTABLE": str(Path("yada").absolute()),  # Any bad path.
+            "GIT_PYTHON_REFRESH": mode,
+        }
+        with _rollback_refresh():
+            Git.GIT_PYTHON_GIT_EXECUTABLE = None  # Simulate startup.
+
+            with mock.patch.dict(os.environ, env_vars):
+                with self.assertLogs(cmd.__name__, logging.CRITICAL) as ctx:
+                    refresh()
+                self.assertEqual(len(ctx.records), 1)
+                message = ctx.records[0].getMessage()
+                self.assertRegex(message, r"\ABad git executable.\n")
+                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, "git")
+
+    @ddt.data(("2",), ("r",), ("raise",), ("e",), ("error",))
+    def test_initial_refresh_from_bad_git_path_env_error(self, case):
+        """In "e" mode, bad initial path raises an exception."""
+        (mode,) = case
+        env_vars = {
+            "GIT_PYTHON_GIT_EXECUTABLE": str(Path("yada").absolute()),  # Any bad path.
+            "GIT_PYTHON_REFRESH": mode,
+        }
+        with _rollback_refresh():
+            Git.GIT_PYTHON_GIT_EXECUTABLE = None  # Simulate startup.
+
+            with mock.patch.dict(os.environ, env_vars):
+                with self.assertRaisesRegex(ImportError, r"\ABad git executable.\n"):
+                    refresh()
+
+    def test_initial_refresh_from_good_absolute_git_path_env(self):
+        """Good initial absolute path from environment is set."""
+        absolute_path = shutil.which("git")
+
+        with _rollback_refresh():
+            Git.GIT_PYTHON_GIT_EXECUTABLE = None  # Simulate startup.
+
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": absolute_path}):
+                refresh()
+                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, absolute_path)
+
+    def test_initial_refresh_from_good_relative_git_path_env(self):
+        """Good initial relative path from environment is kept relative and set."""
+        with _rollback_refresh():
+            # Set the fallback to a string that wouldn't work and isn't "git", so we are
+            # more likely to detect if "git" is not set from the environment variable.
+            with mock.patch.object(Git, "git_exec_name", ""):
+                Git.GIT_PYTHON_GIT_EXECUTABLE = None  # Simulate startup.
+
+                # Now observe if setting the environment variable to "git" takes effect.
+                with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": "git"}):
+                    refresh()
+                    self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, "git")
+
+    def test_refresh_from_bad_absolute_git_path_env(self):
+        """Bad absolute path from environment is reported and not set."""
+        absolute_path = str(Path("yada").absolute())
+        expected_pattern = rf"\n[ \t]*cmdline: {re.escape(absolute_path)}\Z"
+
+        with _rollback_refresh() as old_git_executable:
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": absolute_path}):
+                with self.assertRaisesRegex(GitCommandNotFound, expected_pattern):
+                    refresh()
+                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, old_git_executable)
+
+    def test_refresh_from_bad_relative_git_path_env(self):
+        """Bad relative path from environment is kept relative and reported, not set."""
+        # Relative paths are not resolved when refresh() is called with no arguments, so
+        # use a string that's very unlikely to be a command name found in a path lookup.
+        relative_path = "yada-e47e70c6-acbf-40f8-ad65-13af93c2195b"
+        expected_pattern = rf"\n[ \t]*cmdline: {re.escape(relative_path)}\Z"
+
+        with _rollback_refresh() as old_git_executable:
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": relative_path}):
+                with self.assertRaisesRegex(GitCommandNotFound, expected_pattern):
+                    refresh()
+                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, old_git_executable)
+
+    def test_refresh_from_good_absolute_git_path_env(self):
+        """Good absolute path from environment is set."""
+        absolute_path = shutil.which("git")
+
+        with _rollback_refresh():
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": absolute_path}):
+                refresh()
+                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, absolute_path)
+
+    def test_refresh_from_good_relative_git_path_env(self):
+        """Good relative path from environment is kept relative and set."""
+        with _rollback_refresh():
+            # Set as the executable name a string that wouldn't work and isn't "git".
+            Git.GIT_PYTHON_GIT_EXECUTABLE = ""
+
+            # Now observe if setting the environment variable to "git" takes effect.
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": "git"}):
+                refresh()
+                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, "git")
+
+    def test_refresh_with_bad_absolute_git_path_arg(self):
+        """Bad absolute path arg is reported and not set."""
+        absolute_path = str(Path("yada").absolute())
+        expected_pattern = rf"\n[ \t]*cmdline: {re.escape(absolute_path)}\Z"
+
+        with _rollback_refresh() as old_git_executable:
+            with self.assertRaisesRegex(GitCommandNotFound, expected_pattern):
+                refresh(absolute_path)
+            self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, old_git_executable)
+
+    def test_refresh_with_bad_relative_git_path_arg(self):
+        """Bad relative path arg is resolved to absolute path and reported, not set."""
+        absolute_path = str(Path("yada").absolute())
+        expected_pattern = rf"\n[ \t]*cmdline: {re.escape(absolute_path)}\Z"
+
+        with _rollback_refresh() as old_git_executable:
+            with self.assertRaisesRegex(GitCommandNotFound, expected_pattern):
+                refresh("yada")
+            self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, old_git_executable)
+
+    def test_refresh_with_good_absolute_git_path_arg(self):
+        """Good absolute path arg is set."""
+        absolute_path = shutil.which("git")
+
+        with _rollback_refresh():
+            refresh(absolute_path)
+            self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, absolute_path)
+
+    def test_refresh_with_good_relative_git_path_arg(self):
+        """Good relative path arg is resolved to absolute path and set."""
+        absolute_path = shutil.which("git")
+        dirname, basename = osp.split(absolute_path)
+
+        with cwd(dirname):
+            with _rollback_refresh():
+                refresh(basename)
+                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, absolute_path)
+
+    def test_version_info_is_cached(self):
+        fake_version_info = (123, 456, 789)
+        with _rollback_refresh():
+            with _fake_git(*fake_version_info) as path:
+                new_git = Git()  # Not cached yet.
+                refresh(path)
+                self.assertEqual(new_git.version_info, fake_version_info)
+                os.remove(path)  # Arrange that a second subprocess call would fail.
+                self.assertEqual(new_git.version_info, fake_version_info)
+
+    def test_version_info_cache_is_per_instance(self):
+        with _rollback_refresh():
+            with _fake_git(123, 456, 789) as path:
+                git1 = Git()
+                git2 = Git()
+                refresh(path)
+                git1.version_info
+                os.remove(path)  # Arrange that the second subprocess call will fail.
+                with self.assertRaises(GitCommandNotFound):
+                    git2.version_info
+                git1.version_info
+
+    def test_version_info_cache_is_not_pickled(self):
+        with _rollback_refresh():
+            with _fake_git(123, 456, 789) as path:
+                git1 = Git()
+                refresh(path)
+                git1.version_info
+                git2 = pickle.loads(pickle.dumps(git1))
+                os.remove(path)  # Arrange that the second subprocess call will fail.
+                with self.assertRaises(GitCommandNotFound):
+                    git2.version_info
+                git1.version_info
+
+    def test_successful_refresh_with_arg_invalidates_cached_version_info(self):
+        with _rollback_refresh():
+            with _fake_git(11, 111, 1) as path1:
+                with _fake_git(22, 222, 2) as path2:
+                    new_git = Git()
+                    refresh(path1)
+                    new_git.version_info
+                    refresh(path2)
+                    self.assertEqual(new_git.version_info, (22, 222, 2))
+
+    def test_failed_refresh_with_arg_does_not_invalidate_cached_version_info(self):
+        with _rollback_refresh():
+            with _fake_git(11, 111, 1) as path1:
+                with _fake_git(22, 222, 2) as path2:
+                    new_git = Git()
+                    refresh(path1)
+                    new_git.version_info
+                    os.remove(path1)  # Arrange that a repeat call for path1 would fail.
+                    os.remove(path2)  # Arrange that the new call for path2 will fail.
+                    with self.assertRaises(GitCommandNotFound):
+                        refresh(path2)
+                    self.assertEqual(new_git.version_info, (11, 111, 1))
+
+    def test_successful_refresh_with_same_arg_invalidates_cached_version_info(self):
+        """Changing git at the same path and refreshing affects version_info."""
+        with _rollback_refresh():
+            with _fake_git(11, 111, 1) as path1:
+                with _fake_git(22, 222, 2) as path2:
+                    new_git = Git()
+                    refresh(path1)
+                    new_git.version_info
+                    shutil.copy(path2, path1)
+                    refresh(path1)  # The fake git at path1 has a different version now.
+                    self.assertEqual(new_git.version_info, (22, 222, 2))
+
+    def test_successful_refresh_with_env_invalidates_cached_version_info(self):
+        with contextlib.ExitStack() as stack:
+            stack.enter_context(_rollback_refresh())
+            path1 = stack.enter_context(_fake_git(11, 111, 1))
+            path2 = stack.enter_context(_fake_git(22, 222, 2))
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": path1}):
+                new_git = Git()
+                refresh()
+                new_git.version_info
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": path2}):
+                refresh()
+                self.assertEqual(new_git.version_info, (22, 222, 2))
+
+    def test_failed_refresh_with_env_does_not_invalidate_cached_version_info(self):
+        with contextlib.ExitStack() as stack:
+            stack.enter_context(_rollback_refresh())
+            path1 = stack.enter_context(_fake_git(11, 111, 1))
+            path2 = stack.enter_context(_fake_git(22, 222, 2))
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": path1}):
+                new_git = Git()
+                refresh()
+                new_git.version_info
+            os.remove(path1)  # Arrange that a repeat call for path1 would fail.
+            os.remove(path2)  # Arrange that the new call for path2 will fail.
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": path2}):
+                with self.assertRaises(GitCommandNotFound):
+                    refresh(path2)
+                self.assertEqual(new_git.version_info, (11, 111, 1))
+
+    def test_successful_refresh_with_same_env_invalidates_cached_version_info(self):
+        """Changing git at the same path/command and refreshing affects version_info."""
+        with contextlib.ExitStack() as stack:
+            stack.enter_context(_rollback_refresh())
+            path1 = stack.enter_context(_fake_git(11, 111, 1))
+            path2 = stack.enter_context(_fake_git(22, 222, 2))
+            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": path1}):
+                new_git = Git()
+                refresh()
+                new_git.version_info
+                shutil.copy(path2, path1)
+                refresh()  # The fake git at path1 has a different version now.
+                self.assertEqual(new_git.version_info, (22, 222, 2))
+
+    def test_successful_default_refresh_invalidates_cached_version_info(self):
+        """Refreshing updates version after a filesystem change adds a git command."""
+        # The key assertion here is the last. The others mainly verify the test itself.
+        with contextlib.ExitStack() as stack:
+            stack.enter_context(_rollback_refresh())
+
+            path1 = Path(stack.enter_context(_fake_git(11, 111, 1)))
+            path2 = Path(stack.enter_context(_fake_git(22, 222, 2)))
+
+            new_path_var = f"{path1.parent}{os.pathsep}{path2.parent}"
+            stack.enter_context(mock.patch.dict(os.environ, {"PATH": new_path_var}))
+            stack.enter_context(_patch_out_env("GIT_PYTHON_GIT_EXECUTABLE"))
+
+            if sys.platform == "win32":
+                # On Windows, use a shell so "git" finds "git.cmd". The correct and safe
+                # ways to do this straightforwardly are to set GIT_PYTHON_GIT_EXECUTABLE
+                # to git.cmd in the environment, or call git.refresh with the command's
+                # full path. See the Git.USE_SHELL docstring for deprecation details.
+                # But this tests a "default" scenario where neither is done. The
+                # approach used here, setting USE_SHELL to True so PATHEXT is honored,
+                # should not be used in production code (nor even in most test cases).
+                stack.enter_context(mock.patch.object(Git, "USE_SHELL", True))
+
+            new_git = Git()
+            _rename_with_stem(path2, "git")  # "Install" git, "late" in the PATH.
+            refresh()
+            self.assertEqual(new_git.version_info, (22, 222, 2), 'before "downgrade"')
+            _rename_with_stem(path1, "git")  # "Install" another, higher priority.
+            self.assertEqual(new_git.version_info, (22, 222, 2), "stale version")
+            refresh()
+            self.assertEqual(new_git.version_info, (11, 111, 1), "fresh version")
+
+    def test_options_are_passed_to_git(self):
+        # This works because any command after git --version is ignored.
+        git_version = self.git(version=True).NoOp()
+        git_command_version = self.git.version()
+        self.assertEqual(git_version, git_command_version)
+
+    def test_persistent_options(self):
+        git_command_version = self.git.version()
+        # Analog to test_options_are_passed_to_git.
+        self.git.set_persistent_git_options(version=True)
+        git_version = self.git.NoOp()
+        self.assertEqual(git_version, git_command_version)
+        # Subsequent calls keep this option:
+        git_version_2 = self.git.NoOp()
+        self.assertEqual(git_version_2, git_command_version)
+
+        # Reset to empty:
+        self.git.set_persistent_git_options()
+        self.assertRaises(GitCommandError, self.git.NoOp)
+
+    def test_single_char_git_options_are_passed_to_git(self):
+        input_value = "TestValue"
+        output_value = self.git(c="user.name=%s" % input_value).config("--get", "user.name")
+        self.assertEqual(input_value, output_value)
+
+    def test_change_to_transform_kwargs_does_not_break_command_options(self):
+        self.git.log(n=1)
+
+    def test_insert_after_kwarg_raises(self):
+        # This isn't a complete add command, which doesn't matter here.
+        self.assertRaises(ValueError, self.git.remote, "add", insert_kwargs_after="foo")
+
+    def test_env_vars_passed_to_git(self):
+        editor = "non_existent_editor"
+        with mock.patch.dict(os.environ, {"GIT_EDITOR": editor}):
+            self.assertEqual(self.git.var("GIT_EDITOR"), editor)
+
+    @with_rw_directory
+    def test_environment(self, rw_dir):
+        # Sanity check.
+        self.assertEqual(self.git.environment(), {})
+
+        # Make sure the context manager works and cleans up after itself.
+        with self.git.custom_environment(PWD="/tmp"):
+            self.assertEqual(self.git.environment(), {"PWD": "/tmp"})
+
+        self.assertEqual(self.git.environment(), {})
+
+        old_env = self.git.update_environment(VARKEY="VARVALUE")
+        # The returned dict can be used to revert the change, hence why it has
+        # an entry with value 'None'.
+        self.assertEqual(old_env, {"VARKEY": None})
+        self.assertEqual(self.git.environment(), {"VARKEY": "VARVALUE"})
+
+        new_env = self.git.update_environment(**old_env)
+        self.assertEqual(new_env, {"VARKEY": "VARVALUE"})
+        self.assertEqual(self.git.environment(), {})
+
+        path = osp.join(rw_dir, "failing-script.sh")
+        with open(path, "wt") as stream:
+            stream.write("#!/usr/bin/env sh\necho FOO\n")
+        os.chmod(path, 0o777)
+
+        rw_repo = Repo.init(osp.join(rw_dir, "repo"))
+        remote = rw_repo.create_remote("ssh-origin", "ssh://git@server/foo")
+
+        with rw_repo.git.custom_environment(GIT_SSH=path):
+            try:
+                remote.fetch()
+            except GitCommandError as err:
+                self.assertIn("FOO", str(err))
+
+    def test_handle_process_output(self):
+        from git.cmd import handle_process_output, safer_popen
+
+        expected_line_count = 5002
+        actual_lines = [None, [], []]
+
+        def stdout_handler(line):
+            actual_lines[1].append(line)
+
+        def stderr_handler(line):
+            actual_lines[2].append(line)
+
+        cmdline = [
+            sys.executable,
+            "-S",  # Keep any `CoverageWarning` messages out of the subprocess stderr.
+            fixture_path("cat_file.py"),
+            str(fixture_path("issue-301_stderr")),
+        ]
+        proc = safer_popen(
+            cmdline,
+            stdin=None,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+            shell=False,
+        )
+
+        handle_process_output(proc, stdout_handler, stderr_handler, finalize_process)
+
+        self.assertEqual(len(actual_lines[1]), expected_line_count, repr(actual_lines[1]))
+        self.assertEqual(len(actual_lines[2]), expected_line_count, repr(actual_lines[2]))
+
+    def test_execute_kwargs_set_agrees_with_method(self):
+        parameter_names = inspect.signature(cmd.Git.execute).parameters.keys()
+        self_param, command_param, *most_params, extra_kwargs_param = parameter_names
+        self.assertEqual(self_param, "self")
+        self.assertEqual(command_param, "command")
+        self.assertEqual(set(most_params), cmd.execute_kwargs)  # Most important.
+        self.assertEqual(extra_kwargs_param, "subprocess_kwargs")
diff --git a/test/test_imports.py b/test/test_imports.py
new file mode 100644
index 000000000..8e70c6689
--- /dev/null
+++ b/test/test_imports.py
@@ -0,0 +1,32 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import sys
+
+import git
+
+
+def test_git_util_attribute_is_git_index_util():
+    """The top-level module's ``util`` attribute is really :mod:`git.index.util`.
+
+    Although this situation is unintuitive and not a design goal, this has historically
+    been the case, and it should not be changed without considering the effect on
+    backward compatibility. In practice, it cannot be changed at least until the next
+    major version of GitPython. This test checks that it is not accidentally changed,
+    which could happen when refactoring imports.
+    """
+    assert git.util is git.index.util
+
+
+def test_git_index_util_attribute_is_git_index_util():
+    """Nothing unusual is happening with git.index.util itself."""
+    assert git.index.util is sys.modules["git.index.util"]
+
+
+def test_separate_git_util_module_exists():
+    """The real git.util and git.index.util modules really are separate.
+
+    The real git.util module can be accessed to import a name ``...` by writing
+    ``from git.util import ...``, and the module object can be accessed in sys.modules.
+    """
+    assert sys.modules["git.util"] is not sys.modules["git.index.util"]
diff --git a/test/test_index.py b/test/test_index.py
new file mode 100644
index 000000000..cf3b90fa6
--- /dev/null
+++ b/test/test_index.py
@@ -0,0 +1,1241 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import contextlib
+from dataclasses import dataclass
+from io import BytesIO
+import logging
+import os
+import os.path as osp
+from pathlib import Path
+import re
+import shutil
+from stat import S_ISLNK, ST_MODE
+import subprocess
+import sys
+import tempfile
+from unittest import mock
+
+from gitdb.base import IStream
+
+import ddt
+import pytest
+
+from git import BlobFilter, Diff, Git, IndexFile, Object, Repo, Tree
+from git.exc import (
+    CheckoutError,
+    GitCommandError,
+    HookExecutionError,
+    InvalidGitRepositoryError,
+    UnmergedEntriesError,
+)
+from git.index.fun import hook_path, run_commit_hook
+from git.index.typ import BaseIndexEntry, IndexEntry
+from git.index.util import TemporaryFileSwap
+from git.objects import Blob
+from git.util import Actor, cwd, hex_to_bin, rmtree
+
+from test.lib import (
+    TestBase,
+    VirtualEnvironment,
+    fixture,
+    fixture_path,
+    with_rw_directory,
+    with_rw_repo,
+)
+
+HOOKS_SHEBANG = "#!/usr/bin/env sh\n"
+
+_logger = logging.getLogger(__name__)
+
+
+def _get_windows_ansi_encoding():
+    """Get the encoding specified by the Windows system-wide ANSI active code page."""
+    # locale.getencoding may work but is only in Python 3.11+. Use the registry instead.
+    import winreg
+
+    hklm_path = R"SYSTEM\CurrentControlSet\Control\Nls\CodePage"
+    with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, hklm_path) as key:
+        value, _ = winreg.QueryValueEx(key, "ACP")
+    return f"cp{value}"
+
+
+class WinBashStatus:
+    """Namespace of native-Windows bash.exe statuses. Affects what hook tests can pass.
+
+    Call check() to check the status. (CheckError and WinError should not typically be
+    used to trigger skip or xfail, because they represent unexpected situations.)
+    """
+
+    @dataclass
+    class Inapplicable:
+        """This system is not native Windows: either not Windows at all, or Cygwin."""
+
+    @dataclass
+    class Absent:
+        """No command for bash.exe is found on the system."""
+
+    @dataclass
+    class Native:
+        """Running bash.exe operates outside any WSL distribution (as with Git Bash)."""
+
+    @dataclass
+    class Wsl:
+        """Running bash.exe calls bash in a WSL distribution."""
+
+    @dataclass
+    class WslNoDistro:
+        """Running bash.exe tries to run bash on a WSL distribution, but none exists."""
+
+        process: "subprocess.CompletedProcess[bytes]"
+        message: str
+
+    @dataclass
+    class CheckError:
+        """Running bash.exe fails in an unexpected error or gives unexpected output."""
+
+        process: "subprocess.CompletedProcess[bytes]"
+        message: str
+
+    @dataclass
+    class WinError:
+        """bash.exe may exist but can't run. CreateProcessW fails unexpectedly."""
+
+        exception: OSError
+
+    @classmethod
+    def check(cls):
+        """Check the status of the bash.exe that run_commit_hook will try to use.
+
+        This runs a command with bash.exe and checks the result. On Windows, shell and
+        non-shell executable search differ; shutil.which often finds the wrong bash.exe.
+
+        run_commit_hook uses Popen, including to run bash.exe on Windows. It doesn't
+        pass shell=True (and shouldn't). On Windows, Popen calls CreateProcessW, which
+        checks some locations before using the PATH environment variable. It is expected
+        to try System32, even if another directory with the executable precedes it in
+        PATH. When WSL is present, even with no distributions, bash.exe usually exists
+        in System32; Popen finds it even if a shell would run another one, as on CI.
+        (Without WSL, System32 may still have bash.exe; users sometimes put it there.)
+        """
+        if sys.platform != "win32":
+            return cls.Inapplicable()
+
+        try:
+            # Output rather than forwarding the test command's exit status so that if a
+            # failure occurs before we even get to this point, we will detect it. For
+            # information on ways to check for WSL, see https://superuser.com/a/1749811.
+            script = 'test -e /proc/sys/fs/binfmt_misc/WSLInterop; echo "$?"'
+            command = ["bash.exe", "-c", script]
+            process = subprocess.run(command, capture_output=True)
+        except FileNotFoundError:
+            return cls.Absent()
+        except OSError as error:
+            return cls.WinError(error)
+
+        text = cls._decode(process.stdout).rstrip()  # stdout includes WSL's own errors.
+
+        if process.returncode == 1 and re.search(r"\bhttps://aka.ms/wslstore\b", text):
+            return cls.WslNoDistro(process, text)
+        if process.returncode != 0:
+            _logger.error("Error running bash.exe to check WSL status: %s", text)
+            return cls.CheckError(process, text)
+        if text == "0":
+            return cls.Wsl()
+        if text == "1":
+            return cls.Native()
+        _logger.error("Strange output checking WSL status: %s", text)
+        return cls.CheckError(process, text)
+
+    @staticmethod
+    def _decode(stdout):
+        """Decode bash.exe output as best we can."""
+        # When bash.exe is the WSL wrapper but the output is from WSL itself rather than
+        # code running in a distribution, the output is often in UTF-16LE, which Windows
+        # uses internally. The UTF-16LE representation of a Windows-style line ending is
+        # rarely seen otherwise, so use it to detect this situation.
+        if b"\r\0\n\0" in stdout:
+            return stdout.decode("utf-16le")
+
+        # At this point, the output is either blank or probably not UTF-16LE. It's often
+        # UTF-8 from inside a WSL distro or non-WSL bash shell. Our test command only
+        # uses the ASCII subset, so we can safely guess a wrong code page for it. Errors
+        # from such an environment can contain any text, but unlike WSL's own messages,
+        # they go to stderr, not stdout. So we can try the system ANSI code page first.
+        acp = _get_windows_ansi_encoding()
+        try:
+            return stdout.decode(acp)
+        except UnicodeDecodeError:
+            pass
+        except LookupError as error:
+            _logger.warning(str(error))  # Message already says "Unknown encoding:".
+
+        # Assume UTF-8. If invalid, substitute Unicode replacement characters.
+        return stdout.decode("utf-8", errors="replace")
+
+
+_win_bash_status = WinBashStatus.check()
+
+
+def _make_hook(git_dir, name, content, make_exec=True):
+    """A helper to create a hook"""
+    hp = hook_path(name, git_dir)
+    hpd = osp.dirname(hp)
+    if not osp.isdir(hpd):
+        os.mkdir(hpd)
+    with open(hp, "wt") as fp:
+        fp.write(HOOKS_SHEBANG + content)
+    if make_exec:
+        os.chmod(hp, 0o744)
+    return hp
+
+
+@ddt.ddt
+class TestIndex(TestBase):
+    def __init__(self, *args):
+        super().__init__(*args)
+        self._reset_progress()
+
+    def _assert_fprogress(self, entries):
+        self.assertEqual(len(entries), len(self._fprogress_map))
+        for _path, call_count in self._fprogress_map.items():
+            self.assertEqual(call_count, 2)
+        # END for each item in progress map
+        self._reset_progress()
+
+    def _fprogress(self, path, done, item):
+        self._fprogress_map.setdefault(path, 0)
+        curval = self._fprogress_map[path]
+        if curval == 0:
+            assert not done
+        if curval == 1:
+            assert done
+        self._fprogress_map[path] = curval + 1
+
+    def _fprogress_add(self, path, done, item):
+        """Called as progress func - we keep track of the proper call order."""
+        assert item is not None
+        self._fprogress(path, done, item)
+
+    def _reset_progress(self):
+        # Maps paths to the count of calls.
+        self._fprogress_map = {}
+
+    def _assert_entries(self, entries):
+        for entry in entries:
+            assert isinstance(entry, BaseIndexEntry)
+            assert not osp.isabs(entry.path)
+            assert "\\" not in entry.path
+        # END for each entry
+
+    def test_index_file_base(self):
+        # Read from file.
+        index = IndexFile(self.rorepo, fixture_path("index"))
+        assert index.entries
+        assert index.version > 0
+
+        # Test entry.
+        entry = next(iter(index.entries.values()))
+        for attr in (
+            "path",
+            "ctime",
+            "mtime",
+            "dev",
+            "inode",
+            "mode",
+            "uid",
+            "gid",
+            "size",
+            "binsha",
+            "hexsha",
+            "stage",
+        ):
+            getattr(entry, attr)
+        # END for each method
+
+        # Test update.
+        entries = index.entries
+        assert isinstance(index.update(), IndexFile)
+        assert entries is not index.entries
+
+        # Test stage.
+        index_merge = IndexFile(self.rorepo, fixture_path("index_merge"))
+        self.assertEqual(len(index_merge.entries), 106)
+        assert len([e for e in index_merge.entries.values() if e.stage != 0])
+
+        # Write the data - it must match the original.
+        tmpfile = tempfile.mktemp()
+        index_merge.write(tmpfile)
+        with open(tmpfile, "rb") as fp:
+            self.assertEqual(fp.read(), fixture("index_merge"))
+        os.remove(tmpfile)
+
+    def _cmp_tree_index(self, tree, index):
+        # Fail unless both objects contain the same paths and blobs.
+        if isinstance(tree, str):
+            tree = self.rorepo.commit(tree).tree
+
+        blist = []
+        for blob in tree.traverse(predicate=lambda e, d: e.type == "blob", branch_first=False):
+            assert (blob.path, 0) in index.entries
+            blist.append(blob)
+        # END for each blob in tree
+        if len(blist) != len(index.entries):
+            iset = {k[0] for k in index.entries.keys()}
+            bset = {b.path for b in blist}
+            raise AssertionError(
+                "CMP Failed: Missing entries in index: %s, missing in tree: %s" % (bset - iset, iset - bset)
+            )
+        # END assertion message
+
+    @with_rw_repo("0.1.6")
+    def test_index_lock_handling(self, rw_repo):
+        def add_bad_blob():
+            rw_repo.index.add([Blob(rw_repo, b"f" * 20, "bad-permissions", "foo")])
+
+        try:
+            ## First, fail on purpose adding into index.
+            add_bad_blob()
+        except Exception as ex:
+            msg_py3 = "required argument is not an integer"
+            msg_py2 = "cannot convert argument to integer"
+            assert msg_py2 in str(ex) or msg_py3 in str(ex)
+
+        ## The second time should not fail due to stray lock file.
+        try:
+            add_bad_blob()
+        except Exception as ex:
+            assert "index.lock' could not be obtained" not in str(ex)
+
+    @with_rw_repo("0.1.6")
+    def test_index_file_from_tree(self, rw_repo):
+        common_ancestor_sha = "5117c9c8a4d3af19a9958677e45cda9269de1541"
+        cur_sha = "4b43ca7ff72d5f535134241e7c797ddc9c7a3573"
+        other_sha = "39f85c4358b7346fee22169da9cad93901ea9eb9"
+
+        # Simple index from tree.
+        base_index = IndexFile.from_tree(rw_repo, common_ancestor_sha)
+        assert base_index.entries
+        self._cmp_tree_index(common_ancestor_sha, base_index)
+
+        # Merge two trees - it's like a fast-forward.
+        two_way_index = IndexFile.from_tree(rw_repo, common_ancestor_sha, cur_sha)
+        assert two_way_index.entries
+        self._cmp_tree_index(cur_sha, two_way_index)
+
+        # Merge three trees - here we have a merge conflict.
+        three_way_index = IndexFile.from_tree(rw_repo, common_ancestor_sha, cur_sha, other_sha)
+        assert len([e for e in three_way_index.entries.values() if e.stage != 0])
+
+        # ITERATE BLOBS
+
+        def merge_required(t):
+            return t[0] != 0
+
+        merge_blobs = list(three_way_index.iter_blobs(merge_required))
+        assert merge_blobs
+        assert merge_blobs[0][0] in (1, 2, 3)
+        assert isinstance(merge_blobs[0][1], Blob)
+
+        # Test BlobFilter.
+        prefix = "lib/git"
+        for _stage, blob in base_index.iter_blobs(BlobFilter([prefix])):
+            assert blob.path.startswith(prefix)
+
+        # Writing a tree should fail with an unmerged index.
+        self.assertRaises(UnmergedEntriesError, three_way_index.write_tree)
+
+        # Removed unmerged entries.
+        unmerged_blob_map = three_way_index.unmerged_blobs()
+        assert unmerged_blob_map
+
+        # Pick the first blob at the first stage we find and use it as resolved version.
+        three_way_index.resolve_blobs(line[0][1] for line in unmerged_blob_map.values())
+        tree = three_way_index.write_tree()
+        assert isinstance(tree, Tree)
+        num_blobs = 0
+        for blob in tree.traverse(predicate=lambda item, d: item.type == "blob"):
+            assert (blob.path, 0) in three_way_index.entries
+            num_blobs += 1
+        # END for each blob
+        self.assertEqual(num_blobs, len(three_way_index.entries))
+
+    @with_rw_repo("0.1.6")
+    def test_index_merge_tree(self, rw_repo):
+        # A bit out of place, but we need a different repo for this:
+        self.assertNotEqual(self.rorepo, rw_repo)
+        self.assertEqual(len({self.rorepo, self.rorepo, rw_repo, rw_repo}), 2)
+
+        # SINGLE TREE MERGE
+        # Current index is at the (virtual) cur_commit.
+        next_commit = "4c39f9da792792d4e73fc3a5effde66576ae128c"
+        parent_commit = rw_repo.head.commit.parents[0]
+        manifest_key = IndexFile.entry_key("MANIFEST.in", 0)
+        manifest_entry = rw_repo.index.entries[manifest_key]
+        rw_repo.index.merge_tree(next_commit)
+        # Only one change should be recorded.
+        assert manifest_entry.binsha != rw_repo.index.entries[manifest_key].binsha
+
+        rw_repo.index.reset(rw_repo.head)
+        self.assertEqual(rw_repo.index.entries[manifest_key].binsha, manifest_entry.binsha)
+
+        # FAKE MERGE
+        #############
+        # Add a change with a NULL sha that should conflict with next_commit. We pretend
+        # there was a change, but we do not even bother adding a proper sha for it
+        # (which makes things faster of course).
+        manifest_fake_entry = BaseIndexEntry((manifest_entry[0], b"\0" * 20, 0, manifest_entry[3]))
+        # Try write flag.
+        self._assert_entries(rw_repo.index.add([manifest_fake_entry], write=False))
+        # Add actually resolves the null-hex-sha for us as a feature, but we can edit
+        # the index manually.
+        assert rw_repo.index.entries[manifest_key].binsha != Object.NULL_BIN_SHA
+        # We must operate on the same index for this! It's a bit problematic as it might
+        # confuse people.
+        index = rw_repo.index
+        index.entries[manifest_key] = IndexEntry.from_base(manifest_fake_entry)
+        index.write()
+        self.assertEqual(rw_repo.index.entries[manifest_key].hexsha, Diff.NULL_HEX_SHA)
+
+        # Write an unchanged index (just for the fun of it).
+        rw_repo.index.write()
+
+        # A three way merge would result in a conflict and fails as the command will not
+        # overwrite any entries in our index and hence leave them unmerged. This is
+        # mainly a protection feature as the current index is not yet in a tree.
+        self.assertRaises(GitCommandError, index.merge_tree, next_commit, base=parent_commit)
+
+        # The only way to get the merged entries is to safe the current index away into
+        # a tree, which is like a temporary commit for us. This fails as well as the
+        # NULL sha does not have a corresponding object.
+        # NOTE: missing_ok is not a kwarg anymore, missing_ok is always true.
+        # self.assertRaises(GitCommandError, index.write_tree)
+
+        # If missing objects are okay, this would work though (they are always okay
+        # now). As we can't read back the tree with NULL_SHA, we rather set it to
+        # something else.
+        index.entries[manifest_key] = IndexEntry(manifest_entry[:1] + (hex_to_bin("f" * 40),) + manifest_entry[2:])
+        tree = index.write_tree()
+
+        # Now make a proper three way merge with unmerged entries.
+        unmerged_tree = IndexFile.from_tree(rw_repo, parent_commit, tree, next_commit)
+        unmerged_blobs = unmerged_tree.unmerged_blobs()
+        self.assertEqual(len(unmerged_blobs), 1)
+        self.assertEqual(list(unmerged_blobs.keys())[0], manifest_key[0])
+
+    @with_rw_repo("0.1.6")
+    def test_index_file_diffing(self, rw_repo):
+        # Default IndexFile instance points to our index.
+        index = IndexFile(rw_repo)
+        assert index.path is not None
+        assert len(index.entries)
+
+        # Write the file back.
+        index.write()
+
+        # Could sha it, or check stats.
+
+        # Test diff.
+        # Resetting the head will leave the index in a different state, and the diff
+        # will yield a few changes.
+        cur_head_commit = rw_repo.head.reference.commit
+        rw_repo.head.reset("HEAD~6", index=True, working_tree=False)
+
+        # Diff against same index is 0.
+        diff = index.diff()
+        self.assertEqual(len(diff), 0)
+
+        # Against HEAD as string, must be the same as it matches index.
+        diff = index.diff("HEAD")
+        self.assertEqual(len(diff), 0)
+
+        # Against previous head, there must be a difference.
+        diff = index.diff(cur_head_commit)
+        assert len(diff)
+
+        # We reverse the result.
+        adiff = index.diff(str(cur_head_commit), R=True)
+        odiff = index.diff(cur_head_commit, R=False)  # Now its not reversed anymore.
+        assert adiff != odiff
+        self.assertEqual(odiff, diff)  # Both unreversed diffs against HEAD.
+
+        # Against working copy - it's still at cur_commit.
+        wdiff = index.diff(None)
+        assert wdiff != adiff
+        assert wdiff != odiff
+
+        # Against something unusual.
+        self.assertRaises(ValueError, index.diff, int)
+
+        # Adjust the index to match an old revision.
+        cur_branch = rw_repo.active_branch
+        cur_commit = cur_branch.commit
+        rev_head_parent = "HEAD~1"
+        assert index.reset(rev_head_parent) is index
+
+        self.assertEqual(cur_branch, rw_repo.active_branch)
+        self.assertEqual(cur_commit, rw_repo.head.commit)
+
+        # There must be differences towards the working tree which is in the 'future'.
+        assert index.diff(None)
+
+        # Reset the working copy as well to current head, to pull 'back' as well.
+        new_data = b"will be reverted"
+        file_path = osp.join(rw_repo.working_tree_dir, "CHANGES")
+        with open(file_path, "wb") as fp:
+            fp.write(new_data)
+        index.reset(rev_head_parent, working_tree=True)
+        assert not index.diff(None)
+        self.assertEqual(cur_branch, rw_repo.active_branch)
+        self.assertEqual(cur_commit, rw_repo.head.commit)
+        with open(file_path, "rb") as fp:
+            assert fp.read() != new_data
+
+        # Test full checkout.
+        test_file = osp.join(rw_repo.working_tree_dir, "CHANGES")
+        with open(test_file, "ab") as fd:
+            fd.write(b"some data")
+        rval = index.checkout(None, force=True, fprogress=self._fprogress)
+        assert "CHANGES" in list(rval)
+        self._assert_fprogress([None])
+        assert osp.isfile(test_file)
+
+        os.remove(test_file)
+        rval = index.checkout(None, force=False, fprogress=self._fprogress)
+        assert "CHANGES" in list(rval)
+        self._assert_fprogress([None])
+        assert osp.isfile(test_file)
+
+        # Individual file.
+        os.remove(test_file)
+        rval = index.checkout(test_file, fprogress=self._fprogress)
+        self.assertEqual(list(rval)[0], "CHANGES")
+        self._assert_fprogress([test_file])
+        assert osp.exists(test_file)
+
+        # Checking out non-existing file throws.
+        self.assertRaises(CheckoutError, index.checkout, "doesnt_exist_ever.txt.that")
+        self.assertRaises(CheckoutError, index.checkout, paths=["doesnt/exist"])
+
+        # Check out file with modifications.
+        append_data = b"hello"
+        with open(test_file, "ab") as fp:
+            fp.write(append_data)
+        try:
+            index.checkout(test_file)
+        except CheckoutError as e:
+            # Detailed exceptions are only possible in older git versions.
+            if rw_repo.git.version_info < (2, 29):
+                self.assertEqual(len(e.failed_files), 1)
+                self.assertEqual(e.failed_files[0], osp.basename(test_file))
+                self.assertEqual(len(e.failed_files), len(e.failed_reasons))
+                self.assertIsInstance(e.failed_reasons[0], str)
+                self.assertEqual(len(e.valid_files), 0)
+                with open(test_file, "rb") as fd:
+                    s = fd.read()
+                self.assertTrue(s.endswith(append_data), s)
+        else:
+            raise AssertionError("Exception CheckoutError not thrown")
+
+        # If we force it, it should work.
+        index.checkout(test_file, force=True)
+        assert not open(test_file, "rb").read().endswith(append_data)
+
+        # Check out directory.
+        rmtree(osp.join(rw_repo.working_tree_dir, "lib"))
+        rval = index.checkout("lib")
+        assert len(list(rval)) > 1
+
+    def _count_existing(self, repo, files):
+        """Return count of files that actually exist in the repository directory."""
+        existing = 0
+        basedir = repo.working_tree_dir
+        for f in files:
+            existing += osp.isfile(osp.join(basedir, f))
+        # END for each deleted file
+        return existing
+
+    # END num existing helper
+
+    @pytest.mark.xfail(
+        sys.platform == "win32" and Git().config("core.symlinks") == "true",
+        reason="Assumes symlinks are not created on Windows and opens a symlink to a nonexistent target.",
+        raises=FileNotFoundError,
+    )
+    @with_rw_repo("0.1.6")
+    def test_index_mutation(self, rw_repo):
+        index = rw_repo.index
+        num_entries = len(index.entries)
+        cur_head = rw_repo.head
+
+        uname = "Thomas Müller"
+        umail = "sd@company.com"
+        with rw_repo.config_writer() as writer:
+            writer.set_value("user", "name", uname)
+            writer.set_value("user", "email", umail)
+        self.assertEqual(writer.get_value("user", "name"), uname)
+
+        # Remove all of the files, provide a wild mix of paths, BaseIndexEntries,
+        # IndexEntries.
+        def mixed_iterator():
+            count = 0
+            for entry in index.entries.values():
+                type_id = count % 5
+                if type_id == 0:  # path (str)
+                    yield entry.path
+                elif type_id == 1:  # path (PathLike)
+                    yield Path(entry.path)
+                elif type_id == 2:  # blob
+                    yield Blob(rw_repo, entry.binsha, entry.mode, entry.path)
+                elif type_id == 3:  # BaseIndexEntry
+                    yield BaseIndexEntry(entry[:4])
+                elif type_id == 4:  # IndexEntry
+                    yield entry
+                else:
+                    raise AssertionError("Invalid Type")
+                count += 1
+            # END for each entry
+
+        # END mixed iterator
+        deleted_files = index.remove(mixed_iterator(), working_tree=False)
+        assert deleted_files
+        self.assertEqual(self._count_existing(rw_repo, deleted_files), len(deleted_files))
+        self.assertEqual(len(index.entries), 0)
+
+        # Reset the index to undo our changes.
+        index.reset()
+        self.assertEqual(len(index.entries), num_entries)
+
+        # Remove with working copy.
+        deleted_files = index.remove(mixed_iterator(), working_tree=True)
+        assert deleted_files
+        self.assertEqual(self._count_existing(rw_repo, deleted_files), 0)
+
+        # Reset everything.
+        index.reset(working_tree=True)
+        self.assertEqual(self._count_existing(rw_repo, deleted_files), len(deleted_files))
+
+        # Invalid type.
+        self.assertRaises(TypeError, index.remove, [1])
+
+        # Absolute path.
+        deleted_files = index.remove([osp.join(rw_repo.working_tree_dir, "lib")], r=True)
+        assert len(deleted_files) > 1
+        self.assertRaises(ValueError, index.remove, ["/doesnt/exists"])
+
+        # TEST COMMITTING
+        # Commit changed index.
+        cur_commit = cur_head.commit
+        commit_message = "commit default head by Frèderic Çaufl€"
+
+        new_commit = index.commit(commit_message, head=False)
+        assert cur_commit != new_commit
+        self.assertEqual(new_commit.author.name, uname)
+        self.assertEqual(new_commit.author.email, umail)
+        self.assertEqual(new_commit.committer.name, uname)
+        self.assertEqual(new_commit.committer.email, umail)
+        self.assertEqual(new_commit.message, commit_message)
+        self.assertEqual(new_commit.parents[0], cur_commit)
+        self.assertEqual(len(new_commit.parents), 1)
+        self.assertEqual(cur_head.commit, cur_commit)
+
+        # Commit with other actor.
+        cur_commit = cur_head.commit
+
+        my_author = Actor("Frèderic Çaufl€", "author@example.com")
+        my_committer = Actor("Committing Frèderic Çaufl€", "committer@example.com")
+        commit_actor = index.commit(commit_message, author=my_author, committer=my_committer)
+        assert cur_commit != commit_actor
+        self.assertEqual(commit_actor.author.name, "Frèderic Çaufl€")
+        self.assertEqual(commit_actor.author.email, "author@example.com")
+        self.assertEqual(commit_actor.committer.name, "Committing Frèderic Çaufl€")
+        self.assertEqual(commit_actor.committer.email, "committer@example.com")
+        self.assertEqual(commit_actor.message, commit_message)
+        self.assertEqual(commit_actor.parents[0], cur_commit)
+        self.assertEqual(len(new_commit.parents), 1)
+        self.assertEqual(cur_head.commit, commit_actor)
+        self.assertEqual(cur_head.log()[-1].actor, my_committer)
+
+        # Commit with author_date and commit_date.
+        cur_commit = cur_head.commit
+        commit_message = "commit with dates by Avinash Sajjanshetty"
+
+        new_commit = index.commit(
+            commit_message,
+            author_date="2006-04-07T22:13:13",
+            commit_date="2005-04-07T22:13:13",
+        )
+        assert cur_commit != new_commit
+        print(new_commit.authored_date, new_commit.committed_date)
+        self.assertEqual(new_commit.message, commit_message)
+        self.assertEqual(new_commit.authored_date, 1144447993)
+        self.assertEqual(new_commit.committed_date, 1112911993)
+
+        # Same index, no parents.
+        commit_message = "index without parents"
+        commit_no_parents = index.commit(commit_message, parent_commits=[], head=True)
+        self.assertEqual(commit_no_parents.message, commit_message)
+        self.assertEqual(len(commit_no_parents.parents), 0)
+        self.assertEqual(cur_head.commit, commit_no_parents)
+
+        # same index, multiple parents.
+        commit_message = "Index with multiple parents\n    commit with another line"
+        commit_multi_parent = index.commit(commit_message, parent_commits=(commit_no_parents, new_commit))
+        self.assertEqual(commit_multi_parent.message, commit_message)
+        self.assertEqual(len(commit_multi_parent.parents), 2)
+        self.assertEqual(commit_multi_parent.parents[0], commit_no_parents)
+        self.assertEqual(commit_multi_parent.parents[1], new_commit)
+        self.assertEqual(cur_head.commit, commit_multi_parent)
+
+        # Re-add all files in lib.
+        # Get the lib folder back on disk, but get an index without it.
+        index.reset(new_commit.parents[0], working_tree=True).reset(new_commit, working_tree=False)
+        lib_file_path = osp.join("lib", "git", "__init__.py")
+        assert (lib_file_path, 0) not in index.entries
+        assert osp.isfile(osp.join(rw_repo.working_tree_dir, lib_file_path))
+
+        # Directory.
+        entries = index.add(["lib"], fprogress=self._fprogress_add)
+        self._assert_entries(entries)
+        self._assert_fprogress(entries)
+        assert len(entries) > 1
+
+        # Glob.
+        entries = index.reset(new_commit).add([osp.join("lib", "git", "*.py")], fprogress=self._fprogress_add)
+        self._assert_entries(entries)
+        self._assert_fprogress(entries)
+        self.assertEqual(len(entries), 14)
+
+        # Same file.
+        entries = index.reset(new_commit).add(
+            [osp.join(rw_repo.working_tree_dir, "lib", "git", "head.py")] * 2,
+            fprogress=self._fprogress_add,
+        )
+        self._assert_entries(entries)
+        self.assertEqual(entries[0].mode & 0o644, 0o644)
+        # Would fail, test is too primitive to handle this case.
+        # self._assert_fprogress(entries)
+        self._reset_progress()
+        self.assertEqual(len(entries), 2)
+
+        # Missing path.
+        self.assertRaises(OSError, index.reset(new_commit).add, ["doesnt/exist/must/raise"])
+
+        # Blob from older revision overrides current index revision.
+        old_blob = new_commit.parents[0].tree.blobs[0]
+        entries = index.reset(new_commit).add([old_blob], fprogress=self._fprogress_add)
+        self._assert_entries(entries)
+        self._assert_fprogress(entries)
+        self.assertEqual(index.entries[(old_blob.path, 0)].hexsha, old_blob.hexsha)
+        self.assertEqual(len(entries), 1)
+
+        # Mode 0 not allowed.
+        null_hex_sha = Diff.NULL_HEX_SHA
+        null_bin_sha = b"\0" * 20
+        self.assertRaises(
+            ValueError,
+            index.reset(new_commit).add,
+            [BaseIndexEntry((0, null_bin_sha, 0, "doesntmatter"))],
+        )
+
+        # Add new file.
+        new_file_relapath = "my_new_file"
+        self._make_file(new_file_relapath, "hello world", rw_repo)
+        entries = index.reset(new_commit).add(
+            [BaseIndexEntry((0o10644, null_bin_sha, 0, new_file_relapath))],
+            fprogress=self._fprogress_add,
+        )
+        self._assert_entries(entries)
+        self._assert_fprogress(entries)
+        self.assertEqual(len(entries), 1)
+        self.assertNotEqual(entries[0].hexsha, null_hex_sha)
+
+        # Add symlink.
+        if sys.platform != "win32":
+            for target in ("/etc/nonexisting", "/etc/passwd", "/etc"):
+                basename = "my_real_symlink"
+
+                link_file = osp.join(rw_repo.working_tree_dir, basename)
+                os.symlink(target, link_file)
+                entries = index.reset(new_commit).add([link_file], fprogress=self._fprogress_add)
+                self._assert_entries(entries)
+                self._assert_fprogress(entries)
+                self.assertEqual(len(entries), 1)
+                self.assertTrue(S_ISLNK(entries[0].mode))
+                self.assertTrue(S_ISLNK(index.entries[index.entry_key("my_real_symlink", 0)].mode))
+
+                # We expect only the target to be written.
+                self.assertEqual(
+                    index.repo.odb.stream(entries[0].binsha).read().decode("ascii"),
+                    target,
+                )
+
+                os.remove(link_file)
+            # END for each target
+        # END real symlink test
+
+        # Add fake symlink and assure it checks out as a symlink.
+        fake_symlink_relapath = "my_fake_symlink"
+        link_target = "/etc/that"
+        fake_symlink_path = self._make_file(fake_symlink_relapath, link_target, rw_repo)
+        fake_entry = BaseIndexEntry((0o120000, null_bin_sha, 0, fake_symlink_relapath))
+        entries = index.reset(new_commit).add([fake_entry], fprogress=self._fprogress_add)
+        self._assert_entries(entries)
+        self._assert_fprogress(entries)
+        assert entries[0].hexsha != null_hex_sha
+        self.assertEqual(len(entries), 1)
+        self.assertTrue(S_ISLNK(entries[0].mode))
+
+        # Check that this also works with an alternate method.
+        full_index_entry = IndexEntry.from_base(BaseIndexEntry((0o120000, entries[0].binsha, 0, entries[0].path)))
+        entry_key = index.entry_key(full_index_entry)
+        index.reset(new_commit)
+
+        assert entry_key not in index.entries
+        index.entries[entry_key] = full_index_entry
+        index.write()
+        index.update()  # Force reread of entries.
+        new_entry = index.entries[entry_key]
+        assert S_ISLNK(new_entry.mode)
+
+        # A tree created from this should contain the symlink.
+        tree = index.write_tree()
+        assert fake_symlink_relapath in tree
+        index.write()  # Flush our changes for the checkout.
+
+        # Check out the fake link, should be a link then.
+        assert not S_ISLNK(os.stat(fake_symlink_path)[ST_MODE])
+        os.remove(fake_symlink_path)
+        index.checkout(fake_symlink_path)
+
+        # On Windows, we currently assume we will never get symlinks.
+        if sys.platform == "win32":
+            # Symlinks should contain the link as text (which is what a
+            # symlink actually is).
+            with open(fake_symlink_path, "rt") as fd:
+                self.assertEqual(fd.read(), link_target)
+        else:
+            self.assertTrue(S_ISLNK(os.lstat(fake_symlink_path)[ST_MODE]))
+
+        # TEST RENAMING
+        def assert_mv_rval(rval):
+            for source, dest in rval:
+                assert not osp.exists(source) and osp.exists(dest)
+            # END for each renamed item
+
+        # END move assertion utility
+
+        self.assertRaises(ValueError, index.move, ["just_one_path"])
+        # Try to move a file onto an existing file.
+        files = ["AUTHORS", "LICENSE"]
+        self.assertRaises(GitCommandError, index.move, files)
+
+        # Again, with force.
+        assert_mv_rval(index.move(files, f=True))
+
+        # Move files into a directory - dry run.
+        paths = ["LICENSE", "VERSION", "doc"]
+        rval = index.move(paths, dry_run=True)
+        self.assertEqual(len(rval), 2)
+        assert osp.exists(paths[0])
+
+        # Again, no dry run.
+        rval = index.move(paths)
+        assert_mv_rval(rval)
+
+        # Move dir into dir.
+        rval = index.move(["doc", "test"])
+        assert_mv_rval(rval)
+
+        # TEST PATH REWRITING
+        ######################
+        count = [0]
+
+        def rewriter(entry):
+            rval = str(count[0])
+            count[0] += 1
+            return rval
+
+        # END rewriter
+
+        def make_paths():
+            """Help out the test by yielding two existing paths and one new path."""
+            yield "CHANGES"
+            yield "ez_setup.py"
+            yield index.entries[index.entry_key("README", 0)]
+            yield index.entries[index.entry_key(".gitignore", 0)]
+
+            for fid in range(3):
+                fname = "newfile%i" % fid
+                with open(fname, "wb") as fd:
+                    fd.write(b"abcd")
+                yield Blob(rw_repo, Blob.NULL_BIN_SHA, 0o100644, fname)
+            # END for each new file
+
+        # END path producer
+        paths = list(make_paths())
+        self._assert_entries(index.add(paths, path_rewriter=rewriter))
+
+        for filenum in range(len(paths)):
+            assert index.entry_key(str(filenum), 0) in index.entries
+
+        # TEST RESET ON PATHS
+        ######################
+        arela = "aa"
+        brela = "bb"
+        afile = self._make_file(arela, "adata", rw_repo)
+        bfile = self._make_file(brela, "bdata", rw_repo)
+        akey = index.entry_key(arela, 0)
+        bkey = index.entry_key(brela, 0)
+        keys = (akey, bkey)
+        absfiles = (afile, bfile)
+        files = (arela, brela)
+
+        for fkey in keys:
+            assert fkey not in index.entries
+
+        index.add(files, write=True)
+        nc = index.commit("2 files committed", head=False)
+
+        for fkey in keys:
+            assert fkey in index.entries
+
+        # Just the index.
+        index.reset(paths=(arela, afile))
+        assert akey not in index.entries
+        assert bkey in index.entries
+
+        # Now with working tree - files on disk as well as entries must be recreated.
+        rw_repo.head.commit = nc
+        for absfile in absfiles:
+            os.remove(absfile)
+
+        index.reset(working_tree=True, paths=files)
+
+        for fkey in keys:
+            assert fkey in index.entries
+        for absfile in absfiles:
+            assert osp.isfile(absfile)
+
+    @with_rw_repo("HEAD")
+    def test_compare_write_tree(self, rw_repo):
+        """Test writing all trees, comparing them for equality."""
+        # It's important to have a few submodules in there too.
+        max_count = 25
+        count = 0
+        for commit in rw_repo.head.commit.traverse():
+            if count >= max_count:
+                break
+            count += 1
+            index = rw_repo.index.reset(commit)
+            orig_tree = commit.tree
+            self.assertEqual(index.write_tree(), orig_tree)
+        # END for each commit
+
+    @with_rw_repo("HEAD", bare=False)
+    def test_index_single_addremove(self, rw_repo):
+        fp = osp.join(rw_repo.working_dir, "testfile.txt")
+        with open(fp, "w") as fs:
+            fs.write("content of testfile")
+        self._assert_entries(rw_repo.index.add(fp))
+        deleted_files = rw_repo.index.remove(fp)
+        assert deleted_files
+
+    def test_index_new(self):
+        B = self.rorepo.tree("6d9b1f4f9fa8c9f030e3207e7deacc5d5f8bba4e")
+        H = self.rorepo.tree("25dca42bac17d511b7e2ebdd9d1d679e7626db5f")
+        M = self.rorepo.tree("e746f96bcc29238b79118123028ca170adc4ff0f")
+
+        for args in ((B,), (B, H), (B, H, M)):
+            index = IndexFile.new(self.rorepo, *args)
+            assert isinstance(index, IndexFile)
+        # END for each arg tuple
+
+    @with_rw_repo("HEAD", bare=True)
+    def test_index_bare_add(self, rw_bare_repo):
+        # Something is wrong after cloning to a bare repo, reading the property
+        # rw_bare_repo.working_tree_dir will return '/tmp' instead of throwing the
+        # Exception we are expecting. This is a quick hack to make this test fail when
+        # expected.
+        assert rw_bare_repo.working_tree_dir is None
+        assert rw_bare_repo.bare
+        contents = b"This is a BytesIO file"
+        filesize = len(contents)
+        fileobj = BytesIO(contents)
+        filename = "my-imaginary-file"
+        istream = rw_bare_repo.odb.store(IStream(Blob.type, filesize, fileobj))
+        entry = BaseIndexEntry((0o100644, istream.binsha, 0, filename))
+        try:
+            rw_bare_repo.index.add([entry])
+        except AssertionError:
+            self.fail("Adding to the index of a bare repo is not allowed.")
+
+        # Adding using a path should still require a non-bare repository.
+        asserted = False
+        path = osp.join("git", "test", "test_index.py")
+        try:
+            rw_bare_repo.index.add([path])
+        except InvalidGitRepositoryError:
+            asserted = True
+        assert asserted, "Adding using a filename is not correctly asserted."
+
+    @with_rw_directory
+    def test_add_utf8P_path(self, rw_dir):
+        # NOTE: fp is not a Unicode object in Python 2
+        # (which is the source of the problem).
+        fp = osp.join(rw_dir, "ø.txt")
+        with open(fp, "wb") as fs:
+            fs.write("content of ø".encode("utf-8"))
+
+        r = Repo.init(rw_dir)
+        r.index.add([fp])
+        r.index.commit("Added orig and prestable")
+
+    @with_rw_directory
+    def test_add_a_file_with_wildcard_chars(self, rw_dir):
+        # See issue #407.
+        fp = osp.join(rw_dir, "[.exe")
+        with open(fp, "wb") as f:
+            f.write(b"something")
+
+        r = Repo.init(rw_dir)
+        r.index.add([fp])
+        r.index.commit("Added [.exe")
+
+    def test__to_relative_path_at_root(self):
+        root = osp.abspath(os.sep)
+
+        class Mocked:
+            bare = False
+            git_dir = root
+            working_tree_dir = root
+
+        repo = Mocked()
+        path = os.path.join(root, "file")
+        index = IndexFile(repo)
+
+        rel = index._to_relative_path(path)
+        self.assertEqual(rel, os.path.relpath(path, root))
+
+    def test__to_relative_path_absolute_trailing_slash(self):
+        repo_root = os.path.join(osp.abspath(os.sep), "directory1", "repo_root")
+
+        class Mocked:
+            bare = False
+            git_dir = repo_root
+            working_tree_dir = repo_root
+
+        repo = Mocked()
+        path = os.path.join(repo_root, f"directory2{os.sep}")
+        index = IndexFile(repo)
+
+        expected_path = f"directory2{os.sep}"
+        actual_path = index._to_relative_path(path)
+        self.assertEqual(expected_path, actual_path)
+
+        with mock.patch("git.index.base.os.path") as ospath_mock:
+            ospath_mock.relpath.return_value = f"directory2{os.sep}"
+            actual_path = index._to_relative_path(path)
+            self.assertEqual(expected_path, actual_path)
+
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.Absent,
+        reason="Can't run a hook on Windows without bash.exe.",
+        raises=HookExecutionError,
+    )
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.WslNoDistro,
+        reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
+        raises=HookExecutionError,
+    )
+    @with_rw_repo("HEAD", bare=True)
+    def test_run_commit_hook(self, rw_repo):
+        index = rw_repo.index
+        _make_hook(index.repo.git_dir, "fake-hook", "echo 'ran fake hook' >output.txt")
+        run_commit_hook("fake-hook", index)
+        output = Path(rw_repo.git_dir, "output.txt").read_text(encoding="utf-8")
+        self.assertEqual(output, "ran fake hook\n")
+
+    @ddt.data((False,), (True,))
+    @with_rw_directory
+    def test_hook_uses_shell_not_from_cwd(self, rw_dir, case):
+        (chdir_to_repo,) = case
+
+        shell_name = "bash.exe" if sys.platform == "win32" else "sh"
+        maybe_chdir = cwd(rw_dir) if chdir_to_repo else contextlib.nullcontext()
+        repo = Repo.init(rw_dir)
+
+        # We need an impostor shell that works on Windows and that the test can
+        # distinguish from the real bash.exe. But even if the real bash.exe is absent or
+        # unusable, we should verify the impostor is not run. So the impostor needs a
+        # clear side effect (unlike in TestGit.test_it_executes_git_not_from_cwd). Popen
+        # on Windows uses CreateProcessW, which disregards PATHEXT; the impostor may
+        # need to be a binary executable to ensure the vulnerability is found if
+        # present. No compiler need exist, shipping a binary in the test suite may
+        # target the wrong architecture, and generating one in a bespoke way may trigger
+        # false positive virus scans. So we use a Bash/Python polyglot for the hook and
+        # use the Python interpreter itself as the bash.exe impostor. But an interpreter
+        # from a venv may not run when copied outside of it, and a global interpreter
+        # won't run when copied to a different location if it was installed from the
+        # Microsoft Store. So we make a new venv in rw_dir and use its interpreter.
+        venv = VirtualEnvironment(rw_dir, with_pip=False)
+        shutil.copy(venv.python, Path(rw_dir, shell_name))
+        shutil.copy(fixture_path("polyglot"), hook_path("polyglot", repo.git_dir))
+        payload = Path(rw_dir, "payload.txt")
+
+        if type(_win_bash_status) in {WinBashStatus.Absent, WinBashStatus.WslNoDistro}:
+            # The real shell can't run, but the impostor should still not be used.
+            with self.assertRaises(HookExecutionError):
+                with maybe_chdir:
+                    run_commit_hook("polyglot", repo.index)
+            self.assertFalse(payload.exists())
+        else:
+            # The real shell should run, and not the impostor.
+            with maybe_chdir:
+                run_commit_hook("polyglot", repo.index)
+            self.assertFalse(payload.exists())
+            output = Path(rw_dir, "output.txt").read_text(encoding="utf-8")
+            self.assertEqual(output, "Ran intended hook.\n")
+
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.Absent,
+        reason="Can't run a hook on Windows without bash.exe.",
+        raises=HookExecutionError,
+    )
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.WslNoDistro,
+        reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
+        raises=HookExecutionError,
+    )
+    @with_rw_repo("HEAD", bare=True)
+    def test_pre_commit_hook_success(self, rw_repo):
+        index = rw_repo.index
+        _make_hook(index.repo.git_dir, "pre-commit", "exit 0")
+        index.commit("This should not fail")
+
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.WslNoDistro,
+        reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
+        raises=AssertionError,
+    )
+    @with_rw_repo("HEAD", bare=True)
+    def test_pre_commit_hook_fail(self, rw_repo):
+        index = rw_repo.index
+        hp = _make_hook(index.repo.git_dir, "pre-commit", "echo stdout; echo stderr 1>&2; exit 1")
+        try:
+            index.commit("This should fail")
+        except HookExecutionError as err:
+            if type(_win_bash_status) is WinBashStatus.Absent:
+                self.assertIsInstance(err.status, OSError)
+                self.assertEqual(err.command, [hp])
+                self.assertEqual(err.stdout, "")
+                self.assertEqual(err.stderr, "")
+                assert str(err)
+            else:
+                self.assertEqual(err.status, 1)
+                self.assertEqual(err.command, [hp])
+                self.assertEqual(err.stdout, "\n  stdout: 'stdout\n'")
+                self.assertEqual(err.stderr, "\n  stderr: 'stderr\n'")
+                assert str(err)
+        else:
+            raise AssertionError("Should have caught a HookExecutionError")
+
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.Absent,
+        reason="Can't run a hook on Windows without bash.exe.",
+        raises=HookExecutionError,
+    )
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.Wsl,
+        reason="Specifically seems to fail on WSL bash (in spite of #1399)",
+        raises=AssertionError,
+    )
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.WslNoDistro,
+        reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
+        raises=HookExecutionError,
+    )
+    @with_rw_repo("HEAD", bare=True)
+    def test_commit_msg_hook_success(self, rw_repo):
+        commit_message = "commit default head by Frèderic Çaufl€"
+        from_hook_message = "from commit-msg"
+        index = rw_repo.index
+        _make_hook(
+            index.repo.git_dir,
+            "commit-msg",
+            'printf " {}" >> "$1"'.format(from_hook_message),
+        )
+        new_commit = index.commit(commit_message)
+        self.assertEqual(new_commit.message, "{} {}".format(commit_message, from_hook_message))
+
+    @pytest.mark.xfail(
+        type(_win_bash_status) is WinBashStatus.WslNoDistro,
+        reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
+        raises=AssertionError,
+    )
+    @with_rw_repo("HEAD", bare=True)
+    def test_commit_msg_hook_fail(self, rw_repo):
+        index = rw_repo.index
+        hp = _make_hook(index.repo.git_dir, "commit-msg", "echo stdout; echo stderr 1>&2; exit 1")
+        try:
+            index.commit("This should fail")
+        except HookExecutionError as err:
+            if type(_win_bash_status) is WinBashStatus.Absent:
+                self.assertIsInstance(err.status, OSError)
+                self.assertEqual(err.command, [hp])
+                self.assertEqual(err.stdout, "")
+                self.assertEqual(err.stderr, "")
+                assert str(err)
+            else:
+                self.assertEqual(err.status, 1)
+                self.assertEqual(err.command, [hp])
+                self.assertEqual(err.stdout, "\n  stdout: 'stdout\n'")
+                self.assertEqual(err.stderr, "\n  stderr: 'stderr\n'")
+                assert str(err)
+        else:
+            raise AssertionError("Should have caught a HookExecutionError")
+
+    @with_rw_repo("HEAD")
+    def test_index_add_pathlike(self, rw_repo):
+        git_dir = Path(rw_repo.git_dir)
+
+        file = git_dir / "file.txt"
+        file.touch()
+
+        rw_repo.index.add(file)
+
+    @with_rw_repo("HEAD")
+    def test_index_add_non_normalized_path(self, rw_repo):
+        git_dir = Path(rw_repo.git_dir)
+
+        file = git_dir / "file.txt"
+        file.touch()
+        non_normalized_path = file.as_posix()
+        if os.name != "nt":
+            non_normalized_path = "/" + non_normalized_path[1:].replace("/", "//")
+
+        rw_repo.index.add(non_normalized_path)
+
+
+class TestIndexUtils:
+    @pytest.mark.parametrize("file_path_type", [str, Path])
+    def test_temporary_file_swap(self, tmp_path, file_path_type):
+        file_path = tmp_path / "foo"
+        file_path.write_bytes(b"some data")
+
+        with TemporaryFileSwap(file_path_type(file_path)) as ctx:
+            assert Path(ctx.file_path) == file_path
+            assert not file_path.exists()
+
+            # Recreate it with new data, so we can observe that they're really separate.
+            file_path.write_bytes(b"other data")
+
+            temp_file_path = Path(ctx.tmp_file_path)
+            assert temp_file_path.parent == file_path.parent
+            assert temp_file_path.name.startswith(file_path.name)
+            assert temp_file_path.read_bytes() == b"some data"
+
+        assert not temp_file_path.exists()
+        assert file_path.read_bytes() == b"some data"  # Not b"other data".
diff --git a/test/test_installation.py b/test/test_installation.py
new file mode 100644
index 000000000..7c82bd403
--- /dev/null
+++ b/test/test_installation.py
@@ -0,0 +1,73 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import ast
+import functools
+import os
+import subprocess
+
+from test.lib import TestBase, VirtualEnvironment, with_rw_directory
+
+
+class TestInstallation(TestBase):
+    @with_rw_directory
+    def test_installation(self, rw_dir):
+        venv, run = self._set_up_venv(rw_dir)
+
+        result = run([venv.pip, "install", "."])
+        self._check_result(result, "Can't install project")
+
+        result = run([venv.python, "-c", "import git"])
+        self._check_result(result, "Self-test failed")
+
+        result = run([venv.python, "-c", "import gitdb; import smmap"])
+        self._check_result(result, "Dependencies not installed")
+
+        # Even IF gitdb or any other dependency is supplied during development by
+        # inserting its location into PYTHONPATH or otherwise patched into sys.path,
+        # make sure it is not wrongly inserted as the *first* entry.
+        result = run([venv.python, "-c", "import sys; import git; print(sys.path)"])
+        syspath = result.stdout.splitlines()[0]
+        syspath = ast.literal_eval(syspath)
+        self.assertEqual(
+            "",
+            syspath[0],
+            msg="Failed to follow the conventions for https://docs.python.org/3/library/sys.html#sys.path",
+        )
+
+    @staticmethod
+    def _set_up_venv(rw_dir):
+        # Initialize the virtual environment.
+        venv = VirtualEnvironment(rw_dir, with_pip=True)
+
+        # Make its src directory a symlink to our own top-level source tree.
+        os.symlink(
+            os.path.dirname(os.path.dirname(__file__)),
+            venv.sources,
+            target_is_directory=True,
+        )
+
+        # Create a convenience function to run commands in it.
+        run = functools.partial(
+            subprocess.run,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+            universal_newlines=True,
+            cwd=venv.sources,
+            env={**os.environ, "PYTHONWARNINGS": "error"},
+        )
+
+        return venv, run
+
+    def _check_result(self, result, failure_summary):
+        self.assertEqual(
+            0,
+            result.returncode,
+            msg=self._prepare_failure_message(result, failure_summary),
+        )
+
+    @staticmethod
+    def _prepare_failure_message(result, failure_summary):
+        stdout = result.stdout.rstrip()
+        stderr = result.stderr.rstrip()
+        return f"{failure_summary}\n\nstdout:\n{stdout}\n\nstderr:\n{stderr}"
diff --git a/test/test_quick_doc.py b/test/test_quick_doc.py
new file mode 100644
index 000000000..98658e02f
--- /dev/null
+++ b/test/test_quick_doc.py
@@ -0,0 +1,222 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import gc
+
+from test.lib import TestBase
+from test.lib.helper import with_rw_directory
+
+
+class QuickDoc(TestBase):
+    def tearDown(self):
+        gc.collect()
+
+    @with_rw_directory
+    def test_init_repo_object(self, path_to_dir):
+        # [1-test_init_repo_object]
+        # $ git init <path/to/dir>
+
+        from git import Repo
+
+        repo = Repo.init(path_to_dir)
+        # ![1-test_init_repo_object]
+
+        # [2-test_init_repo_object]
+        repo = Repo(path_to_dir)
+        # ![2-test_init_repo_object]
+
+        del repo  # Avoids "assigned to but never used" warning. Doesn't go in the docs.
+
+    @with_rw_directory
+    def test_cloned_repo_object(self, local_dir):
+        from git import Repo
+
+        # Code to clone from url
+        # [1-test_cloned_repo_object]
+        # $ git clone <url> <local_dir>
+
+        repo_url = "https://github.com/gitpython-developers/QuickStartTutorialFiles.git"
+
+        repo = Repo.clone_from(repo_url, local_dir)
+        # ![1-test_cloned_repo_object]
+
+        # Code to add files
+        # [2-test_cloned_repo_object]
+        # We must make a change to a file so that we can add the update to git
+
+        update_file = "dir1/file2.txt"  # we'll use local_dir/dir1/file2.txt
+        with open(f"{local_dir}/{update_file}", "a") as f:
+            f.write("\nUpdate version 2")
+        # ![2-test_cloned_repo_object]
+
+        # [3-test_cloned_repo_object]
+        # $ git add <file>
+        add_file = [update_file]  # relative path from git root
+        repo.index.add(add_file)  # notice the add function requires a list of paths
+        # ![3-test_cloned_repo_object]
+
+        # Code to commit - not sure how to test this
+        # [4-test_cloned_repo_object]
+        # $ git commit -m <message>
+        repo.index.commit("Update to file2")
+        # ![4-test_cloned_repo_object]
+
+        # [5-test_cloned_repo_object]
+        # $ git log <file>
+
+        # Relative path from git root
+        repo.iter_commits(all=True, max_count=10, paths=update_file)  # Gets the last 10 commits from all branches.
+
+        # Outputs: <generator object Commit._iter_from_process_or_stream at 0x7fb66c186cf0>
+
+        # ![5-test_cloned_repo_object]
+
+        # [6-test_cloned_repo_object]
+        commits_for_file_generator = repo.iter_commits(all=True, max_count=10, paths=update_file)
+        commits_for_file = list(commits_for_file_generator)
+        commits_for_file
+
+        # Outputs: [<git.Commit "SHA1-HEX_HASH-2">,
+        # <git.Commit "SHA1-HEX-HASH-1">]
+        # ![6-test_cloned_repo_object]
+
+        # Untracked files - create new file
+        # [7-test_cloned_repo_object]
+        f = open(f"{local_dir}/untracked.txt", "w")  # Creates an empty file.
+        f.close()
+        # ![7-test_cloned_repo_object]
+
+        # [8-test_cloned_repo_object]
+        repo.untracked_files
+        # Output: ['untracked.txt']
+        # ![8-test_cloned_repo_object]
+
+        # Modified files
+        # [9-test_cloned_repo_object]
+        # Let's modify one of our tracked files.
+
+        with open(f"{local_dir}/Downloads/file3.txt", "w") as f:
+            f.write("file3 version 2")  # Overwrite file 3.
+        # ![9-test_cloned_repo_object]
+
+        # [10-test_cloned_repo_object]
+        repo.index.diff(None)  # Compares staging area to working directory.
+
+        # Output: [<git.diff.Diff object at 0x7fb66c076e50>,
+        # <git.diff.Diff object at 0x7fb66c076ca0>]
+        # ![10-test_cloned_repo_object]
+
+        # [11-test_cloned_repo_object]
+        diffs = repo.index.diff(None)
+        for d in diffs:
+            print(d.a_path)
+
+        # Output
+        # Downloads/file3.txt
+        # ![11-test_cloned_repo_object]
+
+        # Compares staging area to head commit
+        # [11.1-test_cloned_repo_object]
+        diffs = repo.index.diff(repo.head.commit)
+        for d in diffs:
+            print(d.a_path)
+
+        # Output
+
+        # ![11.1-test_cloned_repo_object]
+        # [11.2-test_cloned_repo_object]
+        # Let's add untracked.txt.
+        repo.index.add(["untracked.txt"])
+        diffs = repo.index.diff(repo.head.commit)
+        for d in diffs:
+            print(d.a_path)
+
+        # Output
+        # untracked.txt
+        # ![11.2-test_cloned_repo_object]
+
+        # Compare commit to commit
+        # [11.3-test_cloned_repo_object]
+        first_commit = list(repo.iter_commits(all=True))[-1]
+        diffs = repo.head.commit.diff(first_commit)
+        for d in diffs:
+            print(d.a_path)
+
+        # Output
+        # dir1/file2.txt
+        # ![11.3-test_cloned_repo_object]
+
+        """Trees and Blobs"""
+
+        # Latest commit tree
+        # [12-test_cloned_repo_object]
+        tree = repo.head.commit.tree
+        # ![12-test_cloned_repo_object]
+
+        # Previous commit tree
+        # [13-test_cloned_repo_object]
+        prev_commits = list(repo.iter_commits(all=True, max_count=10))  # Last 10 commits from all branches.
+        tree = prev_commits[0].tree
+        # ![13-test_cloned_repo_object]
+
+        # Iterating through tree
+        # [14-test_cloned_repo_object]
+        files_and_dirs = [(entry, entry.name, entry.type) for entry in tree]
+        files_and_dirs
+
+        # Output
+        # [(< git.Tree "SHA1-HEX_HASH" >, 'Downloads', 'tree'),
+        #  (< git.Tree "SHA1-HEX_HASH" >, 'dir1', 'tree'),
+        #  (< git.Blob "SHA1-HEX_HASH" >, 'file4.txt', 'blob')]
+        # ![14-test_cloned_repo_object]
+
+        # [15-test_cloned_repo_object]
+        def print_files_from_git(root, level=0):
+            for entry in root:
+                print(f"{'-' * 4 * level}| {entry.path}, {entry.type}")
+                if entry.type == "tree":
+                    print_files_from_git(entry, level + 1)
+
+        # ![15-test_cloned_repo_object]
+
+        # [16-test_cloned_repo_object]
+        print_files_from_git(tree)
+
+        # Output
+        # | Downloads, tree
+        # ----| Downloads / file3.txt, blob
+        # | dir1, tree
+        # ----| dir1 / file1.txt, blob
+        # ----| dir1 / file2.txt, blob
+        # | file4.txt, blob
+        # # ![16-test_cloned_repo_object]
+
+        # Printing text files
+        # [17-test_cloned_repo_object]
+        print_file = "dir1/file2.txt"
+        tree[print_file]  # The head commit tree.
+
+        # Output <git.Blob "SHA1-HEX-HASH">
+        # ![17-test_cloned_repo_object]
+
+        # Print latest file
+        # [18-test_cloned_repo_object]
+        blob = tree[print_file]
+        print(blob.data_stream.read().decode())
+
+        # Output
+        # File 2 version 1
+        # Update version 2
+        # ![18-test_cloned_repo_object]
+
+        # Print previous tree
+        # [18.1-test_cloned_repo_object]
+        commits_for_file = list(repo.iter_commits(all=True, paths=print_file))
+        tree = commits_for_file[-1].tree  # Gets the first commit tree.
+        blob = tree[print_file]
+
+        print(blob.data_stream.read().decode())
+
+        # Output
+        # File 2 version 1
+        # ![18.1-test_cloned_repo_object]
diff --git a/test/test_reflog.py b/test/test_reflog.py
new file mode 100644
index 000000000..7ce64219a
--- /dev/null
+++ b/test/test_reflog.py
@@ -0,0 +1,101 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import os.path as osp
+import tempfile
+
+from git.objects import IndexObject
+from git.refs import RefLog, RefLogEntry
+from git.util import Actor, hex_to_bin, rmtree
+
+from test.lib import TestBase, fixture_path
+
+
+class TestRefLog(TestBase):
+    def test_reflogentry(self):
+        nullhexsha = IndexObject.NULL_HEX_SHA
+        hexsha = "F" * 40
+        actor = Actor("name", "email")
+        msg = "message"
+
+        self.assertRaises(ValueError, RefLogEntry.new, nullhexsha, hexsha, "noactor", 0, 0, "")
+        e = RefLogEntry.new(nullhexsha, hexsha, actor, 0, 1, msg)
+
+        assert e.oldhexsha == nullhexsha
+        assert e.newhexsha == hexsha
+        assert e.actor == actor
+        assert e.time[0] == 0
+        assert e.time[1] == 1
+        assert e.message == msg
+
+        # Check representation (roughly).
+        assert repr(e).startswith(nullhexsha)
+
+    def test_base(self):
+        rlp_head = fixture_path("reflog_HEAD")
+        rlp_master = fixture_path("reflog_master")
+        tdir = tempfile.mkdtemp(suffix="test_reflogs")
+
+        rlp_master_ro = RefLog.path(self.rorepo.head)
+        assert osp.isfile(rlp_master_ro)
+
+        # Simple read.
+        reflog = RefLog.from_file(rlp_master_ro)
+        assert reflog._path is not None
+        assert isinstance(reflog, RefLog)
+        assert len(reflog)
+
+        # iter_entries works with path and with stream.
+        assert len(list(RefLog.iter_entries(open(rlp_master, "rb"))))
+        assert len(list(RefLog.iter_entries(rlp_master)))
+
+        # Raise on invalid revlog.
+        # TODO: Try multiple corrupted ones!
+        pp = "reflog_invalid_"
+        for suffix in ("oldsha", "newsha", "email", "date", "sep"):
+            self.assertRaises(ValueError, RefLog.from_file, fixture_path(pp + suffix))
+        # END for each invalid file
+
+        # Cannot write an uninitialized reflog.
+        self.assertRaises(ValueError, RefLog().write)
+
+        # Test serialize and deserialize - results must match exactly.
+        binsha = hex_to_bin(("f" * 40).encode("ascii"))
+        msg = "my reflog message"
+        cr = self.rorepo.config_reader()
+        for rlp in (rlp_head, rlp_master):
+            reflog = RefLog.from_file(rlp)
+            tfile = osp.join(tdir, osp.basename(rlp))
+            reflog.to_file(tfile)
+            assert reflog.write() is reflog
+
+            # Parsed result must match...
+            treflog = RefLog.from_file(tfile)
+            assert treflog == reflog
+
+            # ...as well as each bytes of the written stream.
+            assert open(tfile).read() == open(rlp).read()
+
+            # Append an entry.
+            entry = RefLog.append_entry(cr, tfile, IndexObject.NULL_BIN_SHA, binsha, msg)
+            assert entry.oldhexsha == IndexObject.NULL_HEX_SHA
+            assert entry.newhexsha == "f" * 40
+            assert entry.message == msg
+            assert RefLog.from_file(tfile)[-1] == entry
+
+            # Index entry.
+            # Raises on invalid index.
+            self.assertRaises(IndexError, RefLog.entry_at, rlp, 10000)
+
+            # Indices can be positive...
+            assert isinstance(RefLog.entry_at(rlp, 0), RefLogEntry)
+            RefLog.entry_at(rlp, 23)
+
+            # ...and negative.
+            for idx in (-1, -24):
+                RefLog.entry_at(rlp, idx)
+            # END for each index to read
+        # END for each reflog
+
+        # Finally remove our temporary data.
+        rmtree(tdir)
diff --git a/git/test/test_refs.py b/test/test_refs.py
similarity index 50%
rename from git/test/test_refs.py
rename to test/test_refs.py
index 14b91cfeb..08096e69e 100644
--- a/git/test/test_refs.py
+++ b/test/test_refs.py
@@ -1,49 +1,51 @@
-# test_refs.py
 # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
 #
-# This module is part of GitPython and is released under
-# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+from itertools import chain
+import os.path as osp
+from pathlib import Path
+import tempfile
+
+from gitdb.exc import BadName
 
-from git.test.lib import (
-    TestBase,
-    with_rw_repo
-)
 from git import (
-    Reference,
+    Commit,
+    GitCommandError,
+    GitConfigParser,
     Head,
-    TagReference,
+    RefLog,
+    Reference,
     RemoteReference,
-    Commit,
     SymbolicReference,
-    GitCommandError,
-    RefLog
+    TagReference,
 )
+from git.objects.tag import TagObject
 import git.refs as refs
 from git.util import Actor
-from git.objects.tag import TagObject
-from itertools import chain
-import os
 
+from test.lib import TestBase, with_rw_repo
 
-class TestRefs(TestBase):
 
+class TestRefs(TestBase):
     def test_from_path(self):
-        # should be able to create any reference directly
+        # Should be able to create any reference directly.
         for ref_type in (Reference, Head, TagReference, RemoteReference):
-            for name in ('rela_name', 'path/rela_name'):
+            for name in ("rela_name", "path/rela_name"):
                 full_path = ref_type.to_full_path(name)
                 instance = ref_type.from_path(self.rorepo, full_path)
                 assert isinstance(instance, ref_type)
             # END for each name
         # END for each type
 
-        # invalid path
-        self.failUnlessRaises(ValueError, TagReference, self.rorepo, "refs/invalid/tag")
-        # works without path check
+        # Invalid path.
+        self.assertRaises(ValueError, TagReference, self.rorepo, "refs/invalid/tag")
+        # Works without path check.
         TagReference(self.rorepo, "refs/invalid/tag", check_path=False)
 
     def test_tag_base(self):
-        tag_object_refs = list()
+        tag_object_refs = []
         for tag in self.rorepo.tags:
             assert "refs/tags" in tag.path
             assert tag.name
@@ -51,8 +53,8 @@ def test_tag_base(self):
             if tag.tag is not None:
                 tag_object_refs.append(tag)
                 tagobj = tag.tag
-                # have no dict
-                self.failUnlessRaises(AttributeError, setattr, tagobj, 'someattr', 1)
+                # Have no dict.
+                self.assertRaises(AttributeError, setattr, tagobj, "someattr", 1)
                 assert isinstance(tagobj, TagObject)
                 assert tagobj.tag == tag.name
                 assert isinstance(tagobj.tagger, Actor)
@@ -60,22 +62,22 @@ def test_tag_base(self):
                 assert isinstance(tagobj.tagger_tz_offset, int)
                 assert tagobj.message
                 assert tag.object == tagobj
-                # can't assign the object
-                self.failUnlessRaises(AttributeError, setattr, tag, 'object', tagobj)
+                # Can't assign the object.
+                self.assertRaises(AttributeError, setattr, tag, "object", tagobj)
             # END if we have a tag object
         # END for tag in repo-tags
         assert tag_object_refs
-        assert isinstance(self.rorepo.tags['0.1.5'], TagReference)
+        assert isinstance(self.rorepo.tags["0.1.5"], TagReference)
 
     def test_tags_author(self):
         tag = self.rorepo.tags[0]
         tagobj = tag.tag
         assert isinstance(tagobj.tagger, Actor)
         tagger_name = tagobj.tagger.name
-        assert tagger_name == 'Michael Trier'
+        assert tagger_name == "Michael Trier"
 
     def test_tags(self):
-        # tag refs can point to tag objects or to commits
+        # Tag refs can point to tag objects or to commits.
         s = set()
         ref_count = 0
         for ref in chain(self.rorepo.tags, self.rorepo.heads):
@@ -90,7 +92,7 @@ def test_tags(self):
         assert len(s) == ref_count
         assert len(s | s) == ref_count
 
-    @with_rw_repo('HEAD', bare=False)
+    @with_rw_repo("HEAD", bare=False)
     def test_heads(self, rwrepo):
         for head in rwrepo.heads:
             assert head.name
@@ -98,20 +100,18 @@ def test_heads(self, rwrepo):
             assert "refs/heads" in head.path
             prev_object = head.object
             cur_object = head.object
-            assert prev_object == cur_object        # represent the same git object
-            assert prev_object is not cur_object    # but are different instances
-
-            writer = head.config_writer()
-            tv = "testopt"
-            writer.set_value(tv, 1)
-            assert writer.get_value(tv) == 1
-            writer.release()
+            assert prev_object == cur_object  # Represent the same git object...
+            assert prev_object is not cur_object  # ...but are different instances.
+
+            with head.config_writer() as writer:
+                tv = "testopt"
+                writer.set_value(tv, 1)
+                assert writer.get_value(tv) == 1
             assert head.config_reader().get_value(tv) == 1
-            writer = head.config_writer()
-            writer.remove_option(tv)
-            writer.release()
+            with head.config_writer() as writer:
+                writer.remove_option(tv)
 
-            # after the clone, we might still have a tracking branch setup
+            # After the clone, we might still have a tracking branch setup.
             head.set_tracking_branch(None)
             assert head.tracking_branch() is None
             remote_ref = rwrepo.remotes[0].refs[0]
@@ -119,48 +119,82 @@ def test_heads(self, rwrepo):
             assert head.tracking_branch() == remote_ref
             head.set_tracking_branch(None)
             assert head.tracking_branch() is None
+
+            special_name = "feature#123"
+            special_name_remote_ref = SymbolicReference.create(rwrepo, "refs/remotes/origin/%s" % special_name)
+            gp_tracking_branch = rwrepo.create_head("gp_tracking#123")
+            special_name_remote_ref = rwrepo.remotes[0].refs[special_name]  # Get correct type.
+            gp_tracking_branch.set_tracking_branch(special_name_remote_ref)
+            TBranch = gp_tracking_branch.tracking_branch()
+            if TBranch is not None:
+                assert TBranch.path == special_name_remote_ref.path
+
+            git_tracking_branch = rwrepo.create_head("git_tracking#123")
+            rwrepo.git.branch("-u", special_name_remote_ref.name, git_tracking_branch.name)
+            TBranch = gp_tracking_branch.tracking_branch()
+            if TBranch is not None:
+                assert TBranch.name == special_name_remote_ref.name
         # END for each head
 
-        # verify REFLOG gets altered
+        # Verify REFLOG gets altered.
         head = rwrepo.head
         cur_head = head.ref
         cur_commit = cur_head.commit
         pcommit = cur_head.commit.parents[0].parents[0]
         hlog_len = len(head.log())
         blog_len = len(cur_head.log())
-        assert head.set_reference(pcommit, 'detached head') is head
-        # one new log-entry
+        assert head.set_reference(pcommit, "detached head") is head
+        # One new log-entry.
         thlog = head.log()
         assert len(thlog) == hlog_len + 1
         assert thlog[-1].oldhexsha == cur_commit.hexsha
         assert thlog[-1].newhexsha == pcommit.hexsha
 
-        # the ref didn't change though
+        # The ref didn't change though.
         assert len(cur_head.log()) == blog_len
 
-        # head changes once again, cur_head doesn't change
-        head.set_reference(cur_head, 'reattach head')
+        # head changes once again, cur_head doesn't change.
+        head.set_reference(cur_head, "reattach head")
         assert len(head.log()) == hlog_len + 2
         assert len(cur_head.log()) == blog_len
 
-        # adjusting the head-ref also adjust the head, so both reflogs are
-        # altered
-        cur_head.set_commit(pcommit, 'changing commit')
+        # Adjusting the head-ref also adjust the head, so both reflogs are altered.
+        cur_head.set_commit(pcommit, "changing commit")
         assert len(cur_head.log()) == blog_len + 1
         assert len(head.log()) == hlog_len + 3
 
-        # with automatic dereferencing
-        assert head.set_commit(cur_commit, 'change commit once again') is head
+        # With automatic dereferencing.
+        assert head.set_commit(cur_commit, "change commit once again") is head
         assert len(head.log()) == hlog_len + 4
         assert len(cur_head.log()) == blog_len + 2
 
-        # a new branch has just a single entry
-        other_head = Head.create(rwrepo, 'mynewhead', pcommit, logmsg='new head created')
+        # A new branch has just a single entry.
+        other_head = Head.create(rwrepo, "mynewhead", pcommit, logmsg="new head created")
         log = other_head.log()
         assert len(log) == 1
         assert log[0].oldhexsha == pcommit.NULL_HEX_SHA
         assert log[0].newhexsha == pcommit.hexsha
 
+    @with_rw_repo("HEAD", bare=False)
+    def test_set_tracking_branch_with_import(self, rwrepo):
+        # Prepare included config file.
+        included_config = osp.join(rwrepo.git_dir, "config.include")
+        with GitConfigParser(included_config, read_only=False) as writer:
+            writer.set_value("test", "value", "test")
+        assert osp.exists(included_config)
+
+        with rwrepo.config_writer() as writer:
+            writer.set_value("include", "path", included_config)
+
+        for head in rwrepo.heads:
+            head.set_tracking_branch(None)
+            assert head.tracking_branch() is None
+            remote_ref = rwrepo.remotes[0].refs[0]
+            assert head.set_tracking_branch(remote_ref) is head
+            assert head.tracking_branch() == remote_ref
+            head.set_tracking_branch(None)
+            assert head.tracking_branch() is None
+
     def test_refs(self):
         types_found = set()
         for ref in self.rorepo.refs:
@@ -168,15 +202,21 @@ def test_refs(self):
         assert len(types_found) >= 3
 
     def test_is_valid(self):
-        assert not Reference(self.rorepo, 'refs/doesnt/exist').is_valid()
+        assert not Reference(self.rorepo, "refs/doesnt/exist").is_valid()
         assert self.rorepo.head.is_valid()
         assert self.rorepo.head.reference.is_valid()
-        assert not SymbolicReference(self.rorepo, 'hellothere').is_valid()
+        assert not SymbolicReference(self.rorepo, "hellothere").is_valid()
 
     def test_orig_head(self):
-        assert type(self.rorepo.head.orig_head()) == SymbolicReference
+        assert type(self.rorepo.head.orig_head()) is SymbolicReference
 
-    @with_rw_repo('0.1.6')
+    @with_rw_repo("0.1.6")
+    def test_head_checkout_detached_head(self, rw_repo):
+        res = rw_repo.remotes.origin.refs.master.checkout()
+        assert isinstance(res, SymbolicReference)
+        assert res.name == "HEAD"
+
+    @with_rw_repo("0.1.6")
     def test_head_reset(self, rw_repo):
         cur_head = rw_repo.head
         old_head_commit = cur_head.commit
@@ -184,24 +224,30 @@ def test_head_reset(self, rw_repo):
         cur_head.reset(new_head_commit, index=True)  # index only
         assert cur_head.reference.commit == new_head_commit
 
-        self.failUnlessRaises(ValueError, cur_head.reset, new_head_commit, index=False, working_tree=True)
+        self.assertRaises(ValueError, cur_head.reset, new_head_commit, index=False, working_tree=True)
         new_head_commit = new_head_commit.parents[0]
         cur_head.reset(new_head_commit, index=True, working_tree=True)  # index + wt
         assert cur_head.reference.commit == new_head_commit
 
-        # paths - make sure we have something to do
+        # Paths - make sure we have something to do.
         rw_repo.index.reset(old_head_commit.parents[0])
         cur_head.reset(cur_head, paths="test")
         cur_head.reset(new_head_commit, paths="lib")
-        # hard resets with paths don't work, its all or nothing
-        self.failUnlessRaises(GitCommandError, cur_head.reset, new_head_commit, working_tree=True, paths="lib")
-
-        # we can do a mixed reset, and then checkout from the index though
+        # Hard resets with paths don't work; it's all or nothing.
+        self.assertRaises(
+            GitCommandError,
+            cur_head.reset,
+            new_head_commit,
+            working_tree=True,
+            paths="lib",
+        )
+
+        # We can do a mixed reset, and then checkout from the index though.
         cur_head.reset(new_head_commit)
         rw_repo.index.checkout(["lib"], force=True)
 
-        # now that we have a write write repo, change the HEAD reference - its
-        # like git-reset --soft
+        # Now that we have a write write repo, change the HEAD reference - it's like
+        # "git-reset --soft".
         heads = rw_repo.heads
         assert heads
         for head in heads:
@@ -212,29 +258,29 @@ def test_head_reset(self, rw_repo):
             assert not cur_head.is_detached
         # END for each head
 
-        # detach
+        # Detach.
         active_head = heads[0]
         curhead_commit = active_head.commit
         cur_head.reference = curhead_commit
         assert cur_head.commit == curhead_commit
         assert cur_head.is_detached
-        self.failUnlessRaises(TypeError, getattr, cur_head, "reference")
+        self.assertRaises(TypeError, getattr, cur_head, "reference")
 
-        # tags are references, hence we can point to them
+        # Tags are references, hence we can point to them.
         some_tag = rw_repo.tags[0]
         cur_head.reference = some_tag
         assert not cur_head.is_detached
         assert cur_head.commit == some_tag.commit
         assert isinstance(cur_head.reference, TagReference)
 
-        # put HEAD back to a real head, otherwise everything else fails
+        # Put HEAD back to a real head, otherwise everything else fails.
         cur_head.reference = active_head
 
-        # type check
-        self.failUnlessRaises(ValueError, setattr, cur_head, "reference", "that")
+        # Type check.
+        self.assertRaises(ValueError, setattr, cur_head, "reference", "that")
 
-        # head handling
-        commit = 'HEAD'
+        # Head handling.
+        commit = "HEAD"
         prev_head_commit = cur_head.commit
         for count, new_name in enumerate(("my_new_head", "feature/feature1")):
             actual_commit = commit + "^" * count
@@ -242,13 +288,13 @@ def test_head_reset(self, rw_repo):
             assert new_head.is_detached
             assert cur_head.commit == prev_head_commit
             assert isinstance(new_head, Head)
-            # already exists, but has the same value, so its fine
+            # Already exists, but has the same value, so it's fine.
             Head.create(rw_repo, new_name, new_head.commit)
 
-            # its not fine with a different value
-            self.failUnlessRaises(OSError, Head.create, rw_repo, new_name, new_head.commit.parents[0])
+            # It's not fine with a different value.
+            self.assertRaises(OSError, Head.create, rw_repo, new_name, new_head.commit.parents[0])
 
-            # force it
+            # Force it.
             new_head = Head.create(rw_repo, new_name, actual_commit, force=True)
             old_path = new_head.path
             old_name = new_head.name
@@ -257,34 +303,34 @@ def test_head_reset(self, rw_repo):
             assert new_head.rename("hello/world").name == "hello/world"
             assert new_head.rename(old_name).name == old_name and new_head.path == old_path
 
-            # rename with force
+            # Rename with force.
             tmp_head = Head.create(rw_repo, "tmphead")
-            self.failUnlessRaises(GitCommandError, tmp_head.rename, new_head)
+            self.assertRaises(GitCommandError, tmp_head.rename, new_head)
             tmp_head.rename(new_head, force=True)
             assert tmp_head == new_head and tmp_head.object == new_head.object
 
             logfile = RefLog.path(tmp_head)
-            assert os.path.isfile(logfile)
+            assert osp.isfile(logfile)
             Head.delete(rw_repo, tmp_head)
-            # deletion removes the log as well
-            assert not os.path.isfile(logfile)
+            # Deletion removes the log as well.
+            assert not osp.isfile(logfile)
             heads = rw_repo.heads
             assert tmp_head not in heads and new_head not in heads
-            # force on deletion testing would be missing here, code looks okay though ;)
+            # Force on deletion testing would be missing here, code looks okay though. ;)
         # END for each new head name
-        self.failUnlessRaises(TypeError, RemoteReference.create, rw_repo, "some_name")
+        self.assertRaises(TypeError, RemoteReference.create, rw_repo, "some_name")
 
-        # tag ref
-        tag_name = "1.0.2"
-        light_tag = TagReference.create(rw_repo, tag_name)
-        self.failUnlessRaises(GitCommandError, TagReference.create, rw_repo, tag_name)
+        # Tag ref.
+        tag_name = "5.0.2"
+        TagReference.create(rw_repo, tag_name)
+        self.assertRaises(GitCommandError, TagReference.create, rw_repo, tag_name)
         light_tag = TagReference.create(rw_repo, tag_name, "HEAD~1", force=True)
         assert isinstance(light_tag, TagReference)
         assert light_tag.name == tag_name
         assert light_tag.commit == cur_head.commit.parents[0]
         assert light_tag.tag is None
 
-        # tag with tag object
+        # Tag with tag object.
         other_tag_name = "releases/1.0.2RC"
         msg = "my mighty tag\nsecond line"
         obj_tag = TagReference.create(rw_repo, other_tag_name, message=msg)
@@ -297,19 +343,19 @@ def test_head_reset(self, rw_repo):
         tags = rw_repo.tags
         assert light_tag not in tags and obj_tag not in tags
 
-        # remote deletion
+        # Remote deletion.
         remote_refs_so_far = 0
         remotes = rw_repo.remotes
         assert remotes
         for remote in remotes:
             refs = remote.refs
 
-            # If a HEAD exists, it must be deleted first. Otherwise it might
-            # end up pointing to an invalid ref it the ref was deleted before.
+            # If a HEAD exists, it must be deleted first. Otherwise it might end up
+            # pointing to an invalid ref it the ref was deleted before.
             remote_head_name = "HEAD"
             if remote_head_name in refs:
                 RemoteReference.delete(rw_repo, refs[remote_head_name])
-                del(refs[remote_head_name])
+                del refs[remote_head_name]
             # END handle HEAD deletion
 
             RemoteReference.delete(rw_repo, *refs)
@@ -320,11 +366,11 @@ def test_head_reset(self, rw_repo):
         assert remote_refs_so_far
 
         for remote in remotes:
-            # remotes without references throw
-            self.failUnlessRaises(AssertionError, getattr, remote, 'refs')
+            # Remotes without references should produce an empty list.
+            self.assertEqual(remote.refs, [])
         # END for each remote
 
-        # change where the active head points to
+        # Change where the active head points to.
         if cur_head.is_detached:
             cur_head.reference = rw_repo.heads[0]
 
@@ -335,17 +381,17 @@ def test_head_reset(self, rw_repo):
         assert head.commit == cur_head.commit
         head.commit = old_commit
 
-        # setting a non-commit as commit fails, but succeeds as object
+        # Setting a non-commit as commit fails, but succeeds as object.
         head_tree = head.commit.tree
-        self.failUnlessRaises(ValueError, setattr, head, 'commit', head_tree)
-        assert head.commit == old_commit        # and the ref did not change
-        # we allow heds to point to any object
+        self.assertRaises(ValueError, setattr, head, "commit", head_tree)
+        assert head.commit == old_commit  # And the ref did not change.
+        # We allow heads to point to any object.
         head.object = head_tree
         assert head.object == head_tree
-        # cannot query tree as commit
-        self.failUnlessRaises(TypeError, getattr, head, 'commit')
+        # Cannot query tree as commit.
+        self.assertRaises(TypeError, getattr, head, "commit")
 
-        # set the commit directly using the head. This would never detach the head
+        # Set the commit directly using the head. This would never detach the head.
         assert not cur_head.is_detached
         head.object = old_commit
         cur_head.reference = head.commit
@@ -361,54 +407,54 @@ def test_head_reset(self, rw_repo):
         assert not cur_head.is_detached
         assert head.commit == parent_commit
 
-        # test checkout
+        # Test checkout.
         active_branch = rw_repo.active_branch
         for head in rw_repo.heads:
             checked_out_head = head.checkout()
             assert checked_out_head == head
         # END for each head to checkout
 
-        # checkout with branch creation
+        # Check out with branch creation.
         new_head = active_branch.checkout(b="new_head")
         assert active_branch != rw_repo.active_branch
         assert new_head == rw_repo.active_branch
 
-        # checkout  with force as we have a changed a file
-        # clear file
-        open(new_head.commit.tree.blobs[-1].abspath, 'w').close()
+        # Checkout with force as we have a changed a file.
+        # Clear file.
+        open(new_head.commit.tree.blobs[-1].abspath, "w").close()
         assert len(new_head.commit.diff(None))
 
-        # create a new branch that is likely to touch the file we changed
-        far_away_head = rw_repo.create_head("far_head", 'HEAD~100')
-        self.failUnlessRaises(GitCommandError, far_away_head.checkout)
+        # Create a new branch that is likely to touch the file we changed.
+        far_away_head = rw_repo.create_head("far_head", "HEAD~100")
+        self.assertRaises(GitCommandError, far_away_head.checkout)
         assert active_branch == active_branch.checkout(force=True)
         assert rw_repo.head.reference != far_away_head
 
-        # test reference creation
-        partial_ref = 'sub/ref'
-        full_ref = 'refs/%s' % partial_ref
+        # Test reference creation.
+        partial_ref = "sub/ref"
+        full_ref = "refs/%s" % partial_ref
         ref = Reference.create(rw_repo, partial_ref)
         assert ref.path == full_ref
         assert ref.object == rw_repo.head.commit
 
-        self.failUnlessRaises(OSError, Reference.create, rw_repo, full_ref, 'HEAD~20')
-        # it works if it is at the same spot though and points to the same reference
-        assert Reference.create(rw_repo, full_ref, 'HEAD').path == full_ref
+        self.assertRaises(OSError, Reference.create, rw_repo, full_ref, "HEAD~20")
+        # It works if it is at the same spot though and points to the same reference.
+        assert Reference.create(rw_repo, full_ref, "HEAD").path == full_ref
         Reference.delete(rw_repo, full_ref)
 
-        # recreate the reference using a full_ref
+        # Recreate the reference using a full_ref.
         ref = Reference.create(rw_repo, full_ref)
         assert ref.path == full_ref
         assert ref.object == rw_repo.head.commit
 
-        # recreate using force
-        ref = Reference.create(rw_repo, partial_ref, 'HEAD~1', force=True)
+        # Recreate using force.
+        ref = Reference.create(rw_repo, partial_ref, "HEAD~1", force=True)
         assert ref.path == full_ref
         assert ref.object == rw_repo.head.commit.parents[0]
 
-        # rename it
+        # Rename it.
         orig_obj = ref.object
-        for name in ('refs/absname', 'rela_name', 'feature/rela_name'):
+        for name in ("refs/absname", "rela_name", "feature/rela_name"):
             ref_new_name = ref.rename(name)
             assert isinstance(ref_new_name, Reference)
             assert name in ref_new_name.path
@@ -416,45 +462,51 @@ def test_head_reset(self, rw_repo):
             assert ref_new_name == ref
         # END for each name type
 
-        # References that don't exist trigger an error if we want to access them
-        self.failUnlessRaises(ValueError, getattr, Reference(rw_repo, "refs/doesntexist"), 'commit')
+        # References that don't exist trigger an error if we want to access them.
+        self.assertRaises(ValueError, getattr, Reference(rw_repo, "refs/doesntexist"), "commit")
 
-        # exists, fail unless we force
+        # Exists, fail unless we force.
         ex_ref_path = far_away_head.path
-        self.failUnlessRaises(OSError, ref.rename, ex_ref_path)
-        # if it points to the same commit it works
+        self.assertRaises(OSError, ref.rename, ex_ref_path)
+        # If it points to the same commit it works.
         far_away_head.commit = ref.commit
         ref.rename(ex_ref_path)
         assert ref.path == ex_ref_path and ref.object == orig_obj
         assert ref.rename(ref.path).path == ex_ref_path  # rename to same name
 
-        # create symbolic refs
+        # Create symbolic refs.
         symref_path = "symrefs/sym"
         symref = SymbolicReference.create(rw_repo, symref_path, cur_head.reference)
         assert symref.path == symref_path
         assert symref.reference == cur_head.reference
 
-        self.failUnlessRaises(OSError, SymbolicReference.create, rw_repo, symref_path, cur_head.reference.commit)
-        # it works if the new ref points to the same reference
-        SymbolicReference.create(rw_repo, symref.path, symref.reference).path == symref.path
+        self.assertRaises(
+            OSError,
+            SymbolicReference.create,
+            rw_repo,
+            symref_path,
+            cur_head.reference.commit,
+        )
+        # It works if the new ref points to the same reference.
+        assert SymbolicReference.create(rw_repo, symref.path, symref.reference).path == symref.path
         SymbolicReference.delete(rw_repo, symref)
-        # would raise if the symref wouldn't have been deletedpbl
+        # Would raise if the symref wouldn't have been deleted (probably).
         symref = SymbolicReference.create(rw_repo, symref_path, cur_head.reference)
 
-        # test symbolic references which are not at default locations like HEAD
-        # or FETCH_HEAD - they may also be at spots in refs of course
+        # Test symbolic references which are not at default locations like HEAD or
+        # FETCH_HEAD - they may also be at spots in refs of course.
         symbol_ref_path = "refs/symbol_ref"
         symref = SymbolicReference(rw_repo, symbol_ref_path)
         assert symref.path == symbol_ref_path
-        symbol_ref_abspath = os.path.join(rw_repo.git_dir, symref.path)
+        symbol_ref_abspath = osp.join(rw_repo.git_dir, symref.path)
 
-        # set it
+        # Set it.
         symref.reference = new_head
         assert symref.reference == new_head
-        assert os.path.isfile(symbol_ref_abspath)
+        assert osp.isfile(symbol_ref_abspath)
         assert symref.commit == new_head.commit
 
-        for name in ('absname', 'folder/rela_name'):
+        for name in ("absname", "folder/rela_name"):
             symref_new_name = symref.rename(name)
             assert isinstance(symref_new_name, SymbolicReference)
             assert name in symref_new_name.path
@@ -463,10 +515,10 @@ def test_head_reset(self, rw_repo):
             assert not symref.is_detached
         # END for each ref
 
-        # create a new non-head ref just to be sure we handle it even if packed
+        # Create a new non-head ref just to be sure we handle it even if packed.
         Reference.create(rw_repo, full_ref)
 
-        # test ref listing - assure we have packed refs
+        # Test ref listing - make sure we have packed refs.
         rw_repo.git.pack_refs(all=True, prune=True)
         heads = rw_repo.heads
         assert heads
@@ -474,15 +526,14 @@ def test_head_reset(self, rw_repo):
         assert active_branch in heads
         assert rw_repo.tags
 
-        # we should be able to iterate all symbolic refs as well - in that case
-        # we should expect only symbolic references to be returned
+        # We should be able to iterate all symbolic refs as well - in that case we
+        # should expect only symbolic references to be returned.
         for symref in SymbolicReference.iter_items(rw_repo):
             assert not symref.is_detached
 
-        # when iterating references, we can get references and symrefs
-        # when deleting all refs, I'd expect them to be gone ! Even from
-        # the packed ones
-        # For this to work, we must not be on any branch
+        # When iterating references, we can get references and symrefs when deleting all
+        # refs, I'd expect them to be gone! Even from the packed ones.
+        # For this to work, we must not be on any branch.
         rw_repo.head.reference = rw_repo.head.commit
         deleted_refs = set()
         for ref in Reference.iter_items(rw_repo):
@@ -498,16 +549,15 @@ def test_head_reset(self, rw_repo):
                 assert ref not in deleted_refs
         # END for each ref
 
-        # reattach head - head will not be returned if it is not a symbolic
-        # ref
+        # Reattach head - head will not be returned if it is not a symbolic ref.
         rw_repo.head.reference = Head.create(rw_repo, "master")
 
-        # At least the head should still exist
-        assert os.path.isfile(os.path.join(rw_repo.git_dir, 'HEAD'))
+        # At least the head should still exist.
+        assert osp.isfile(osp.join(rw_repo.git_dir, "HEAD"))
         refs = list(SymbolicReference.iter_items(rw_repo))
         assert len(refs) == 1
 
-        # test creation of new refs from scratch
+        # Test creation of new refs from scratch.
         for path in ("basename", "dir/somename", "dir2/subdir/basename"):
             # REFERENCES
             ############
@@ -517,19 +567,19 @@ def test_head_reset(self, rw_repo):
             ref = Reference(rw_repo, fpath)
             assert ref == ref_fp
 
-            # can be created by assigning a commit
+            # Can be created by assigning a commit.
             ref.commit = rw_repo.head.commit
             assert ref.is_valid()
 
-            # if the assignment raises, the ref doesn't exist
+            # If the assignment raises, the ref doesn't exist.
             Reference.delete(ref.repo, ref.path)
             assert not ref.is_valid()
-            self.failUnlessRaises(ValueError, setattr, ref, 'commit', "nonsense")
+            self.assertRaises(ValueError, setattr, ref, "commit", "nonsense")
             assert not ref.is_valid()
 
-            # I am sure I had my reason to make it a class method at first, but
-            # now it doesn't make so much sense anymore, want an instance method as well
-            # See http://byronimo.lighthouseapp.com/projects/51787-gitpython/tickets/27
+            # I am sure I had my reason to make it a class method at first, but now it
+            # doesn't make so much sense anymore, want an instance method as well. See:
+            # http://byronimo.lighthouseapp.com/projects/51787-gitpython/tickets/27
             Reference.delete(ref.repo, ref.path)
             assert not ref.is_valid()
 
@@ -538,14 +588,94 @@ def test_head_reset(self, rw_repo):
 
             Reference.delete(ref.repo, ref.path)
             assert not ref.is_valid()
-            self.failUnlessRaises(ValueError, setattr, ref, 'object', "nonsense")
+            self.assertRaises(ValueError, setattr, ref, "object", "nonsense")
             assert not ref.is_valid()
 
         # END for each path
 
+    @with_rw_repo("0.1.6")
+    def test_tag_message(self, rw_repo):
+        tag_ref = TagReference.create(rw_repo, "test-message-1", message="test")
+        assert tag_ref.tag.message == "test"
+
+        tag_ref = TagReference.create(rw_repo, "test-message-2", logmsg="test")
+        assert tag_ref.tag.message == "test"
+
+        tag_ref = TagReference.create(
+            rw_repo,
+            "test-message-3",
+            # Logmsg should take precedence over "message".
+            message="test1",
+            logmsg="test2",
+        )
+        assert tag_ref.tag.message == "test2"
+
     def test_dereference_recursive(self):
-        # for now, just test the HEAD
-        assert SymbolicReference.dereference_recursive(self.rorepo, 'HEAD')
+        # For now, just test the HEAD.
+        assert SymbolicReference.dereference_recursive(self.rorepo, "HEAD")
 
     def test_reflog(self):
         assert isinstance(self.rorepo.heads.master.log(), RefLog)
+
+    def test_refs_outside_repo(self):
+        # Create a file containing a valid reference outside the repository. Attempting
+        # to access it should raise an exception, due to it containing a parent
+        # directory reference ('..'). This tests for CVE-2023-41040.
+        git_dir = Path(self.rorepo.git_dir)
+        repo_parent_dir = git_dir.parent.parent
+        with tempfile.NamedTemporaryFile(dir=repo_parent_dir) as ref_file:
+            ref_file.write(b"91b464cd624fe22fbf54ea22b85a7e5cca507cfe")
+            ref_file.flush()
+            ref_file_name = Path(ref_file.name).name
+            self.assertRaises(BadName, self.rorepo.commit, f"../../{ref_file_name}")
+
+    def test_validity_ref_names(self):
+        """Ensure ref names are checked for validity.
+
+        This is based on the rules specified in:
+        https://git-scm.com/docs/git-check-ref-format/#_description
+        """
+        check_ref = SymbolicReference._check_ref_name_valid
+
+        # Rule 1
+        self.assertRaises(ValueError, check_ref, ".ref/begins/with/dot")
+        self.assertRaises(ValueError, check_ref, "ref/component/.begins/with/dot")
+        self.assertRaises(ValueError, check_ref, "ref/ends/with/a.lock")
+        self.assertRaises(ValueError, check_ref, "ref/component/ends.lock/with/period_lock")
+
+        # Rule 2
+        check_ref("valid_one_level_refname")
+
+        # Rule 3
+        self.assertRaises(ValueError, check_ref, "ref/contains/../double/period")
+
+        # Rule 4
+        for c in " ~^:":
+            self.assertRaises(ValueError, check_ref, f"ref/contains/invalid{c}/character")
+        for code in range(0, 32):
+            self.assertRaises(ValueError, check_ref, f"ref/contains/invalid{chr(code)}/ASCII/control_character")
+        self.assertRaises(ValueError, check_ref, f"ref/contains/invalid{chr(127)}/ASCII/control_character")
+
+        # Rule 5
+        for c in "*?[":
+            self.assertRaises(ValueError, check_ref, f"ref/contains/invalid{c}/character")
+
+        # Rule 6
+        self.assertRaises(ValueError, check_ref, "/ref/begins/with/slash")
+        self.assertRaises(ValueError, check_ref, "ref/ends/with/slash/")
+        self.assertRaises(ValueError, check_ref, "ref/contains//double/slash/")
+
+        # Rule 7
+        self.assertRaises(ValueError, check_ref, "ref/ends/with/dot.")
+
+        # Rule 8
+        self.assertRaises(ValueError, check_ref, "ref/contains@{/at_brace")
+
+        # Rule 9
+        self.assertRaises(ValueError, check_ref, "@")
+
+        # Rule 10
+        self.assertRaises(ValueError, check_ref, "ref/contain\\s/backslash")
+
+        # Valid reference name should not raise.
+        check_ref("valid/ref/name")
diff --git a/test/test_remote.py b/test/test_remote.py
new file mode 100644
index 000000000..5ddb41bc0
--- /dev/null
+++ b/test/test_remote.py
@@ -0,0 +1,1034 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import gc
+import os.path as osp
+from pathlib import Path
+import random
+import sys
+import tempfile
+from unittest import skipIf
+
+import pytest
+
+from git import (
+    Commit,
+    FetchInfo,
+    GitCommandError,
+    Head,
+    PushInfo,
+    Reference,
+    Remote,
+    RemoteProgress,
+    RemoteReference,
+    SymbolicReference,
+    TagReference,
+)
+from git.cmd import Git
+from git.exc import UnsafeOptionError, UnsafeProtocolError
+from git.util import HIDE_WINDOWS_FREEZE_ERRORS, IterableList, rmtree
+from test.lib import (
+    GIT_DAEMON_PORT,
+    TestBase,
+    fixture,
+    with_rw_and_rw_remote_repo,
+    with_rw_repo,
+)
+
+# Make sure we have repeatable results.
+random.seed(0)
+
+
+class TestRemoteProgress(RemoteProgress):
+    __slots__ = ("_seen_lines", "_stages_per_op", "_num_progress_messages")
+
+    def __init__(self):
+        super().__init__()
+        self._seen_lines = []
+        self._stages_per_op = {}
+        self._num_progress_messages = 0
+
+    def _parse_progress_line(self, line):
+        # We may remove the line later if it is dropped.
+        # Keep it for debugging.
+        self._seen_lines.append(line)
+        rval = super()._parse_progress_line(line)
+        return rval
+
+    def line_dropped(self, line):
+        try:
+            self._seen_lines.remove(line)
+        except ValueError:
+            pass
+
+    def update(self, op_code, cur_count, max_count=None, message=""):
+        # Check each stage only comes once.
+        op_id = op_code & self.OP_MASK
+        assert op_id in (self.COUNTING, self.COMPRESSING, self.WRITING)
+
+        if op_code & self.WRITING > 0:
+            if op_code & self.BEGIN > 0:
+                assert not message, "should not have message when remote begins writing"
+            elif op_code & self.END > 0:
+                assert message
+                assert not message.startswith(", "), "Sanitize progress messages: '%s'" % message
+                assert not message.endswith(", "), "Sanitize progress messages: '%s'" % message
+
+        self._stages_per_op.setdefault(op_id, 0)
+        self._stages_per_op[op_id] = self._stages_per_op[op_id] | (op_code & self.STAGE_MASK)
+
+        if op_code & (self.WRITING | self.END) == (self.WRITING | self.END):
+            assert message
+        # END check we get message
+
+        self._num_progress_messages += 1
+
+    def make_assertion(self):
+        # We don't always receive messages.
+        if not self._seen_lines:
+            return
+
+        # Sometimes objects are not compressed which is okay.
+        assert len(self._seen_ops) in (2, 3), len(self._seen_ops)
+        assert self._stages_per_op
+
+        # Must have seen all stages.
+        for _op, stages in self._stages_per_op.items():
+            assert stages & self.STAGE_MASK == self.STAGE_MASK
+        # END for each op/stage
+
+    def assert_received_message(self):
+        assert self._num_progress_messages
+
+
+class TestRemote(TestBase):
+    def tearDown(self):
+        gc.collect()
+
+    def _print_fetchhead(self, repo):
+        with open(osp.join(repo.git_dir, "FETCH_HEAD")):
+            pass
+
+    def _do_test_fetch_result(self, results, remote):
+        # self._print_fetchhead(remote.repo)
+        self.assertGreater(len(results), 0)
+        self.assertIsInstance(results[0], FetchInfo)
+        for info in results:
+            self.assertIsInstance(info.note, str)
+            if isinstance(info.ref, Reference):
+                self.assertTrue(info.flags)
+            # END reference type flags handling
+            self.assertIsInstance(info.ref, (SymbolicReference, Reference))
+            if info.flags & (info.FORCED_UPDATE | info.FAST_FORWARD):
+                self.assertIsInstance(info.old_commit, Commit)
+            else:
+                self.assertIsNone(info.old_commit)
+            # END forced update checking
+        # END for each info
+
+    def _do_test_push_result(self, results, remote):
+        self.assertIsInstance(results, list)
+        self.assertIsInstance(results, IterableList)
+
+        self.assertGreater(len(results), 0)
+        self.assertIsInstance(results[0], PushInfo)
+        for info in results:
+            self.assertTrue(info.flags)
+            self.assertIsInstance(info.summary, str)
+            if info.old_commit is not None:
+                self.assertIsInstance(info.old_commit, Commit)
+            if info.flags & info.ERROR:
+                has_one = False
+                for bitflag in (
+                    info.REJECTED,
+                    info.REMOTE_REJECTED,
+                    info.REMOTE_FAILURE,
+                ):
+                    has_one |= bool(info.flags & bitflag)
+                # END for each bitflag
+                self.assertTrue(has_one)
+            else:
+                # There must be a remote commit.
+                if info.flags & info.DELETED == 0:
+                    self.assertIsInstance(info.local_ref, Reference)
+                else:
+                    self.assertIsNone(info.local_ref)
+                self.assertIn(type(info.remote_ref), (TagReference, RemoteReference))
+            # END error checking
+        # END for each info
+
+        if any(info.flags & info.ERROR for info in results):
+            self.assertRaises(GitCommandError, results.raise_if_error)
+        else:
+            # No errors, so this should do nothing.
+            results.raise_if_error()
+
+    def _do_test_fetch_info(self, repo):
+        self.assertRaises(ValueError, FetchInfo._from_line, repo, "nonsense", "")
+        self.assertRaises(
+            ValueError,
+            FetchInfo._from_line,
+            repo,
+            "? [up to date]      0.1.7RC    -> origin/0.1.7RC",
+            "",
+        )
+
+    def _commit_random_file(self, repo):
+        """Create a file with a random name and random data and commit it to a repo.
+
+        :return: The committed absolute file path.
+        """
+        index = repo.index
+        new_file = self._make_file(osp.basename(tempfile.mktemp()), str(random.random()), repo)
+        index.add([new_file])
+        index.commit("Committing %s" % new_file)
+        return new_file
+
+    def _do_test_fetch(self, remote, rw_repo, remote_repo, **kwargs):
+        """Specialized fetch testing to de-clutter the main test."""
+        self._do_test_fetch_info(rw_repo)
+
+        def fetch_and_test(remote, **kwargs):
+            progress = TestRemoteProgress()
+            kwargs["progress"] = progress
+            res = remote.fetch(**kwargs)
+            progress.make_assertion()
+            self._do_test_fetch_result(res, remote)
+            return res
+
+        # END fetch and check
+
+        def get_info(res, remote, name):
+            return res["%s/%s" % (remote, name)]
+
+        # Put remote head to master as it is guaranteed to exist.
+        remote_repo.head.reference = remote_repo.heads.master
+
+        res = fetch_and_test(remote, **kwargs)
+        # All up to date.
+        for info in res:
+            self.assertTrue(info.flags & info.HEAD_UPTODATE)
+
+        # Rewind remote head to trigger rejection.
+        # index must be false as remote is a bare repo.
+        rhead = remote_repo.head
+        remote_commit = rhead.commit
+        rhead.reset("HEAD~2", index=False)
+        res = fetch_and_test(remote)
+        mkey = "%s/%s" % (remote, "master")
+        master_info = res[mkey]
+        self.assertTrue(master_info.flags & FetchInfo.FORCED_UPDATE)
+        self.assertIsNotNone(master_info.note)
+
+        # Normal fast forward - set head back to previous one.
+        rhead.commit = remote_commit
+        res = fetch_and_test(remote)
+        self.assertTrue(res[mkey].flags & FetchInfo.FAST_FORWARD)
+
+        # New remote branch.
+        new_remote_branch = Head.create(remote_repo, "new_branch")
+        res = fetch_and_test(remote)
+        new_branch_info = get_info(res, remote, new_remote_branch)
+        self.assertTrue(new_branch_info.flags & FetchInfo.NEW_HEAD)
+
+        # Remote branch rename (causes creation of a new one locally).
+        new_remote_branch.rename("other_branch_name")
+        res = fetch_and_test(remote)
+        other_branch_info = get_info(res, remote, new_remote_branch)
+        self.assertEqual(other_branch_info.ref.commit, new_branch_info.ref.commit)
+
+        # Remove new branch.
+        Head.delete(new_remote_branch.repo, new_remote_branch)
+        res = fetch_and_test(remote)
+        # Deleted remote will not be fetched.
+        self.assertRaises(IndexError, get_info, res, remote, new_remote_branch)
+
+        # Prune stale tracking branches.
+        stale_refs = remote.stale_refs
+        self.assertEqual(len(stale_refs), 2)
+        self.assertIsInstance(stale_refs[0], RemoteReference)
+        RemoteReference.delete(rw_repo, *stale_refs)
+
+        # Test single branch fetch with refspec including target remote.
+        res = fetch_and_test(remote, refspec="master:refs/remotes/%s/master" % remote)
+        self.assertEqual(len(res), 1)
+        self.assertTrue(get_info(res, remote, "master"))
+
+        # ...with respec and no target.
+        res = fetch_and_test(remote, refspec="master")
+        self.assertEqual(len(res), 1)
+
+        # ...multiple refspecs...works, but git command returns with error if one ref is
+        # wrong without doing anything. This is new in later binaries.
+        # res = fetch_and_test(remote, refspec=['master', 'fred'])
+        # self.assertEqual(len(res), 1)
+
+        # Add new tag reference.
+        rtag = TagReference.create(remote_repo, "1.0-RV_hello.there")
+        res = fetch_and_test(remote, tags=True)
+        tinfo = res[str(rtag)]
+        self.assertIsInstance(tinfo.ref, TagReference)
+        self.assertEqual(tinfo.ref.commit, rtag.commit)
+        self.assertTrue(tinfo.flags & tinfo.NEW_TAG)
+
+        # Adjust the local tag commit.
+        Reference.set_object(rtag, rhead.commit.parents[0].parents[0])
+
+        # As of git 2.20 one cannot clobber local tags that have changed without
+        # specifying --force, and the test assumes you can clobber, so...
+        force = None
+        if rw_repo.git.version_info[:2] >= (2, 20):
+            force = True
+        res = fetch_and_test(remote, tags=True, force=force)
+        tinfo = res[str(rtag)]
+        self.assertEqual(tinfo.commit, rtag.commit)
+        self.assertTrue(tinfo.flags & tinfo.TAG_UPDATE)
+
+        # Delete remote tag - local one will stay.
+        TagReference.delete(remote_repo, rtag)
+        res = fetch_and_test(remote, tags=True)
+        self.assertRaises(IndexError, get_info, res, remote, str(rtag))
+
+        # Provoke to receive actual objects to see what kind of output we have to
+        # expect. For that we need a remote transport protocol.
+        # Create a new UN-shared repo and fetch into it after we pushed a change to the
+        # shared repo.
+        other_repo_dir = tempfile.mktemp("other_repo")
+        # Must clone with a local path for the repo implementation not to freak out as
+        # it wants local paths only (which I can understand).
+        other_repo = remote_repo.clone(other_repo_dir, shared=False)
+        remote_repo_url = osp.basename(remote_repo.git_dir)  # git-daemon runs with appropriate `--base-path`.
+        remote_repo_url = Git.polish_url("git://localhost:%s/%s" % (GIT_DAEMON_PORT, remote_repo_url))
+
+        # Put origin to git-url.
+        other_origin = other_repo.remotes.origin
+        with other_origin.config_writer as cw:
+            cw.set("url", remote_repo_url)
+        # It automatically creates alternates as remote_repo is shared as well.
+        # It will use the transport though and ignore alternates when fetching.
+        # assert not other_repo.alternates  # this would fail
+
+        # Ensure we are in the right state.
+        rw_repo.head.reset(remote.refs.master, working_tree=True)
+        try:
+            self._commit_random_file(rw_repo)
+            remote.push(rw_repo.head.reference)
+
+            # Here I would expect to see remote-information about packing objects and so
+            # on. Unfortunately, this does not happen if we are redirecting the output -
+            # git explicitly checks for this and only provides progress information to
+            # ttys.
+            res = fetch_and_test(other_origin)
+        finally:
+            rmtree(other_repo_dir)
+        # END test and cleanup
+
+    def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
+        # Push our changes.
+        lhead = rw_repo.head
+        # Ensure we are on master and it is checked out where the remote is.
+        try:
+            lhead.reference = rw_repo.heads.master
+        except AttributeError:
+            # If the author is on a non-master branch, the clones might not have a local
+            # master yet. We simply create it.
+            lhead.reference = rw_repo.create_head("master")
+        # END master handling
+        lhead.reset(remote.refs.master, working_tree=True)
+
+        # Push without spec should fail (without further configuration)
+        # well, works nicely
+        # self.assertRaises(GitCommandError, remote.push)
+
+        # Simple file push.
+        self._commit_random_file(rw_repo)
+        progress = TestRemoteProgress()
+        res = remote.push(lhead.reference, progress)
+        self.assertIsInstance(res, list)
+        self._do_test_push_result(res, remote)
+        progress.make_assertion()
+
+        # Rejected - undo last commit.
+        lhead.reset("HEAD~1")
+        res = remote.push(lhead.reference)
+        self.assertTrue(res[0].flags & PushInfo.ERROR)
+        self.assertTrue(res[0].flags & PushInfo.REJECTED)
+        self._do_test_push_result(res, remote)
+
+        # Force rejected pull.
+        res = remote.push("+%s" % lhead.reference)
+        self.assertEqual(res[0].flags & PushInfo.ERROR, 0)
+        self.assertTrue(res[0].flags & PushInfo.FORCED_UPDATE)
+        self._do_test_push_result(res, remote)
+
+        # Invalid refspec.
+        self.assertRaises(GitCommandError, remote.push, "hellothere")
+
+        # Push new tags.
+        progress = TestRemoteProgress()
+        to_be_updated = "my_tag.1.0RV"
+        new_tag = TagReference.create(rw_repo, to_be_updated)  # @UnusedVariable
+        other_tag = TagReference.create(rw_repo, "my_obj_tag.2.1aRV", logmsg="my message")
+        res = remote.push(progress=progress, tags=True)
+        self.assertTrue(res[-1].flags & PushInfo.NEW_TAG)
+        progress.make_assertion()
+        self._do_test_push_result(res, remote)
+
+        # Update push new tags.
+        # Rejection is default.
+        new_tag = TagReference.create(rw_repo, to_be_updated, reference="HEAD~1", force=True)
+        res = remote.push(tags=True)
+        self._do_test_push_result(res, remote)
+        self.assertTrue(res[-1].flags & PushInfo.REJECTED)
+        self.assertTrue(res[-1].flags & PushInfo.ERROR)
+
+        # Force push this tag.
+        res = remote.push("+%s" % new_tag.path)
+        self.assertEqual(res[-1].flags & PushInfo.ERROR, 0)
+        self.assertTrue(res[-1].flags & PushInfo.FORCED_UPDATE)
+
+        # Delete tag - have to do it using refspec.
+        res = remote.push(":%s" % new_tag.path)
+        self._do_test_push_result(res, remote)
+        self.assertTrue(res[0].flags & PushInfo.DELETED)
+        # Currently progress is not properly transferred, especially not using
+        # the git daemon.
+        # progress.assert_received_message()
+
+        # Push new branch.
+        new_head = Head.create(rw_repo, "my_new_branch")
+        progress = TestRemoteProgress()
+        res = remote.push(new_head, progress)
+        self.assertGreater(len(res), 0)
+        self.assertTrue(res[0].flags & PushInfo.NEW_HEAD)
+        progress.make_assertion()
+        self._do_test_push_result(res, remote)
+
+        # Rejected stale delete.
+        force_with_lease = "%s:0000000000000000000000000000000000000000" % new_head.path
+        res = remote.push(":%s" % new_head.path, force_with_lease=force_with_lease)
+        self.assertTrue(res[0].flags & PushInfo.ERROR)
+        self.assertTrue(res[0].flags & PushInfo.REJECTED)
+        self.assertIsNone(res[0].local_ref)
+        self._do_test_push_result(res, remote)
+
+        # Delete new branch on the remote end and locally.
+        res = remote.push(":%s" % new_head.path)
+        self._do_test_push_result(res, remote)
+        Head.delete(rw_repo, new_head)
+        self.assertTrue(res[-1].flags & PushInfo.DELETED)
+
+        # --all
+        res = remote.push(all=True)
+        self._do_test_push_result(res, remote)
+
+        remote.pull("master", kill_after_timeout=10.0)
+
+        # Cleanup - delete created tags and branches as we are in an inner loop on
+        # the same repository.
+        TagReference.delete(rw_repo, new_tag, other_tag)
+        remote.push(":%s" % other_tag.path, kill_after_timeout=10.0)
+
+    @skipIf(HIDE_WINDOWS_FREEZE_ERRORS, "FIXME: Freezes!")
+    @with_rw_and_rw_remote_repo("0.1.6")
+    def test_base(self, rw_repo, remote_repo):
+        num_remotes = 0
+        remote_set = set()
+        ran_fetch_test = False
+
+        for remote in rw_repo.remotes:
+            num_remotes += 1
+            self.assertEqual(remote, remote)
+            self.assertNotEqual(str(remote), repr(remote))
+            remote_set.add(remote)
+            remote_set.add(remote)  # Should already exist.
+            # REFS
+            refs = remote.refs
+            self.assertTrue(refs)
+            for ref in refs:
+                self.assertEqual(ref.remote_name, remote.name)
+                self.assertTrue(ref.remote_head)
+            # END for each ref
+
+            # OPTIONS
+            # Cannot use 'fetch' key anymore as it is now a method.
+            for opt in ("url",):
+                val = getattr(remote, opt)
+                reader = remote.config_reader
+                assert reader.get(opt) == val
+                assert reader.get_value(opt, None) == val
+
+                # Unable to write with a reader.
+                self.assertRaises(IOError, reader.set, opt, "test")
+
+                # Change value.
+                with remote.config_writer as writer:
+                    new_val = "myval"
+                    writer.set(opt, new_val)
+                    assert writer.get(opt) == new_val
+                    writer.set(opt, val)
+                    assert writer.get(opt) == val
+                assert getattr(remote, opt) == val
+            # END for each default option key
+
+            # RENAME
+            other_name = "totally_other_name"
+            prev_name = remote.name
+            self.assertEqual(remote.rename(other_name), remote)
+            self.assertNotEqual(prev_name, remote.name)
+            # Multiple times.
+            for _ in range(2):
+                self.assertEqual(remote.rename(prev_name).name, prev_name)
+            # END for each rename ( back to prev_name )
+
+            # PUSH/PULL TESTING
+            self._assert_push_and_pull(remote, rw_repo, remote_repo)
+
+            # FETCH TESTING
+            # Only for remotes - local cases are the same or less complicated as
+            # additional progress information will never be emitted.
+            if remote.name == "daemon_origin":
+                self._do_test_fetch(remote, rw_repo, remote_repo, kill_after_timeout=10.0)
+                ran_fetch_test = True
+            # END fetch test
+
+            remote.update()
+        # END for each remote
+
+        self.assertTrue(ran_fetch_test)
+        self.assertTrue(num_remotes)
+        self.assertEqual(num_remotes, len(remote_set))
+
+        origin = rw_repo.remote("origin")
+        assert origin == rw_repo.remotes.origin
+
+        # Verify we can handle prunes when fetching.
+        # stderr lines look like this:  x [deleted]         (none)     -> origin/experiment-2012
+        # These should just be skipped.
+        # If we don't have a manual checkout, we can't actually assume there are any
+        # non-master branches.
+        remote_repo.create_head("myone_for_deletion")
+        # Get the branch - to be pruned later
+        origin.fetch()
+
+        num_deleted = False
+        for branch in remote_repo.heads:
+            if branch.name != "master":
+                branch.delete(remote_repo, branch, force=True)
+                num_deleted += 1
+        # END for each branch
+        self.assertGreater(num_deleted, 0)
+        self.assertEqual(
+            len(rw_repo.remotes.origin.fetch(prune=True)),
+            1,
+            "deleted everything but master",
+        )
+
+    @with_rw_repo("HEAD", bare=True)
+    def test_creation_and_removal(self, bare_rw_repo):
+        new_name = "test_new_one"
+        arg_list = (new_name, "git@server:hello.git")
+        remote = Remote.create(bare_rw_repo, *arg_list)
+        self.assertEqual(remote.name, "test_new_one")
+        self.assertIn(remote, bare_rw_repo.remotes)
+        self.assertTrue(remote.exists())
+
+        # Create same one again.
+        self.assertRaises(GitCommandError, Remote.create, bare_rw_repo, *arg_list)
+
+        Remote.remove(bare_rw_repo, new_name)
+        self.assertTrue(remote.exists())  # We still have a cache that doesn't know we were deleted by name.
+        remote._clear_cache()
+        assert not remote.exists()  # Cache should be renewed now. This is an issue...
+
+        for remote in bare_rw_repo.remotes:
+            if remote.name == new_name:
+                raise AssertionError("Remote removal failed")
+            # END if deleted remote matches existing remote's name
+        # END for each remote
+
+        # Issue #262 - the next call would fail if bug wasn't fixed.
+        bare_rw_repo.create_remote("bogus", "/bogus/path", mirror="push")
+
+    def test_fetch_info(self):
+        # Ensure we can handle remote-tracking branches.
+        fetch_info_line_fmt = "c437ee5deb8d00cf02f03720693e4c802e99f390	not-for-merge	%s '0.3' of "
+        fetch_info_line_fmt += "git://github.com/gitpython-developers/GitPython"
+        remote_info_line_fmt = "* [new branch]      nomatter     -> %s"
+
+        self.assertRaises(
+            ValueError,
+            FetchInfo._from_line,
+            self.rorepo,
+            remote_info_line_fmt % "refs/something/branch",
+            "269c498e56feb93e408ed4558c8138d750de8893\t\t/Users/ben/test/foo\n",
+        )
+
+        fi = FetchInfo._from_line(
+            self.rorepo,
+            remote_info_line_fmt % "local/master",
+            fetch_info_line_fmt % "remote-tracking branch",
+        )
+        assert not fi.ref.is_valid()
+        self.assertEqual(fi.ref.name, "local/master")
+
+        # Handles non-default refspecs: One can specify a different path in refs/remotes
+        # or a special path just in refs/something for instance.
+
+        fi = FetchInfo._from_line(
+            self.rorepo,
+            remote_info_line_fmt % "subdir/tagname",
+            fetch_info_line_fmt % "tag",
+        )
+
+        self.assertIsInstance(fi.ref, TagReference)
+        assert fi.ref.path.startswith("refs/tags"), fi.ref.path
+
+        # It could be in a remote directory though.
+        fi = FetchInfo._from_line(
+            self.rorepo,
+            remote_info_line_fmt % "remotename/tags/tagname",
+            fetch_info_line_fmt % "tag",
+        )
+
+        self.assertIsInstance(fi.ref, TagReference)
+        assert fi.ref.path.startswith("refs/remotes/"), fi.ref.path
+
+        # It can also be anywhere!
+        tag_path = "refs/something/remotename/tags/tagname"
+        fi = FetchInfo._from_line(self.rorepo, remote_info_line_fmt % tag_path, fetch_info_line_fmt % "tag")
+
+        self.assertIsInstance(fi.ref, TagReference)
+        self.assertEqual(fi.ref.path, tag_path)
+
+        # Branches default to refs/remotes.
+        fi = FetchInfo._from_line(
+            self.rorepo,
+            remote_info_line_fmt % "remotename/branch",
+            fetch_info_line_fmt % "branch",
+        )
+
+        self.assertIsInstance(fi.ref, RemoteReference)
+        self.assertEqual(fi.ref.remote_name, "remotename")
+
+        # But you can force it anywhere, in which case we only have a references.
+        fi = FetchInfo._from_line(
+            self.rorepo,
+            remote_info_line_fmt % "refs/something/branch",
+            fetch_info_line_fmt % "branch",
+        )
+
+        assert type(fi.ref) is Reference, type(fi.ref)
+        self.assertEqual(fi.ref.path, "refs/something/branch")
+
+    def test_uncommon_branch_names(self):
+        stderr_lines = fixture("uncommon_branch_prefix_stderr").decode("ascii").splitlines()
+        fetch_lines = fixture("uncommon_branch_prefix_FETCH_HEAD").decode("ascii").splitlines()
+
+        # The contents of the files above must be fetched with a custom refspec:
+        # +refs/pull/*:refs/heads/pull/*
+        res = [
+            FetchInfo._from_line("ShouldntMatterRepo", stderr, fetch_line)
+            for stderr, fetch_line in zip(stderr_lines, fetch_lines)
+        ]
+        self.assertGreater(len(res), 0)
+        self.assertEqual(res[0].remote_ref_path, "refs/pull/1/head")
+        self.assertEqual(res[0].ref.path, "refs/heads/pull/1/head")
+        self.assertIsInstance(res[0].ref, Head)
+
+    @with_rw_repo("HEAD", bare=False)
+    def test_multiple_urls(self, rw_repo):
+        # Test addresses.
+        test1 = "https://github.com/gitpython-developers/GitPython"
+        test2 = "https://github.com/gitpython-developers/gitdb"
+        test3 = "https://github.com/gitpython-developers/smmap"
+
+        remote = rw_repo.remotes[0]
+        # Test setting a single URL.
+        remote.set_url(test1)
+        self.assertEqual(list(remote.urls), [test1])
+
+        # Test replacing that single URL.
+        remote.set_url(test1)
+        self.assertEqual(list(remote.urls), [test1])
+        # Test adding new URLs.
+        remote.set_url(test2, add=True)
+        self.assertEqual(list(remote.urls), [test1, test2])
+        remote.set_url(test3, add=True)
+        self.assertEqual(list(remote.urls), [test1, test2, test3])
+        # Test removing a URL.
+        remote.set_url(test2, delete=True)
+        self.assertEqual(list(remote.urls), [test1, test3])
+        # Test changing a URL.
+        remote.set_url(test2, test3)
+        self.assertEqual(list(remote.urls), [test1, test2])
+
+        # will raise: fatal: --add --delete doesn't make sense
+        self.assertRaises(GitCommandError, remote.set_url, test2, add=True, delete=True)
+
+        # Test on another remote, with the add/delete URL.
+        remote = rw_repo.create_remote("another", url=test1)
+        remote.add_url(test2)
+        self.assertEqual(list(remote.urls), [test1, test2])
+        remote.add_url(test3)
+        self.assertEqual(list(remote.urls), [test1, test2, test3])
+        # Test removing all the URLs.
+        remote.delete_url(test2)
+        self.assertEqual(list(remote.urls), [test1, test3])
+        remote.delete_url(test1)
+        self.assertEqual(list(remote.urls), [test3])
+        # Will raise fatal: Will not delete all non-push URLs.
+        self.assertRaises(GitCommandError, remote.delete_url, test3)
+
+    def test_fetch_error(self):
+        rem = self.rorepo.remote("origin")
+        with self.assertRaisesRegex(GitCommandError, "[Cc]ouldn't find remote ref __BAD_REF__"):
+            rem.fetch("__BAD_REF__")
+
+    @with_rw_repo("0.1.6", bare=False)
+    def test_push_error(self, repo):
+        rem = repo.remote("origin")
+        with self.assertRaisesRegex(GitCommandError, "src refspec __BAD_REF__ does not match any"):
+            rem.push("__BAD_REF__")
+
+    @with_rw_repo("HEAD")
+    def test_set_unsafe_url(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                with self.assertRaises(UnsafeProtocolError):
+                    remote.set_url(url)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_set_unsafe_url_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                remote.set_url(url, allow_unsafe_protocols=True)
+                assert list(remote.urls)[-1] == url
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_add_unsafe_url(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                with self.assertRaises(UnsafeProtocolError):
+                    remote.add_url(url)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_add_unsafe_url_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                remote.add_url(url, allow_unsafe_protocols=True)
+                assert list(remote.urls)[-1] == url
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_create_remote_unsafe_url(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                with self.assertRaises(UnsafeProtocolError):
+                    Remote.create(rw_repo, "origin", url)
+                assert not tmp_file.exists()
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason=R"Multiple '\' instead of '/' in remote.url make it differ from expected value",
+        raises=AssertionError,
+    )
+    @with_rw_repo("HEAD")
+    def test_create_remote_unsafe_url_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for i, url in enumerate(urls):
+                remote = Remote.create(rw_repo, f"origin{i}", url, allow_unsafe_protocols=True)
+                assert remote.url == url
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_fetch_unsafe_url(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                with self.assertRaises(UnsafeProtocolError):
+                    remote.fetch(url)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_fetch_unsafe_url_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                # The URL will be allowed into the command, but the command will fail
+                # since we don't have that protocol enabled in the Git config file.
+                with self.assertRaises(GitCommandError):
+                    remote.fetch(url, allow_unsafe_protocols=True)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_fetch_unsafe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            remote = rw_repo.remote("origin")
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [{"upload-pack": f"touch {tmp_file}"}]
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(UnsafeOptionError):
+                    remote.fetch(**unsafe_option)
+                assert not tmp_file.exists()
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason=(
+            "File not created. A separate Windows command may be needed. This and the "
+            "currently passing test test_fetch_unsafe_options must be adjusted in the "
+            "same way. Until then, test_fetch_unsafe_options is unreliable on Windows."
+        ),
+        raises=AssertionError,
+    )
+    @with_rw_repo("HEAD")
+    def test_fetch_unsafe_options_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            remote = rw_repo.remote("origin")
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [{"upload-pack": f"touch {tmp_file}"}]
+            for unsafe_option in unsafe_options:
+                # The options will be allowed, but the command will fail.
+                assert not tmp_file.exists()
+                with self.assertRaises(GitCommandError):
+                    remote.fetch(**unsafe_option, allow_unsafe_options=True)
+                assert tmp_file.exists()
+                tmp_file.unlink()
+
+    @with_rw_repo("HEAD")
+    def test_pull_unsafe_url(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                with self.assertRaises(UnsafeProtocolError):
+                    remote.pull(url)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_pull_unsafe_url_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                # The URL will be allowed into the command, but the command will fail
+                # since we don't have that protocol enabled in the Git config file.
+                with self.assertRaises(GitCommandError):
+                    remote.pull(url, allow_unsafe_protocols=True)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_pull_unsafe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            remote = rw_repo.remote("origin")
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [{"upload-pack": f"touch {tmp_file}"}]
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(UnsafeOptionError):
+                    remote.pull(**unsafe_option)
+                assert not tmp_file.exists()
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason=(
+            "File not created. A separate Windows command may be needed. This and the "
+            "currently passing test test_pull_unsafe_options must be adjusted in the "
+            "same way. Until then, test_pull_unsafe_options is unreliable on Windows."
+        ),
+        raises=AssertionError,
+    )
+    @with_rw_repo("HEAD")
+    def test_pull_unsafe_options_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            remote = rw_repo.remote("origin")
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [{"upload-pack": f"touch {tmp_file}"}]
+            for unsafe_option in unsafe_options:
+                # The options will be allowed, but the command will fail.
+                assert not tmp_file.exists()
+                with self.assertRaises(GitCommandError):
+                    remote.pull(**unsafe_option, allow_unsafe_options=True)
+                assert tmp_file.exists()
+                tmp_file.unlink()
+
+    @with_rw_repo("HEAD")
+    def test_push_unsafe_url(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                with self.assertRaises(UnsafeProtocolError):
+                    remote.push(url)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_push_unsafe_url_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            remote = rw_repo.remote("origin")
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                # The URL will be allowed into the command, but the command will fail
+                # since we don't have that protocol enabled in the Git config file.
+                with self.assertRaises(GitCommandError):
+                    remote.push(url, allow_unsafe_protocols=True)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_push_unsafe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            remote = rw_repo.remote("origin")
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                {
+                    "receive-pack": f"touch {tmp_file}",
+                    "exec": f"touch {tmp_file}",
+                }
+            ]
+            for unsafe_option in unsafe_options:
+                assert not tmp_file.exists()
+                with self.assertRaises(UnsafeOptionError):
+                    remote.push(**unsafe_option)
+                assert not tmp_file.exists()
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason=(
+            "File not created. A separate Windows command may be needed. This and the "
+            "currently passing test test_push_unsafe_options must be adjusted in the "
+            "same way. Until then, test_push_unsafe_options is unreliable on Windows."
+        ),
+        raises=AssertionError,
+    )
+    @with_rw_repo("HEAD")
+    def test_push_unsafe_options_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            remote = rw_repo.remote("origin")
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                {
+                    "receive-pack": f"touch {tmp_file}",
+                    "exec": f"touch {tmp_file}",
+                }
+            ]
+            for unsafe_option in unsafe_options:
+                # The options will be allowed, but the command will fail.
+                assert not tmp_file.exists()
+                with self.assertRaises(GitCommandError):
+                    remote.push(**unsafe_option, allow_unsafe_options=True)
+                assert tmp_file.exists()
+                tmp_file.unlink()
+
+    @with_rw_and_rw_remote_repo("0.1.6")
+    def test_fetch_unsafe_branch_name(self, rw_repo, remote_repo):
+        # Create branch with a name containing a NBSP
+        bad_branch_name = f"branch_with_{chr(160)}_nbsp"
+        Head.create(remote_repo, bad_branch_name)
+
+        # Fetch and get branches
+        remote = rw_repo.remote("origin")
+        branches = remote.fetch()
+
+        # Test for truncated branch name in branches
+        assert f"origin/{bad_branch_name}" in [b.name for b in branches]
+
+        # Cleanup branch
+        Head.delete(remote_repo, bad_branch_name)
+
+
+class TestTimeouts(TestBase):
+    @with_rw_repo("HEAD", bare=False)
+    def test_timeout_funcs(self, repo):
+        # Force error code to prevent a race condition if the python thread is slow.
+        default = Git.AutoInterrupt._status_code_if_terminate
+        Git.AutoInterrupt._status_code_if_terminate = -15
+        for function in ["pull", "fetch"]:  # Can't get push to time out.
+            f = getattr(repo.remotes.origin, function)
+            assert f is not None  # Make sure these functions exist.
+            _ = f()  # Make sure the function runs.
+            with pytest.raises(GitCommandError, match="kill_after_timeout=0 s"):
+                f(kill_after_timeout=0)
+
+        Git.AutoInterrupt._status_code_if_terminate = default
diff --git a/test/test_repo.py b/test/test_repo.py
new file mode 100644
index 000000000..bfa1bbb78
--- /dev/null
+++ b/test/test_repo.py
@@ -0,0 +1,1448 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import gc
+import glob
+import io
+from io import BytesIO
+import itertools
+import os
+import os.path as osp
+import pathlib
+import pickle
+import sys
+import tempfile
+from unittest import mock, skip
+
+import pytest
+
+from git import (
+    BadName,
+    Commit,
+    Git,
+    GitCmdObjectDB,
+    GitCommandError,
+    GitDB,
+    Head,
+    IndexFile,
+    InvalidGitRepositoryError,
+    NoSuchPathError,
+    Object,
+    Reference,
+    Remote,
+    Repo,
+    Submodule,
+    Tree,
+)
+from git.exc import BadObject, UnsafeOptionError, UnsafeProtocolError
+from git.repo.fun import touch
+from git.util import bin_to_hex, cwd, cygpath, join_path_native, rmfile, rmtree
+
+from test.lib import TestBase, fixture, with_rw_directory, with_rw_repo
+
+
+def iter_flatten(lol):
+    for items in lol:
+        for item in items:
+            yield item
+
+
+def flatten(lol):
+    return list(iter_flatten(lol))
+
+
+_tc_lock_fpaths = osp.join(osp.dirname(__file__), "../../.git/*.lock")
+
+
+def _rm_lock_files():
+    for lfp in glob.glob(_tc_lock_fpaths):
+        rmfile(lfp)
+
+
+class TestRepo(TestBase):
+    def setUp(self):
+        _rm_lock_files()
+
+    def tearDown(self):
+        for lfp in glob.glob(_tc_lock_fpaths):
+            if osp.isfile(lfp):
+                raise AssertionError("Previous TC left hanging git-lock file: {}".format(lfp))
+
+        gc.collect()
+
+    def test_new_should_raise_on_invalid_repo_location(self):
+        # Ideally this tests a directory that is outside of any repository. In the rare
+        # case tempfile.gettempdir() is inside a repo, this still passes, but tests the
+        # same scenario as test_new_should_raise_on_invalid_repo_location_within_repo.
+        with tempfile.TemporaryDirectory() as tdir:
+            self.assertRaises(InvalidGitRepositoryError, Repo, tdir)
+
+    @with_rw_directory
+    def test_new_should_raise_on_invalid_repo_location_within_repo(self, rw_dir):
+        repo_dir = osp.join(rw_dir, "repo")
+        Repo.init(repo_dir)
+        subdir = osp.join(repo_dir, "subdir")
+        os.mkdir(subdir)
+        self.assertRaises(InvalidGitRepositoryError, Repo, subdir)
+
+    def test_new_should_raise_on_non_existent_path(self):
+        with tempfile.TemporaryDirectory() as tdir:
+            nonexistent = osp.join(tdir, "foobar")
+            self.assertRaises(NoSuchPathError, Repo, nonexistent)
+
+    @with_rw_repo("0.3.2.1")
+    def test_repo_creation_from_different_paths(self, rw_repo):
+        r_from_gitdir = Repo(rw_repo.git_dir)
+        self.assertEqual(r_from_gitdir.git_dir, rw_repo.git_dir)
+        assert r_from_gitdir.git_dir.endswith(".git")
+        assert not rw_repo.git.working_dir.endswith(".git")
+        self.assertEqual(r_from_gitdir.git.working_dir, rw_repo.git.working_dir)
+
+    @with_rw_repo("0.3.2.1")
+    def test_repo_creation_pathlib(self, rw_repo):
+        r_from_gitdir = Repo(pathlib.Path(rw_repo.git_dir))
+        self.assertEqual(r_from_gitdir.git_dir, rw_repo.git_dir)
+
+    def test_description(self):
+        txt = "Test repository"
+        self.rorepo.description = txt
+        self.assertEqual(self.rorepo.description, txt)
+
+    def test_heads_should_return_array_of_head_objects(self):
+        for head in self.rorepo.heads:
+            self.assertEqual(Head, head.__class__)
+
+    def test_heads_should_populate_head_data(self):
+        for head in self.rorepo.heads:
+            assert head.name
+            self.assertIsInstance(head.commit, Commit)
+        # END for each head
+
+        self.assertIsInstance(self.rorepo.heads.master, Head)
+        self.assertIsInstance(self.rorepo.heads["master"], Head)
+
+    def test_tree_from_revision(self):
+        tree = self.rorepo.tree("0.1.6")
+        self.assertEqual(len(tree.hexsha), 40)
+        self.assertEqual(tree.type, "tree")
+        self.assertEqual(self.rorepo.tree(tree), tree)
+
+        # Try from an invalid revision that does not exist.
+        self.assertRaises(BadName, self.rorepo.tree, "hello world")
+
+    def test_pickleable(self):
+        pickle.loads(pickle.dumps(self.rorepo))
+
+    def test_commit_from_revision(self):
+        commit = self.rorepo.commit("0.1.4")
+        self.assertEqual(commit.type, "commit")
+        self.assertEqual(self.rorepo.commit(commit), commit)
+
+    def test_commits(self):
+        mc = 10
+        commits = list(self.rorepo.iter_commits("0.1.6", max_count=mc))
+        self.assertEqual(len(commits), mc)
+
+        c = commits[0]
+        self.assertEqual("9a4b1d4d11eee3c5362a4152216376e634bd14cf", c.hexsha)
+        self.assertEqual(["c76852d0bff115720af3f27acdb084c59361e5f6"], [p.hexsha for p in c.parents])
+        self.assertEqual("ce41fc29549042f1aa09cc03174896cf23f112e3", c.tree.hexsha)
+        self.assertEqual("Michael Trier", c.author.name)
+        self.assertEqual("mtrier@gmail.com", c.author.email)
+        self.assertEqual(1232829715, c.authored_date)
+        self.assertEqual(5 * 3600, c.author_tz_offset)
+        self.assertEqual("Michael Trier", c.committer.name)
+        self.assertEqual("mtrier@gmail.com", c.committer.email)
+        self.assertEqual(1232829715, c.committed_date)
+        self.assertEqual(5 * 3600, c.committer_tz_offset)
+        self.assertEqual("Bumped version 0.1.6\n", c.message)
+
+        c = commits[1]
+        self.assertIsInstance(c.parents, tuple)
+
+    def test_trees(self):
+        mc = 30
+        num_trees = 0
+        for tree in self.rorepo.iter_trees("0.1.5", max_count=mc):
+            num_trees += 1
+            self.assertIsInstance(tree, Tree)
+        # END for each tree
+        self.assertEqual(num_trees, mc)
+
+    def _assert_empty_repo(self, repo):
+        """Test all kinds of things with an empty, freshly initialized repo.
+
+        It should throw good errors.
+        """
+        # Entries should be empty.
+        self.assertEqual(len(repo.index.entries), 0)
+
+        # head is accessible.
+        assert repo.head
+        assert repo.head.ref
+        assert not repo.head.is_valid()
+
+        # We can change the head to some other ref.
+        head_ref = Head.from_path(repo, Head.to_full_path("some_head"))
+        assert not head_ref.is_valid()
+        repo.head.ref = head_ref
+
+        # is_dirty can handle all kwargs.
+        for args in ((1, 0, 0), (0, 1, 0), (0, 0, 1)):
+            assert not repo.is_dirty(*args)
+        # END for each arg
+
+        # We can add a file to the index (if we are not bare).
+        if not repo.bare:
+            pass
+        # END test repos with working tree
+
+    @with_rw_directory
+    def test_clone_from_keeps_env(self, rw_dir):
+        original_repo = Repo.init(osp.join(rw_dir, "repo"))
+        environment = {"entry1": "value", "another_entry": "10"}
+
+        cloned = Repo.clone_from(original_repo.git_dir, osp.join(rw_dir, "clone"), env=environment)
+
+        self.assertEqual(environment, cloned.git.environment())
+
+    @with_rw_directory
+    def test_date_format(self, rw_dir):
+        repo = Repo.init(osp.join(rw_dir, "repo"))
+        # @-timestamp is the format used by git commit hooks.
+        repo.index.commit("Commit messages", commit_date="@1400000000 +0000")
+
+    @with_rw_directory
+    def test_clone_from_pathlib(self, rw_dir):
+        original_repo = Repo.init(osp.join(rw_dir, "repo"))
+
+        Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib")
+
+    @with_rw_directory
+    def test_clone_from_pathlib_withConfig(self, rw_dir):
+        original_repo = Repo.init(osp.join(rw_dir, "repo"))
+
+        cloned = Repo.clone_from(
+            original_repo.git_dir,
+            pathlib.Path(rw_dir) / "clone_pathlib_withConfig",
+            multi_options=[
+                "--recurse-submodules=repo",
+                "--config core.filemode=false",
+                "--config submodule.repo.update=checkout",
+                "--config filter.lfs.clean='git-lfs clean -- %f'",
+            ],
+            allow_unsafe_options=True,
+        )
+
+        self.assertEqual(cloned.config_reader().get_value("submodule", "active"), "repo")
+        self.assertEqual(cloned.config_reader().get_value("core", "filemode"), False)
+        self.assertEqual(cloned.config_reader().get_value('submodule "repo"', "update"), "checkout")
+        self.assertEqual(
+            cloned.config_reader().get_value('filter "lfs"', "clean"),
+            "git-lfs clean -- %f",
+        )
+
+    def test_clone_from_with_path_contains_unicode(self):
+        with tempfile.TemporaryDirectory() as tmpdir:
+            unicode_dir_name = "\u0394"
+            path_with_unicode = os.path.join(tmpdir, unicode_dir_name)
+            os.makedirs(path_with_unicode)
+
+            try:
+                Repo.clone_from(
+                    url=self._small_repo_url(),
+                    to_path=path_with_unicode,
+                )
+            except UnicodeEncodeError:
+                self.fail("Raised UnicodeEncodeError")
+
+    @with_rw_directory
+    @skip(
+        """The referenced repository was removed, and one needs to set up a new
+        password controlled repo under the org's control."""
+    )
+    def test_leaking_password_in_clone_logs(self, rw_dir):
+        password = "fakepassword1234"
+        try:
+            Repo.clone_from(
+                url="https://fakeuser:{}@fakerepo.example.com/testrepo".format(password),
+                to_path=rw_dir,
+            )
+        except GitCommandError as err:
+            assert password not in str(err), "The error message '%s' should not contain the password" % err
+        # Working example from a blank private project.
+        Repo.clone_from(
+            url="https://gitlab+deploy-token-392045:mLWhVus7bjLsy8xj8q2V@gitlab.com/mercierm/test_git_python",
+            to_path=rw_dir,
+        )
+
+    @with_rw_repo("HEAD")
+    def test_clone_unsafe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                f"--upload-pack='touch {tmp_file}'",
+                f"-u 'touch {tmp_file}'",
+                "--config=protocol.ext.allow=always",
+                "-c protocol.ext.allow=always",
+            ]
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(UnsafeOptionError):
+                    rw_repo.clone(tmp_dir, multi_options=[unsafe_option])
+                assert not tmp_file.exists()
+
+            unsafe_options = [
+                {"upload-pack": f"touch {tmp_file}"},
+                {"u": f"touch {tmp_file}"},
+                {"config": "protocol.ext.allow=always"},
+                {"c": "protocol.ext.allow=always"},
+            ]
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(UnsafeOptionError):
+                    rw_repo.clone(tmp_dir, **unsafe_option)
+                assert not tmp_file.exists()
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason=(
+            "File not created. A separate Windows command may be needed. This and the "
+            "currently passing test test_clone_unsafe_options must be adjusted in the "
+            "same way. Until then, test_clone_unsafe_options is unreliable on Windows."
+        ),
+        raises=AssertionError,
+    )
+    @with_rw_repo("HEAD")
+    def test_clone_unsafe_options_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                f"--upload-pack='touch {tmp_file}'",
+                f"-u 'touch {tmp_file}'",
+            ]
+            for i, unsafe_option in enumerate(unsafe_options):
+                destination = tmp_dir / str(i)
+                assert not tmp_file.exists()
+                # The options will be allowed, but the command will fail.
+                with self.assertRaises(GitCommandError):
+                    rw_repo.clone(destination, multi_options=[unsafe_option], allow_unsafe_options=True)
+                assert tmp_file.exists()
+                tmp_file.unlink()
+
+            unsafe_options = [
+                "--config=protocol.ext.allow=always",
+                "-c protocol.ext.allow=always",
+            ]
+            for i, unsafe_option in enumerate(unsafe_options):
+                destination = tmp_dir / str(i)
+                assert not destination.exists()
+                rw_repo.clone(destination, multi_options=[unsafe_option], allow_unsafe_options=True)
+                assert destination.exists()
+
+    @with_rw_repo("HEAD")
+    def test_clone_safe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            options = [
+                "--depth=1",
+                "--single-branch",
+                "-q",
+            ]
+            for option in options:
+                destination = tmp_dir / option
+                assert not destination.exists()
+                rw_repo.clone(destination, multi_options=[option])
+                assert destination.exists()
+
+    @with_rw_repo("HEAD")
+    def test_clone_from_unsafe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                f"--upload-pack='touch {tmp_file}'",
+                f"-u 'touch {tmp_file}'",
+                "--config=protocol.ext.allow=always",
+                "-c protocol.ext.allow=always",
+            ]
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(UnsafeOptionError):
+                    Repo.clone_from(rw_repo.working_dir, tmp_dir, multi_options=[unsafe_option])
+                assert not tmp_file.exists()
+
+            unsafe_options = [
+                {"upload-pack": f"touch {tmp_file}"},
+                {"u": f"touch {tmp_file}"},
+                {"config": "protocol.ext.allow=always"},
+                {"c": "protocol.ext.allow=always"},
+            ]
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(UnsafeOptionError):
+                    Repo.clone_from(rw_repo.working_dir, tmp_dir, **unsafe_option)
+                assert not tmp_file.exists()
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason=(
+            "File not created. A separate Windows command may be needed. This and the "
+            "currently passing test test_clone_from_unsafe_options must be adjusted in the "
+            "same way. Until then, test_clone_from_unsafe_options is unreliable on Windows."
+        ),
+        raises=AssertionError,
+    )
+    @with_rw_repo("HEAD")
+    def test_clone_from_unsafe_options_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                f"--upload-pack='touch {tmp_file}'",
+                f"-u 'touch {tmp_file}'",
+            ]
+            for i, unsafe_option in enumerate(unsafe_options):
+                destination = tmp_dir / str(i)
+                assert not tmp_file.exists()
+                # The options will be allowed, but the command will fail.
+                with self.assertRaises(GitCommandError):
+                    Repo.clone_from(
+                        rw_repo.working_dir, destination, multi_options=[unsafe_option], allow_unsafe_options=True
+                    )
+                assert tmp_file.exists()
+                tmp_file.unlink()
+
+            unsafe_options = [
+                "--config=protocol.ext.allow=always",
+                "-c protocol.ext.allow=always",
+            ]
+            for i, unsafe_option in enumerate(unsafe_options):
+                destination = tmp_dir / str(i)
+                assert not destination.exists()
+                Repo.clone_from(
+                    rw_repo.working_dir, destination, multi_options=[unsafe_option], allow_unsafe_options=True
+                )
+                assert destination.exists()
+
+    @with_rw_repo("HEAD")
+    def test_clone_from_safe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            options = [
+                "--depth=1",
+                "--single-branch",
+                "-q",
+            ]
+            for option in options:
+                destination = tmp_dir / option
+                assert not destination.exists()
+                Repo.clone_from(rw_repo.common_dir, destination, multi_options=[option])
+                assert destination.exists()
+
+    def test_clone_from_unsafe_protocol(self):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::17/foo",
+            ]
+            for url in urls:
+                with self.assertRaises(UnsafeProtocolError):
+                    Repo.clone_from(url, tmp_dir / "repo")
+                assert not tmp_file.exists()
+
+    def test_clone_from_unsafe_protocol_allowed(self):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::/foo",
+            ]
+            for url in urls:
+                # The URL will be allowed into the command, but the command will
+                # fail since we don't have that protocol enabled in the Git config file.
+                with self.assertRaises(GitCommandError):
+                    Repo.clone_from(url, tmp_dir / "repo", allow_unsafe_protocols=True)
+                assert not tmp_file.exists()
+
+    def test_clone_from_unsafe_protocol_allowed_and_enabled(self):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+            ]
+            allow_ext = [
+                "--config=protocol.ext.allow=always",
+            ]
+            for url in urls:
+                # The URL will be allowed into the command, and the protocol is enabled,
+                # but the command will fail since it can't read from the remote repo.
+                assert not tmp_file.exists()
+                with self.assertRaises(GitCommandError):
+                    Repo.clone_from(
+                        url,
+                        tmp_dir / "repo",
+                        multi_options=allow_ext,
+                        allow_unsafe_protocols=True,
+                        allow_unsafe_options=True,
+                    )
+                assert tmp_file.exists()
+                tmp_file.unlink()
+
+    @with_rw_repo("HEAD")
+    def test_max_chunk_size(self, repo):
+        class TestOutputStream(TestBase):
+            def __init__(self, max_chunk_size):
+                self.max_chunk_size = max_chunk_size
+
+            def write(self, b):
+                self.assertTrue(len(b) <= self.max_chunk_size)
+
+        for chunk_size in [16, 128, 1024]:
+            repo.git.status(output_stream=TestOutputStream(chunk_size), max_chunk_size=chunk_size)
+
+        repo.git.log(
+            n=100,
+            output_stream=TestOutputStream(io.DEFAULT_BUFFER_SIZE),
+            max_chunk_size=None,
+        )
+        repo.git.log(
+            n=100,
+            output_stream=TestOutputStream(io.DEFAULT_BUFFER_SIZE),
+            max_chunk_size=-10,
+        )
+        repo.git.log(n=100, output_stream=TestOutputStream(io.DEFAULT_BUFFER_SIZE))
+
+    def test_init(self):
+        with tempfile.TemporaryDirectory() as tdir, cwd(tdir):
+            git_dir_rela = "repos/foo/bar.git"
+            git_dir_abs = osp.abspath(git_dir_rela)
+
+            # With specific path
+            for path in (git_dir_rela, git_dir_abs):
+                r = Repo.init(path=path, bare=True)
+                self.assertIsInstance(r, Repo)
+                assert r.bare is True
+                assert not r.has_separate_working_tree()
+                assert osp.isdir(r.git_dir)
+
+                self._assert_empty_repo(r)
+
+                # Test clone
+                clone_path = path + "_clone"
+                rc = r.clone(clone_path)
+                self._assert_empty_repo(rc)
+
+                try:
+                    rmtree(clone_path)
+                except OSError:
+                    # When relative paths are used, the clone may actually be inside of
+                    # the parent directory.
+                    pass
+                # END exception handling
+
+                # Try again, this time with the absolute version.
+                rc = Repo.clone_from(r.git_dir, clone_path)
+                self._assert_empty_repo(rc)
+
+                rmtree(git_dir_abs)
+                try:
+                    rmtree(clone_path)
+                except OSError:
+                    # When relative paths are used, the clone may actually be inside of
+                    # the parent directory.
+                    pass
+                # END exception handling
+
+            # END for each path
+
+            os.makedirs(git_dir_rela)
+            os.chdir(git_dir_rela)
+            r = Repo.init(bare=False)
+            assert r.bare is False
+            assert not r.has_separate_working_tree()
+
+            self._assert_empty_repo(r)
+
+    def test_bare_property(self):
+        self.rorepo.bare
+
+    def test_daemon_export(self):
+        orig_val = self.rorepo.daemon_export
+        self.rorepo.daemon_export = not orig_val
+        self.assertEqual(self.rorepo.daemon_export, (not orig_val))
+        self.rorepo.daemon_export = orig_val
+        self.assertEqual(self.rorepo.daemon_export, orig_val)
+
+    def test_alternates(self):
+        cur_alternates = self.rorepo.alternates
+        # empty alternates
+        self.rorepo.alternates = []
+        self.assertEqual(self.rorepo.alternates, [])
+        alts = ["other/location", "this/location"]
+        self.rorepo.alternates = alts
+        self.assertEqual(alts, self.rorepo.alternates)
+        self.rorepo.alternates = cur_alternates
+
+    def test_repr(self):
+        assert repr(self.rorepo).startswith("<git.repo.base.Repo ")
+
+    def test_is_dirty_with_bare_repository(self):
+        orig_value = self.rorepo._bare
+        self.rorepo._bare = True
+        self.assertFalse(self.rorepo.is_dirty())
+        self.rorepo._bare = orig_value
+
+    def test_is_dirty(self):
+        self.rorepo._bare = False
+        for index in (0, 1):
+            for working_tree in (0, 1):
+                for untracked_files in (0, 1):
+                    assert self.rorepo.is_dirty(index, working_tree, untracked_files) in (True, False)
+                # END untracked files
+            # END working tree
+        # END index
+        orig_val = self.rorepo._bare
+        self.rorepo._bare = True
+        assert self.rorepo.is_dirty() is False
+        self.rorepo._bare = orig_val
+
+    def test_is_dirty_pathspec(self):
+        self.rorepo._bare = False
+        for index in (0, 1):
+            for working_tree in (0, 1):
+                for untracked_files in (0, 1):
+                    assert self.rorepo.is_dirty(index, working_tree, untracked_files, path=":!foo") in (True, False)
+                # END untracked files
+            # END working tree
+        # END index
+        orig_val = self.rorepo._bare
+        self.rorepo._bare = True
+        assert self.rorepo.is_dirty() is False
+        self.rorepo._bare = orig_val
+
+    @with_rw_repo("HEAD")
+    def test_is_dirty_with_path(self, rwrepo):
+        assert rwrepo.is_dirty(path="git") is False
+
+        with open(osp.join(rwrepo.working_dir, "git", "util.py"), "at") as f:
+            f.write("junk")
+        assert rwrepo.is_dirty(path="git") is True
+        assert rwrepo.is_dirty(path="doc") is False
+
+        rwrepo.git.add(Git.polish_url(osp.join("git", "util.py")))
+        assert rwrepo.is_dirty(index=False, path="git") is False
+        assert rwrepo.is_dirty(path="git") is True
+
+        with open(osp.join(rwrepo.working_dir, "doc", "no-such-file.txt"), "wt") as f:
+            f.write("junk")
+        assert rwrepo.is_dirty(path="doc") is False
+        assert rwrepo.is_dirty(untracked_files=True, path="doc") is True
+
+    def test_head(self):
+        self.assertEqual(self.rorepo.head.reference.object, self.rorepo.active_branch.object)
+
+    def test_index(self):
+        index = self.rorepo.index
+        self.assertIsInstance(index, IndexFile)
+
+    def test_tag(self):
+        assert self.rorepo.tag("refs/tags/0.1.5").commit
+
+    def test_tag_to_full_tag_path(self):
+        tags = ["0.1.5", "tags/0.1.5", "refs/tags/0.1.5"]
+        value_errors = []
+        for tag in tags:
+            try:
+                self.rorepo.tag(tag)
+            except ValueError as valueError:
+                value_errors.append(valueError.args[0])
+        self.assertEqual(value_errors, [])
+
+    def test_archive(self):
+        with tempfile.NamedTemporaryFile("wb", suffix="archive-test", delete=False) as stream:
+            self.rorepo.archive(stream, "0.1.6", path="doc")
+            assert stream.tell()
+        os.remove(stream.name)  # Do it this way so we can inspect the file on failure.
+
+    @mock.patch.object(Git, "_call_process")
+    def test_should_display_blame_information(self, git):
+        git.return_value = fixture("blame")
+        b = self.rorepo.blame("master", "lib/git.py")
+        self.assertEqual(13, len(b))
+        self.assertEqual(2, len(b[0]))
+        # self.assertEqual(25, reduce(lambda acc, x: acc + len(x[-1]), b))
+        self.assertEqual(hash(b[0][0]), hash(b[9][0]))
+        c = b[0][0]
+        self.assertTrue(git.called)
+
+        self.assertEqual("634396b2f541a9f2d58b00be1a07f0c358b999b3", c.hexsha)
+        self.assertEqual("Tom Preston-Werner", c.author.name)
+        self.assertEqual("tom@mojombo.com", c.author.email)
+        self.assertEqual(1191997100, c.authored_date)
+        self.assertEqual("Tom Preston-Werner", c.committer.name)
+        self.assertEqual("tom@mojombo.com", c.committer.email)
+        self.assertEqual(1191997100, c.committed_date)
+        self.assertRaisesRegex(
+            ValueError,
+            "634396b2f541a9f2d58b00be1a07f0c358b999b3 missing",
+            lambda: c.message,
+        )
+
+        # Test the 'lines per commit' entries.
+        tlist = b[0][1]
+        self.assertTrue(tlist)
+        self.assertTrue(isinstance(tlist[0], str))
+        self.assertTrue(len(tlist) < sum(len(t) for t in tlist))  # Test for single-char bug.
+
+        # BINARY BLAME
+        git.return_value = fixture("blame_binary")
+        blames = self.rorepo.blame("master", "rps")
+        self.assertEqual(len(blames), 2)
+
+    def test_blame_real(self):
+        c = 0
+        nml = 0  # Amount of multi-lines per blame.
+        for item in self.rorepo.head.commit.tree.traverse(
+            predicate=lambda i, d: i.type == "blob" and i.path.endswith(".py")
+        ):
+            c += 1
+
+            for b in self.rorepo.blame(self.rorepo.head, item.path):
+                nml += int(len(b[1]) > 1)
+        # END for each item to traverse
+        assert c, "Should have executed at least one blame command"
+        assert nml, "There should at least be one blame commit that contains multiple lines"
+
+    @mock.patch.object(Git, "_call_process")
+    def test_blame_incremental(self, git):
+        # Loop over two fixtures, create a test fixture for 2.11.1+ syntax.
+        for git_fixture in ("blame_incremental", "blame_incremental_2.11.1_plus"):
+            git.return_value = fixture(git_fixture)
+            blame_output = self.rorepo.blame_incremental("9debf6b0aafb6f7781ea9d1383c86939a1aacde3", "AUTHORS")
+            blame_output = list(blame_output)
+            self.assertEqual(len(blame_output), 5)
+
+            # Check all outputted line numbers.
+            ranges = flatten([entry.linenos for entry in blame_output])
+            self.assertEqual(
+                ranges,
+                flatten(
+                    [
+                        range(2, 3),
+                        range(14, 15),
+                        range(1, 2),
+                        range(3, 14),
+                        range(15, 17),
+                    ]
+                ),
+            )
+
+            commits = [entry.commit.hexsha[:7] for entry in blame_output]
+            self.assertEqual(commits, ["82b8902", "82b8902", "c76852d", "c76852d", "c76852d"])
+
+            # Original filenames.
+            self.assertSequenceEqual(
+                [entry.orig_path for entry in blame_output],
+                ["AUTHORS"] * len(blame_output),
+            )
+
+            # Original line numbers.
+            orig_ranges = flatten([entry.orig_linenos for entry in blame_output])
+            self.assertEqual(
+                orig_ranges,
+                flatten(
+                    [
+                        range(2, 3),
+                        range(14, 15),
+                        range(1, 2),
+                        range(2, 13),
+                        range(13, 15),
+                    ]
+                ),
+            )
+
+    @mock.patch.object(Git, "_call_process")
+    def test_blame_complex_revision(self, git):
+        git.return_value = fixture("blame_complex_revision")
+        res = self.rorepo.blame("HEAD~10..HEAD", "README.md")
+        self.assertEqual(len(res), 1)
+        self.assertEqual(len(res[0][1]), 83, "Unexpected amount of parsed blame lines")
+
+    @mock.patch.object(Git, "_call_process")
+    def test_blame_accepts_rev_opts(self, git):
+        expected_args = ["blame", "HEAD", "-M", "-C", "-C", "--", "README.md"]
+        boilerplate_kwargs = {"p": True, "stdout_as_string": False}
+        self.rorepo.blame("HEAD", "README.md", rev_opts=["-M", "-C", "-C"])
+        git.assert_called_once_with(*expected_args, **boilerplate_kwargs)
+
+    @with_rw_repo("HEAD", bare=False)
+    def test_untracked_files(self, rwrepo):
+        for run, repo_add in enumerate((rwrepo.index.add, rwrepo.git.add)):
+            base = rwrepo.working_tree_dir
+            files = (
+                join_path_native(base, "%i_test _myfile" % run),
+                join_path_native(base, "%i_test_other_file" % run),
+                join_path_native(base, "%i__çava verböten" % run),
+                join_path_native(base, "%i_çava-----verböten" % run),
+            )
+
+            num_recently_untracked = 0
+            for fpath in files:
+                with open(fpath, "wb"):
+                    pass
+            untracked_files = rwrepo.untracked_files
+            num_recently_untracked = len(untracked_files)
+
+            # Ensure we have all names - they are relative to the git-dir.
+            num_test_untracked = 0
+            for utfile in untracked_files:
+                num_test_untracked += join_path_native(base, utfile) in files
+            self.assertEqual(len(files), num_test_untracked)
+
+            repo_add(untracked_files)
+            self.assertEqual(len(rwrepo.untracked_files), (num_recently_untracked - len(files)))
+        # END for each run
+
+    def test_config_reader(self):
+        reader = self.rorepo.config_reader()  # All config files.
+        assert reader.read_only
+        reader = self.rorepo.config_reader("repository")  # Single config file.
+        assert reader.read_only
+
+    def test_config_writer(self):
+        for config_level in self.rorepo.config_level:
+            try:
+                with self.rorepo.config_writer(config_level) as writer:
+                    self.assertFalse(writer.read_only)
+            except IOError:
+                # It's okay not to get a writer for some configuration files if we
+                # have no permissions.
+                pass
+
+    def test_config_level_paths(self):
+        for config_level in self.rorepo.config_level:
+            assert self.rorepo._get_config_path(config_level)
+
+    def test_creation_deletion(self):
+        # Just a very quick test to assure it generally works. There are specialized
+        # cases in the test_refs module.
+        head = self.rorepo.create_head("new_head", "HEAD~1")
+        self.rorepo.delete_head(head)
+
+        try:
+            tag = self.rorepo.create_tag("new_tag", "HEAD~2")
+        finally:
+            self.rorepo.delete_tag(tag)
+        with self.rorepo.config_writer():
+            pass
+        try:
+            remote = self.rorepo.create_remote("new_remote", "git@server:repo.git")
+        finally:
+            self.rorepo.delete_remote(remote)
+
+    def test_comparison_and_hash(self):
+        # This is only a preliminary test, more testing done in test_index.
+        self.assertEqual(self.rorepo, self.rorepo)
+        self.assertFalse(self.rorepo != self.rorepo)
+        self.assertEqual(len({self.rorepo, self.rorepo}), 1)
+
+    @with_rw_directory
+    def test_tilde_and_env_vars_in_repo_path(self, rw_dir):
+        with mock.patch.dict(os.environ, {"HOME": rw_dir}):
+            os.environ["HOME"] = rw_dir
+            Repo.init(osp.join("~", "test.git"), bare=True)
+
+        with mock.patch.dict(os.environ, {"FOO": rw_dir}):
+            os.environ["FOO"] = rw_dir
+            Repo.init(osp.join("$FOO", "test.git"), bare=True)
+
+    def test_git_cmd(self):
+        # Test CatFileContentStream, just to be very sure we have no fencepost errors.
+        # The last \n is the terminating newline that it expects.
+        l1 = b"0123456789\n"
+        l2 = b"abcdefghijklmnopqrstxy\n"
+        l3 = b"z\n"
+        d = l1 + l2 + l3 + b"\n"
+
+        l1p = l1[:5]
+
+        # Full size.
+        # Size is without terminating newline.
+        def mkfull():
+            return Git.CatFileContentStream(len(d) - 1, BytesIO(d))
+
+        ts = 5
+
+        def mktiny():
+            return Git.CatFileContentStream(ts, BytesIO(d))
+
+        # readlines no limit
+        s = mkfull()
+        lines = s.readlines()
+        self.assertEqual(len(lines), 3)
+        self.assertTrue(lines[-1].endswith(b"\n"), lines[-1])
+        self.assertEqual(s._stream.tell(), len(d))  # Must have scrubbed to the end.
+
+        # realines line limit
+        s = mkfull()
+        lines = s.readlines(5)
+        self.assertEqual(len(lines), 1)
+
+        # readlines on tiny sections
+        s = mktiny()
+        lines = s.readlines()
+        self.assertEqual(len(lines), 1)
+        self.assertEqual(lines[0], l1p)
+        self.assertEqual(s._stream.tell(), ts + 1)
+
+        # readline no limit
+        s = mkfull()
+        self.assertEqual(s.readline(), l1)
+        self.assertEqual(s.readline(), l2)
+        self.assertEqual(s.readline(), l3)
+        self.assertEqual(s.readline(), b"")
+        self.assertEqual(s._stream.tell(), len(d))
+
+        # readline limit
+        s = mkfull()
+        self.assertEqual(s.readline(5), l1p)
+        self.assertEqual(s.readline(), l1[5:])
+
+        # readline on tiny section
+        s = mktiny()
+        self.assertEqual(s.readline(), l1p)
+        self.assertEqual(s.readline(), b"")
+        self.assertEqual(s._stream.tell(), ts + 1)
+
+        # read no limit
+        s = mkfull()
+        self.assertEqual(s.read(), d[:-1])
+        self.assertEqual(s.read(), b"")
+        self.assertEqual(s._stream.tell(), len(d))
+
+        # read limit
+        s = mkfull()
+        self.assertEqual(s.read(5), l1p)
+        self.assertEqual(s.read(6), l1[5:])
+        self.assertEqual(s._stream.tell(), 5 + 6)  # It's not yet done.
+
+        # read tiny
+        s = mktiny()
+        self.assertEqual(s.read(2), l1[:2])
+        self.assertEqual(s._stream.tell(), 2)
+        self.assertEqual(s.read(), l1[2:ts])
+        self.assertEqual(s._stream.tell(), ts + 1)
+
+    def _assert_rev_parse_types(self, name, rev_obj):
+        rev_parse = self.rorepo.rev_parse
+
+        if rev_obj.type == "tag":
+            rev_obj = rev_obj.object
+
+        # Tree and blob type.
+        obj = rev_parse(name + "^{tree}")
+        self.assertEqual(obj, rev_obj.tree)
+
+        obj = rev_parse(name + ":CHANGES")
+        self.assertEqual(obj.type, "blob")
+        self.assertEqual(obj.path, "CHANGES")
+        self.assertEqual(rev_obj.tree["CHANGES"], obj)
+
+    def _assert_rev_parse(self, name):
+        """tries multiple different rev-parse syntaxes with the given name
+        :return: parsed object"""
+        rev_parse = self.rorepo.rev_parse
+        orig_obj = rev_parse(name)
+        if orig_obj.type == "tag":
+            obj = orig_obj.object
+        else:
+            obj = orig_obj
+        # END deref tags by default
+
+        # Try history
+        rev = name + "~"
+        obj2 = rev_parse(rev)
+        self.assertEqual(obj2, obj.parents[0])
+        self._assert_rev_parse_types(rev, obj2)
+
+        # History with number
+        ni = 11
+        history = [obj.parents[0]]
+        for _ in range(ni):
+            history.append(history[-1].parents[0])
+        # END get given amount of commits
+
+        for pn in range(11):
+            rev = name + "~%i" % (pn + 1)
+            obj2 = rev_parse(rev)
+            self.assertEqual(obj2, history[pn])
+            self._assert_rev_parse_types(rev, obj2)
+        # END history check
+
+        # Parent (default)
+        rev = name + "^"
+        obj2 = rev_parse(rev)
+        self.assertEqual(obj2, obj.parents[0])
+        self._assert_rev_parse_types(rev, obj2)
+
+        # Parent with number
+        for pn, parent in enumerate(obj.parents):
+            rev = name + "^%i" % (pn + 1)
+            self.assertEqual(rev_parse(rev), parent)
+            self._assert_rev_parse_types(rev, parent)
+        # END for each parent
+
+        return orig_obj
+
+    @with_rw_repo("HEAD", bare=False)
+    def test_rw_rev_parse(self, rwrepo):
+        # Verify it does not confuse branches with hexsha ids.
+        ahead = rwrepo.create_head("aaaaaaaa")
+        assert rwrepo.rev_parse(str(ahead)) == ahead.commit
+
+    def test_rev_parse(self):
+        rev_parse = self.rorepo.rev_parse
+
+        # Try special case: This one failed at some point, make sure its fixed.
+        self.assertEqual(rev_parse("33ebe").hexsha, "33ebe7acec14b25c5f84f35a664803fcab2f7781")
+
+        # Start from reference.
+        num_resolved = 0
+
+        for ref_no, ref in enumerate(Reference.iter_items(self.rorepo)):
+            path_tokens = ref.path.split("/")
+            for pt in range(len(path_tokens)):
+                path_section = "/".join(path_tokens[-(pt + 1) :])
+                try:
+                    obj = self._assert_rev_parse(path_section)
+                    self.assertEqual(obj.type, ref.object.type)
+                    num_resolved += 1
+                except (BadName, BadObject):
+                    print("failed on %s" % path_section)
+                    # This is fine if we have something like 112, which belongs to
+                    # remotes/rname/merge-requests/112.
+                # END exception handling
+            # END for each token
+            if ref_no == 3 - 1:
+                break
+        # END for each reference
+        assert num_resolved
+
+        # It works with tags!
+        tag = self._assert_rev_parse("0.1.4")
+        self.assertEqual(tag.type, "tag")
+
+        # try full sha directly (including type conversion).
+        self.assertEqual(tag.object, rev_parse(tag.object.hexsha))
+        self._assert_rev_parse_types(tag.object.hexsha, tag.object)
+
+        # Multiple tree types result in the same tree: HEAD^{tree}^{tree}:CHANGES
+        rev = "0.1.4^{tree}^{tree}"
+        self.assertEqual(rev_parse(rev), tag.object.tree)
+        self.assertEqual(rev_parse(rev + ":CHANGES"), tag.object.tree["CHANGES"])
+
+        # Try to get parents from first revision - it should fail as no such revision
+        # exists.
+        first_rev = "33ebe7acec14b25c5f84f35a664803fcab2f7781"
+        commit = rev_parse(first_rev)
+        self.assertEqual(len(commit.parents), 0)
+        self.assertEqual(commit.hexsha, first_rev)
+        self.assertRaises(BadName, rev_parse, first_rev + "~")
+        self.assertRaises(BadName, rev_parse, first_rev + "^")
+
+        # Short SHA1.
+        commit2 = rev_parse(first_rev[:20])
+        self.assertEqual(commit2, commit)
+        commit2 = rev_parse(first_rev[:5])
+        self.assertEqual(commit2, commit)
+
+        # TODO: Dereference tag into a blob 0.1.7^{blob} - quite a special one.
+        # Needs a tag which points to a blob.
+
+        # ref^0 returns commit being pointed to, same with ref~0, ^{}, and ^{commit}
+        tag = rev_parse("0.1.4")
+        for token in ("~0", "^0", "^{}", "^{commit}"):
+            self.assertEqual(tag.object, rev_parse("0.1.4%s" % token))
+        # END handle multiple tokens
+
+        # Try partial parsing.
+        max_items = 40
+        for i, binsha in enumerate(self.rorepo.odb.sha_iter()):
+            self.assertEqual(
+                rev_parse(bin_to_hex(binsha)[: 8 - (i % 2)].decode("ascii")).binsha,
+                binsha,
+            )
+            if i > max_items:
+                # This is rather slow currently, as rev_parse returns an object that
+                # requires accessing packs, so it has some additional overhead.
+                break
+        # END for each binsha in repo
+
+        # Missing closing brace: commit^{tree
+        self.assertRaises(ValueError, rev_parse, "0.1.4^{tree")
+
+        # Missing starting brace.
+        self.assertRaises(ValueError, rev_parse, "0.1.4^tree}")
+
+        # REVLOG
+        #######
+        head = self.rorepo.head
+
+        # Need to specify a ref when using the @ syntax.
+        self.assertRaises(BadObject, rev_parse, "%s@{0}" % head.commit.hexsha)
+
+        # Uses HEAD.ref by default.
+        self.assertEqual(rev_parse("@{0}"), head.commit)
+        if not head.is_detached:
+            refspec = "%s@{0}" % head.ref.name
+            self.assertEqual(rev_parse(refspec), head.ref.commit)
+            # All additional specs work as well.
+            self.assertEqual(rev_parse(refspec + "^{tree}"), head.commit.tree)
+            self.assertEqual(rev_parse(refspec + ":CHANGES").type, "blob")
+        # END operate on non-detached head
+
+        # Position doesn't exist.
+        self.assertRaises(IndexError, rev_parse, "@{10000}")
+
+        # Currently, nothing more is supported.
+        self.assertRaises(NotImplementedError, rev_parse, "@{1 week ago}")
+
+        # The last position.
+        assert rev_parse("@{1}") != head.commit
+
+    def test_repo_odbtype(self):
+        target_type = GitCmdObjectDB
+        self.assertIsInstance(self.rorepo.odb, target_type)
+
+    @pytest.mark.xfail(
+        sys.platform == "cygwin",
+        reason="Cygwin GitPython can't find submodule SHA",
+        raises=ValueError,
+    )
+    def test_submodules(self):
+        self.assertEqual(len(self.rorepo.submodules), 1)  # non-recursive
+        self.assertGreaterEqual(len(list(self.rorepo.iter_submodules())), 2)
+
+        self.assertIsInstance(self.rorepo.submodule("gitdb"), Submodule)
+        self.assertRaises(ValueError, self.rorepo.submodule, "doesn't exist")
+
+    @with_rw_repo("HEAD", bare=False)
+    def test_submodule_update(self, rwrepo):
+        # Fails in bare mode.
+        rwrepo._bare = True
+        self.assertRaises(InvalidGitRepositoryError, rwrepo.submodule_update)
+        rwrepo._bare = False
+
+        # Test submodule creation.
+        sm = rwrepo.submodules[0]
+        sm = rwrepo.create_submodule(
+            "my_new_sub",
+            "some_path",
+            join_path_native(self.rorepo.working_tree_dir, sm.path),
+        )
+        self.assertIsInstance(sm, Submodule)
+
+        # NOTE: The rest of this functionality is tested in test_submodule.
+
+    @with_rw_repo("HEAD")
+    def test_git_file(self, rwrepo):
+        # Move the .git directory to another location and create the .git file.
+        real_path_abs = osp.abspath(join_path_native(rwrepo.working_tree_dir, ".real"))
+        os.rename(rwrepo.git_dir, real_path_abs)
+        git_file_path = join_path_native(rwrepo.working_tree_dir, ".git")
+        with open(git_file_path, "wb") as fp:
+            fp.write(fixture("git_file"))
+
+        # Create a repo and make sure it's pointing to the relocated .git directory.
+        git_file_repo = Repo(rwrepo.working_tree_dir)
+        self.assertEqual(osp.abspath(git_file_repo.git_dir), real_path_abs)
+
+        # Test using an absolute gitdir path in the .git file.
+        with open(git_file_path, "wb") as fp:
+            fp.write(("gitdir: %s\n" % real_path_abs).encode("ascii"))
+        git_file_repo = Repo(rwrepo.working_tree_dir)
+        self.assertEqual(osp.abspath(git_file_repo.git_dir), real_path_abs)
+
+    def test_file_handle_leaks(self):
+        def last_commit(repo, rev, path):
+            commit = next(repo.iter_commits(rev, path, max_count=1))
+            commit.tree[path]
+
+        # This is based on this comment:
+        # https://github.com/gitpython-developers/GitPython/issues/60#issuecomment-23558741
+        # And we expect to set max handles to a low value, like 64.
+        # You should set ulimit -n X. See .travis.yml.
+        # The loops below would easily create 500 handles if these would leak
+        # (4 pipes + multiple mapped files).
+        for _ in range(64):
+            for repo_type in (GitCmdObjectDB, GitDB):
+                repo = Repo(self.rorepo.working_tree_dir, odbt=repo_type)
+                last_commit(repo, "master", "test/test_base.py")
+            # END for each repository type
+        # END for each iteration
+
+    def test_remote_method(self):
+        self.assertRaises(ValueError, self.rorepo.remote, "foo-blue")
+        self.assertIsInstance(self.rorepo.remote(name="origin"), Remote)
+
+    @with_rw_directory
+    def test_empty_repo(self, rw_dir):
+        """Assure we can handle empty repositories"""
+        r = Repo.init(rw_dir, mkdir=False)
+        # It's ok not to be able to iterate a commit, as there is none.
+        self.assertRaises(ValueError, r.iter_commits)
+        self.assertEqual(r.active_branch.name, "master")
+        assert not r.active_branch.is_valid(), "Branch is yet to be born"
+
+        # Actually, when trying to create a new branch without a commit, git itself
+        # fails. We should, however, not fail ungracefully.
+        self.assertRaises(BadName, r.create_head, "foo")
+        self.assertRaises(BadName, r.create_head, "master")
+        # It's expected to not be able to access a tree
+        self.assertRaises(ValueError, r.tree)
+
+        new_file_path = osp.join(rw_dir, "new_file.ext")
+        touch(new_file_path)
+        r.index.add([new_file_path])
+        r.index.commit("initial commit\nBAD MESSAGE 1\n")
+
+        # Now a branch should be creatable.
+        nb = r.create_head("foo")
+        assert nb.is_valid()
+
+        with open(new_file_path, "w") as f:
+            f.write("Line 1\n")
+
+        r.index.add([new_file_path])
+        r.index.commit("add line 1\nBAD MESSAGE 2\n")
+
+        with open("%s/.git/logs/refs/heads/master" % (rw_dir,), "r") as f:
+            contents = f.read()
+
+        assert "BAD MESSAGE" not in contents, "log is corrupt"
+
+    def test_merge_base(self):
+        repo = self.rorepo
+        c1 = "f6aa8d1"
+        c2 = repo.commit("d46e3fe")
+        c3 = "763ef75"
+        self.assertRaises(ValueError, repo.merge_base)
+        self.assertRaises(ValueError, repo.merge_base, "foo")
+
+        # Two commit merge-base.
+        res = repo.merge_base(c1, c2)
+        self.assertIsInstance(res, list)
+        self.assertEqual(len(res), 1)
+        self.assertIsInstance(res[0], Commit)
+        self.assertTrue(res[0].hexsha.startswith("3936084"))
+
+        for kw in ("a", "all"):
+            res = repo.merge_base(c1, c2, c3, **{kw: True})
+            self.assertIsInstance(res, list)
+            self.assertEqual(len(res), 1)
+        # END for each keyword signalling all merge-bases to be returned
+
+        # Test for no merge base - can't do as we have.
+        self.assertRaises(GitCommandError, repo.merge_base, c1, "ffffff")
+
+    def test_is_ancestor(self):
+        git = self.rorepo.git
+        if git.version_info[:3] < (1, 8, 0):
+            raise RuntimeError("git merge-base --is-ancestor feature unsupported (test needs git 1.8.0 or later)")
+
+        repo = self.rorepo
+        c1 = "f6aa8d1"
+        c2 = "763ef75"
+        self.assertTrue(repo.is_ancestor(c1, c1))
+        self.assertTrue(repo.is_ancestor("master", "master"))
+        self.assertTrue(repo.is_ancestor(c1, c2))
+        self.assertTrue(repo.is_ancestor(c1, "master"))
+        self.assertFalse(repo.is_ancestor(c2, c1))
+        self.assertFalse(repo.is_ancestor("master", c1))
+        for i, j in itertools.permutations([c1, "ffffff", ""], r=2):
+            self.assertRaises(GitCommandError, repo.is_ancestor, i, j)
+
+    def test_is_valid_object(self):
+        repo = self.rorepo
+        commit_sha = "f6aa8d1"
+        blob_sha = "1fbe3e4375"
+        tree_sha = "960b40fe36"
+        tag_sha = "42c2f60c43"
+
+        # Check for valid objects.
+        self.assertTrue(repo.is_valid_object(commit_sha))
+        self.assertTrue(repo.is_valid_object(blob_sha))
+        self.assertTrue(repo.is_valid_object(tree_sha))
+        self.assertTrue(repo.is_valid_object(tag_sha))
+
+        # Check for valid objects of specific type.
+        self.assertTrue(repo.is_valid_object(commit_sha, "commit"))
+        self.assertTrue(repo.is_valid_object(blob_sha, "blob"))
+        self.assertTrue(repo.is_valid_object(tree_sha, "tree"))
+        self.assertTrue(repo.is_valid_object(tag_sha, "tag"))
+
+        # Check for invalid objects.
+        self.assertFalse(repo.is_valid_object(b"1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a", "blob"))
+
+        # Check for invalid objects of specific type.
+        self.assertFalse(repo.is_valid_object(commit_sha, "blob"))
+        self.assertFalse(repo.is_valid_object(blob_sha, "commit"))
+        self.assertFalse(repo.is_valid_object(tree_sha, "commit"))
+        self.assertFalse(repo.is_valid_object(tag_sha, "commit"))
+
+    @with_rw_directory
+    def test_git_work_tree_dotgit(self, rw_dir):
+        """Check that we find .git as a worktree file and find the worktree
+        based on it."""
+        git = Git(rw_dir)
+        if git.version_info[:3] < (2, 5, 1):
+            raise RuntimeError("worktree feature unsupported (test needs git 2.5.1 or later)")
+
+        rw_master = self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
+        branch = rw_master.create_head("aaaaaaaa")
+        worktree_path = join_path_native(rw_dir, "worktree_repo")
+        if Git.is_cygwin():
+            worktree_path = cygpath(worktree_path)
+        rw_master.git.worktree("add", worktree_path, branch.name)
+
+        # This ensures that we can read the repo's gitdir correctly.
+        repo = Repo(worktree_path)
+        self.assertIsInstance(repo, Repo)
+
+        # This ensures we're able to actually read the refs in the tree, which means we
+        # can read commondir correctly.
+        commit = repo.head.commit
+        self.assertIsInstance(commit, Object)
+
+        # This ensures we can read the remotes, which confirms we're reading the config
+        # correctly.
+        origin = repo.remotes.origin
+        self.assertIsInstance(origin, Remote)
+
+        self.assertIsInstance(repo.heads["aaaaaaaa"], Head)
+
+    @with_rw_directory
+    def test_git_work_tree_env(self, rw_dir):
+        """Check that we yield to GIT_WORK_TREE."""
+        # Clone a repo.
+        # Move .git directory to a subdirectory.
+        # Set GIT_DIR and GIT_WORK_TREE appropriately.
+        # Check that: repo.working_tree_dir == rw_dir
+
+        self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
+
+        repo_dir = join_path_native(rw_dir, "master_repo")
+        old_git_dir = join_path_native(repo_dir, ".git")
+        new_subdir = join_path_native(repo_dir, "gitdir")
+        new_git_dir = join_path_native(new_subdir, "git")
+        os.mkdir(new_subdir)
+        os.rename(old_git_dir, new_git_dir)
+
+        to_patch = {"GIT_DIR": new_git_dir, "GIT_WORK_TREE": repo_dir}
+
+        with mock.patch.dict(os.environ, to_patch):
+            r = Repo()
+            self.assertEqual(r.working_tree_dir, repo_dir)
+            self.assertEqual(r.working_dir, repo_dir)
+
+    @with_rw_directory
+    def test_rebasing(self, rw_dir):
+        r = Repo.init(rw_dir)
+        fp = osp.join(rw_dir, "hello.txt")
+        r.git.commit(
+            "--allow-empty",
+            message="init",
+        )
+        with open(fp, "w") as fs:
+            fs.write("hello world")
+        r.git.add(Git.polish_url(fp))
+        r.git.commit(message="English")
+        self.assertEqual(r.currently_rebasing_on(), None)
+        r.git.checkout("HEAD^1")
+        with open(fp, "w") as fs:
+            fs.write("Hola Mundo")
+        r.git.add(Git.polish_url(fp))
+        r.git.commit(message="Spanish")
+        commitSpanish = r.commit()
+        try:
+            r.git.rebase("master")
+        except GitCommandError:
+            pass
+        self.assertEqual(r.currently_rebasing_on(), commitSpanish)
+
+    @with_rw_directory
+    def test_do_not_strip_newline_in_stdout(self, rw_dir):
+        r = Repo.init(rw_dir)
+        fp = osp.join(rw_dir, "hello.txt")
+        with open(fp, "w") as fs:
+            fs.write("hello\n")
+        r.git.add(Git.polish_url(fp))
+        r.git.commit(message="init")
+        self.assertEqual(r.git.show("HEAD:hello.txt", strip_newline_in_stdout=False), "hello\n")
+
+    @pytest.mark.xfail(
+        sys.platform == "win32",
+        reason=R"fatal: could not create leading directories of '--upload-pack=touch C:\Users\ek\AppData\Local\Temp\tmpnantqizc\pwn': Invalid argument",  # noqa: E501
+        raises=GitCommandError,
+    )
+    @with_rw_repo("HEAD")
+    def test_clone_command_injection(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            unexpected_file = tmp_dir / "pwn"
+            assert not unexpected_file.exists()
+
+            payload = f"--upload-pack=touch {unexpected_file}"
+            rw_repo.clone(payload)
+
+            assert not unexpected_file.exists()
+            # A repo was cloned with the payload as name.
+            assert pathlib.Path(payload).exists()
+
+    @with_rw_repo("HEAD")
+    def test_clone_from_command_injection(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            temp_repo = Repo.init(tmp_dir / "repo")
+            unexpected_file = tmp_dir / "pwn"
+
+            assert not unexpected_file.exists()
+            payload = f"--upload-pack=touch {unexpected_file}"
+            with self.assertRaises(GitCommandError):
+                rw_repo.clone_from(payload, temp_repo.common_dir)
+
+            assert not unexpected_file.exists()
+
+    def test_ignored_items_reported(self):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            temp_repo = Repo.init(tmp_dir / "repo")
+
+            gi = tmp_dir / "repo" / ".gitignore"
+
+            with open(gi, "w") as file:
+                file.write("ignored_file.txt\n")
+                file.write("ignored_dir/\n")
+
+            assert temp_repo.ignored(["included_file.txt", "included_dir/file.txt"]) == []
+            assert temp_repo.ignored(["ignored_file.txt"]) == ["ignored_file.txt"]
+            assert temp_repo.ignored(["included_file.txt", "ignored_file.txt"]) == ["ignored_file.txt"]
+            assert temp_repo.ignored(
+                ["included_file.txt", "ignored_file.txt", "included_dir/file.txt", "ignored_dir/file.txt"]
+            ) == ["ignored_file.txt", "ignored_dir/file.txt"]
+
+    def test_ignored_raises_error_w_symlink(self):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = pathlib.Path(tdir)
+            temp_repo = Repo.init(tmp_dir / "repo")
+
+            os.mkdir(tmp_dir / "target")
+            os.symlink(tmp_dir / "target", tmp_dir / "symlink")
+
+            with pytest.raises(GitCommandError):
+                temp_repo.ignored(tmp_dir / "symlink/file.txt")
diff --git a/test/test_stats.py b/test/test_stats.py
new file mode 100644
index 000000000..91d2cf6ae
--- /dev/null
+++ b/test/test_stats.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+from git import Stats
+from git.compat import defenc
+
+from test.lib import TestBase, fixture
+
+
+class TestStats(TestBase):
+    def test_list_from_string(self):
+        output = fixture("diff_numstat").decode(defenc)
+        stats = Stats._list_from_string(self.rorepo, output)
+
+        self.assertEqual(3, stats.total["files"])
+        self.assertEqual(59, stats.total["lines"])
+        self.assertEqual(36, stats.total["insertions"])
+        self.assertEqual(23, stats.total["deletions"])
+
+        self.assertEqual(29, stats.files["a.txt"]["insertions"])
+        self.assertEqual(18, stats.files["a.txt"]["deletions"])
+        self.assertEqual("M", stats.files["a.txt"]["change_type"])
+
+        self.assertEqual(0, stats.files["b.txt"]["insertions"])
+        self.assertEqual(5, stats.files["b.txt"]["deletions"])
+        self.assertEqual("M", stats.files["b.txt"]["change_type"])
+
+        self.assertEqual(7, stats.files["c.txt"]["insertions"])
+        self.assertEqual(0, stats.files["c.txt"]["deletions"])
+        self.assertEqual("A", stats.files["c.txt"]["change_type"])
diff --git a/test/test_submodule.py b/test/test_submodule.py
new file mode 100644
index 000000000..4a248eb60
--- /dev/null
+++ b/test/test_submodule.py
@@ -0,0 +1,1372 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import contextlib
+import gc
+import os
+import os.path as osp
+from pathlib import Path
+import shutil
+import sys
+import tempfile
+from unittest import mock, skipUnless
+
+import pytest
+
+import git
+from git.cmd import Git
+from git.config import GitConfigParser, cp
+from git.exc import (
+    GitCommandError,
+    InvalidGitRepositoryError,
+    RepositoryDirtyError,
+    UnsafeOptionError,
+    UnsafeProtocolError,
+)
+from git.objects.submodule.base import Submodule
+from git.objects.submodule.root import RootModule, RootUpdateProgress
+from git.repo.fun import find_submodule_git_dir, touch
+from git.util import HIDE_WINDOWS_KNOWN_ERRORS, join_path_native, to_native_path_linux
+
+from test.lib import TestBase, with_rw_directory, with_rw_repo
+
+
+@contextlib.contextmanager
+def _patch_git_config(name, value):
+    """Temporarily add a git config name-value pair, using environment variables."""
+    pair_index = int(os.getenv("GIT_CONFIG_COUNT", "0"))
+
+    # This is recomputed each time the context is entered, for compatibility with
+    # existing GIT_CONFIG_* environment variables, even if changed in this process.
+    patcher = mock.patch.dict(
+        os.environ,
+        {
+            "GIT_CONFIG_COUNT": str(pair_index + 1),
+            f"GIT_CONFIG_KEY_{pair_index}": name,
+            f"GIT_CONFIG_VALUE_{pair_index}": value,
+        },
+    )
+
+    with patcher:
+        yield
+
+
+class TestRootProgress(RootUpdateProgress):
+    """Just prints messages, for now without checking the correctness of the states"""
+
+    def update(self, op, cur_count, max_count, message=""):
+        print(op, cur_count, max_count, message)
+
+
+prog = TestRootProgress()
+
+
+class TestSubmodule(TestBase):
+    def tearDown(self):
+        gc.collect()
+
+    k_subm_current = "c15a6e1923a14bc760851913858a3942a4193cdb"
+    k_subm_changed = "394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3"
+    k_no_subm_tag = "0.1.6"
+
+    def _do_base_tests(self, rwrepo):
+        """Perform all tests in the given repository, it may be bare or nonbare"""
+        # Manual instantiation.
+        smm = Submodule(rwrepo, "\0" * 20)
+        # Name needs to be set in advance.
+        self.assertRaises(AttributeError, getattr, smm, "name")
+
+        # Iterate - 1 submodule.
+        sms = Submodule.list_items(rwrepo, self.k_subm_current)
+        assert len(sms) == 1
+        sm = sms[0]
+
+        # At a different time, there is None.
+        assert len(Submodule.list_items(rwrepo, self.k_no_subm_tag)) == 0
+
+        assert sm.path == "git/ext/gitdb"
+        assert sm.path != sm.name  # In our case, we have ids there, which don't equal the path.
+        assert sm.url.endswith("github.com/gitpython-developers/gitdb.git")
+        assert sm.branch_path == "refs/heads/master"  # the default ...
+        assert sm.branch_name == "master"
+        assert sm.parent_commit == rwrepo.head.commit
+        # Size is always 0.
+        assert sm.size == 0
+        # The module is not checked-out yet.
+        self.assertRaises(InvalidGitRepositoryError, sm.module)
+
+        # ...which is why we can't get the branch either - it points into the module()
+        # repository.
+        self.assertRaises(InvalidGitRepositoryError, getattr, sm, "branch")
+
+        # branch_path works, as it's just a string.
+        assert isinstance(sm.branch_path, str)
+
+        # Some commits earlier we still have a submodule, but it's at a different
+        # commit.
+        smold = next(Submodule.iter_items(rwrepo, self.k_subm_changed))
+        assert smold.binsha != sm.binsha
+        assert smold != sm  # the name changed
+
+        # Force it to reread its information.
+        del smold._url
+        smold.url == sm.url  # noqa: B015  # FIXME: Should this be an assertion?
+
+        # Test config_reader/writer methods.
+        sm.config_reader()
+        new_smclone_path = None  # Keep custom paths for later.
+        new_csmclone_path = None  #
+        if rwrepo.bare:
+            with self.assertRaises(InvalidGitRepositoryError):
+                with sm.config_writer() as cw:
+                    pass
+        else:
+            with sm.config_writer() as writer:
+                # For faster checkout, set the url to the local path.
+                new_smclone_path = Git.polish_url(osp.join(self.rorepo.working_tree_dir, sm.path))
+                writer.set_value("url", new_smclone_path)
+                writer.release()
+                assert sm.config_reader().get_value("url") == new_smclone_path
+                assert sm.url == new_smclone_path
+        # END handle bare repo
+        smold.config_reader()
+
+        # Cannot get a writer on historical submodules.
+        if not rwrepo.bare:
+            with self.assertRaises(ValueError):
+                with smold.config_writer():
+                    pass
+        # END handle bare repo
+
+        # Make the old into a new - this doesn't work as the name changed.
+        self.assertRaises(ValueError, smold.set_parent_commit, self.k_subm_current)
+        # the sha is properly updated
+        smold.set_parent_commit(self.k_subm_changed + "~1")
+        assert smold.binsha != sm.binsha
+
+        # Raises if the sm didn't exist in new parent - it keeps its parent_commit
+        # unchanged.
+        self.assertRaises(ValueError, smold.set_parent_commit, self.k_no_subm_tag)
+
+        # TODO: Test that, if a path is in the .gitmodules file, but not in the index,
+        # then it raises.
+
+        # TEST UPDATE
+        ##############
+        # Module retrieval is not always possible.
+        if rwrepo.bare:
+            self.assertRaises(InvalidGitRepositoryError, sm.module)
+            self.assertRaises(InvalidGitRepositoryError, sm.remove)
+            self.assertRaises(InvalidGitRepositoryError, sm.add, rwrepo, "here", "there")
+        else:
+            # It's not checked out in our case.
+            self.assertRaises(InvalidGitRepositoryError, sm.module)
+            assert not sm.module_exists()
+
+            # Currently there is only one submodule.
+            assert len(list(rwrepo.iter_submodules())) == 1
+            assert sm.binsha != "\0" * 20
+
+            # TEST ADD
+            ###########
+            # Preliminary tests.
+            # Adding existing returns exactly the existing.
+            sma = Submodule.add(rwrepo, sm.name, sm.path)
+            assert sma.path == sm.path
+
+            # No url and no module at path fails.
+            self.assertRaises(ValueError, Submodule.add, rwrepo, "newsubm", "pathtorepo", url=None)
+
+            # CONTINUE UPDATE
+            #################
+
+            # Let's update it - it's a recursive one too.
+            newdir = osp.join(sm.abspath, "dir")
+            os.makedirs(newdir)
+
+            # Update fails if the path already exists non-empty.
+            self.assertRaises(OSError, sm.update)
+            os.rmdir(newdir)
+
+            # Dry-run does nothing.
+            sm.update(dry_run=True, progress=prog)
+            assert not sm.module_exists()
+
+            assert sm.update() is sm
+            sm_repopath = sm.path  # Cache for later.
+            assert sm.module_exists()
+            assert isinstance(sm.module(), git.Repo)
+            assert sm.module().working_tree_dir == sm.abspath
+
+            # INTERLEAVE ADD TEST
+            #####################
+            # url must match the one in the existing repository (if submodule name
+            # suggests a new one) or we raise.
+            self.assertRaises(
+                ValueError,
+                Submodule.add,
+                rwrepo,
+                "newsubm",
+                sm.path,
+                "git://someurl/repo.git",
+            )
+
+            # CONTINUE UPDATE
+            #################
+            # We should have setup a tracking branch, which is also active.
+            assert sm.module().head.ref.tracking_branch() is not None
+
+            # Delete the whole directory and re-initialize.
+            assert len(sm.children()) != 0
+            # shutil.rmtree(sm.abspath)
+            sm.remove(force=True, configuration=False)
+            assert len(sm.children()) == 0
+            # Dry-run does nothing.
+            sm.update(dry_run=True, recursive=False, progress=prog)
+            assert len(sm.children()) == 0
+
+            sm.update(recursive=False)
+            assert len(list(rwrepo.iter_submodules())) == 2
+            assert len(sm.children()) == 1  # It's not checked out yet.
+            csm = sm.children()[0]
+            assert not csm.module_exists()
+            csm_repopath = csm.path
+
+            # Adjust the path of the submodules module to point to the local
+            # destination.
+            new_csmclone_path = Git.polish_url(osp.join(self.rorepo.working_tree_dir, sm.path, csm.path))
+            with csm.config_writer() as writer:
+                writer.set_value("url", new_csmclone_path)
+            assert csm.url == new_csmclone_path
+
+            # Dry-run does nothing.
+            assert not csm.module_exists()
+            sm.update(recursive=True, dry_run=True, progress=prog)
+            assert not csm.module_exists()
+
+            # Update recursively again.
+            sm.update(recursive=True)
+            assert csm.module_exists()
+
+            # Tracking branch once again.
+            assert csm.module().head.ref.tracking_branch() is not None
+
+            # This flushed in a sub-submodule.
+            assert len(list(rwrepo.iter_submodules())) == 2
+
+            # Reset both heads to the previous version, verify that to_latest_revision
+            # works.
+            smods = (sm.module(), csm.module())
+            for repo in smods:
+                repo.head.reset("HEAD~2", working_tree=1)
+            # END for each repo to reset
+
+            # Dry-run does nothing.
+            self.assertRaises(
+                RepositoryDirtyError,
+                sm.update,
+                recursive=True,
+                dry_run=True,
+                progress=prog,
+            )
+            sm.update(recursive=True, dry_run=True, progress=prog, force=True)
+            for repo in smods:
+                assert repo.head.commit != repo.head.ref.tracking_branch().commit
+            # END for each repo to check
+
+            self.assertRaises(RepositoryDirtyError, sm.update, recursive=True, to_latest_revision=True)
+            sm.update(recursive=True, to_latest_revision=True, force=True)
+            for repo in smods:
+                assert repo.head.commit == repo.head.ref.tracking_branch().commit
+            # END for each repo to check
+            del smods
+
+            # If the head is detached, it still works (but warns).
+            smref = sm.module().head.ref
+            sm.module().head.ref = "HEAD~1"
+            # If there is no tracking branch, we get a warning as well.
+            csm_tracking_branch = csm.module().head.ref.tracking_branch()
+            csm.module().head.ref.set_tracking_branch(None)
+            sm.update(recursive=True, to_latest_revision=True)
+
+            # to_latest_revision changes the child submodule's commit, it needs an
+            # update now.
+            csm.set_parent_commit(csm.repo.head.commit)
+
+            # Undo the changes.
+            sm.module().head.ref = smref
+            csm.module().head.ref.set_tracking_branch(csm_tracking_branch)
+
+            # REMOVAL OF REPOSITORY
+            #######################
+            # Must delete something.
+            self.assertRaises(ValueError, csm.remove, module=False, configuration=False)
+
+            # module() is supposed to point to gitdb, which has a child-submodule whose
+            # URL is still pointing to GitHub. To save time, we will change it to:
+            csm.set_parent_commit(csm.repo.head.commit)
+            with csm.config_writer() as cw:
+                cw.set_value("url", self._small_repo_url())
+            csm.repo.index.commit("adjusted URL to point to local source, instead of the internet")
+
+            # We have modified the configuration, hence the index is dirty, and the
+            # deletion will fail.
+            # NOTE: As we did a few updates in the meanwhile, the indices were reset.
+            # Hence we create some changes.
+            csm.set_parent_commit(csm.repo.head.commit)
+            with sm.config_writer() as writer:
+                writer.set_value("somekey", "somevalue")
+            with csm.config_writer() as writer:
+                writer.set_value("okey", "ovalue")
+            self.assertRaises(InvalidGitRepositoryError, sm.remove)
+            # If we remove the dirty index, it would work.
+            sm.module().index.reset()
+            # Still, we have the file modified.
+            self.assertRaises(InvalidGitRepositoryError, sm.remove, dry_run=True)
+            sm.module().index.reset(working_tree=True)
+
+            # Enforce the submodule to be checked out at the right spot as well.
+            csm.update()
+            assert csm.module_exists()
+            assert csm.exists()
+            assert osp.isdir(csm.module().working_tree_dir)
+
+            # This would work.
+            assert sm.remove(force=True, dry_run=True) is sm
+            assert sm.module_exists()
+            sm.remove(force=True, dry_run=True)
+            assert sm.module_exists()
+
+            # But... we have untracked files in the child submodule.
+            fn = join_path_native(csm.module().working_tree_dir, "newfile")
+            with open(fn, "w") as fd:
+                fd.write("hi")
+            self.assertRaises(InvalidGitRepositoryError, sm.remove)
+
+            # Forcibly delete the child repository.
+            prev_count = len(sm.children())
+            self.assertRaises(ValueError, csm.remove, force=True)
+            # We removed sm, which removed all submodules. However, the instance we
+            # have still points to the commit prior to that, where it still existed.
+            csm.set_parent_commit(csm.repo.commit(), check=False)
+            assert not csm.exists()
+            assert not csm.module_exists()
+            assert len(sm.children()) == prev_count
+            # Now we have a changed index, as configuration was altered.
+            # Fix this.
+            sm.module().index.reset(working_tree=True)
+
+            # Now delete only the module of the main submodule.
+            assert sm.module_exists()
+            sm.remove(configuration=False, force=True)
+            assert sm.exists()
+            assert not sm.module_exists()
+            assert sm.config_reader().get_value("url")
+
+            # Delete the rest.
+            sm_path = sm.path
+            sm.remove()
+            assert not sm.exists()
+            assert not sm.module_exists()
+            self.assertRaises(ValueError, getattr, sm, "path")
+
+            assert len(rwrepo.submodules) == 0
+
+            # ADD NEW SUBMODULE
+            ###################
+            # Add a simple remote repo - trailing slashes are no problem.
+            smid = "newsub"
+            osmid = "othersub"
+            nsm = Submodule.add(
+                rwrepo,
+                smid,
+                sm_repopath,
+                new_smclone_path + "/",
+                None,
+                no_checkout=True,
+            )
+            assert nsm.name == smid
+            assert nsm.module_exists()
+            assert nsm.exists()
+            # It's not checked out.
+            assert not osp.isfile(join_path_native(nsm.module().working_tree_dir, Submodule.k_modules_file))
+            assert len(rwrepo.submodules) == 1
+
+            # Add another submodule, but into the root, not as submodule.
+            osm = Submodule.add(rwrepo, osmid, csm_repopath, new_csmclone_path, Submodule.k_head_default)
+            assert osm != nsm
+            assert osm.module_exists()
+            assert osm.exists()
+            assert osp.isfile(join_path_native(osm.module().working_tree_dir, "setup.py"))
+
+            assert len(rwrepo.submodules) == 2
+
+            # Commit the changes, just to finalize the operation.
+            rwrepo.index.commit("my submod commit")
+            assert len(rwrepo.submodules) == 2
+
+            # Needs update, as the head changed.
+            # It thinks it's in the history of the repo otherwise.
+            nsm.set_parent_commit(rwrepo.head.commit)
+            osm.set_parent_commit(rwrepo.head.commit)
+
+            # MOVE MODULE
+            #############
+            # Invalid input.
+            self.assertRaises(ValueError, nsm.move, "doesntmatter", module=False, configuration=False)
+
+            # Renaming to the same path does nothing.
+            assert nsm.move(sm_path) is nsm
+
+            # Rename a module.
+            nmp = join_path_native("new", "module", "dir") + "/"  # New module path.
+            pmp = nsm.path
+            assert nsm.move(nmp) is nsm
+            nmp = nmp[:-1]  # Cut last /
+            nmpl = to_native_path_linux(nmp)
+            assert nsm.path == nmpl
+            assert rwrepo.submodules[0].path == nmpl
+
+            mpath = "newsubmodule"
+            absmpath = join_path_native(rwrepo.working_tree_dir, mpath)
+            open(absmpath, "w").write("")
+            self.assertRaises(ValueError, nsm.move, mpath)
+            os.remove(absmpath)
+
+            # Now it works, as we just move it back.
+            nsm.move(pmp)
+            assert nsm.path == pmp
+            assert rwrepo.submodules[0].path == pmp
+
+            # REMOVE 'EM ALL
+            ################
+            # If a submodule's repo has no remotes, it can't be added without an
+            # explicit url.
+            osmod = osm.module()
+
+            osm.remove(module=False)
+            for remote in osmod.remotes:
+                remote.remove(osmod, remote.name)
+            assert not osm.exists()
+            self.assertRaises(ValueError, Submodule.add, rwrepo, osmid, csm_repopath, url=None)
+        # END handle bare mode
+
+        # Error if there is no submodule file here.
+        self.assertRaises(
+            IOError,
+            Submodule._config_parser,
+            rwrepo,
+            rwrepo.commit(self.k_no_subm_tag),
+            True,
+        )
+
+    # ACTUALLY skipped by git.util.rmtree (in local onerror function), called via
+    # git.objects.submodule.base.Submodule.remove at "method(mp)", line 1011.
+    #
+    # @skipIf(HIDE_WINDOWS_KNOWN_ERRORS,
+    #         "FIXME: fails with: PermissionError: [WinError 32] The process cannot access the file because"
+    #         "it is being used by another process: "
+    #         "'C:\\Users\\ankostis\\AppData\\Local\\Temp\\tmp95c3z83bnon_bare_test_base_rw\\git\\ext\\gitdb\\gitdb\\ext\\smmap'")  # noqa: E501
+    @with_rw_repo(k_subm_current)
+    def test_base_rw(self, rwrepo):
+        self._do_base_tests(rwrepo)
+
+    @with_rw_repo(k_subm_current, bare=True)
+    def test_base_bare(self, rwrepo):
+        self._do_base_tests(rwrepo)
+
+    @pytest.mark.xfail(
+        sys.platform == "cygwin",
+        reason="Cygwin GitPython can't find submodule SHA",
+        raises=ValueError,
+    )
+    @pytest.mark.xfail(
+        HIDE_WINDOWS_KNOWN_ERRORS,
+        reason=(
+            '"The process cannot access the file because it is being used by another process"'
+            + " on first call to rm.update"
+        ),
+        raises=PermissionError,
+    )
+    @with_rw_repo(k_subm_current, bare=False)
+    def test_root_module(self, rwrepo):
+        # Can query everything without problems.
+        rm = RootModule(self.rorepo)
+        assert rm.module() is self.rorepo
+
+        # Try attributes.
+        rm.binsha
+        rm.mode
+        rm.path
+        assert rm.name == rm.k_root_name
+        assert rm.parent_commit == self.rorepo.head.commit
+        rm.url
+        rm.branch
+
+        assert len(rm.list_items(rm.module())) == 1
+        rm.config_reader()
+        with rm.config_writer():
+            pass
+
+        # Deep traversal gitdb / async.
+        rsmsp = [sm.path for sm in rm.traverse()]
+        assert len(rsmsp) >= 2  # gitdb and async [and smmap], async being a child of gitdb.
+
+        # Cannot set the parent commit as root module's path didn't exist.
+        self.assertRaises(ValueError, rm.set_parent_commit, "HEAD")
+
+        # TEST UPDATE
+        #############
+        # Set up a commit that removes existing, adds new and modifies existing
+        # submodules.
+        rm = RootModule(rwrepo)
+        assert len(rm.children()) == 1
+
+        # Modify path without modifying the index entry.
+        # (Which is what the move method would do properly.)
+        # ==================================================
+        sm = rm.children()[0]
+        pp = "path/prefix"
+        fp = join_path_native(pp, sm.path)
+        prep = sm.path
+        assert not sm.module_exists()  # It was never updated after rwrepo's clone.
+
+        # Ensure we clone from a local source.
+        with sm.config_writer() as writer:
+            writer.set_value("url", Git.polish_url(osp.join(self.rorepo.working_tree_dir, sm.path)))
+
+        # Dry-run does nothing.
+        sm.update(recursive=False, dry_run=True, progress=prog)
+        assert not sm.module_exists()
+
+        sm.update(recursive=False)
+        assert sm.module_exists()
+        with sm.config_writer() as writer:
+            # Change path to something with prefix AFTER url change.
+            writer.set_value("path", fp)
+
+        # Update doesn't fail, because list_items ignores the wrong path in such
+        # situations.
+        rm.update(recursive=False)
+
+        # Move it properly - doesn't work as it its path currently points to an
+        # indexentry which doesn't exist (move it to some path, it doesn't matter here).
+        self.assertRaises(InvalidGitRepositoryError, sm.move, pp)
+        # Reset the path(cache) to where it was, now it works.
+        sm.path = prep
+        sm.move(fp, module=False)  # Leave it at the old location.
+
+        assert not sm.module_exists()
+        cpathchange = rwrepo.index.commit("changed sm path")  # Finally we can commit.
+
+        # Update puts the module into place.
+        rm.update(recursive=False, progress=prog)
+        sm.set_parent_commit(cpathchange)
+        assert sm.module_exists()
+
+        # Add submodule.
+        # ==============
+        nsmn = "newsubmodule"
+        nsmp = "submrepo"
+        subrepo_url = Git.polish_url(osp.join(self.rorepo.working_tree_dir, rsmsp[0], rsmsp[1]))
+        nsm = Submodule.add(rwrepo, nsmn, nsmp, url=subrepo_url)
+        csmadded = rwrepo.index.commit("Added submodule").hexsha  # Make sure we don't keep the repo reference.
+        nsm.set_parent_commit(csmadded)
+        assert nsm.module_exists()
+        # In our case, the module should not exist, which happens if we update a parent
+        # repo and a new submodule comes into life.
+        nsm.remove(configuration=False, module=True)
+        assert not nsm.module_exists() and nsm.exists()
+
+        # Dry-run does nothing.
+        rm.update(recursive=False, dry_run=True, progress=prog)
+
+        # Otherwise it will work.
+        rm.update(recursive=False, progress=prog)
+        assert nsm.module_exists()
+
+        # Remove submodule - the previous one.
+        # ====================================
+        sm.set_parent_commit(csmadded)
+        smp = sm.abspath
+        assert not sm.remove(module=False).exists()
+        assert osp.isdir(smp)  # Module still exists.
+        csmremoved = rwrepo.index.commit("Removed submodule")
+
+        # An update will remove the module.
+        # Not in dry_run.
+        rm.update(recursive=False, dry_run=True, force_remove=True)
+        assert osp.isdir(smp)
+
+        # When removing submodules, we may get new commits as nested submodules are
+        # auto-committing changes to allow deletions without force, as the index would
+        # be dirty otherwise.
+        # QUESTION: Why does this seem to work in test_git_submodule_compatibility() ?
+        self.assertRaises(InvalidGitRepositoryError, rm.update, recursive=False, force_remove=False)
+        rm.update(recursive=False, force_remove=True)
+        assert not osp.isdir(smp)
+
+        # 'Apply work' to the nested submodule and ensure this is not removed/altered
+        # during updates. We need to commit first, otherwise submodule.update wouldn't
+        # have a reason to change the head.
+        touch(osp.join(nsm.module().working_tree_dir, "new-file"))
+        # We cannot expect is_dirty to even run as we wouldn't reset a head to the same
+        # location.
+        assert nsm.module().head.commit.hexsha == nsm.hexsha
+        nsm.module().index.add([nsm])
+        nsm.module().index.commit("added new file")
+        rm.update(recursive=False, dry_run=True, progress=prog)  # Would not change head, and thus doesn't fail.
+        # Everything we can do from now on will trigger the 'future' check, so no
+        # is_dirty() check will even run. This would only run if our local branch is in
+        # the past and we have uncommitted changes.
+
+        prev_commit = nsm.module().head.commit
+        rm.update(recursive=False, dry_run=False, progress=prog)
+        assert prev_commit == nsm.module().head.commit, "head shouldn't change, as it is in future of remote branch"
+
+        # this kills the new file
+        rm.update(recursive=True, progress=prog, force_reset=True)
+        assert prev_commit != nsm.module().head.commit, "head changed, as the remote url and its commit changed"
+
+        # Change url...
+        # =============
+        # ...to the first repository. This way we have a fast checkout, and a completely
+        # different repository at the different url.
+        nsm.set_parent_commit(csmremoved)
+        nsmurl = Git.polish_url(osp.join(self.rorepo.working_tree_dir, rsmsp[0]))
+        with nsm.config_writer() as writer:
+            writer.set_value("url", nsmurl)
+        csmpathchange = rwrepo.index.commit("changed url")
+        nsm.set_parent_commit(csmpathchange)
+
+        # Now nsm head is in the future of the tracked remote branch.
+        prev_commit = nsm.module().head.commit
+        # dry-run does nothing
+        rm.update(recursive=False, dry_run=True, progress=prog)
+        assert nsm.module().remotes.origin.url != nsmurl
+
+        rm.update(recursive=False, progress=prog, force_reset=True)
+        assert nsm.module().remotes.origin.url == nsmurl
+        assert prev_commit != nsm.module().head.commit, "Should now point to gitdb"
+        assert len(rwrepo.submodules) == 1
+        assert not rwrepo.submodules[0].children()[0].module_exists(), "nested submodule should not be checked out"
+
+        # Add the submodule's changed commit to the index, which is what the user would
+        # do. Beforehand, update our instance's binsha with the new one.
+        nsm.binsha = nsm.module().head.commit.binsha
+        rwrepo.index.add([nsm])
+
+        # Change branch.
+        # ==============
+        # We only have one branch, so we switch to a virtual one, and back to the
+        # current one to trigger the difference.
+        cur_branch = nsm.branch
+        nsmm = nsm.module()
+        prev_commit = nsmm.head.commit
+        for branch in ("some_virtual_branch", cur_branch.name):
+            with nsm.config_writer() as writer:
+                writer.set_value(Submodule.k_head_option, git.Head.to_full_path(branch))
+            csmbranchchange = rwrepo.index.commit("changed branch to %s" % branch)
+            nsm.set_parent_commit(csmbranchchange)
+        # END for each branch to change
+
+        # Let's remove our tracking branch to simulate some changes.
+        nsmmh = nsmm.head
+        assert nsmmh.ref.tracking_branch() is None  # Never set it up until now.
+        assert not nsmmh.is_detached
+
+        # Dry-run does nothing.
+        rm.update(recursive=False, dry_run=True, progress=prog)
+        assert nsmmh.ref.tracking_branch() is None
+
+        # The real thing does.
+        rm.update(recursive=False, progress=prog)
+
+        assert nsmmh.ref.tracking_branch() is not None
+        assert not nsmmh.is_detached
+
+        # Recursive update.
+        # =================
+        # Finally we recursively update a module, just to run the code at least once
+        # remove the module so that it has more work.
+        assert len(nsm.children()) >= 1  # Could include smmap.
+        assert nsm.exists() and nsm.module_exists() and len(nsm.children()) >= 1
+        # Ensure we pull locally only.
+        nsmc = nsm.children()[0]
+        with nsmc.config_writer() as writer:
+            writer.set_value("url", subrepo_url)
+        rm.update(recursive=True, progress=prog, dry_run=True)  # Just to run the code.
+        rm.update(recursive=True, progress=prog)
+
+        # gitdb: has either 1 or 2 submodules depending on the version.
+        assert len(nsm.children()) >= 1 and nsmc.module_exists()
+
+    def test_iter_items_from_nonexistent_hash(self):
+        it = Submodule.iter_items(self.rorepo, "b4ecbfaa90c8be6ed6d9fb4e57cc824663ae15b4")
+        with self.assertRaisesRegex(ValueError, r"\bcould not be resolved\b"):
+            next(it)
+
+    def test_iter_items_from_invalid_hash(self):
+        """Check legacy behavaior on BadName (also applies to IOError, i.e. OSError)."""
+        it = Submodule.iter_items(self.rorepo, "xyz")
+        with self.assertRaises(StopIteration) as ctx:
+            next(it)
+        self.assertIsNone(ctx.exception.value)
+
+    @with_rw_repo(k_no_subm_tag, bare=False)
+    def test_first_submodule(self, rwrepo):
+        assert len(list(rwrepo.iter_submodules())) == 0
+
+        for sm_name, sm_path in (
+            ("first", "submodules/first"),
+            ("second", osp.join(rwrepo.working_tree_dir, "submodules/second")),
+        ):
+            sm = rwrepo.create_submodule(sm_name, sm_path, rwrepo.git_dir, no_checkout=True)
+            assert sm.exists() and sm.module_exists()
+            rwrepo.index.commit("Added submodule " + sm_name)
+        # END for each submodule path to add
+
+        self.assertRaises(ValueError, rwrepo.create_submodule, "fail", osp.expanduser("~"))
+        self.assertRaises(
+            ValueError,
+            rwrepo.create_submodule,
+            "fail-too",
+            rwrepo.working_tree_dir + osp.sep,
+        )
+
+    @with_rw_directory
+    def test_add_empty_repo(self, rwdir):
+        empty_repo_dir = osp.join(rwdir, "empty-repo")
+
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        git.Repo.init(empty_repo_dir)
+
+        for checkout_mode in range(2):
+            name = "empty" + str(checkout_mode)
+            self.assertRaises(
+                ValueError,
+                parent.create_submodule,
+                name,
+                name,
+                url=empty_repo_dir,
+                no_checkout=checkout_mode and True or False,
+            )
+        # END for each checkout mode
+
+    @with_rw_directory
+    @_patch_git_config("protocol.file.allow", "always")
+    def test_update_submodule_with_relative_path(self, rwdir):
+        repo_path = osp.join(rwdir, "parent")
+        repo = git.Repo.init(repo_path)
+        module_repo_path = osp.join(rwdir, "module")
+        module_repo = git.Repo.init(module_repo_path)
+        module_repo.git.commit(m="test", allow_empty=True)
+        repo.git.submodule("add", "../module", "module")
+        repo.index.commit("add submodule")
+
+        cloned_repo_path = osp.join(rwdir, "cloned_repo")
+        cloned_repo = git.Repo.clone_from(repo_path, cloned_repo_path)
+
+        cloned_repo.submodule_update(init=True, recursive=True)
+
+    @with_rw_directory
+    @_patch_git_config("protocol.file.allow", "always")
+    def test_list_only_valid_submodules(self, rwdir):
+        repo_path = osp.join(rwdir, "parent")
+        repo = git.Repo.init(repo_path)
+        repo.git.submodule("add", self._small_repo_url(), "module")
+        repo.index.commit("add submodule")
+
+        assert len(repo.submodules) == 1
+
+        # Delete the directory from submodule.
+        submodule_path = osp.join(repo_path, "module")
+        shutil.rmtree(submodule_path)
+        repo.git.add([submodule_path])
+        repo.index.commit("remove submodule")
+
+        repo = git.Repo(repo_path)
+        assert len(repo.submodules) == 0
+
+    @pytest.mark.xfail(
+        HIDE_WINDOWS_KNOWN_ERRORS,
+        reason=(
+            '"The process cannot access the file because it is being used by another process"'
+            + " on first call to sm.move"
+        ),
+        raises=PermissionError,
+    )
+    @with_rw_directory
+    @_patch_git_config("protocol.file.allow", "always")
+    def test_git_submodules_and_add_sm_with_new_commit(self, rwdir):
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        parent.git.submodule("add", self._small_repo_url(), "module")
+        parent.index.commit("added submodule")
+
+        assert len(parent.submodules) == 1
+        sm = parent.submodules[0]
+
+        assert sm.exists() and sm.module_exists()
+
+        clone = git.Repo.clone_from(
+            self._small_repo_url(),
+            osp.join(parent.working_tree_dir, "existing-subrepository"),
+        )
+        sm2 = parent.create_submodule("nongit-file-submodule", clone.working_tree_dir)
+        assert len(parent.submodules) == 2
+
+        for _ in range(2):
+            for init in (False, True):
+                sm.update(init=init)
+                sm2.update(init=init)
+            # END for each init state
+        # END for each iteration
+
+        sm.move(sm.path + "_moved")
+        sm2.move(sm2.path + "_moved")
+
+        parent.index.commit("moved submodules")
+
+        with sm.config_writer() as writer:
+            writer.set_value("user.email", "example@example.com")
+            writer.set_value("user.name", "me")
+        smm = sm.module()
+        fp = osp.join(smm.working_tree_dir, "empty-file")
+        with open(fp, "w"):
+            pass
+        smm.git.add(Git.polish_url(fp))
+        smm.git.commit(m="new file added")
+
+        # Submodules are retrieved from the current commit's tree, therefore we can't
+        # really get a new submodule object pointing to the new submodule commit.
+        sm_too = parent.submodules["module_moved"]
+        assert parent.head.commit.tree[sm.path].binsha == sm.binsha
+        assert sm_too.binsha == sm.binsha, "cached submodule should point to the same commit as updated one"
+
+        added_bies = parent.index.add([sm])  # Added base-index-entries.
+        assert len(added_bies) == 1
+        parent.index.commit("add same submodule entry")
+        commit_sm = parent.head.commit.tree[sm.path]
+        assert commit_sm.binsha == added_bies[0].binsha
+        assert commit_sm.binsha == sm.binsha
+
+        sm_too.binsha = sm_too.module().head.commit.binsha
+        added_bies = parent.index.add([sm_too])
+        assert len(added_bies) == 1
+        parent.index.commit("add new submodule entry")
+        commit_sm = parent.head.commit.tree[sm.path]
+        assert commit_sm.binsha == added_bies[0].binsha
+        assert commit_sm.binsha == sm_too.binsha
+        assert sm_too.binsha != sm.binsha
+
+    @pytest.mark.xfail(
+        HIDE_WINDOWS_KNOWN_ERRORS,
+        reason='"The process cannot access the file because it is being used by another process" on call to sm.move',
+        raises=PermissionError,
+    )
+    @with_rw_directory
+    def test_git_submodule_compatibility(self, rwdir):
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        sm_path = join_path_native("submodules", "intermediate", "one")
+        sm = parent.create_submodule("mymodules/myname", sm_path, url=self._small_repo_url())
+        parent.index.commit("added submodule")
+
+        def assert_exists(sm, value=True):
+            assert sm.exists() == value
+            assert sm.module_exists() == value
+
+        # END assert_exists
+
+        # As git is backwards compatible itself, it would still recognize what we do
+        # here... unless we really muss it up. That's the only reason why the test is
+        # still here...
+        assert len(parent.git.submodule().splitlines()) == 1
+
+        module_repo_path = osp.join(sm.module().working_tree_dir, ".git")
+        assert module_repo_path.startswith(osp.join(parent.working_tree_dir, sm_path))
+        if not sm._need_gitfile_submodules(parent.git):
+            assert osp.isdir(module_repo_path)
+            assert not sm.module().has_separate_working_tree()
+        else:
+            assert osp.isfile(module_repo_path)
+            assert sm.module().has_separate_working_tree()
+            assert find_submodule_git_dir(module_repo_path) is not None, "module pointed to by .git file must be valid"
+        # END verify submodule 'style'
+
+        # Test move.
+        new_sm_path = join_path_native("submodules", "one")
+        sm.move(new_sm_path)
+        assert_exists(sm)
+
+        # Add additional submodule level.
+        csm = sm.module().create_submodule(
+            "nested-submodule",
+            join_path_native("nested-submodule", "working-tree"),
+            url=self._small_repo_url(),
+        )
+        sm.module().index.commit("added nested submodule")
+        sm_head_commit = sm.module().commit()
+        assert_exists(csm)
+
+        # Fails because there are new commits, compared to the remote we cloned from.
+        self.assertRaises(InvalidGitRepositoryError, sm.remove, dry_run=True)
+        assert_exists(sm)
+        assert sm.module().commit() == sm_head_commit
+        assert_exists(csm)
+
+        # Rename nested submodule.
+        # This name would move itself one level deeper - needs special handling
+        # internally.
+        new_name = csm.name + "/mine"
+        assert csm.rename(new_name).name == new_name
+        assert_exists(csm)
+        assert csm.repo.is_dirty(index=True, working_tree=False), "index must contain changed .gitmodules file"
+        csm.repo.index.commit("renamed module")
+
+        # keep_going evaluation.
+        rsm = parent.submodule_update()
+        assert_exists(sm)
+        assert_exists(csm)
+        with csm.config_writer().set_value("url", "bar"):
+            pass
+        csm.repo.index.commit("Have to commit submodule change for algorithm to pick it up")
+        assert csm.url == "bar"
+
+        self.assertRaises(
+            Exception,
+            rsm.update,
+            recursive=True,
+            to_latest_revision=True,
+            progress=prog,
+        )
+        assert_exists(csm)
+        rsm.update(recursive=True, to_latest_revision=True, progress=prog, keep_going=True)
+
+        # remove
+        sm_module_path = sm.module().git_dir
+
+        for dry_run in (True, False):
+            sm.remove(dry_run=dry_run, force=True)
+            assert_exists(sm, value=dry_run)
+            assert osp.isdir(sm_module_path) == dry_run
+        # END for each dry-run mode
+
+    @with_rw_directory
+    def test_ignore_non_submodule_file(self, rwdir):
+        parent = git.Repo.init(rwdir)
+
+        smp = osp.join(rwdir, "module")
+        os.mkdir(smp)
+
+        with open(osp.join(smp, "a"), "w", encoding="utf-8") as f:
+            f.write("test\n")
+
+        with open(osp.join(rwdir, ".gitmodules"), "w", encoding="utf-8") as f:
+            f.write('[submodule "a"]\n')
+            f.write("    path = module\n")
+            f.write("    url = https://github.com/chaconinc/DbConnector\n")
+
+        parent.git.add(Git.polish_url(osp.join(smp, "a")))
+        parent.git.add(Git.polish_url(osp.join(rwdir, ".gitmodules")))
+
+        parent.git.commit(message="test")
+
+        assert len(parent.submodules) == 0
+
+    @with_rw_directory
+    def test_remove_norefs(self, rwdir):
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        sm_name = "mymodules/myname"
+        sm = parent.create_submodule(sm_name, sm_name, url=self._small_repo_url())
+        assert sm.exists()
+
+        parent.index.commit("Added submodule")
+
+        assert sm.repo is parent  # yoh was surprised since expected sm repo!!
+        # So created a new instance for submodule.
+        smrepo = git.Repo(osp.join(rwdir, "parent", sm.path))
+        # Adding a remote without fetching so would have no references.
+        smrepo.create_remote("special", "git@server-shouldnotmatter:repo.git")
+        # And we should be able to remove it just fine.
+        sm.remove()
+        assert not sm.exists()
+
+    @with_rw_directory
+    def test_rename(self, rwdir):
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        sm_name = "mymodules/myname"
+        sm = parent.create_submodule(sm_name, sm_name, url=self._small_repo_url())
+        parent.index.commit("Added submodule")
+
+        assert sm.rename(sm_name) is sm and sm.name == sm_name
+        assert not sm.repo.is_dirty(index=True, working_tree=False, untracked_files=False)
+
+        # This is needed to work around a PermissionError on Windows, resembling others,
+        # except new in Python 3.12. (*Maybe* this could be due to changes in CPython's
+        # garbage collector detailed in https://github.com/python/cpython/issues/97922.)
+        if sys.platform == "win32" and sys.version_info >= (3, 12):
+            gc.collect()
+
+        new_path = "renamed/myname"
+        assert sm.move(new_path).name == new_path
+
+        new_sm_name = "shortname"
+        assert sm.rename(new_sm_name) is sm
+        assert sm.repo.is_dirty(index=True, working_tree=False, untracked_files=False)
+        assert sm.exists()
+
+        sm_mod = sm.module()
+        if osp.isfile(osp.join(sm_mod.working_tree_dir, ".git")) == sm._need_gitfile_submodules(parent.git):
+            assert sm_mod.git_dir.endswith(join_path_native(".git", "modules", new_sm_name))
+
+    @with_rw_directory
+    def test_branch_renames(self, rw_dir):
+        # Set up initial sandbox:
+        # The parent repo has one submodule, which has all the latest changes.
+        source_url = self._small_repo_url()
+        sm_source_repo = git.Repo.clone_from(source_url, osp.join(rw_dir, "sm-source"), b="master")
+        parent_repo = git.Repo.init(osp.join(rw_dir, "parent"))
+        sm = parent_repo.create_submodule(
+            "mysubmodule",
+            "subdir/submodule",
+            sm_source_repo.working_tree_dir,
+            branch="master",
+        )
+        parent_repo.index.commit("added submodule")
+        assert sm.exists()
+
+        # Create feature branch with one new commit in submodule source.
+        sm_fb = sm_source_repo.create_head("feature")
+        sm_fb.checkout()
+        new_file = touch(osp.join(sm_source_repo.working_tree_dir, "new-file"))
+        sm_source_repo.index.add([new_file])
+        sm.repo.index.commit("added new file")
+
+        # Change designated submodule checkout branch to the new upstream feature
+        # branch.
+        with sm.config_writer() as smcw:
+            smcw.set_value("branch", sm_fb.name)
+        assert sm.repo.is_dirty(index=True, working_tree=False)
+        sm.repo.index.commit("changed submodule branch to '%s'" % sm_fb)
+
+        # Verify submodule update with feature branch that leaves currently checked out
+        # branch in it's past.
+        sm_mod = sm.module()
+        prev_commit = sm_mod.commit()
+        assert sm_mod.head.ref.name == "master"
+        assert parent_repo.submodule_update()
+        assert sm_mod.head.ref.name == sm_fb.name
+        assert sm_mod.commit() == prev_commit, "Without to_latest_revision, we don't change the commit"
+
+        assert parent_repo.submodule_update(to_latest_revision=True)
+        assert sm_mod.head.ref.name == sm_fb.name
+        assert sm_mod.commit() == sm_fb.commit
+
+        # Create new branch which is in our past, and thus seemingly unrelated to the
+        # currently checked out one.
+        # To make it even 'harder', we shall fork and create a new commit.
+        sm_pfb = sm_source_repo.create_head("past-feature", commit="HEAD~20")
+        sm_pfb.checkout()
+        sm_source_repo.index.add([touch(osp.join(sm_source_repo.working_tree_dir, "new-file"))])
+        sm_source_repo.index.commit("new file added, to past of '%r'" % sm_fb)
+
+        # Change designated submodule checkout branch to a new commit in its own past.
+        with sm.config_writer() as smcw:
+            smcw.set_value("branch", sm_pfb.path)
+        sm.repo.index.commit("changed submodule branch to '%s'" % sm_pfb)
+
+        # Test submodule updates - must fail if submodule is dirty.
+        touch(osp.join(sm_mod.working_tree_dir, "unstaged file"))
+        # This doesn't fail as our own submodule binsha didn't change, and the reset is
+        # only triggered if to_latest_revision is True.
+        parent_repo.submodule_update(to_latest_revision=False)
+        assert sm_mod.head.ref.name == sm_pfb.name, "should have been switched to past head"
+        assert sm_mod.commit() == sm_fb.commit, "Head wasn't reset"
+
+        self.assertRaises(RepositoryDirtyError, parent_repo.submodule_update, to_latest_revision=True)
+        parent_repo.submodule_update(to_latest_revision=True, force_reset=True)
+        assert sm_mod.commit() == sm_pfb.commit, "Now head should have been reset"
+        assert sm_mod.head.ref.name == sm_pfb.name
+
+    @skipUnless(sys.platform == "win32", "Specifically for Windows.")
+    def test_to_relative_path_with_super_at_root_drive(self):
+        class Repo:
+            working_tree_dir = "D:\\"
+
+        super_repo = Repo()
+        submodule_path = "D:\\submodule_path"
+        relative_path = Submodule._to_relative_path(super_repo, submodule_path)
+        msg = '_to_relative_path should be "submodule_path" but was "%s"' % relative_path
+        assert relative_path == "submodule_path", msg
+
+    @pytest.mark.xfail(
+        reason="for some unknown reason the assertion fails, even though it in fact is working in more common setup",
+        raises=AssertionError,
+    )
+    @with_rw_directory
+    def test_depth(self, rwdir):
+        parent = git.Repo.init(osp.join(rwdir, "test_depth"))
+        sm_name = "mymodules/myname"
+        sm_depth = 1
+        sm = parent.create_submodule(sm_name, sm_name, url=self._small_repo_url(), depth=sm_depth)
+        self.assertEqual(len(list(sm.module().iter_commits())), sm_depth)
+
+    @with_rw_directory
+    def test_update_clone_multi_options_argument(self, rwdir):
+        # Arrange
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        sm_name = "foo"
+        sm_url = self._small_repo_url()
+        sm_branch = "refs/heads/master"
+        sm_hexsha = git.Repo(self._small_repo_url()).head.commit.hexsha
+        sm = Submodule(
+            parent,
+            bytes.fromhex(sm_hexsha),
+            name=sm_name,
+            path=sm_name,
+            url=sm_url,
+            branch_path=sm_branch,
+        )
+
+        # Act
+        sm.update(init=True, clone_multi_options=["--config core.eol=true"], allow_unsafe_options=True)
+
+        # Assert
+        sm_config = GitConfigParser(file_or_files=osp.join(parent.git_dir, "modules", sm_name, "config"))
+        self.assertTrue(sm_config.get_value("core", "eol"))
+
+    @with_rw_directory
+    def test_update_no_clone_multi_options_argument(self, rwdir):
+        # Arrange
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        sm_name = "foo"
+        sm_url = self._small_repo_url()
+        sm_branch = "refs/heads/master"
+        sm_hexsha = git.Repo(self._small_repo_url()).head.commit.hexsha
+        sm = Submodule(
+            parent,
+            bytes.fromhex(sm_hexsha),
+            name=sm_name,
+            path=sm_name,
+            url=sm_url,
+            branch_path=sm_branch,
+        )
+
+        # Act
+        sm.update(init=True)
+
+        # Assert
+        sm_config = GitConfigParser(file_or_files=osp.join(parent.git_dir, "modules", sm_name, "config"))
+        with self.assertRaises(cp.NoOptionError):
+            sm_config.get_value("core", "eol")
+
+    @with_rw_directory
+    def test_add_clone_multi_options_argument(self, rwdir):
+        # Arrange
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        sm_name = "foo"
+
+        # Act
+        Submodule.add(
+            parent,
+            sm_name,
+            sm_name,
+            url=self._small_repo_url(),
+            clone_multi_options=["--config core.eol=true"],
+            allow_unsafe_options=True,
+        )
+
+        # Assert
+        sm_config = GitConfigParser(file_or_files=osp.join(parent.git_dir, "modules", sm_name, "config"))
+        self.assertTrue(sm_config.get_value("core", "eol"))
+
+    @with_rw_directory
+    def test_add_no_clone_multi_options_argument(self, rwdir):
+        # Arrange
+        parent = git.Repo.init(osp.join(rwdir, "parent"))
+        sm_name = "foo"
+
+        # Act
+        Submodule.add(parent, sm_name, sm_name, url=self._small_repo_url())
+
+        # Assert
+        sm_config = GitConfigParser(file_or_files=osp.join(parent.git_dir, "modules", sm_name, "config"))
+        with self.assertRaises(cp.NoOptionError):
+            sm_config.get_value("core", "eol")
+
+    @with_rw_repo("HEAD")
+    def test_submodule_add_unsafe_url(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::/foo",
+            ]
+            for url in urls:
+                with self.assertRaises(UnsafeProtocolError):
+                    Submodule.add(rw_repo, "new", "new", url)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_submodule_add_unsafe_url_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::/foo",
+            ]
+            for url in urls:
+                # The URL will be allowed into the command, but the command will fail
+                # since we don't have that protocol enabled in the Git config file.
+                with self.assertRaises(GitCommandError):
+                    Submodule.add(rw_repo, "new", "new", url, allow_unsafe_protocols=True)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_submodule_add_unsafe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                f"--upload-pack='touch {tmp_file}'",
+                f"-u 'touch {tmp_file}'",
+                "--config=protocol.ext.allow=always",
+                "-c protocol.ext.allow=always",
+            ]
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(UnsafeOptionError):
+                    Submodule.add(rw_repo, "new", "new", str(tmp_dir), clone_multi_options=[unsafe_option])
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_submodule_add_unsafe_options_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                f"--upload-pack='touch {tmp_file}'",
+                f"-u 'touch {tmp_file}'",
+            ]
+            for unsafe_option in unsafe_options:
+                # The options will be allowed, but the command will fail.
+                with self.assertRaises(GitCommandError):
+                    Submodule.add(
+                        rw_repo,
+                        "new",
+                        "new",
+                        str(tmp_dir),
+                        clone_multi_options=[unsafe_option],
+                        allow_unsafe_options=True,
+                    )
+                assert not tmp_file.exists()
+
+            unsafe_options = [
+                "--config=protocol.ext.allow=always",
+                "-c protocol.ext.allow=always",
+            ]
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(GitCommandError):
+                    Submodule.add(
+                        rw_repo,
+                        "new",
+                        "new",
+                        str(tmp_dir),
+                        clone_multi_options=[unsafe_option],
+                        allow_unsafe_options=True,
+                    )
+
+    @with_rw_repo("HEAD")
+    def test_submodule_update_unsafe_url(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::/foo",
+            ]
+            for url in urls:
+                submodule = Submodule(rw_repo, b"\0" * 20, name="new", path="new", url=url)
+                with self.assertRaises(UnsafeProtocolError):
+                    submodule.update()
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_submodule_update_unsafe_url_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            urls = [
+                f"ext::sh -c touch% {tmp_file}",
+                "fd::/foo",
+            ]
+            for url in urls:
+                submodule = Submodule(rw_repo, b"\0" * 20, name="new", path="new", url=url)
+                # The URL will be allowed into the command, but the command will fail
+                # since we don't have that protocol enabled in the Git config file.
+                with self.assertRaises(GitCommandError):
+                    submodule.update(allow_unsafe_protocols=True)
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_submodule_update_unsafe_options(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                f"--upload-pack='touch {tmp_file}'",
+                f"-u 'touch {tmp_file}'",
+                "--config=protocol.ext.allow=always",
+                "-c protocol.ext.allow=always",
+            ]
+            submodule = Submodule(rw_repo, b"\0" * 20, name="new", path="new", url=str(tmp_dir))
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(UnsafeOptionError):
+                    submodule.update(clone_multi_options=[unsafe_option])
+                assert not tmp_file.exists()
+
+    @with_rw_repo("HEAD")
+    def test_submodule_update_unsafe_options_allowed(self, rw_repo):
+        with tempfile.TemporaryDirectory() as tdir:
+            tmp_dir = Path(tdir)
+            tmp_file = tmp_dir / "pwn"
+            unsafe_options = [
+                f"--upload-pack='touch {tmp_file}'",
+                f"-u 'touch {tmp_file}'",
+            ]
+            submodule = Submodule(rw_repo, b"\0" * 20, name="new", path="new", url=str(tmp_dir))
+            for unsafe_option in unsafe_options:
+                # The options will be allowed, but the command will fail.
+                with self.assertRaises(GitCommandError):
+                    submodule.update(clone_multi_options=[unsafe_option], allow_unsafe_options=True)
+                assert not tmp_file.exists()
+
+            unsafe_options = [
+                "--config=protocol.ext.allow=always",
+                "-c protocol.ext.allow=always",
+            ]
+            submodule = Submodule(rw_repo, b"\0" * 20, name="new", path="new", url=str(tmp_dir))
+            for unsafe_option in unsafe_options:
+                with self.assertRaises(GitCommandError):
+                    submodule.update(clone_multi_options=[unsafe_option], allow_unsafe_options=True)
+
+    @with_rw_directory
+    @_patch_git_config("protocol.file.allow", "always")
+    def test_submodule_update_relative_url(self, rwdir):
+        parent_path = osp.join(rwdir, "parent")
+        parent_repo = git.Repo.init(parent_path)
+        submodule_path = osp.join(rwdir, "module")
+        submodule_repo = git.Repo.init(submodule_path)
+        submodule_repo.git.commit(m="initial commit", allow_empty=True)
+
+        parent_repo.git.submodule("add", "../module", "module")
+        parent_repo.index.commit("add submodule with relative URL")
+
+        cloned_path = osp.join(rwdir, "cloned_repo")
+        cloned_repo = git.Repo.clone_from(parent_path, cloned_path)
+
+        cloned_repo.submodule_update(init=True, recursive=True)
+
+        has_module = any(sm.name == "module" for sm in cloned_repo.submodules)
+        assert has_module, "Relative submodule was not updated properly"
diff --git a/test/test_tree.py b/test/test_tree.py
new file mode 100644
index 000000000..7ba93bd36
--- /dev/null
+++ b/test/test_tree.py
@@ -0,0 +1,163 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+from io import BytesIO
+import os.path as osp
+from pathlib import Path
+import subprocess
+
+from git.objects import Blob, Tree
+from git.util import cwd
+
+from test.lib import TestBase, with_rw_directory
+
+
+class TestTree(TestBase):
+    def test_serializable(self):
+        # Tree at the given commit contains a submodule as well.
+        roottree = self.rorepo.tree("6c1faef799095f3990e9970bc2cb10aa0221cf9c")
+        for item in roottree.traverse(ignore_self=False):
+            if item.type != Tree.type:
+                continue
+            # END skip non-trees
+            tree = item
+            # Trees have no dict.
+            self.assertRaises(AttributeError, setattr, tree, "someattr", 1)
+
+            orig_data = tree.data_stream.read()
+            orig_cache = tree._cache
+
+            stream = BytesIO()
+            tree._serialize(stream)
+            assert stream.getvalue() == orig_data
+
+            stream.seek(0)
+            testtree = Tree(self.rorepo, Tree.NULL_BIN_SHA, 0, "")
+            testtree._deserialize(stream)
+            assert testtree._cache == orig_cache
+
+            # Replaces cache, but we make sure of it.
+            del testtree._cache
+            testtree._deserialize(stream)
+        # END for each item in tree
+
+    @with_rw_directory
+    def _get_git_ordered_files(self, rw_dir):
+        """Get files as git orders them, to compare in test_tree_modifier_ordering."""
+        # Create directory contents.
+        Path(rw_dir, "file").mkdir()
+        for filename in (
+            "bin",
+            "bin.d",
+            "file.to",
+            "file.toml",
+            "file.toml.bin",
+            "file0",
+        ):
+            Path(rw_dir, filename).touch()
+        Path(rw_dir, "file", "a").touch()
+
+        with cwd(rw_dir):
+            # Prepare the repository.
+            subprocess.run(["git", "init", "-q"], check=True)
+            subprocess.run(["git", "add", "."], check=True)
+            subprocess.run(["git", "commit", "-m", "c1"], check=True)
+
+            # Get git output from which an ordered file list can be parsed.
+            rev_parse_command = ["git", "rev-parse", "HEAD^{tree}"]
+            tree_hash = subprocess.check_output(rev_parse_command).decode().strip()
+            cat_file_command = ["git", "cat-file", "-p", tree_hash]
+            cat_file_output = subprocess.check_output(cat_file_command).decode()
+
+        return [line.split()[-1] for line in cat_file_output.split("\n") if line]
+
+    def test_tree_modifier_ordering(self):
+        """TreeModifier.set_done() sorts files in the same order git does."""
+        git_file_names_in_order = self._get_git_ordered_files()
+
+        hexsha = "6c1faef799095f3990e9970bc2cb10aa0221cf9c"
+        roottree = self.rorepo.tree(hexsha)
+        blob_mode = Tree.blob_id << 12
+        tree_mode = Tree.tree_id << 12
+
+        files_in_desired_order = [
+            (blob_mode, "bin"),
+            (blob_mode, "bin.d"),
+            (blob_mode, "file.to"),
+            (blob_mode, "file.toml"),
+            (blob_mode, "file.toml.bin"),
+            (blob_mode, "file0"),
+            (tree_mode, "file"),
+        ]
+        mod = roottree.cache
+        for file_mode, file_name in files_in_desired_order:
+            mod.add(hexsha, file_mode, file_name)
+        # end for each file
+
+        def file_names_in_order():
+            return [t[1] for t in files_in_desired_order]
+
+        def names_in_mod_cache():
+            a = [t[2] for t in mod._cache]
+            here = file_names_in_order()
+            return [e for e in a if e in here]
+
+        mod.set_done()
+        assert names_in_mod_cache() == git_file_names_in_order, "set_done() performs git-sorting"
+
+    def test_traverse(self):
+        root = self.rorepo.tree("0.1.6")
+        num_recursive = 0
+        all_items = []
+        for obj in root.traverse():
+            if "/" in obj.path:
+                num_recursive += 1
+
+            assert isinstance(obj, (Blob, Tree))
+            all_items.append(obj)
+        # END for each object
+        assert all_items == root.list_traverse()
+
+        # Limit recursion level to 0 - should be same as default iteration.
+        assert all_items
+        assert "CHANGES" in root
+        assert len(list(root)) == len(list(root.traverse(depth=1)))
+
+        # Only choose trees.
+
+        def trees_only(i, _d):
+            return i.type == "tree"
+
+        trees = list(root.traverse(predicate=trees_only))
+        assert len(trees) == len([i for i in root.traverse() if trees_only(i, 0)])
+
+        # Test prune.
+
+        def lib_folder(t, _d):
+            return t.path == "lib"
+
+        pruned_trees = list(root.traverse(predicate=trees_only, prune=lib_folder))
+        assert len(pruned_trees) < len(trees)
+
+        # Trees and blobs.
+        assert len(set(trees) | set(root.trees)) == len(trees)
+        assert len({b for b in root if isinstance(b, Blob)} | set(root.blobs)) == len(root.blobs)
+        subitem = trees[0][0]
+        assert "/" in subitem.path
+        assert subitem.name == osp.basename(subitem.path)
+
+        # Check that at some point the traversed paths have a slash in them.
+        found_slash = False
+        for item in root.traverse():
+            assert osp.isabs(item.abspath)
+            if "/" in item.path:
+                found_slash = True
+            # END check for slash
+
+            # Slashes in paths are supported as well.
+            # NOTE: On Python 3, / doesn't work with strings anymore...
+            assert root[item.path] == item == root / item.path
+        # END for each item
+        assert found_slash
diff --git a/test/test_util.py b/test/test_util.py
new file mode 100644
index 000000000..000830f41
--- /dev/null
+++ b/test/test_util.py
@@ -0,0 +1,679 @@
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+import ast
+from datetime import datetime
+import os
+import pathlib
+import pickle
+import stat
+import subprocess
+import sys
+import tempfile
+import time
+from unittest import SkipTest, mock
+
+import ddt
+import pytest
+
+from git.cmd import dashify
+from git.objects.util import (
+    altz_to_utctz_str,
+    from_timestamp,
+    parse_date,
+    tzoffset,
+    utctz_to_altz,
+    verify_utctz,
+)
+from git.util import (
+    Actor,
+    BlockingLockFile,
+    IterableList,
+    LockFile,
+    cygpath,
+    decygpath,
+    is_cygwin_git,
+    get_user_id,
+    remove_password_if_present,
+    rmtree,
+)
+
+from test.lib import TestBase, with_rw_repo
+
+
+@pytest.fixture
+def permission_error_tmpdir(tmp_path):
+    """Fixture to test permissions errors in situations where they are not overcome."""
+    td = tmp_path / "testdir"
+    td.mkdir()
+    (td / "x").touch()
+
+    # Set up PermissionError on Windows, where we can't delete read-only files.
+    (td / "x").chmod(stat.S_IRUSR)
+
+    # Set up PermissionError on Unix, where non-root users can't delete files in
+    # read-only directories. (Tests that rely on this and assert that rmtree raises
+    # PermissionError will fail if they are run as root.)
+    td.chmod(stat.S_IRUSR | stat.S_IXUSR)
+
+    yield td
+
+
+class TestRmtree:
+    """Tests for :func:`git.util.rmtree`."""
+
+    def test_deletes_nested_dir_with_files(self, tmp_path):
+        td = tmp_path / "testdir"
+
+        for d in td, td / "q", td / "s":
+            d.mkdir()
+        for f in (
+            td / "p",
+            td / "q" / "w",
+            td / "q" / "x",
+            td / "r",
+            td / "s" / "y",
+            td / "s" / "z",
+        ):
+            f.touch()
+
+        try:
+            rmtree(td)
+        except SkipTest as ex:
+            pytest.fail(f"rmtree unexpectedly attempts skip: {ex!r}")
+
+        assert not td.exists()
+
+    @pytest.mark.skipif(
+        sys.platform == "cygwin",
+        reason="Cygwin can't set the permissions that make the test meaningful.",
+    )
+    def test_deletes_dir_with_readonly_files(self, tmp_path):
+        # Automatically works on Unix, but requires special handling on Windows.
+        # Not to be confused with what permission_error_tmpdir sets up (see below).
+
+        td = tmp_path / "testdir"
+
+        for d in td, td / "sub":
+            d.mkdir()
+        for f in td / "x", td / "sub" / "y":
+            f.touch()
+            f.chmod(0)
+
+        try:
+            rmtree(td)
+        except SkipTest as ex:
+            self.fail(f"rmtree unexpectedly attempts skip: {ex!r}")
+
+        assert not td.exists()
+
+    @pytest.mark.skipif(
+        sys.platform == "cygwin",
+        reason="Cygwin can't set the permissions that make the test meaningful.",
+    )
+    def test_avoids_changing_permissions_outside_tree(self, tmp_path):
+        # Automatically works on Windows, but on Unix requires either special handling
+        # or refraining from attempting to fix PermissionError by making chmod calls.
+
+        dir1 = tmp_path / "dir1"
+        dir1.mkdir()
+        (dir1 / "file").touch()
+        (dir1 / "file").chmod(stat.S_IRUSR)
+        old_mode = (dir1 / "file").stat().st_mode
+
+        dir2 = tmp_path / "dir2"
+        dir2.mkdir()
+        (dir2 / "symlink").symlink_to(dir1 / "file")
+        dir2.chmod(stat.S_IRUSR | stat.S_IXUSR)
+
+        try:
+            rmtree(dir2)
+        except PermissionError:
+            pass  # On Unix, dir2 is not writable, so dir2/symlink may not be deleted.
+        except SkipTest as ex:
+            self.fail(f"rmtree unexpectedly attempts skip: {ex!r}")
+
+        new_mode = (dir1 / "file").stat().st_mode
+        assert old_mode == new_mode, f"Should stay {old_mode:#o}, became {new_mode:#o}."
+
+    def _patch_for_wrapping_test(self, mocker, hide_windows_known_errors):
+        # Access the module through sys.modules so it is unambiguous which module's
+        # attribute we patch: the original git.util, not git.index.util even though
+        # git.index.util "replaces" git.util and is what "import git.util" gives us.
+        mocker.patch.object(sys.modules["git.util"], "HIDE_WINDOWS_KNOWN_ERRORS", hide_windows_known_errors)
+
+        # Mock out common chmod functions to simulate PermissionError the callback can't
+        # fix. (We leave the corresponding lchmod functions alone. If they're used, it's
+        # more important we detect any failures from inadequate compatibility checks.)
+        mocker.patch.object(os, "chmod")
+        mocker.patch.object(pathlib.Path, "chmod")
+
+    @pytest.mark.skipif(
+        sys.platform != "win32",
+        reason="PermissionError is only ever wrapped on Windows",
+    )
+    def test_wraps_perm_error_if_enabled(self, mocker, permission_error_tmpdir):
+        """rmtree wraps PermissionError on Windows when HIDE_WINDOWS_KNOWN_ERRORS is
+        true."""
+        self._patch_for_wrapping_test(mocker, True)
+
+        with pytest.raises(SkipTest):
+            rmtree(permission_error_tmpdir)
+
+    @pytest.mark.skipif(
+        sys.platform == "cygwin",
+        reason="Cygwin can't set the permissions that make the test meaningful.",
+    )
+    @pytest.mark.parametrize(
+        "hide_windows_known_errors",
+        [
+            pytest.param(False),
+            pytest.param(True, marks=pytest.mark.skipif(sys.platform == "win32", reason="We would wrap on Windows")),
+        ],
+    )
+    def test_does_not_wrap_perm_error_unless_enabled(self, mocker, permission_error_tmpdir, hide_windows_known_errors):
+        """rmtree does not wrap PermissionError on non-Windows systems or when
+        HIDE_WINDOWS_KNOWN_ERRORS is false."""
+        self._patch_for_wrapping_test(mocker, hide_windows_known_errors)
+
+        with pytest.raises(PermissionError):
+            try:
+                rmtree(permission_error_tmpdir)
+            except SkipTest as ex:
+                pytest.fail(f"rmtree unexpectedly attempts skip: {ex!r}")
+
+    @pytest.mark.parametrize("hide_windows_known_errors", [False, True])
+    def test_does_not_wrap_other_errors(self, tmp_path, mocker, hide_windows_known_errors):
+        # The file is deliberately never created.
+        file_not_found_tmpdir = tmp_path / "testdir"
+
+        self._patch_for_wrapping_test(mocker, hide_windows_known_errors)
+
+        with pytest.raises(FileNotFoundError):
+            try:
+                rmtree(file_not_found_tmpdir)
+            except SkipTest as ex:
+                self.fail(f"rmtree unexpectedly attempts skip: {ex!r}")
+
+
+class TestEnvParsing:
+    """Tests for environment variable parsing logic in :mod:`git.util`."""
+
+    @staticmethod
+    def _run_parse(name, value):
+        command = [
+            sys.executable,
+            "-c",
+            f"from git.util import {name}; print(repr({name}))",
+        ]
+        output = subprocess.check_output(
+            command,
+            env=None if value is None else dict(os.environ, **{name: value}),
+            text=True,
+        )
+        return ast.literal_eval(output)
+
+    @pytest.mark.skipif(
+        sys.platform != "win32",
+        reason="These environment variables are only used on Windows.",
+    )
+    @pytest.mark.parametrize(
+        "env_var_value, expected_truth_value",
+        [
+            (None, True),  # When the environment variable is unset.
+            ("", False),
+            (" ", False),
+            ("0", False),
+            ("1", True),
+            ("false", False),
+            ("true", True),
+            ("False", False),
+            ("True", True),
+            ("no", False),
+            ("yes", True),
+            ("NO", False),
+            ("YES", True),
+            (" no  ", False),
+            (" yes  ", True),
+        ],
+    )
+    @pytest.mark.parametrize(
+        "name",
+        [
+            "HIDE_WINDOWS_KNOWN_ERRORS",
+            "HIDE_WINDOWS_FREEZE_ERRORS",
+        ],
+    )
+    def test_env_vars_for_windows_tests(self, name, env_var_value, expected_truth_value):
+        actual_parsed_value = self._run_parse(name, env_var_value)
+        assert actual_parsed_value is expected_truth_value
+
+
+def _xfail_param(*values, **xfail_kwargs):
+    """Build a pytest.mark.parametrize parameter that carries an xfail mark."""
+    return pytest.param(*values, marks=pytest.mark.xfail(**xfail_kwargs))
+
+
+_norm_cygpath_pairs = (
+    (R"foo\bar", "foo/bar"),
+    (R"foo/bar", "foo/bar"),
+    (R"C:\Users", "/cygdrive/c/Users"),
+    (R"C:\d/e", "/cygdrive/c/d/e"),
+    ("C:\\", "/cygdrive/c/"),
+    (R"\\server\C$\Users", "//server/C$/Users"),
+    (R"\\server\C$", "//server/C$"),
+    ("\\\\server\\c$\\", "//server/c$/"),
+    (R"\\server\BAR/", "//server/BAR/"),
+    (R"D:/Apps", "/cygdrive/d/Apps"),
+    (R"D:/Apps\fOO", "/cygdrive/d/Apps/fOO"),
+    (R"D:\Apps/123", "/cygdrive/d/Apps/123"),
+)
+"""Path test cases for cygpath and decygpath, other than extended UNC paths."""
+
+_unc_cygpath_pairs = (
+    (R"\\?\a:\com", "/cygdrive/a/com"),
+    (R"\\?\a:/com", "/cygdrive/a/com"),
+    (R"\\?\UNC\server\D$\Apps", "//server/D$/Apps"),
+)
+"""Extended UNC path test cases for cygpath."""
+
+_cygpath_ok_xfails = {
+    # From _norm_cygpath_pairs:
+    (R"C:\Users", "/cygdrive/c/Users"): "/proc/cygdrive/c/Users",
+    (R"C:\d/e", "/cygdrive/c/d/e"): "/proc/cygdrive/c/d/e",
+    ("C:\\", "/cygdrive/c/"): "/proc/cygdrive/c/",
+    (R"\\server\BAR/", "//server/BAR/"): "//server/BAR",
+    (R"D:/Apps", "/cygdrive/d/Apps"): "/proc/cygdrive/d/Apps",
+    (R"D:/Apps\fOO", "/cygdrive/d/Apps/fOO"): "/proc/cygdrive/d/Apps/fOO",
+    (R"D:\Apps/123", "/cygdrive/d/Apps/123"): "/proc/cygdrive/d/Apps/123",
+    # From _unc_cygpath_pairs:
+    (R"\\?\a:\com", "/cygdrive/a/com"): "/proc/cygdrive/a/com",
+    (R"\\?\a:/com", "/cygdrive/a/com"): "/proc/cygdrive/a/com",
+}
+"""Mapping of expected failures for the test_cygpath_ok test."""
+
+
+_cygpath_ok_params = [
+    (
+        _xfail_param(*case, reason=f"Returns: {_cygpath_ok_xfails[case]!r}", raises=AssertionError)
+        if case in _cygpath_ok_xfails
+        else case
+    )
+    for case in _norm_cygpath_pairs + _unc_cygpath_pairs
+]
+"""Parameter sets for the test_cygpath_ok test."""
+
+
+@pytest.mark.skipif(sys.platform != "cygwin", reason="Paths specifically for Cygwin.")
+class TestCygpath:
+    """Tests for :func:`git.util.cygpath` and :func:`git.util.decygpath`."""
+
+    @pytest.mark.parametrize("wpath, cpath", _cygpath_ok_params)
+    def test_cygpath_ok(self, wpath, cpath):
+        cwpath = cygpath(wpath)
+        assert cwpath == cpath, wpath
+
+    @pytest.mark.parametrize(
+        "wpath, cpath",
+        [
+            (R"./bar", "bar"),
+            _xfail_param(R".\bar", "bar", reason="Returns: './bar'", raises=AssertionError),
+            (R"../bar", "../bar"),
+            (R"..\bar", "../bar"),
+            (R"../bar/.\foo/../chu", "../bar/chu"),
+        ],
+    )
+    def test_cygpath_norm_ok(self, wpath, cpath):
+        cwpath = cygpath(wpath)
+        assert cwpath == (cpath or wpath), wpath
+
+    @pytest.mark.parametrize(
+        "wpath",
+        [
+            R"C:",
+            R"C:Relative",
+            R"D:Apps\123",
+            R"D:Apps/123",
+            R"\\?\a:rel",
+            R"\\share\a:rel",
+        ],
+    )
+    def test_cygpath_invalids(self, wpath):
+        cwpath = cygpath(wpath)
+        assert cwpath == wpath.replace("\\", "/"), wpath
+
+    @pytest.mark.parametrize("wpath, cpath", _norm_cygpath_pairs)
+    def test_decygpath(self, wpath, cpath):
+        wcpath = decygpath(cpath)
+        assert wcpath == wpath.replace("/", "\\"), cpath
+
+
+class TestIsCygwinGit:
+    """Tests for :func:`is_cygwin_git`"""
+
+    def test_on_path_executable(self):
+        # Currently we assume tests run on Cygwin use Cygwin git. See #533 and #1455 for background.
+        if sys.platform == "cygwin":
+            assert is_cygwin_git("git")
+        else:
+            assert not is_cygwin_git("git")
+
+    def test_none_executable(self):
+        assert not is_cygwin_git(None)
+
+    def test_with_missing_uname(self):
+        """Test for handling when `uname` isn't in the same directory as `git`"""
+        assert not is_cygwin_git("/bogus_path/git")
+
+
+class _Member:
+    """A member of an IterableList."""
+
+    __slots__ = ("name",)
+
+    def __init__(self, name):
+        self.name = name
+
+    def __repr__(self):
+        return f"{type(self).__name__}({self.name!r})"
+
+
+@ddt.ddt
+class TestUtils(TestBase):
+    """Tests for most utilities in :mod:`git.util`."""
+
+    def test_it_should_dashify(self):
+        self.assertEqual("this-is-my-argument", dashify("this_is_my_argument"))
+        self.assertEqual("foo", dashify("foo"))
+
+    def test_lock_file(self):
+        with tempfile.TemporaryDirectory() as tdir:
+            my_file = os.path.join(tdir, "my-lock-file")
+            lock_file = LockFile(my_file)
+            assert not lock_file._has_lock()
+            # Release lock we don't have - fine.
+            lock_file._release_lock()
+
+            # Get lock.
+            lock_file._obtain_lock_or_raise()
+            assert lock_file._has_lock()
+
+            # Concurrent access.
+            other_lock_file = LockFile(my_file)
+            assert not other_lock_file._has_lock()
+            self.assertRaises(IOError, other_lock_file._obtain_lock_or_raise)
+
+            lock_file._release_lock()
+            assert not lock_file._has_lock()
+
+            other_lock_file._obtain_lock_or_raise()
+            self.assertRaises(IOError, lock_file._obtain_lock_or_raise)
+
+            # Auto-release on destruction.
+            del other_lock_file
+            lock_file._obtain_lock_or_raise()
+            lock_file._release_lock()
+
+    def test_blocking_lock_file(self):
+        with tempfile.TemporaryDirectory() as tdir:
+            my_file = os.path.join(tdir, "my-lock-file")
+            lock_file = BlockingLockFile(my_file)
+            lock_file._obtain_lock()
+
+            # Next one waits for the lock.
+            start = time.time()
+            wait_time = 0.1
+            wait_lock = BlockingLockFile(my_file, 0.05, wait_time)
+            self.assertRaises(IOError, wait_lock._obtain_lock)
+            elapsed = time.time() - start
+
+        extra_time = 0.02
+        if sys.platform in {"win32", "cygwin"}:
+            extra_time *= 6  # Without this, we get indeterministic failures on Windows.
+        elif sys.platform == "darwin":
+            extra_time *= 18  # The situation on macOS is similar, but with more delay.
+
+        self.assertLess(elapsed, wait_time + extra_time)
+
+    def test_user_id(self):
+        self.assertIn("@", get_user_id())
+
+    def test_parse_date(self):
+        # parse_date(from_timestamp()) must return the tuple unchanged.
+        for timestamp, offset in (
+            (1522827734, -7200),
+            (1522827734, 0),
+            (1522827734, +3600),
+        ):
+            self.assertEqual(parse_date(from_timestamp(timestamp, offset)), (timestamp, offset))
+
+        # Test all supported formats.
+        def assert_rval(rval, veri_time, offset=0):
+            self.assertEqual(len(rval), 2)
+            self.assertIsInstance(rval[0], int)
+            self.assertIsInstance(rval[1], int)
+            self.assertEqual(rval[0], veri_time)
+            self.assertEqual(rval[1], offset)
+
+            # Now that we are here, test our conversion functions as well.
+            utctz = altz_to_utctz_str(offset)
+            self.assertIsInstance(utctz, str)
+            self.assertEqual(utctz_to_altz(verify_utctz(utctz)), offset)
+
+        # END assert rval utility
+
+        rfc = ("Thu, 07 Apr 2005 22:13:11 +0000", 0)
+        iso = ("2005-04-07T22:13:11 -0200", 7200)
+        iso2 = ("2005-04-07 22:13:11 +0400", -14400)
+        iso3 = ("2005.04.07 22:13:11 -0000", 0)
+        alt = ("04/07/2005 22:13:11", 0)
+        alt2 = ("07.04.2005 22:13:11", 0)
+        veri_time_utc = 1112911991  # The time this represents, in time since epoch, UTC.
+        for date, offset in (rfc, iso, iso2, iso3, alt, alt2):
+            assert_rval(parse_date(date), veri_time_utc, offset)
+        # END for each date type
+
+        # ...and failure.
+        self.assertRaises(ValueError, parse_date, datetime.now())  # Non-aware datetime.
+        self.assertRaises(ValueError, parse_date, "invalid format")
+        self.assertRaises(ValueError, parse_date, "123456789 -02000")
+        self.assertRaises(ValueError, parse_date, " 123456789 -0200")
+
+    def test_actor(self):
+        for cr in (None, self.rorepo.config_reader()):
+            self.assertIsInstance(Actor.committer(cr), Actor)
+            self.assertIsInstance(Actor.author(cr), Actor)
+        # END ensure config reader is handled
+
+    @with_rw_repo("HEAD")
+    @mock.patch("getpass.getuser")
+    def test_actor_get_uid_laziness_not_called(self, rwrepo, mock_get_uid):
+        with rwrepo.config_writer() as cw:
+            cw.set_value("user", "name", "John Config Doe")
+            cw.set_value("user", "email", "jcdoe@example.com")
+
+        cr = rwrepo.config_reader()
+        committer = Actor.committer(cr)
+        author = Actor.author(cr)
+
+        self.assertEqual(committer.name, "John Config Doe")
+        self.assertEqual(committer.email, "jcdoe@example.com")
+        self.assertEqual(author.name, "John Config Doe")
+        self.assertEqual(author.email, "jcdoe@example.com")
+        self.assertFalse(mock_get_uid.called)
+
+        env = {
+            "GIT_AUTHOR_NAME": "John Doe",
+            "GIT_AUTHOR_EMAIL": "jdoe@example.com",
+            "GIT_COMMITTER_NAME": "Jane Doe",
+            "GIT_COMMITTER_EMAIL": "jane@example.com",
+        }
+        os.environ.update(env)
+        for cr in (None, rwrepo.config_reader()):
+            committer = Actor.committer(cr)
+            author = Actor.author(cr)
+            self.assertEqual(committer.name, "Jane Doe")
+            self.assertEqual(committer.email, "jane@example.com")
+            self.assertEqual(author.name, "John Doe")
+            self.assertEqual(author.email, "jdoe@example.com")
+        self.assertFalse(mock_get_uid.called)
+
+    @mock.patch("getpass.getuser")
+    def test_actor_get_uid_laziness_called(self, mock_get_uid):
+        mock_get_uid.return_value = "user"
+        committer = Actor.committer(None)
+        author = Actor.author(None)
+        # We can't test with `self.rorepo.config_reader()` here, as the UUID laziness
+        # depends on whether the user running the test has their global user.name config
+        # set.
+        self.assertEqual(committer.name, "user")
+        self.assertTrue(committer.email.startswith("user@"))
+        self.assertEqual(author.name, "user")
+        self.assertTrue(committer.email.startswith("user@"))
+        self.assertTrue(mock_get_uid.called)
+        self.assertEqual(mock_get_uid.call_count, 2)
+
+    def test_actor_from_string(self):
+        self.assertEqual(Actor._from_string("name"), Actor("name", None))
+        self.assertEqual(Actor._from_string("name <>"), Actor("name", ""))
+        self.assertEqual(
+            Actor._from_string("name last another <some-very-long-email@example.com>"),
+            Actor("name last another", "some-very-long-email@example.com"),
+        )
+
+    @ddt.data(
+        ("name", ""),
+        ("name", "prefix_"),
+    )
+    def test_iterable_list(self, case):
+        name, prefix = case
+        ilist = IterableList(name, prefix)
+
+        name1 = "one"
+        name2 = "two"
+        m1 = _Member(prefix + name1)
+        m2 = _Member(prefix + name2)
+
+        ilist.extend((m1, m2))
+
+        self.assertEqual(len(ilist), 2)
+
+        # Contains works with name and identity.
+        self.assertIn(name1, ilist)
+        self.assertIn(name2, ilist)
+        self.assertIn(m2, ilist)
+        self.assertIn(m2, ilist)
+        self.assertNotIn("invalid", ilist)
+
+        # With string index.
+        self.assertIs(ilist[name1], m1)
+        self.assertIs(ilist[name2], m2)
+
+        # With int index.
+        self.assertIs(ilist[0], m1)
+        self.assertIs(ilist[1], m2)
+
+        # With getattr.
+        self.assertIs(ilist.one, m1)
+        self.assertIs(ilist.two, m2)
+
+        # Test exceptions.
+        self.assertRaises(AttributeError, getattr, ilist, "something")
+        self.assertRaises(IndexError, ilist.__getitem__, "something")
+
+        # Delete by name and index.
+        self.assertRaises(IndexError, ilist.__delitem__, "something")
+        del ilist[name2]
+        self.assertEqual(len(ilist), 1)
+        self.assertNotIn(name2, ilist)
+        self.assertIn(name1, ilist)
+        del ilist[0]
+        self.assertNotIn(name1, ilist)
+        self.assertEqual(len(ilist), 0)
+
+        self.assertRaises(IndexError, ilist.__delitem__, 0)
+        self.assertRaises(IndexError, ilist.__delitem__, "something")
+
+    def test_utctz_to_altz(self):
+        self.assertEqual(utctz_to_altz("+0000"), 0)
+        self.assertEqual(utctz_to_altz("+1400"), -(14 * 3600))
+        self.assertEqual(utctz_to_altz("-1200"), 12 * 3600)
+        self.assertEqual(utctz_to_altz("+0001"), -60)
+        self.assertEqual(utctz_to_altz("+0530"), -(5 * 3600 + 1800))
+        self.assertEqual(utctz_to_altz("-0930"), 9 * 3600 + 1800)
+
+    def test_altz_to_utctz_str(self):
+        self.assertEqual(altz_to_utctz_str(0), "+0000")
+        self.assertEqual(altz_to_utctz_str(-(14 * 3600)), "+1400")
+        self.assertEqual(altz_to_utctz_str(12 * 3600), "-1200")
+        self.assertEqual(altz_to_utctz_str(-60), "+0001")
+        self.assertEqual(altz_to_utctz_str(-(5 * 3600 + 1800)), "+0530")
+        self.assertEqual(altz_to_utctz_str(9 * 3600 + 1800), "-0930")
+
+        self.assertEqual(altz_to_utctz_str(1), "+0000")
+        self.assertEqual(altz_to_utctz_str(59), "+0000")
+        self.assertEqual(altz_to_utctz_str(-1), "+0000")
+        self.assertEqual(altz_to_utctz_str(-59), "+0000")
+
+    def test_from_timestamp(self):
+        # Correct offset: UTC+2, should return datetime + tzoffset(+2).
+        altz = utctz_to_altz("+0200")
+        self.assertEqual(
+            datetime.fromtimestamp(1522827734, tzoffset(altz)),
+            from_timestamp(1522827734, altz),
+        )
+
+        # Wrong offset: UTC+58, should return datetime + tzoffset(UTC).
+        altz = utctz_to_altz("+5800")
+        self.assertEqual(
+            datetime.fromtimestamp(1522827734, tzoffset(0)),
+            from_timestamp(1522827734, altz),
+        )
+
+        # Wrong offset: UTC-9000, should return datetime + tzoffset(UTC).
+        altz = utctz_to_altz("-9000")
+        self.assertEqual(
+            datetime.fromtimestamp(1522827734, tzoffset(0)),
+            from_timestamp(1522827734, altz),
+        )
+
+    def test_pickle_tzoffset(self):
+        t1 = tzoffset(555)
+        t2 = pickle.loads(pickle.dumps(t1))
+        self.assertEqual(t1._offset, t2._offset)
+        self.assertEqual(t1._name, t2._name)
+
+    def test_remove_password_from_command_line(self):
+        username = "fakeuser"
+        password = "fakepassword1234"
+        url_with_user_and_pass = "https://{}:{}@fakerepo.example.com/testrepo".format(username, password)
+        url_with_user = "https://{}@fakerepo.example.com/testrepo".format(username)
+        url_with_pass = "https://:{}@fakerepo.example.com/testrepo".format(password)
+        url_without_user_or_pass = "https://fakerepo.example.com/testrepo"
+
+        cmd_1 = ["git", "clone", "-v", url_with_user_and_pass]
+        cmd_2 = ["git", "clone", "-v", url_with_user]
+        cmd_3 = ["git", "clone", "-v", url_with_pass]
+        cmd_4 = ["git", "clone", "-v", url_without_user_or_pass]
+        cmd_5 = ["no", "url", "in", "this", "one"]
+
+        redacted_cmd_1 = remove_password_if_present(cmd_1)
+        assert username not in " ".join(redacted_cmd_1)
+        assert password not in " ".join(redacted_cmd_1)
+        # Check that we use a copy.
+        assert cmd_1 is not redacted_cmd_1
+        assert username in " ".join(cmd_1)
+        assert password in " ".join(cmd_1)
+
+        redacted_cmd_2 = remove_password_if_present(cmd_2)
+        assert username not in " ".join(redacted_cmd_2)
+        assert password not in " ".join(redacted_cmd_2)
+
+        redacted_cmd_3 = remove_password_if_present(cmd_3)
+        assert username not in " ".join(redacted_cmd_3)
+        assert password not in " ".join(redacted_cmd_3)
+
+        assert cmd_4 == remove_password_if_present(cmd_4)
+        assert cmd_5 == remove_password_if_present(cmd_5)
diff --git a/test/tstrunner.py b/test/tstrunner.py
new file mode 100644
index 000000000..fc9a59c8c
--- /dev/null
+++ b/test/tstrunner.py
@@ -0,0 +1,13 @@
+# This module is part of GitPython and is released under the
+# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
+
+"""Hook for MonkeyType (see PR #1188)."""
+
+import unittest
+
+loader = unittest.TestLoader()
+start_dir = "."
+suite = loader.discover(start_dir)
+
+runner = unittest.TextTestRunner()
+runner.run(suite)
diff --git a/tox.ini b/tox.ini
index a3509756d..fc62fa587 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,23 +1,50 @@
 [tox]
-envlist = py26,py27,py33,py34,flake8
+requires = tox>=4
+env_list = py{37,38,39,310,311,312}, ruff, format, mypy, html, misc
 
 [testenv]
-commands = nosetests {posargs}
-deps = -r{toxinidir}/requirements.txt
-       -r{toxinidir}/test-requirements.txt
+description = Run unit tests
+package = wheel
+extras = test
+pass_env = SSH_*
+commands = pytest --color=yes {posargs}
 
-[testenv:cover]
-commands = nosetests --with-coverage {posargs}
+[testenv:ruff]
+description = Lint with Ruff
+base_python = py{39,310,311,312,38,37}
+deps = ruff
+set_env =
+    CLICOLOR_FORCE = 1  # Set NO_COLOR to override this.
+commands = ruff check .
 
-[testenv:flake8]
-commands = flake8 {posargs}
+[testenv:format]
+description = Check formatting with Ruff
+base_python = py{39,310,311,312,38,37}
+deps = ruff
+set_env =
+    CLICOLOR_FORCE = 1  # Set NO_COLOR to override this.
+commands = ruff format --check .
 
-[testenv:venv]
-commands = {posargs}
+[testenv:mypy]
+description = Typecheck with mypy
+base_python = py{39,310,311,312,38,37}
+set_env =
+    MYPY_FORCE_COLOR = 1
+commands = mypy
+ignore_outcome = true
 
-[flake8]
-#show-source = True
-# E265 = comment blocks like @{ section, which it can't handle
-ignore = E265
-max-line-length = 120
-exclude = .tox,.venv,build,dist,doc,git/ext/
+[testenv:html]
+description = Build HTML documentation
+base_python = py{39,310,311,312,38,37}
+extras = doc
+allowlist_externals = make
+commands =
+    make BUILDDIR={env_tmp_dir}/doc/build -C doc clean
+    make BUILDDIR={env_tmp_dir}/doc/build -C doc html
+
+[testenv:misc]
+description = Run other checks via pre-commit
+base_python = py{39,310,311,312,38,37}
+set_env =
+    SKIP = ruff-format,ruff
+commands = pre-commit run --all-files
