All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, David Turner <dturner@twopensource.com>,
	Michael Haggerty <mhagger@alum.mit.edu>
Subject: [PATCH v6 19/25] refs: move copy_msg to the common code
Date: Tue,  3 Nov 2015 08:40:03 +0100	[thread overview]
Message-ID: <226c66afe0bc7eb946c0f3075ab8b1062f074fc3.1446534991.git.mhagger@alum.mit.edu> (raw)
In-Reply-To: <cover.1446534991.git.mhagger@alum.mit.edu>

From: David Turner <dturner@twopensource.com>

Rename copy_msg to copy_reflog_msg and add it to refs/refs-internal.h.

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 refs/files-backend.c | 28 +---------------------------
 refs/refs-internal.h |  7 +++++++
 refs/refs.c          | 21 +++++++++++++++++++++
 3 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index 3a4aff6..4807b32 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2665,32 +2665,6 @@ static int commit_ref(struct ref_lock *lock)
 	return 0;
 }
 
-/*
- * copy the reflog message msg to buf, which has been allocated sufficiently
- * large, while cleaning up the whitespaces.  Especially, convert LF to space,
- * because reflog file is one line per entry.
- */
-static int copy_msg(char *buf, const char *msg)
-{
-	char *cp = buf;
-	char c;
-	int wasspace = 1;
-
-	*cp++ = '\t';
-	while ((c = *msg++)) {
-		if (wasspace && isspace(c))
-			continue;
-		wasspace = isspace(c);
-		if (wasspace)
-			c = ' ';
-		*cp++ = c;
-	}
-	while (buf < cp && isspace(cp[-1]))
-		cp--;
-	*cp++ = '\n';
-	return cp - buf;
-}
-
 static int should_autocreate_reflog(const char *refname)
 {
 	if (!log_all_ref_updates)
@@ -2774,7 +2748,7 @@ static int log_ref_write_fd(int fd, const unsigned char *old_sha1,
 			sha1_to_hex(new_sha1),
 			committer);
 	if (msglen)
-		len += copy_msg(logrec + len - 1, msg) - 1;
+		len += copy_reflog_msg(logrec + len - 1, msg) - 1;
 
 	written = len <= maxlen ? write_in_full(fd, logrec, len) : -1;
 	free(logrec);
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 5ae084b..a1655e3 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -114,4 +114,11 @@ struct ref_transaction {
 	enum ref_transaction_state state;
 };
 
+/*
+ * Copy the reflog message msg to buf, which has been allocated sufficiently
+ * large, while cleaning up the whitespaces.  Especially, convert LF to space,
+ * because reflog file is one line per entry.
+ */
+int copy_reflog_msg(char *buf, const char *msg);
+
 #endif /* REFS_REFS_INTERNAL_H */
diff --git a/refs/refs.c b/refs/refs.c
index 31f1b19..6bf790b 100644
--- a/refs/refs.c
+++ b/refs/refs.c
@@ -827,6 +827,27 @@ int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *c
 	return for_each_ref_in_submodule(submodule, "refs/remotes/", fn, cb_data);
 }
 
