Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

stub out revlist functionality

  • Loading branch information...
commit df877612f9ff9658f57b25f32ce2763862951233 1 parent 84e32a7
@schacon authored
View
18 src/git.erl
@@ -3,9 +3,9 @@
%%
-module(git).
--export([open/1, read_object/2, object_exists/2]).
+-export([open/1, read_object/2, object_exists/2, rev_list/2]).
--include("packindex.hrl").
+-include("git.hrl").
%%-define(cassandra_ZERO, 0).
@@ -30,6 +30,20 @@ open(Path) ->
% traverse the reference, printing out all the log information to stdout
%io:fwrite("Log:~n").
+rev_list(Git, Shas) ->
+ rev_list(Git, Shas, []).
+
+rev_list(Git, [Sha|Shas], Gathered) ->
+ Commit = commit(Git, Sha),
+ Parents = git_object:get_parents(Commit),
+ rev_list(Git, Parents ++ Shas, [Sha|Gathered]);
+rev_list(Git, [], Gathered) ->
+ Gathered.
+
+commit(Git, Sha) ->
+ {Type, Size, Data} = read_object(Git, Sha),
+ git_object:parse_commit(Data).
+
git_dir(Git) ->
{Path} = Git,
Path.
View
0  src/packindex.hrl → src/git.hrl
File renamed without changes
View
14 src/git_object.erl
@@ -0,0 +1,14 @@
+%%
+%% Partial Git Implementation
+%%
+
+-module(git_object).
+-export([parse_commit/1, get_parents/1]).
+
+parse_commit(Data) ->
+ io:format("Commit: ~p~n", [Data]),
+ Data.
+
+get_parents(Commit) ->
+ [].
+
View
5 src/packindex.erl
@@ -5,7 +5,7 @@
-module(packindex).
-export([extract_packfile_index/1, object_offset/2]).
--include("packindex.hrl").
+-include("git.hrl").
%%%
% get an object offset from an index record
@@ -33,7 +33,7 @@ extract_packfile_index(Data) ->
{OffsetList, Data7} = extract_offsets(Data6, Size),
{PackCs, Data8} = split_binary(Data7, 20),
{_IdxCs, _Empty} = split_binary(Data8, 20),
- Index = #index{header=Header, version=Version, size=Size, fanout=FanoutTable,
+ Index = #index{header=Header, version=Version, size=Size, fanout=FanoutTable,
shalist=ShaList, crclist=CrcList, offsets=OffsetList, packcs=hex:bin_to_hexstr(PackCs)},
{ok, Index}.
@@ -85,3 +85,4 @@ extract_fanout(IndexData, Count, Fanout) ->
{Fan, IndexDataRem} = split_binary(IndexData, 4), % fanout entry
<<FanInt:32>> = Fan,
extract_fanout(IndexDataRem, Count + 1, [FanInt|Fanout]).
+
View
9 t/006-rev-list.t
@@ -0,0 +1,9 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+%%! -pa ./ebin -sasl -boot start_sasl -noshell
+
+main(_) ->
+ Git = git:open("test_git"),
+ RevList = git:rev_list(Git, ["25daa907ccb6feb267bfec70a130d5fe13e48a79"]), %% blob
+ io:fwrite("RevList: ~p~n", [RevList]).
+
Please sign in to comment.
Something went wrong with that request. Please try again.