Git index file parser, using python3
The
ginscript parses the databases that live at
.git/indexin any Git repository, and shows the contents in a readable form, or as a JSON dump. These databases store the current state of the stage area, sometimes called the index or cache.
pip3 install gin
Or clone this repo and use the
ginscript.
Or download the script directly.
The script requires Python 3.
usage: gin [-h] [-j] [-v] [path]parse a Git index file
positional arguments: path path to a Git repository or index file
optional arguments: -h, --help show this help message and exit -j, --json output JSON -v, --version show script version number
Show the Git index file in the current repository, if in the repository root:
gin
Show the Git index file in the
~/git-reporepository:
gin ~/git-repo
Show the Git index file
~/git-repo/.git/index:
gin ~/git-repo/.git/index
The script supports index file versions 2 and 3, and will skip over extensions.
Use the
-jor
--jsonflags to dump JSON.
To use the script as a module, rename it to
gin.py.
Submit issues on Github.
Tweet @sbp with short comments or enquiries.
$ gin test/01.index
Output:
[header] signature = DIRC version = 3 entries = 5[entry] entry = 1 ctime = 1363549359.0 mtime = 1363549359.0 dev = 16777217 ino = 1154043 mode = 100644 uid = 501 gid = 20 size = 6 sha1 = d5f7fc3f74f7dec08280f370a975b112e8f60818 flags = 9 assume-valid = False extended = False stage = (False, False) name = added.txt
[...]
[checksum] checksum = True sha1 = 1ef0972eb948e6229240668effcb9c600fe5888d
$ gin | egrep '^ name ='
Output:
name = .gitignore name = MANIFEST name = Makefile name = README.md name = gin name = setup.py name = test/01.index name = test/01.json name = test/01.txt name = test/run
Which should be equivalent to
git ls-files.