All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add --pretty=changelog
@ 2007-02-27 15:21 ` Johannes Schindelin
  2007-02-27 15:38   ` Nicolas Pitre
                     ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Johannes Schindelin @ 2007-02-27 15:21 UTC (permalink / raw)
  To: git, Simon Josefsson; +Cc: junkio


This outputs the log in GNU ChangeLog format.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 commit.c   |   18 +++++++++++---
 commit.h   |    1 +
 diff.c     |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 diff.h     |    1 +
 log-tree.c |   17 ++++++++++++-
 revision.c |    6 ++++
 6 files changed, 115 insertions(+), 5 deletions(-)

diff --git a/commit.c b/commit.c
index fb75ae5..64ddb56 100644
--- a/commit.c
+++ b/commit.c
@@ -38,6 +38,7 @@ struct cmt_fmt_map {
 	{ "fuller",	5,	CMIT_FMT_FULLER },
 	{ "oneline",	1,	CMIT_FMT_ONELINE },
 	{ "format:",	7,	CMIT_FMT_USERFORMAT},
+	{ "changelog",	9,	CMIT_FMT_CHANGELOG}
 };
 
 static char *user_format;
@@ -563,6 +564,8 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,
 		ret += namelen - display_name_length;
 		buf[ret++] = '\n';
 	}
+	else if (fmt == CMIT_FMT_CHANGELOG)
+		ret = 0;
 	else {
 		ret = sprintf(buf, "%s: %.*s%.*s\n", what,
 			      (fmt == CMIT_FMT_FULLER) ? 4 : 0,
@@ -581,6 +584,11 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,
 		ret += sprintf(buf + ret, "%sDate: %s\n", what,
 			       show_date(time, tz, relative_date));
 		break;
+	case CMIT_FMT_CHANGELOG:
+		ret += sprintf(buf + ret, "%s  %.*s\n",
+				show_date(time, tz, DATE_SHORT),
+				namelen, line);
+		break;
 	default:
 		/* notin' */
 		break;
@@ -603,7 +611,7 @@ static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *com
 	int offset;
 
 	if ((fmt == CMIT_FMT_ONELINE) || (fmt == CMIT_FMT_EMAIL) ||
-	    !parent || !parent->next)
+	    fmt == CMIT_FMT_CHANGELOG || !parent || !parent->next)
 		return 0;
 
 	offset = sprintf(buf, "Merge:");
@@ -931,7 +939,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 	if (reencoded)
 		msg = reencoded;
 
-	if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL)
+	if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL ||
+	    fmt == CMIT_FMT_CHANGELOG)
 		indent = 0;
 
 	/* After-subject is used to pass in Content-Type: multipart
@@ -982,7 +991,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 		if (hdr) {
 			if (linelen == 1) {
 				hdr = 0;
-				if ((fmt != CMIT_FMT_ONELINE) && !subject)
+				if (fmt != CMIT_FMT_ONELINE &&
+				    fmt != CMIT_FMT_CHANGELOG && !subject)
 					buf[offset++] = '\n';
 				continue;
 			}
@@ -1052,7 +1062,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 			offset += linelen + indent;
 		}
 		buf[offset++] = '\n';
-		if (fmt == CMIT_FMT_ONELINE)
+		if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_CHANGELOG)
 			break;
 		if (subject && plain_non_ascii) {
 			int sz;
diff --git a/commit.h b/commit.h
index 83507a0..9d59e0f 100644
--- a/commit.h
+++ b/commit.h
@@ -48,6 +48,7 @@ enum cmit_fmt {
 	CMIT_FMT_ONELINE,
 	CMIT_FMT_EMAIL,
 	CMIT_FMT_USERFORMAT,
+	CMIT_FMT_CHANGELOG,
 
 	CMIT_FMT_UNSPECIFIED,
 };
diff --git a/diff.c b/diff.c
index 5651152..aed5388 100644
--- a/diff.c
+++ b/diff.c
@@ -8,6 +8,7 @@
 #include "delta.h"
 #include "xdiff-interface.h"
 #include "color.h"
+#include "utf8.h"
 
 #ifdef NO_FAST_WORKING_DIRECTORY
 #define FAST_WORKING_DIRECTORY 0
@@ -1845,6 +1846,59 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
 	builtin_checkdiff(name, other, p->one, p->two, o);
 }
 
+#define CHANGELOG_TAB_SIZE 8
+#define CHANGELOG_WIDTH 76
+
+struct changelog_t {
+	int offset, seen_first;
+};
+
+static void run_changelog(struct diff_filepair *p, struct diff_options *o,
+	struct changelog_t *changelog)
+{
+	const char *name;
+	const char *other;
+	static char buffer[1024];
+
+	if (DIFF_PAIR_UNMERGED(p)) {
+		/* unmerged */
+		return;
+	}
+
+	if (changelog->seen_first)
+		buffer[0] = ',';
+	else {
+		buffer[0] = '*';
+		changelog->offset = -CHANGELOG_TAB_SIZE;
+		changelog->seen_first = 1;
+	}
+
+	name = p->one->path;
+	other = p->two->path;
+
+	if (!name) {
+		if (!other)
+			return;
+		snprintf(buffer + 1, sizeof(buffer) - 1, " %s", other);
+	} else if (!other || !strcmp(name, other))
+		snprintf(buffer + 1, sizeof(buffer) - 1, " %s", name);
+	else
+		snprintf(buffer + 1, sizeof(buffer) - 1, " %s => %s",
+				name, other);
+	changelog->offset = print_wrapped_text(buffer, -changelog->offset,
+		CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
+}
+
+static void finalize_changelog(struct diff_options *options,
+		struct changelog_t *changelog)
+{
+	changelog->offset = print_wrapped_text(": ", -changelog->offset,
+		CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
+	changelog->offset = print_wrapped_text(options->stat_sep,
+			-changelog->offset,
+			CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
+}
+
 void diff_setup(struct diff_options *options)
 {
 	memset(options, 0, sizeof(*options));
@@ -2366,6 +2420,19 @@ static void diff_flush_checkdiff(struct diff_filepair *p,
 	run_checkdiff(p, o);
 }
 
+static void diff_flush_changelog(struct diff_filepair *p,
+		struct diff_options *o, struct changelog_t *changelog)
+{
+	if (diff_unmodified_pair(p))
+		return;
+
+	if ((DIFF_FILE_VALID(p->one) && S_ISDIR(p->one->mode)) ||
+	    (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode)))
+		return; /* no tree diffs in patch format */
+
+	run_changelog(p, o, changelog);
+}
+
 int diff_queue_is_empty(void)
 {
 	struct diff_queue_struct *q = &diff_queued_diff;
@@ -2752,6 +2819,16 @@ void diff_flush(struct diff_options *options)
 		separator++;
 	}
 
+	if (output_format & DIFF_FORMAT_CHANGELOG) {
+		struct changelog_t changelog;
+		memset(&changelog, 0, sizeof(struct changelog_t));
+		for (i = 0; i < q->nr; i++) {
+			struct diff_filepair *p = q->queue[i];
+			if (check_pair_status(p))
+				diff_flush_changelog(p, options, &changelog);
+		}
+		finalize_changelog(options, &changelog);
+	}
 	if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT)) {
 		struct diffstat_t diffstat;
 
diff --git a/diff.h b/diff.h
index 4043cec..df3b512 100644
--- a/diff.h
+++ b/diff.h
@@ -30,6 +30,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
 #define DIFF_FORMAT_SUMMARY	0x0008
 #define DIFF_FORMAT_PATCH	0x0010
 #define DIFF_FORMAT_SHORTSTAT	0x0020
+#define DIFF_FORMAT_CHANGELOG	0x0040
 
 /* These override all above */
 #define DIFF_FORMAT_NAME	0x0100
diff --git a/log-tree.c b/log-tree.c
index 6ce239d..b7006bf 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -211,7 +211,8 @@ void show_log(struct rev_info *opt, const char *sep)
 				 sha1, sha1);
 			opt->diffopt.stat_sep = buffer;
 		}
