Live data from Hacker News

A Git query language

github.com

41–50 of 72 posts

Re: A Git query language

#41
post #38
post #36

Earlier quoted context omitted.

I believe the goal is to get a diff, not a list of commits, in which case you need to figure out an expression for getting the last commit common to master and experiment so you can diff it with experiment.

`git diff master..experiment`

I just tried that, and it seems to be the same as `git diff master experiment`. We don't want to diff the two heads. The command in Mercurial is `hg diff -r 'ancestor(master, experiment)' -r experiment`. Comrade trolor seems to have found the correct git expression.

Re: A Git query language

#42
post #40

Oh I love that the example gif includes: select author, message from commits where 'Fuck' in message I'm pretty sure that query's results would fill my screen buffer.

Just for comparison, in Mercurial you would do

   hg log --template "{author}, {desc}\n" --rev "desc('fuck')"

Re: A Git query language

#43
post #37
post #26

Earlier quoted context omitted.

Complete guess based on [1], but wouldn't git diff HEAD $(git merge-base HEAD master) work? [1]: https://stackoverflow.com/questions/1549146/find-common-ance...

This requires using bash. I find it kind of cheating that git ships bash on Windows so that Windows users can rely on bash for composing git commands. I'm not sure if Windows users are generally that happy about typing bash commands, but I guess nobody really cares what you have to type in as long as it's high in the Google hits for whatever operation you want to perform. Mercurial's API (i.e. the CLI) makes a point…

Another way to look at this is that hg needed to bake this into their core, whereas git didn't need to. There is a non-zero cost to all additional code, so leaning on the shell to do work is generally a smart move.

Re: A Git query language

#44
post #37
post #26

Earlier quoted context omitted.

Complete guess based on [1], but wouldn't git diff HEAD $(git merge-base HEAD master) work? [1]: https://stackoverflow.com/questions/1549146/find-common-ance...

This requires using bash. I find it kind of cheating that git ships bash on Windows so that Windows users can rely on bash for composing git commands. I'm not sure if Windows users are generally that happy about typing bash commands, but I guess nobody really cares what you have to type in as long as it's high in the Google hits for whatever operation you want to perform. Mercurial's API (i.e. the CLI) makes a point…

Git ships with Git Bash on Windows.

Re: A Git query language

#46
post #33
post #19

This might benefit from SQLite's Virtual tables: https://sqlite.org/vtab.html With Virtual Tables you can expose any data source as a SQLite table -- then you can use every SQL feature that sqlite offers. You can just tell sqlite how to iterate through your data with a few functions, with an option to push down filtering information for efficiency. You can also create your own aggregates, functions etc. Here's an art…

My thoughts went straight to PostgreSQL Foreign Data Wrappers. Something like that would be really helpful!

Wouldn't that require a running Postgres server, though? Seems a bit heavy for ad hoc queries.

For something like a GitLab server, though, that would be amazing.

Re: A Git query language

#47
If you actually want to query git data in production, it's really a better idea to copy all the data into a real SQL data warehouse. If you're using github, my company (Fivetran.com) has a connector that pulls from their API.

Re: A Git query language

#48
post #41
post #38

Earlier quoted context omitted.

`git diff master..experiment`

I just tried that, and it seems to be the same as `git diff master experiment`. We don't want to diff the two heads. The command in Mercurial is `hg diff -r 'ancestor(master, experiment)' -r experiment`. Comrade trolor seems to have found the correct git expression.

Try

    git diff master...experiment
(note there's three periods)

Re: A Git query language

#49

Imagine if we could just have this automatically for every program that generated text output. It doesn't seem beyond the realms of possibility that every tool could either a) structure its text output in a way that can guarantee simple command-piping to a general purpose query-language processing tool or b) in the presence of a "--output-json" flag, produce json which can then easily be queried.

It's the UNIX principle/tradition that line oriented text is the universal format. It's quite flexible. But I share your feeling, and I keep hearing nice things about powershell.

Also, if you work with CSV files, look at textql.

Re: A Git query language

#50
post #27
post #12

Earlier quoted context omitted.

https://github.com/gitql/gitql (last commit 12 days ago)

Not the same project (look at the number of commits, and the top issue).

I was responding to:

> interesting, I mean the fact that this _or something similar_ didn't get traction

I think you'll agree this is something very similar and that has traction.

Post reply on HN