git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] log and rev-list: add --graph option

From
Junio C Hamano <gitster@pobox.com>
Date
May 6, 2008, 06:41 UTC
Message-ID
<7vtzhcgci1.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1209897414-10091-4-git-send-email-adam@adamsimpkins.net>
Adam Simpkins <adam@adamsimpkins.net> writes:
Show 32 quoted lines
> diff --git a/builtin-rev-list.c b/builtin-rev-list.c
> index 476a870..f868290 100644
> --- a/builtin-rev-list.c
> +++ b/builtin-rev-list.c
> ...
> @@ -52,12 +53,13 @@ static struct rev_info revs;
>  
>  static int bisect_list;
>  static int show_timestamp;
> -static int hdr_termination;
>  static const char *header_prefix;
>  
>  static void finish_commit(struct commit *commit);
>  static void show_commit(struct commit *commit)
>  {
> +	graph_show_commit(revs.graph);
> +
>  	if (show_timestamp)
>  		printf("%lu ", commit->date);
>  	if (header_prefix)
> @@ -96,9 +98,50 @@ static void show_commit(struct commit *commit)
>  		pretty_print_commit(revs.commit_format, commit,
>  				    &buf, revs.abbrev, NULL, NULL,
>  				    revs.date_mode, 0);
> -		if (buf.len)
> -			printf("%s%c", buf.buf, hdr_termination);
> +		if (revs.graph) {
> ...
> +		} else {
> +			if (buf.len) {
> +				fwrite(buf.buf, sizeof(char), buf.len, stdout);
> +				putchar('\n');
Now hdr_termination can never be NUL, iow you broke "rev-list -v -z"?

I'll squash in a minimum fix, because otherwise this breaks existing tests.

--
 builtin-rev-list.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index f868290..54d55cc 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -53,6 +53,7 @@ static struct rev_info revs;
 
 static int bisect_list;
 static int show_timestamp;
+static int hdr_termination;
 static const char *header_prefix;
 
 static void finish_commit(struct commit *commit);
@@ -133,10 +134,8 @@ static void show_commit(struct commit *commit)
 					putchar('\n');
 			}
 		} else {
-			if (buf.len) {
-				fwrite(buf.buf, sizeof(char), buf.len, stdout);
-				putchar('\n');
-			}
+			if (buf.len)
+				printf("%s%c", buf.buf, hdr_termination);
 		}
 		strbuf_release(&buf);
 	} else {
@@ -635,6 +634,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 	}
 	if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
 		/* The command line has a --pretty  */
+		hdr_termination = '\n';
 		if (revs.commit_format == CMIT_FMT_ONELINE)
 			header_prefix = "";
 		else
Previous: Ping YinNext: Adam Simpkins
Message 7 of 13 in “log --graph and rev-list --graph”
  1. 0/3 log --graph and rev-list --graphAdam Simpkins, May 4, 2008
  2. 1/3 revision API: split parent rewriting and parent printing optionsAdam Simpkins, May 4, 2008
  3. 2/3 Add history graph APIAdam Simpkins, May 4, 2008
  4. 3/3 log and rev-list: add --graph optionAdam Simpkins, May 4, 2008
  5. graph API: eliminate unnecessary indentationAdam Simpkins, May 5, 2008
  6. Ping YinMay 5, 2008
  7. Junio C HamanoMay 6, 2008
  8. Adam SimpkinsMay 6, 2008
  9. Junio C HamanoMay 6, 2008
  10. bash: Add more option completions for 'git log'Teemu Likonen, May 4, 2008
  11. Ping YinMay 5, 2008
  12. Adam SimpkinsMay 5, 2008
  13. Teemu LikonenMay 6, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.