-	} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
+	} else if (opt->commit_format != CMIT_FMT_USERFORMAT &&
+			opt->commit_format != CMIT_FMT_CHANGELOG) {
 		fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
 		      stdout);
 		if (opt->commit_format != CMIT_FMT_ONELINE)
@@ -253,6 +254,20 @@ void show_log(struct rev_info *opt, const char *sep)
 				  sizeof(this_header), abbrev, subject,
 				  extra_headers, opt->relative_date);
 
+	if (opt->commit_format == CMIT_FMT_CHANGELOG) {
+		static char *oneline = NULL;
+		char *eol = strchr(this_header, '\n');
+
+		if (oneline)
+			free(oneline);
+		if (eol) {
+			oneline = xstrdup(eol + 1);
+			eol[1] = '\0';
+		} else
+			oneline = NULL;
+		opt->diffopt.stat_sep = oneline;
+	}
+
 	if (opt->add_signoff)
 		len = append_signoff(this_header, sizeof(this_header), len,
 				     opt->add_signoff);
diff --git a/revision.c b/revision.c
index 823bbd1..5bdc1fc 100644
--- a/revision.c
+++ b/revision.c
@@ -1119,6 +1119,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 		if (revs->dense_combined_merges && !revs->diffopt.output_format)
 			revs->diffopt.output_format = DIFF_FORMAT_PATCH;
 	}
+	if (revs->commit_format == CMIT_FMT_CHANGELOG) {
+		revs->diffopt.output_format |= DIFF_FORMAT_CHANGELOG;
+		revs->diff = 1;
+		revs->diffopt.recursive = 1;
+		revs->no_merges = 1;
+	}
 	revs->diffopt.abbrev = revs->abbrev;
 	if (diff_setup_done(&revs->diffopt) < 0)
 		die("diff_setup_done failed");
-- 
1.5.0.2.2410.g737b

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-02-27 15:21 ` [PATCH] Add --pretty=changelog Johannes Schindelin
@ 2007-02-27 15:38   ` Nicolas Pitre
  2007-02-27 15:57     ` Johannes Schindelin
  2007-02-28  1:58   ` [PATCH 4/3] Rename --pretty=changelog to --pretty=gnucl, and fix a bug Johannes Schindelin
  2007-03-01 15:23   ` [PATCH] Add --pretty=changelog Simon Josefsson
  2 siblings, 1 reply; 24+ messages in thread
From: Nicolas Pitre @ 2007-02-27 15:38 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Simon Josefsson, junkio

On Tue, 27 Feb 2007, Johannes Schindelin wrote:

> 
> This outputs the log in GNU ChangeLog format.

Please don't call it "changelog".  I personally find this format horrid 
and "changelog" is too generic for such a specific format.  
"gnu_changelog" maybe...


Nicolas

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-02-27 15:38   ` Nicolas Pitre
@ 2007-02-27 15:57     ` Johannes Schindelin
  2007-02-27 23:11       ` Eric Wong
  0 siblings, 1 reply; 24+ messages in thread
From: Johannes Schindelin @ 2007-02-27 15:57 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: git, Simon Josefsson, junkio

Hi,

On Tue, 27 Feb 2007, Nicolas Pitre wrote:

> On Tue, 27 Feb 2007, Johannes Schindelin wrote:
> 
> > 
> > This outputs the log in GNU ChangeLog format.
> 
> Please don't call it "changelog".  I personally find this format horrid 
> and "changelog" is too generic for such a specific format.  
> "gnu_changelog" maybe...

Fair enough. Maybe with a dash, so it is easier to type?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-02-27 15:57     ` Johannes Schindelin
@ 2007-02-27 23:11       ` Eric Wong
  2007-02-27 23:22         ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Eric Wong @ 2007-02-27 23:11 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Nicolas Pitre, git, Simon Josefsson, junkio

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
> 
> On Tue, 27 Feb 2007, Nicolas Pitre wrote:
> 
> > On Tue, 27 Feb 2007, Johannes Schindelin wrote:
> > 
> > > 
> > > This outputs the log in GNU ChangeLog format.
> > 
> > Please don't call it "changelog".  I personally find this format horrid 
> > and "changelog" is too generic for such a specific format.  
> > "gnu_changelog" maybe...
> 
> Fair enough. Maybe with a dash, so it is easier to type?

> --- a/commit.c
> +++ b/commit.c
> @@ -38,6 +38,7 @@ struct cmt_fmt_map {
>  	{ "fuller",	5,	CMIT_FMT_FULLER },
>  	{ "oneline",	1,	CMIT_FMT_ONELINE },
>  	{ "format:",	7,	CMIT_FMT_USERFORMAT},
> +	{ "changelog",	9,	CMIT_FMT_CHANGELOG}
                        ^- that should be a 1

'gnu[_-]changelog' or 'changelog' would all uniquely abbreviate to a
single character.

--pretty=gnu sounds nice, however :)

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-02-27 23:11       ` Eric Wong
@ 2007-02-27 23:22         ` Junio C Hamano
  0 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2007-02-27 23:22 UTC (permalink / raw)
  To: Eric Wong
  Cc: Johannes Schindelin, Nicolas Pitre, git, Simon Josefsson, junkio

Eric Wong <normalperson@yhbt.net> writes:

> --pretty=gnu sounds nice, however :)

Huh?  It has the same problem as the earlier one suggested by
HPA: --pretty=rpm ;-)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 4/3] Rename --pretty=changelog to --pretty=gnucl, and fix a bug
  2007-02-27 15:21 ` [PATCH] Add --pretty=changelog Johannes Schindelin
  2007-02-27 15:38   ` Nicolas Pitre
