Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit c68b42cac009853ac31340998142c3e7084b168e 0 parents
@schacon authored
1  .gitignore
@@ -0,0 +1 @@
+ebin
17 README
@@ -0,0 +1,17 @@
+ergit
+====================
+
+ergit cat-file (commit, tree, blob, tag)
+
+ergit log
+
+ergit status
+ergit diff
+
+ergit add
+ergit stage
+ergit commit
+
+ergit push
+
+ergit serve
9 Rakefile
@@ -0,0 +1,9 @@
+require 'rubygems'
+require 'rake'
+
+ERLC_FLAGS = "+debug_info -W2 -o ../ebin"
+
+task :default do
+ cd "src"
+ sh "erlc #{ERLC_FLAGS} *.erl"
+end
28 src/git.erl
@@ -0,0 +1,28 @@
+%%
+%% Partial Git Implementation
+%%
+
+-module(git).
+-export([open/1, read_object/2]).
+
+%%-define(cassandra_ZERO, 0).
+
+%-record(git_dir, {path}).
+%-record(commit, {commit_sha, tree_sha, parents, author, committer, encoding, message}).
+
+% Cp = #commit{sha=Sha, tree=Tree},
+
+open(Path) ->
+ %% normalize the path (look for .git, etc)
+ {Path}.
+
+read_object(Git, ObjectSha) ->
+ %% find object path (loose)
+ %% read object data
+ %% de-header it
+ %% de-zlib it
+ %% return object data
+ Type = commit,
+ Size = 355,
+ Data = <<"hello">>,
+ {Type, Size, Data}.
8 t/001-cat-file.t
@@ -0,0 +1,8 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+%%! -pa ./ebin -sasl -boot start_sasl -noshell
+
+main(_) ->
+ Git = git:open("/Users/schacon/projects/subsucka/.git"),
+ {Type, Size, _} = git:read_object(Git, "019b03b2b5f184a9bbec13bfb4be53b80561f213"), %% blob
+ io:fwrite("Data: ~p ~p~n", [Type, Size]).
Please sign in to comment.
Something went wrong with that request. Please try again.