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
9ca4ff41
Commit
9ca4ff41
authored
May 09, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1563 from arrbee/doc-fix-repo-message
Fix git_repository_message docs
parents
503dd0f3
3d1c9f61
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
include/git2/repository.h
+11
-2
src/repository.c
+3
-0
tests-clar/repo/message.c
+6
-1
No files found.
include/git2/repository.h
View file @
9ca4ff41
...
@@ -460,10 +460,19 @@ GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
...
@@ -460,10 +460,19 @@ GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
* Use this function to get the contents of this file. Don't forget to
* Use this function to get the contents of this file. Don't forget to
* remove the file after you create the commit.
* remove the file after you create the commit.
*
*
* If the repository message exists and there are no errors reading it, this
* returns the bytes needed to store the message in memory (i.e. message
* file size plus one terminating NUL byte). That value is returned even if
* `out` is NULL or `len` is shorter than the necessary size.
*
* The `out` buffer will *always* be NUL terminated, even if truncation
* occurs.
*
* @param out Buffer to write data into or NULL to just read required size
* @param out Buffer to write data into or NULL to just read required size
* @param len Length of buffer in bytes
* @param len Length of
`out`
buffer in bytes
* @param repo Repository to read prepared message from
* @param repo Repository to read prepared message from
* @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error
* @return GIT_ENOUTFOUND if no message exists, other value < 0 for other
* errors, or total bytes in message (may be > `len`) on success
*/
*/
GIT_EXTERN
(
int
)
git_repository_message
(
char
*
out
,
size_t
len
,
git_repository
*
repo
);
GIT_EXTERN
(
int
)
git_repository_message
(
char
*
out
,
size_t
len
,
git_repository
*
repo
);
...
...
src/repository.c
View file @
9ca4ff41
...
@@ -1596,6 +1596,9 @@ int git_repository_message(char *buffer, size_t len, git_repository *repo)
...
@@ -1596,6 +1596,9 @@ int git_repository_message(char *buffer, size_t len, git_repository *repo)
struct
stat
st
;
struct
stat
st
;
int
error
;
int
error
;
if
(
buffer
!=
NULL
)
*
buffer
=
'\0'
;
if
(
git_buf_joinpath
(
&
path
,
repo
->
path_repository
,
GIT_MERGE_MSG_FILE
)
<
0
)
if
(
git_buf_joinpath
(
&
path
,
repo
->
path_repository
,
GIT_MERGE_MSG_FILE
)
<
0
)
return
-
1
;
return
-
1
;
...
...
tests-clar/repo/message.c
View file @
9ca4ff41
...
@@ -35,13 +35,18 @@ void test_repo_message__message(void)
...
@@ -35,13 +35,18 @@ void test_repo_message__message(void)
len
=
git_repository_message
(
NULL
,
0
,
_repo
);
len
=
git_repository_message
(
NULL
,
0
,
_repo
);
cl_assert
(
len
>
0
);
cl_assert
(
len
>
0
);
_actual
=
git__malloc
(
len
+
1
);
_actual
=
git__malloc
(
len
+
1
);
cl_assert
(
_actual
!=
NULL
);
cl_assert
(
_actual
!=
NULL
);
/* Test non truncation */
cl_assert
(
git_repository_message
(
_actual
,
len
,
_repo
)
>
0
);
cl_assert
(
git_repository_message
(
_actual
,
len
,
_repo
)
>
0
);
_actual
[
len
]
=
'\0'
;
cl_assert_equal_s
(
expected
,
_actual
);
cl_assert_equal_s
(
expected
,
_actual
);
/* Test truncation and that trailing NUL is inserted */
cl_assert
(
git_repository_message
(
_actual
,
6
,
_repo
)
>
0
);
cl_assert_equal_s
(
"Test
\n
"
,
_actual
);
cl_git_pass
(
p_unlink
(
git_buf_cstr
(
&
_path
)));
cl_git_pass
(
p_unlink
(
git_buf_cstr
(
&
_path
)));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_repository_message
(
NULL
,
0
,
_repo
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_repository_message
(
NULL
,
0
,
_repo
));
}
}
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