# bug report: regression in git subtree add

1 messages from 2014-03-14 to 2014-03-14. Participants: Peter Wolanin.
Thread: https://gitlist.dev/t/36159

## Peter Wolanin, 2014-03-14 20:49

Subject: bug report: regression in git subtree add
Message-ID: <CANae7MgZQs4tV9QcJvU3_anABSj-uTdwO+Y4x4mWKySprOEnBA@mail.gmail.com>
URL: https://gitlist.dev/e/CANae7MgZQs4tV9QcJvU3_anABSj-uTdwO%2BY4x4mWKySprOEnBA%40mail.gmail.com

```
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

```
