summaryrefslogtreecommitdiff
path: root/tests/refs/create.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-11-03 17:18:00 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-11-12 09:35:51 -0500
commitb46c7ee5e270cc29e2fc0420a55e347a3242b3b5 (patch)
treeedc402d7b2ccebc9f719ffc048382f55aaf46967 /tests/refs/create.c
parentec50b23acc5a9f00f597fa877ad09cad56cb1204 (diff)
downloadlibgit2-b46c7ee5e270cc29e2fc0420a55e347a3242b3b5.tar.gz
refs: complain when a directory exists at ref
When a (non-empty) directory exists at the reference target location, complain with a more actionable error message.
Diffstat (limited to 'tests/refs/create.c')
-rw-r--r--tests/refs/create.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/refs/create.c b/tests/refs/create.c
index 192551dbd..48194ae3b 100644
--- a/tests/refs/create.c
+++ b/tests/refs/create.c
@@ -151,6 +151,23 @@ void test_refs_create__propagate_eexists(void)
cl_assert(error == GIT_EEXISTS);
}
+void test_refs_create__existing_dir_propagates_edirectory(void)
+{
+ git_reference *new_reference, *fail_reference;
+ git_oid id;
+ const char *dir_head = "refs/heads/new-dir/new-head",
+ *fail_head = "refs/heads/new-dir";
+
+ git_oid_fromstr(&id, current_master_tip);
+
+ /* Create and write the new object id reference */
+ cl_git_pass(git_reference_create(&new_reference, g_repo, dir_head, &id, 1, NULL));
+ cl_git_fail_with(GIT_EDIRECTORY,
+ git_reference_create(&fail_reference, g_repo, fail_head, &id, false, NULL));
+
+ git_reference_free(new_reference);
+}
+
static void test_invalid_name(const char *name)
{
git_reference *new_reference;