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