code: func renameDuplicates(bf []*blobFile) sortedFiles {
  	noDup := make(map[string]blob.Ref)
  	// use a map to detect duplicates and rename them
  	for _, file := range bf {
  		if _, ok := noDup[file.path]; ok {
  			// path already exists, so rename
  			suffix := 0
  			var newname string
  			for {
  				suffix++
  				ext := path.Ext(file.path)
  				newname = fmt.Sprintf("%s(%d)%s",
  					file.path[:len(file.path)-len(ext)], suffix, ext)
  				if _, ok := noDup[newname]; !ok {
  					break
  				}
  			}
  			noDup[newname] = file.blobRef
  		} else {
  			noDup[file.path] = file.blobRef
  		}
  	}
  
  	// reinsert in a slice and sort it
  	var sorted sortedFiles
  	for p, b := range noDup {
  		sorted = append(sorted, &blobFile{path: p, blobRef: b})
  	}
  	sort.Sort(sorted)
  	return sorted
  }
docs: // renameDuplicates goes through bf to check for duplicate filepaths.
  // It renames duplicate filepaths and returns a new slice, sorted by
  // file path.