aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-19 22:04:46 +0200
committerGitHub <noreply@github.com>2017-07-19 22:04:46 +0200
commit8738a04708b91683d5804b4c648c871fdeb87f82 (patch)
tree017b15080dee8bd64026c9358d832e61d12674d5 /storage/filesystem/internal/dotgit
parent595dfe6e53a038da4949263ea2d9a7a0020c48b7 (diff)
parent4a7e7cddc0e4f88085b263693c87635254de7f35 (diff)
downloadgo-git-8738a04708b91683d5804b4c648c871fdeb87f82.tar.gz
Merge pull request #493 from src-d/windows
*: several windows support fixes
Diffstat (limited to 'storage/filesystem/internal/dotgit')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go16
-rw-r--r--storage/filesystem/internal/dotgit/dotgit_test.go1
2 files changed, 11 insertions, 6 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index f3a2308..b672d4b 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -348,7 +348,6 @@ func (d *DotGit) rewritePackedRefsWithoutRef(name plumbing.ReferenceName) (err e
return err
}
- defer ioutil.CheckClose(f, &err)
// Creating the temp file in the same directory as the target file
// improves our chances for rename operation to be atomic.
@@ -357,10 +356,6 @@ func (d *DotGit) rewritePackedRefsWithoutRef(name plumbing.ReferenceName) (err e
return err
}
- tmpPath := tmp.Name()
- defer ioutil.CheckClose(tmp, &err)
- defer d.fs.Remove(tmpPath)
-
s := bufio.NewScanner(f)
found := false
for s.Scan() {
@@ -388,7 +383,16 @@ func (d *DotGit) rewritePackedRefsWithoutRef(name plumbing.ReferenceName) (err e
return nil
}
- return d.fs.Rename(tmpPath, packedRefsPath)
+ if err := f.Close(); err != nil {
+ ioutil.CheckClose(tmp, &err)
+ return err
+ }
+
+ if err := tmp.Close(); err != nil {
+ return err
+ }
+
+ return d.fs.Rename(tmp.Name(), packedRefsPath)
}
// process lines from a packed-refs file
diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go
index d4cda0e..d935ec5 100644
--- a/storage/filesystem/internal/dotgit/dotgit_test.go
+++ b/storage/filesystem/internal/dotgit/dotgit_test.go
@@ -373,6 +373,7 @@ func (s *SuiteDotGit) TestObjectPackIdx(c *C) {
idx, err := dir.ObjectPackIdx(f.PackfileHash)
c.Assert(err, IsNil)
c.Assert(filepath.Ext(idx.Name()), Equals, ".idx")
+ c.Assert(idx.Close(), IsNil)
}
func (s *SuiteDotGit) TestObjectPackNotFound(c *C) {