# git p4: bug - branch detection broken on empty branches

2 messages from 2014-04-22 to 2014-04-26. Participants: Dan Porter, Pete Wyckoff.
Thread: https://gitlist.dev/t/36473

## Dan Porter, 2014-04-22 09:20

Subject: git p4: bug - branch detection broken on empty branches
Message-ID: <CADtnS+zAnnpaU59-rAwMHF7Z4SNjcYWASqpKdEq+GVs8mVSb3w@mail.gmail.com>
URL: https://gitlist.dev/e/CADtnS%2BzAnnpaU59-rAwMHF7Z4SNjcYWASqpKdEq%2BGVs8mVSb3w%40mail.gmail.com

```
As part of my work to help get git-p4 close to bug-free before Git
2.0, I'm posting all bugs and patches to this mailing list. Please
direct me elsewhere if this is incorrect.

When trying to clone a particular directory from a depot, that
contains one or more branches that contain no commits for that
directory, branch detection is broken and results in a failed clone.

fatal: ambiguous argument
'refs/remotes/p4/silly_project_branch/trunk': unknown revision or path
not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Traceback (most recent call last):
  File "/home/dreid/bin/git-p4", line 3295, in ?
    main()
  File "/home/dreid/bin/git-p4", line 3289, in main
    if not cmd.run(args):
  File "/home/dreid/bin/git-p4", line 3163, in run
    if not P4Sync.run(self, depotPaths):
  File "/home/dreid/bin/git-p4", line 3016, in run
    self.importChanges(changes)
  File "/home/dreid/bin/git-p4", line 2678, in importChanges
    blob = self.searchParent(parent, branch, tempBranch)
  File "/home/dreid/bin/git-p4", line 2600, in searchParent
    for blob in read_pipe_lines(["git", "rev-list", "--reverse",
  File "/home/dreid/bin/git-p4", line 155, in read_pipe_lines
    die('Command failed: %s' % str(c))
  File "/home/dreid/bin/git-p4", line 106, in die
    raise Exception(msg)
Exception: Command failed: ['git', 'rev-list', '--reverse',
'--no-merges', 'refs/remotes/p4/silly_project_branch/trunk']

Original command:
$ git-p4 clone //insane_depot/projects/Exchange/CompanyName/silly_project_branch@all
silly-project --detect-branches -v

```

## Pete Wyckoff, 2014-04-26 12:40

Subject: Re: git p4: bug - branch detection broken on empty branches
Message-ID: <20140426124000.GA4767@padd.com>
URL: https://gitlist.dev/e/20140426124000.GA4767%40padd.com
In-Reply-To: <CADtnS+zAnnpaU59-rAwMHF7Z4SNjcYWASqpKdEq+GVs8mVSb3w@mail.gmail.com>

```
dpreid@gmail.com wrote on Tue, 22 Apr 2014 10:20 +0100:
> As part of my work to help get git-p4 close to bug-free before Git
> 2.0, I'm posting all bugs and patches to this mailing list. Please
> direct me elsewhere if this is incorrect.
> 
> When trying to clone a particular directory from a depot, that
> contains one or more branches that contain no commits for that
> directory, branch detection is broken and results in a failed clone.
> 
> fatal: ambiguous argument
> 'refs/remotes/p4/silly_project_branch/trunk': unknown revision or path
> not in the working tree.
[..]
>   File "/home/dreid/bin/git-p4", line 2678, in importChanges
>     blob = self.searchParent(parent, branch, tempBranch)
>   File "/home/dreid/bin/git-p4", line 2600, in searchParent
>     for blob in read_pipe_lines(["git", "rev-list", "--reverse",
>   File "/home/dreid/bin/git-p4", line 155, in read_pipe_lines
>     die('Command failed: %s' % str(c))
>   File "/home/dreid/bin/git-p4", line 106, in die
>     raise Exception(msg)
> Exception: Command failed: ['git', 'rev-list', '--reverse',
> '--no-merges', 'refs/remotes/p4/silly_project_branch/trunk']
> 
> Original command:
> $ git-p4 clone //insane_depot/projects/Exchange/CompanyName/silly_project_branch@all
> silly-project --detect-branches -v

Yes, this is a good bug.  You could do "git rev-parse -q --verify"
on parent before trying to read the rev-list.

But then what should happen?  I suspect git-p4 will just create
that ref when it commits the change it is considering.

		-- Pete

```
