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
11d33df8
Commit
11d33df8
authored
Nov 18, 2018
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tiennou/fix/logallrefupdates-always'
parents
646a94be
e226ad8f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
13 deletions
+52
-13
src/config_cache.c
+7
-1
src/refdb_fs.c
+20
-12
src/repository.h
+3
-0
tests/refs/reflog/reflog.c
+22
-0
No files found.
src/config_cache.c
View file @
11d33df8
...
@@ -58,6 +58,12 @@ static git_cvar_map _cvar_map_safecrlf[] = {
...
@@ -58,6 +58,12 @@ static git_cvar_map _cvar_map_safecrlf[] = {
{
GIT_CVAR_STRING
,
"warn"
,
GIT_SAFE_CRLF_WARN
}
{
GIT_CVAR_STRING
,
"warn"
,
GIT_SAFE_CRLF_WARN
}
};
};
static
git_cvar_map
_cvar_map_logallrefupdates
[]
=
{
{
GIT_CVAR_FALSE
,
NULL
,
GIT_LOGALLREFUPDATES_FALSE
},
{
GIT_CVAR_TRUE
,
NULL
,
GIT_LOGALLREFUPDATES_TRUE
},
{
GIT_CVAR_STRING
,
"always"
,
GIT_LOGALLREFUPDATES_ALWAYS
},
};
/*
/*
* Generic map for integer values
* Generic map for integer values
*/
*/
...
@@ -76,7 +82,7 @@ static struct map_data _cvar_maps[] = {
...
@@ -76,7 +82,7 @@ static struct map_data _cvar_maps[] = {
{
"core.abbrev"
,
_cvar_map_int
,
1
,
GIT_ABBREV_DEFAULT
},
{
"core.abbrev"
,
_cvar_map_int
,
1
,
GIT_ABBREV_DEFAULT
},
{
"core.precomposeunicode"
,
NULL
,
0
,
GIT_PRECOMPOSE_DEFAULT
},
{
"core.precomposeunicode"
,
NULL
,
0
,
GIT_PRECOMPOSE_DEFAULT
},
{
"core.safecrlf"
,
_cvar_map_safecrlf
,
ARRAY_SIZE
(
_cvar_map_safecrlf
),
GIT_SAFE_CRLF_DEFAULT
},
{
"core.safecrlf"
,
_cvar_map_safecrlf
,
ARRAY_SIZE
(
_cvar_map_safecrlf
),
GIT_SAFE_CRLF_DEFAULT
},
{
"core.logallrefupdates"
,
NULL
,
0
,
GIT_LOGALLREFUPDATES_DEFAULT
},
{
"core.logallrefupdates"
,
_cvar_map_logallrefupdates
,
ARRAY_SIZE
(
_cvar_map_logallrefupdates
),
GIT_LOGALLREFUPDATES_DEFAULT
},
{
"core.protecthfs"
,
NULL
,
0
,
GIT_PROTECTHFS_DEFAULT
},
{
"core.protecthfs"
,
NULL
,
0
,
GIT_PROTECTHFS_DEFAULT
},
{
"core.protectntfs"
,
NULL
,
0
,
GIT_PROTECTNTFS_DEFAULT
},
{
"core.protectntfs"
,
NULL
,
0
,
GIT_PROTECTNTFS_DEFAULT
},
{
"core.fsyncobjectfiles"
,
NULL
,
0
,
GIT_FSYNCOBJECTFILES_DEFAULT
},
{
"core.fsyncobjectfiles"
,
NULL
,
0
,
GIT_FSYNCOBJECTFILES_DEFAULT
},
...
...
src/refdb_fs.c
View file @
11d33df8
...
@@ -1090,7 +1090,6 @@ fail:
...
@@ -1090,7 +1090,6 @@ fail:
static
int
reflog_append
(
refdb_fs_backend
*
backend
,
const
git_reference
*
ref
,
const
git_oid
*
old
,
const
git_oid
*
new
,
const
git_signature
*
author
,
const
char
*
message
);
static
int
reflog_append
(
refdb_fs_backend
*
backend
,
const
git_reference
*
ref
,
const
git_oid
*
old
,
const
git_oid
*
new
,
const
git_signature
*
author
,
const
char
*
message
);
static
int
has_reflog
(
git_repository
*
repo
,
const
char
*
name
);
static
int
has_reflog
(
git_repository
*
repo
,
const
char
*
name
);
/* We only write if it's under heads/, remotes/ or notes/ or if it already has a log */
static
int
should_write_reflog
(
int
*
write
,
git_repository
*
repo
,
const
char
*
name
)
static
int
should_write_reflog
(
int
*
write
,
git_repository
*
repo
,
const
char
*
name
)
{
{
int
error
,
logall
;
int
error
,
logall
;
...
@@ -1103,17 +1102,26 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam
...
@@ -1103,17 +1102,26 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam
if
(
logall
==
GIT_LOGALLREFUPDATES_UNSET
)
if
(
logall
==
GIT_LOGALLREFUPDATES_UNSET
)
logall
=
!
git_repository_is_bare
(
repo
);
logall
=
!
git_repository_is_bare
(
repo
);
if
(
!
logall
)
{
*
write
=
0
;
switch
(
logall
)
{
case
GIT_LOGALLREFUPDATES_FALSE
:
*
write
=
0
;
*
write
=
0
;
}
else
if
(
has_reflog
(
repo
,
name
))
{
break
;
*
write
=
1
;
}
else
if
(
!
git__prefixcmp
(
name
,
GIT_REFS_HEADS_DIR
)
||
case
GIT_LOGALLREFUPDATES_TRUE
:
!
git__strcmp
(
name
,
GIT_HEAD_FILE
)
||
/* Only write if it already has a log,
!
git__prefixcmp
(
name
,
GIT_REFS_REMOTES_DIR
)
||
* or if it's under heads/, remotes/ or notes/
!
git__prefixcmp
(
name
,
GIT_REFS_NOTES_DIR
))
{
*/
*
write
=
has_reflog
(
repo
,
name
)
||
!
git__prefixcmp
(
name
,
GIT_REFS_HEADS_DIR
)
||
!
git__strcmp
(
name
,
GIT_HEAD_FILE
)
||
!
git__prefixcmp
(
name
,
GIT_REFS_REMOTES_DIR
)
||
!
git__prefixcmp
(
name
,
GIT_REFS_NOTES_DIR
);
break
;
case
GIT_LOGALLREFUPDATES_ALWAYS
:
*
write
=
1
;
*
write
=
1
;
}
else
{
break
;
*
write
=
0
;
}
}
return
0
;
return
0
;
...
@@ -1713,7 +1721,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
...
@@ -1713,7 +1721,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
if
((
error
==
GIT_ENOTFOUND
)
&&
if
((
error
==
GIT_ENOTFOUND
)
&&
((
error
=
create_new_reflog_file
(
git_buf_cstr
(
&
log_path
)))
<
0
))
((
error
=
create_new_reflog_file
(
git_buf_cstr
(
&
log_path
)))
<
0
))
goto
cleanup
;
goto
cleanup
;
if
((
error
=
reflog_parse
(
log
,
if
((
error
=
reflog_parse
(
log
,
git_buf_cstr
(
&
log_file
),
git_buf_len
(
&
log_file
)))
<
0
)
git_buf_cstr
(
&
log_file
),
git_buf_len
(
&
log_file
)))
<
0
)
goto
cleanup
;
goto
cleanup
;
...
@@ -1973,7 +1981,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
...
@@ -1973,7 +1981,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
goto
cleanup
;
goto
cleanup
;
}
}
if
(
git_path_isdir
(
git_buf_cstr
(
&
new_path
))
&&
if
(
git_path_isdir
(
git_buf_cstr
(
&
new_path
))
&&
(
git_futils_rmdir_r
(
git_buf_cstr
(
&
new_path
),
NULL
,
GIT_RMDIR_SKIP_NONEMPTY
)
<
0
))
{
(
git_futils_rmdir_r
(
git_buf_cstr
(
&
new_path
),
NULL
,
GIT_RMDIR_SKIP_NONEMPTY
)
<
0
))
{
error
=
-
1
;
error
=
-
1
;
goto
cleanup
;
goto
cleanup
;
...
...
src/repository.h
View file @
11d33df8
...
@@ -105,7 +105,10 @@ typedef enum {
...
@@ -105,7 +105,10 @@ typedef enum {
/* core.safecrlf */
/* core.safecrlf */
GIT_SAFE_CRLF_DEFAULT
=
GIT_CVAR_FALSE
,
GIT_SAFE_CRLF_DEFAULT
=
GIT_CVAR_FALSE
,
/* core.logallrefupdates */
/* core.logallrefupdates */
GIT_LOGALLREFUPDATES_FALSE
=
GIT_CVAR_FALSE
,
GIT_LOGALLREFUPDATES_TRUE
=
GIT_CVAR_TRUE
,
GIT_LOGALLREFUPDATES_UNSET
=
2
,
GIT_LOGALLREFUPDATES_UNSET
=
2
,
GIT_LOGALLREFUPDATES_ALWAYS
=
3
,
GIT_LOGALLREFUPDATES_DEFAULT
=
GIT_LOGALLREFUPDATES_UNSET
,
GIT_LOGALLREFUPDATES_DEFAULT
=
GIT_LOGALLREFUPDATES_UNSET
,
/* core.protectHFS */
/* core.protectHFS */
GIT_PROTECTHFS_DEFAULT
=
GIT_CVAR_FALSE
,
GIT_PROTECTHFS_DEFAULT
=
GIT_CVAR_FALSE
,
...
...
tests/refs/reflog/reflog.c
View file @
11d33df8
...
@@ -422,6 +422,28 @@ void test_refs_reflog_reflog__logallrefupdates_bare_set_false(void)
...
@@ -422,6 +422,28 @@ void test_refs_reflog_reflog__logallrefupdates_bare_set_false(void)
assert_no_reflog_update
();
assert_no_reflog_update
();
}
}
void
test_refs_reflog_reflog__logallrefupdates_bare_set_always
(
void
)
{
git_config
*
config
;
git_reference
*
ref
;
git_reflog
*
log
;
git_oid
id
;
cl_git_pass
(
git_repository_config
(
&
config
,
g_repo
));
cl_git_pass
(
git_config_set_string
(
config
,
"core.logallrefupdates"
,
"always"
));
git_config_free
(
config
);
git_oid_fromstr
(
&
id
,
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644"
);
cl_git_pass
(
git_reference_create
(
&
ref
,
g_repo
,
"refs/bork"
,
&
id
,
1
,
"message"
));
cl_git_pass
(
git_reflog_read
(
&
log
,
g_repo
,
"refs/bork"
));
cl_assert_equal_i
(
1
,
git_reflog_entrycount
(
log
));
cl_assert_equal_s
(
"message"
,
git_reflog_entry_byindex
(
log
,
0
)
->
msg
);
git_reflog_free
(
log
);
git_reference_free
(
ref
);
}
void
test_refs_reflog_reflog__logallrefupdates_bare_unset
(
void
)
void
test_refs_reflog_reflog__logallrefupdates_bare_unset
(
void
)
{
{
git_config
*
config
;
git_config
*
config
;
...
...
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