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
0adb0606
Commit
0adb0606
authored
Feb 04, 2014
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix reflog message when creating commits
parent
86746b4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
src/commit.c
+21
-2
tests/commit/write.c
+14
-1
No files found.
src/commit.c
View file @
0adb0606
...
...
@@ -111,8 +111,27 @@ int git_commit_create_from_ids(
git_buf_free
(
&
commit
);
if
(
update_ref
!=
NULL
)
return
git_reference__update_terminal
(
repo
,
update_ref
,
oid
,
NULL
,
NULL
);
if
(
update_ref
!=
NULL
)
{
int
error
;
git_commit
*
c
;
const
char
*
shortmsg
;
git_buf
reflog_msg
=
GIT_BUF_INIT
;
if
(
git_commit_lookup
(
&
c
,
repo
,
oid
)
<
0
)
goto
on_error
;
shortmsg
=
git_commit_summary
(
c
);
git_buf_printf
(
&
reflog_msg
,
"commit%s: %s"
,
git_commit_parentcount
(
c
)
==
0
?
" (initial)"
:
""
,
shortmsg
);
git_commit_free
(
c
);
error
=
git_reference__update_terminal
(
repo
,
update_ref
,
oid
,
committer
,
git_buf_cstr
(
&
reflog_msg
));
git_buf_free
(
&
reflog_msg
);
return
error
;
}
return
0
;
...
...
tests/commit/write.c
View file @
0adb0606
...
...
@@ -7,6 +7,8 @@ static const char *commit_message = "This commit has been created in memory\n\
static
const
char
*
tree_oid
=
"1810dff58d8a660512d4832e740f692884338ccd"
;
static
const
char
*
root_commit_message
=
"This is a root commit
\n
\
This is a root commit and should be the only one in this branch
\n
"
;
static
const
char
*
root_reflog_message
=
"commit (initial): This is a root commit \
This is a root commit and should be the only one in this branch"
;
static
char
*
head_old
;
static
git_reference
*
head
,
*
branch
;
static
git_commit
*
commit
;
...
...
@@ -101,6 +103,8 @@ void test_commit_write__root(void)
git_signature
*
author
,
*
committer
;
const
char
*
branch_name
=
"refs/heads/root-commit-branch"
;
git_tree
*
tree
;
git_reflog
*
log
;
const
git_reflog_entry
*
entry
;
git_oid_fromstr
(
&
tree_id
,
tree_oid
);
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
tree_id
));
...
...
@@ -130,7 +134,6 @@ void test_commit_write__root(void)
0
));
git_object_free
((
git_object
*
)
tree
);
git_signature_free
(
committer
);
git_signature_free
(
author
);
/*
...
...
@@ -144,4 +147,14 @@ void test_commit_write__root(void)
branch_oid
=
git_reference_target
(
branch
);
cl_git_pass
(
git_oid_cmp
(
branch_oid
,
&
commit_id
));
cl_assert_equal_s
(
root_commit_message
,
git_commit_message
(
commit
));
cl_git_pass
(
git_reflog_read
(
&
log
,
g_repo
,
branch_name
));
cl_assert_equal_i
(
1
,
git_reflog_entrycount
(
log
));
entry
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
committer
->
email
,
git_reflog_entry_committer
(
entry
)
->
email
);
cl_assert_equal_s
(
committer
->
name
,
git_reflog_entry_committer
(
entry
)
->
name
);
cl_assert_equal_s
(
root_reflog_message
,
git_reflog_entry_message
(
entry
));
git_signature_free
(
committer
);
git_reflog_free
(
log
);
}
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