sapling/eden/scm/tests/test-git-init.t
Max Coplan 0de6043ff5 Allow sl init --git in non-empty directory (#463)
Summary:
Allow `sl init --git` in non-empty directory

 Currently, running `sl init --git` for a nonempty directory gives the
follwing error:
```
destination <..> already exists
```
This seems like an arbitary restriction to me, so I removed it.

It looks like this restriction was put in place because `sl init` and
`sl clone` share similar logic.  Is there any other reason for not allowing
`sl init` in non-empty directories?

Also, this commit fixes an imprecise error message when `init`ing a repository
in a non-directory (i.e. a file)

Pull Request resolved: https://github.com/facebook/sapling/pull/463

Test Plan:
Blocked by https://github.com/facebook/sapling/issues/447
manually tested with

(should pass, but didn't before)
```sh
DIR=/tmp/sl-clone-test zsh -c 'rm -rf $DIR; mkdir $DIR && cd $DIR && touch hi && CHGDISABLE=1 sl init --git .'
```

(should still fail)
```sh
DIR=/tmp/sl-clone-test REPO=git@github.com:97-things/97-things-every-programmer-should-know.git zsh -c 'rm -rf $DIR; mkdir $DIR && cd $DIR && CHGDISABLE=1 sl clone $REPO && CHGDISABLE=1 sl clone $REPO'
```

 ---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/sapling/pull/463).
* __->__ https://github.com/facebook/sapling/issues/463

Reviewed By: muirdm

Differential Revision: D43328481

Pulled By: quark-zju

fbshipit-source-id: 0a82d88c393c847579e644b7c368db09cab51003
2023-02-17 12:04:00 -08:00

17 lines
327 B
Perl

#debugruntest-compatible
#require git no-windows
Can init with --git in an existing directory
$ mkdir init-git-nonempty
$ cd init-git-nonempty
$ echo hello > hello
$ sl init --git .
$ sl status
? hello
Re-init is an error
$ sl init --git
abort: repository `$TESTTMP/init-git-nonempty` already exists
[255]