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

Re: [PATCH 3/3] diffstat generation in hooks--update was passing "^baserev" to git-diff-tree

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 13, 2007, 17:03 UTC
Message-ID
<Pine.LNX.4.64.0702130856580.8424@woody.linux-foundation.org>
In-Reply-To
<200702131424.21665.andyparkins@gmail.com>
On Tue, 13 Feb 2007, Andy Parkins wrote:
Show 5 quoted lines
>
> -			echo "Diffstat:"
> -			git-diff-tree --no-color --stat -M -C --find-copies-harder $newrev ^$baserev
> +			echo "Diffstat against $baserev:"
> +			git-diff-tree --no-color --stat -M -C --find-copies-harder $newrev $baserev
This is wrong.
	newrev ^baserev

is right. The "not baserev" tells diff-tree that the baserev is the starting point, so newrev is obviously the target, and thus that will generate a diff from baserev to newrev.

So will either of
	baserev..newrev
	baserev newrev

which mean _exactly_ the same thing as "newrev ^basrev" to "diff-tree", because in all cases it's obviously "baserev" that is the old one to diff against.

But
	newrev baserev

means the diff from "new" to "base", which is exactly the wrong way around.

Of course, since we did
	baserev=$(git-merge-base $oldrev $newrev)
to generate base-rev, we could actually have done
	$oldrev...$newrev

(note the _three_ dots) which means "diff from merge-base to newrev". But since we use "baserev" multiple times, what the update hook does right now is actually better - it avoids the cost of re-computing the merge base that we needed for other things anyway.

		Linus
Previous: Johannes SixtNext: Andy Parkins
Message 5 of 6 in “diffstat generation in hooks--update was passing "^baserev" to git-diff-tree”
  1. 3/3 diffstat generation in hooks--update was passing "^baserev" to git-diff-treeAndy Parkins, Feb 13, 2007
  2. Johannes SixtFeb 13, 2007
  3. Andy ParkinsFeb 13, 2007
  4. Johannes SixtFeb 13, 2007
  5. Linus TorvaldsFeb 13, 2007
  6. Andy ParkinsFeb 13, 2007

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.