git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andry <andry@inbox.ru>
To: Git <git@vger.kernel.org>
Subject: [FEATURE REQUEST] New method of commits range selection
Date: Mon, 25 Dec 2023 05:08:45 +0400	[thread overview]
Message-ID: <31177532.20231225050845@inbox.ru> (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.


                 reply	other threads:[~2023-12-25  2:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31177532.20231225050845@inbox.ru \
    --to=andry@inbox.ru \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).