@ 2007-02-28  1:58   ` Johannes Schindelin
  2007-02-28  2:52     ` Nicolas Pitre
  2007-03-01 15:23   ` [PATCH] Add --pretty=changelog Simon Josefsson
  2 siblings, 1 reply; 24+ messages in thread
From: Johannes Schindelin @ 2007-02-28  1:58 UTC (permalink / raw)
  To: git, Simon Josefsson; +Cc: junkio


It was pointed out that this format is rather specific. So, rename it
to "gnucl".

Also fix a bug where it would crash with an empty commit message.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 Documentation/pretty-formats.txt |   10 ++++++++++
 commit.c                         |    2 +-
 diff.c                           |    2 ++
 3 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 2fe6c31..f9ce4fb 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -77,6 +77,16 @@ displayed in full, regardless of whether --abbrev or
 true parent commits, without taking grafts nor history
 simplification into account.
 
+	* 'gnucl'
++
+--------------------------------------------------------------
+2007-02-22  Simon Josefsson <simon@josefsson.org>
+
+    * link-warning.h, gl/getaddrinfo.c, gl/gnulib.mk,
+         gl/string_.h, lgl/m4/unistd_h.m4: Update.
+--------------------------------------------------------------
+
+
 	* 'format:'
 +
 The 'format:' format allows you to specify which information
diff --git a/commit.c b/commit.c
index 64ddb56..abd84a8 100644
--- a/commit.c
+++ b/commit.c
@@ -38,7 +38,7 @@ struct cmt_fmt_map {
 	{ "fuller",	5,	CMIT_FMT_FULLER },
 	{ "oneline",	1,	CMIT_FMT_ONELINE },
 	{ "format:",	7,	CMIT_FMT_USERFORMAT},
-	{ "changelog",	9,	CMIT_FMT_CHANGELOG}
+	{ "gnucl",	1,	CMIT_FMT_CHANGELOG}
 };
 
 static char *user_format;
diff --git a/diff.c b/diff.c
index aed5388..f2d162f 100644
--- a/diff.c
+++ b/diff.c
@@ -1892,6 +1892,8 @@ static void run_changelog(struct diff_filepair *p, struct diff_options *o,
 static void finalize_changelog(struct diff_options *options,
 		struct changelog_t *changelog)
 {
+	if (!options->stat_sep)
+		return;
 	changelog->offset = print_wrapped_text(": ", -changelog->offset,
 		CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
 	changelog->offset = print_wrapped_text(options->stat_sep,
-- 
1.5.0.2.778.g534f-dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 4/3] Rename --pretty=changelog to --pretty=gnucl, and fix a bug
  2007-02-28  1:58   ` [PATCH 4/3] Rename --pretty=changelog to --pretty=gnucl, and fix a bug Johannes Schindelin
@ 2007-02-28  2:52     ` Nicolas Pitre
  2007-02-28 12:44       ` [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl Johannes Schindelin
  0 siblings, 1 reply; 24+ messages in thread
From: Nicolas Pitre @ 2007-02-28  2:52 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Simon Josefsson, junkio

On Wed, 28 Feb 2007, Johannes Schindelin wrote:

> It was pointed out that this format is rather specific. So, rename it
> to "gnucl".
[...]
> +	{ "gnucl",	1,	CMIT_FMT_CHANGELOG}

Shouldn't it be CMIT_FMT_GNUCL as well to be consistent?

This is nitpicking but I don't see why those GNU abominations should 
be assigned generic terms, even in this particular name space.


Nicolas

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl
  2007-02-28  2:52     ` Nicolas Pitre
@ 2007-02-28 12:44       ` Johannes Schindelin
  2007-03-02  8:49         ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Johannes Schindelin @ 2007-02-28 12:44 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: git, Simon Josefsson, junkio


Also rename {CMIT_FMT_,DIFF_FORMAT_}{CHANGELOG=>GNUCL}.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	On Tue, 27 Feb 2007, Nicolas Pitre wrote:

	> Shouldn't it be CMIT_FMT_GNUCL as well to be consistent?
	> 
	> This is nitpicking but I don't see why those GNU abominations 
	> should be assigned generic terms, even in this particular name 
	> space.

	I agree.

 commit.c   |   14 +++++++-------
 commit.h   |    2 +-
 diff.c     |    2 +-
 diff.h     |    2 +-
 log-tree.c |    4 ++--
 revision.c |    4 ++--
 6 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/commit.c b/commit.c
index abd84a8..3cb7e1c 100644
--- a/commit.c
+++ b/commit.c
@@ -38,7 +38,7 @@ struct cmt_fmt_map {
 	{ "fuller",	5,	CMIT_FMT_FULLER },
 	{ "oneline",	1,	CMIT_FMT_ONELINE },
 	{ "format:",	7,	CMIT_FMT_USERFORMAT},
-	{ "gnucl",	1,	CMIT_FMT_CHANGELOG}
+	{ "gnucl",	1,	CMIT_FMT_GNUCL}
 };
 
 static char *user_format;
@@ -564,7 +564,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,
 		ret += namelen - display_name_length;
 		buf[ret++] = '\n';
 	}
-	else if (fmt == CMIT_FMT_CHANGELOG)
+	else if (fmt == CMIT_FMT_GNUCL)
 		ret = 0;
 	else {
 		ret = sprintf(buf, "%s: %.*s%.*s\n", what,
@@ -584,7 +584,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,
 		ret += sprintf(buf + ret, "%sDate: %s\n", what,
 			       show_date(time, tz, relative_date));
 		break;
-	case CMIT_FMT_CHANGELOG:
+	case CMIT_FMT_GNUCL:
 		ret += sprintf(buf + ret, "%s  %.*s\n",
 				show_date(time, tz, DATE_SHORT),
 				namelen, line);
@@ -611,7 +611,7 @@ static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *com
 	int offset;
 
 	if ((fmt == CMIT_FMT_ONELINE) || (fmt == CMIT_FMT_EMAIL) ||
-	    fmt == CMIT_FMT_CHANGELOG || !parent || !parent->next)
+	    fmt == CMIT_FMT_GNUCL || !parent || !parent->next)
 		return 0;
 
 	offset = sprintf(buf, "Merge:");
@@ -940,7 +940,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 		msg = reencoded;
 
 	if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL ||
-	    fmt == CMIT_FMT_CHANGELOG)
+	    fmt == CMIT_FMT_GNUCL)
 		indent = 0;
 
 	/* After-subject is used to pass in Content-Type: multipart
@@ -992,7 +992,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 			if (linelen == 1) {
 				hdr = 0;
 				if (fmt != CMIT_FMT_ONELINE &&
-				    fmt != CMIT_FMT_CHANGELOG && !subject)
+				    fmt != CMIT_FMT_GNUCL && !subject)
 					buf[offset++] = '\n';
 				continue;
 			}
@@ -1062,7 +1062,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 			offset += linelen + indent;
 		}
 		buf[offset++] = '\n';
-		if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_CHANGELOG)
+		if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_GNUCL)
 			break;
 		if (subject && plain_non_ascii) {
 			int sz;
diff --git a/commit.h b/commit.h
index 9d59e0f..2425f7b 100644
--- a/commit.h
+++ b/commit.h
@@ -48,7 +48,7 @@ enum cmit_fmt {
 	CMIT_FMT_ONELINE,
 	CMIT_FMT_EMAIL,
 	CMIT_FMT_USERFORMAT,
-	CMIT_FMT_CHANGELOG,
+	CMIT_FMT_GNUCL,
 
 	CMIT_FMT_UNSPECIFIED,
 };
diff --git a/diff.c b/diff.c
index f2d162f..9f9cb34 100644
--- a/diff.c
+++ b/diff.c
@@ -2821,7 +2821,7 @@ void diff_flush(struct diff_options *options)
 		separator++;
 	}
 
-	if (output_format & DIFF_FORMAT_CHANGELOG) {
+	if (output_format & DIFF_FORMAT_GNUCL) {
 		struct changelog_t changelog;
 		memset(&changelog, 0, sizeof(struct changelog_t));
 		for (i = 0; i < q->nr; i++) {
diff --git a/diff.h b/diff.h
index df3b512..1c52851 100644
--- a/diff.h
+++ b/diff.h
@@ -30,7 +30,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
 #define DIFF_FORMAT_SUMMARY	0x0008
 #define DIFF_FORMAT_PATCH	0x0010
 #define DIFF_FORMAT_SHORTSTAT	0x0020
-#define DIFF_FORMAT_CHANGELOG	0x0040
+#define DIFF_FORMAT_GNUCL	0x0040
 
 /* These override all above */
 #define DIFF_FORMAT_NAME	0x0100
