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
6d4b6097
Commit
6d4b6097
authored
Jun 28, 2011
by
Carlos Martín Nieto
Committed by
Vicent Marti
Jul 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add git_config_del to delete a variable
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent
9f86ec52
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
src/config.c
+4
-4
src/config_file.c
+14
-2
No files found.
src/config.c
View file @
6d4b6097
...
...
@@ -167,15 +167,15 @@ int git_config_foreach(git_config *cfg, int (*fn)(const char *, const char *, vo
return
ret
;
}
int
git_config_del
(
git_config
*
cfg
,
const
char
*
name
)
{
return
git_config_set_string
(
cfg
,
name
,
NULL
);
}
/**************
* Setters
**************/
/*
* Internal function to actually set the string value of a variable
*/
int
git_config_set_long
(
git_config
*
cfg
,
const
char
*
name
,
long
int
value
)
{
char
str_value
[
32
];
/* All numbers should fit in here */
...
...
src/config_file.c
View file @
6d4b6097
...
...
@@ -356,9 +356,14 @@ static int config_set(git_config_file *cfg, const char *name, const char *value)
}
/*
* Otherwise, create it and stick it at the end of the queue.
* Otherwise, create it and stick it at the end of the queue. If
* value is NULL, we return an error, because you can't delete a
* variable that doesn't exist.
*/
if
(
value
==
NULL
)
return
git__throw
(
GIT_ENOTFOUND
,
"Can't delete non-exitent variable"
);
last_dot
=
strrchr
(
name
,
'.'
);
if
(
last_dot
==
NULL
)
{
return
git__throw
(
GIT_EINVALIDTYPE
,
"Variables without section aren't allowed"
);
...
...
@@ -1011,7 +1016,14 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
break
;
}
/* Then replace the variable */
/*
* Then replace the variable. If the value is NULL, it
* means we want to delete it, so pretend everything went
* fine
*/
if
(
var
->
value
==
NULL
)
error
=
GIT_SUCCESS
;
else
error
=
git_filebuf_printf
(
&
file
,
"
\t
%s = %s
\n
"
,
var
->
name
,
var
->
value
);
if
(
error
<
GIT_SUCCESS
)
{
git__rethrow
(
error
,
"Failed to overwrite the variable"
);
...
...
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