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
5ad0351d
Commit
5ad0351d
authored
Mar 03, 2011
by
nulltoken
Committed by
Vicent Marti
Mar 03, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix reference removal: remove packed refs together with loose ones
parent
d561403f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
src/refs.c
+16
-2
No files found.
src/refs.c
View file @
5ad0351d
...
...
@@ -1089,15 +1089,18 @@ int git_reference_set_target(git_reference *ref, const char *target)
* operation. We need to remove the reference from
* the memory cache and then rewrite the whole pack
*
* If the reference is loose, we
just
remove it on
* If the reference is loose, we remove it on
* the filesystem and update the in-memory cache
* accordingly.
* accordingly. We also make sure that an older version
* of it doesn't exist as a packed reference. If this
* is the case, this packed reference is removed as well.
*
* This obviously invalidates the `ref` pointer.
*/
int
git_reference_delete
(
git_reference
*
ref
)
{
int
error
;
git_reference
*
reference
;
assert
(
ref
);
...
...
@@ -1109,8 +1112,19 @@ int git_reference_delete(git_reference *ref)
git__joinpath
(
full_path
,
ref
->
owner
->
path_repository
,
ref
->
name
);
git_hashtable_remove
(
ref
->
owner
->
references
.
loose_cache
,
ref
->
name
);
error
=
gitfo_unlink
(
full_path
);
if
(
error
<
GIT_SUCCESS
)
goto
cleanup
;
/* When deleting a loose reference, we have to ensure that an older
* packed version of it doesn't exist
*/
if
(
!
git_repository_lookup_ref
(
&
reference
,
ref
->
owner
,
ref
->
name
))
{
assert
((
reference
->
type
&
GIT_REF_PACKED
)
!=
0
);
error
=
git_reference_delete
(
reference
);
}
}
cleanup:
reference_free
(
ref
);
return
error
;
}
...
...
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