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
e7c24ea2
Commit
e7c24ea2
authored
Jul 20, 2017
by
Etienne Samson
Committed by
Patrick Steinhardt
Mar 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: fix the rebase-submodule test
parent
54d4e5de
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
+36
-7
tests/rebase/submodule.c
+36
-7
tests/resources/rebase-submodule/gitmodules
+0
-0
No files found.
tests/rebase/submodule.c
View file @
e7c24ea2
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "git2/rebase.h"
#include "git2/rebase.h"
#include "posix.h"
#include "posix.h"
#include "signature.h"
#include "signature.h"
#include "../submodule/submodule_helpers.h"
#include <fcntl.h>
#include <fcntl.h>
...
@@ -12,9 +13,44 @@ static git_signature *signature;
...
@@ -12,9 +13,44 @@ static git_signature *signature;
// Fixture setup and teardown
// Fixture setup and teardown
void
test_rebase_submodule__initialize
(
void
)
void
test_rebase_submodule__initialize
(
void
)
{
{
git_index
*
index
;
git_oid
tree_oid
,
commit_id
;
git_tree
*
tree
;
git_commit
*
parent
;
git_object
*
obj
;
git_reference
*
master_ref
;
git_checkout_options
opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
repo
=
cl_git_sandbox_init
(
"rebase-submodule"
);
repo
=
cl_git_sandbox_init
(
"rebase-submodule"
);
cl_git_pass
(
git_signature_new
(
&
signature
,
cl_git_pass
(
git_signature_new
(
&
signature
,
"Rebaser"
,
"rebaser@rebaser.rb"
,
1405694510
,
0
));
"Rebaser"
,
"rebaser@rebaser.rb"
,
1405694510
,
0
));
rewrite_gitmodules
(
git_repository_workdir
(
repo
));
git_submodule_set_url
(
repo
,
"my-submodule"
,
git_repository_path
(
repo
));
/* We have to commit the rewritten .gitmodules file */
git_repository_index
(
&
index
,
repo
);
git_index_add_bypath
(
index
,
".gitmodules"
);
git_index_write_tree
(
&
tree_oid
,
index
);
git_index_free
(
index
);
cl_git_pass
(
git_tree_lookup
(
&
tree
,
repo
,
&
tree_oid
));
git_repository_head
(
&
master_ref
,
repo
);
cl_git_pass
(
git_commit_lookup
(
&
parent
,
repo
,
git_reference_target
(
master_ref
)));
cl_git_pass
(
git_commit_create_v
(
&
commit_id
,
repo
,
git_reference_name
(
master_ref
),
signature
,
signature
,
NULL
,
"Fixup .gitmodules"
,
tree
,
1
,
parent
));
/* And a final reset, for good measure */
git_object_lookup
(
&
obj
,
repo
,
&
commit_id
,
GIT_OBJ_COMMIT
);
cl_git_pass
(
git_reset
(
repo
,
obj
,
GIT_RESET_HARD
,
&
opts
));
git_object_free
(
obj
);
git_commit_free
(
parent
);
git_reference_free
(
master_ref
);
git_tree_free
(
tree
);
}
}
void
test_rebase_submodule__cleanup
(
void
)
void
test_rebase_submodule__cleanup
(
void
)
...
@@ -31,7 +67,6 @@ void test_rebase_submodule__init_untracked(void)
...
@@ -31,7 +67,6 @@ void test_rebase_submodule__init_untracked(void)
git_buf
untracked_path
=
GIT_BUF_INIT
;
git_buf
untracked_path
=
GIT_BUF_INIT
;
FILE
*
fp
;
FILE
*
fp
;
git_submodule
*
submodule
;
git_submodule
*
submodule
;
git_config
*
config
;
cl_git_pass
(
git_reference_lookup
(
&
branch_ref
,
repo
,
"refs/heads/asparagus"
));
cl_git_pass
(
git_reference_lookup
(
&
branch_ref
,
repo
,
"refs/heads/asparagus"
));
cl_git_pass
(
git_reference_lookup
(
&
upstream_ref
,
repo
,
"refs/heads/master"
));
cl_git_pass
(
git_reference_lookup
(
&
upstream_ref
,
repo
,
"refs/heads/master"
));
...
@@ -39,12 +74,6 @@ void test_rebase_submodule__init_untracked(void)
...
@@ -39,12 +74,6 @@ void test_rebase_submodule__init_untracked(void)
cl_git_pass
(
git_annotated_commit_from_ref
(
&
branch_head
,
repo
,
branch_ref
));
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_annotated_commit_from_ref
(
&
upstream_head
,
repo
,
upstream_ref
));
git_repository_config
(
&
config
,
repo
);
cl_git_pass
(
git_config_set_string
(
config
,
"submodule.my-submodule.url"
,
git_repository_path
(
repo
)));
git_config_free
(
config
);
cl_git_pass
(
git_submodule_lookup
(
&
submodule
,
repo
,
"my-submodule"
));
cl_git_pass
(
git_submodule_lookup
(
&
submodule
,
repo
,
"my-submodule"
));
cl_git_pass
(
git_submodule_update
(
submodule
,
1
,
NULL
));
cl_git_pass
(
git_submodule_update
(
submodule
,
1
,
NULL
));
...
...
tests/resources/rebase-submodule/
.
gitmodules
→
tests/resources/rebase-submodule/gitmodules
View file @
e7c24ea2
File moved
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