libgit2/include/git2/message.h
Russell Belfer 85a0e28b80 Make git_message_prettify return bytes written
If you want to be absolutely safe with git_message_prettify, you
can now pass a NULL pointer for the buffer and get back the number
of bytes that would be copied into the buffer.

This means that an error is a non-negative return code and a
success will be greater than zero from this function.
2012-08-14 10:50:58 -07:00

44 lines
1.2 KiB
C

/*
* Copyright (C) 2009-2012 the libgit2 contributors
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_git_message_h__
#define INCLUDE_git_message_h__
#include "common.h"
/**
* @file git2/message.h
* @brief Git message management routines
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
/**
* Clean up message from excess whitespace and make sure that the last line
* ends with a '\n'.
*
* Optionally, can remove lines starting with a "#".
*
* @param message_out The user allocated buffer which will be filled with
* the cleaned up message. Pass NULL if you just want to get the size of the
* prettified message as the output value.
*
* @param size The size of the allocated buffer message_out.
*
* @param message The message to be prettified.
*
* @param strip_comments 1 to remove lines starting with a "#", 0 otherwise.
*
* @return -1 on error, else number of characters in prettified message
* including the trailing NUL byte
*/
GIT_EXTERN(int) git_message_prettify(char *message_out, size_t buffer_size, const char *message, int strip_comments);
/** @} */
GIT_END_DECL
#endif /* INCLUDE_git_message_h__ */