diff --git a/log-tree.c b/log-tree.c
index b7006bf..dd49154 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -212,7 +212,7 @@ void show_log(struct rev_info *opt, const char *sep)
 			opt->diffopt.stat_sep = buffer;
 		}
 	} else if (opt->commit_format != CMIT_FMT_USERFORMAT &&
-			opt->commit_format != CMIT_FMT_CHANGELOG) {
+			opt->commit_format != CMIT_FMT_GNUCL) {
 		fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
 		      stdout);
 		if (opt->commit_format != CMIT_FMT_ONELINE)
@@ -254,7 +254,7 @@ void show_log(struct rev_info *opt, const char *sep)
 				  sizeof(this_header), abbrev, subject,
 				  extra_headers, opt->relative_date);
 
-	if (opt->commit_format == CMIT_FMT_CHANGELOG) {
+	if (opt->commit_format == CMIT_FMT_GNUCL) {
 		static char *oneline = NULL;
 		char *eol = strchr(this_header, '\n');
 
diff --git a/revision.c b/revision.c
index 5bdc1fc..d7b9d2d 100644
--- a/revision.c
+++ b/revision.c
@@ -1119,8 +1119,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 		if (revs->dense_combined_merges && !revs->diffopt.output_format)
 			revs->diffopt.output_format = DIFF_FORMAT_PATCH;
 	}
-	if (revs->commit_format == CMIT_FMT_CHANGELOG) {
-		revs->diffopt.output_format |= DIFF_FORMAT_CHANGELOG;
+	if (revs->commit_format == CMIT_FMT_GNUCL) {
+		revs->diffopt.output_format |= DIFF_FORMAT_GNUCL;
 		revs->diff = 1;
 		revs->diffopt.recursive = 1;
 		revs->no_merges = 1;
-- 
1.5.0.2.778.g534f-dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-02-27 15:21 ` [PATCH] Add --pretty=changelog Johannes Schindelin
  2007-02-27 15:38   ` Nicolas Pitre
  2007-02-28  1:58   ` [PATCH 4/3] Rename --pretty=changelog to --pretty=gnucl, and fix a bug Johannes Schindelin
@ 2007-03-01 15:23   ` Simon Josefsson
  2007-03-01 18:15     ` Johannes Schindelin
  2 siblings, 1 reply; 24+ messages in thread
From: Simon Josefsson @ 2007-03-01 15:23 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> This outputs the log in GNU ChangeLog format.

Many thanks!  I ran this in my cvs->git repository for libtasn1, and
then did a diff against the output from cvs2cl in the old repository.
Here are some categories of differences:

1) Indentation should be under the '*'.  Compare (wrong):

        * src/asn1Coding.c, src/asn1Decoding.c, src/asn1Parser.c: Improve
          --help output.  Assume getopt_long, since gnulib provides it.

with (correct):

        * src/asn1Coding.c, src/asn1Decoding.c, src/asn1Parser.c: Improve
        --help output.  Assume getopt_long, since gnulib provides it.

2) Don't log anything for empty messages:

        * gl/.cvsignore: *** empty log message ***

Possibly, this should be an option.

3) Possible charset problem?  Compare this (correct):

        * configure.in: Fix -Wno-pointer-sign test to respect user-defined
        CFLAGS.  Reported by "Diego 'Flameeyes' Pettenò"
        <flameeyes@gentoo.org>.

with (wrong):

        * configure.in: Fix -Wno-pointer-sign test to respect user-defined
          CFLAGS.  Reported

The git log do seem to contain the correct data, though, from git-log:

    Fix -Wno-pointer-sign test to respect user-defined CFLAGS.  Reported
    by "Diego 'Flameeyes' Pettenò" <flameeyes@gentoo.org>.

4) Weird error, compare (correct):

        * lib/coding.c:
        (asn1_der_coding): For TYPE_NULL, increment counter even if we don't
        write any output.  Reported by Stephen Wrobleski
        <steve@localtoast.org>.

with (wrong):

        * lib/coding.c: (asn1_der_coding): For TYPE_NULL, increment counter
          even if we don't

Maybe this is related to the last one, and the problem really is '<' or '>'?

Here is another one, compare (correct):

        * lib/coding.c:
        (asn1_octet_der): Work even if str_len is 0, i.e., write an ASN.1
        length of zero.  Otherwise encodings became garbled on 64-bit
        platforms, detected while running the Shishi self-tests on the
        Debian build robots.  A self test to reproduce this is in Test_tree.

with (wrong):

        * lib/coding.c: (asn1_octet_der): Work even if str_len is 0, i.e.,
          write an ASN.1

I'll let you fix these and resume the diff later. :)

Can I pull your git tree from somewhere?  Applying patches from e-mail
is kind of boring.

/Simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-01 15:23   ` [PATCH] Add --pretty=changelog Simon Josefsson
@ 2007-03-01 18:15     ` Johannes Schindelin
  2007-03-01 18:27       ` Shawn O. Pearce
                         ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Johannes Schindelin @ 2007-03-01 18:15 UTC (permalink / raw)
  To: Simon Josefsson; +Cc: git, junkio

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2075 bytes --]

Hi,

On Thu, 1 Mar 2007, Simon Josefsson wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > This outputs the log in GNU ChangeLog format.
> 
> Many thanks!  I ran this in my cvs->git repository for libtasn1, and 
> then did a diff against the output from cvs2cl in the old repository. 
> Here are some categories of differences:

No good deed goes unpunished, they say...

> 1) Indentation should be under the '*'.  Compare (wrong):
> 
>         * src/asn1Coding.c, src/asn1Decoding.c, src/asn1Parser.c: Improve
>           --help output.  Assume getopt_long, since gnulib provides it.

I saw that in your mail already, and I find the style cvs2cl outputs ugly.

> 2) Don't log anything for empty messages:
> 
>         * gl/.cvsignore: *** empty log message ***
> 
> Possibly, this should be an option.

It does not log anything for empty messages. Not even a colon.

