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
8339c660
Commit
8339c660
authored
Dec 07, 2016
by
Edward Thomson
Committed by
GitHub
Dec 07, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4020 from novalis/rebase-detached
git_rebase_init: correctly handle detached HEAD
parents
15769731
4db1fc7e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
1 deletions
+54
-1
src/rebase.c
+1
-1
tests/rebase/merge.c
+53
-0
No files found.
src/rebase.c
View file @
8339c660
...
...
@@ -630,7 +630,7 @@ static int rebase_init_merge(
rebase
->
state_path
=
git_buf_detach
(
&
state_path
);
GITERR_CHECK_ALLOC
(
rebase
->
state_path
);
if
(
branch
->
ref_name
)
{
if
(
branch
->
ref_name
&&
strcmp
(
branch
->
ref_name
,
"HEAD"
)
)
{
rebase
->
orig_head_name
=
git__strdup
(
branch
->
ref_name
);
GITERR_CHECK_ALLOC
(
rebase
->
orig_head_name
);
}
else
{
...
...
tests/rebase/merge.c
View file @
8339c660
#include "clar_libgit2.h"
#include "git2/checkout.h"
#include "git2/rebase.h"
#include "posix.h"
#include "signature.h"
...
...
@@ -475,6 +476,58 @@ void test_rebase_merge__finish(void)
git_rebase_free
(
rebase
);
}
void
test_rebase_merge__detached_finish
(
void
)
{
git_rebase
*
rebase
;
git_reference
*
branch_ref
,
*
upstream_ref
,
*
head_ref
;
git_annotated_commit
*
branch_head
,
*
upstream_head
;
git_rebase_operation
*
rebase_operation
;
git_oid
commit_id
;
git_reflog
*
reflog
;
const
git_reflog_entry
*
reflog_entry
;
git_checkout_options
opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
int
error
;
cl_git_pass
(
git_reference_lookup
(
&
branch_ref
,
repo
,
"refs/heads/gravy"
));
cl_git_pass
(
git_reference_lookup
(
&
upstream_ref
,
repo
,
"refs/heads/veal"
));
cl_git_pass
(
git_annotated_commit_from_ref
(
&
branch_head
,
repo
,
branch_ref
));
cl_git_pass
(
git_annotated_commit_from_ref
(
&
upstream_head
,
repo
,
upstream_ref
));
cl_git_pass
(
git_repository_set_head_detached_from_annotated
(
repo
,
branch_head
));
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
git_checkout_head
(
repo
,
&
opts
);
cl_git_pass
(
git_rebase_init
(
&
rebase
,
repo
,
NULL
,
upstream_head
,
NULL
,
NULL
));
cl_git_pass
(
git_rebase_next
(
&
rebase_operation
,
rebase
));
cl_git_pass
(
git_rebase_commit
(
&
commit_id
,
rebase
,
NULL
,
signature
,
NULL
,
NULL
));
cl_git_fail
(
error
=
git_rebase_next
(
&
rebase_operation
,
rebase
));
cl_assert_equal_i
(
GIT_ITEROVER
,
error
);
cl_git_pass
(
git_rebase_finish
(
rebase
,
signature
));
cl_assert_equal_i
(
GIT_REPOSITORY_STATE_NONE
,
git_repository_state
(
repo
));
cl_git_pass
(
git_reference_lookup
(
&
head_ref
,
repo
,
"HEAD"
));
cl_assert_equal_i
(
GIT_REF_OID
,
git_reference_type
(
head_ref
));
/* Make sure the reflogs are updated appropriately */
cl_git_pass
(
git_reflog_read
(
&
reflog
,
repo
,
"HEAD"
));
cl_assert
(
reflog_entry
=
git_reflog_entry_byindex
(
reflog
,
0
));
cl_assert_equal_oid
(
git_annotated_commit_id
(
upstream_head
),
git_reflog_entry_id_old
(
reflog_entry
));
cl_assert_equal_oid
(
&
commit_id
,
git_reflog_entry_id_new
(
reflog_entry
));
git_reflog_free
(
reflog
);
git_annotated_commit_free
(
branch_head
);
git_annotated_commit_free
(
upstream_head
);
git_reference_free
(
branch_ref
);
git_reference_free
(
upstream_ref
);
git_rebase_free
(
rebase
);
}
void
test_rebase_merge__finish_with_ids
(
void
)
{
git_rebase
*
rebase
;
...
...
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