Page MenuHomePhabricator

`arc patch` fails in empty repositories
Open, NormalPublic

Description

From @bitglue:

pfrost@zoom:~/Documents$ git clone git@git:puppet-macpros_jenkins test
Cloning into 'test'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done
pfrost@zoom:~/Documents$ cd test/
pfrost@zoom:~/Documents/test$ arc patch D7
Exception
Command failed with error #128!
COMMAND
git diff --no-ext-diff --no-textconv --raw 'HEAD' --

STDOUT
(empty)

STDERR
fatal: bad revision 'HEAD'

(Run with --trace for a full exception trace.)
pfrost@zoom:~/Documents/test$

We probably need some special casing for empty repositories (like we have in various other places), since HEAD isn't meaningful when a repo is empty.

Event Timeline

epriestley raised the priority of this task from to Normal.
epriestley updated the task description. (Show Details)
epriestley added a project: Arcanist.
epriestley added subscribers: epriestley, bitglue.

A rather poor workaround is:

$ git clone git@git:puppet-macpros_jenkins test
$ cd test/
$ git commit --allow-empty -m 'initial commit'
$ arc patch D7 --nobranch --nocommit

Not quite the desired behavior, but it does at least get the changes into a working directory. Even better might be to initialize repositories with an empty commit before arc diff, avoiding this issue, whilst still passing all changes through review.