> 3) Possible charset problem?  Compare this (correct):
> 
>         * configure.in: Fix -Wno-pointer-sign test to respect user-defined
>         CFLAGS.  Reported by "Diego 'Flameeyes' Pettenò"
>         <flameeyes@gentoo.org>.
> 
> with (wrong):
> 
>         * configure.in: Fix -Wno-pointer-sign test to respect user-defined
>           CFLAGS.  Reported
> 
> The git log do seem to contain the correct data, though, from git-log:
> 
>     Fix -Wno-pointer-sign test to respect user-defined CFLAGS.  Reported
>     by "Diego 'Flameeyes' Pettenò" <flameeyes@gentoo.org>.

No charset problem. In Git commit messages, the first line is special. It 
is the so called "oneline" description. If you wrap the oneline, it's your 
fault, not Git's.

> 4) Weird error, compare (correct):

This is exactly the same as 3).

> I'll let you fix these and resume the diff later. :)

As far as I am concerned, I don't think there is anything to fix. Except 
maybe the wrapping of your commit messages, but I guess it is too late now 
to change them?

> Can I pull your git tree from somewhere?  Applying patches from e-mail 
> is kind of boring.

No, I don't have a public Git tree.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-01 18:15     ` Johannes Schindelin
@ 2007-03-01 18:27       ` Shawn O. Pearce
  2007-03-01 18:40         ` Johannes Schindelin
  2007-03-02  4:39       ` Junio C Hamano
  2007-03-02  9:14       ` Simon Josefsson
  2 siblings, 1 reply; 24+ messages in thread
From: Shawn O. Pearce @ 2007-03-01 18:27 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> No, I don't have a public Git tree.

Shame on you Dscho!  Even Junio has a public git tree!  ;-)

-- 
Shawn.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-01 18:27       ` Shawn O. Pearce
@ 2007-03-01 18:40         ` Johannes Schindelin
  0 siblings, 0 replies; 24+ messages in thread
From: Johannes Schindelin @ 2007-03-01 18:40 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

Hi,

On Thu, 1 Mar 2007, Shawn O. Pearce wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > No, I don't have a public Git tree.
> 
> Shame on you Dscho!  Even Junio has a public git tree!  ;-)

What would I do with a public git tree? It would only attract the svn 
dogs, who would cvs piss on it...

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-01 18:15     ` Johannes Schindelin
  2007-03-01 18:27       ` Shawn O. Pearce
@ 2007-03-02  4:39       ` Junio C Hamano
  2007-03-02  9:14       ` Simon Josefsson
  2 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2007-03-02  4:39 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Simon Josefsson, git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> 3) Possible charset problem?  Compare this (correct):
>> 
>>         * configure.in: Fix -Wno-pointer-sign test to respect user-defined
>>         CFLAGS.  Reported by "Diego 'Flameeyes' Pettenò"
>>         <flameeyes@gentoo.org>.
>> 
>> with (wrong):
>> 
>>         * configure.in: Fix -Wno-pointer-sign test to respect user-defined
>>           CFLAGS.  Reported
>> 
>> The git log do seem to contain the correct data, though, from git-log:
>> 
>>     Fix -Wno-pointer-sign test to respect user-defined CFLAGS.  Reported
>>     by "Diego 'Flameeyes' Pettenò" <flameeyes@gentoo.org>.
>
> No charset problem. In Git commit messages, the first line is special. It 
> is the so called "oneline" description. If you wrap the oneline, it's your 
> fault, not Git's.

I suspect that oneline mode in pretty_print_commit() _could_
treat the first line specially, by grabbing the first paragraph
and squashing LF into SP.  Commit messages that follow the
kernel convention (which matches well with what applymbox and am
creates) would always have a single line in the first paragraph,
so there is no change in behaviour, while commits that lack the
empty line on the second line, most often seen in cvsimport,
would get something a bit more readable than the status quo.

Not that I care too deeply about it.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl
  2007-02-28 12:44       ` [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl Johannes Schindelin
@ 2007-03-02  8:49         ` Junio C Hamano
  2007-03-02 14:28           ` [PATCH] print_wrapped_text: fix output for negative indent Johannes Schindelin
                             ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Junio C Hamano @ 2007-03-02  8:49 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Nicolas Pitre, git, Simon Josefsson, junkio

Is it just me or is your word wrapper misbehaving?  Notice the
line that ends with read-cache.c, and the line the comes after
it, in the sample output.

$ ./git show -s --pretty=gnucl ':/convert object type h'
2007-02-26  Nicolas Pitre <nico@cam.org>

        * archive-tar.c, archive-zip.c, blob.c, builtin-apply.c,
          builtin-blame.c, builtin-cat-file.c, builtin-commit-tree.c,
          builtin-for-each-ref.c, builtin-grep.c, builtin-log.c,
          builtin-pack-objects.c, builtin-prune.c, builtin-reflog.c,
          builtin-unpack-objects.c, cache.h, combine-diff.c, commit.c,
          convert-objects.c, diff.c, entry.c, fast-import.c, http-push.c,
          index-pack.c, merge-file.c, merge-recursive.c, merge-tree.c,
          mktag.c, mktree.c, object.c, object.h, pack-check.c, read-cache.c
           sha1_file.c, tag.c, tree-diff.c, tree.c, unpack-file.c: convert
          object type handling from a string to a number

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-01 18:15     ` Johannes Schindelin
  2007-03-01 18:27       ` Shawn O. Pearce
  2007-03-02  4:39       ` Junio C Hamano
