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
8a89aa1f
Commit
8a89aa1f
authored
Oct 22, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #963 from carlosmn/remote-save-autotag
Save the autotag configuration for remotes
parents
40846f3d
c648d4a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
src/remote.c
+39
-0
tests-clar/network/remotes.c
+24
-0
No files found.
src/remote.c
View file @
8a89aa1f
...
...
@@ -86,6 +86,11 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *name, con
goto
on_error
;
}
/* A remote without a name doesn't download tags */
if
(
!
name
)
{
remote
->
download_tags
=
GIT_REMOTE_DOWNLOAD_TAGS_NONE
;
}
*
out
=
remote
;
return
0
;
...
...
@@ -198,7 +203,9 @@ cleanup:
int
git_remote_save
(
const
git_remote
*
remote
)
{
int
error
;
git_config
*
config
;
const
char
*
tagopt
=
NULL
;
git_buf
buf
=
GIT_BUF_INIT
,
value
=
GIT_BUF_INIT
;
if
(
git_repository_config__weakptr
(
&
config
,
remote
->
repo
)
<
0
)
...
...
@@ -260,6 +267,38 @@ int git_remote_save(const git_remote *remote)
goto
on_error
;
}
/*
* What action to take depends on the old and new values. This
* is describes by the table below. tagopt means whether the
* is already a value set in the config
*
* AUTO ALL or NONE
* +-----------------------+
* tagopt | remove | set |
* +---------+-------------|
* !tagopt | nothing | set |
* +---------+-------------+
*/
git_buf_clear
(
&
buf
);
if
(
git_buf_printf
(
&
buf
,
"remote.%s.tagopt"
,
remote
->
name
)
<
0
)
goto
on_error
;
error
=
git_config_get_string
(
&
tagopt
,
config
,
git_buf_cstr
(
&
buf
));
if
(
error
<
0
&&
error
!=
GIT_ENOTFOUND
)
goto
on_error
;
if
(
remote
->
download_tags
==
GIT_REMOTE_DOWNLOAD_TAGS_ALL
)
{
if
(
git_config_set_string
(
config
,
git_buf_cstr
(
&
buf
),
"--tags"
)
<
0
)
goto
on_error
;
}
else
if
(
remote
->
download_tags
==
GIT_REMOTE_DOWNLOAD_TAGS_NONE
)
{
if
(
git_config_set_string
(
config
,
git_buf_cstr
(
&
buf
),
"--no-tags"
)
<
0
)
goto
on_error
;
}
else
if
(
tagopt
)
{
if
(
git_config_delete
(
config
,
git_buf_cstr
(
&
buf
))
<
0
)
goto
on_error
;
}
git_buf_free
(
&
buf
);
git_buf_free
(
&
value
);
...
...
tests-clar/network/remotes.c
View file @
8a89aa1f
...
...
@@ -225,3 +225,27 @@ void test_network_remotes__add(void)
cl_assert
(
!
strcmp
(
git_refspec_dst
(
_refspec
),
"refs/remotes/addtest/*"
));
cl_assert_equal_s
(
git_remote_url
(
_remote
),
"http://github.com/libgit2/libgit2"
);
}
void
test_network_remotes__tagopt
(
void
)
{
const
char
*
opt
;
git_config
*
cfg
;
cl_git_pass
(
git_repository_config
(
&
cfg
,
_repo
));
git_remote_set_autotag
(
_remote
,
GIT_REMOTE_DOWNLOAD_TAGS_ALL
);
cl_git_pass
(
git_remote_save
(
_remote
));
cl_git_pass
(
git_config_get_string
(
&
opt
,
cfg
,
"remote.test.tagopt"
));
cl_assert
(
!
strcmp
(
opt
,
"--tags"
));
git_remote_set_autotag
(
_remote
,
GIT_REMOTE_DOWNLOAD_TAGS_NONE
);
cl_git_pass
(
git_remote_save
(
_remote
));
cl_git_pass
(
git_config_get_string
(
&
opt
,
cfg
,
"remote.test.tagopt"
));
cl_assert
(
!
strcmp
(
opt
,
"--no-tags"
));
git_remote_set_autotag
(
_remote
,
GIT_REMOTE_DOWNLOAD_TAGS_AUTO
);
cl_git_pass
(
git_remote_save
(
_remote
));
cl_assert
(
git_config_get_string
(
&
opt
,
cfg
,
"remote.test.tagopt"
)
==
GIT_ENOTFOUND
);
git_config_free
(
cfg
);
}
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