Thread (76 messages) 76 messages, 6 authors, 2025-08-23

symmetric difference with --left-only vs. range notation

From: D. Ben Knoble <hidden>
Date: 2025-08-13 18:55:43

On Sun, Aug 10, 2025 at 11:42 AM Phillip Wood [off-list ref] wrote:
Hi Julia

On 09/08/2025 02:14, Julia Evans via GitGitGadget wrote:
quoted
From: Julia Evans <redacted>

+Here is a more detailed description of what `git rebase <upstream>` does:
+
+First, it makes a list of all commits in the current branch that are not in
+`<upstream>`. This is the same set of commits that would be shown by `git log
+<upstream>..HEAD`.
The existing text is not quite accurate here, it should really say `git
log --cherry-pick --right-only <upstream>...HEAD` as we drop any commits
from the branch that have already been cherry-picked to <upstream>.
This reminds me, I've been meaning to ask: is there a meaningful
difference between the following 2 commands?

    git rev-list --count --left-only @{u}...
    git rev-list --count ..@{u}

In my estimation, since we're not using --cherry-pick here, the first
says "list (count) the commits on upstream but not in HEAD, since the
merge-base (which is reachable from both)" while the second says "list
(count) the commits on upstream but not in HEAD." Is there ever a
situation where those sets aren't the same?

Of course the symmetric difference is not always the same as the range
notation, but when we add --left-only [or --right-only, by symmetry
;)], does this collapse to the 2-dot notation?

I've been assuming the latter is more performant, too, but if that's
not the case, that's also good to know.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help