git-subrepo icon indicating copy to clipboard operation
git-subrepo copied to clipboard

Cannot change tracking branch if two branches point to the same hash

Open queil opened this issue 4 years ago • 1 comments

In one of my subrepos I've branched test2 off of master. Neither of them has any new commits so they effectively point to the same hash.

> git subrepo status
1 subrepo:

Git subrepo 'myrepo':
  Subrepo Branch:  subrepo/myrepo
  Remote URL:      [email protected]:zzz/xxx.git
  Upstream Ref:    66e98f3
  Tracking Branch: test2
  Pulled Commit:   66e98f3
  Pull Parent:     7e41165

When I try changing the tracking branch to master I get:

git subrepo pull -b master --force --update myrepo
Subrepo 'myrepo' pulled from '[email protected]:zzz/xxx.git' (master).

But git subrepo status still shows:

1 subrepo:

Git subrepo 'myrepo':
  Subrepo Branch:  subrepo/myrepo
  Remote URL:      [email protected]:zzz/xxx.git
  Upstream Ref:    66e98f3
  Tracking Branch: test2
  Pulled Commit:   66e98f3
  Pull Parent:     7e41165

Expected result

> git subrepo status
1 subrepo:

Git subrepo 'myrepo':
  Subrepo Branch:  subrepo/myrepo
  Remote URL:     [email protected]:zzz/xxx.git
  Upstream Ref:    66e98f3
  Tracking Branch: master
  Pulled Commit:   66e98f3
  Pull Parent:     c7c19cd

Workaround

Change the tracking branch to some other branch (that points to another commit) first and then change it again to the target one.

queil avatar Oct 27 '21 10:10 queil

Can confirm that I am also running into this issue

Eoxan avatar Nov 24 '22 03:11 Eoxan