Re: [PATCH] pretty.c: Don't expand %N without --show-notes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Gilger <heipei@xxxxxxxxxxxx> writes:

> The %N placeholder will only work if --show-notes was provided to log.
> By not expanding the user is given feedback that he won't be shown any
> notes.

I kind of like the simplicity of this approach, but this probably cuts
both ways.  I can hear some users screaming "But but but I already told
you that I am interested in notes---how else would I say %N in the format
string?" while others say "Yeah, that way I can keep using the same format
and when I don't give --show-notes it won't show extra information in the
output.  Very nice".

> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
> index 1686a54..bf7813f 100644
> --- a/Documentation/pretty-formats.txt
> +++ b/Documentation/pretty-formats.txt
> @@ -143,7 +143,8 @@ NOTE: Some placeholders may depend on other options given to the
>  revision traversal engine. For example, the `%g*` reflog options will
>  insert an empty string unless we are traversing reflog entries (e.g., by
>  `git log -g`). The `%d` placeholder will use the "short" decoration
> -format if `--decorate` was not already provided on the command line.
> +format if `--decorate` was not already provided on the command line. The %N
> +placeholder won't be expanded unless `--show-notes` was provided.
>  
>  If you add a `{plus}` (plus sign) after '%' of a placeholder, a line-feed
>  is inserted immediately before the expansion if and only if the
> diff --git a/pretty.c b/pretty.c
> index 6ba3da8..b39e2d5 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -775,6 +775,9 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
>  		}
>  		return 0;	/* unknown %g placeholder */
>  	case 'N':
> +		if (!c->pretty_ctx->show_notes)
> +			return 0;
> +
>  		format_display_notes(commit->object.sha1, sb,
>  			    git_log_output_encoding ? git_log_output_encoding
>  						    : git_commit_encoding, 0);
> -- 
> 1.7.0.2.201.g80978
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]