Commit f15ba7e0 authored by Alain Takoudjou's avatar Alain Takoudjou

do not fail if folder ends with .git and is not a git repository

parent 0985ff32
...@@ -495,6 +495,12 @@ func cmd_pull_(ctx context.Context, gb *git.Repository, pullspecv []PullSpec) { ...@@ -495,6 +495,12 @@ func cmd_pull_(ctx context.Context, gb *git.Repository, pullspecv []PullSpec) {
return nil return nil
} }
folder, err := os.Stat(path + "/objects")
if os.IsNotExist(err) || !folder.IsDir() {
// If this is not a git directory, then return
return nil
}
// git repo - let's pull all refs from it to our backup refs namespace // git repo - let's pull all refs from it to our backup refs namespace
infof("# git %s\t<- %s", prefix, path) infof("# git %s\t<- %s", prefix, path)
refv, _, err := fetch(ctx, path, alreadyHave) refv, _, err := fetch(ctx, path, alreadyHave)
...@@ -1012,7 +1018,7 @@ func cmd_restore_(ctx context.Context, gb *git.Repository, HEAD_ string, restore ...@@ -1012,7 +1018,7 @@ func cmd_restore_(ctx context.Context, gb *git.Repository, HEAD_ string, restore
// empty - without refs at all, and thus next "git packs restore" // empty - without refs at all, and thus next "git packs restore"
// step will not be run for it. // step will not be run for it.
filedir := pathpkg.Dir(filename) filedir := pathpkg.Dir(filename)
if strings.HasSuffix(filedir, ".git") && !repos_seen.Contains(filedir) { if strings.HasSuffix(filename, ".git/HEAD") && !repos_seen.Contains(filedir) {
infof("# repo %s\t-> %s", prefix, filedir) infof("# repo %s\t-> %s", prefix, filedir)
for _, __ := range []string{"refs/heads", "refs/tags", "objects/pack"} { for _, __ := range []string{"refs/heads", "refs/tags", "objects/pack"} {
err := os.MkdirAll(filedir+"/"+__, 0777) err := os.MkdirAll(filedir+"/"+__, 0777)
......
...@@ -257,8 +257,8 @@ func TestPullRestore(t *testing.T) { ...@@ -257,8 +257,8 @@ func TestPullRestore(t *testing.T) {
return err return err
} }
// non *.git/ -- not interesting // non *.git/ or nongit.git/ -- not interesting
if !(info.IsDir() && strings.HasSuffix(path, ".git")) { if !(info.IsDir() && strings.HasSuffix(path, ".git")) || strings.HasSuffix(path, "nongit.git") {
return nil return nil
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment