diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-06-16 16:34:25 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-06-16 16:39:13 -0400 |
commit | fef5344c50e33d01c08bec1687cb8a14a2a5efa2 (patch) | |
tree | d001e43003808317d512983ab4711e28b49336ca | |
parent | 121c3171e5b4918337910250487691efa8dbbd49 (diff) | |
download | libgit2-fef5344c50e33d01c08bec1687cb8a14a2a5efa2.tar.gz |
merge::workdir::dirty: tick idx to defeat racy-git
-rw-r--r-- | tests/merge/workdir/dirty.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/merge/workdir/dirty.c b/tests/merge/workdir/dirty.c index b66225d1f..30c404b70 100644 --- a/tests/merge/workdir/dirty.c +++ b/tests/merge/workdir/dirty.c @@ -2,6 +2,7 @@ #include "git2/merge.h" #include "buffer.h" #include "merge.h" +#include "index.h" #include "../merge_helpers.h" #include "posix.h" @@ -231,9 +232,20 @@ static int merge_differently_filtered_files(char *files[]) cl_git_pass(git_reference_peel(&head_object, head, GIT_OBJ_COMMIT)); cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD, NULL)); + /* Emulate checkout with a broken or misconfigured filter: modify some + * files on-disk and then update the index with the updated file size + * and time, as if some filter applied them. These files should not be + * treated as dirty since we created them. + * + * (Make sure to update the index stamp to defeat racy-git protections + * trying to sanity check the files in the index; those would rehash the + * files, showing them as dirty, the exact mechanism we're trying to avoid.) + */ + write_files(files); hack_index(files); + repo_index->stamp.mtime = time(NULL) + 1; cl_git_pass(git_index_write(repo_index)); error = merge_branch(); |