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

Re: [PATCH 2/7] Merge with_raw, with_stat and summary variables to output_format

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jun 24, 2006, 23:20 UTC
Message-ID
<Pine.LNX.4.63.0606250113280.29667@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<20060625005654.627e176b.tihirvon@gmail.com>
Hi,
On Sun, 25 Jun 2006, Timo Hirvonen wrote:
Show 29 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> 
> > On Sat, 24 Jun 2006, Timo Hirvonen wrote:
> > 
> > > @@ -818,17 +817,12 @@ void show_combined_diff(struct combine_d
> > >  	struct diff_options *opt = &rev->diffopt;
> > >  	if (!p->len)
> > >  		return;
> > > -	switch (opt->output_format) {
> > > -	case DIFF_FORMAT_RAW:
> > > -	case DIFF_FORMAT_NAME_STATUS:
> > > -	case DIFF_FORMAT_NAME:
> > > +	if (opt->output_format & (DIFF_FORMAT_RAW |
> > > +				  DIFF_FORMAT_NAME |
> > > +				  DIFF_FORMAT_NAME_STATUS)) {
> > >  		show_raw_diff(p, num_parent, rev);
> > > -		return;
> > > -	case DIFF_FORMAT_PATCH:
> > > +	} else if (opt->output_format & DIFF_FORMAT_PATCH) {
> > 
> > Not that it matters, but this "else" could go. (Otherwise,  "--raw -p" 
> > would be the same as "--raw", right?)
> 
> Just tested, ./git log -p --raw displays both raw and patch.  I think it
> works because I changed diff_tree_combined() to use show_raw_diff() and
> show_patch_diff() directly.
> 
> It feels 'wrong' to check flags and then call a function which checks
> the flags again.  This combined diff stuff is confusing.

Sorry for not checking the result, but just the patch. I also find this behaviour confusing. Junio?

Show 12 quoted lines
> > > +	int inter_name_termination = '\t';
> > > +	int line_termination = options->line_termination;
> > > +
> > > +	if (!line_termination)
> > > +		inter_name_termination = 0;
> > 
> > <nit type=minor>
> > 	This should be part of patch 1/7.
> > </nit>
> 
> That clean up was possible only after I made other changes to the code,
> I think.  At least it wasn't obvious when I wrote 1/7.

It is just a minor nit, I do not think it is necessary to change the patch.

Show 8 quoted lines
> > >  		show_stats(diffstat);
> > >  		free(diffstat);
> > 
> > Why not go the full nine yards, and make diffstat not a pointer, but the 
> > struct itself? You would avoid calloc()ing and free()ing. (Of course, 
> > instead of calloc()ing you have to memset() it to 0.)
> 
> I was blind :)

;-) In my experience, after staring at the code too long, you turn blind. This is why I like a second pair of eyeballs so much.

Show 21 quoted lines
> > > +	if (output_format & DIFF_FORMAT_PATCH) {
> > > +		if (output_format & (DIFF_FORMAT_DIFFSTAT |
> > > +				     DIFF_FORMAT_SUMMARY)) {
> > > +			if (options->stat_sep)
> > > +				fputs(options->stat_sep, stdout);
> > > +			else
> > > +				putchar(options->line_termination);
> > 
> > Are we sure we do not want something like
> > 
> > 	if (output_format / DIFF_FORMAT_DIFFSTAT > 1)
> > 		/* output separator */
> > 
> > after each format (this example being after the diffstat), the condition 
> > being: if there is still an output format to come, add the separator?
> 
> I'm not sure what you mean.
> 
> It outputs separator between (diffstat and/or summary) and patch.
> There's no separator between diffstat and summary or raw and diffstat.
> Should there be one?
IMHO there should be one.
> Thanks for your comments.  Should I patch the patch or send a fixed one?

I cannot speak for Junio, but I think an additional patch to clean things up would be the way to go.

Ciao, Dscho

Previous: Timo HirvonenNext: Timo Hirvonen
Message 6 of 20 in “Rework diff options”
  1. 0/7 Rework diff optionsTimo Hirvonen, Jun 24, 2006
  2. 1/7 Clean up diff.cTimo Hirvonen, Jun 24, 2006
  3. 2/7 Merge with_raw, with_stat and summary variables to output_formatTimo Hirvonen, Jun 24, 2006
  4. Johannes SchindelinJun 24, 2006
  5. Timo HirvonenJun 24, 2006
  6. Johannes SchindelinJun 24, 2006
  7. Add msg_sep to diff_optionsTimo Hirvonen, Jun 25, 2006
  8. Junio C HamanoJun 25, 2006
  9. whatchanged: Default to DIFF_FORMAT_RAWTimo Hirvonen, Jun 25, 2006
  10. Junio C HamanoJun 25, 2006
  11. whatchanged: Default to DIFF_FORMAT_RAWTimo Hirvonen, Jun 25, 2006
  12. Don't xcalloc() struct diffstat_tTimo Hirvonen, Jun 25, 2006
  13. 3/7 Make --raw option available for all diff commandsTimo Hirvonen, Jun 24, 2006
  14. 4/7 Set default diff output format after parsing command lineTimo Hirvonen, Jun 24, 2006
  15. 5/7 DIFF_FORMAT_RAW is not default anymoreTimo Hirvonen, Jun 24, 2006
  16. 6/7 --name-only, --name-status, --check and -s are mutually exclusiveTimo Hirvonen, Jun 24, 2006
  17. 7/7 Remove awkward compatibility wartsTimo Hirvonen, Jun 24, 2006
  18. Junio C HamanoJun 25, 2006
  19. Timo HirvonenJun 25, 2006
  20. Junio C HamanoJun 26, 2006

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.