Skip to content

Commit 219fb35

Browse files
author
scott Chacon
committed
added test for bare repo
1 parent 0e5c332 commit 219fb35

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

TODO

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
* more documentation
22

3-
* git revert, stash, rebase
43

54
* more low level index actions
65
- (with_index), checkout-index, read-tree, write-tree, update-ref
76

8-
* submodule support
7+
* git revert, stash, rebase
98

109
* diff additions
1110
- annotate, blame
1211

12+
13+
* submodule support
14+
1315
* repository admin
1416
- prune, fsck, pack-refs, gc, count-objects, unpack-objects
1517

lib/git/lib.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class Lib
1515
def initialize(base = nil)
1616
if base.is_a?(Git::Base)
1717
@git_dir = base.repo.path
18-
@git_index_file = base.index.path
19-
@git_work_dir = base.dir.path
18+
@git_index_file = base.index.path if base.index
19+
@git_work_dir = base.dir.path if base.dir
2020
elsif base.is_a?(Hash)
2121
@git_dir = base[:repository]
2222
@git_index_file = base[:index]
@@ -389,17 +389,32 @@ def command_lines(cmd, opts = {})
389389

390390
def command(cmd, opts = {})
391391
ENV['GIT_DIR'] = @git_dir
392-
ENV['GIT_INDEX_FILE'] = @git_index_file
393-
ENV['GIT_WORK_DIR'] = @git_work_dir
392+
393+
if @git_index_file
394+
ENV['GIT_INDEX_FILE'] = @git_index_file
395+
else
396+
ENV['GIT_INDEX_FILE'].delete rescue nil
397+
end
398+
399+
if @git_work_dir
400+
ENV['GIT_WORK_TREE'] = @git_work_dir if @git_work_dir
401+
else
402+
ENV['GIT_WORK_TREE'].delete rescue nil
403+
end
404+
394405
path = @git_work_dir || @git_dir || @path
395406
Dir.chdir(path) do
396407
opts = opts.to_a.join(' ')
397408
git_cmd = "git #{cmd} #{opts}"
398409
out = `git #{cmd} #{opts} 2>&1`.chomp
399410
#puts path
411+
#puts "gr: #{@git_dir}"
400412
#puts "gd: #{@git_work_dir}"
401413
#puts "gi: #{@git_index_file}"
402414
#puts "pp: #{@path}"
415+
#puts ENV['GIT_DIR']
416+
#puts ENV['GIT_WORK_TREE']
417+
#puts ENV['GIT_INDEX_FILE']
403418
#puts git_cmd
404419
#puts out
405420
#puts
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
545ffc79786f268524c35e1e05b1770c7c74faf1
1+
5e392652a881999392c2757cf9b783c5d47b67f7

0 commit comments

Comments
 (0)