tig icon indicating copy to clipboard operation
tig copied to clipboard

%(remote) state variable always contain "origin" for local branches

Open sim590 opened this issue 2 years ago • 1 comments

I have this binding in my config file:

bind refs   p    ?git push -u %(remote) %(refname)

I want to press p in refs view in order to push my branch. It always defaults to git push -u origin BRANCHNAME when using local branches even though I don't have any origin remote in my repository:

image

I would have assumed that tig would have used the associated upstream branch's remote instead of simply using origin.

However, if I try the command on a remote branch in the refs view, then it uses the remote name associated with the remote branch. But, using the remote branch, I endup with %(refname) expanding to remotename/branchname which doesn't help me. I know I could use %(branch) which would give the correct output on a remote branch, but then I couldn't use the command on a tag.

I know I could use git push (with no arguments) if the upstream branch is configured for the current branch, but what if I want to push a branch I'm not currently checking out?

sim590 avatar Feb 05 '23 23:02 sim590

I could may be use:

bind refs   p    ?git push -u %(remote) %(branch)%(tag)

and only select remote branches and tags to push my branches/tags, but then, for tags, it will only work with origin remote. I guess that there is no remote tracked for tags, so this couldn't be supported anyways. I'd have to have user input for tags.

But I guess that I still think that %(remote) should expand to the remote tracking branch's remote name (if any) when a local branch is selected. In that case, selecting either remote or local branch would work equally.

sim590 avatar Feb 05 '23 23:02 sim590