Desktop: Remote name isn't properly parsed when the name contains slashes

Created on 16 Dec 2017  路  3Comments  路  Source: desktop/desktop

We discovered this while working on https://github.com/desktop/desktop/pull/3602.

We currently get the remote name for a branch by parsing its full ref name with a regex. That regex assumes the remote does not contain a slash:

https://github.com/desktop/desktop/blob/251c0af8e105c9835455fa06c9fb57d0e1a3e956/app/src/models/branch.ts#L44

But remote names can totally contain a slash.

The good news is that in Git 2.16, git for-each-ref has learned how to tell us the remote name. See https://github.com/git/git/blob/52015aaf9d19c97b52c47c7046058e6d029ff856/Documentation/RelNotes/2.16.0.txt#L50-L53. The bad news is that Git 2.16 isn't out yet. So we'll have to wait to fix this.

bug priority-3

Most helpful comment

I had a look into this, and we're still reliant for this parsing in git status --branch. We do this for loading the current remote inside GitStore, which then flows through to push/pull operations (maybe we can break this? I'm not sure):

~/src/desktop/ git status --branch --porcelain=2
# branch.oid 86edf4c6e1198b19dac474adafe314931097dbdd
# branch.head master
# branch.upstream origin/master
# branch.ab +0 -0

I'll see if there's a discussion about this elsewhere, otherwise I might brave the Git mailing list and see if they're receptive to applying the same changes here.

All 3 comments

This actually has a body now 馃檲

FYI: [email protected] with Git 2.16.0-rc0 is available if you want to start testing out the new version of git for-each-ref

I had a look into this, and we're still reliant for this parsing in git status --branch. We do this for loading the current remote inside GitStore, which then flows through to push/pull operations (maybe we can break this? I'm not sure):

~/src/desktop/ git status --branch --porcelain=2
# branch.oid 86edf4c6e1198b19dac474adafe314931097dbdd
# branch.head master
# branch.upstream origin/master
# branch.ab +0 -0

I'll see if there's a discussion about this elsewhere, otherwise I might brave the Git mailing list and see if they're receptive to applying the same changes here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sbonami picture sbonami  路  3Comments

smilecs picture smilecs  路  3Comments

IvanS95 picture IvanS95  路  3Comments

j-f1 picture j-f1  路  3Comments

mikeytag picture mikeytag  路  3Comments