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

Re: [PATCH/RFC] rev-list: fix --pretty=oneline with empty message

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 21, 2010, 02:54 UTC
Message-ID
<7vk4t64c5t.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1269109201-5768-1-git-send-email-kusmabite@gmail.com>
Erik Faye-Lund <kusmabite@googlemail.com> writes:
> This is a fix for the issue I posted about with rebase -i:
> http://permalink.gmane.org/gmane.comp.version-control.git/141782
Thanks.
Show 13 quoted lines
> diff --git a/builtin/rev-list.c b/builtin/rev-list.c
> index 5679170..133056b 100644
> --- a/builtin/rev-list.c
> +++ b/builtin/rev-list.c
> @@ -135,7 +135,8 @@ static void show_commit(struct commit *commit, void *data)
>  					putchar('\n');
>  			}
>  		} else {
> -			if (buf.len)
> +			if (revs->commit_format != CMIT_FMT_USERFORMAT ||
> +			    buf.len)
>  				printf("%s%c", buf.buf, info->hdr_termination);
>  		}

When the format is not user-specified one (e.g. "-v"), then a commit with no message will only show the regular header, without any body.

I wonder if we need something similar in the "graph" case, most of which is outside the context before this hunk. With your patch, this still seems to misbehave:

    $ git rev-list --graph --oneline --abbrev=4 HEAD
    * 8cb0 * efea 4th commit
    * 341e 3rd commit
    * 2321 2nd commit
    * 3814 1st commit
Although anything other than --oneline seems to do just fine.

Perhaps this one on top, with an appropriate test, and we can lose the RFC from the title?

 builtin-rev-list.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 133056b..1db4b4c 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -133,6 +133,8 @@ static void show_commit(struct commit *commit, void *data)
 				 */
 				if (graph_show_remainder(revs->graph))
 					putchar('\n');
+				if (revs->commit_format == CMIT_FMT_ONELINE)
+					putchar('\n');
 			}
 		} else {
 			if (revs->commit_format != CMIT_FMT_USERFORMAT ||
Previous: Erik Faye-Lund
Message 2 of 2 in “rev-list: fix --pretty=oneline with empty message”
  1. rev-list: fix --pretty=oneline with empty messageErik Faye-Lund, Mar 20, 2010
  2. Junio C HamanoMar 21, 2010

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.