From: Elia Pinto Date: Thu, 19 Nov 2026 05:50:26 GMT Subject: Re: [PATCH v2] status: reword message for a missing upstream branch Message-ID: <20261119055026.759205-1-gitter.spiros@gmail.com> In-Reply-To: Junio C Hamano writes: > Using --mirror means the local branch we are interested in (e.g., > 'master' in your example) would be sent to their 'master'. Do we > need to check if their 'master' is what our 'master' is based on, > though? Can our 'master' be tracking their 'main', for example? The first check in push_creates() catches that. push_ref is what "@{push}" resolves to, and for a mirror remote branch_get_push_1() maps refs/heads/master to origin/master. That differs from the upstream origin/main, so we return false before looking at the mirror setting. With remote.origin.mirror=true and branch.master.merge=refs/heads/main, "git status" gives only the "--unset-upstream" hint. > We are content if there exists one or more "push" refspecs for the > remote, regardless of what the value is, but is that really > sufficient? What if our push refspec is deliberately narrow to > publish only selected branches, such as: > > [remote "origin"] > push = next > push = seen > > and the current branch in question is not among them? The same check again: no push refspec matches 'master', so branch_get_push_1() fails with "push refspecs for 'origin' do not include 'master'", push_ref is NULL and we return false. The refspec and mirror tests only come into play once we know that @{push} is the upstream; they are there because push.default is not consulted at all when either is set. > You mentioned "nothing" in the log message; shouldn't that also be > special cased? With push.default=nothing @{push} does not resolve either, so it ends up in the same place; 'status (missing upstream, push.default=nothing)' in t6040 covers it. "matching" is the only mode in which @{push} resolves to the upstream although "git push" would not create it, hence the special case. None of this is said in the comment above push_creates(), which is why it raises these questions. In v3 I will spell it out there and add tests for the mirror and the narrow refspec cases. > But we call push_creates() to compute suggest_push whether we have > advice enabled or declined. I wonder if it makes the logic flow > cleaner to give a few more arguments to format_missing_upstream() > and move push_creates() call there, not here? Yes, that reads better. I will do it in v3. Thanks for the review.