Commit 63f7c6f4 by Vicent Martí

Merge pull request #1072 from arrbee/diff-api-signatures

Diff API signatures
parents 5a36f127 bbe6dbec
...@@ -204,22 +204,22 @@ int main(int argc, char *argv[]) ...@@ -204,22 +204,22 @@ int main(int argc, char *argv[])
/* nothing */ /* nothing */
if (t1 && t2) if (t1 && t2)
check(git_diff_tree_to_tree(repo, &opts, t1, t2, &diff), "Diff"); check(git_diff_tree_to_tree(&diff, repo, t1, t2, &opts), "Diff");
else if (t1 && cached) else if (t1 && cached)
check(git_diff_index_to_tree(repo, &opts, t1, &diff), "Diff"); check(git_diff_index_to_tree(&diff, repo, t1, NULL, &opts), "Diff");
else if (t1) { else if (t1) {
git_diff_list *diff2; git_diff_list *diff2;
check(git_diff_index_to_tree(repo, &opts, t1, &diff), "Diff"); check(git_diff_index_to_tree(&diff, repo, t1, NULL, &opts), "Diff");
check(git_diff_workdir_to_index(repo, &opts, &diff2), "Diff"); check(git_diff_workdir_to_index(&diff2, repo, NULL, &opts), "Diff");
check(git_diff_merge(diff, diff2), "Merge diffs"); check(git_diff_merge(diff, diff2), "Merge diffs");
git_diff_list_free(diff2); git_diff_list_free(diff2);
} }
else if (cached) { else if (cached) {
check(resolve_to_tree(repo, "HEAD", &t1), "looking up HEAD"); check(resolve_to_tree(repo, "HEAD", &t1), "looking up HEAD");
check(git_diff_index_to_tree(repo, &opts, t1, &diff), "Diff"); check(git_diff_index_to_tree(&diff, repo, t1, NULL, &opts), "Diff");
} }
else else
check(git_diff_workdir_to_index(repo, &opts, &diff), "Diff"); check(git_diff_workdir_to_index(&diff, repo, NULL, &opts), "Diff");
if (color >= 0) if (color >= 0)
fputs(colors[0], stdout); fputs(colors[0], stdout);
......
...@@ -199,13 +199,15 @@ GIT_EXTERN(int) git_checkout_head( ...@@ -199,13 +199,15 @@ GIT_EXTERN(int) git_checkout_head(
/** /**
* Updates files in the working tree to match the content of the index. * Updates files in the working tree to match the content of the index.
* *
* @param repo repository to check out (must be non-bare) * @param repo repository into which to check out (must be non-bare)
* @param index index to be checked out (or NULL to use repository index)
* @param opts specifies checkout options (may be NULL) * @param opts specifies checkout options (may be NULL)
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
* about the error) * about the error)
*/ */
GIT_EXTERN(int) git_checkout_index( GIT_EXTERN(int) git_checkout_index(
git_repository *repo, git_repository *repo,
git_index *index,
git_checkout_opts *opts); git_checkout_opts *opts);
/** /**
......
...@@ -317,52 +317,56 @@ GIT_EXTERN(void) git_diff_list_free(git_diff_list *diff); ...@@ -317,52 +317,56 @@ GIT_EXTERN(void) git_diff_list_free(git_diff_list *diff);
* *
* This is equivalent to `git diff <treeish> <treeish>` * This is equivalent to `git diff <treeish> <treeish>`
* *
* @param diff Output pointer to a git_diff_list pointer to be allocated.
* @param repo The repository containing the trees. * @param repo The repository containing the trees.
* @param opts Structure with options to influence diff or NULL for defaults.
* @param old_tree A git_tree object to diff from. * @param old_tree A git_tree object to diff from.
* @param new_tree A git_tree object to diff to. * @param new_tree A git_tree object to diff to.
* @param diff A pointer to a git_diff_list pointer that will be allocated. * @param opts Structure with options to influence diff or NULL for defaults.
*/ */
GIT_EXTERN(int) git_diff_tree_to_tree( GIT_EXTERN(int) git_diff_tree_to_tree(
git_diff_list **diff,
git_repository *repo, git_repository *repo,
const git_diff_options *opts, /**< can be NULL for defaults */
git_tree *old_tree, git_tree *old_tree,
git_tree *new_tree, git_tree *new_tree,
git_diff_list **diff); const git_diff_options *opts); /**< can be NULL for defaults */
/** /**
* Compute a difference between a tree and the index. * Compute a difference between a tree and the repository index.
* *
* This is equivalent to `git diff --cached <treeish>` or if you pass * This is equivalent to `git diff --cached <treeish>` or if you pass
* the HEAD tree, then like `git diff --cached`. * the HEAD tree, then like `git diff --cached`.
* *
* @param diff Output pointer to a git_diff_list pointer to be allocated.
* @param repo The repository containing the tree and index. * @param repo The repository containing the tree and index.
* @param opts Structure with options to influence diff or NULL for defaults.
* @param old_tree A git_tree object to diff from. * @param old_tree A git_tree object to diff from.
* @param diff A pointer to a git_diff_list pointer that will be allocated. * @param index The index to diff with; repo index used if NULL.
* @param opts Structure with options to influence diff or NULL for defaults.
*/ */
GIT_EXTERN(int) git_diff_index_to_tree( GIT_EXTERN(int) git_diff_index_to_tree(
git_diff_list **diff,
git_repository *repo, git_repository *repo,
const git_diff_options *opts, /**< can be NULL for defaults */
git_tree *old_tree, git_tree *old_tree,
git_diff_list **diff); git_index *index,
const git_diff_options *opts); /**< can be NULL for defaults */
/** /**
* Compute a difference between the working directory and the index. * Compute a difference between the working directory and the repository index.
* *
* This matches the `git diff` command. See the note below on * This matches the `git diff` command. See the note below on
* `git_diff_workdir_to_tree` for a discussion of the difference between * `git_diff_workdir_to_tree` for a discussion of the difference between
* `git diff` and `git diff HEAD` and how to emulate a `git diff <treeish>` * `git diff` and `git diff HEAD` and how to emulate a `git diff <treeish>`
* using libgit2. * using libgit2.
* *
* @param diff Output pointer to a git_diff_list pointer to be allocated.
* @param repo The repository. * @param repo The repository.
* @param index The index to diff from; repo index used if NULL.
* @param opts Structure with options to influence diff or NULL for defaults. * @param opts Structure with options to influence diff or NULL for defaults.
* @param diff A pointer to a git_diff_list pointer that will be allocated.
*/ */
GIT_EXTERN(int) git_diff_workdir_to_index( GIT_EXTERN(int) git_diff_workdir_to_index(
git_diff_list **diff,
git_repository *repo, git_repository *repo,
const git_diff_options *opts, /**< can be NULL for defaults */ git_index *index,
git_diff_list **diff); const git_diff_options *opts); /**< can be NULL for defaults */
/** /**
* Compute a difference between the working directory and a tree. * Compute a difference between the working directory and a tree.
...@@ -386,16 +390,16 @@ GIT_EXTERN(int) git_diff_workdir_to_index( ...@@ -386,16 +390,16 @@ GIT_EXTERN(int) git_diff_workdir_to_index(
* The tree-to-workdir diff for that file is 'modified', but core git would * The tree-to-workdir diff for that file is 'modified', but core git would
* show status 'deleted' since there is a pending deletion in the index. * show status 'deleted' since there is a pending deletion in the index.
* *
* @param diff A pointer to a git_diff_list pointer that will be allocated.
* @param repo The repository containing the tree. * @param repo The repository containing the tree.
* @param opts Structure with options to influence diff or NULL for defaults.
* @param old_tree A git_tree object to diff from. * @param old_tree A git_tree object to diff from.
* @param diff A pointer to a git_diff_list pointer that will be allocated. * @param opts Structure with options to influence diff or NULL for defaults.
*/ */
GIT_EXTERN(int) git_diff_workdir_to_tree( GIT_EXTERN(int) git_diff_workdir_to_tree(
git_diff_list **diff,
git_repository *repo, git_repository *repo,
const git_diff_options *opts, /**< can be NULL for defaults */
git_tree *old_tree, git_tree *old_tree,
git_diff_list **diff); const git_diff_options *opts); /**< can be NULL for defaults */
/** /**
* Merge one diff list into another. * Merge one diff list into another.
......
...@@ -601,12 +601,12 @@ static int checkout_create_submodules( ...@@ -601,12 +601,12 @@ static int checkout_create_submodules(
int git_checkout_index( int git_checkout_index(
git_repository *repo, git_repository *repo,
git_index *index,
git_checkout_opts *opts) git_checkout_opts *opts)
{ {
git_diff_list *diff = NULL; git_diff_list *diff = NULL;
git_diff_options diff_opts = {0}; git_diff_options diff_opts = {0};
git_checkout_opts checkout_opts; git_checkout_opts checkout_opts;
checkout_diff_data data; checkout_diff_data data;
git_buf workdir = GIT_BUF_INIT; git_buf workdir = GIT_BUF_INIT;
uint32_t *actions = NULL; uint32_t *actions = NULL;
...@@ -625,7 +625,7 @@ int git_checkout_index( ...@@ -625,7 +625,7 @@ int git_checkout_index(
if (opts && opts->paths.count > 0) if (opts && opts->paths.count > 0)
diff_opts.pathspec = opts->paths; diff_opts.pathspec = opts->paths;
if ((error = git_diff_workdir_to_index(repo, &diff_opts, &diff)) < 0) if ((error = git_diff_workdir_to_index(&diff, repo, index, &diff_opts)) < 0)
goto cleanup; goto cleanup;
if ((error = git_buf_puts(&workdir, git_repository_workdir(repo))) < 0) if ((error = git_buf_puts(&workdir, git_repository_workdir(repo))) < 0)
...@@ -706,12 +706,14 @@ int git_checkout_tree( ...@@ -706,12 +706,14 @@ int git_checkout_tree(
return -1; return -1;
} }
/* TODO: create a temp index, load tree there and check it out */
/* load paths in tree that match pathspec into index */ /* load paths in tree that match pathspec into index */
if (!(error = git_repository_index(&index, repo)) && if (!(error = git_repository_index(&index, repo)) &&
!(error = git_index_read_tree_match( !(error = git_index_read_tree_match(
index, tree, opts ? &opts->paths : NULL)) && index, tree, opts ? &opts->paths : NULL)) &&
!(error = git_index_write(index))) !(error = git_index_write(index)))
error = git_checkout_index(repo, opts); error = git_checkout_index(repo, NULL, opts);
git_index_free(index); git_index_free(index);
git_tree_free(tree); git_tree_free(tree);
......
...@@ -568,11 +568,11 @@ static int diff_list_init_from_iterators( ...@@ -568,11 +568,11 @@ static int diff_list_init_from_iterators(
} }
static int diff_from_iterators( static int diff_from_iterators(
git_diff_list **diff_ptr,
git_repository *repo, git_repository *repo,
const git_diff_options *opts, /**< can be NULL for defaults */
git_iterator *old_iter, git_iterator *old_iter,
git_iterator *new_iter, git_iterator *new_iter,
git_diff_list **diff_ptr) const git_diff_options *opts)
{ {
int error = 0; int error = 0;
const git_index_entry *oitem, *nitem; const git_index_entry *oitem, *nitem;
...@@ -747,108 +747,97 @@ fail: ...@@ -747,108 +747,97 @@ fail:
error = -1; error = -1;
} }
git_iterator_free(old_iter);
git_iterator_free(new_iter);
git_buf_free(&ignore_prefix); git_buf_free(&ignore_prefix);
return error; return error;
} }
#define DIFF_FROM_ITERATORS(MAKE_FIRST, MAKE_SECOND) do { \
git_iterator *a = NULL, *b = NULL; \
char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL; \
if (!(error = MAKE_FIRST) && !(error = MAKE_SECOND)) \
error = diff_from_iterators(diff, repo, a, b, opts); \
git__free(pfx); git_iterator_free(a); git_iterator_free(b); \
} while (0)
int git_diff_tree_to_tree( int git_diff_tree_to_tree(
git_diff_list **diff,
git_repository *repo, git_repository *repo,
const git_diff_options *opts, /**< can be NULL for defaults */
git_tree *old_tree, git_tree *old_tree,
git_tree *new_tree, git_tree *new_tree,
git_diff_list **diff) const git_diff_options *opts)
{ {
git_iterator *a = NULL, *b = NULL; int error = 0;
char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL;
assert(repo && old_tree && new_tree && diff); assert(diff && repo);
if (git_iterator_for_tree_range(&a, repo, old_tree, pfx, pfx) < 0 || DIFF_FROM_ITERATORS(
git_iterator_for_tree_range(&b, repo, new_tree, pfx, pfx) < 0) git_iterator_for_tree_range(&a, repo, old_tree, pfx, pfx),
return -1; git_iterator_for_tree_range(&b, repo, new_tree, pfx, pfx)
);
git__free(pfx); return error;
return diff_from_iterators(repo, opts, a, b, diff);
} }
int git_diff_index_to_tree( int git_diff_index_to_tree(
git_diff_list **diff,
git_repository *repo, git_repository *repo,
const git_diff_options *opts,
git_tree *old_tree, git_tree *old_tree,
git_diff_list **diff) git_index *index,
const git_diff_options *opts)
{ {
git_iterator *a = NULL, *b = NULL; int error = 0;
char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL;
assert(repo && diff);
if (git_iterator_for_tree_range(&a, repo, old_tree, pfx, pfx) < 0 || assert(diff && repo);
git_iterator_for_index_range(&b, repo, pfx, pfx) < 0)
goto on_error;
git__free(pfx); if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0)
return error;
return diff_from_iterators(repo, opts, a, b, diff); DIFF_FROM_ITERATORS(
git_iterator_for_tree_range(&a, repo, old_tree, pfx, pfx),
git_iterator_for_index_range(&b, index, pfx, pfx)
);
on_error: return error;
git__free(pfx);
git_iterator_free(a);
return -1;
} }
int git_diff_workdir_to_index( int git_diff_workdir_to_index(
git_diff_list **diff,
git_repository *repo, git_repository *repo,
const git_diff_options *opts, git_index *index,
git_diff_list **diff) const git_diff_options *opts)
{ {
int error; int error = 0;
git_iterator *a = NULL, *b = NULL;
char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL;
assert(repo && diff);
if ((error = git_iterator_for_index_range(&a, repo, pfx, pfx)) < 0 || assert(diff && repo);
(error = git_iterator_for_workdir_range(&b, repo, pfx, pfx)) < 0)
goto on_error;
git__free(pfx); if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0)
return error;
return diff_from_iterators(repo, opts, a, b, diff); DIFF_FROM_ITERATORS(
git_iterator_for_index_range(&a, index, pfx, pfx),
git_iterator_for_workdir_range(&b, repo, pfx, pfx)
);
on_error:
git__free(pfx);
git_iterator_free(a);
return error; return error;
} }
int git_diff_workdir_to_tree( int git_diff_workdir_to_tree(
git_diff_list **diff,
git_repository *repo, git_repository *repo,
const git_diff_options *opts, git_tree *old_tree,
git_tree *tree, const git_diff_options *opts)
git_diff_list **diff)
{ {
int error; int error = 0;
git_iterator *a = NULL, *b = NULL;
char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL;
assert(repo && tree && diff);
if ((error = git_iterator_for_tree_range(&a, repo, tree, pfx, pfx)) < 0 ||
(error = git_iterator_for_workdir_range(&b, repo, pfx, pfx)) < 0)
goto on_error;
git__free(pfx); assert(diff && repo);
return diff_from_iterators(repo, opts, a, b, diff); DIFF_FROM_ITERATORS(
git_iterator_for_tree_range(&a, repo, old_tree, pfx, pfx),
git_iterator_for_workdir_range(&b, repo, pfx, pfx)
);
on_error:
git__free(pfx);
git_iterator_free(a);
return error; return error;
} }
...@@ -835,7 +835,9 @@ unsigned int git_index__prefix_position(git_index *index, const char *path) ...@@ -835,7 +835,9 @@ unsigned int git_index__prefix_position(git_index *index, const char *path)
srch_key.path = path; srch_key.path = path;
srch_key.stage = 0; srch_key.stage = 0;
git_vector_bsearch3(&pos, &index->entries, index->entries_search, &srch_key); git_vector_sort(&index->entries);
git_vector_bsearch3(
&pos, &index->entries, index->entries_search, &srch_key);
return pos; return pos;
} }
......
...@@ -330,6 +330,7 @@ typedef struct { ...@@ -330,6 +330,7 @@ typedef struct {
git_iterator base; git_iterator base;
git_index *index; git_index *index;
unsigned int current; unsigned int current;
bool free_index;
} index_iterator; } index_iterator;
static int index_iterator__current( static int index_iterator__current(
...@@ -387,32 +388,47 @@ static int index_iterator__reset(git_iterator *self) ...@@ -387,32 +388,47 @@ static int index_iterator__reset(git_iterator *self)
static void index_iterator__free(git_iterator *self) static void index_iterator__free(git_iterator *self)
{ {
index_iterator *ii = (index_iterator *)self; index_iterator *ii = (index_iterator *)self;
if (ii->free_index)
git_index_free(ii->index); git_index_free(ii->index);
ii->index = NULL; ii->index = NULL;
} }
int git_iterator_for_index_range( int git_iterator_for_index_range(
git_iterator **iter, git_iterator **iter,
git_repository *repo, git_index *index,
const char *start, const char *start,
const char *end) const char *end)
{ {
int error;
index_iterator *ii; index_iterator *ii;
ITERATOR_BASE_INIT(ii, index, INDEX); ITERATOR_BASE_INIT(ii, index, INDEX);
if ((error = git_repository_index(&ii->index, repo)) < 0) ii->index = index;
git__free(ii);
else {
ii->base.ignore_case = ii->index->ignore_case; ii->base.ignore_case = ii->index->ignore_case;
ii->current = start ? git_index__prefix_position(ii->index, start) : 0; ii->current = start ? git_index__prefix_position(ii->index, start) : 0;
*iter = (git_iterator *)ii; *iter = (git_iterator *)ii;
}
return error; return 0;
} }
int git_iterator_for_repo_index_range(
git_iterator **iter,
git_repository *repo,
const char *start,
const char *end)
{
int error;
git_index *index;
if ((error = git_repository_index(&index, repo)) < 0)
return error;
if (!(error = git_iterator_for_index_range(iter, index, start, end)))
((index_iterator *)(*iter))->free_index = true;
return error;
}
typedef struct workdir_iterator_frame workdir_iterator_frame; typedef struct workdir_iterator_frame workdir_iterator_frame;
struct workdir_iterator_frame { struct workdir_iterator_frame {
...@@ -690,24 +706,21 @@ int git_iterator_for_workdir_range( ...@@ -690,24 +706,21 @@ int git_iterator_for_workdir_range(
assert(iter && repo); assert(iter && repo);
if ((error = git_repository__ensure_not_bare(repo, "scan working directory")) < 0) if ((error = git_repository__ensure_not_bare(
repo, "scan working directory")) < 0)
return error; return error;
ITERATOR_BASE_INIT(wi, workdir, WORKDIR); ITERATOR_BASE_INIT(wi, workdir, WORKDIR);
wi->repo = repo; wi->repo = repo;
if ((error = git_repository_index(&index, repo)) < 0) { if ((error = git_repository_index__weakptr(&index, repo)) < 0) {
git__free(wi); git__free(wi);
return error; return error;
} }
/* Set the ignore_case flag for the workdir iterator to match /* Match ignore_case flag for iterator to that of the index */
* that of the index. */
wi->base.ignore_case = index->ignore_case; wi->base.ignore_case = index->ignore_case;
git_index_free(index);
if (git_buf_sets(&wi->path, git_repository_workdir(repo)) < 0 || if (git_buf_sets(&wi->path, git_repository_workdir(repo)) < 0 ||
git_path_to_dir(&wi->path) < 0 || git_path_to_dir(&wi->path) < 0 ||
git_ignore__for_path(repo, "", &wi->ignores) < 0) git_ignore__for_path(repo, "", &wi->ignores) < 0)
......
...@@ -52,13 +52,23 @@ GIT_INLINE(int) git_iterator_for_tree( ...@@ -52,13 +52,23 @@ GIT_INLINE(int) git_iterator_for_tree(
} }
extern int git_iterator_for_index_range( extern int git_iterator_for_index_range(
git_iterator **iter, git_repository *repo, git_iterator **iter, git_index *index,
const char *start, const char *end); const char *start, const char *end);
GIT_INLINE(int) git_iterator_for_index( GIT_INLINE(int) git_iterator_for_index(
git_iterator **iter, git_index *index)
{
return git_iterator_for_index_range(iter, index, NULL, NULL);
}
extern int git_iterator_for_repo_index_range(
git_iterator **iter, git_repository *repo,
const char *start, const char *end);
GIT_INLINE(int) git_iterator_for_repo_index(
git_iterator **iter, git_repository *repo) git_iterator **iter, git_repository *repo)
{ {
return git_iterator_for_index_range(iter, repo, NULL, NULL); return git_iterator_for_repo_index_range(iter, repo, NULL, NULL);
} }
extern int git_iterator_for_workdir_range( extern int git_iterator_for_workdir_range(
......
...@@ -139,7 +139,7 @@ int git_reset( ...@@ -139,7 +139,7 @@ int git_reset(
memset(&opts, 0, sizeof(opts)); memset(&opts, 0, sizeof(opts));
opts.checkout_strategy = GIT_CHECKOUT_FORCE; opts.checkout_strategy = GIT_CHECKOUT_FORCE;
if (git_checkout_index(repo, &opts) < 0) { if (git_checkout_index(repo, NULL, &opts) < 0) {
giterr_set(GITERR_INDEX, "%s - Failed to checkout the index.", ERROR_MSG); giterr_set(GITERR_INDEX, "%s - Failed to checkout the index.", ERROR_MSG);
goto cleanup; goto cleanup;
} }
......
...@@ -250,7 +250,7 @@ static int build_untracked_tree( ...@@ -250,7 +250,7 @@ static int build_untracked_tree(
if (git_commit_tree(&i_tree, i_commit) < 0) if (git_commit_tree(&i_tree, i_commit) < 0)
goto cleanup; goto cleanup;
if (git_diff_workdir_to_tree(git_index_owner(index), &opts, i_tree, &diff) < 0) if (git_diff_workdir_to_tree(&diff, git_index_owner(index), i_tree, &opts) < 0)
goto cleanup; goto cleanup;
if (git_diff_foreach(diff, &data, update_index_cb, NULL, NULL) < 0) if (git_diff_foreach(diff, &data, update_index_cb, NULL, NULL) < 0)
...@@ -312,6 +312,7 @@ static int build_workdir_tree( ...@@ -312,6 +312,7 @@ static int build_workdir_tree(
git_index *index, git_index *index,
git_commit *b_commit) git_commit *b_commit)
{ {
git_repository *repo = git_index_owner(index);
git_tree *b_tree = NULL; git_tree *b_tree = NULL;
git_diff_list *diff = NULL, *diff2 = NULL; git_diff_list *diff = NULL, *diff2 = NULL;
git_diff_options opts = {0}; git_diff_options opts = {0};
...@@ -321,10 +322,10 @@ static int build_workdir_tree( ...@@ -321,10 +322,10 @@ static int build_workdir_tree(
if (git_commit_tree(&b_tree, b_commit) < 0) if (git_commit_tree(&b_tree, b_commit) < 0)
goto cleanup; goto cleanup;
if (git_diff_index_to_tree(git_index_owner(index), &opts, b_tree, &diff) < 0) if (git_diff_index_to_tree(&diff, repo, b_tree, NULL, &opts) < 0)
goto cleanup; goto cleanup;
if (git_diff_workdir_to_index(git_index_owner(index), &opts, &diff2) < 0) if (git_diff_workdir_to_index(&diff2, repo, NULL, &opts) < 0)
goto cleanup; goto cleanup;
if (git_diff_merge(diff, diff2) < 0) if (git_diff_merge(diff, diff2) < 0)
......
...@@ -142,11 +142,11 @@ int git_status_foreach_ext( ...@@ -142,11 +142,11 @@ int git_status_foreach_ext(
/* TODO: support EXCLUDE_SUBMODULES flag */ /* TODO: support EXCLUDE_SUBMODULES flag */
if (show != GIT_STATUS_SHOW_WORKDIR_ONLY && if (show != GIT_STATUS_SHOW_WORKDIR_ONLY &&
(err = git_diff_index_to_tree(repo, &diffopt, head, &idx2head)) < 0) (err = git_diff_index_to_tree(&idx2head, repo, head, NULL, &diffopt)) < 0)
goto cleanup; goto cleanup;
if (show != GIT_STATUS_SHOW_INDEX_ONLY && if (show != GIT_STATUS_SHOW_INDEX_ONLY &&
(err = git_diff_workdir_to_index(repo, &diffopt, &wd2idx)) < 0) (err = git_diff_workdir_to_index(&wd2idx, repo, NULL, &diffopt)) < 0)
goto cleanup; goto cleanup;
usercb.cb = cb; usercb.cb = cb;
......
...@@ -1118,7 +1118,7 @@ static int load_submodule_config_from_index( ...@@ -1118,7 +1118,7 @@ static int load_submodule_config_from_index(
git_iterator *i; git_iterator *i;
const git_index_entry *entry; const git_index_entry *entry;
if ((error = git_iterator_for_index(&i, repo)) < 0) if ((error = git_iterator_for_repo_index(&i, repo)) < 0)
return error; return error;
error = git_iterator_current(i, &entry); error = git_iterator_current(i, &entry);
...@@ -1455,7 +1455,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm) ...@@ -1455,7 +1455,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
if (sm->ignore == GIT_SUBMODULE_IGNORE_NONE) if (sm->ignore == GIT_SUBMODULE_IGNORE_NONE)
opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED; opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
error = git_diff_index_to_tree(sm_repo, &opt, sm_head, &diff); error = git_diff_index_to_tree(&diff, sm_repo, sm_head, NULL, &opt);
if (!error) { if (!error) {
if (git_diff_num_deltas(diff) > 0) if (git_diff_num_deltas(diff) > 0)
...@@ -1472,7 +1472,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm) ...@@ -1472,7 +1472,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
/* perform index-to-workdir diff on submodule */ /* perform index-to-workdir diff on submodule */
error = git_diff_workdir_to_index(sm_repo, &opt, &diff); error = git_diff_workdir_to_index(&diff, sm_repo, NULL, &opt);
if (!error) { if (!error) {
size_t untracked = size_t untracked =
......
...@@ -29,17 +29,26 @@ void git_vector_swap(git_vector *a, git_vector *b); ...@@ -29,17 +29,26 @@ void git_vector_swap(git_vector *a, git_vector *b);
void git_vector_sort(git_vector *v); void git_vector_sort(git_vector *v);
/** Linear search for matching entry using internal comparison function */
int git_vector_search(git_vector *v, const void *entry); int git_vector_search(git_vector *v, const void *entry);
/** Linear search for matching entry using explicit comparison function */
int git_vector_search2(git_vector *v, git_vector_cmp cmp, const void *key); int git_vector_search2(git_vector *v, git_vector_cmp cmp, const void *key);
/**
* Binary search for matching entry using explicit comparison function that
* returns position where item would go if not found.
*/
int git_vector_bsearch3( int git_vector_bsearch3(
unsigned int *at_pos, git_vector *v, git_vector_cmp cmp, const void *key); unsigned int *at_pos, git_vector *v, git_vector_cmp cmp, const void *key);
/** Binary search for matching entry using internal comparison function */
GIT_INLINE(int) git_vector_bsearch(git_vector *v, const void *key) GIT_INLINE(int) git_vector_bsearch(git_vector *v, const void *key)
{ {
return git_vector_bsearch3(NULL, v, v->_cmp, key); return git_vector_bsearch3(NULL, v, v->_cmp, key);
} }
/** Binary search for matching entry using explicit comparison function */
GIT_INLINE(int) git_vector_bsearch2( GIT_INLINE(int) git_vector_bsearch2(
git_vector *v, git_vector_cmp cmp, const void *key) git_vector *v, git_vector_cmp cmp, const void *key)
{ {
......
...@@ -69,7 +69,7 @@ void test_checkout_index__cannot_checkout_a_bare_repository(void) ...@@ -69,7 +69,7 @@ void test_checkout_index__cannot_checkout_a_bare_repository(void)
memset(&g_opts, 0, sizeof(g_opts)); memset(&g_opts, 0, sizeof(g_opts));
g_repo = cl_git_sandbox_init("testrepo.git"); g_repo = cl_git_sandbox_init("testrepo.git");
cl_git_fail(git_checkout_index(g_repo, NULL)); cl_git_fail(git_checkout_index(g_repo, NULL, NULL));
} }
void test_checkout_index__can_create_missing_files(void) void test_checkout_index__can_create_missing_files(void)
...@@ -78,7 +78,7 @@ void test_checkout_index__can_create_missing_files(void) ...@@ -78,7 +78,7 @@ void test_checkout_index__can_create_missing_files(void)
cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt")); cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt"));
cl_assert_equal_i(false, git_path_isfile("./testrepo/new.txt")); cl_assert_equal_i(false, git_path_isfile("./testrepo/new.txt"));
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/README", "hey there\n"); test_file_contents("./testrepo/README", "hey there\n");
test_file_contents("./testrepo/branch_file.txt", "hi\nbye!\n"); test_file_contents("./testrepo/branch_file.txt", "hi\nbye!\n");
...@@ -94,7 +94,7 @@ void test_checkout_index__can_remove_untracked_files(void) ...@@ -94,7 +94,7 @@ void test_checkout_index__can_remove_untracked_files(void)
cl_assert_equal_i(true, git_path_isdir("./testrepo/dir/subdir/subsubdir")); cl_assert_equal_i(true, git_path_isdir("./testrepo/dir/subdir/subsubdir"));
g_opts.checkout_strategy |= GIT_CHECKOUT_REMOVE_UNTRACKED; g_opts.checkout_strategy |= GIT_CHECKOUT_REMOVE_UNTRACKED;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
cl_assert_equal_i(false, git_path_isdir("./testrepo/dir")); cl_assert_equal_i(false, git_path_isdir("./testrepo/dir"));
} }
...@@ -110,7 +110,7 @@ void test_checkout_index__honor_the_specified_pathspecs(void) ...@@ -110,7 +110,7 @@ void test_checkout_index__honor_the_specified_pathspecs(void)
cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt")); cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt"));
cl_assert_equal_i(false, git_path_isfile("./testrepo/new.txt")); cl_assert_equal_i(false, git_path_isfile("./testrepo/new.txt"));
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
cl_assert_equal_i(false, git_path_isfile("./testrepo/README")); cl_assert_equal_i(false, git_path_isfile("./testrepo/README"));
test_file_contents("./testrepo/branch_file.txt", "hi\nbye!\n"); test_file_contents("./testrepo/branch_file.txt", "hi\nbye!\n");
...@@ -141,7 +141,7 @@ void test_checkout_index__honor_the_gitattributes_directives(void) ...@@ -141,7 +141,7 @@ void test_checkout_index__honor_the_gitattributes_directives(void)
cl_git_mkfile("./testrepo/.gitattributes", attributes); cl_git_mkfile("./testrepo/.gitattributes", attributes);
set_core_autocrlf_to(false); set_core_autocrlf_to(false);
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/README", "hey there\n"); test_file_contents("./testrepo/README", "hey there\n");
test_file_contents("./testrepo/new.txt", "my new file\n"); test_file_contents("./testrepo/new.txt", "my new file\n");
...@@ -156,7 +156,7 @@ void test_checkout_index__honor_coreautocrlf_setting_set_to_true(void) ...@@ -156,7 +156,7 @@ void test_checkout_index__honor_coreautocrlf_setting_set_to_true(void)
cl_git_pass(p_unlink("./testrepo/.gitattributes")); cl_git_pass(p_unlink("./testrepo/.gitattributes"));
set_core_autocrlf_to(true); set_core_autocrlf_to(true);
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/README", expected_readme_text); test_file_contents("./testrepo/README", expected_readme_text);
#endif #endif
...@@ -171,7 +171,7 @@ void test_checkout_index__honor_coresymlinks_setting_set_to_true(void) ...@@ -171,7 +171,7 @@ void test_checkout_index__honor_coresymlinks_setting_set_to_true(void)
{ {
set_repo_symlink_handling_cap_to(true); set_repo_symlink_handling_cap_to(true);
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
#ifdef GIT_WIN32 #ifdef GIT_WIN32
test_file_contents("./testrepo/link_to_new.txt", "new.txt"); test_file_contents("./testrepo/link_to_new.txt", "new.txt");
...@@ -193,7 +193,7 @@ void test_checkout_index__honor_coresymlinks_setting_set_to_false(void) ...@@ -193,7 +193,7 @@ void test_checkout_index__honor_coresymlinks_setting_set_to_false(void)
{ {
set_repo_symlink_handling_cap_to(false); set_repo_symlink_handling_cap_to(false);
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/link_to_new.txt", "new.txt"); test_file_contents("./testrepo/link_to_new.txt", "new.txt");
} }
...@@ -207,7 +207,7 @@ void test_checkout_index__donot_overwrite_modified_file_by_default(void) ...@@ -207,7 +207,7 @@ void test_checkout_index__donot_overwrite_modified_file_by_default(void)
*/ */
g_opts.checkout_strategy = GIT_CHECKOUT_ALLOW_CONFLICTS; g_opts.checkout_strategy = GIT_CHECKOUT_ALLOW_CONFLICTS;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/new.txt", "This isn't what's stored!"); test_file_contents("./testrepo/new.txt", "This isn't what's stored!");
} }
...@@ -218,7 +218,7 @@ void test_checkout_index__can_overwrite_modified_file(void) ...@@ -218,7 +218,7 @@ void test_checkout_index__can_overwrite_modified_file(void)
g_opts.checkout_strategy |= GIT_CHECKOUT_UPDATE_MODIFIED; g_opts.checkout_strategy |= GIT_CHECKOUT_UPDATE_MODIFIED;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/new.txt", "my new file\n"); test_file_contents("./testrepo/new.txt", "my new file\n");
} }
...@@ -228,14 +228,14 @@ void test_checkout_index__options_disable_filters(void) ...@@ -228,14 +228,14 @@ void test_checkout_index__options_disable_filters(void)
cl_git_mkfile("./testrepo/.gitattributes", "*.txt text eol=crlf\n"); cl_git_mkfile("./testrepo/.gitattributes", "*.txt text eol=crlf\n");
g_opts.disable_filters = false; g_opts.disable_filters = false;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/new.txt", "my new file\r\n"); test_file_contents("./testrepo/new.txt", "my new file\r\n");
p_unlink("./testrepo/new.txt"); p_unlink("./testrepo/new.txt");
g_opts.disable_filters = true; g_opts.disable_filters = true;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/new.txt", "my new file\n"); test_file_contents("./testrepo/new.txt", "my new file\n");
} }
...@@ -253,7 +253,7 @@ void test_checkout_index__options_dir_modes(void) ...@@ -253,7 +253,7 @@ void test_checkout_index__options_dir_modes(void)
reset_index_to_treeish((git_object *)commit); reset_index_to_treeish((git_object *)commit);
g_opts.dir_mode = 0701; g_opts.dir_mode = 0701;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
cl_git_pass(p_stat("./testrepo/a", &st)); cl_git_pass(p_stat("./testrepo/a", &st));
cl_assert_equal_i(st.st_mode & 0777, 0701); cl_assert_equal_i(st.st_mode & 0777, 0701);
...@@ -273,7 +273,7 @@ void test_checkout_index__options_override_file_modes(void) ...@@ -273,7 +273,7 @@ void test_checkout_index__options_override_file_modes(void)
g_opts.file_mode = 0700; g_opts.file_mode = 0700;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
cl_git_pass(p_stat("./testrepo/new.txt", &st)); cl_git_pass(p_stat("./testrepo/new.txt", &st));
cl_assert_equal_i(st.st_mode & 0777, 0700); cl_assert_equal_i(st.st_mode & 0777, 0700);
...@@ -287,7 +287,7 @@ void test_checkout_index__options_open_flags(void) ...@@ -287,7 +287,7 @@ void test_checkout_index__options_open_flags(void)
g_opts.file_open_flags = O_CREAT | O_RDWR | O_APPEND; g_opts.file_open_flags = O_CREAT | O_RDWR | O_APPEND;
g_opts.checkout_strategy |= GIT_CHECKOUT_UPDATE_MODIFIED; g_opts.checkout_strategy |= GIT_CHECKOUT_UPDATE_MODIFIED;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
test_file_contents("./testrepo/new.txt", "hi\nmy new file\n"); test_file_contents("./testrepo/new.txt", "hi\nmy new file\n");
} }
...@@ -334,7 +334,7 @@ void test_checkout_index__can_notify_of_skipped_files(void) ...@@ -334,7 +334,7 @@ void test_checkout_index__can_notify_of_skipped_files(void)
g_opts.conflict_cb = conflict_cb; g_opts.conflict_cb = conflict_cb;
g_opts.conflict_payload = &data; g_opts.conflict_payload = &data;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
} }
static int dont_conflict_cb( static int dont_conflict_cb(
...@@ -366,7 +366,7 @@ void test_checkout_index__wont_notify_of_expected_line_ending_changes(void) ...@@ -366,7 +366,7 @@ void test_checkout_index__wont_notify_of_expected_line_ending_changes(void)
g_opts.conflict_cb = dont_conflict_cb; g_opts.conflict_cb = dont_conflict_cb;
g_opts.conflict_payload = NULL; g_opts.conflict_payload = NULL;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
} }
static void progress(const char *path, size_t cur, size_t tot, void *payload) static void progress(const char *path, size_t cur, size_t tot, void *payload)
...@@ -382,7 +382,7 @@ void test_checkout_index__calls_progress_callback(void) ...@@ -382,7 +382,7 @@ void test_checkout_index__calls_progress_callback(void)
g_opts.progress_cb = progress; g_opts.progress_cb = progress;
g_opts.progress_payload = &was_called; g_opts.progress_payload = &was_called;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
cl_assert_equal_i(was_called, true); cl_assert_equal_i(was_called, true);
} }
...@@ -413,13 +413,13 @@ void test_checkout_index__can_overcome_name_clashes(void) ...@@ -413,13 +413,13 @@ void test_checkout_index__can_overcome_name_clashes(void)
cl_assert(git_path_isfile("./testrepo/path0/file0")); cl_assert(git_path_isfile("./testrepo/path0/file0"));
g_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS; g_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
cl_assert(git_path_isfile("./testrepo/path1")); cl_assert(git_path_isfile("./testrepo/path1"));
cl_assert(git_path_isfile("./testrepo/path0/file0")); cl_assert(git_path_isfile("./testrepo/path0/file0"));
g_opts.checkout_strategy = GIT_CHECKOUT_FORCE; g_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_checkout_index(g_repo, &g_opts)); cl_git_pass(git_checkout_index(g_repo, NULL, &g_opts));
cl_assert(git_path_isfile("./testrepo/path0")); cl_assert(git_path_isfile("./testrepo/path0"));
cl_assert(git_path_isfile("./testrepo/path1/file1")); cl_assert(git_path_isfile("./testrepo/path1/file1"));
......
...@@ -16,7 +16,7 @@ void test_diff_diffiter__create(void) ...@@ -16,7 +16,7 @@ void test_diff_diffiter__create(void)
git_diff_list *diff; git_diff_list *diff;
size_t d, num_d; size_t d, num_d;
cl_git_pass(git_diff_workdir_to_index(repo, NULL, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, NULL));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) { for (d = 0; d < num_d; ++d) {
...@@ -34,7 +34,7 @@ void test_diff_diffiter__iterate_files(void) ...@@ -34,7 +34,7 @@ void test_diff_diffiter__iterate_files(void)
size_t d, num_d; size_t d, num_d;
int count = 0; int count = 0;
cl_git_pass(git_diff_workdir_to_index(repo, NULL, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, NULL));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(6, (int)num_d); cl_assert_equal_i(6, (int)num_d);
...@@ -57,7 +57,7 @@ void test_diff_diffiter__iterate_files_2(void) ...@@ -57,7 +57,7 @@ void test_diff_diffiter__iterate_files_2(void)
size_t d, num_d; size_t d, num_d;
int count = 0; int count = 0;
cl_git_pass(git_diff_workdir_to_index(repo, NULL, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, NULL));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(8, (int)num_d); cl_assert_equal_i(8, (int)num_d);
...@@ -85,7 +85,7 @@ void test_diff_diffiter__iterate_files_and_hunks(void) ...@@ -85,7 +85,7 @@ void test_diff_diffiter__iterate_files_and_hunks(void)
opts.interhunk_lines = 1; opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED; opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
...@@ -138,7 +138,7 @@ void test_diff_diffiter__max_size_threshold(void) ...@@ -138,7 +138,7 @@ void test_diff_diffiter__max_size_threshold(void)
opts.interhunk_lines = 1; opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED; opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) { for (d = 0; d < num_d; ++d) {
...@@ -173,7 +173,7 @@ void test_diff_diffiter__max_size_threshold(void) ...@@ -173,7 +173,7 @@ void test_diff_diffiter__max_size_threshold(void)
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED; opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
opts.max_size = 50; /* treat anything over 50 bytes as binary! */ opts.max_size = 50; /* treat anything over 50 bytes as binary! */
cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) { for (d = 0; d < num_d; ++d) {
...@@ -216,7 +216,7 @@ void test_diff_diffiter__iterate_all(void) ...@@ -216,7 +216,7 @@ void test_diff_diffiter__iterate_all(void)
opts.interhunk_lines = 1; opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED; opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) { for (d = 0; d < num_d; ++d) {
...@@ -292,7 +292,7 @@ void test_diff_diffiter__iterate_randomly_while_saving_state(void) ...@@ -292,7 +292,7 @@ void test_diff_diffiter__iterate_randomly_while_saving_state(void)
opts.interhunk_lines = 1; opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED; opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
...@@ -419,7 +419,7 @@ void test_diff_diffiter__iterate_and_generate_patch_text(void) ...@@ -419,7 +419,7 @@ void test_diff_diffiter__iterate_and_generate_patch_text(void)
git_diff_list *diff; git_diff_list *diff;
size_t d, num_d; size_t d, num_d;
cl_git_pass(git_diff_workdir_to_index(repo, NULL, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, NULL));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(8, (int)num_d); cl_assert_equal_i(8, (int)num_d);
......
...@@ -32,7 +32,7 @@ void test_diff_index__0(void) ...@@ -32,7 +32,7 @@ void test_diff_index__0(void)
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_index_to_tree(g_repo, &opts, a, &diff)); cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
cl_git_pass(git_diff_foreach( cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
...@@ -60,7 +60,7 @@ void test_diff_index__0(void) ...@@ -60,7 +60,7 @@ void test_diff_index__0(void)
diff = NULL; diff = NULL;
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_index_to_tree(g_repo, &opts, b, &diff)); cl_git_pass(git_diff_index_to_tree(&diff, g_repo, b, NULL, &opts));
cl_git_pass(git_diff_foreach( cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
...@@ -125,7 +125,7 @@ void test_diff_index__1(void) ...@@ -125,7 +125,7 @@ void test_diff_index__1(void)
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_index_to_tree(g_repo, &opts, a, &diff)); cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
cl_assert_equal_i( cl_assert_equal_i(
GIT_EUSER, GIT_EUSER,
......
...@@ -350,7 +350,7 @@ static void index_iterator_test( ...@@ -350,7 +350,7 @@ static void index_iterator_test(
int count = 0; int count = 0;
git_repository *repo = cl_git_sandbox_init(sandbox); git_repository *repo = cl_git_sandbox_init(sandbox);
cl_git_pass(git_iterator_for_index_range(&i, repo, start, end)); cl_git_pass(git_iterator_for_repo_index_range(&i, repo, start, end));
cl_git_pass(git_iterator_current(i, &entry)); cl_git_pass(git_iterator_current(i, &entry));
while (entry != NULL) { while (entry != NULL) {
......
...@@ -88,7 +88,7 @@ void test_diff_patch__can_properly_display_the_removal_of_a_file(void) ...@@ -88,7 +88,7 @@ void test_diff_patch__can_properly_display_the_removal_of_a_file(void)
one = resolve_commit_oid_to_tree(g_repo, one_sha); one = resolve_commit_oid_to_tree(g_repo, one_sha);
another = resolve_commit_oid_to_tree(g_repo, another_sha); another = resolve_commit_oid_to_tree(g_repo, another_sha);
cl_git_pass(git_diff_tree_to_tree(g_repo, NULL, one, another, &diff)); cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, one, another, NULL));
cl_git_pass(git_diff_print_patch(diff, NULL, check_removal_cb)); cl_git_pass(git_diff_print_patch(diff, NULL, check_removal_cb));
...@@ -111,7 +111,7 @@ void test_diff_patch__to_string(void) ...@@ -111,7 +111,7 @@ void test_diff_patch__to_string(void)
one = resolve_commit_oid_to_tree(g_repo, one_sha); one = resolve_commit_oid_to_tree(g_repo, one_sha);
another = resolve_commit_oid_to_tree(g_repo, another_sha); another = resolve_commit_oid_to_tree(g_repo, another_sha);
cl_git_pass(git_diff_tree_to_tree(g_repo, NULL, one, another, &diff)); cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, one, another, NULL));
cl_assert_equal_i(1, git_diff_num_deltas(diff)); cl_assert_equal_i(1, git_diff_num_deltas(diff));
......
...@@ -47,7 +47,7 @@ void test_diff_rename__match_oid(void) ...@@ -47,7 +47,7 @@ void test_diff_rename__match_oid(void)
diffopts.flags |= GIT_DIFF_INCLUDE_UNMODIFIED; diffopts.flags |= GIT_DIFF_INCLUDE_UNMODIFIED;
cl_git_pass(git_diff_tree_to_tree( cl_git_pass(git_diff_tree_to_tree(
g_repo, &diffopts, old_tree, new_tree, &diff)); &diff, g_repo, old_tree, new_tree, &diffopts));
/* git diff --no-renames \ /* git diff --no-renames \
* 31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 \ * 31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 \
...@@ -79,7 +79,7 @@ void test_diff_rename__match_oid(void) ...@@ -79,7 +79,7 @@ void test_diff_rename__match_oid(void)
git_diff_list_free(diff); git_diff_list_free(diff);
cl_git_pass(git_diff_tree_to_tree( cl_git_pass(git_diff_tree_to_tree(
g_repo, &diffopts, old_tree, new_tree, &diff)); &diff, g_repo, old_tree, new_tree, &diffopts));
/* git diff --find-copies-harder \ /* git diff --find-copies-harder \
* 31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 \ * 31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 \
......
...@@ -34,7 +34,7 @@ void test_diff_tree__0(void) ...@@ -34,7 +34,7 @@ void test_diff_tree__0(void)
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff)); cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach( cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
...@@ -56,7 +56,7 @@ void test_diff_tree__0(void) ...@@ -56,7 +56,7 @@ void test_diff_tree__0(void)
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, c, b, &diff)); cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, b, &opts));
cl_git_pass(git_diff_foreach( cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
...@@ -141,9 +141,9 @@ void test_diff_tree__options(void) ...@@ -141,9 +141,9 @@ void test_diff_tree__options(void)
opts = test_options[i]; opts = test_options[i];
if (test_ab_or_cd[i] == 0) if (test_ab_or_cd[i] == 0)
cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff)); cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
else else
cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, c, d, &diff)); cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, d, &opts));
cl_git_pass(git_diff_foreach( cl_git_pass(git_diff_foreach(
diff, &actual, diff_file_fn, diff_hunk_fn, diff_line_fn)); diff, &actual, diff_file_fn, diff_hunk_fn, diff_line_fn));
...@@ -187,7 +187,7 @@ void test_diff_tree__bare(void) ...@@ -187,7 +187,7 @@ void test_diff_tree__bare(void)
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff)); cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach( cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
...@@ -225,9 +225,9 @@ void test_diff_tree__merge(void) ...@@ -225,9 +225,9 @@ void test_diff_tree__merge(void)
cl_assert((b = resolve_commit_oid_to_tree(g_repo, b_commit)) != NULL); cl_assert((b = resolve_commit_oid_to_tree(g_repo, b_commit)) != NULL);
cl_assert((c = resolve_commit_oid_to_tree(g_repo, c_commit)) != NULL); cl_assert((c = resolve_commit_oid_to_tree(g_repo, c_commit)) != NULL);
cl_git_pass(git_diff_tree_to_tree(g_repo, NULL, a, b, &diff1)); cl_git_pass(git_diff_tree_to_tree(&diff1, g_repo, a, b, NULL));
cl_git_pass(git_diff_tree_to_tree(g_repo, NULL, c, b, &diff2)); cl_git_pass(git_diff_tree_to_tree(&diff2, g_repo, c, b, NULL));
git_tree_free(a); git_tree_free(a);
git_tree_free(b); git_tree_free(b);
...@@ -279,7 +279,7 @@ void test_diff_tree__larger_hunks(void) ...@@ -279,7 +279,7 @@ void test_diff_tree__larger_hunks(void)
opts.context_lines = 1; opts.context_lines = 1;
opts.interhunk_lines = 0; opts.interhunk_lines = 0;
cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff)); cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
num_d = git_diff_num_deltas(diff); num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) { for (d = 0; d < num_d; ++d) {
......
...@@ -26,7 +26,7 @@ void test_diff_workdir__to_index(void) ...@@ -26,7 +26,7 @@ void test_diff_workdir__to_index(void)
opts.interhunk_lines = 1; opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED; opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -94,7 +94,7 @@ void test_diff_workdir__to_tree(void) ...@@ -94,7 +94,7 @@ void test_diff_workdir__to_tree(void)
* The results are documented at the bottom of this file in the * The results are documented at the bottom of this file in the
* long comment entitled "PREPARATION OF TEST DATA". * long comment entitled "PREPARATION OF TEST DATA".
*/ */
cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, a, &diff)); cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -127,8 +127,8 @@ void test_diff_workdir__to_tree(void) ...@@ -127,8 +127,8 @@ void test_diff_workdir__to_tree(void)
* a workdir to tree diff (even though it is not really). This is what * a workdir to tree diff (even though it is not really). This is what
* you would get from "git diff --name-status 26a125ee1bf" * you would get from "git diff --name-status 26a125ee1bf"
*/ */
cl_git_pass(git_diff_index_to_tree(g_repo, &opts, a, &diff)); cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff2)); cl_git_pass(git_diff_workdir_to_index(&diff2, g_repo, NULL, &opts));
cl_git_pass(git_diff_merge(diff, diff2)); cl_git_pass(git_diff_merge(diff, diff2));
git_diff_list_free(diff2); git_diff_list_free(diff2);
...@@ -164,8 +164,8 @@ void test_diff_workdir__to_tree(void) ...@@ -164,8 +164,8 @@ void test_diff_workdir__to_tree(void)
/* Again, emulating "git diff <sha>" for testing purposes using /* Again, emulating "git diff <sha>" for testing purposes using
* "git diff --name-status 0017bd4ab1ec3" instead. * "git diff --name-status 0017bd4ab1ec3" instead.
*/ */
cl_git_pass(git_diff_index_to_tree(g_repo, &opts, b, &diff)); cl_git_pass(git_diff_index_to_tree(&diff, g_repo, b, NULL, &opts));
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff2)); cl_git_pass(git_diff_workdir_to_index(&diff2, g_repo, NULL, &opts));
cl_git_pass(git_diff_merge(diff, diff2)); cl_git_pass(git_diff_merge(diff, diff2));
git_diff_list_free(diff2); git_diff_list_free(diff2);
...@@ -216,7 +216,7 @@ void test_diff_workdir__to_index_with_pathspec(void) ...@@ -216,7 +216,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
opts.pathspec.strings = &pathspec; opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1; opts.pathspec.count = 1;
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -239,7 +239,7 @@ void test_diff_workdir__to_index_with_pathspec(void) ...@@ -239,7 +239,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "modified_file"; pathspec = "modified_file";
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -262,7 +262,7 @@ void test_diff_workdir__to_index_with_pathspec(void) ...@@ -262,7 +262,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "subdir"; pathspec = "subdir";
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -285,7 +285,7 @@ void test_diff_workdir__to_index_with_pathspec(void) ...@@ -285,7 +285,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "*_deleted"; pathspec = "*_deleted";
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -324,7 +324,7 @@ void test_diff_workdir__filemode_changes(void) ...@@ -324,7 +324,7 @@ void test_diff_workdir__filemode_changes(void)
/* test once with no mods */ /* test once with no mods */
cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, NULL));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -347,7 +347,7 @@ void test_diff_workdir__filemode_changes(void) ...@@ -347,7 +347,7 @@ void test_diff_workdir__filemode_changes(void)
cl_assert(cl_toggle_filemode("issue_592/a.txt")); cl_assert(cl_toggle_filemode("issue_592/a.txt"));
cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, NULL));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -386,7 +386,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void) ...@@ -386,7 +386,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
/* test once with no mods */ /* test once with no mods */
cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, NULL));
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach( cl_git_pass(git_diff_foreach(
...@@ -402,7 +402,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void) ...@@ -402,7 +402,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
cl_assert(cl_toggle_filemode("issue_592/a.txt")); cl_assert(cl_toggle_filemode("issue_592/a.txt"));
cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, NULL));
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach( cl_git_pass(git_diff_foreach(
...@@ -442,8 +442,8 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void) ...@@ -442,8 +442,8 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
opts.pathspec.strings = &pathspec; opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1; opts.pathspec.count = 1;
cl_git_pass(git_diff_index_to_tree(g_repo, &opts, tree, &diff_i2t)); cl_git_pass(git_diff_index_to_tree(&diff_i2t, g_repo, tree, NULL, &opts));
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff_w2i)); cl_git_pass(git_diff_workdir_to_index(&diff_w2i, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -529,7 +529,7 @@ void test_diff_workdir__eof_newline_changes(void) ...@@ -529,7 +529,7 @@ void test_diff_workdir__eof_newline_changes(void)
opts.pathspec.strings = &pathspec; opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1; opts.pathspec.count = 1;
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -556,7 +556,7 @@ void test_diff_workdir__eof_newline_changes(void) ...@@ -556,7 +556,7 @@ void test_diff_workdir__eof_newline_changes(void)
cl_git_append2file("status/current_file", "\n"); cl_git_append2file("status/current_file", "\n");
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -583,7 +583,7 @@ void test_diff_workdir__eof_newline_changes(void) ...@@ -583,7 +583,7 @@ void test_diff_workdir__eof_newline_changes(void)
cl_git_rewritefile("status/current_file", "current_file"); cl_git_rewritefile("status/current_file", "current_file");
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) { for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp)); memset(&exp, 0, sizeof(exp));
...@@ -699,13 +699,13 @@ void test_diff_workdir__larger_hunks(void) ...@@ -699,13 +699,13 @@ void test_diff_workdir__larger_hunks(void)
/* okay, this is a bit silly, but oh well */ /* okay, this is a bit silly, but oh well */
switch (i) { switch (i) {
case 0: case 0:
cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
break; break;
case 1: case 1:
cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, a, &diff)); cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
break; break;
case 2: case 2:
cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, b, &diff)); cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, b, &opts));
break; break;
} }
...@@ -784,7 +784,7 @@ void test_diff_workdir__submodules(void) ...@@ -784,7 +784,7 @@ void test_diff_workdir__submodules(void)
GIT_DIFF_RECURSE_UNTRACKED_DIRS | GIT_DIFF_RECURSE_UNTRACKED_DIRS |
GIT_DIFF_INCLUDE_UNTRACKED_CONTENT; GIT_DIFF_INCLUDE_UNTRACKED_CONTENT;
cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, a, &diff)); cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
/* diff_print(stderr, diff); */ /* diff_print(stderr, diff); */
...@@ -828,10 +828,13 @@ void test_diff_workdir__cannot_diff_against_a_bare_repository(void) ...@@ -828,10 +828,13 @@ void test_diff_workdir__cannot_diff_against_a_bare_repository(void)
g_repo = cl_git_sandbox_init("testrepo.git"); g_repo = cl_git_sandbox_init("testrepo.git");
cl_assert_equal_i(GIT_EBAREREPO, git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_assert_equal_i(
GIT_EBAREREPO, git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
cl_git_pass(git_repository_head_tree(&tree, g_repo)); cl_git_pass(git_repository_head_tree(&tree, g_repo));
cl_assert_equal_i(GIT_EBAREREPO, git_diff_workdir_to_tree(g_repo, &opts, tree, &diff));
cl_assert_equal_i(
GIT_EBAREREPO, git_diff_workdir_to_tree(&diff, g_repo, tree, &opts));
git_tree_free(tree); git_tree_free(tree);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment