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
796b03bd
Commit
796b03bd
authored
Oct 03, 2014
by
Edward Thomson
Committed by
Edward Thomson
Oct 26, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rebase: clean up some warnings and memory leaks
parent
e69737d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
26 deletions
+15
-26
src/rebase.c
+14
-26
tests/rebase/setup.c
+1
-0
No files found.
src/rebase.c
View file @
796b03bd
...
...
@@ -33,7 +33,7 @@
#define MSGNUM_FILE "msgnum"
#define END_FILE "end"
#define CMT_FILE_FMT "cmt.%
d"
#define CMT_FILE_FMT "cmt.%
" PRIuZ
#define CURRENT_FILE "current"
#define REWRITTEN_FILE "rewritten"
...
...
@@ -109,7 +109,10 @@ done:
return
0
;
}
GIT_INLINE
(
int
)
rebase_readfile
(
git_buf
*
out
,
git_buf
*
state_path
,
const
char
*
filename
)
GIT_INLINE
(
int
)
rebase_readfile
(
git_buf
*
out
,
git_buf
*
state_path
,
const
char
*
filename
)
{
size_t
state_path_len
=
state_path
->
size
;
int
error
;
...
...
@@ -131,7 +134,7 @@ GIT_INLINE(int) rebase_readint(
size_t
*
out
,
git_buf
*
asc_out
,
git_buf
*
state_path
,
const
char
*
filename
)
{
int32_t
num
;
char
*
eol
;
c
onst
c
har
*
eol
;
int
error
=
0
;
if
((
error
=
rebase_readfile
(
asc_out
,
state_path
,
filename
))
<
0
)
...
...
@@ -166,7 +169,7 @@ GIT_INLINE(int) rebase_readoid(
static
int
rebase_open_merge
(
git_rebase
*
rebase
)
{
git_buf
state_path
=
GIT_BUF_INIT
,
buf
=
GIT_BUF_INIT
,
cmt
=
GIT_BUF_INIT
;
git_oid
current_id
=
{
0
};
git_oid
current_id
=
{
{
0
}
};
git_rebase_operation
*
operation
;
size_t
i
,
msgnum
=
0
,
end
;
int
error
;
...
...
@@ -667,14 +670,12 @@ done:
return
error
;
}
static
int
normalize_checkout_opts
(
static
void
normalize_checkout_opts
(
git_rebase
*
rebase
,
git_commit
*
current_commit
,
git_checkout_options
*
checkout_opts
,
const
git_checkout_options
*
given_checkout_opts
)
{
git_commit
*
current_commit
=
NULL
;
int
error
=
0
;
if
(
given_checkout_opts
!=
NULL
)
memcpy
(
checkout_opts
,
given_checkout_opts
,
sizeof
(
git_checkout_options
));
else
{
...
...
@@ -691,25 +692,11 @@ static int normalize_checkout_opts(
if
(
!
checkout_opts
->
our_label
)
checkout_opts
->
our_label
=
rebase
->
onto_name
;
if
(
!
checkout_opts
->
their_label
)
{
git_rebase_operation
*
operation
=
git_array_get
(
rebase
->
operations
,
rebase
->
current
);
if
((
error
=
git_commit_lookup
(
&
current_commit
,
rebase
->
repo
,
&
operation
->
id
))
<
0
)
goto
done
;
checkout_opts
->
their_label
=
git__strdup
(
git_commit_summary
(
current_commit
));
GITERR_CHECK_ALLOC
(
checkout_opts
->
their_label
);
}
if
(
!
checkout_opts
->
their_label
)
checkout_opts
->
their_label
=
git_commit_summary
(
current_commit
);
}
else
{
abort
();
}
done
:
git_commit_free
(
current_commit
);
return
error
;
}
GIT_INLINE
(
int
)
rebase_movenext
(
git_rebase
*
rebase
)
...
...
@@ -768,8 +755,9 @@ static int rebase_next_merge(
(
error
=
rebase_setupfile
(
rebase
,
CURRENT_FILE
,
-
1
,
"%.*s
\n
"
,
GIT_OID_HEXSZ
,
current_idstr
))
<
0
)
goto
done
;
if
((
error
=
normalize_checkout_opts
(
rebase
,
&
checkout_opts
,
given_checkout_opts
))
<
0
||
(
error
=
git_merge_trees
(
&
index
,
rebase
->
repo
,
parent_tree
,
head_tree
,
current_tree
,
NULL
))
<
0
||
normalize_checkout_opts
(
rebase
,
current_commit
,
&
checkout_opts
,
given_checkout_opts
);
if
((
error
=
git_merge_trees
(
&
index
,
rebase
->
repo
,
parent_tree
,
head_tree
,
current_tree
,
NULL
))
<
0
||
(
error
=
git_merge__check_result
(
rebase
->
repo
,
index
))
<
0
||
(
error
=
git_checkout_index
(
rebase
->
repo
,
index
,
&
checkout_opts
))
<
0
)
goto
done
;
...
...
tests/rebase/setup.c
View file @
796b03bd
...
...
@@ -40,6 +40,7 @@ void test_rebase_setup__blocked_when_in_progress(void)
cl_git_pass
(
git_merge_head_from_ref
(
&
upstream_head
,
repo
,
upstream_ref
));
cl_git_pass
(
git_rebase_init
(
&
rebase
,
repo
,
branch_head
,
upstream_head
,
NULL
,
signature
,
NULL
));
git_rebase_free
(
rebase
);
cl_assert_equal_i
(
GIT_REPOSITORY_STATE_REBASE_MERGE
,
git_repository_state
(
repo
));
...
...
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