Issue #254: Please warn when newly added git repository is not in 'bare' format (conservancy/kallithea)
Karl Goetz
issues-reply at bitbucket.org
Sun Nov 13 23:13:29 UTC 2016
New issue 254: Please warn when newly added git repository is not in 'bare' format
https://bitbucket.org/conservancy/kallithea/issues/254/please-warn-when-newly-added-git
Karl Goetz:
Hi,
I decided to try and import some existing repositories to kallithea and they appeared to work.
- I took my existing git repositories
- synced them from my laptop to my repositories directory
- ran Remap and Scan
Kallithea detected the repositories, showed them in the UI, let me change settings and let me add the repository as a git remote.
The repository in Kallithea looks like this
```
root at kallithea-combined:/srv/kallithea/repositories# ls -lha test-git-repo/
total 12K
drwxr-xr-x 3 root root 4.0K Nov 14 09:45 .
drwxr-xr-x 6 root root 4.0K Nov 14 09:48 ..
-rw-r--r-- 1 root root 0 Nov 14 09:45 file
drwxr-xr-x 8 root root 4.0K Nov 14 09:45 .git
-rw-r--r-- 1 root root 0 Nov 14 09:45 test
```
Unfortunately (for me), when trying to push the failure occurs.
```
Karls-Air:test-git-repo kgoetz$ git push
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 259 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To http://192.168.1.17:5000/test-git-repo
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'http://kgoetz@192.168.1.17:5000/test-git-repo'
Karls-Air:test-git-repo kgoetz$
```
While I think its an entirely reasonable error, i wonder if kallithea could could convert the non bare repositories to bare?
Converting is a simple process
```
root at kallithea-combined:/srv/kallithea/repositories# cd test-git-repo/
root at kallithea-combined:/srv/kallithea/repositories/test-git-repo# ls -lh
total 0
-rw-r--r-- 1 root root 0 Nov 14 09:45 file
-rw-r--r-- 1 root root 0 Nov 14 09:45 test
root at kallithea-combined:/srv/kallithea/repositories/test-git-repo# rm *
root at kallithea-combined:/srv/kallithea/repositories/test-git-repo# mv .git/* .
root at kallithea-combined:/srv/kallithea/repositories/test-git-repo# rmdir .git/
root at kallithea-combined:/srv/kallithea/repositories/test-git-repo# git config --bool core.bare true
root at kallithea-combined:/srv/kallithea/repositories/test-git-repo# ls -lh
total 44K
drwxr-xr-x 2 root root 4.0K Nov 14 09:45 branches
-rw-r--r-- 1 root root 577 Nov 14 09:45 COMMIT_EDITMSG
-rwxr--r-- 1 root root 91 Nov 14 10:11 config
-rw-r--r-- 1 root root 73 Nov 14 09:45 description
-rw-r--r-- 1 root root 23 Nov 14 09:45 HEAD
drwxr-xr-x 2 root root 4.0K Nov 14 09:47 hooks
-rw-r--r-- 1 root root 209 Nov 14 09:45 index
drwxr-xr-x 2 root root 4.0K Nov 14 09:58 info
drwxr-xr-x 3 root root 4.0K Nov 14 09:45 logs
drwxr-xr-x 9 root root 4.0K Nov 14 09:58 objects
drwxr-xr-x 4 root root 4.0K Nov 14 09:45 refs
```
Which allows pushing to work.
```
Karls-Air:test-git-repo kgoetz$ git push
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 259 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To http://192.168.1.17:5000/test-git-repo
07e4b1e..15774e0 master -> master
Karls-Air:test-git-repo kgoetz$
```
If thats deemed to dangerous (data loss issues perhaps?) if Kallithea could refuse to import anything except bare repositories that would help too.
I'm happy to contribute some documentation on importing repositories 'the right way' if it would be helpful.
thanks,
More information about the kallithea-general
mailing list