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

Re: combined diff, but not condensed, howto?

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Sep 18, 2008, 07:30 UTC
Message-ID
<48D203B3.90807@viscovery.net>
In-Reply-To
<7vskryym24.fsf@gitster.siamese.dyndns.org>
Junio C Hamano schrieb:
Show 9 quoted lines
> It is very much Ok and useful for "git diff" to default to "--cc -p", and
> it may be fine for "git diff-files -p" to default to "--cc".
> 
> But I think ideally an explicit "git diff -c" and "git diff-files -c -p"
> should not turn the "dense combined" mode on.
> 
> The commonality of these two functions is striking and calls for proper
> refactoring, but aside from that, I think a patch like this should be
> applied.  What do you think?

This makes a lot of sense. As I mention in my initial post, I was wondering why 'diff -c' was the same as 'diff --cc'.

Show 17 quoted lines
> diff --git i/builtin-diff-files.c w/builtin-diff-files.c
> index 9bf10bb..2b578c7 100644
> --- i/builtin-diff-files.c
> +++ w/builtin-diff-files.c
> @@ -50,7 +50,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
>  	    3 < rev.max_count)
>  		usage(diff_files_usage);
>  
> -	if (rev.max_count == -1 &&
> +	/*
> +	 * "diff-files --base -p" should not combine merges because it
> +	 * was not asked to.  "diff-files -c -p" should not densify
> +	 * (the user should ask with "diff-files --cc" explicitly).
> +	 */
> +	if (rev.max_count == -1 && !rev.combine_merges &&
>  	    (rev.diffopt.output_format & DIFF_FORMAT_PATCH))
>  		rev.combine_merges = rev.dense_combined_merges = 1;

Hm... In my tests, a bare 'git diff-files --cc' produces a combined diff, but 'git diff-files -c' does not.

Show 13 quoted lines
> diff --git i/builtin-diff.c w/builtin-diff.c
> index 037c303..9fb30c6 100644
> --- i/builtin-diff.c
> +++ w/builtin-diff.c
> @@ -223,7 +223,12 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
>  		argv++; argc--;
>  	}
>  
> -	if (revs->max_count == -1 &&
> +	/*
> +	 * "diff --base" should not combine merges because it was not
> +	 * asked to.  "diff -c" should not densify (the user should ask
> +	 * with "diff --cc" explicitly.

I don't see why you add "the user should ask with 'diff --cc'" when this becomes the default anyway.

> +	 */
> +	if (revs->max_count == -1 && !revs->combine_merges &&
>  	    (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
>  		revs->combine_merges = revs->dense_combined_merges = 1;
-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 9 in “combined diff, but not condensed, howto?”
  1. Johannes SixtSep 17, 2008
  2. Junio C HamanoSep 17, 2008
  3. Johannes SixtSep 18, 2008
  4. Junio C HamanoSep 18, 2008
  5. Johannes SixtSep 18, 2008
  6. Junio C HamanoSep 18, 2008
  7. Johannes SixtSep 18, 2008
  8. diff/diff-files: do not use --cc too aggressivelyJunio C Hamano, Sep 18, 2008
  9. Johannes SixtSep 18, 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.