# index-of-git

> Maintain a mapping from some SHA to files somewhere in the history of a git repo

Latest version **1.0.0** (published 2018-12-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install index-of-git
pnpm add index-of-git
yarn add index-of-git
bun add index-of-git
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-12-04 |
| First published | 2018-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| Author | Sandro Hawke |
| Maintainers | sandhawke |
| Keywords | git, version, integrity, sha256, hash, cache |

## Links

- npm: https://www.npmjs.com/package/index-of-git
- Repository: https://github.com/sandhawke/index-of-git
- Homepage: https://github.com/sandhawke/index-of-git#readme
- Issues: https://github.com/sandhawke/index-of-git/issues
- npm.io page: https://npm.io/package/index-of-git

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^4.1.0
- [vihash](https://npm.io/package/vihash.md) ^1.1.0
- [simple-git](https://npm.io/package/simple-git.md) ^1.107.0

## Recent versions

- 1.0.0 (latest) — 2018-12-04

## README

# index-of-git
[![NPM version][npm-image]][npm-url]

Given the SHA of a file that existed at any point in the history of a
git repo, find the text of that file.  This module maintains an
in-memory index to make that search fast.  It could easily be extended
to keep a persistent index, if that turns out to be worthwhile.

It does not currently provide the commit + filename information,
because I don't need that, and it would be a bit more work because
we'd need to track **all** the commit + filename pairs which had
matching content.  And would you want the commits where the filename
didn't change, but still had that content?

## API

```js
const Index = require('index-of-git')

const options = {
      // gitroot: where your repo is, default CWD
      // git: or your own simple-git instance
      // hasher: your own hash function, default vihash
      // variants: lists of argument lists for hasher, default sha256, sha512
}
const ix = new Index(options)

const text = await ix.get('sha256-47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU=')
//  => '' since that's the sha256 of the null string, if there's an empty
//     file anywhere in the repo history
//  => undefined  if there's no empty file anywhere in the repo history

```

[npm-image]: https://img.shields.io/npm/v/index-of-git.svg?style=flat-square
[npm-url]: https://npmjs.org/package/index-of-git

---
_Source: https://npm.io/package/index-of-git · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
