
Using Askgit – A SQL interface to your Git repository - pcr910303
https://willschenk.com/articles/2020/using_askgit/
======
andreypopp
What would be nice is to add to this a way to plug language specific semantic
analysers. Then it could be possible to do queries like "which commits did
changes to a specific function" and so on.

~~~
mattigames
I have always wondered why GitHub doesn't add such functionality, its a no-
brainer how much it would help to have a way to right-click a function and see
how has it changed through history, it could use an interface where you scroll
through time (eg the most you scroll the older versions you see, until you
reach when it was created); same thing for files.

~~~
oefrha
Presumably you’ve heard about git-blame, which is available on GitHub.

~~~
mattigames
Yeah, I find it of little use due being syntax agnostic (e.g can't tell me
about the changes on a function because it doesn't know what a function is).
If you are taking about me asking the same for "files" I meant being able to
see all the versions of a file in a single page (maybe using "infinite scroll"
in case there are too many)

------
gigatexal
I’m an absolute fanboy of all the efforts to bolt on SQL interfaces to things.
I love this. Kudos to the creator.

~~~
cube2222
If you like this, check out OctoSQL[0], it bolts on SQL on json, CSV, Excel
and Parquet files.

It also let's you join them with each other (and other databases).

[0]:[https://github.com/cube2222/octosql](https://github.com/cube2222/octosql)

~~~
sirodoht
There is also xsv [0] for CSV SQLing

[0] [https://github.com/BurntSushi/xsv](https://github.com/BurntSushi/xsv)

~~~
gigatexal
For this and the above +1 to you both and thanks.

------
shoo
It'd be interesting to see some examples of queries that operate on the graph
structure of the repo.

mercurial offers a language where you can build expressions to select revsets:

E.g.

> Changesets mentioning "bug" or "issue" that are not in a tagged release:

hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tag())"

[https://hg.mozilla.org/mozilla-
central/help/revsets](https://hg.mozilla.org/mozilla-central/help/revsets)

------
bravura
What are good APIs to git, besides git itself? Something high level,
ergonomic, and with write operations, not just querying?

~~~
gru
libgit2[0] has a comprehensive API and bindings for dozens of languages.

I also like go-git[1] - a pure Go implementation with idiomatic Go API and
cool features like in-memory filesystem.

[0] [https://libgit2.org/](https://libgit2.org/)

[1] [https://github.com/go-git/go-git](https://github.com/go-git/go-git)

------
danielbigham
This is really nice. I experimented converting natural language to git log
commands this week
([https://twitter.com/danielbigham/status/1294461750251839489](https://twitter.com/danielbigham/status/1294461750251839489)),
but mapping natural language to git sql might be better and more flexible in
some cases.

------
burstmode
If adding a SQL interface makes a system easier to access, that says a lot
about how convoluted the original interface is...

Next logical step : a kernel level SQL interpreter integrated in systemd.

~~~
jarym
Actually I think it says a lot about how expressive SQL is.

I get why a lot of developers take swipes at SQL - it is a bit different to
other languages. But you cannot beat it for what it does.

Another ‘great’ language is XSLT - so far I’ve seen nothing else that comes
close for transforming data. It’s just a shame it’s so closely tied to XML
which has understandably fallen out of favour

