threads / bug / 36159

bug report: regression in git subtree add

Subject: bug report: regression in git subtree add

## tl;dr

One message between Mar 14, 2014 and Mar 14, 2014.

replies: 0people: 1as markdown or json

Peter Wolanin· Mar 14, 2014, 20:49 UTC · lore

In this commit: https://github.com/git/git/commit/10a49587fabde88c0afbc80a99d97fae91811f5f

git subtree add for a remote repository and branch was fundamentally broken.

It works by chance if a local branch exists that matches the name of the desired remote branch. Thus, "master" happens to work and the bug possibly escapes common notice.

cmd_add_repository() does a git fetch - the desired remote refspec can never be found in the local repo until that git fetch is run, so the attempt to validate it within cmd_add() is wrong - if desired, that should happen after the fetch in cmd_add_repository().

I think the additions shown in lines 505 and 506 should be reverted, since the rev is also checked in cmd_add_commit()

Best,
Peter Wolanin

← back to recent threads