Skip to content

Commit 2addbba

Browse files
committed
repository: fix error handling in PlainCloneContext(). [Fixes src-d#741]
Signed-off-by: Bartek Jaroszewski <[email protected]>
1 parent b9308fa commit 2addbba

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

repository.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,14 @@ func PlainCloneContext(ctx context.Context, path string, isBare bool, o *CloneOp
368368
}
369369
defer fh.Close()
370370

371-
names, err := fh.Readdirnames(1)
372-
if err != nil {
373-
if err == io.EOF {
374-
dirEmpty = true
375-
} else if len(names) != 0 {
376-
return nil, ErrDirNotEmpty
377-
}
371+
if err != io.EOF && err != nil {
378372
return nil, err
379373
}
374+
if len(names) == 0 {
375+
dirEmpty = true
376+
} else {
377+
return nil, ErrDirNotEmpty
378+
}
380379
}
381380

382381
r, err := PlainInit(path, isBare)

0 commit comments

Comments
 (0)