Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Files are deleted after commit #132

Closed
tonini opened this Issue · 2 comments

3 participants

@tonini

Hi,

After trying one of the examples all the files are deleted in the repository (marked as ready to be commited):

require 'grit'

count = 1
Dir.chdir("localstore") do
  r = Grit::Repo.new('.')
  i = r.index
  while(count < 10) do
    fname = Time.now.to_i.to_s + count.to_s
    i.add(fname, 'hello ' + fname)
    count += 1
  end
  count = 5
  while(count < 10) do
    puts "HELLO"
    fname = Time.now.to_i.to_s + count.to_s
    i.add('test/' + fname, 'hello ' + fname)
    count += 1
  end
  puts i.commit('my commit')
  puts i.inspect
end

Git Version => 1.7.4.2 (maybe that's the problem?)

@whitehat101

This is a case of advanced git use and a poorly commented example.

No files are created in this test. However the git index is modified. The contents of the files are supplied as strings in i.add(fname, 'hello ' + fname). The index is committed, but since files weren't created in the first place they become 'deleted' because they are not in the repo.

If you run git checkout master in the repo after running the example, you will see what you expected.

@bkeepers
Collaborator

Grit is no longer maintained. See #183 and check out libgit2/rugged.

@bkeepers bkeepers closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.