git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Sean <seanlkml@sympatico.ca>,
	Benoit SIGOURE <tsuna@lrde.epita.fr>,
	git@vger.kernel.org
Subject: Re: [PATCH 1/3] log_ref_write() -- do not chomp reflog message at the first LF
Date: Sun, 29 Jul 2007 12:57:09 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707291248560.14781@racer.site> (raw)
In-Reply-To: <7vvec4nhfk.fsf_-_@assigned-by-dhcp.cox.net>

Hi,

On Sat, 28 Jul 2007, Junio C Hamano wrote:

> A reflog file is organized as one-line-per-entry records, and we
> enforced the file format integrity by chomping the given message
> at the first LF.  This changes it to convert them to SP, which
> is more in line with the --pretty=oneline format.

Would it not be better to chop off before the first "\n", and just append 
"..."?  IOW something like

-- snip --
 refs.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/refs.c b/refs.c
index 2694e70..554436b 100644
--- a/refs.c
+++ b/refs.c
@@ -1043,7 +1043,7 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
 	unsigned maxlen, len;
 	int msglen;
 	char *log_file, *logrec;
-	const char *committer;
+	const char *committer, *postmsg;
 
 	if (log_all_ref_updates < 0)
 		log_all_ref_updates = !is_bare_repository();
@@ -1088,15 +1088,16 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
 				break;
 		if (*msg) {
 			const char *ep = strchr(msg, '\n');
-			if (ep)
+			if (ep) {
 				msglen = ep - msg;
-			else
+				postmsg = (ep[1] && !isspace(ep[1])) ? "..." : NULL;
+			} else
 				msglen = strlen(msg);
 		}
 	}
 
 	committer = git_committer_info(-1);
-	maxlen = strlen(committer) + msglen + 100;
+	maxlen = strlen(committer) + msglen + 100 + 3;
 	logrec = xmalloc(maxlen);
 	len = sprintf(logrec, "%s %s %s\n",
 		      sha1_to_hex(old_sha1),
@@ -1104,6 +1105,10 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
 		      committer);
 	if (msglen)
 		len += sprintf(logrec + len - 1, "\t%.*s\n", msglen, msg) - 1;
+	if (postmsg) {
+		len += strlen(postmsg);
+		strcat(logrec + len - 1, postmsg);
+	}
 	written = len <= maxlen ? write_in_full(logfd, logrec, len) : -1;
 	free(logrec);
 	if (close(logfd) != 0 || written != len)
-- snap --

It is not like the reflog messages have to be very verbose; they only have 
to give a hint what the commit was about, and the commit name is the 
important information.

What do you think?

Ciao,
Dscho

  reply	other threads:[~2007-07-29 11:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-28 10:07 git-svn rebase screwing up commit messages Benoit SIGOURE
2007-07-28 12:14 ` Junio C Hamano
2007-07-28 12:35   ` Sean
2007-07-28 13:10     ` Junio C Hamano
2007-07-28 13:29       ` Sean
2007-07-28 13:38         ` Junio C Hamano
2007-07-28 14:11           ` Sean
2007-07-28 20:41             ` Junio C Hamano
2007-07-29  1:08               ` Junio C Hamano
2007-07-29  1:10                 ` [PATCH 1/3] log_ref_write() -- do not chomp reflog message at the first LF Junio C Hamano
2007-07-29 11:57                   ` Johannes Schindelin [this message]
2007-07-29 18:47                     ` Junio C Hamano
2007-07-29 19:02                       ` Johannes Schindelin
2007-07-29  1:10                 ` [PATCH 2/3] symbolic-ref, update-ref: do not refuse reflog message with LF Junio C Hamano
2007-07-29  1:11                 ` [PATCH 3/3] rebase: try not to munge commit log message Junio C Hamano
2007-07-28 14:32           ` git-svn rebase screwing up commit messages Jakub Narebski
2007-07-28 19:48           ` Robin Rosenberg
2007-07-28 17:33       ` Benoit SIGOURE

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=Pine.LNX.4.64.0707291248560.14781@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=seanlkml@sympatico.ca \
    --cc=tsuna@lrde.epita.fr \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).