Skip to contentSkip to conversation

New method of commits range selection

FEATURE REQUEST Andry 1 participant 1 message Dec 25, 2023

lore
Share & tools
lore

Andry

author
#0 lore raw

Hello Git,

I've described the details in the GitHub discussion: https://github.com/orgs/community/discussions/56342#discussioncomment-7882789

But because the problem is related to the Git commands like git log: https://git-scm.com/docs/git-log

Then I think it have to requested from the Git developers.

---

Even more reliable variant is to reverse the second end point search direction in the commit range.

Instead of search from the top to the bottom of a tree beginning a branch tip, there is another way to search from the bottom to the top beginning a commit or a tag. This is better because there is no need to exclude anything else, because the search path is an intersection of both search directions in any potential tree if both ends exists.

Examples:

Search from the top to the bottom:

range: d3^...dev, where ...dev - includes and searches back, d3^... - excludes first parent and searches back

```
Example #1               Example #2

m1 -o- master            m1 -o- master
    |                        |
    |   o- d1 dev            |   o- d1 dev
m2 -o   |                m2 -o   |
    |\  |  o- tags/t1        |\  |  o- tags/t1
    | \ | /                  | \ | /
m3 -o  \|/               m3 -o  \|/
    |   o- d2                |   o- d2
    |  /|                    |  /|
    | / |                    | / |
    |/  |                    |/  |
m4 -o   |                m4 -o   |
    |   o- d3                |\  |
    |  /                     | \ |
    | /                      |  \|
    |/                       |   o- d3
m5 -o                        |  /
                             | /
                             |/
                         m5 -o
```

Selection result:

Example #1: d1, d2, m4, d3
https://github.com/andry81-tests/commits-range-selection-test-1/compare/d3^...dev

Example #2: d1, d2, m4, d3
https://github.com/andry81-tests/commits-range-selection-test-2/compare/d3^...dev

To exclude the master commits, there is need to add more exclusions: {d3^,m4}..dev

This will give invalid selection for the second example, because d3 would be excluded from m4, because we need to include *at least* all dev commits.

Instead of add more exclusion, we can just reverse the second end point search direction: --intersect d3..dev, where ..dev - includes and searches back, d3.. - includes and searches forward.

Selection result:

Example #1: d1, d2, d3
Example #2: d1, d2, m4, d3

This does not require to actually search from the d3 up, because only requires to collect all merge commits down from the dev which might has path to the d3.

It does not exclude all the master branch commits, but gives a cleaner result without additional excludes.