Re: [PATCH v2 02/18] Add a new builtin: branch-diff
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- May 7, 2018, 01:34 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1805062124470.77@tvgsbejvaqbjf.bet>
- In-Reply-To
- <e0db15c5-e897-5b03-20ff-d83f38496e61@gmail.com>
Hi Buga,
On Sun, 6 May 2018, Igor Djordjevic wrote:
Show 12 quoted lines
> On 06/05/2018 14:10, Johannes Schindelin wrote: > > > I think Todd's idea to shift it from a full-blown builtin to a cmdmode > > of `branch` makes tons of sense. > > I don`t know, I still find it a bit strange that in order to "diff > something", you go to "something" and tell it to "diff itself" - not > because it`s a weird concept (OOP, anyone? :]), but because we already > have "diff" command that can accept different things, thus just teaching > it to accept additional "something" (branch, in this case), seems more > natural (to me) - "branch diff" being just another "diff" mode of > operation.
You also have to call `git branch` to list branches. And to rename branches. And to delete them. So why not also compare them at the same time?
> What about that side thought you left out from my original message, > making it `git diff --branch` instead?
I really did not like this, as all of the `git diff` options really are about comparing two revisions, not two *sets* of revisions.
Further, if I put my unsuspecting user hat on, I would ask myself how you can compare branches with one another? That is what I would expect `git diff --branch` to do, not to compare two versions of *the same* branch.
So `git diff --branch` does not at all convey the same to me as `git branch --diff`, and I find that the latter does match better what this patch series tries to achieve.
I briefly considered `git branch --compare` instead, but then rejected it: it would again sound more like I try to compare two separate (and likely unrelated) branches with one another, and that simply does not make much sense, and tbdiff would not help with that, anyway.
Show 6 quoted lines
> But if "branch diff" is considered to be too special-cased mode of > "diff" so that supporting it from `diff` itself would make it feel > awkward in both usage and maintenance (in terms of many other regular > `diff` specific options being unsupported), I guess I would understand > having it outside `diff` altogether (and implemented as proposed `git > branch --diff`, or something)... for the time being, at least :)
The branch diff is not even a special-cased mode of diff. It is *way* more complicated than that. It tries to find 1:1 correspondences between *sets* of commits, and then only outputs a "sort" of a diff between the commits that correspond with each other. I say "sort" of a diff because that diff does not look like `git diff <commit1> <commit2>` at all!
So I think it would just be confusing to add that mode to `git diff`.
Ciao, Dscho