@ 2007-03-02  9:14       ` Simon Josefsson
  2007-03-02 10:03         ` Junio C Hamano
  2007-03-02 14:09         ` Johannes Schindelin
  2 siblings, 2 replies; 24+ messages in thread
From: Simon Josefsson @ 2007-03-02  9:14 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> 1) Indentation should be under the '*'.  Compare (wrong):
>> 
>>         * src/asn1Coding.c, src/asn1Decoding.c, src/asn1Parser.c: Improve
>>           --help output.  Assume getopt_long, since gnulib provides it.
>
> I saw that in your mail already, and I find the style cvs2cl outputs ugly.

Well, if you don't follow the GNU ChangeLog format, then please call
it something else.  The format is well documented.

>> 2) Don't log anything for empty messages:
>> 
>>         * gl/.cvsignore: *** empty log message ***
>> 
>> Possibly, this should be an option.
>
> It does not log anything for empty messages. Not even a colon.

The problem here is that CVS insert '*** empty log message ***' when
you didn't supply a log message, and doing something intelligent with
such logs would be useful.  Plenty of projects that needs cvs2cl
functionality will be coming from the cvs world.

There is plenty of functionality in cvs2cl that I believe a proper
git2cl should support, handling empty CVS commit messages is one,
others would include ignoring files based on a regexp, output in XML
format, put ChangeLog's in sub-directories, show branches and tags.

>> 3) Possible charset problem?  Compare this (correct):
>> 
>>         * configure.in: Fix -Wno-pointer-sign test to respect user-defined
>>         CFLAGS.  Reported by "Diego 'Flameeyes' Pettenò"
>>         <flameeyes@gentoo.org>.
>> 
>> with (wrong):
>> 
>>         * configure.in: Fix -Wno-pointer-sign test to respect user-defined
>>           CFLAGS.  Reported
>> 
>> The git log do seem to contain the correct data, though, from git-log:
>> 
>>     Fix -Wno-pointer-sign test to respect user-defined CFLAGS.  Reported
>>     by "Diego 'Flameeyes' Pettenò" <flameeyes@gentoo.org>.
>
> No charset problem. In Git commit messages, the first line is special. It 
> is the so called "oneline" description. If you wrap the oneline, it's your 
> fault, not Git's.

But I want more than the oneline comment in the ChangeLog?  There is
no size limit on ChangeLog messages, and having as much information as
possible available is better.

Anyway, for now I'll be settling with the (just announced) git2cl
since it gives me the most flexibility.  If/when git core includes
your patch later on, and some of my pet problems are fixed, and my
distribution catches up, I'll be back.

/Simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-02  9:14       ` Simon Josefsson
@ 2007-03-02 10:03         ` Junio C Hamano
  2007-03-02 10:15           ` Simon Josefsson
  2007-03-02 14:09         ` Johannes Schindelin
  1 sibling, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2007-03-02 10:03 UTC (permalink / raw)
  To: Simon Josefsson; +Cc: Johannes Schindelin, git

Simon Josefsson <simon@josefsson.org> writes:

> The problem here is that CVS insert '*** empty log message ***' when
> you didn't supply a log message, and doing something intelligent with
> such logs would be useful.

If that is indeed the case then I suspect that cvs-to-git
conversion should know about it and strip the artificial
string.

In any case, as I already said a few times in this thread, I
think what you did is the right approach --- to read from "git
log --numstat" output and format the output to match the precise
detail of your project's liking with an external script.

> But I want more than the oneline comment in the ChangeLog?  There is
> no size limit on ChangeLog messages, and having as much information as
> possible available is better.

I think this was purely underspecification when your request was
passed to Johannes.

I've merged Johannes's gnucl series to 'next' but haven't pushed
out, so I'll revert it.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-02 10:03         ` Junio C Hamano
@ 2007-03-02 10:15           ` Simon Josefsson
  0 siblings, 0 replies; 24+ messages in thread
From: Simon Josefsson @ 2007-03-02 10:15 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git

Junio C Hamano <junkio@cox.net> writes:

> Simon Josefsson <simon@josefsson.org> writes:
>
>> The problem here is that CVS insert '*** empty log message ***' when
>> you didn't supply a log message, and doing something intelligent with
>> such logs would be useful.
>
> If that is indeed the case then I suspect that cvs-to-git
> conversion should know about it and strip the artificial
> string.

Yes, actually, that seems like a better solution.

Btw, there is a custom to work around cvs translating empty log
messages into '*** empty log message ***' strings, and that is to
commit a log consisting of '.'.  Translating both of those cvs log
messages into a '' git log message, during cvs-import, seems like a
useful change.

>> But I want more than the oneline comment in the ChangeLog?  There is
>> no size limit on ChangeLog messages, and having as much information as
>> possible available is better.
>
> I think this was purely underspecification when your request was
> passed to Johannes.
>
> I've merged Johannes's gnucl series to 'next' but haven't pushed
> out, so I'll revert it.

Sorry for the trouble!

Also thanks, Johannes, for working so quickly on this.  Seeing the
first version of the ChangeLog output from your patched git allowed me
to realize that the imported cvs history seemed ok.  After replacing
'cvs2cl' and 'cvsco' I couldn't find any other more cvs-specific
features in the project.  I have just released the first version of
libtasn1 from git instead of cvs.  More projects will follow...

/Simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-02  9:14       ` Simon Josefsson
  2007-03-02 10:03         ` Junio C Hamano
@ 2007-03-02 14:09         ` Johannes Schindelin
  2007-03-03 14:12           ` Simon Josefsson
  1 sibling, 1 reply; 24+ messages in thread
From: Johannes Schindelin @ 2007-03-02 14:09 UTC (permalink / raw)
  To: Simon Josefsson; +Cc: git, junkio

Hi,

On Fri, 2 Mar 2007, Simon Josefsson wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > I saw that in your mail already, and I find the style cvs2cl outputs 
> > ugly.
> 
> Well, if you don't follow the GNU ChangeLog format, then please call it 
> something else.  The format is well documented.

Well, it is still ugly. I mean, really ugly. Like in "it's easier to 
script, therefore I don't fix it" ugly.

And yes, the format is well documented. For example, it includes the 
function names in brackets, which both my patch and cvs2cl do not do. 
These function names actually got me interested, and I would have tried to 
generate them automatically, too.

> > No charset problem. In Git commit messages, the first line is special. 
> > It is the so called "oneline" description. If you wrap the oneline, 
> > it's your fault, not Git's.
> 
> But I want more than the oneline comment in the ChangeLog?  There is no 
> size limit on ChangeLog messages, and having as much information as 
> possible available is better.

With Git, it is encouraged that you write useful commit messages. There 
are commits where the patch consists of just a line change, and the 
message of a really long text. For a good example, look at commit 
v1.4.0-rc1~50: the commit message has 49 lines of text, but the patch only 
changes 5 lines.

If you are serious about "having as much information", include the 
_complete_ commit message.

> Anyway, for now I'll be settling with the (just announced) git2cl since 
> it gives me the most flexibility.

In hindsight I agree with Junio that a script is better for this purpose. 
At least I tricked you into writing it yourself.

> If/when git core includes your patch later on, and some of my pet 
> problems are fixed, and my distribution catches up, I'll be back.

FWIW I am now opposed to inclusion of --pretty=gnucl.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH] print_wrapped_text: fix output for negative indent
  2007-03-02  8:49         ` Junio C Hamano
