Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clarify behavior of index/workdir operations on a case insensitive platforms #1689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests-clar/clar_libgit2.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <git2.h>
#include "common.h"

#if (defined(GIT_WIN32) || defined(__APPLE__))
#define CASE_INSENSITIVE_FILESYSTEM 1
#endif

/**
* Replace for `clar_must_pass` that passes the last library error as the
* test failure message.
Expand Down
2 changes: 0 additions & 2 deletions tests-clar/repo/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ void test_repo_init__detect_filemode(void)
#endif
}

#define CASE_INSENSITIVE_FILESYSTEM (defined GIT_WIN32 || defined __APPLE__)

void test_repo_init__detect_ignorecase(void)
{
#if CASE_INSENSITIVE_FILESYSTEM
Expand Down
55 changes: 42 additions & 13 deletions tests-clar/status/worktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,30 +675,59 @@ void test_status_worktree__file_status_honors_core_ignorecase_false(void)

void test_status_worktree__file_status_honors_case_ignorecase_regarding_untracked_files(void)
{
git_repository *repo = cl_git_sandbox_init("status");
unsigned int status;
git_index *index;
git_repository *repo = cl_git_sandbox_init("status");
unsigned int status;
git_index *index;

cl_repo_set_bool(repo, "core.ignorecase", false);
cl_repo_set_bool(repo, "core.ignorecase", false);

repo = cl_git_sandbox_reopen();

/* Actually returns GIT_STATUS_IGNORED on Windows */
cl_git_fail_with(git_status_file(&status, repo, "NEW_FILE"), GIT_ENOTFOUND);
cl_git_fail_with(git_status_file(&status, repo, "NEW_FILE"), GIT_ENOTFOUND);

cl_git_pass(git_repository_index(&index, repo));
cl_git_pass(git_repository_index(&index, repo));

cl_git_pass(git_index_add_bypath(index, "new_file"));
cl_git_pass(git_index_write(index));
git_index_free(index);
cl_git_pass(git_index_add_bypath(index, "new_file"));
cl_git_pass(git_index_write(index));
git_index_free(index);

/* Actually returns GIT_STATUS_IGNORED on Windows */
cl_git_fail_with(git_status_file(&status, repo, "NEW_FILE"), GIT_ENOTFOUND);
cl_git_fail_with(git_status_file(&status, repo, "NEW_FILE"), GIT_ENOTFOUND);
}

void test_status_worktree__file_status_honors_case_ignorecase_on_case_insensitive_platforms(void)
{
#ifdef CASE_INSENSITIVE_FILESYSTEM
git_repository *repo = cl_git_sandbox_init("status");
unsigned int status;
git_index *index;

cl_repo_set_bool(repo, "core.ignorecase", true);

repo = cl_git_sandbox_reopen();

cl_git_pass(git_status_file(&status, repo, "NEW_FILE"));
cl_assert_equal_i(GIT_STATUS_WT_NEW, status);

cl_git_pass(git_status_file(&status, repo, "new_file"));
cl_assert_equal_i(GIT_STATUS_WT_NEW, status);

cl_git_pass(git_repository_index(&index, repo));

cl_git_pass(git_index_add_bypath(index, "new_file"));
cl_git_pass(git_index_write(index));
git_index_free(index);

cl_git_pass(git_status_file(&status, repo, "new_file"));
cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status);

cl_git_pass(git_status_file(&status, repo, "NEW_FILE"));
cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status);
#endif
}

void test_status_worktree__simple_delete(void)
{
git_repository *repo = cl_git_sandbox_init("renames");
git_repository *repo = cl_git_sandbox_init("renames");
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
int count;

Expand Down