Re: [PATCH v6 0/5] branch: prune-merged
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 11, 2026, 23:20 UTC
- Message-ID
- <xmqqse7xr0t7.fsf@gitster.g>
- In-Reply-To
- <pull.2285.v6.git.git.1778492691.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> * --prune-merged now measures merged-ness against the remote's default > branch instead of the candidate's upstream — so the decision no longer > depends on which branch happens to be checked out locally.
I may be misreading the above and misunderstood you, but if you mean that the feature now checks with remote/origin/master when I have a local branch that were forked from remote/origin/todo and set to merge new changes from there, I do not think it is a good change.
The two remote-tracking branches may not even share any commit.
The "what it tracks or HEAD" logic I raised as questionable is in the function builtin/branch.c:branch_merged() that is called from the function check_branch_commit() you updated and used in the implementation of prune-merged. It does branch_get_upstream() to find the tip of remote-tracking branch that the target branch builds upon, and performs comparison (which is very sensible). I do not think you want to change it to check with remotes/<remote>/HEAD instead, as the upstream of the local branch may not be building on their HEAD at all. But when the upstream is not found, the code makes the reference_rev variable fall back to head_rev, and checks if the commit at the tip of the target branch is already merged there.
It is still not clear to me if we want to optionally disable this fallback to HEAD, but a quick scan of branch_merged() tells me that it is prepared to see NULL in head_rev.