@ 2007-03-02 14:28           ` Johannes Schindelin
  2007-03-02 14:29           ` [PATCH] --pretty=gnucl: avoid line wrapping before the comma Johannes Schindelin
  2007-03-03 12:38           ` [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl Junio C Hamano
  2 siblings, 0 replies; 24+ messages in thread
From: Johannes Schindelin @ 2007-03-02 14:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nicolas Pitre, git, Simon Josefsson


When providing a negative indent, it means that -indent columns were
already printed. Fix a bug where the function ate the first character
if already the first word did not fit into the first line.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Fri, 2 Mar 2007, Junio C Hamano wrote:

	> Is it just me or is your word wrapper misbehaving?

	It was. It separated printing of the file name and of the comma. 
	This is fixed with my next reply, but it triggered this small
	bug.

 utf8.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/utf8.c b/utf8.c
index ea23a6e..9e1a6d4 100644
--- a/utf8.c
+++ b/utf8.c
@@ -268,7 +268,7 @@ int print_wrapped_text(const char *text, int indent, int indent2, int width)
 			}
 			else {
 				putchar('\n');
-				text = bol = space + 1;
+				text = bol = space + isspace(*space);
 				space = NULL;
 				w = indent = indent2;
 			}
-- 
1.5.0.2.780.g57e5-dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH] --pretty=gnucl: avoid line wrapping before the comma
  2007-03-02  8:49         ` Junio C Hamano
  2007-03-02 14:28           ` [PATCH] print_wrapped_text: fix output for negative indent Johannes Schindelin
@ 2007-03-02 14:29           ` Johannes Schindelin
  2007-03-03 12:38           ` [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl Junio C Hamano
  2 siblings, 0 replies; 24+ messages in thread
From: Johannes Schindelin @ 2007-03-02 14:29 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nicolas Pitre, git, Simon Josefsson


Earlier, this code played dumb by outputting the file name and the comma
separately (to make it easier to determine when to output a colon
instead of the comma). This misguided code is fixed by this patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	I know that this is a dead topic branch, but I did not want
	to leave buggy code behind for future reference.

 diff.c |   60 ++++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/diff.c b/diff.c
index 9f9cb34..d33242a 100644
--- a/diff.c
+++ b/diff.c
@@ -1851,52 +1851,64 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
 
 struct changelog_t {
 	int offset, seen_first;
+	char buffer[1024];
 };
 
+static void flush_changelog_file_entry(struct changelog_t *log, char delim) {
+	if (!log->seen_first) {
+		log->offset = print_wrapped_text("* ", -CHANGELOG_TAB_SIZE,
+				CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
+		log->seen_first = 1;
+	}
+
+	if (log->buffer[0]) {
+		int len = strlen(log->buffer);
+		if (len + 3 < sizeof(log->buffer)) {
+			log->buffer[len++] = delim;
+			log->buffer[len++] = ' ';
+			log->buffer[len++] = '\0';
+		} else
+			warn("Line too long: skipping delimiter");
+
+		log->offset = print_wrapped_text(log->buffer, -log->offset,
+				CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
+		log->buffer[0] = '\0';
+	}
+}
+
 static void run_changelog(struct diff_filepair *p, struct diff_options *o,
-	struct changelog_t *changelog)
+	struct changelog_t *log)
 {
 	const char *name;
 	const char *other;
-	static char buffer[1024];
 
 	if (DIFF_PAIR_UNMERGED(p)) {
 		/* unmerged */
 		return;
 	}
 
-	if (changelog->seen_first)
-		buffer[0] = ',';
-	else {
-		buffer[0] = '*';
-		changelog->offset = -CHANGELOG_TAB_SIZE;
-		changelog->seen_first = 1;
-	}
-
 	name = p->one->path;
 	other = p->two->path;
 
-	if (!name) {
-		if (!other)
-			return;
-		snprintf(buffer + 1, sizeof(buffer) - 1, " %s", other);
-	} else if (!other || !strcmp(name, other))
-		snprintf(buffer + 1, sizeof(buffer) - 1, " %s", name);
+	if (!name && !other)
+		return;
+
+	flush_changelog_file_entry(log, ',');
+	if (!name)
+		snprintf(log->buffer, sizeof(log->buffer), "%s", other);
+	else if (!other || !strcmp(name, other))
+		snprintf(log->buffer, sizeof(log->buffer), "%s", name);
 	else
-		snprintf(buffer + 1, sizeof(buffer) - 1, " %s => %s",
+		snprintf(log->buffer, sizeof(log->buffer), "%s => %s",
 				name, other);
-	changelog->offset = print_wrapped_text(buffer, -changelog->offset,
-		CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
 }
 
 static void finalize_changelog(struct diff_options *options,
 		struct changelog_t *changelog)
 {
-	if (!options->stat_sep)
-		return;
-	changelog->offset = print_wrapped_text(": ", -changelog->offset,
-		CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
-	changelog->offset = print_wrapped_text(options->stat_sep,
+	flush_changelog_file_entry(changelog, ':');
+	changelog->offset = print_wrapped_text(options->stat_sep ?
+			options->stat_sep : "*** empty message ***",
 			-changelog->offset,
 			CHANGELOG_TAB_SIZE + 2, CHANGELOG_WIDTH);
 }
-- 
1.5.0.2.780.g57e5-dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl
  2007-03-02  8:49         ` Junio C Hamano
  2007-03-02 14:28           ` [PATCH] print_wrapped_text: fix output for negative indent Johannes Schindelin
  2007-03-02 14:29           ` [PATCH] --pretty=gnucl: avoid line wrapping before the comma Johannes Schindelin
@ 2007-03-03 12:38           ` Junio C Hamano
  2007-03-03 14:13             ` Johannes Schindelin
  2 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2007-03-03 12:38 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Nicolas Pitre, git, Simon Josefsson, junkio

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Earlier, this code played dumb by outputting the file name and the comma
> separately (to make it easier to determine when to output a colon
> instead of the comma). This misguided code is fixed by this patch.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>
> 	I know that this is a dead topic branch, but I did not want
> 	to leave buggy code behind for future reference.

Huh?  How did you measure bugginess before and after the change?

$ ./git show -s --pretty=gnucl ':/convert object type h'
2007-02-26  Nicolas Pitre <nico@cam.org>

* archive-tar.c, archive-zip.c, blob.c, builtin-apply.c, 
          uiltin-blame.c, builtin-cat-file.c, builtin-commit-tree.c, 
          uiltin-for-each-ref.c, builtin-grep.c, builtin-log.c, 
          uiltin-pack-objects.c, builtin-prune.c, builtin-reflog.c, 
          uiltin-unpack-objects.c, cache.h, combine-diff.c, commit.c, 
          onvert-objects.c, diff.c, entry.c, fast-import.c, http-push.c, 
          ndex-pack.c, merge-file.c, merge-recursive.c, merge-tree.c, 
          ktag.c, mktree.c, object.c, object.h, pack-check.c, read-cache.c,
          sha1_file.c, tag.c, tree-diff.c, tree.c, unpack-file.c: convert
          object type handling from a string to a number


Perhaps you would want something like this...

diff --git a/utf8.c b/utf8.c
index ea23a6e..3a7b923 100644
--- a/utf8.c
+++ b/utf8.c
@@ -268,7 +268,9 @@ int print_wrapped_text(const char *text, int indent, int indent2, int width)
 			}
 			else {
 				putchar('\n');
-				text = bol = space + 1;
+				if (isspace(*space))
+					space++;
+				text = bol = space;
 				space = NULL;
 				w = indent = indent2;
 			}

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH] Add --pretty=changelog
  2007-03-02 14:09         ` Johannes Schindelin
@ 2007-03-03 14:12           ` Simon Josefsson
  0 siblings, 0 replies; 24+ messages in thread
From: Simon Josefsson @ 2007-03-03 14:12 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Hi,
>
> On Fri, 2 Mar 2007, Simon Josefsson wrote:
>
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> 
>> > I saw that in your mail already, and I find the style cvs2cl outputs 
>> > ugly.
>> 
>> Well, if you don't follow the GNU ChangeLog format, then please call it 
>> something else.  The format is well documented.
>
> Well, it is still ugly. I mean, really ugly. Like in "it's easier to 
> script, therefore I don't fix it" ugly.
>
> And yes, the format is well documented. For example, it includes the 
> function names in brackets, which both my patch and cvs2cl do not do. 
> These function names actually got me interested, and I would have tried to 
> generate them automatically, too.

