Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
fc1eeb9d
Commit
fc1eeb9d
authored
Mar 29, 2011
by
Carlos Martín Nieto
Committed by
Vicent Marti
Mar 29, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make overwrite test more comprehensive
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent
ec991936
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
3 deletions
+42
-3
tests/t10-refs.c
+42
-3
No files found.
tests/t10-refs.c
View file @
fc1eeb9d
...
...
@@ -297,17 +297,33 @@ END_TEST
static
const
char
*
ref_name
=
"refs/heads/other"
;
static
const
char
*
ref_master_name
=
"refs/heads/master"
;
static
const
char
*
ref_branch_name
=
"refs/heads/branch"
;
static
const
char
*
ref_test_name
=
"refs/heads/test"
;
BEGIN_TEST
(
overwrite0
,
"Overwrite an existing symbolic reference"
)
git_reference
*
ref
;
git_reference
*
ref
,
*
branch_ref
;
git_repository
*
repo
;
must_pass
(
git_repository_open
(
&
repo
,
REPOSITORY_FOLDER
));
must_pass
(
git_reference_create_symbolic
(
&
ref
,
repo
,
ref_name
,
ref_master_name
));
/* The target needds to exist and we need to check the name has changed */
must_pass
(
git_reference_create_symbolic
(
&
branch_ref
,
repo
,
ref_branch_name
,
ref_master_name
));
must_pass
(
git_reference_create_symbolic
(
&
ref
,
repo
,
ref_name
,
ref_branch_name
));
/* Ensure it points to the right place*/
must_pass
(
git_reference_lookup
(
&
ref
,
repo
,
ref_name
));
must_be_true
(
git_reference_type
(
ref
)
&
GIT_REF_SYMBOLIC
);
must_be_true
(
!
strcmp
(
git_reference_target
(
ref
),
ref_branch_name
));
/* Ensure we can't create it unless we force it to */
must_fail
(
git_reference_create_symbolic
(
&
ref
,
repo
,
ref_name
,
ref_master_name
));
must_pass
(
git_reference_create_symbolic_force
(
&
ref
,
repo
,
ref_name
,
ref_master_name
));
git_reference_delete
(
ref
);
/* Ensure it points to the right place */
must_pass
(
git_reference_lookup
(
&
ref
,
repo
,
ref_name
));
must_be_true
(
git_reference_type
(
ref
)
&
GIT_REF_SYMBOLIC
);
must_be_true
(
!
strcmp
(
git_reference_target
(
ref
),
ref_master_name
));
must_pass
(
git_reference_delete
(
ref
));
must_pass
(
git_reference_delete
(
branch_ref
));
git_repository_free
(
repo
);
END_TEST
...
...
@@ -322,10 +338,21 @@ BEGIN_TEST(overwrite1, "Overwrite an existing object id reference")
must_be_true
(
ref
->
type
&
GIT_REF_OID
);
git_oid_cpy
(
&
id
,
git_reference_oid
(
ref
));
/* Create it */
must_pass
(
git_reference_create_oid
(
&
ref
,
repo
,
ref_name
,
&
id
));
must_pass
(
git_reference_lookup
(
&
ref
,
repo
,
ref_test_name
));
must_be_true
(
ref
->
type
&
GIT_REF_OID
);
git_oid_cpy
(
&
id
,
git_reference_oid
(
ref
));
/* Ensure we can't overwrite unless we force it */
must_fail
(
git_reference_create_oid
(
&
ref
,
repo
,
ref_name
,
&
id
));
must_pass
(
git_reference_create_oid_force
(
&
ref
,
repo
,
ref_name
,
&
id
));
/* Ensure it has been overwritten */
must_pass
(
git_reference_lookup
(
&
ref
,
repo
,
ref_name
));
must_be_true
(
!
git_oid_cmp
(
&
id
,
git_reference_oid
(
ref
)));
git_reference_delete
(
ref
);
git_repository_free
(
repo
);
END_TEST
...
...
@@ -345,6 +372,11 @@ BEGIN_TEST(overwrite2, "Overwrite an existing object id reference with a symboli
must_fail
(
git_reference_create_symbolic
(
&
ref
,
repo
,
ref_name
,
ref_master_name
));
must_pass
(
git_reference_create_symbolic_force
(
&
ref
,
repo
,
ref_name
,
ref_master_name
));
/* Ensure it points to the right place */
must_pass
(
git_reference_lookup
(
&
ref
,
repo
,
ref_name
));
must_be_true
(
git_reference_type
(
ref
)
&
GIT_REF_SYMBOLIC
);
must_be_true
(
!
strcmp
(
git_reference_target
(
ref
),
ref_master_name
));
git_reference_delete
(
ref
);
git_repository_free
(
repo
);
END_TEST
...
...
@@ -360,10 +392,17 @@ BEGIN_TEST(overwrite3, "Overwrite an existing symbolic reference with an object
must_be_true
(
ref
->
type
&
GIT_REF_OID
);
git_oid_cpy
(
&
id
,
git_reference_oid
(
ref
));
/* Create the symbolic ref */
must_pass
(
git_reference_create_symbolic
(
&
ref
,
repo
,
ref_name
,
ref_master_name
));
/* It shouldn't overwrite unless we tell it to */
must_fail
(
git_reference_create_oid
(
&
ref
,
repo
,
ref_name
,
&
id
));
must_pass
(
git_reference_create_oid_force
(
&
ref
,
repo
,
ref_name
,
&
id
));
/* Ensure it points to the right place */
must_pass
(
git_reference_lookup
(
&
ref
,
repo
,
ref_name
));
must_be_true
(
git_reference_type
(
ref
)
&
GIT_REF_OID
);
must_be_true
(
!
git_oid_cmp
(
git_reference_oid
(
ref
),
&
id
));
git_reference_delete
(
ref
);
git_repository_free
(
repo
);
END_TEST
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment