I am attempting to use Rugged::Index #add to add a new file to the index. It seems to be successfully added to the index but the associated Rugged::Repository #status is cleared for the given file.
Example IRB session showing my attempt to add file "TEST_JJV_IRB1"
>> path = "TEST_JJV_IRB1"
=> "TEST_JJV_IRB1"
>> FileUtils.touch("#{local_repo}/#{path}")
=> ["/var/tmp/d20141015-95025-c5bbxe/TEST_JJV_IRB1"]
>> repo.inspect
=> "#<Rugged::Repository:70155837868280 {path: \"/private/var/tmp/d20141015-95025-c5bbxe/.git/\"}>"
The newly created file, "TEST_JJV_IRB1", is correctly reported by Rugged::Repository #status
>> repo.status(path)
=> [:worktree_new]
and correctly not included in the Rugged::Index
>> index = repo.index
=> #<Rugged::Index
[0] 'a_file'
[0] 'b_file'
[0] 'c_file'
Here I attempt to add the new file to the index.
>> oid = Rugged::Blob.from_workdir repo, path
=> "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
>> index.add(:path => path, :oid => oid, :mode => 0100644)
=> nil
>> index.write
=> nil
The file being added, "TEST_JJV_IRB1", is now correctly included in the index.
>> repo.index
=> #<Rugged::Index
[0] 'a_file'
[0] 'b_file'
[0] 'c_file'
[0] 'TEST_JJV_IRB1'
But it's status reported as cleared by Rugged::Repository #status
>> repo.status(path)
=> []
I would expect Rugged::Repository #status to report [:index_new]
Oddly the issuing git status
from the command line shows the new
file, "TEST_JJV_IRB1", as "Changes to be committed:"
% git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: TEST_JJV_IRB1