Including the function names in brackets is optional, but the wrap
style is inherent in the format.

However, it sounds like a nice idea to automatically add function
names when there aren't too many of them.  Possibly one should be able
to use a regexp to restrict the set of function names (useful, e.g.,
for only having brackets for public API functions).  I recall that
"diff" has an option to print C function names in patches, maybe that
could be used.

>> > No charset problem. In Git commit messages, the first line is special. 
>> > It is the so called "oneline" description. If you wrap the oneline, 
>> > it's your fault, not Git's.
>> 
>> But I want more than the oneline comment in the ChangeLog?  There is no 
>> size limit on ChangeLog messages, and having as much information as 
>> possible available is better.
>
> With Git, it is encouraged that you write useful commit messages. There 
> are commits where the patch consists of just a line change, and the 
> message of a really long text. For a good example, look at commit 
> v1.4.0-rc1~50: the commit message has 49 lines of text, but the patch only 
> changes 5 lines.
>
> If you are serious about "having as much information", include the 
> _complete_ commit message.

Yes, I do want the complete commit message.  While 49 lines of
ChangeLog entry is a lot, it is not completely unheard of.  Although
the recommendation in the GNU ChangeLog specification to move such
lengthy discussions to manuals or source code comments is often good.

>> Anyway, for now I'll be settling with the (just announced) git2cl since 
>> it gives me the most flexibility.
>
> In hindsight I agree with Junio that a script is better for this purpose. 

Yup, I think it will be more flexible to keep it outside of git.  It
makes it easier to do some un-git-ish things (like handling those
"empty" CVS log messages).

/Simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl
  2007-03-03 12:38           ` [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl Junio C Hamano
@ 2007-03-03 14:13             ` Johannes Schindelin
  2007-03-03 20:07               ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Johannes Schindelin @ 2007-03-03 14:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nicolas Pitre, git, Simon Josefsson

Hi,

On Sat, 3 Mar 2007, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Earlier, this code played dumb by outputting the file name and the comma
> > separately (to make it easier to determine when to output a colon
> > instead of the comma). This misguided code is fixed by this patch.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >
> > 	I know that this is a dead topic branch, but I did not want
> > 	to leave buggy code behind for future reference.
> 
> Huh?  How did you measure bugginess before and after the change?
> 
> $ ./git show -s --pretty=gnucl ':/convert object type h'
> 2007-02-26  Nicolas Pitre <nico@cam.org>
> 
> * archive-tar.c, archive-zip.c, blob.c, builtin-apply.c, 
>           uiltin-blame.c, builtin-cat-file.c, builtin-commit-tree.c, 
>           uiltin-for-each-ref.c, builtin-grep.c, builtin-log.c, 
>           uiltin-pack-objects.c, builtin-prune.c, builtin-reflog.c, 
>           uiltin-unpack-objects.c, cache.h, combine-diff.c, commit.c, 
>           onvert-objects.c, diff.c, entry.c, fast-import.c, http-push.c, 
>           ndex-pack.c, merge-file.c, merge-recursive.c, merge-tree.c, 
>           ktag.c, mktree.c, object.c, object.h, pack-check.c, read-cache.c,
>           sha1_file.c, tag.c, tree-diff.c, tree.c, unpack-file.c: convert
>           object type handling from a string to a number

For me, it is

$ ./git show -s --pretty=gnucl ':/convert object type h'
2007-02-26  Nicolas Pitre <nico@cam.org>

* archive-tar.c, archive-zip.c, blob.c, builtin-apply.c,
          builtin-blame.c, builtin-cat-file.c, builtin-commit-tree.c,
          builtin-for-each-ref.c, builtin-grep.c, builtin-log.c,
          builtin-pack-objects.c, builtin-prune.c, builtin-reflog.c,
          builtin-unpack-objects.c, cache.h, combine-diff.c, commit.c,
          convert-objects.c, diff.c, entry.c, fast-import.c, http-push.c,
          index-pack.c, merge-file.c, merge-recursive.c, merge-tree.c,
          mktag.c, mktree.c, object.c, object.h, pack-check.c,
          read-cache.c, sha1_file.c, tag.c, tree-diff.c, tree.c,
          unpack-file.c: convert object type handling from a string to a
          number

> Perhaps you would want something like this...
> 
> diff --git a/utf8.c b/utf8.c
> index ea23a6e..3a7b923 100644
> --- a/utf8.c
> +++ b/utf8.c
> @@ -268,7 +268,9 @@ int print_wrapped_text(const char *text, int indent, int indent2, int width)
>  			}
>  			else {
>  				putchar('\n');
> -				text = bol = space + 1;
> +				if (isspace(*space))
> +					space++;
> +				text = bol = space;
>  				space = NULL;
>  				w = indent = indent2;
>  			}

... or something like in

$ git show ':/print_wrapped_text: fix output for negative indent'

?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl
  2007-03-03 14:13             ` Johannes Schindelin
@ 2007-03-03 20:07               ` Junio C Hamano
  0 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2007-03-03 20:07 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Nicolas Pitre, git, Simon Josefsson

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> $ git show ':/print_wrapped_text: fix output for negative indent'

I forgot that your patch is relative to 'next'.  Silly me.

I cannot fork a topic directly from 'next', but I always test
topics in isolation first.  And I forgot that this topic
depended on that fix.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2007-03-03 20:07 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.63.0702271621120.22628@wbgn013.biozentrum.uni-wuerz burg.de>
2007-02-27 15:21 ` [PATCH] Add --pretty=changelog Johannes Schindelin
2007-02-27 15:38   ` Nicolas Pitre
2007-02-27 15:57     ` Johannes Schindelin
2007-02-27 23:11       ` Eric Wong
2007-02-27 23:22         ` Junio C Hamano
2007-02-28  1:58   ` [PATCH 4/3] Rename --pretty=changelog to --pretty=gnucl, and fix a bug Johannes Schindelin
2007-02-28  2:52     ` Nicolas Pitre
2007-02-28 12:44       ` [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl Johannes Schindelin
2007-03-02  8:49         ` Junio C Hamano
2007-03-02 14:28           ` [PATCH] print_wrapped_text: fix output for negative indent Johannes Schindelin
2007-03-02 14:29           ` [PATCH] --pretty=gnucl: avoid line wrapping before the comma Johannes Schindelin
2007-03-03 12:38           ` [PATCH] --amend Rename --pretty=changelog to --pretty=gnucl Junio C Hamano
2007-03-03 14:13             ` Johannes Schindelin
2007-03-03 20:07               ` Junio C Hamano
2007-03-01 15:23   ` [PATCH] Add --pretty=changelog Simon Josefsson
2007-03-01 18:15     ` Johannes Schindelin
2007-03-01 18:27       ` Shawn O. Pearce
2007-03-01 18:40         ` Johannes Schindelin
2007-03-02  4:39       ` Junio C Hamano
2007-03-02  9:14       ` Simon Josefsson
2007-03-02 10:03         ` Junio C Hamano
2007-03-02 10:15           ` Simon Josefsson
2007-03-02 14:09         ` Johannes Schindelin
2007-03-03 14:12           ` Simon Josefsson

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.