Better handling of trying to set an upstream branch not set to be fetched in the remote
What steps will reproduce the problem?
- Open the Browse References window in a repository where remote foo is not set to fetch the branch bar (i.e., the refspec in the remote.foo.fetch config option does not include the branch bar)
- Right-click a local branch baz and try to set its upstream branch to remotes/foo/bar
- The column Tracked branch of baz becomes blank
What is the expected output? What do you see instead?
Git considers this an invalid situation. If one tries to do that by running git branch "baz" --set-upstream-to="foo/bar", git will complain like this:
fatal: Cannot setup tracking information; starting point 'foo/bar' is not a branch.
The problem is that TortoiseGit sets the branch.baz.remote and branch.baz.merge directly, instead of calling git branch like shown above. When the Browse References window tries to refresh the list, it will call git for-each-branch, which will report a blank value or an otherwise invalid value for the upstream branch.
What version of TortoiseGit and Git are you using? On what operating system?
Development snapshot as of 2020-09-09. Git version 2.28.0.windows.1. Windows 10 x64.
Please provide any additional information below.
I've attached a patch which, instead of setting the config keys directly, calls git branch and errors out if necessary.
I leave this up for discussion whether it is better to, in this case, call git remote set-branches and then try to run git branch again, possibly warning the user about that, instead of erroring out and being done with it as I did in my patch.
Possibly related: #2239 (closed)