summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-06-15 22:24:59 +0200
committernulltoken <emeric.fermas@gmail.com>2012-06-19 10:02:22 +0200
commit743a4b3bdd0ff37eacf49e496ba2e5cd7b9a3f83 (patch)
tree70a6ea1a449e504bfe66dbf47168a360f049086f /include/git2
parent68f527c4480f0c1e24f29dc0a2337469fe50967f (diff)
downloadlibgit2-743a4b3bdd0ff37eacf49e496ba2e5cd7b9a3f83.tar.gz
message: Expose git_message_prettify()
git_commit() and git_tag() no longer prettify the message by default. This has to be taken care of by the caller. This has the nice side effect of putting the caller in position to actually choose to strip the comments or not.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/commit.h4
-rw-r--r--include/git2/message.h41
-rw-r--r--include/git2/tag.h4
3 files changed, 45 insertions, 4 deletions
diff --git a/include/git2/commit.h b/include/git2/commit.h
index a6d9bb0e..640adf5c 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -182,8 +182,8 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i
* Create a new commit in the repository using `git_object`
* instances as parameters.
*
- * The message will be cleaned up from excess whitespace
- * it will be made sure that the last line ends with a '\n'.
+ * The message will not be cleaned up. This can be achieved
+ * through `git_message_prettify()`.
*
* @param oid Pointer where to store the OID of the
* newly created commit
diff --git a/include/git2/message.h b/include/git2/message.h
new file mode 100644
index 00000000..7f255858
--- /dev/null
+++ b/include/git2/message.h
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ *
+ * @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 GIT_SUCCESS or an error code
+ */
+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__ */
diff --git a/include/git2/tag.h b/include/git2/tag.h
index 13dc145b..b522451a 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -137,8 +137,8 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
* this tag object. If `force` is true and a reference
* already exists with the given name, it'll be replaced.
*
- * The message will be cleaned up from excess whitespace
- * it will be made sure that the last line ends with a '\n'.
+ * The message will not be cleaned up. This can be achieved
+ * through `git_message_prettify()`.
*
* @param oid Pointer where to store the OID of the
* newly created tag. If the tag already exists, this parameter