Method: Rugged::Repository#checkout_tree
- Defined in:
- ext/rugged/rugged_repo.c
permalink #checkout_tree(treeish[, options]) ⇒ Object
Updates files in the index and working tree to match the content of the tree pointed at by the treeish
.
The following options can be passed in the options
Hash:
- :progress
-
A callback that will be executed for checkout progress notifications. Up to 3 parameters are passed on each execution:
-
The path to the last updated file (or
nil
on the very first invocation). -
The number of completed checkout steps.
-
The number of total checkout steps to be performed.
-
- :notify
-
A callback that will be executed for each checkout notification types specified with
:notify_flags
. Up to 5 parameters are passed on each execution:-
An array containing the
:notify_flags
that caused the callback execution. -
The path of the current file.
-
A hash describing the baseline blob (or
nil
if it does not exist). -
A hash describing the target blob (or
nil
if it does not exist). -
A hash describing the workdir blob (or
nil
if it does not exist).
-
- :strategy
-
A single symbol or an array of symbols representing the strategies to use when performing the checkout. Possible values are:
- :none
-
Perform a dry run (default).
- :safe
-
Allow safe updates that cannot overwrite uncommitted data.
- :recreate_missing
-
Allow checkout to recreate missing files.
- :force
-
Allow all updates to force working directory to look like index.
- :allow_conflicts
-
Allow checkout to make safe updates even if conflicts are found.
- :remove_untracked
-
Remove untracked files not in index (that are not ignored).
- :remove_ignored
-
Remove ignored files not in index.
- :update_only
-
Only update existing files, don’t create new ones.
- :dont_update_index
-
Normally checkout updates index entries as it goes; this stops that.
- :no_refresh
-
Don’t refresh index/config/etc before doing checkout.
- :disable_pathspec_match
-
Treat pathspec as simple list of exact match file paths.
- :skip_locked_directories
-
Ignore directories in use, they will be left empty.
- :skip_unmerged
-
Allow checkout to skip unmerged files (NOT IMPLEMENTED).
- :use_ours
-
For unmerged files, checkout stage 2 from index (NOT IMPLEMENTED).
- :use_theirs
-
For unmerged files, checkout stage 3 from index (NOT IMPLEMENTED).
- :update_submodules
-
Recursively checkout submodules with same options (NOT IMPLEMENTED).
- :update_submodules_if_changed
-
Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED).
- :disable_filters
-
If
true
, filters like CRLF line conversion will be disabled. - :dir_mode
-
Mode for newly created directories. Default:
0755
. - :file_mode
-
Mode for newly created files. Default:
0755
or0644
. - :file_open_flags
-
Mode for opening files. Default:
IO::CREAT | IO::TRUNC | IO::WRONLY
. - :notify_flags
-
A single symbol or an array of symbols representing the cases in which the
:notify
callback should be invoked. Possible values are:- :none
-
Do not invoke the
:notify
callback (default). - :conflict
-
Invoke the callback for conflicting paths.
- :dirty
-
Invoke the callback for “dirty” files, i.e. those that do not need an update but no longer match the baseline.
- :updated
-
Invoke the callback for any file that was changed.
- :untracked
-
Invoke the callback for untracked files.
- :ignored
-
Invoke the callback for ignored files.
- :all
-
Invoke the callback for all these cases.
- :paths
-
A glob string or an array of glob strings specifying which paths should be taken into account for the checkout operation.
nil
will match all files. Default:nil
. - :baseline
-
A Rugged::Tree that represents the current, expected contents of the workdir. Default:
HEAD
. - :target_directory
-
A path to an alternative workdir directory in which the checkout should be performed.
2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 |
# File 'ext/rugged/rugged_repo.c', line 2354
static VALUE rb_git_checkout_tree(int argc, VALUE *argv, VALUE self)
{
VALUE rb_treeish, rb_options;
git_repository *repo;
git_object *treeish;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
struct rugged_cb_payload *payload;
int error, exception = 0;
rb_scan_args(argc, argv, "10:", &rb_treeish, &rb_options);
if (TYPE(rb_treeish) == T_STRING) {
rb_treeish = rugged_object_rev_parse(self, rb_treeish, 1);
}
if (!rb_obj_is_kind_of(rb_treeish, rb_cRuggedCommit) &&
!rb_obj_is_kind_of(rb_treeish, rb_cRuggedTag) &&
!rb_obj_is_kind_of(rb_treeish, rb_cRuggedTree)) {
rb_raise(rb_eTypeError, "Expected Rugged::Commit, Rugged::Tag or Rugged::Tree");
}
Data_Get_Struct(self, git_repository, repo);
TypedData_Get_Struct(rb_treeish, git_object, &rugged_object_type, treeish);
rugged_parse_checkout_options(&opts, rb_options);
error = git_checkout_tree(repo, treeish, &opts);
xfree(opts.paths.strings);
if ((payload = opts.notify_payload) != NULL) {
exception = payload->exception;
xfree(opts.notify_payload);
}
if ((payload = opts.progress_payload) != NULL) {
exception = payload->exception;
xfree(opts.progress_payload);
}
if (exception)
rb_jump_tag(exception);
rugged_exception_check(error);
return Qnil;
}
|