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
176f5552
Commit
176f5552
authored
Jan 21, 2017
by
Edward Thomson
Committed by
GitHub
Jan 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4085 from libgit2/ethomson/packfile_close
indexer: introduce `git_packfile_close`
parents
98f53872
87b7a705
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
15 deletions
+18
-15
src/indexer.c
+4
-11
src/pack.c
+13
-4
src/pack.h
+1
-0
No files found.
src/indexer.c
View file @
176f5552
...
@@ -1081,7 +1081,7 @@ void git_indexer_free(git_indexer *idx)
...
@@ -1081,7 +1081,7 @@ void git_indexer_free(git_indexer *idx)
git_vector_free_deep
(
&
idx
->
objects
);
git_vector_free_deep
(
&
idx
->
objects
);
if
(
idx
->
pack
&&
idx
->
pack
->
idx_cache
)
{
if
(
idx
->
pack
->
idx_cache
)
{
struct
git_pack_entry
*
pentry
;
struct
git_pack_entry
*
pentry
;
kh_foreach_value
(
kh_foreach_value
(
idx
->
pack
->
idx_cache
,
pentry
,
{
git__free
(
pentry
);
});
idx
->
pack
->
idx_cache
,
pentry
,
{
git__free
(
pentry
);
});
...
@@ -1091,17 +1091,10 @@ void git_indexer_free(git_indexer *idx)
...
@@ -1091,17 +1091,10 @@ void git_indexer_free(git_indexer *idx)
git_vector_free_deep
(
&
idx
->
deltas
);
git_vector_free_deep
(
&
idx
->
deltas
);
/* Try to delete the temporary file in case it was not committed. */
git_mwindow_free_all
(
&
idx
->
pack
->
mwf
);
/* We need to close the descriptor here so Windows doesn't choke on unlink */
if
(
idx
->
pack
->
mwf
.
fd
!=
-
1
)
p_close
(
idx
->
pack
->
mwf
.
fd
);
if
(
!
idx
->
pack_committed
)
p_unlink
(
idx
->
pack
->
pack_name
);
if
(
!
git_mutex_lock
(
&
git__mwindow_mutex
))
{
if
(
!
git_mutex_lock
(
&
git__mwindow_mutex
))
{
if
(
!
idx
->
pack_committed
)
git_packfile_close
(
idx
->
pack
,
true
);
git_packfile_free
(
idx
->
pack
);
git_packfile_free
(
idx
->
pack
);
git_mutex_unlock
(
&
git__mwindow_mutex
);
git_mutex_unlock
(
&
git__mwindow_mutex
);
}
}
...
...
src/pack.c
View file @
176f5552
...
@@ -991,6 +991,18 @@ git_off_t get_delta_base(
...
@@ -991,6 +991,18 @@ git_off_t get_delta_base(
*
*
***********************************************************/
***********************************************************/
void
git_packfile_close
(
struct
git_pack_file
*
p
,
bool
unlink_packfile
)
{
if
(
p
->
mwf
.
fd
>=
0
)
{
git_mwindow_free_all_locked
(
&
p
->
mwf
);
p_close
(
p
->
mwf
.
fd
);
p
->
mwf
.
fd
=
-
1
;
}
if
(
unlink_packfile
)
p_unlink
(
p
->
pack_name
);
}
void
git_packfile_free
(
struct
git_pack_file
*
p
)
void
git_packfile_free
(
struct
git_pack_file
*
p
)
{
{
if
(
!
p
)
if
(
!
p
)
...
@@ -998,10 +1010,7 @@ void git_packfile_free(struct git_pack_file *p)
...
@@ -998,10 +1010,7 @@ void git_packfile_free(struct git_pack_file *p)
cache_free
(
&
p
->
bases
);
cache_free
(
&
p
->
bases
);
if
(
p
->
mwf
.
fd
>=
0
)
{
git_packfile_close
(
p
,
false
);
git_mwindow_free_all_locked
(
&
p
->
mwf
);
p_close
(
p
->
mwf
.
fd
);
}
pack_index_free
(
p
);
pack_index_free
(
p
);
...
...
src/pack.h
View file @
176f5552
...
@@ -149,6 +149,7 @@ git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
...
@@ -149,6 +149,7 @@ git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
git_off_t
*
curpos
,
git_otype
type
,
git_off_t
*
curpos
,
git_otype
type
,
git_off_t
delta_obj_offset
);
git_off_t
delta_obj_offset
);
void
git_packfile_close
(
struct
git_pack_file
*
p
,
bool
unlink_packfile
);
void
git_packfile_free
(
struct
git_pack_file
*
p
);
void
git_packfile_free
(
struct
git_pack_file
*
p
);
int
git_packfile_alloc
(
struct
git_pack_file
**
pack_out
,
const
char
*
path
);
int
git_packfile_alloc
(
struct
git_pack_file
**
pack_out
,
const
char
*
path
);
...
...
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