Message ID | 041456b6e73b3a88097d0cc06056eb43d35d42c6.1611267638.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Range diff with ranges lacking dotdot | expand |
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > There are three forms, depending whether the user specifies one, two or > three non-option arguments. We've never actually explained how this > works in the manual, so let's explain it. > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > --- > Documentation/git-range-diff.txt | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt > index 9701c1e5fdd..76359baf26d 100644 > --- a/Documentation/git-range-diff.txt > +++ b/Documentation/git-range-diff.txt > @@ -28,6 +28,19 @@ Finally, the list of matching commits is shown in the order of the > second commit range, with unmatched commits being inserted just after > all of their ancestors have been shown. > > +There are three ways to specify the commit ranges: > + > +- `<range1> <range2>`: Either commit range can be of the form > + `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See `SPECIFYING RANGES` > + in linkgit:gitrevisions[7] for more details. Good. > +- `<rev1>...<rev2>`. This resembles the symmetric ranges mentioned in > + the `SPECIFYING RANGES` section of linkgit:gitrevisions[7], and is > + equivalent to `<base>..<rev1> <base>..<rev2>` where `<base>` is the > + merge base as obtained via `git merge-base <rev1> <rev2>`. Does this merely resemble? Isn't it exactly what a symmetric range is? > +- `<base> <rev1> <rev2>`: This is equivalent to `<base>..<rev1> > + <base>..<rev2>`. Nice to see this documented. Thanks.
Hi Junio, On Thu, 21 Jan 2021, Junio C Hamano wrote: > "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> > writes: > > > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > > > There are three forms, depending whether the user specifies one, two or > > three non-option arguments. We've never actually explained how this > > works in the manual, so let's explain it. > > > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > > --- > > Documentation/git-range-diff.txt | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > > > diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt > > index 9701c1e5fdd..76359baf26d 100644 > > --- a/Documentation/git-range-diff.txt > > +++ b/Documentation/git-range-diff.txt > > @@ -28,6 +28,19 @@ Finally, the list of matching commits is shown in the order of the > > second commit range, with unmatched commits being inserted just after > > all of their ancestors have been shown. > > > > +There are three ways to specify the commit ranges: > > + > > +- `<range1> <range2>`: Either commit range can be of the form > > + `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See `SPECIFYING RANGES` > > + in linkgit:gitrevisions[7] for more details. > > Good. > > > +- `<rev1>...<rev2>`. This resembles the symmetric ranges mentioned in > > + the `SPECIFYING RANGES` section of linkgit:gitrevisions[7], and is > > + equivalent to `<base>..<rev1> <base>..<rev2>` where `<base>` is the > > + merge base as obtained via `git merge-base <rev1> <rev2>`. > > Does this merely resemble? Isn't it exactly what a symmetric range is? No, it is not exactly what a symmetric range is because `range-diff` treats both arms of the symmetric range independently, as two distinct non-symmetric ranges. > > +- `<base> <rev1> <rev2>`: This is equivalent to `<base>..<rev1> > > + <base>..<rev2>`. > > Nice to see this documented. Yes. I was rather surprised that I had overlooked that in my original submission of the `range-diff` command. Ciao, Dscho
On Thu, Jan 21, 2021 at 10:20:38PM +0000, Johannes Schindelin via GitGitGadget wrote: > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > There are three forms, depending whether the user specifies one, two or > three non-option arguments. We've never actually explained how this > works in the manual, so let's explain it. > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > --- > Documentation/git-range-diff.txt | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt > index 9701c1e5fdd..76359baf26d 100644 > --- a/Documentation/git-range-diff.txt > +++ b/Documentation/git-range-diff.txt > @@ -28,6 +28,19 @@ Finally, the list of matching commits is shown in the order of the > second commit range, with unmatched commits being inserted just after > all of their ancestors have been shown. > > +There are three ways to specify the commit ranges: > + > +- `<range1> <range2>`: Either commit range can be of the form > + `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See `SPECIFYING RANGES` > + in linkgit:gitrevisions[7] for more details. > + > +- `<rev1>...<rev2>`. This resembles the symmetric ranges mentioned in > + the `SPECIFYING RANGES` section of linkgit:gitrevisions[7], and is > + equivalent to `<base>..<rev1> <base>..<rev2>` where `<base>` is the > + merge base as obtained via `git merge-base <rev1> <rev2>`. > + > +- `<base> <rev1> <rev2>`: This is equivalent to `<base>..<rev1> > + <base>..<rev2>`. git-log takes a range, too. There you can specify a single rev (with the semantic to list all commits from this rev up (or down?) to the root). So <rev> means implicitly <rev>^∞..<rev> for git-log. Does it make sense to implement this here, too? Maybe this even allows sharing some more code? Best regards Uwe
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: >> > +- `<rev1>...<rev2>`. This resembles the symmetric ranges mentioned in >> > + the `SPECIFYING RANGES` section of linkgit:gitrevisions[7], and is >> > + equivalent to `<base>..<rev1> <base>..<rev2>` where `<base>` is the >> > + merge base as obtained via `git merge-base <rev1> <rev2>`. The above paragraph says A...B is turned into $(git merge-base A B)..A and $(git merge-base A B)..B, but I wonder if we should be rewriting it into A..B and B..A instead; that would make it unnecessary to explain what should happen when there are more than one merge bases. >> Does this merely resemble? Isn't it exactly what a symmetric range is? > > No, it is not exactly what a symmetric range is because `range-diff` > treats both arms of the symmetric range independently, as two distinct > non-symmetric ranges. This however is an end-user documentation, isn't it? The fact that range-diff internally translates A...B into something else is an implementation detail of achieving something, and from the end-users' point of view, isn't it "take A...B from the end-user, and show the difference between the left and right branches of the symmetric range" that range-diff achieves to do? So it processes exactly the same two sets of commits as what is given by "--left-right A...B", no?
Hi Uwe, On Fri, 22 Jan 2021, Uwe Kleine-König wrote: > On Thu, Jan 21, 2021 at 10:20:38PM +0000, Johannes Schindelin via GitGitGadget wrote: > > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > > > There are three forms, depending whether the user specifies one, two or > > three non-option arguments. We've never actually explained how this > > works in the manual, so let's explain it. > > > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > > --- > > Documentation/git-range-diff.txt | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > > > diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt > > index 9701c1e5fdd..76359baf26d 100644 > > --- a/Documentation/git-range-diff.txt > > +++ b/Documentation/git-range-diff.txt > > @@ -28,6 +28,19 @@ Finally, the list of matching commits is shown in the order of the > > second commit range, with unmatched commits being inserted just after > > all of their ancestors have been shown. > > > > +There are three ways to specify the commit ranges: > > + > > +- `<range1> <range2>`: Either commit range can be of the form > > + `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See `SPECIFYING RANGES` > > + in linkgit:gitrevisions[7] for more details. > > + > > +- `<rev1>...<rev2>`. This resembles the symmetric ranges mentioned in > > + the `SPECIFYING RANGES` section of linkgit:gitrevisions[7], and is > > + equivalent to `<base>..<rev1> <base>..<rev2>` where `<base>` is the > > + merge base as obtained via `git merge-base <rev1> <rev2>`. > > + > > +- `<base> <rev1> <rev2>`: This is equivalent to `<base>..<rev1> > > + <base>..<rev2>`. > > git-log takes a range, too. There you can specify a single rev (with the > semantic to list all commits from this rev up (or down?) to the root). > So <rev> means implicitly <rev>^∞..<rev> for git-log. > > Does it make sense to implement this here, too? Maybe this even allows > sharing some more code? I don't think that it makes sense to support open-ended ranges. `git range-diff` is expensive, its runtime is proportional to the number of patches in the first range times the number of patches in the second range. Allowing open-ended ranges will simply allow users to be stuck with a long runtime by mistake, and I do not see any valid use case in return for that risk. Ciao, Johannes
Hi Junio, On Fri, 22 Jan 2021, Junio C Hamano wrote: > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > > >> > +- `<rev1>...<rev2>`. This resembles the symmetric ranges mentioned in > >> > + the `SPECIFYING RANGES` section of linkgit:gitrevisions[7], and is > >> > + equivalent to `<base>..<rev1> <base>..<rev2>` where `<base>` is the > >> > + merge base as obtained via `git merge-base <rev1> <rev2>`. > > The above paragraph says A...B is turned into $(git merge-base A > B)..A and $(git merge-base A B)..B, but I wonder if we should be > rewriting it into A..B and B..A instead; that would make it > unnecessary to explain what should happen when there are more than > one merge bases. You know what? I lied. The code already does what you suggested. Look [here](https://github.com/git/git/blob/v2.30.0/builtin/range-diff.c#L59-L77): [...] } else if (argc == 1) { const char *b = strstr(argv[0], "..."), *a = argv[0]; int a_len; if (!b) { error(_("single arg format must be symmetric range")); usage_with_options(builtin_range_diff_usage, options); } a_len = (int)(b - a); if (!a_len) { a = "HEAD"; a_len = strlen(a); } b += 3; if (!*b) b = "HEAD"; strbuf_addf(&range1, "%s..%.*s", b, a_len, a); strbuf_addf(&range2, "%.*s..%s", a_len, a, b); [...] > >> Does this merely resemble? Isn't it exactly what a symmetric range is? > > > > No, it is not exactly what a symmetric range is because `range-diff` > > treats both arms of the symmetric range independently, as two distinct > > non-symmetric ranges. > > This however is an end-user documentation, isn't it? Yes, and the end user is talking about _two_ commit ranges in the context of `git range-diff`, and about _one_ commit range in the context of `git log`. So I still think that it really just only resembles the symmetric range. It is fundamentally as different from it as the number 2 is different from the number 1. Ciao, Dscho
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: >> The above paragraph says A...B is turned into $(git merge-base A >> B)..A and $(git merge-base A B)..B, but I wonder if we should be >> rewriting it into A..B and B..A instead; that would make it >> unnecessary to explain what should happen when there are more than >> one merge bases. > > You know what? I lied. I knew. So we need an update to the patch. >> >> Does this merely resemble? Isn't it exactly what a symmetric range is? >> > >> > No, it is not exactly what a symmetric range is because `range-diff` >> > treats both arms of the symmetric range independently, as two distinct >> > non-symmetric ranges. >> >> This however is an end-user documentation, isn't it? > > Yes, and the end user is talking about _two_ commit ranges in the context > of `git range-diff`, and about _one_ commit range in the context of `git > log`. You are forgetting that "log A...B" shows only one half of what a symmetric range means, and hides which side each commit belongs to. "git log --left-right A...B" shows what a symmetric range really is; there are two sides, left and right, and "git range-diff A...B" is a natural way to compare these two ranges. I've been quite happy with the way how "git range-diff @{-1}..." shows the comparison of two sides of the symmetric range, given by "git log --oneline --left-right @{-1}..."
diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt index 9701c1e5fdd..76359baf26d 100644 --- a/Documentation/git-range-diff.txt +++ b/Documentation/git-range-diff.txt @@ -28,6 +28,19 @@ Finally, the list of matching commits is shown in the order of the second commit range, with unmatched commits being inserted just after all of their ancestors have been shown. +There are three ways to specify the commit ranges: + +- `<range1> <range2>`: Either commit range can be of the form + `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See `SPECIFYING RANGES` + in linkgit:gitrevisions[7] for more details. + +- `<rev1>...<rev2>`. This resembles the symmetric ranges mentioned in + the `SPECIFYING RANGES` section of linkgit:gitrevisions[7], and is + equivalent to `<base>..<rev1> <base>..<rev2>` where `<base>` is the + merge base as obtained via `git merge-base <rev1> <rev2>`. + +- `<base> <rev1> <rev2>`: This is equivalent to `<base>..<rev1> + <base>..<rev2>`. OPTIONS -------