git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Tweak git-diff-tree -v output further.
@ 2005-05-06 19:27 Junio C Hamano
  2005-05-06 21:54 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Junio C Hamano @ 2005-05-06 19:27 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

The first hunk of this is a pure bugfix---it guards us against a
commit message that does not end with a newline.

This adds the full header information to git-diff-tree -v output
in addition to the log message it already produces.

Maybe we want to stop indenting so that it matches what
git-export produces better.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

diff-tree.c |   30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)

# - linus-mirror: diff-tree: add "verbose header" mode
# + (working tree)
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -278,7 +278,7 @@ static int get_one_line(const char *msg,
 
 	while (len--) {
 		ret++;
-		if (*msg++ == '\n')
+		if (!*msg || *msg++ == '\n')
 			break;
 	}
 	return ret;
@@ -287,12 +287,14 @@ static int get_one_line(const char *msg,
 static char *generate_header(const char *commit, const char *parent, const char *msg, unsigned long len)
 {
 	static char this_header[1000];
-	int offset;
 
-	offset = sprintf(this_header, "%s%s (from %s)\n", header_prefix, commit, parent);
-	if (verbose_header) {
+	if (!verbose_header)
+		sprintf(this_header, "%s%s (from %s)\n", header_prefix,
+			commit, parent);
+	else {
+		int offset;
 		int hdr = 1;
-
+		offset = sprintf(this_header, "Id: %s\n", commit);
 		for (;;) {
 			const char *line = msg;
 			int linelen = get_one_line(msg, len);
@@ -306,11 +308,19 @@ static char *generate_header(const char 
 			len -= linelen;
 			if (linelen == 1)
 				hdr = 0;
-			if (hdr)
-				continue;
-			memset(this_header + offset, ' ', 4);
-			memcpy(this_header + offset + 4, line, linelen);
-			offset += linelen + 4;
+			if (hdr) {
+				memcpy(this_header + offset, line, linelen);
+				if (!strncmp(line, "parent ", 7) &&
+				    !strncmp(line+7, parent, 40))
+					this_header[offset + 6] = '*';
+				offset += linelen;
+					
+			}
+			else {
+				memset(this_header + offset, ' ', 4);
+				memcpy(this_header + offset + 4, line, linelen);
+				offset += linelen + 4;
+			}
 		}
 		this_header[offset++] = '\n';
 		this_header[offset] = 0;


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

* Re: [PATCH] Tweak git-diff-tree -v output further.
  2005-05-06 19:27 [PATCH] Tweak git-diff-tree -v output further Junio C Hamano
@ 2005-05-06 21:54 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2005-05-06 21:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git



On Fri, 6 May 2005, Junio C Hamano wrote:
> 
> This adds the full header information to git-diff-tree -v output
> in addition to the log message it already produces.

I don't actually like the git internal commit format, it's not very 
readable. It's designed to be nicely readable by machines, not humans.

If you want machine-readable output, you shouldn't use "-v" (or probably
-p either) anyway, you'd be better off with the raw file changes.

> Maybe we want to stop indenting so that it matches what
> git-export produces better.

Again, it's indented so that it's human-readable, and I was planning on
adding _some_ human-readable output from the headers (author and a
human-readable date or something).

		Linus

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

end of thread, other threads:[~2005-05-06 21:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-06 19:27 [PATCH] Tweak git-diff-tree -v output further Junio C Hamano
2005-05-06 21:54 ` Linus Torvalds

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).