+int copy_reflog_msg(char *buf, const char *msg)
+{
+	char *cp = buf;
+	char c;
+	int wasspace = 1;
+
+	*cp++ = '\t';
+	while ((c = *msg++)) {
+		if (wasspace && isspace(c))
+			continue;
+		wasspace = isspace(c);
+		if (wasspace)
+			c = ' ';
+		*cp++ = c;
+	}
+	while (buf < cp && isspace(cp[-1]))
+		cp--;
+	*cp++ = '\n';
+	return cp - buf;
+}
+
 int head_ref_namespaced(each_ref_fn fn, void *cb_data)
 {
 	struct strbuf buf = STRBUF_INIT;
-- 
2.6.2

  parent reply	other threads:[~2015-11-03  7:47 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-28  2:14 [PATCH v5 00/26] refs backend pre-vtable David Turner
2015-10-28  2:14 ` [PATCH v5 01/26] refs.c: create a public version of verify_refname_available David Turner
2015-10-28  2:14 ` [PATCH v5 02/26] refs: make is_branch public David Turner
2015-10-28  2:14 ` [PATCH v5 03/26] refs-be-files.c: rename refs to refs-be-files David Turner
2015-10-28  2:14 ` [PATCH v5 04/26] refs.c: add a new refs.c file to hold all common refs code David Turner
2015-10-28  2:14 ` [PATCH v5 05/26] refs.c: move update_ref to refs.c David Turner
2015-10-28  2:14 ` [PATCH v5 06/26] refs.c: move delete_pseudoref and delete_ref to the common code David Turner
2015-10-28  2:14 ` [PATCH v5 07/26] refs.c: move read_ref_at to the common refs file David Turner
2015-10-28  2:14 ` [PATCH v5 08/26] refs.c: move the hidden refs functions to the common code David Turner
2015-10-28  2:14 ` [PATCH v5 09/26] refs.c: move dwim and friend functions to the common refs code David Turner
2015-10-28  2:14 ` [PATCH v5 10/26] refs.c: move warn_if_dangling_symref* to the common code David Turner
2015-10-28  2:14 ` [PATCH v5 11/26] refs.c: move read_ref, read_ref_full and ref_exists " David Turner
2015-10-28  2:14 ` [PATCH v5 12/26] refs.c: move resolve_refdup to common David Turner
2015-10-28  2:14 ` [PATCH v5 13/26] refs.c: move check_refname_format to the common code David Turner
2015-10-28  2:14 ` [PATCH v5 14/26] refs.c: move is_branch " David Turner
2015-10-28  2:14 ` [PATCH v5 15/26] refs.c: move prettify_refname " David Turner
2015-10-28  2:14 ` [PATCH v5 16/26] refs.c: move ref iterators " David Turner
2015-11-01  4:39   ` Michael Haggerty
2015-10-28  2:14 ` [PATCH v5 17/26] refs.c: move head_ref_namespaced " David Turner
2015-10-28  2:14 ` [PATCH v5 18/26] refs: move transaction functions into " David Turner
2015-11-01  8:17   ` Michael Haggerty
2015-11-02 22:19     ` David Turner
2015-10-28  2:14 ` [PATCH v5 19/26] refs.c: move refname_is_safe to the " David Turner
2015-10-28  2:14 ` [PATCH v5 20/26] refs.c: move copy_msg " David Turner
2015-10-28  2:14 ` [PATCH v5 21/26] refs.c: move peel_object " David Turner
2015-10-28  2:14 ` [PATCH v5 22/26] refs.c: move should_autocreate_reflog to " David Turner
2015-10-28  2:14 ` [PATCH v5 23/26] initdb: move safe_create_dir into " David Turner
2015-10-28  2:14 ` [PATCH v5 24/26] refs: make files_log_ref_write functions public David Turner
2015-10-28  2:14 ` [PATCH v5 25/26] refs: break out ref conflict checks David Turner
2015-11-02 16:52   ` Michael Haggerty
2015-10-28  2:14 ` [PATCH v5 26/26] introduce "extensions" form of core.repositoryformatversion David Turner
2015-11-03  7:36 ` [PATCH v5 00/26] refs backend pre-vtable Michael Haggerty
2015-11-03  7:39 ` [PATCH v6 00/25] " Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 01/25] refs: make is_branch public Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 02/25] refs/files-backend.c: new file, renamed from refs.c Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 03/25] refs: add a new file, refs/refs.c, to hold common refs code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 04/25] refs: move update_ref to refs/refs.c Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 05/25] refs: move delete_pseudoref and delete_ref to the common code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 06/25] refs: move read_ref_at to the common refs file Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 07/25] refs: move the hidden refs functions to the common code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 08/25] refs: move dwim and friend functions to the common refs code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 09/25] refs: move warn_if_dangling_symref* to the common code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 10/25] refs: move read_ref, read_ref_full and ref_exists " Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 11/25] refs: move resolve_refdup to common Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 12/25] refs: move check_refname_format to the common code Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 13/25] refs: move is_branch " Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 14/25] refs: move prettify_refname " Michael Haggerty
2015-11-03  7:39   ` [PATCH v6 15/25] refs: move ref iterators " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 16/25] refs: move head_ref_namespaced " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 17/25] refs: move transaction functions " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 18/25] refs: move refname_is_safe " Michael Haggerty
2015-11-03  7:40   ` Michael Haggerty [this message]
2015-11-03  7:40   ` [PATCH v6 20/25] refs: move peel_object " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 21/25] refs: move should_autocreate_reflog to " Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 22/25] initdb: make safe_create_dir public Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 23/25] files_log_ref_write: new function Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 24/25] refs: create a shared version of verify_refname_available Michael Haggerty
2015-11-03  7:40   ` [PATCH v6 25/25] refs: break out ref conflict checks Michael Haggerty
2015-11-04 21:01     ` David Turner
2015-11-05  4:00       ` Michael Haggerty
2015-11-05 16:22         ` David Turner
2015-11-06 13:34           ` Michael Haggerty
2015-11-06 17:28             ` Junio C Hamano
2015-11-06 23:24               ` Junio C Hamano
2015-11-08  5:03                 ` Michael Haggerty
2015-11-08  5:54                   ` Michael Haggerty
2015-11-08 18:23                   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=226c66afe0bc7eb946c0f3075ab8b1062f074fc3.1446534991.git.mhagger@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=dturner@twopensource.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.