ref: 101885dd84333a2151fe1c681004f49a9c31f7c6
dir: /refstore/packed/shorten.go/
package packed
import "codeberg.org/lindenii/furgit/refstore"
// Shorten returns the shortest unambiguous shorthand for a packed ref name.
func (store *Store) Shorten(name string) (string, error) {
_, ok := store.byName[name]
if !ok {
return "", refstore.ErrReferenceNotFound
}
names := make([]string, 0, len(store.ordered))
for _, entry := range store.ordered {
names = append(names, entry.Name())
}
return refstore.ShortenName(name, names), nil
}