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

[FEATURE REQUEST] New method of commits range selection

From
AAndry <andry@inbox.ru>
Date
Dec 25, 2023, 01:08 UTC
Message-ID
<31177532.20231225050845@inbox.ru>
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.
Message 1 of 1 in “[FEATURE REQUEST] New method of commits range selection”
  1. AndryDec 25, 2023

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.