Method: Rugged::Index#get
- Defined in:
- ext/rugged/rugged_index.c
permalink #[](path[, stage = 0)) ⇒ nil #[](position) ⇒ nil #get(path[, stage = 0]) ⇒ nil #get(position) ⇒ nil
Return a specific entry in the index.
The first two forms returns entries based on their path
in the index and an optional stage
, while the last two forms return entries based on their position in the index.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'ext/rugged/rugged_index.c', line 144
static VALUE rb_git_index_get(int argc, VALUE *argv, VALUE self)
{
git_index *index;
const git_index_entry *entry = NULL;
VALUE rb_entry, rb_stage;
Data_Get_Struct(self, git_index, index);
rb_scan_args(argc, argv, "11", &rb_entry, &rb_stage);
if (TYPE(rb_entry) == T_STRING) {
int stage = 0;
if (!NIL_P(rb_stage)) {
Check_Type(rb_stage, T_FIXNUM);
stage = FIX2INT(rb_stage);
}
entry = git_index_get_bypath(index, StringValueCStr(rb_entry), stage);
}
else if (TYPE(rb_entry) == T_FIXNUM) {
if (argc > 1) {
rb_raise(rb_eArgError,
"Too many arguments when trying to lookup entry by index");
}
entry = git_index_get_byindex(index, FIX2INT(rb_entry));
} else {
rb_raise(rb_eArgError,
"Invalid type for `entry`: expected String or Fixnum");
}
return entry ? rb_git_indexentry_fromC(entry) : Qnil;
}
|