summaryrefslogtreecommitdiff
path: root/tests-clar/index/addall.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-10-31 14:36:52 -0700
committerRussell Belfer <rb@github.com>2013-11-01 10:20:51 -0700
commit4bf630b6baf342fa929a8f7e4e6643197b74216f (patch)
tree95778a5807b4043202eaea18a266a264e611649c /tests-clar/index/addall.c
parent3940310e29363978ccdc1f3b557bc6f48ebae8f0 (diff)
downloadlibgit2-4bf630b6baf342fa929a8f7e4e6643197b74216f.tar.gz
Make diff and status perform soft index reload
This changes `git_index_read` to have two modes - a hard index reload that always resets the index to match the on-disk data (which was the old behavior) and a soft index reload that uses the timestamp / file size information and only replaces the index data if the file on disk has been modified. This then updates the git_status code to do a soft reload unless the new GIT_STATUS_OPT_NO_REFRESH flag is passed in. This also changes the behavior of the git_diff functions that use the index so that when an index is not explicitly passed in (i.e. when the functions call git_repository_index for you), they will also do a soft reload for you. This intentionally breaks the file signature of git_index_read because there has been some confusion about the behavior previously and it seems like all existing uses of the API should probably be examined to select the desired behavior.
Diffstat (limited to 'tests-clar/index/addall.c')
-rw-r--r--tests-clar/index/addall.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/tests-clar/index/addall.c b/tests-clar/index/addall.c
index 3b5f5f22d..44c51279d 100644
--- a/tests-clar/index/addall.c
+++ b/tests-clar/index/addall.c
@@ -68,10 +68,11 @@ static int index_status_cb(
return 0;
}
-static void check_status(
+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)
+ size_t wt_adds, size_t wt_dels, size_t wt_mods, size_t ignores,
+ const char *file, int line)
{
index_status_counts vals;
@@ -79,15 +80,25 @@ static void check_status(
cl_git_pass(git_status_foreach(repo, index_status_cb, &vals));
- cl_assert_equal_sz(index_adds, vals.index_adds);
- cl_assert_equal_sz(index_dels, vals.index_dels);
- cl_assert_equal_sz(index_mods, vals.index_mods);
- cl_assert_equal_sz(wt_adds, vals.wt_adds);
- cl_assert_equal_sz(wt_dels, vals.wt_dels);
- cl_assert_equal_sz(wt_mods, vals.wt_mods);
- cl_assert_equal_sz(ignores, vals.ignores);
+ clar__assert_equal(
+ file,line,"wrong index adds", 1, "%"PRIuZ, index_adds, vals.index_adds);
+ clar__assert_equal(
+ file,line,"wrong index dels", 1, "%"PRIuZ, index_dels, vals.index_dels);
+ clar__assert_equal(
+ file,line,"wrong index mods", 1, "%"PRIuZ, index_mods, vals.index_mods);
+ clar__assert_equal(
+ file,line,"wrong workdir adds", 1, "%"PRIuZ, wt_adds, vals.wt_adds);
+ clar__assert_equal(
+ file,line,"wrong workdir dels", 1, "%"PRIuZ, wt_dels, vals.wt_dels);
+ clar__assert_equal(
+ file,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods);
+ clar__assert_equal(
+ file,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores);
}
+#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__)
+
static void check_stat_data(git_index *index, const char *path, bool match)
{
const git_index_entry *entry;