if change.Old.Mode.Type() == fs.ModeSymlink {
// Some BSD systems permit changing permissions of
// symlinks but ignore them on traversal. To keep it
- // simple we don't support that and always use 0777 for
- // symlink permissions (the value on GNU/Linux).
+ // simple we don't support that and always use 0777
+ // for symlink permissions (the value on GNU/Linux).
//
// TODO: Add proper support for symlinks on BSD
change.Old.Mode |= 0777
}
}
- // Directory: create new directory (also type change to directory)
+ // Directory: create new directory, also type change to directory
if file.Mode.IsDir() && (change.Created || changeType) {
debugf("creating directory")
err := os.Mkdir(file.Path, 0700)
os.Remove(tmpPath)
return err
}
- // Permissions are irrelevant for symlinks
+ // Permissions are irrelevant for symlinks (on most systems)
default:
panic(fmt.Sprintf("invalid file type %s", file.Mode))
oldBin := !strings.HasPrefix(http.DetectContentType(oldData), "text/")
newBin := !strings.HasPrefix(http.DetectContentType(newData), "text/")
if oldBin && newBin {
- return "Binary files differ, cannot show diff", nil
+ return fmt.Sprintf("Binary files differ (%d -> %d bytes), "+
+ "cannot show diff", len(oldData), len(newData)), nil
}
if oldBin {
- oldData = []byte("<binary content>\n")
+ oldData = []byte(fmt.Sprintf("<binary content, %d bytes>\n",
+ len(oldData)))
}
if newBin {
- newData = []byte("<binary content>\n")
+ newData = []byte(fmt.Sprintf("<binary content, %d bytes>\n",
+ len(newData)))
}
// TODO: difflib shows empty context lines at the end of the file