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

Re: [PATCH 2/5] Rework diff options

From
THTimo Hirvonen <tihirvon@gmail.com>
Date
Jun 24, 2006, 11:29 UTC
Message-ID
<20060624142943.2aeda5d2.tihirvon@gmail.com>
In-Reply-To
<7vodwj11qa.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 20 quoted lines
> > diff --git a/builtin-log.c b/builtin-log.c
> > index 5a8a50b..e4a6385 100644
> > --- a/builtin-log.c
> > +++ b/builtin-log.c
> > @@ -26,8 +26,8 @@ static int cmd_log_wc(int argc, const ch
> >  	if (rev->always_show_header) {
> >  		if (rev->diffopt.pickaxe || rev->diffopt.filter) {
> >  			rev->always_show_header = 0;
> > -			if (rev->diffopt.output_format == DIFF_FORMAT_RAW)
> > -				rev->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT;
> > +			if (rev->diffopt.output_fmt & OUTPUT_FMT_RAW)
> > +				rev->diffopt.output_fmt |= OUTPUT_FMT_NONE;
> >  		}
> >  	}
> 
> The original code is saying "For git-log command (i.e. when
> always-show-header is on), if the command line did not override
> but ended up asking for diff only because it wanted to do -S or
> --diff-filter, do not show any diff" which is quite an opaque
> logic.

I'll just remove this change from the fixed patch 2/5. New version of the patch 3/5 should then fix this logic.

Show 17 quoted lines
> > @@ -1371,23 +1371,26 @@ int diff_setup_done(struct diff_options 
> >  	    (0 <= options->rename_limit && !options->detect_rename))
> >  		return -1;
> >  
> > +	if (options->output_fmt & OUTPUT_FMT_NONE)
> > +		options->output_fmt = 0;
> > +
> > +	if (options->output_fmt & (OUTPUT_FMT_NAME |
> > +				   OUTPUT_FMT_CHECKDIFF |
> > +				   OUTPUT_FMT_NONE))
> > +		options->output_fmt &= ~(OUTPUT_FMT_RAW |
> > +					 OUTPUT_FMT_DIFFSTAT |
> > +					 OUTPUT_FMT_SUMMARY |
> > +					 OUTPUT_FMT_PATCH);
> > +
> 
> Maybe doing the same for --name-status?

Will fix. Originally I made --name-status imply --name-only but changed it and forgot to fix this.

> I wonder if the --name,
> --name-status and --check should be mutually exclusive.  What
> happens when you specify more than one of them?

I'll just make it die() then. If it breaks something then the code is really dumb anyway.

Show 19 quoted lines
> > diff --git a/revision.c b/revision.c
> > index b963f2a..4ad2272 100644
> > --- a/revision.c
> > +++ b/revision.c
> > @@ -852,8 +852,8 @@ int setup_revisions(int argc, const char
> >  	if (revs->combine_merges) {
> >  		revs->ignore_merges = 0;
> >  		if (revs->dense_combined_merges &&
> > -		    (revs->diffopt.output_format != DIFF_FORMAT_DIFFSTAT))
> > -			revs->diffopt.output_format = DIFF_FORMAT_PATCH;
> > +		   !(revs->diffopt.output_fmt & OUTPUT_FMT_DIFFSTAT))
> > +			revs->diffopt.output_fmt |= OUTPUT_FMT_PATCH;
> >  	}
> >  	revs->diffopt.abbrev = revs->abbrev;
> >  	diff_setup_done(&revs->diffopt);
> 
> This tells it to default to patch format unless we are asked to
> do diffstat only, in which case we just show stat without patch.
> The new logic seems to be fishy.

If we first initialize it to 0 instead of DIFF_FORMAT_RAW and after command line flags have been parsed, if it still is 0, then default to DIFF_FORMAT_PATCH.

Show 11 quoted lines
>  - could I ask you to redo a patch to do only the clean-up part
>    first, so that I can accept it for either "next" or "master".
> 
>  - Then after I take the clean-up, could you rebase four
>    remainder patches ("Rework diff options" to "Add --patch
>    option for diff-*") on the result?  The patches this round
>    are already split quite well in that the first one does the
>    enum to bit conversion and the latter three cleans things up
>    (all of which I like a lot).  As Johannes suggested, it might
>    be easier to review if they reused the same preprocessor
>    symbols instead of renaming them.  I'd take them for "next".
Yes, all this makes sense.
-- 
http://onion.dynserv.net/~timo/
Previous: Junio C HamanoNext: Timo Hirvonen
Message 5 of 8 in “git-merge: Don't use -p when outputting summary”
  1. 1/5 git-merge: Don't use -p when outputting summaryTimo Hirvonen, Jun 23, 2006
  2. 2/5 Rework diff optionsTimo Hirvonen, Jun 23, 2006
  3. Timo HirvonenJun 23, 2006
  4. Junio C HamanoJun 24, 2006
  5. Timo HirvonenJun 24, 2006
  6. 3/5 Set default diff output format after parsing command lineTimo Hirvonen, Jun 23, 2006
  7. 4/5 Make --raw option available for all diff commandsTimo Hirvonen, Jun 23, 2006
  8. 5/5 Add --patch option for diff-*Timo Hirvonen, Jun 23, 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.