summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/checkout/conflict.c2
-rw-r--r--tests/checkout/index.c6
-rw-r--r--tests/checkout/tree.c20
-rw-r--r--tests/clar_libgit2.c8
-rw-r--r--tests/clar_libgit2.h1
-rw-r--r--tests/core/path.c2
-rw-r--r--tests/diff/diff_helpers.c2
-rw-r--r--tests/diff/diff_helpers.h2
-rw-r--r--tests/diff/index.c76
-rw-r--r--tests/diff/workdir.c45
-rw-r--r--tests/index/addall.c154
-rw-r--r--tests/index/collision.c10
-rw-r--r--tests/index/conflicts.c75
-rw-r--r--tests/merge/trees/trivial.c2
-rw-r--r--tests/merge/workdir/trivial.c2
-rw-r--r--tests/network/refspecs.c10
-rw-r--r--tests/network/remote/local.c10
-rw-r--r--tests/network/remote/remotes.c14
-rw-r--r--tests/object/tree/duplicateentries.c6
-rw-r--r--tests/odb/foreach.c20
-rw-r--r--tests/online/clone.c68
-rw-r--r--tests/online/remotes.c23
-rw-r--r--tests/refs/branches/upstream.c32
-rw-r--r--tests/remote/insteadof.c72
-rw-r--r--tests/reset/hard.c2
-rw-r--r--tests/resources/testrepo2/.gitted/config12
-rw-r--r--tests/stash/apply.c18
-rw-r--r--tests/status/worktree.c56
28 files changed, 629 insertions, 121 deletions
diff --git a/tests/checkout/conflict.c b/tests/checkout/conflict.c
index 3d763af12..006dc6522 100644
--- a/tests/checkout/conflict.c
+++ b/tests/checkout/conflict.c
@@ -102,7 +102,7 @@ static void create_index(struct checkout_index_entry *entries, size_t entries_le
memset(&entry, 0x0, sizeof(git_index_entry));
entry.mode = entries[i].mode;
- entry.flags = entries[i].stage << GIT_IDXENTRY_STAGESHIFT;
+ GIT_IDXENTRY_STAGE_SET(&entry, entries[i].stage);
git_oid_fromstr(&entry.id, entries[i].oid_str);
entry.path = entries[i].path;
diff --git a/tests/checkout/index.c b/tests/checkout/index.c
index de0770dba..89b014586 100644
--- a/tests/checkout/index.c
+++ b/tests/checkout/index.c
@@ -685,15 +685,15 @@ static void add_conflict(git_index *index, const char *path)
entry.path = path;
git_oid_fromstr(&entry.id, "d427e0b2e138501a3d15cc376077a3631e15bd46");
- entry.flags = (1 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, 1);
cl_git_pass(git_index_add(index, &entry));
git_oid_fromstr(&entry.id, "4e886e602529caa9ab11d71f86634bd1b6e0de10");
- entry.flags = (2 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, 2);
cl_git_pass(git_index_add(index, &entry));
git_oid_fromstr(&entry.id, "2bd0a343aeef7a2cf0d158478966a6e587ff3863");
- entry.flags = (3 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, 3);
cl_git_pass(git_index_add(index, &entry));
}
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index 50541a703..be4019822 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -306,7 +306,7 @@ void test_checkout_tree__conflict_on_ignored_when_not_overwriting(void)
cl_git_fail(error = checkout_tree_with_blob_ignored_in_workdir(
GIT_CHECKOUT_SAFE | GIT_CHECKOUT_DONT_OVERWRITE_IGNORED, false));
- cl_assert_equal_i(GIT_EMERGECONFLICT, error);
+ cl_assert_equal_i(GIT_ECONFLICT, error);
}
void test_checkout_tree__can_overwrite_ignored_by_default(void)
@@ -327,7 +327,7 @@ void test_checkout_tree__conflict_on_ignored_folder_when_not_overwriting(void)
cl_git_fail(error = checkout_tree_with_blob_ignored_in_workdir(
GIT_CHECKOUT_SAFE | GIT_CHECKOUT_DONT_OVERWRITE_IGNORED, true));
- cl_assert_equal_i(GIT_EMERGECONFLICT, error);
+ cl_assert_equal_i(GIT_ECONFLICT, error);
}
void test_checkout_tree__can_overwrite_ignored_folder_by_default(void)
@@ -512,7 +512,7 @@ void assert_conflict(
g_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
cl_assert_equal_i(
- GIT_EMERGECONFLICT, git_checkout_tree(g_repo, g_object, &g_opts));
+ GIT_ECONFLICT, git_checkout_tree(g_repo, g_object, &g_opts));
/* Stage the conflicting change */
cl_git_pass(git_index_add_bypath(index, entry_path));
@@ -520,10 +520,10 @@ void assert_conflict(
git_index_free(index);
cl_assert_equal_i(
- GIT_EMERGECONFLICT, git_checkout_tree(g_repo, g_object, &g_opts));
+ GIT_ECONFLICT, git_checkout_tree(g_repo, g_object, &g_opts));
}
-void test_checkout_tree__checking_out_a_conflicting_type_change_returns_EMERGECONFLICT(void)
+void test_checkout_tree__checking_out_a_conflicting_type_change_returns_ECONFLICT(void)
{
/*
* 099faba adds a symlink named 'link_to_new.txt'
@@ -533,7 +533,7 @@ void test_checkout_tree__checking_out_a_conflicting_type_change_returns_EMERGECO
assert_conflict("link_to_new.txt", "old.txt", "a65fedf", "099faba");
}
-void test_checkout_tree__checking_out_a_conflicting_type_change_returns_EMERGECONFLICT_2(void)
+void test_checkout_tree__checking_out_a_conflicting_type_change_returns_ECONFLICT_2(void)
{
/*
* cf80f8d adds a directory named 'a/'
@@ -543,7 +543,7 @@ void test_checkout_tree__checking_out_a_conflicting_type_change_returns_EMERGECO
assert_conflict("a", "hello\n", "a4a7dce", "cf80f8d");
}
-void test_checkout_tree__checking_out_a_conflicting_content_change_returns_EMERGECONFLICT(void)
+void test_checkout_tree__checking_out_a_conflicting_content_change_returns_ECONFLICT(void)
{
/*
* c47800c adds a symlink named 'branch_file.txt'
@@ -893,16 +893,16 @@ static void create_conflict(const char *path)
memset(&entry, 0x0, sizeof(git_index_entry));
entry.mode = 0100644;
- entry.flags = 1 << GIT_IDXENTRY_STAGESHIFT;
+ GIT_IDXENTRY_STAGE_SET(&entry, 1);
git_oid_fromstr(&entry.id, "d427e0b2e138501a3d15cc376077a3631e15bd46");
entry.path = path;
cl_git_pass(git_index_add(index, &entry));
- entry.flags = 2 << GIT_IDXENTRY_STAGESHIFT;
+ GIT_IDXENTRY_STAGE_SET(&entry, 2);
git_oid_fromstr(&entry.id, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf");
cl_git_pass(git_index_add(index, &entry));
- entry.flags = 3 << GIT_IDXENTRY_STAGESHIFT;
+ GIT_IDXENTRY_STAGE_SET(&entry, 3);
git_oid_fromstr(&entry.id, "2bd0a343aeef7a2cf0d158478966a6e587ff3863");
cl_git_pass(git_index_add(index, &entry));
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index 6087c2a67..dabc47a09 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -197,6 +197,14 @@ git_repository *cl_git_sandbox_init(const char *sandbox)
return _cl_repo;
}
+git_repository *cl_git_sandbox_init_new(const char *sandbox)
+{
+ cl_git_pass(git_repository_init(&_cl_repo, sandbox, false));
+ _cl_sandbox = sandbox;
+
+ return _cl_repo;
+}
+
git_repository *cl_git_sandbox_reopen(void)
{
if (_cl_repo) {
diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h
index 86c90b049..9ab0da4f6 100644
--- a/tests/clar_libgit2.h
+++ b/tests/clar_libgit2.h
@@ -127,6 +127,7 @@ int cl_rename(const char *source, const char *dest);
/* Git sandbox setup helpers */
git_repository *cl_git_sandbox_init(const char *sandbox);
+git_repository *cl_git_sandbox_init_new(const char *name);
void cl_git_sandbox_cleanup(void);
git_repository *cl_git_sandbox_reopen(void);
diff --git a/tests/core/path.c b/tests/core/path.c
index 7d3e4938f..c3e622f02 100644
--- a/tests/core/path.c
+++ b/tests/core/path.c
@@ -492,7 +492,7 @@ void test_core_path__13_cannot_prettify_a_non_existing_file(void)
{
git_buf p = GIT_BUF_INIT;
- cl_must_pass(git_path_exists(NON_EXISTING_FILEPATH) == false);
+ cl_assert_equal_b(git_path_exists(NON_EXISTING_FILEPATH), false);
cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH, NULL));
cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH "/so-do-i", NULL));
diff --git a/tests/diff/diff_helpers.c b/tests/diff/diff_helpers.c
index 47e06f0d8..03862d6b4 100644
--- a/tests/diff/diff_helpers.c
+++ b/tests/diff/diff_helpers.c
@@ -68,7 +68,7 @@ int diff_file_cb(
if ((delta->flags & GIT_DIFF_FLAG_BINARY) != 0)
e->files_binary++;
- cl_assert(delta->status <= GIT_DELTA_TYPECHANGE);
+ cl_assert(delta->status <= GIT_DELTA_CONFLICTED);
e->file_status[delta->status] += 1;
diff --git a/tests/diff/diff_helpers.h b/tests/diff/diff_helpers.h
index bf21f4b1f..6bcd1e671 100644
--- a/tests/diff/diff_helpers.h
+++ b/tests/diff/diff_helpers.h
@@ -8,7 +8,7 @@ typedef struct {
int files;
int files_binary;
- int file_status[10]; /* indexed by git_delta_t value */
+ int file_status[11]; /* indexed by git_delta_t value */
int hunks;
int hunk_new_lines;
diff --git a/tests/diff/index.c b/tests/diff/index.c
index 21afe8da2..cf883f12a 100644
--- a/tests/diff/index.c
+++ b/tests/diff/index.c
@@ -163,3 +163,79 @@ void test_diff_index__checks_options_version(void)
git_tree_free(a);
}
+static void do_conflicted_diff(diff_expects *exp, unsigned long flags)
+{
+ const char *a_commit = "26a125ee1bf"; /* the current HEAD */
+ git_tree *a = resolve_commit_oid_to_tree(g_repo, a_commit);
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ git_index_entry ancestor = {{0}}, ours = {{0}}, theirs = {{0}};
+ git_diff *diff = NULL;
+ git_index *index;
+
+ cl_assert(a);
+
+ opts.context_lines = 1;
+ opts.interhunk_lines = 1;
+ opts.flags |= flags;
+
+ memset(exp, 0, sizeof(diff_expects));
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ ancestor.path = ours.path = theirs.path = "staged_changes";
+ ancestor.mode = ours.mode = theirs.mode = 0100644;
+
+ git_oid_fromstr(&ancestor.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
+ git_oid_fromstr(&ours.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
+ git_oid_fromstr(&theirs.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
+
+ cl_git_pass(git_index_conflict_add(index, &ancestor, &ours, &theirs));
+ cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, index, &opts));
+
+ cl_git_pass(git_diff_foreach(
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, exp));
+
+ git_diff_free(diff);
+ git_tree_free(a);
+ git_index_free(index);
+}
+
+void test_diff_index__reports_conflicts(void)
+{
+ diff_expects exp;
+
+ do_conflicted_diff(&exp, 0);
+
+ cl_assert_equal_i(8, exp.files);
+ cl_assert_equal_i(3, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(2, exp.file_status[GIT_DELTA_DELETED]);
+ cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_CONFLICTED]);
+
+ cl_assert_equal_i(7, exp.hunks);
+
+ cl_assert_equal_i(9, exp.lines);
+ cl_assert_equal_i(2, exp.line_ctxt);
+ cl_assert_equal_i(5, exp.line_adds);
+ cl_assert_equal_i(2, exp.line_dels);
+}
+
+void test_diff_index__reports_conflicts_when_reversed(void)
+{
+ diff_expects exp;
+
+ do_conflicted_diff(&exp, GIT_DIFF_REVERSE);
+
+ cl_assert_equal_i(8, exp.files);
+ cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(3, exp.file_status[GIT_DELTA_DELETED]);
+ cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_CONFLICTED]);
+
+ cl_assert_equal_i(7, exp.hunks);
+
+ cl_assert_equal_i(9, exp.lines);
+ cl_assert_equal_i(2, exp.line_ctxt);
+ cl_assert_equal_i(2, exp.line_adds);
+ cl_assert_equal_i(5, exp.line_dels);
+}
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index 963be9481..65005f927 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -68,6 +68,51 @@ void test_diff_workdir__to_index(void)
git_diff_free(diff);
}
+void test_diff_workdir__to_index_with_conflicts(void)
+{
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ git_diff *diff = NULL;
+ git_index *index;
+ git_index_entry our_entry = {{0}}, their_entry = {{0}};
+ diff_expects exp = {0};
+
+ g_repo = cl_git_sandbox_init("status");
+
+ opts.context_lines = 3;
+ opts.interhunk_lines = 1;
+
+ /* Adding an entry that represents a rename gets two files in conflict */
+ our_entry.path = "subdir/modified_file";
+ our_entry.mode = 0100644;
+
+ their_entry.path = "subdir/rename_conflict";
+ their_entry.mode = 0100644;
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(git_index_conflict_add(index, NULL, &our_entry, &their_entry));
+
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, index, &opts));
+
+ cl_git_pass(diff_foreach_via_iterator(
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+
+ cl_assert_equal_i(9, exp.files);
+ cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(4, exp.file_status[GIT_DELTA_DELETED]);
+ cl_assert_equal_i(3, exp.file_status[GIT_DELTA_MODIFIED]);
+ cl_assert_equal_i(2, exp.file_status[GIT_DELTA_CONFLICTED]);
+
+ cl_assert_equal_i(7, exp.hunks);
+
+ cl_assert_equal_i(12, exp.lines);
+ cl_assert_equal_i(4, exp.line_ctxt);
+ cl_assert_equal_i(3, exp.line_adds);
+ cl_assert_equal_i(5, exp.line_dels);
+
+ git_diff_free(diff);
+ git_index_free(index);
+}
+
void test_diff_workdir__to_index_with_assume_unchanged(void)
{
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
diff --git a/tests/index/addall.c b/tests/index/addall.c
index 377d2079e..f344cc6ae 100644
--- a/tests/index/addall.c
+++ b/tests/index/addall.c
@@ -12,10 +12,7 @@ void test_index_addall__initialize(void)
void test_index_addall__cleanup(void)
{
- git_repository_free(g_repo);
- g_repo = NULL;
-
- cl_fixture_cleanup(TEST_DIR);
+ cl_git_sandbox_cleanup();
}
#define STATUS_INDEX_FLAGS \
@@ -36,6 +33,7 @@ typedef struct {
size_t wt_dels;
size_t wt_mods;
size_t ignores;
+ size_t conflicts;
} index_status_counts;
static int index_status_cb(
@@ -67,6 +65,8 @@ static int index_status_cb(
if (status_flags & GIT_STATUS_IGNORED)
vals->ignores++;
+ if (status_flags & GIT_STATUS_CONFLICTED)
+ vals->conflicts++;
return 0;
}
@@ -75,7 +75,7 @@ static void check_status_at_line(
git_repository *repo,
size_t index_adds, size_t index_dels, size_t index_mods,
size_t wt_adds, size_t wt_dels, size_t wt_mods, size_t ignores,
- const char *file, int line)
+ size_t conflicts, const char *file, int line)
{
index_status_counts vals;
@@ -97,10 +97,12 @@ static void check_status_at_line(
file,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods);
clar__assert_equal(
file,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores);
+ clar__assert_equal(
+ file,line,"wrong conflicts", 1, "%"PRIuZ, conflicts, vals.conflicts);
}
-#define check_status(R,IA,ID,IM,WA,WD,WM,IG) \
- check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,__FILE__,__LINE__)
+#define check_status(R,IA,ID,IM,WA,WD,WM,IG,C) \
+ check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,C,__FILE__,__LINE__)
static void check_stat_data(git_index *index, const char *path, bool match)
{
@@ -137,21 +139,22 @@ static void check_stat_data(git_index *index, const char *path, bool match)
static void addall_create_test_repo(bool check_every_step)
{
- cl_git_pass(git_repository_init(&g_repo, TEST_DIR, false));
+ g_repo = cl_git_sandbox_init_new(TEST_DIR);
+
if (check_every_step)
- check_status(g_repo, 0, 0, 0, 0, 0, 0, 0);
+ check_status(g_repo, 0, 0, 0, 0, 0, 0, 0, 0);
cl_git_mkfile(TEST_DIR "/file.foo", "a file");
if (check_every_step)
- check_status(g_repo, 0, 0, 0, 1, 0, 0, 0);
+ check_status(g_repo, 0, 0, 0, 1, 0, 0, 0, 0);
cl_git_mkfile(TEST_DIR "/.gitignore", "*.foo\n");
if (check_every_step)
- check_status(g_repo, 0, 0, 0, 1, 0, 0, 1);
+ check_status(g_repo, 0, 0, 0, 1, 0, 0, 1, 0);
cl_git_mkfile(TEST_DIR "/file.bar", "another file");
if (check_every_step)
- check_status(g_repo, 0, 0, 0, 2, 0, 0, 1);
+ check_status(g_repo, 0, 0, 0, 2, 0, 0, 1, 0);
}
void test_index_addall__repo_lifecycle(void)
@@ -171,107 +174,107 @@ void test_index_addall__repo_lifecycle(void)
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
check_stat_data(index, TEST_DIR "/file.bar", true);
- check_status(g_repo, 1, 0, 0, 1, 0, 0, 1);
+ check_status(g_repo, 1, 0, 0, 1, 0, 0, 1, 0);
cl_git_rewritefile(TEST_DIR "/file.bar", "new content for file");
check_stat_data(index, TEST_DIR "/file.bar", false);
- check_status(g_repo, 1, 0, 0, 1, 0, 1, 1);
+ check_status(g_repo, 1, 0, 0, 1, 0, 1, 1, 0);
cl_git_mkfile(TEST_DIR "/file.zzz", "yet another one");
cl_git_mkfile(TEST_DIR "/other.zzz", "yet another one");
cl_git_mkfile(TEST_DIR "/more.zzz", "yet another one");
- check_status(g_repo, 1, 0, 0, 4, 0, 1, 1);
+ check_status(g_repo, 1, 0, 0, 4, 0, 1, 1, 0);
cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
check_stat_data(index, TEST_DIR "/file.bar", true);
- check_status(g_repo, 1, 0, 0, 4, 0, 0, 1);
+ check_status(g_repo, 1, 0, 0, 4, 0, 0, 1, 0);
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
check_stat_data(index, TEST_DIR "/file.zzz", true);
- check_status(g_repo, 2, 0, 0, 3, 0, 0, 1);
+ check_status(g_repo, 2, 0, 0, 3, 0, 0, 1, 0);
cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "first commit");
- check_status(g_repo, 0, 0, 0, 3, 0, 0, 1);
+ check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0);
if (cl_repo_get_bool(g_repo, "core.filemode")) {
cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
cl_must_pass(p_chmod(TEST_DIR "/file.zzz", 0777));
cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
- check_status(g_repo, 0, 0, 1, 3, 0, 0, 1);
+ check_status(g_repo, 0, 0, 1, 3, 0, 0, 1, 0);
/* go back to what we had before */
cl_must_pass(p_chmod(TEST_DIR "/file.zzz", 0666));
cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
- check_status(g_repo, 0, 0, 0, 3, 0, 0, 1);
+ check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0);
}
/* attempt to add an ignored file - does nothing */
strs[0] = "file.foo";
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
- check_status(g_repo, 0, 0, 0, 3, 0, 0, 1);
+ check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0);
/* add with check - should generate error */
error = git_index_add_all(
index, &paths, GIT_INDEX_ADD_CHECK_PATHSPEC, NULL, NULL);
cl_assert_equal_i(GIT_EINVALIDSPEC, error);
- check_status(g_repo, 0, 0, 0, 3, 0, 0, 1);
+ check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0);
/* add with force - should allow */
cl_git_pass(git_index_add_all(
index, &paths, GIT_INDEX_ADD_FORCE, NULL, NULL));
check_stat_data(index, TEST_DIR "/file.foo", true);
- check_status(g_repo, 1, 0, 0, 3, 0, 0, 0);
+ check_status(g_repo, 1, 0, 0, 3, 0, 0, 0, 0);
/* now it's in the index, so regular add should work */
cl_git_rewritefile(TEST_DIR "/file.foo", "new content for file");
check_stat_data(index, TEST_DIR "/file.foo", false);
- check_status(g_repo, 1, 0, 0, 3, 0, 1, 0);
+ check_status(g_repo, 1, 0, 0, 3, 0, 1, 0, 0);
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
check_stat_data(index, TEST_DIR "/file.foo", true);
- check_status(g_repo, 1, 0, 0, 3, 0, 0, 0);
+ check_status(g_repo, 1, 0, 0, 3, 0, 0, 0, 0);
cl_git_pass(git_index_add_bypath(index, "more.zzz"));
check_stat_data(index, TEST_DIR "/more.zzz", true);
- check_status(g_repo, 2, 0, 0, 2, 0, 0, 0);
+ check_status(g_repo, 2, 0, 0, 2, 0, 0, 0, 0);
cl_git_rewritefile(TEST_DIR "/file.zzz", "new content for file");
- check_status(g_repo, 2, 0, 0, 2, 0, 1, 0);
+ check_status(g_repo, 2, 0, 0, 2, 0, 1, 0, 0);
cl_git_pass(git_index_add_bypath(index, "file.zzz"));
check_stat_data(index, TEST_DIR "/file.zzz", true);
- check_status(g_repo, 2, 0, 1, 2, 0, 0, 0);
+ check_status(g_repo, 2, 0, 1, 2, 0, 0, 0, 0);
strs[0] = "*.zzz";
cl_git_pass(git_index_remove_all(index, &paths, NULL, NULL));
- check_status(g_repo, 1, 1, 0, 4, 0, 0, 0);
+ check_status(g_repo, 1, 1, 0, 4, 0, 0, 0, 0);
cl_git_pass(git_index_add_bypath(index, "file.zzz"));
- check_status(g_repo, 1, 0, 1, 3, 0, 0, 0);
+ check_status(g_repo, 1, 0, 1, 3, 0, 0, 0, 0);
cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "second commit");
- check_status(g_repo, 0, 0, 0, 3, 0, 0, 0);
+ check_status(g_repo, 0, 0, 0, 3, 0, 0, 0, 0);
cl_must_pass(p_unlink(TEST_DIR "/file.zzz"));
- check_status(g_repo, 0, 0, 0, 3, 1, 0, 0);
+ check_status(g_repo, 0, 0, 0, 3, 1, 0, 0, 0);
/* update_all should be able to remove entries */
cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
- check_status(g_repo, 0, 1, 0, 3, 0, 0, 0);
+ check_status(g_repo, 0, 1, 0, 3, 0, 0, 0, 0);
strs[0] = "*";
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
- check_status(g_repo, 3, 1, 0, 0, 0, 0, 0);
+ check_status(g_repo, 3, 1, 0, 0, 0, 0, 0, 0);
/* must be able to remove at any position while still updating other files */
cl_must_pass(p_unlink(TEST_DIR "/.gitignore"));
cl_git_rewritefile(TEST_DIR "/file.zzz", "reconstructed file");
cl_git_rewritefile(TEST_DIR "/more.zzz", "altered file reality");
- check_status(g_repo, 3, 1, 0, 1, 1, 1, 0);
+ check_status(g_repo, 3, 1, 0, 1, 1, 1, 0, 0);
cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
- check_status(g_repo, 2, 1, 0, 1, 0, 0, 0);
+ check_status(g_repo, 2, 1, 0, 1, 0, 0, 0, 0);
/* this behavior actually matches 'git add -u' where "file.zzz" has
* been removed from the index, so when you go to update, even though
* it exists in the HEAD, it is not re-added to the index, leaving it
@@ -285,7 +288,6 @@ void test_index_addall__repo_lifecycle(void)
void test_index_addall__files_in_folders(void)
{
git_index *index;
- git_strarray paths = { NULL, 0 };
addall_create_test_repo(true);
@@ -293,14 +295,14 @@ void test_index_addall__files_in_folders(void)
cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
check_stat_data(index, TEST_DIR "/file.bar", true);
- check_status(g_repo, 2, 0, 0, 0, 0, 0, 1);
+ check_status(g_repo, 2, 0, 0, 0, 0, 0, 1, 0);
cl_must_pass(p_mkdir(TEST_DIR "/subdir", 0777));
cl_git_mkfile(TEST_DIR "/subdir/file", "hello!\n");
- check_status(g_repo, 2, 0, 0, 1, 0, 0, 1);
+ check_status(g_repo, 2, 0, 0, 1, 0, 0, 1, 0);
cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
- check_status(g_repo, 3, 0, 0, 0, 0, 0, 1);
+ check_status(g_repo, 3, 0, 0, 0, 0, 0, 1, 0);
git_index_free(index);
}
@@ -337,7 +339,7 @@ void test_index_addall__callback_filtering(void)
cl_git_pass(
git_index_add_all(index, NULL, 0, addall_match_prefix, "file."));
check_stat_data(index, TEST_DIR "/file.bar", true);
- check_status(g_repo, 1, 0, 0, 1, 0, 0, 1);
+ check_status(g_repo, 1, 0, 0, 1, 0, 0, 1, 0);
cl_git_mkfile(TEST_DIR "/file.zzz", "yet another one");
cl_git_mkfile(TEST_DIR "/more.zzz", "yet another one");
@@ -345,32 +347,32 @@ void test_index_addall__callback_filtering(void)
cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
check_stat_data(index, TEST_DIR "/file.bar", true);
- check_status(g_repo, 1, 0, 0, 4, 0, 0, 1);
+ check_status(g_repo, 1, 0, 0, 4, 0, 0, 1, 0);
cl_git_pass(
git_index_add_all(index, NULL, 0, addall_match_prefix, "other"));
check_stat_data(index, TEST_DIR "/other.zzz", true);
- check_status(g_repo, 2, 0, 0, 3, 0, 0, 1);
+ check_status(g_repo, 2, 0, 0, 3, 0, 0, 1, 0);
cl_git_pass(
git_index_add_all(index, NULL, 0, addall_match_suffix, ".zzz"));
- check_status(g_repo, 4, 0, 0, 1, 0, 0, 1);
+ check_status(g_repo, 4, 0, 0, 1, 0, 0, 1, 0);
cl_git_pass(
git_index_remove_all(index, NULL, addall_match_suffix, ".zzz"));
- check_status(g_repo, 1, 0, 0, 4, 0, 0, 1);
+ check_status(g_repo, 1, 0, 0, 4, 0, 0, 1, 0);
cl_git_fail_with(
git_index_add_all(index, NULL, 0, addall_cancel_at, "more.zzz"), -123);
- check_status(g_repo, 3, 0, 0, 2, 0, 0, 1);
+ check_status(g_repo, 3, 0, 0, 2, 0, 0, 1, 0);
cl_git_fail_with(
git_index_add_all(index, NULL, 0, addall_cancel_at, "other.zzz"), -123);
- check_status(g_repo, 4, 0, 0, 1, 0, 0, 1);
+ check_status(g_repo, 4, 0, 0, 1, 0, 0, 1, 0);
cl_git_pass(
git_index_add_all(index, NULL, 0, addall_match_suffix, ".zzz"));
- check_status(g_repo, 5, 0, 0, 0, 0, 0, 1);
+ check_status(g_repo, 5, 0, 0, 0, 0, 0, 1, 0);
cl_must_pass(p_unlink(TEST_DIR "/file.zzz"));
cl_must_pass(p_unlink(TEST_DIR "/more.zzz"));
@@ -380,13 +382,65 @@ void test_index_addall__callback_filtering(void)
git_index_update_all(index, NULL, addall_cancel_at, "more.zzz"), -123);
/* file.zzz removed from index (so Index Adds 5 -> 4) and
* more.zzz + other.zzz removed (so Worktree Dels 0 -> 2) */
- check_status(g_repo, 4, 0, 0, 0, 2, 0, 1);
+ check_status(g_repo, 4, 0, 0, 0, 2, 0, 1, 0);
cl_git_fail_with(
git_index_update_all(index, NULL, addall_cancel_at, "other.zzz"), -123);
/* more.zzz removed from index (so Index Adds 4 -> 3) and
* Just other.zzz removed (so Worktree Dels 2 -> 1) */
- check_status(g_repo, 3, 0, 0, 0, 1, 0, 1);
+ check_status(g_repo, 3, 0, 0, 0, 1, 0, 1, 0);
+
+ git_index_free(index);
+}
+
+void test_index_addall__adds_conflicts(void)
+{
+ git_index *index;
+ git_reference *ref;
+ git_annotated_commit *annotated;
+
+ g_repo = cl_git_sandbox_init("merge-resolve");
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ check_status(g_repo, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/heads/branch"));
+ cl_git_pass(git_annotated_commit_from_ref(&annotated, g_repo, ref));
+
+ cl_git_pass(git_merge(g_repo, (const git_annotated_commit**)&annotated, 1, NULL, NULL));
+ check_status(g_repo, 0, 1, 2, 0, 0, 0, 0, 1);
+ cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
+ check_status(g_repo, 0, 1, 3, 0, 0, 0, 0, 0);
+
+ git_annotated_commit_free(annotated);
+ git_reference_free(ref);
git_index_free(index);
}
+
+void test_index_addall__removes_deleted_conflicted_files(void)
+{
+ git_index *index;
+ git_reference *ref;
+ git_annotated_commit *annotated;
+
+ g_repo = cl_git_sandbox_init("merge-resolve");
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ check_status(g_repo, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/heads/branch"));
+ cl_git_pass(git_annotated_commit_from_ref(&annotated, g_repo, ref));
+
+ cl_git_pass(git_merge(g_repo, (const git_annotated_commit**)&annotated, 1, NULL, NULL));
+ check_status(g_repo, 0, 1, 2, 0, 0, 0, 0, 1);
+
+ cl_git_rmfile("merge-resolve/conflicting.txt");
+
+ cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL));
+ check_status(g_repo, 0, 2, 2, 0, 0, 0, 0, 0);
+
+ git_annotated_commit_free(annotated);
+ git_reference_free(ref);
+ git_index_free(index);
+} \ No newline at end of file
diff --git a/tests/index/collision.c b/tests/index/collision.c
index 1f002e8d3..19c1548e9 100644
--- a/tests/index/collision.c
+++ b/tests/index/collision.c
@@ -57,7 +57,7 @@ void test_index_collision__add_with_highstage_1(void)
git_oid_fromstr(&entry.id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
entry.path = "a/b";
- entry.flags = (2 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, 2);
cl_git_pass(git_index_add(index, &entry));
/* create a blob beneath the previous tree entry */
@@ -67,7 +67,7 @@ void test_index_collision__add_with_highstage_1(void)
/* create another tree entry above the blob */
entry.path = "a/b";
- entry.flags = (1 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, 1);
cl_git_pass(git_index_add(index, &entry));
git_index_free(index);
@@ -89,17 +89,17 @@ void test_index_collision__add_with_highstage_2(void)
git_oid_fromstr(&entry.id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
entry.path = "a/b/c";
- entry.flags = (1 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, 1);
cl_git_pass(git_index_add(index, &entry));
/* create a blob beneath the previous tree entry */
entry.path = "a/b/c";
- entry.flags = (2 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, 2);
cl_git_pass(git_index_add(index, &entry));
/* create another tree entry above the blob */
entry.path = "a/b";
- entry.flags = (3 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, 3);
cl_git_pass(git_index_add(index, &entry));
git_index_free(index);
diff --git a/tests/index/conflicts.c b/tests/index/conflicts.c
index 427351693..b7a2456eb 100644
--- a/tests/index/conflicts.c
+++ b/tests/index/conflicts.c
@@ -16,6 +16,7 @@ static git_index *repo_index;
#define CONFLICTS_TWO_OUR_OID "8b3f43d2402825c200f835ca1762413e386fd0b2"
#define CONFLICTS_TWO_THEIR_OID "220bd62631c8cf7a83ef39c6b94595f00517211e"
+#define TEST_STAGED_OID "beefdadafeedabedcafedeedbabedeadbeaddeaf"
#define TEST_ANCESTOR_OID "f00ff00ff00ff00ff00ff00ff00ff00ff00ff00f"
#define TEST_OUR_OID "b44bb44bb44bb44bb44bb44bb44bb44bb44bb44b"
#define TEST_THEIR_OID "0123456789abcdef0123456789abcdef01234567"
@@ -46,15 +47,18 @@ void test_index_conflicts__add(void)
memset(&their_entry, 0x0, sizeof(git_index_entry));
ancestor_entry.path = "test-one.txt";
- ancestor_entry.flags |= (1 << GIT_IDXENTRY_STAGESHIFT);
+ ancestor_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1);
git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID);
our_entry.path = "test-one.txt";
- ancestor_entry.flags |= (2 << GIT_IDXENTRY_STAGESHIFT);
+ our_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&our_entry, 2);
git_oid_fromstr(&our_entry.id, TEST_OUR_OID);
their_entry.path = "test-one.txt";
- ancestor_entry.flags |= (3 << GIT_IDXENTRY_STAGESHIFT);
+ their_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 2);
git_oid_fromstr(&their_entry.id, TEST_THEIR_OID);
cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry));
@@ -74,15 +78,18 @@ void test_index_conflicts__add_fixes_incorrect_stage(void)
memset(&their_entry, 0x0, sizeof(git_index_entry));
ancestor_entry.path = "test-one.txt";
- ancestor_entry.flags |= (3 << GIT_IDXENTRY_STAGESHIFT);
+ ancestor_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3);
git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID);
our_entry.path = "test-one.txt";
- ancestor_entry.flags |= (1 << GIT_IDXENTRY_STAGESHIFT);
+ our_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&our_entry, 1);
git_oid_fromstr(&our_entry.id, TEST_OUR_OID);
their_entry.path = "test-one.txt";
- ancestor_entry.flags |= (2 << GIT_IDXENTRY_STAGESHIFT);
+ their_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&their_entry, 2);
git_oid_fromstr(&their_entry.id, TEST_THEIR_OID);
cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry));
@@ -96,6 +103,55 @@ void test_index_conflicts__add_fixes_incorrect_stage(void)
cl_assert(git_index_entry_stage(conflict_entry[2]) == 3);
}
+void test_index_conflicts__add_removes_stage_zero(void)
+{
+ git_index_entry staged, ancestor_entry, our_entry, their_entry;
+ const git_index_entry *conflict_entry[3];
+
+ cl_assert(git_index_entrycount(repo_index) == 8);
+
+ memset(&staged, 0x0, sizeof(git_index_entry));
+ memset(&ancestor_entry, 0x0, sizeof(git_index_entry));
+ memset(&our_entry, 0x0, sizeof(git_index_entry));
+ memset(&their_entry, 0x0, sizeof(git_index_entry));
+
+ staged.path = "test-one.txt";
+ staged.mode = 0100644;
+ git_oid_fromstr(&staged.id, TEST_STAGED_OID);
+ cl_git_pass(git_index_add(repo_index, &staged));
+ cl_assert(git_index_entrycount(repo_index) == 9);
+
+ ancestor_entry.path = "test-one.txt";
+ ancestor_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3);
+ git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID);
+
+ our_entry.path = "test-one.txt";
+ our_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&our_entry, 1);
+ git_oid_fromstr(&our_entry.id, TEST_OUR_OID);
+
+ their_entry.path = "test-one.txt";
+ their_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&their_entry, 2);
+ git_oid_fromstr(&their_entry.id, TEST_THEIR_OID);
+
+ cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry));
+
+ cl_assert(git_index_entrycount(repo_index) == 11);
+
+ cl_assert_equal_p(NULL, git_index_get_bypath(repo_index, "test-one.txt", 0));
+
+ cl_git_pass(git_index_conflict_get(&conflict_entry[0], &conflict_entry[1], &conflict_entry[2], repo_index, "test-one.txt"));
+
+ cl_assert_equal_oid(&ancestor_entry.id, &conflict_entry[0]->id);
+ cl_assert_equal_i(1, git_index_entry_stage(conflict_entry[0]));
+ cl_assert_equal_oid(&our_entry.id, &conflict_entry[1]->id);
+ cl_assert_equal_i(2, git_index_entry_stage(conflict_entry[1]));
+ cl_assert_equal_oid(&their_entry.id, &conflict_entry[2]->id);
+ cl_assert_equal_i(3, git_index_entry_stage(conflict_entry[2]));
+}
+
void test_index_conflicts__get(void)
{
const git_index_entry *conflict_entry[3];
@@ -216,7 +272,7 @@ void test_index_conflicts__moved_to_reuc_on_add(void)
cl_assert(entry = git_index_get_byindex(repo_index, i));
if (strcmp(entry->path, "conflicts-one.txt") == 0)
- cl_assert(git_index_entry_stage(entry) == 0);
+ cl_assert(!git_index_entry_is_conflict(entry));
}
}
@@ -256,7 +312,7 @@ void test_index_conflicts__remove_all_conflicts(void)
for (i = 0; i < git_index_entrycount(repo_index); i++) {
cl_assert(entry = git_index_get_byindex(repo_index, i));
- cl_assert(git_index_entry_stage(entry) == 0);
+ cl_assert(!git_index_entry_is_conflict(entry));
}
}
@@ -272,7 +328,8 @@ void test_index_conflicts__partial(void)
memset(&their_entry, 0x0, sizeof(git_index_entry));
ancestor_entry.path = "test-one.txt";
- ancestor_entry.flags |= (1 << GIT_IDXENTRY_STAGESHIFT);
+ ancestor_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1);
git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID);
cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, NULL, NULL));
diff --git a/tests/merge/trees/trivial.c b/tests/merge/trees/trivial.c
index 55f38248f..2262edda6 100644
--- a/tests/merge/trees/trivial.c
+++ b/tests/merge/trees/trivial.c
@@ -71,7 +71,7 @@ static int merge_trivial_conflict_entrycount(git_index *index)
for (i = 0; i < git_index_entrycount(index); i++) {
cl_assert(entry = git_index_get_byindex(index, i));
- if (git_index_entry_stage(entry) > 0)
+ if (git_index_entry_is_conflict(entry))
count++;
}
diff --git a/tests/merge/workdir/trivial.c b/tests/merge/workdir/trivial.c
index 5cc20f746..4ddaf233d 100644
--- a/tests/merge/workdir/trivial.c
+++ b/tests/merge/workdir/trivial.c
@@ -66,7 +66,7 @@ static size_t merge_trivial_conflict_entrycount(void)
for (i = 0; i < git_index_entrycount(repo_index); i++) {
cl_assert(entry = git_index_get_byindex(repo_index, i));
- if (git_index_entry_stage(entry) > 0)
+ if (git_index_entry_is_conflict(entry))
count++;
}
diff --git a/tests/network/refspecs.c b/tests/network/refspecs.c
index c6bcb10e8..614d91d07 100644
--- a/tests/network/refspecs.c
+++ b/tests/network/refspecs.c
@@ -146,3 +146,13 @@ void test_network_refspecs__invalid_reverse(void)
assert_invalid_rtransform("refs/heads/*:refs/remotes/origin/*", "master");
assert_invalid_rtransform("refs/heads/*:refs/remotes/origin/*", "refs/remotes/o/master");
}
+
+void test_network_refspecs__matching(void)
+{
+ git_refspec spec;
+
+ cl_git_pass(git_refspec__parse(&spec, ":", false));
+ cl_assert_equal_s(":", spec.string);
+ cl_assert_equal_s("", spec.src);
+ cl_assert_equal_s("", spec.dst);
+}
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c
index 9d96184a2..5d726c958 100644
--- a/tests/network/remote/local.c
+++ b/tests/network/remote/local.c
@@ -39,7 +39,7 @@ static void connect_to_local_repository(const char *local_repository)
{
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
- cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf), NULL));
+ cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
}
@@ -71,7 +71,7 @@ void test_network_remote_local__retrieve_advertised_before_connect(void)
git_buf_sets(&file_path_buf, cl_git_path_url(cl_fixture("testrepo.git")));
- cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf), NULL));
+ cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
cl_git_fail(git_remote_ls(&refs, &refs_len, remote));
}
@@ -213,7 +213,7 @@ void test_network_remote_local__push_to_bare_remote(void)
}
/* Connect to the bare repo */
- cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git", NULL));
+ cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git"));
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
/* Try to push */
@@ -252,7 +252,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
url = cl_git_path_url("./localbare.git");
/* Connect to the bare repo */
- cl_git_pass(git_remote_create_anonymous(&localremote, repo, url, NULL));
+ cl_git_pass(git_remote_create_anonymous(&localremote, repo, url));
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
/* Try to push */
@@ -289,7 +289,7 @@ void test_network_remote_local__push_to_non_bare_remote(void)
}
/* Connect to the bare repo */
- cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare", NULL));
+ cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare"));
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
/* Try to push */
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index f81c1ccc0..2fa21d460 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -90,7 +90,7 @@ void test_network_remote_remotes__error_when_no_push_available(void)
};
- cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git"), NULL));
+ cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git")));
callbacks.transport = git_transport_local;
cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH, &callbacks));
@@ -128,6 +128,8 @@ void test_network_remote_remotes__add_fetchspec(void)
cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*");
cl_assert_equal_s(git_refspec_string(_refspec), "refs/*:refs/*");
cl_assert_equal_b(_refspec->push, false);
+
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_remote_add_fetch(_repo, "test", "refs/*/foo/*:refs/*"));
}
void test_network_remote_remotes__dup(void)
@@ -465,13 +467,3 @@ void test_network_remote_remotes__query_refspecs(void)
git_remote_free(remote);
git_remote_delete(_repo, "test");
}
-
-void test_network_remote_remotes__fetch_from_anonymous(void)
-{
- git_remote *remote;
-
- cl_git_pass(git_remote_create_anonymous(&remote, _repo, cl_fixture("testrepo.git"),
- "refs/heads/*:refs/other/*"));
- cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
- git_remote_free(remote);
-}
diff --git a/tests/object/tree/duplicateentries.c b/tests/object/tree/duplicateentries.c
index 65be12e9b..35dd383ec 100644
--- a/tests/object/tree/duplicateentries.c
+++ b/tests/object/tree/duplicateentries.c
@@ -126,17 +126,17 @@ static void add_fake_conflicts(git_index *index)
ancestor_entry.path = "duplicate";
ancestor_entry.mode = GIT_FILEMODE_BLOB;
- ancestor_entry.flags |= (1 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1);
git_oid_fromstr(&ancestor_entry.id, "a8233120f6ad708f843d861ce2b7228ec4e3dec6");
our_entry.path = "duplicate";
our_entry.mode = GIT_FILEMODE_BLOB;
- ancestor_entry.flags |= (2 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&our_entry, 2);
git_oid_fromstr(&our_entry.id, "45b983be36b73c0788dc9cbcb76cbb80fc7bb057");
their_entry.path = "duplicate";
their_entry.mode = GIT_FILEMODE_BLOB;
- ancestor_entry.flags |= (3 << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&their_entry, 3);
git_oid_fromstr(&their_entry.id, "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd");
cl_git_pass(git_index_conflict_add(index, &ancestor_entry, &our_entry, &their_entry));
diff --git a/tests/odb/foreach.c b/tests/odb/foreach.c
index 75448a2f7..12b81b4f1 100644
--- a/tests/odb/foreach.c
+++ b/tests/odb/foreach.c
@@ -71,15 +71,35 @@ static int foreach_stop_cb(const git_oid *oid, void *data)
return (*nobj == 1000) ? -321 : 0;
}
+static int foreach_stop_first_cb(const git_oid *oid, void *data)
+{
+ int *nobj = data;
+ (*nobj)++;
+
+ GIT_UNUSED(oid);
+
+ return -123;
+}
+
void test_odb_foreach__interrupt_foreach(void)
{
int nobj = 0;
+ git_oid id;
cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git")));
git_repository_odb(&_odb, _repo);
cl_assert_equal_i(-321, git_odb_foreach(_odb, foreach_stop_cb, &nobj));
cl_assert(nobj == 1000);
+
+ git_odb_free(_odb);
+ git_repository_free(_repo);
+
+ cl_git_pass(git_repository_init(&_repo, "onlyloose.git", true));
+ git_repository_odb(&_odb, _repo);
+
+ cl_git_pass(git_odb_write(&id, _odb, "", 0, GIT_OBJ_BLOB));
+ cl_assert_equal_i(-123, git_odb_foreach(_odb, foreach_stop_first_cb, &nobj));
}
void test_odb_foreach__files_in_objects_dir(void)
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 1930a8ba3..fa0dbd69c 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -501,6 +501,74 @@ void test_online_clone__ssh_cert(void)
cl_git_fail_with(GIT_EUSER, git_clone(&g_repo, "ssh://localhost/foo", "./foo", &g_options));
}
+static char *read_key_file(const char *path)
+{
+ FILE *f;
+ char *buf;
+ long key_length;
+
+ if (!path || !*path)
+ return NULL;
+
+ cl_assert((f = fopen(path, "r")) != NULL);
+ cl_assert(fseek(f, 0, SEEK_END) != -1);
+ cl_assert((key_length = ftell(f)) != -1);
+ cl_assert(fseek(f, 0, SEEK_SET) != -1);
+ cl_assert((buf = malloc(key_length)) != NULL);
+ cl_assert(fread(buf, key_length, 1, f) == 1);
+ fclose(f);
+
+ return buf;
+}
+
+static int ssh_memory_cred_cb(git_cred **cred, const char *url, const char *user_from_url,
+ unsigned int allowed_types, void *payload)
+{
+ const char *remote_user = cl_getenv("GITTEST_REMOTE_USER");
+ const char *pubkey_path = cl_getenv("GITTEST_REMOTE_SSH_PUBKEY");
+ const char *privkey_path = cl_getenv("GITTEST_REMOTE_SSH_KEY");
+ const char *passphrase = cl_getenv("GITTEST_REMOTE_SSH_PASSPHRASE");
+
+ GIT_UNUSED(url); GIT_UNUSED(user_from_url); GIT_UNUSED(payload);
+
+ if (allowed_types & GIT_CREDTYPE_USERNAME)
+ return git_cred_username_new(cred, remote_user);
+
+ if (allowed_types & GIT_CREDTYPE_SSH_KEY)
+ {
+ char *pubkey = read_key_file(pubkey_path);
+ char *privkey = read_key_file(privkey_path);
+
+ int ret = git_cred_ssh_key_memory_new(cred, remote_user, pubkey, privkey, passphrase);
+
+ if (privkey)
+ free(privkey);
+ if (pubkey)
+ free(pubkey);
+ return ret;
+ }
+
+ giterr_set(GITERR_NET, "unexpected cred type");
+ return -1;
+}
+
+void test_online_clone__ssh_memory_auth(void)
+{
+ const char *remote_url = cl_getenv("GITTEST_REMOTE_URL");
+ const char *remote_user = cl_getenv("GITTEST_REMOTE_USER");
+ const char *privkey = cl_getenv("GITTEST_REMOTE_SSH_KEY");
+
+#ifndef GIT_SSH_MEMORY_CREDENTIALS
+ clar__skip();
+#endif
+ if (!remote_url || !remote_user || !privkey || strncmp(remote_url, "ssh://", 5) != 0)
+ clar__skip();
+
+ g_options.fetch_opts.callbacks.credentials = ssh_memory_cred_cb;
+
+ cl_git_pass(git_clone(&g_repo, remote_url, "./foo", &g_options));
+}
+
void test_online_clone__url_with_no_path_returns_EINVALIDSPEC(void)
{
cl_git_fail_with(git_clone(&g_repo, "http://github.com", "./foo", &g_options),
diff --git a/tests/online/remotes.c b/tests/online/remotes.c
index 70374be2f..a86f2d9ae 100644
--- a/tests/online/remotes.c
+++ b/tests/online/remotes.c
@@ -1,19 +1,12 @@
#include "clar_libgit2.h"
+static const char *refspec = "refs/heads/first-merge:refs/remotes/origin/first-merge";
+
static int remote_single_branch(git_remote **out, git_repository *repo, const char *name, const char *url, void *payload)
{
- char *fetch_refspecs[] = {
- "refs/heads/first-merge:refs/remotes/origin/first-merge",
- };
- git_strarray fetch_refspecs_strarray = {
- fetch_refspecs,
- 1,
- };
-
GIT_UNUSED(payload);
- cl_git_pass(git_remote_create(out, repo, name, url));
- cl_git_pass(git_remote_set_fetch_refspecs(*out, &fetch_refspecs_strarray));
+ cl_git_pass(git_remote_create_with_fetchspec(out, repo, name, url, refspec));
return 0;
}
@@ -22,6 +15,7 @@ void test_online_remotes__single_branch(void)
{
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
git_repository *repo;
+ git_remote *remote;
git_strarray refs;
size_t i, count = 0;
@@ -38,6 +32,15 @@ void test_online_remotes__single_branch(void)
cl_assert_equal_i(1, count);
git_strarray_free(&refs);
+
+ cl_git_pass(git_remote_lookup(&remote, repo, "origin"));
+ cl_git_pass(git_remote_get_fetch_refspecs(&refs, remote));
+
+ cl_assert_equal_i(1, refs.count);
+ cl_assert_equal_s(refspec, refs.strings[0]);
+
+ git_strarray_free(&refs);
+ git_remote_free(remote);
git_repository_free(repo);
}
diff --git a/tests/refs/branches/upstream.c b/tests/refs/branches/upstream.c
index 351449416..8f2e7a2ca 100644
--- a/tests/refs/branches/upstream.c
+++ b/tests/refs/branches/upstream.c
@@ -159,3 +159,35 @@ void test_refs_branches_upstream__set_unset_upstream(void)
cl_git_sandbox_cleanup();
}
+
+void test_refs_branches_upstream__no_fetch_refspec(void)
+{
+ git_reference *ref, *branch;
+ git_repository *repo;
+ git_remote *remote;
+ git_config *cfg;
+
+ repo = cl_git_sandbox_init("testrepo.git");
+
+ cl_git_pass(git_remote_create_with_fetchspec(&remote, repo, "matching", ".", NULL));
+ cl_git_pass(git_remote_add_push(repo, "matching", ":"));
+
+ cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/test"));
+ cl_git_pass(git_reference_create(&ref, repo, "refs/remotes/matching/master", git_reference_target(branch), 1, "fetch"));
+ cl_git_fail(git_branch_set_upstream(branch, "matching/master"));
+ cl_assert_equal_s("Could not determine remote for 'refs/remotes/matching/master'",
+ giterr_last()->message);
+
+ /* we can't set it automatically, so let's test the user setting it by hand */
+ cl_git_pass(git_repository_config(&cfg, repo));
+ cl_git_pass(git_config_set_string(cfg, "branch.test.remote", "matching"));
+ cl_git_pass(git_config_set_string(cfg, "branch.test.merge", "refs/heads/master"));
+ /* we still can't find it because there is no rule for that reference */
+ cl_git_fail_with(GIT_ENOTFOUND, git_branch_upstream(&ref, branch));
+
+ git_reference_free(ref);
+ git_reference_free(branch);
+ git_remote_free(remote);
+
+ cl_git_sandbox_cleanup();
+}
diff --git a/tests/remote/insteadof.c b/tests/remote/insteadof.c
new file mode 100644
index 000000000..05d4757cf
--- /dev/null
+++ b/tests/remote/insteadof.c
@@ -0,0 +1,72 @@
+#include "clar_libgit2.h"
+#include "remote.h"
+#include "repository.h"
+
+#define REPO_PATH "testrepo2/.gitted"
+#define REMOTE_ORIGIN "origin"
+#define REMOTE_INSTEADOF "insteadof-test"
+
+static git_repository *g_repo;
+static git_remote *g_remote;
+
+void test_remote_insteadof__initialize(void)
+{
+ g_repo = NULL;
+ g_remote = NULL;
+}
+
+void test_remote_insteadof__cleanup(void)
+{
+ git_repository_free(g_repo);
+ git_remote_free(g_remote);
+}
+
+void test_remote_insteadof__url_insteadof_not_applicable(void)
+{
+ cl_git_pass(git_repository_open(&g_repo, cl_fixture(REPO_PATH)));
+ cl_git_pass(git_remote_lookup(&g_remote, g_repo, REMOTE_ORIGIN));
+
+ cl_assert_equal_s(
+ git_remote_url(g_remote),
+ "https://github.com/libgit2/false.git");
+}
+
+void test_remote_insteadof__url_insteadof_applicable(void)
+{
+ cl_git_pass(git_repository_open(&g_repo, cl_fixture(REPO_PATH)));
+ cl_git_pass(git_remote_lookup(&g_remote, g_repo, REMOTE_INSTEADOF));
+
+ cl_assert_equal_s(
+ git_remote_url(g_remote),
+ "http://github.com/libgit2/libgit2");
+}
+
+void test_remote_insteadof__pushurl_insteadof_not_applicable(void)
+{
+ cl_git_pass(git_repository_open(&g_repo, cl_fixture(REPO_PATH)));
+ cl_git_pass(git_remote_lookup(&g_remote, g_repo, REMOTE_ORIGIN));
+
+ cl_assert_equal_p(git_remote_pushurl(g_remote), NULL);
+}
+
+void test_remote_insteadof__pushurl_insteadof_applicable(void)
+{
+ cl_git_pass(git_repository_open(&g_repo, cl_fixture(REPO_PATH)));
+ cl_git_pass(git_remote_lookup(&g_remote, g_repo, REMOTE_INSTEADOF));
+
+ cl_assert_equal_s(
+ git_remote_pushurl(g_remote),
+ "git@github.com:libgit2/libgit2");
+}
+
+void test_remote_insteadof__anonymous_remote(void)
+{
+ cl_git_pass(git_repository_open(&g_repo, cl_fixture(REPO_PATH)));
+ cl_git_pass(git_remote_create_anonymous(&g_remote, g_repo,
+ "http://example.com/libgit2/libgit2"));
+
+ cl_assert_equal_s(
+ git_remote_url(g_remote),
+ "http://github.com/libgit2/libgit2");
+ cl_assert_equal_p(git_remote_pushurl(g_remote), NULL);
+}
diff --git a/tests/reset/hard.c b/tests/reset/hard.c
index 86d4be2ed..88055adda 100644
--- a/tests/reset/hard.c
+++ b/tests/reset/hard.c
@@ -108,7 +108,7 @@ static void index_entry_init(git_index *index, int side, git_oid *oid)
memset(&entry, 0x0, sizeof(git_index_entry));
entry.path = "conflicting_file";
- entry.flags = (side << GIT_IDXENTRY_STAGESHIFT);
+ GIT_IDXENTRY_STAGE_SET(&entry, side);
entry.mode = 0100644;
git_oid_cpy(&entry.id, oid);
diff --git a/tests/resources/testrepo2/.gitted/config b/tests/resources/testrepo2/.gitted/config
index fc2433caf..4af067f04 100644
--- a/tests/resources/testrepo2/.gitted/config
+++ b/tests/resources/testrepo2/.gitted/config
@@ -8,7 +8,19 @@
[remote "origin"]
url = https://github.com/libgit2/false.git
fetch = +refs/heads/*:refs/remotes/origin/*
+[remote "insteadof-test"]
+ url = http://example.com/libgit2/libgit2
+ pushurl = http://github.com/libgit2/libgit2
+ fetch = +refs/heads/*:refs/remotes/test/*
[branch "master"]
remote = origin
merge = refs/heads/master
rebase = true
+[url "longer-non-prefix-match"]
+ insteadOf = ttp://example.com/li
+[url "shorter-prefix"]
+ insteadOf = http://example.co
+[url "http://github.com"]
+ insteadOf = http://example.com
+[url "git@github.com:"]
+ pushInsteadOf = http://github.com/
diff --git a/tests/stash/apply.c b/tests/stash/apply.c
index 42186b6fb..c242536be 100644
--- a/tests/stash/apply.c
+++ b/tests/stash/apply.c
@@ -118,7 +118,7 @@ void test_stash_apply__conflict_index_with_reinstate_index(void)
cl_git_pass(git_index_add_bypath(repo_index, "who"));
cl_git_pass(git_index_write(repo_index));
- cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_EMERGECONFLICT);
+ cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT);
cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
assert_status(repo, "what", GIT_STATUS_CURRENT);
@@ -133,7 +133,7 @@ void test_stash_apply__conflict_untracked_with_default(void)
cl_git_mkfile("stash/when", "nothing\n");
- cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_EMERGECONFLICT);
+ cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT);
cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
assert_status(repo, "what", GIT_STATUS_CURRENT);
@@ -150,7 +150,7 @@ void test_stash_apply__conflict_untracked_with_reinstate_index(void)
cl_git_mkfile("stash/when", "nothing\n");
- cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_EMERGECONFLICT);
+ cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT);
cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
assert_status(repo, "what", GIT_STATUS_CURRENT);
@@ -163,7 +163,7 @@ void test_stash_apply__conflict_workdir_with_default(void)
{
cl_git_rewritefile("stash/what", "ciao\n");
- cl_git_fail_with(git_stash_apply(repo, 0, NULL), GIT_EMERGECONFLICT);
+ cl_git_fail_with(git_stash_apply(repo, 0, NULL), GIT_ECONFLICT);
cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
assert_status(repo, "what", GIT_STATUS_WT_MODIFIED);
@@ -180,7 +180,7 @@ void test_stash_apply__conflict_workdir_with_reinstate_index(void)
cl_git_rewritefile("stash/what", "ciao\n");
- cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_EMERGECONFLICT);
+ cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT);
cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
assert_status(repo, "what", GIT_STATUS_WT_MODIFIED);
@@ -254,6 +254,11 @@ int checkout_notify(
{
struct seen_paths *seen_paths = (struct seen_paths *)payload;
+ GIT_UNUSED(why);
+ GIT_UNUSED(baseline);
+ GIT_UNUSED(target);
+ GIT_UNUSED(workdir);
+
if (strcmp(path, "what") == 0)
seen_paths->what = 1;
else if (strcmp(path, "how") == 0)
@@ -318,6 +323,8 @@ int aborting_progress_cb(
git_stash_apply_progress_t progress,
void *payload)
{
+ GIT_UNUSED(payload);
+
if (progress == GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED)
return -44;
@@ -327,7 +334,6 @@ int aborting_progress_cb(
void test_stash_apply__progress_cb_can_abort(void)
{
git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT;
- git_stash_apply_progress_t progress = GIT_STASH_APPLY_PROGRESS_NONE;
opts.progress_cb = aborting_progress_cb;
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index 8897bf9b5..3b18ae6c0 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -461,14 +461,17 @@ void test_status_worktree__conflict_with_diff3(void)
memset(&their_entry, 0x0, sizeof(git_index_entry));
ancestor_entry.path = "modified_file";
+ ancestor_entry.mode = 0100644;
git_oid_fromstr(&ancestor_entry.id,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a");
our_entry.path = "modified_file";
+ our_entry.mode = 0100644;
git_oid_fromstr(&our_entry.id,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a");
their_entry.path = "modified_file";
+ their_entry.mode = 0100644;
git_oid_fromstr(&their_entry.id,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a");
@@ -484,7 +487,7 @@ void test_status_worktree__conflict_with_diff3(void)
cl_git_pass(git_status_file(&status, repo, "modified_file"));
- cl_assert_equal_i(GIT_STATUS_INDEX_DELETED | GIT_STATUS_WT_NEW, status);
+ cl_assert_equal_i(GIT_STATUS_CONFLICTED, status);
}
static const char *filemode_paths[] = {
@@ -614,14 +617,17 @@ void test_status_worktree__conflicted_item(void)
memset(&our_entry, 0x0, sizeof(git_index_entry));
memset(&their_entry, 0x0, sizeof(git_index_entry));
+ ancestor_entry.mode = 0100644;
ancestor_entry.path = "modified_file";
git_oid_fromstr(&ancestor_entry.id,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a");
+ our_entry.mode = 0100644;
our_entry.path = "modified_file";
git_oid_fromstr(&our_entry.id,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a");
+ their_entry.mode = 0100644;
their_entry.path = "modified_file";
git_oid_fromstr(&their_entry.id,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a");
@@ -634,9 +640,55 @@ void test_status_worktree__conflicted_item(void)
&our_entry, &their_entry));
cl_git_pass(git_status_file(&status, repo, "modified_file"));
- cl_assert_equal_i(GIT_STATUS_WT_MODIFIED, status);
+ cl_assert_equal_i(GIT_STATUS_CONFLICTED, status);
+
+ git_index_free(index);
+}
+
+void test_status_worktree__conflict_has_no_oid(void)
+{
+ git_repository *repo = cl_git_sandbox_init("status");
+ git_index *index;
+ git_index_entry entry = {{0}};
+ git_status_list *statuslist;
+ const git_status_entry *status;
+ git_oid zero_id = {{0}};
+
+ entry.mode = 0100644;
+ entry.path = "modified_file";
+ git_oid_fromstr(&entry.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
+
+ cl_git_pass(git_repository_index(&index, repo));
+ cl_git_pass(git_index_conflict_add(index, &entry, &entry, &entry));
+
+ git_status_list_new(&statuslist, repo, NULL);
+
+ cl_assert_equal_i(16, git_status_list_entrycount(statuslist));
+
+ status = git_status_byindex(statuslist, 2);
+
+ cl_assert_equal_i(GIT_STATUS_CONFLICTED, status->status);
+ cl_assert_equal_s("modified_file", status->head_to_index->old_file.path);
+ cl_assert(!git_oid_equal(&zero_id, &status->head_to_index->old_file.id));
+ cl_assert(0 != status->head_to_index->old_file.mode);
+ cl_assert_equal_s("modified_file", status->head_to_index->new_file.path);
+ cl_assert_equal_oid(&zero_id, &status->head_to_index->new_file.id);
+ cl_assert_equal_i(0, status->head_to_index->new_file.mode);
+ cl_assert_equal_i(0, status->head_to_index->new_file.size);
+
+ cl_assert_equal_s("modified_file", status->index_to_workdir->old_file.path);
+ cl_assert_equal_oid(&zero_id, &status->index_to_workdir->old_file.id);
+ cl_assert_equal_i(0, status->index_to_workdir->old_file.mode);
+ cl_assert_equal_i(0, status->index_to_workdir->old_file.size);
+ cl_assert_equal_s("modified_file", status->index_to_workdir->new_file.path);
+ cl_assert(
+ !git_oid_equal(&zero_id, &status->index_to_workdir->new_file.id) ||
+ !(status->index_to_workdir->new_file.flags & GIT_DIFF_FLAG_VALID_ID));
+ cl_assert(0 != status->index_to_workdir->new_file.mode);
+ cl_assert(0 != status->index_to_workdir->new_file.size);
git_index_free(index);
+ git_status_list_free(statuslist);
}
static void stage_and_commit(git_repository *repo, const char *path)