git-backup issueshttps://lab.nexedi.com/kirr/git-backup/-/issues2020-03-09T18:23:44Zhttps://lab.nexedi.com/kirr/git-backup/-/issues/3Repo may be kept in locked state (after pulling failed).2020-03-09T18:23:44ZivRepo may be kept in locked state (after pulling failed).See [some](https://lab.nexedi.com/kirr/git-backup/issues/2#note_16361) [comments](https://lab.nexedi.com/kirr/git-backup/issues/2#note_16373) on issue 2.See [some](https://lab.nexedi.com/kirr/git-backup/issues/2#note_16361) [comments](https://lab.nexedi.com/kirr/git-backup/issues/2#note_16373) on issue 2.https://lab.nexedi.com/kirr/git-backup/-/issues/2Impossible to pull from dir with a non-bare repository2020-03-09T18:23:44ZivImpossible to pull from dir with a non-bare repositoryPulling/restoring a bare repository works fine for me (see commands in issue #1), but when I pull a non-bare repo, a problem occurs:
$ cd backup/
$ $ git-backup pull ../slapos/:slapos2
# file slapos2 <- ../slapos/.gitignore
# file slapos2 <- ../slapos/CHANGES.txt
# file slapos2 <- ../slapos/MANIFEST.in
# file slapos2 <- ../slapos/README.software.txt
# file slapos2 <- ../slapos/README.txt
# file slapos2 <- ../slapos/schema.json
# file slapos2 <- ../slapos/setup.py
# file slapos2 <- ../slapos/sla.schema.json
# git slapos2 <- ../slapos/.git
Traceback (most recent call last):
File "/usr/local/bin/git-backup", line 814, in <module>
main()
File "/usr/local/bin/git-backup", line 810, in main
cmd(argv[1:])
File "/usr/local/bin/git-backup", line 402, in cmd_pull
cmd_pull_(pullspecv)
File "/usr/local/bin/git-backup", line 465, in cmd_pull_
stderr=gitprogress())
File "/usr/local/bin/git-backup", line 119, in xgit
raise RuntimeError('git ' + ' '.join(argv) + '\n' + (stderr and stderr or '(failed)'))
RuntimeError: git -c fetch.fsckObjects=true fetch --no-tags ../slapos/.git refs/*:refs/backup/20160701-0820/slapos2/.git/*
fatal: Invalid refspec 'refs/*:refs/backup/20160701-0820/slapos2/.git/*'Pulling/restoring a bare repository works fine for me (see commands in issue #1), but when I pull a non-bare repo, a problem occurs:
$ cd backup/
$ $ git-backup pull ../slapos/:slapos2
# file slapos2 <- ../slapos/.gitignore
# file slapos2 <- ../slapos/CHANGES.txt
# file slapos2 <- ../slapos/MANIFEST.in
# file slapos2 <- ../slapos/README.software.txt
# file slapos2 <- ../slapos/README.txt
# file slapos2 <- ../slapos/schema.json
# file slapos2 <- ../slapos/setup.py
# file slapos2 <- ../slapos/sla.schema.json
# git slapos2 <- ../slapos/.git
Traceback (most recent call last):
File "/usr/local/bin/git-backup", line 814, in <module>
main()
File "/usr/local/bin/git-backup", line 810, in main
cmd(argv[1:])
File "/usr/local/bin/git-backup", line 402, in cmd_pull
cmd_pull_(pullspecv)
File "/usr/local/bin/git-backup", line 465, in cmd_pull_
stderr=gitprogress())
File "/usr/local/bin/git-backup", line 119, in xgit
raise RuntimeError('git ' + ' '.join(argv) + '\n' + (stderr and stderr or '(failed)'))
RuntimeError: git -c fetch.fsckObjects=true fetch --no-tags ../slapos/.git refs/*:refs/backup/20160701-0820/slapos2/.git/*
fatal: Invalid refspec 'refs/*:refs/backup/20160701-0820/slapos2/.git/*'https://lab.nexedi.com/kirr/git-backup/-/issues/1Empty dirs are not tracked (Restoring repo require their name to ends with "....2020-03-09T18:23:44ZivEmpty dirs are not tracked (Restoring repo require their name to ends with ".git")To reproduce the bug:
get some bare repo:
$ git clone --bare slapos slapos.git
backup-pull it:
$ mkdir backup && cd backup && git init
$ git-backup pull ../slapos.git/:slapos
when restoring:
$ git-backup restore HEAD slapos:../slapos.restored
$ cd .. && git clone slapos.restored slapos_bis
fatal: repository 'slapos.restored' does not exist
As @kirr explained me, it is due to git not tracking trees of empty directories:
$ls slapos.git/refs/ -Ra
slapos.git/refs/:
. .. heads tags
slapos.git/refs/heads:
. ..
slapos.git/refs/tags:
. ..
So some directory that are used by the restored repo are missing.
This is currently fixed by detecting if it is a git repo or not (it is also possible to backup usual folder/files) by [verifying its extension](https://lab.nexedi.com/kirr/git-backup/blob/a6cfe210f8bad8a816364220f148957cfdb75a41/git-backup#L679). So it works fine when restoring this way:
$ git-backup restore HEAD slapos:../slapos.restored.git
gives:
$ cd ../slapos.restored.git && git log
commit 5f5d5102cf2dd2b4a8d092e32dfc6b87fa3bbc12
Author: [...]To reproduce the bug:
get some bare repo:
$ git clone --bare slapos slapos.git
backup-pull it:
$ mkdir backup && cd backup && git init
$ git-backup pull ../slapos.git/:slapos
when restoring:
$ git-backup restore HEAD slapos:../slapos.restored
$ cd .. && git clone slapos.restored slapos_bis
fatal: repository 'slapos.restored' does not exist
As @kirr explained me, it is due to git not tracking trees of empty directories:
$ls slapos.git/refs/ -Ra
slapos.git/refs/:
. .. heads tags
slapos.git/refs/heads:
. ..
slapos.git/refs/tags:
. ..
So some directory that are used by the restored repo are missing.
This is currently fixed by detecting if it is a git repo or not (it is also possible to backup usual folder/files) by [verifying its extension](https://lab.nexedi.com/kirr/git-backup/blob/a6cfe210f8bad8a816364220f148957cfdb75a41/git-backup#L679). So it works fine when restoring this way:
$ git-backup restore HEAD slapos:../slapos.restored.git
gives:
$ cd ../slapos.restored.git && git log
commit 5f5d5102cf2dd2b4a8d092e32dfc6b87fa3bbc12
Author: [...]