Skip to content

Commit

Permalink
reformatting readme
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Dec 9, 2009
1 parent bb58a0d commit ad3e7c0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ Basic API


First you initialize a Git object with the path to a Git repository: First you initialize a Git object with the path to a Git repository:


Git = git:open("test_git") Git = git:open("test_git")


You can get the type, size and data for any object in Git with the You can get the type, size and data for any object in Git with the
git:object_data call: git:object_data call:


{Type, Size, Data} = git:object_data(Git, "8d47f3435ce5dfd0b2ab5758590c2db21b5294b4") {Type, Size, Data} = git:object_data(Git, "8d47f3435ce5dfd0b2ab5758590c2db21b5294b4")


Type is a term (one of commit, tree, blob, tag), Size is an int of the size of Type is a term (one of commit, tree, blob, tag), Size is an int of the size of
the object and Data is a binary of the object data. the object and Data is a binary of the object data.


You can use object_exists to get a true/false back as to if a given object You can use object_exists to get a true/false back as to if a given object
exists in the database. exists in the database.


Result = git:object_exists(Git, "8d47f3435ce5dfd0b2ab5758590c2db21b5294b4") Result = git:object_exists(Git, "8d47f3435ce5dfd0b2ab5758590c2db21b5294b4")


You can get a topographically ordered listing of the commit SHAs reachable You can get a topographically ordered listing of the commit SHAs reachable
froma given array of commit SHAs with the git:rev_list command froma given array of commit SHAs with the git:rev_list command


RevList = git:rev_list(Git, ["25daa907ccb6feb267bfec70a130d5fe13e48a79"]) RevList = git:rev_list(Git, ["25daa907ccb6feb267bfec70a130d5fe13e48a79"])


That command will return an array of commit SHA strings: That command will return an array of commit SHA strings:


RevList: ["25daa907ccb6feb267bfec70a130d5fe13e48a79", RevList: ["25daa907ccb6feb267bfec70a130d5fe13e48a79",
"dd991a4966e8807d448305e67a9b3727efc6060c", "dd991a4966e8807d448305e67a9b3727efc6060c",
"be62addb149d286893e2ec254e0dc783a871e8af", "be62addb149d286893e2ec254e0dc783a871e8af",
"208fc4a6a08fb1e5136cf9943d79ad81097a0f36", "208fc4a6a08fb1e5136cf9943d79ad81097a0f36",
Expand All @@ -48,11 +48,11 @@ That command will return an array of commit SHA strings:
You can get formatted data back for tree and commit objects (and blobs, but it You can get formatted data back for tree and commit objects (and blobs, but it
just returns a string of the blob) with the git:object/2 call just returns a string of the blob) with the git:object/2 call


{ok, Commit} = git:object(Git, "25daa907ccb6feb267bfec70a130d5fe13e48a79") {ok, Commit} = git:object(Git, "25daa907ccb6feb267bfec70a130d5fe13e48a79")


That will return a Commit object who's record looks like this: That will return a Commit object who's record looks like this:


-record(commit, {sha, parents, tree, -record(commit, {sha, parents, tree,
author, committer, encoding, message}). author, committer, encoding, message}).


So you can then get the array of parent SHAs with Commit#commit.parents, or So you can then get the array of parent SHAs with Commit#commit.parents, or
Expand All @@ -61,25 +61,25 @@ the commit message with Commit#commit.message.
If you run git:object/2 with a tree SHA, it will give you back an array of If you run git:object/2 with a tree SHA, it will give you back an array of
tree entries, each of which is a tree record: tree entries, each of which is a tree record:


-record(tree, {mode, name, sha}). -record(tree, {mode, name, sha}).


IO Git API IO Git API
=================== ===================


There are also a few output functions to help look at the data returned. You There are also a few output functions to help look at the data returned. You
can get the equivalent of the 'git log' output with the git_io:print_log command. can get the equivalent of the 'git log' output with the git_io:print_log command.


git_io:print_log(Git, ["25daa907ccb6feb267bfec70a130d5fe13e48a79"]) git_io:print_log(Git, ["25daa907ccb6feb267bfec70a130d5fe13e48a79"])


That will print to stdout something like this: That will print to stdout something like this:


commit 61fa970afbf82f79611220203213cd9562a809e3 commit 61fa970afbf82f79611220203213cd9562a809e3
Author: Scott Chacon <schacon@gmail.com> 1258278496 +0100 Author: Scott Chacon <schacon@gmail.com> 1258278496 +0100


added test one added test one


commit a361a3163a1b521f277e3877232d94b787750c36 commit a361a3163a1b521f277e3877232d94b787750c36
Author: Scott Chacon <schacon@gmail.com> 1258278448 +0100 Author: Scott Chacon <schacon@gmail.com> 1258278448 +0100


first commit first commit


0 comments on commit ad3e7c0

Please sign in to comment.