Method: Rugged::Index.new

Defined in:
ext/rugged/rugged_index.c

.new([path]) ⇒ Object

Create a bare index object based on the index file at path.

Any index methods that rely on the ODB or a working directory (e.g. #add) will raise a Rugged::IndexError.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'ext/rugged/rugged_index.c', line 46

static VALUE rb_git_index_new(int argc, VALUE *argv, VALUE klass)
{
  git_index *index;
  int error;

  VALUE rb_path;
  const char *path = NULL;

  if (rb_scan_args(argc, argv, "01", &rb_path) == 1) {
    Check_Type(rb_path, T_STRING);
    path = StringValueCStr(rb_path);
  }

  error = git_index_open(&index, path);
  rugged_exception_check(error);

  return rugged_index_new(klass, Qnil, index);
}