Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/checkout')
-rw-r--r--tests/checkout/checkout_helpers.c22
-rw-r--r--tests/checkout/checkout_helpers.h2
-rw-r--r--tests/checkout/crlf.c11
3 files changed, 31 insertions, 4 deletions
diff --git a/tests/checkout/checkout_helpers.c b/tests/checkout/checkout_helpers.c
index 06b4e0682..f6e36d39b 100644
--- a/tests/checkout/checkout_helpers.c
+++ b/tests/checkout/checkout_helpers.c
@@ -2,6 +2,7 @@
#include "checkout_helpers.h"
#include "refs.h"
#include "fileops.h"
+#include "index.h"
void assert_on_branch(git_repository *repo, const char *branch)
{
@@ -128,3 +129,24 @@ int checkout_count_callback(
return 0;
}
+
+void tick_index(git_index *index)
+{
+ int index_fd;
+ git_time_t ts;
+ struct timeval times[2];
+
+ cl_assert(index->on_disk);
+ cl_assert(git_index_path(index));
+
+ cl_git_pass(git_index_read(index, true));
+ ts = index->stamp.mtime;
+
+ times[0].tv_sec = ts;
+ times[0].tv_usec = 0;
+ times[1].tv_sec = ts + 1;
+ times[1].tv_usec = 0;
+
+ cl_git_pass(p_utimes(git_index_path(index), times));
+ cl_git_pass(git_index_read(index, true));
+}
diff --git a/tests/checkout/checkout_helpers.h b/tests/checkout/checkout_helpers.h
index 705ee903d..6058a196c 100644
--- a/tests/checkout/checkout_helpers.h
+++ b/tests/checkout/checkout_helpers.h
@@ -27,3 +27,5 @@ extern int checkout_count_callback(
const git_diff_file *target,
const git_diff_file *workdir,
void *payload);
+
+extern void tick_index(git_index *index);
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index 381b04013..61459b3a4 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -4,6 +4,7 @@
#include "git2/checkout.h"
#include "repository.h"
+#include "index.h"
#include "posix.h"
static git_repository *g_repo;
@@ -40,9 +41,10 @@ void test_checkout_crlf__autocrlf_false_index_size_is_unfiltered_size(void)
cl_repo_set_bool(g_repo, "core.autocrlf", false);
- git_checkout_head(g_repo, &opts);
-
git_repository_index(&index, g_repo);
+ tick_index(index);
+
+ git_checkout_head(g_repo, &opts);
cl_assert((entry = git_index_get_bypath(index, "all-lf", 0)) != NULL);
cl_assert(entry->file_size == strlen(ALL_LF_TEXT_RAW));
@@ -140,9 +142,10 @@ void test_checkout_crlf__autocrlf_true_index_size_is_filtered_size(void)
cl_repo_set_bool(g_repo, "core.autocrlf", true);
- git_checkout_head(g_repo, &opts);
-
git_repository_index(&index, g_repo);
+ tick_index(index);
+
+ git_checkout_head(g_repo, &opts);
cl_assert((entry = git_index_get_bypath(index, "all-lf", 0)) != NULL);