Method: Rugged::Index#add_all
- Defined in:
- ext/rugged/rugged_index.c
permalink #add_all(pathspec = [][, options]) ⇒ nil #add_all(pathspec = [][, options]) {|path, pathspec| ... } ⇒ nil
Add or update index entries matching files in the working directory.
Searches the working directory for files that pathspec
and adds them to index
(by updating an existing entry or adding a new entry).
pathspec
can either be a String, or an Array of Strings. If pathspec
is empty, all entries in the index will be matched.
Files that are ignored due to .gitignore
rules will be skipped, unless they’re already have an entry in index
.
Files that are marked as the result of a merge request, will have this marking removed and the merge conflict information will be moved into the “resolve undo” (REUC) section of index
.
If a block is given, each matched path
and the pathspec
that matched it will be passed to the block. If the return value of block
is falsy, the matching item will not be added to the index.
This method will fail in bare index instances.
The following options can be passed in the options
Hash:
- :force
-
If
true
, any.gitignore
rules will be ignored. - :disable_pathspec_match
-
If
true
, glob expansion will be disabled and exact matching will be forced. - :check_pathspec
-
If
true
, and the:force
options isfalse
or not given, exact matches of ignored files or files that are not already inindex
will raise a Rugged::InvalidError. This emulatesgit add -A
.
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'ext/rugged/rugged_index.c', line 372
static VALUE rb_git_index_add_all(int argc, VALUE *argv, VALUE self)
{
VALUE rb_pathspecs, rb_options;
git_index *index;
git_strarray pathspecs;
int error, exception = 0;
unsigned int flags = GIT_INDEX_ADD_DEFAULT;
Data_Get_Struct(self, git_index, index);
if (rb_scan_args(argc, argv, "02", &rb_pathspecs, &rb_options) > 1) {
Check_Type(rb_options, T_HASH);
if (RTEST(rb_hash_aref(rb_options, CSTR2SYM("force"))))
flags |= GIT_INDEX_ADD_FORCE;
if (RTEST(rb_hash_aref(rb_options, CSTR2SYM("disable_pathspec_match"))))
flags |= GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH;
if (RTEST(rb_hash_aref(rb_options, CSTR2SYM("check_pathspec"))))
flags |= GIT_INDEX_ADD_CHECK_PATHSPEC;
}
rugged_rb_ary_to_strarray(rb_pathspecs, &pathspecs);
error = git_index_add_all(index, &pathspecs, flags,
rb_block_given_p() ? rugged__index_matched_path_cb : NULL, &exception);
xfree(pathspecs.strings);
if (exception)
rb_jump_tag(exception);
rugged_exception_check(error);
return Qnil;
}
|