@@ -26,9 +26,9 @@ SELECT * FROM refs WHERE ref_name = 'HEAD'
2626``` sql
2727SELECT * FROM (
2828 SELECT COUNT (c .commit_hash ) AS num, c .commit_hash
29- FROM refs r
29+ FROM ref_commits r
3030 INNER JOIN commits c
31- ON history_idx( r .commit_hash , c .commit_hash ) >= 0
31+ ON r .commit_hash = c .commit_hash
3232 GROUP BY c .commit_hash
3333) t WHERE num > 1
3434```
@@ -37,11 +37,11 @@ SELECT * FROM (
3737
3838``` sql
3939SELECT COUNT (c .commit_hash ), c .commit_hash
40- FROM refs r
40+ FROM ref_commitss r
4141INNER JOIN commits c
42- ON r .ref_name = ' HEAD' AND history_idx( r .commit_hash , c .commit_hash ) >= 0
43- INNER JOIN blobs b
44- ON commit_has_blob( c .commit_hash , b .commit_hash )
42+ ON r .ref_name = ' HEAD' AND r .commit_hash = c .commit_hash
43+ INNER JOIN commit_blobs cb
44+ ON cb .commit_hash = c .commit_hash
4545GROUP BY c .commit_hash
4646```
4747
@@ -54,11 +54,10 @@ FROM (
5454 MONTH(committer_when) as month,
5555 r .repository_id as repo_id,
5656 committer_email
57- FROM repositories r
58- INNER JOIN refs
59- ON refs .repository_id = r .repository_id AND refs .ref_name = ' HEAD'
60- INNER JOIN commits c
61- ON YEAR(committer_when) = 2015 AND history_idx(refs .commit_hash , c .commit_hash ) >= 0
57+ FROM ref_commits r
58+ INNER JOIN commits c
59+ ON YEAR(c .committer_when ) = 2015 AND r .commit_hash = c .commit_hash
60+ WHERE r .ref_name = ' HEAD'
6261) as t
6362GROUP BY committer_email, month, repo_id
6463```
@@ -136,22 +135,21 @@ gitbase exposes the following tables:
136135| repositories | repository_id |
137136| remotes | repository_id, remote_name, remote_push_url, remote_fetch_url, remote_push_refspec, remote_fetch_refspec |
138137| commits | repository_id, commit_hash, commit_author_name, commit_author_email, commit_author_when, committer_name, committer_email, committer_when, commit_message, tree_hash |
139- | blobs | repository_id, blob_hash, blob_size, blob_content |
140- | refs | repository_id, ref_name, commit_hash |
141- | tree_entries | repository_id, tree_hash, blob_hash, tree_entry_mode, tree_entry_name |
142- | references | repository_id, ref_name, commit_hash |
143- | ref_commits | repository_id, commit_hash, ref_name, index |
144- | commit_trees | repository_id, commit_hash, tree_hash |
138+ | blobs | repository_id, blob_hash, blob_size, blob_content |
139+ | refs | repository_id, ref_name, commit_hash |
140+ | ref_commits | repository_id, ref_name, commit_hash, index |
141+ | tree_entries | repository_id, tree_hash, blob_hash, tree_entry_mode, tree_entry_name |
142+ | references | repository_id, ref_name, commit_hash |
143+ | commit_trees | repository_id, commit_hash, tree_hash |
144+ | commit_blobs | repository_id, commit_hash, blob_hash |
145+ | files | repository_id, file_path, blob_hash, tree_hash, tree_entry_mode, blob_content, blob_size |
145146
146147## Functions
147148
148149To make some common tasks easier for the user, there are some functions to interact with the previous mentioned tables:
149150
150151| Name | Description |
151152| :-------------| :----------------------------------------------------------------------------------------------------|
152- | commit_has_blob(commit_hash,blob_hash)bool| get if the specified commit contains the specified blob |
153- | commit_has_tree(commit_hash,tree_hash)bool| get if the specified commit contains the specified tree |
154- | history_idx(start_hash, target_hash)int| get the index of a commit in the history of another commit |
155153| is_remote(reference_name)bool| check if the given reference name is from a remote one |
156154| is_tag(reference_name)bool| check if the given reference name is a tag |
157155| language(path, [ blob] )text| gets the language of a file given its path and the optional content of the file |
0 commit comments