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
1c92f109
Commit
1c92f109
authored
May 07, 2013
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1551 from nvloff/set_upstream_local_branch
fix git_branch_set_upstream for local branches
parents
51e297dd
3d42e9a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletions
+14
-1
src/branch.c
+2
-1
tests-clar/refs/branches/upstream.c
+12
-0
No files found.
src/branch.c
View file @
1c92f109
...
...
@@ -521,7 +521,8 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name)
goto
on_error
;
if
(
local
)
{
if
(
git_buf_puts
(
&
value
,
git_reference_name
(
branch
))
<
0
)
git_buf_clear
(
&
value
);
if
(
git_buf_puts
(
&
value
,
git_reference_name
(
upstream
))
<
0
)
goto
on_error
;
}
else
{
/* Get the remoe-tracking branch's refname in its repo */
...
...
tests-clar/refs/branches/upstream.c
View file @
1c92f109
...
...
@@ -103,6 +103,7 @@ void test_refs_branches_upstream__set_unset_upstream(void)
repository
=
cl_git_sandbox_init
(
"testrepo.git"
);
/* remote */
cl_git_pass
(
git_reference_lookup
(
&
branch
,
repository
,
"refs/heads/test"
));
cl_git_pass
(
git_branch_set_upstream
(
branch
,
"test/master"
));
...
...
@@ -112,6 +113,17 @@ void test_refs_branches_upstream__set_unset_upstream(void)
cl_git_pass
(
git_config_get_string
(
&
value
,
config
,
"branch.test.merge"
));
cl_assert_equal_s
(
value
,
"refs/heads/master"
);
/* local */
cl_git_pass
(
git_reference_lookup
(
&
branch
,
repository
,
"refs/heads/test"
));
cl_git_pass
(
git_branch_set_upstream
(
branch
,
"master"
));
cl_git_pass
(
git_repository_config
(
&
config
,
repository
));
cl_git_pass
(
git_config_get_string
(
&
value
,
config
,
"branch.test.remote"
));
cl_assert_equal_s
(
value
,
"."
);
cl_git_pass
(
git_config_get_string
(
&
value
,
config
,
"branch.test.merge"
));
cl_assert_equal_s
(
value
,
"refs/heads/master"
);
/* unset */
cl_git_pass
(
git_branch_set_upstream
(
branch
,
NULL
));
cl_git_fail_with
(
git_config_get_string
(
&
value
,
config
,
"branch.test.merge"
),
GIT_ENOTFOUND
);
cl_git_fail_with
(
git_config_get_string
(
&
value
,
config
,
"branch.test.remote"
),
GIT_ENOTFOUND
);
...
...
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