3 # This is a command line client that can do a number of read operations
4 # on a git repository in pure ruby. This may be helpful if you have access
5 # to a computer that has no C compiler but you want to do some git stuff
6 # on it. It's also helpful for me to test Git stuff with.
8 # author : Scott Chacon (schacon@gmail.com)
23 puts
'You have to provide a command'
24 puts
'usage: gitr (command) [args]'
28 puts
' cat-file (treeish)'
29 puts
' rev-parse (treeish)'
32 puts
' ls-tree (tree)'
36 git_dir
= ENV['GIT_DIR'] || '.git'
37 #@git = Git.bare(git_dir, :log => Logger.new(STDOUT))
38 @git = Git
.bare(git_dir
)
44 puts
'commit ' + l
.sha
53 puts
@git.cat_file(ARGV[1])
56 puts
@git.revparse(ARGV[1])
62 @git.config
.sort
.each
do |k
,v
|
67 tree
= @git.gtree(ARGV[1])
68 tree
.blobs
.sort
.each
do |name
, c
|
69 puts
[[c
.mode
, c
.type
, c
.sha
].join(" "), name
].join("\t")
71 tree
.trees
.sort
.each
do |name
, c
|
72 puts
[[c
.mode
, c
.type
, c
.sha
].join(" "), name
].join("\t")