vendor/libgit2/src/checkout.c in rugged-0.27.9 vs vendor/libgit2/src/checkout.c in rugged-0.27.10
- old
+ new
@@ -5,12 +5,10 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "checkout.h"
-#include <assert.h>
-
#include "git2/repository.h"
#include "git2/refs.h"
#include "git2/tree.h"
#include "git2/blob.h"
#include "git2/config.h"
@@ -144,11 +142,11 @@
{
int error = data->opts.notify_cb(
why, path, baseline, target, workdir, data->opts.notify_payload);
- return giterr_set_after_callback_function(
+ return git_error_set_after_callback_function(
error, "git_checkout notification");
}
}
GIT_INLINE(bool) is_workdir_base_or_new(
@@ -191,11 +189,11 @@
unsigned int sm_status = 0;
const git_oid *sm_oid = NULL;
bool rval = false;
if (git_submodule_lookup(&sm, data->repo, wditem->path) < 0) {
- giterr_clear();
+ git_error_clear();
return true;
}
if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 ||
GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
@@ -352,11 +350,11 @@
}
static int checkout_queue_remove(checkout_data *data, const char *path)
{
char *copy = git_pool_strdup(&data->pool, path);
- GITERR_CHECK_ALLOC(copy);
+ GIT_ERROR_CHECK_ALLOC(copy);
return git_vector_insert(&data->removes, copy);
}
/* note that this advances the iterator over the wd item */
static int checkout_action_wd_only(
@@ -490,11 +488,11 @@
*action = CHECKOUT_ACTION__NONE;
switch (delta->status) {
case GIT_DELTA_UNMODIFIED: /* case 14/15 or 33 */
if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) {
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) );
*action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, NONE);
}
break;
case GIT_DELTA_ADDED: /* case 3, 4 or 6 */
@@ -559,11 +557,11 @@
*action = CHECKOUT_ACTION__NONE;
switch (delta->status) {
case GIT_DELTA_UNMODIFIED:
/* should show delta as dirty / deleted */
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) );
*action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
break;
case GIT_DELTA_ADDED:
case GIT_DELTA_MODIFIED:
@@ -592,13 +590,13 @@
{
*action = CHECKOUT_ACTION__NONE;
switch (delta->status) {
case GIT_DELTA_UNMODIFIED: /* case 19 or 24 (or 34 but not really) */
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL));
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd));
*action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
break;
case GIT_DELTA_ADDED:/* case 4 (and 7 for dir) */
case GIT_DELTA_MODIFIED: /* case 20 (or 37 but not really) */
@@ -609,11 +607,11 @@
CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) :
CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
break;
case GIT_DELTA_DELETED: /* case 11 (and 27 for dir) */
if (delta->old_file.mode != GIT_FILEMODE_TREE)
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd));
break;
case GIT_DELTA_TYPECHANGE: /* case 24 or 31 */
if (delta->old_file.mode == GIT_FILEMODE_TREE) {
/* For typechange from dir, remove dir and add blob, but it is
@@ -900,11 +898,11 @@
checkout_data *data = payload;
checkout_conflictdata *conflict;
int error;
conflict = git__calloc(1, sizeof(checkout_conflictdata));
- GITERR_CHECK_ALLOC(conflict);
+ GIT_ERROR_CHECK_ALLOC(conflict);
conflict->ancestor = ancestor;
conflict->ours = ours;
conflict->theirs = theirs;
@@ -1042,24 +1040,24 @@
*ancestor_out = NULL;
*ours_out = NULL;
*theirs_out = NULL;
if (!name_entry->ancestor) {
- giterr_set(GITERR_INDEX, "a NAME entry exists without an ancestor");
+ git_error_set(GIT_ERROR_INDEX, "a NAME entry exists without an ancestor");
error = -1;
goto done;
}
if (!name_entry->ours && !name_entry->theirs) {
- giterr_set(GITERR_INDEX, "a NAME entry exists without an ours or theirs");
+ git_error_set(GIT_ERROR_INDEX, "a NAME entry exists without an ours or theirs");
error = -1;
goto done;
}
if ((ancestor = checkout_conflicts_search_ancestor(data,
name_entry->ancestor)) == NULL) {
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"a NAME entry referenced ancestor entry '%s' which does not exist in the main index",
name_entry->ancestor);
error = -1;
goto done;
}
@@ -1067,11 +1065,11 @@
if (name_entry->ours) {
if (strcmp(name_entry->ancestor, name_entry->ours) == 0)
ours = ancestor;
else if ((ours = checkout_conflicts_search_branch(data, name_entry->ours)) == NULL ||
ours->ours == NULL) {
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"a NAME entry referenced our entry '%s' which does not exist in the main index",
name_entry->ours);
error = -1;
goto done;
}
@@ -1082,11 +1080,11 @@
theirs = ancestor;
else if (name_entry->ours && strcmp(name_entry->ours, name_entry->theirs) == 0)
theirs = ours;
else if ((theirs = checkout_conflicts_search_branch(data, name_entry->theirs)) == NULL ||
theirs->theirs == NULL) {
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"a NAME entry referenced their entry '%s' which does not exist in the main index",
name_entry->theirs);
error = -1;
goto done;
}
@@ -1181,19 +1179,19 @@
path = conflict->ours ?
conflict->ours->path : conflict->theirs->path;
if ((error = git_index_find(&j, index, path)) < 0) {
if (error == GIT_ENOTFOUND)
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"index inconsistency, could not find entry for expected conflict '%s'", path);
goto done;
}
for (; j < len; j++) {
if ((entry = git_index_get_byindex(index, j)) == NULL) {
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"index inconsistency, truncated index while loading expected conflict '%s'", path);
error = -1;
goto done;
}
@@ -1250,11 +1248,11 @@
else if (theirs)
name = git__strdup(theirs->path);
else
abort();
- GITERR_CHECK_ALLOC(name);
+ GIT_ERROR_CHECK_ALLOC(name);
return git_vector_insert(&data->remove_conflicts, (char *)name);
}
static int checkout_get_remove_conflicts(
@@ -1275,18 +1273,18 @@
{
unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS;
if (action & CHECKOUT_ACTION__REMOVE) {
if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
- giterr_set(GITERR_CHECKOUT, "cannot remove invalid path '%s'", delta->old_file.path);
+ git_error_set(GIT_ERROR_CHECKOUT, "cannot remove invalid path '%s'", delta->old_file.path);
return -1;
}
}
if (action & ~CHECKOUT_ACTION__REMOVE) {
if (!git_path_isvalid(repo, delta->new_file.path, delta->new_file.mode, flags)) {
- giterr_set(GITERR_CHECKOUT, "cannot checkout to invalid path '%s'", delta->new_file.path);
+ git_error_set(GIT_ERROR_CHECKOUT, "cannot checkout to invalid path '%s'", delta->new_file.path);
return -1;
}
}
return 0;
@@ -1352,11 +1350,11 @@
counts[CHECKOUT_ACTION__REMOVE] += data->removes.length;
if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
(data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0)
{
- giterr_set(GITERR_CHECKOUT, "%"PRIuZ" %s checkout",
+ git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
counts[CHECKOUT_ACTION__CONFLICT],
counts[CHECKOUT_ACTION__CONFLICT] == 1 ?
"conflict prevents" : "conflicts prevent");
error = GIT_ECONFLICT;
goto fail;
@@ -1389,11 +1387,11 @@
static bool should_remove_existing(checkout_data *data)
{
int ignorecase;
- if (git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE) < 0) {
+ if (git_repository__configmap_lookup(&ignorecase, data->repo, GIT_CONFIGMAP_IGNORECASE) < 0) {
ignorecase = 0;
}
return (ignorecase &&
(data->strategy & GIT_CHECKOUT_DONT_REMOVE_EXISTING) == 0);
@@ -1451,14 +1449,14 @@
* a case inensitive filesystem (or the user has asked us not
* to). Remove the similarly named file to write the new.
*/
error = git_futils_rmdir_r(path, NULL, GIT_RMDIR_REMOVE_FILES);
} else if (errno != ENOENT) {
- giterr_set(GITERR_OS, "failed to stat '%s'", path);
+ git_error_set(GIT_ERROR_OS, "failed to stat '%s'", path);
return GIT_EEXISTS;
} else {
- giterr_clear();
+ git_error_clear();
}
}
return error;
}
@@ -1475,11 +1473,11 @@
{
struct checkout_stream *stream = (struct checkout_stream *)s;
int ret;
if ((ret = p_write(stream->fd, buffer, len)) < 0)
- giterr_set(GITERR_OS, "could not write to '%s'", stream->path);
+ git_error_set(GIT_ERROR_OS, "could not write to '%s'", stream->path);
return ret;
}
static int checkout_stream_close(git_writestream *s)
@@ -1524,11 +1522,11 @@
flags = O_CREAT | O_TRUNC | O_WRONLY;
if (!(mode = file_mode))
mode = GIT_FILEMODE_BLOB;
if ((fd = p_open(path, flags, mode)) < 0) {
- giterr_set(GITERR_OS, "could not open '%s' for writing", path);
+ git_error_set(GIT_ERROR_OS, "could not open '%s' for writing", path);
return fd;
}
filter_opts.attr_session = &data->attr_session;
filter_opts.temp_buf = &data->tmp;
@@ -1561,11 +1559,11 @@
if (st) {
data->perfdata.stat_calls++;
if ((error = p_stat(path, st)) < 0) {
- giterr_set(GITERR_OS, "failed to stat '%s'", path);
+ git_error_set(GIT_ERROR_OS, "failed to stat '%s'", path);
return error;
}
st->st_mode = entry_filemode;
}
@@ -1588,25 +1586,25 @@
if ((error = git_blob__getbuf(&linktarget, blob)) < 0)
return error;
if (data->can_symlink) {
if ((error = p_symlink(git_buf_cstr(&linktarget), path)) < 0)
- giterr_set(GITERR_OS, "could not create symlink %s", path);
+ git_error_set(GIT_ERROR_OS, "could not create symlink %s", path);
} else {
error = git_futils_fake_symlink(git_buf_cstr(&linktarget), path);
}
if (!error) {
data->perfdata.stat_calls++;
if ((error = p_lstat(path, st)) < 0)
- giterr_set(GITERR_CHECKOUT, "could not stat symlink %s", path);
+ git_error_set(GIT_ERROR_CHECKOUT, "could not stat symlink %s", path);
st->st_mode = GIT_FILEMODE_LINK;
}
- git_buf_free(&linktarget);
+ git_buf_dispose(&linktarget);
return error;
}
static int checkout_update_index(
@@ -1641,12 +1639,12 @@
if (checkout_target_fullpath(&fullpath, data, file->path) < 0)
return -1;
data->perfdata.stat_calls++;
if (p_stat(fullpath->ptr, &st) < 0) {
- giterr_set(
- GITERR_CHECKOUT, "could not stat submodule %s\n", file->path);
+ git_error_set(
+ GIT_ERROR_CHECKOUT, "could not stat submodule %s\n", file->path);
return GIT_ENOTFOUND;
}
st.st_mode = GIT_FILEMODE_COMMIT;
@@ -1673,11 +1671,11 @@
if ((error = git_submodule_lookup(NULL, data->repo, file->path)) < 0) {
/* I've observed repos with submodules in the tree that do not
* have a .gitmodules - core Git just makes an empty directory
*/
if (error == GIT_ENOTFOUND) {
- giterr_clear();
+ git_error_clear();
return checkout_submodule_update_index(data, file);
}
return error;
}
@@ -1715,11 +1713,11 @@
/* if doesn't exist, then no error and no update */
if (errno == ENOENT || errno == ENOTDIR)
return 0;
/* otherwise, stat error and no update */
- giterr_set(GITERR_OS, "failed to stat '%s'", path);
+ git_error_set(GIT_ERROR_OS, "failed to stat '%s'", path);
return -1;
}
/* only safe for update if this is the same type of file */
if ((st.st_mode & ~0777) == (expected_mode & ~0777))
@@ -1754,11 +1752,11 @@
* parent directory - suppress the error and try to continue.
*/
if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 &&
(error == GIT_ENOTFOUND || error == GIT_EEXISTS))
{
- giterr_clear();
+ git_error_clear();
error = 0;
}
return error;
}
@@ -1861,11 +1859,11 @@
int error = git_futils_rmdir_r(
path, data->opts.target_directory, GIT_RMDIR_EMPTY_PARENTS);
if (error == GIT_ENOTFOUND) {
error = 0;
- giterr_clear();
+ git_error_clear();
}
return error;
#else
GIT_UNUSED(repo);
@@ -1891,15 +1889,22 @@
if ((error = checkout_deferred_remove(
data->repo, delta->old_file.path)) < 0)
return error;
}
- if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) {
- error = checkout_blob(data, &delta->new_file);
- if (error < 0)
+ if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) {
+ if ((error = checkout_blob(data, &delta->new_file)) < 0)
return error;
+ data->completed_steps++;
+ report_progress(data, delta->new_file.path);
+ }
+ }
+ git_vector_foreach(&data->diff->deltas, i, delta) {
+ if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && S_ISLNK(delta->new_file.mode)) {
+ if ((error = checkout_blob(data, &delta->new_file)) < 0)
+ return error;
data->completed_steps++;
report_progress(data, delta->new_file.path);
}
}
@@ -1942,11 +1947,11 @@
int error = 0;
git_reference *ref = NULL;
git_object *head;
if (!(error = git_repository_head(&ref, repo)) &&
- !(error = git_reference_peel(&head, ref, GIT_OBJ_TREE)))
+ !(error = git_reference_peel(&head, ref, GIT_OBJECT_TREE)))
*out = (git_tree *)head;
git_reference_free(ref);
return error;
@@ -1987,11 +1992,11 @@
}
if (i == INT_MAX) {
git_buf_truncate(path, path_len);
- giterr_set(GITERR_CHECKOUT, "could not write '%s': working directory file exists", path->ptr);
+ git_error_set(GIT_ERROR_CHECKOUT, "could not write '%s': working directory file exists", path->ptr);
return GIT_EEXISTS;
}
return 0;
}
@@ -2121,11 +2126,11 @@
if ((error = git_merge_file_from_index(&result, data->repo,
conflict->ancestor, conflict->ours, conflict->theirs, &opts)) < 0)
goto done;
if (result.path == NULL || result.mode == 0) {
- giterr_set(GITERR_CHECKOUT, "could not merge contents of file");
+ git_error_set(GIT_ERROR_CHECKOUT, "could not merge contents of file");
error = GIT_ECONFLICT;
goto done;
}
if ((error = checkout_merge_path(&path_workdir, data, conflict, &result)) < 0)
@@ -2159,17 +2164,17 @@
goto done;
done:
git_filter_list_free(fl);
- git_buf_free(&out_data);
- git_buf_free(&our_label);
- git_buf_free(&their_label);
+ git_buf_dispose(&out_data);
+ git_buf_dispose(&our_label);
+ git_buf_dispose(&their_label);
git_merge_file_result_free(&result);
- git_buf_free(&path_workdir);
- git_buf_free(&path_suffixed);
+ git_buf_dispose(&path_workdir);
+ git_buf_dispose(&path_suffixed);
return error;
}
static int checkout_conflict_add(
@@ -2177,11 +2182,11 @@
const git_index_entry *conflict)
{
int error = git_index_remove(data->index, conflict->path, 0);
if (error == GIT_ENOTFOUND)
- giterr_clear();
+ git_error_clear();
else if (error < 0)
return error;
return git_index_add(data->index, conflict);
}
@@ -2345,12 +2350,12 @@
git_vector_free_deep(&data->update_conflicts);
git__free(data->pfx);
data->pfx = NULL;
- git_buf_free(&data->target_path);
- git_buf_free(&data->tmp);
+ git_buf_dispose(&data->target_path);
+ git_buf_dispose(&data->tmp);
git_index_free(data->index);
data->index = NULL;
git_strmap_free(data->mkdir_map);
@@ -2368,22 +2373,22 @@
git_repository *repo = git_iterator_owner(target);
memset(data, 0, sizeof(*data));
if (!repo) {
- giterr_set(GITERR_CHECKOUT, "cannot checkout nothing");
+ git_error_set(GIT_ERROR_CHECKOUT, "cannot checkout nothing");
return -1;
}
if ((!proposed || !proposed->target_directory) &&
(error = git_repository__ensure_not_bare(repo, "checkout")) < 0)
return error;
data->repo = repo;
data->target = target;
- GITERR_CHECK_VERSION(
+ GIT_ERROR_CHECK_VERSION(
proposed, GIT_CHECKOUT_OPTIONS_VERSION, "git_checkout_options");
if (!proposed)
GIT_INIT_STRUCTURE(&data->opts, GIT_CHECKOUT_OPTIONS_VERSION);
else
@@ -2395,35 +2400,44 @@
(error = checkout_mkdir(data,
data->opts.target_directory, NULL,
GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0)
goto cleanup;
+ if ((error = git_repository_index(&data->index, data->repo)) < 0)
+ goto cleanup;
+
/* refresh config and index content unless NO_REFRESH is given */
if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
git_config *cfg;
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
goto cleanup;
- /* Get the repository index and reload it (unless we're checking
- * out the index; then it has the changes we're trying to check
- * out and those should not be overwritten.)
+ /* Reload the repository index (unless we're checking out the
+ * index; then it has the changes we're trying to check out
+ * and those should not be overwritten.)
*/
- if ((error = git_repository_index(&data->index, data->repo)) < 0)
- goto cleanup;
-
if (data->index != git_iterator_index(target)) {
- if ((error = git_index_read(data->index, true)) < 0)
- goto cleanup;
+ if (data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) {
+ /* When forcing, we can blindly re-read the index */
+ if ((error = git_index_read(data->index, false)) < 0)
+ goto cleanup;
+ } else {
+ /*
+ * When not being forced, we need to check for unresolved
+ * conflicts and unsaved changes in the index before
+ * proceeding.
+ */
+ if (git_index_has_conflicts(data->index)) {
+ error = GIT_ECONFLICT;
+ git_error_set(GIT_ERROR_CHECKOUT,
+ "unresolved conflicts exist in the index");
+ goto cleanup;
+ }
- /* cannot checkout if unresolved conflicts exist */
- if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) == 0 &&
- git_index_has_conflicts(data->index)) {
- error = GIT_ECONFLICT;
- giterr_set(GITERR_CHECKOUT,
- "unresolved conflicts exist in the index");
- goto cleanup;
+ if ((error = git_index_read_safely(data->index)) < 0)
+ goto cleanup;
}
/* clean conflict data in the current index */
git_index_name_clear(data->index);
git_index_reuc_clear(data->index);
@@ -2452,16 +2466,16 @@
if (!data->opts.file_open_flags)
data->opts.file_open_flags = O_CREAT | O_TRUNC | O_WRONLY;
data->pfx = git_pathspec_prefix(&data->opts.paths);
- if ((error = git_repository__cvar(
- &data->can_symlink, repo, GIT_CVAR_SYMLINKS)) < 0)
+ if ((error = git_repository__configmap_lookup(
+ &data->can_symlink, repo, GIT_CONFIGMAP_SYMLINKS)) < 0)
goto cleanup;
- if ((error = git_repository__cvar(
- &data->respect_filemode, repo, GIT_CVAR_FILEMODE)) < 0)
+ if ((error = git_repository__configmap_lookup(
+ &data->respect_filemode, repo, GIT_CONFIGMAP_FILEMODE)) < 0)
goto cleanup;
if (!data->opts.baseline && !data->opts.baseline_index) {
data->opts_free_baseline = true;
error = 0;
@@ -2472,11 +2486,11 @@
if (data->index->on_disk)
error = checkout_lookup_head_tree(&data->opts.baseline, repo);
if (error == GIT_EUNBORNBRANCH) {
error = 0;
- giterr_clear();
+ git_error_clear();
}
if (error < 0)
goto cleanup;
}
@@ -2495,11 +2509,11 @@
else if (strcmp(conflict_style->value, "merge") == 0)
data->opts.checkout_strategy |= GIT_CHECKOUT_CONFLICT_STYLE_MERGE;
else if (strcmp(conflict_style->value, "diff3") == 0)
data->opts.checkout_strategy |= GIT_CHECKOUT_CONFLICT_STYLE_DIFF3;
else {
- giterr_set(GITERR_CHECKOUT, "unknown style '%s' given for 'merge.conflictstyle'",
+ git_error_set(GIT_ERROR_CHECKOUT, "unknown style '%s' given for 'merge.conflictstyle'",
conflict_style->value);
error = -1;
git_config_entry_free(conflict_style);
goto cleanup;
}
@@ -2507,15 +2521,15 @@
}
git_pool_init(&data->pool, 1);
if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
- (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
- (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
- (error = git_buf_puts(&data->target_path, data->opts.target_directory)) < 0 ||
- (error = git_path_to_dir(&data->target_path)) < 0 ||
- (error = git_strmap_alloc(&data->mkdir_map)) < 0)
+ (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
+ (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
+ (error = git_buf_puts(&data->target_path, data->opts.target_directory)) < 0 ||
+ (error = git_path_to_dir(&data->target_path)) < 0 ||
+ (error = git_strmap_new(&data->mkdir_map)) < 0)
goto cleanup;
data->target_len = git_buf_len(&data->target_path);
git_attr_session__init(&data->attr_session, data->repo);
@@ -2677,19 +2691,19 @@
{
int error, owned = 0;
git_iterator *index_i;
if (!index && !repo) {
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"must provide either repository or index to checkout");
return -1;
}
if (index && repo &&
git_index_owner(index) &&
git_index_owner(index) != repo) {
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"index to checkout does not match repository");
return -1;
} else if(index && repo && !git_index_owner(index)) {
GIT_REFCOUNT_OWN(index, repo);
owned = 1;
@@ -2724,35 +2738,35 @@
git_tree *tree = NULL;
git_iterator *tree_i = NULL;
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
if (!treeish && !repo) {
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"must provide either repository or tree to checkout");
return -1;
}
if (treeish && repo && git_object_owner(treeish) != repo) {
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"object to checkout does not match repository");
return -1;
}
if (!repo)
repo = git_object_owner(treeish);
if (treeish) {
- if (git_object_peel((git_object **)&tree, treeish, GIT_OBJ_TREE) < 0) {
- giterr_set(
- GITERR_CHECKOUT, "provided object cannot be peeled to a tree");
+ if (git_object_peel((git_object **)&tree, treeish, GIT_OBJECT_TREE) < 0) {
+ git_error_set(
+ GIT_ERROR_CHECKOUT, "provided object cannot be peeled to a tree");
return -1;
}
}
else {
if ((error = checkout_lookup_head_tree(&tree, repo)) < 0) {
if (error != GIT_EUNBORNBRANCH)
- giterr_set(
- GITERR_CHECKOUT,
+ git_error_set(
+ GIT_ERROR_CHECKOUT,
"HEAD could not be peeled to a tree and no treeish given");
return error;
}
}
@@ -2780,11 +2794,16 @@
{
assert(repo);
return git_checkout_tree(repo, NULL, opts);
}
-int git_checkout_init_options(git_checkout_options *opts, unsigned int version)
+int git_checkout_options_init(git_checkout_options *opts, unsigned int version)
{
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_checkout_options, GIT_CHECKOUT_OPTIONS_INIT);
return 0;
+}
+
+int git_checkout_init_options(git_checkout_options *opts, unsigned int version)
+{
+ return git_checkout_options_init(opts, version);
}