Exemple #1
0
func entryKey(entry *objects.TreeEntry, usingMode bool) string {
	key := entry.ObjectId().String() + entry.Name()
	if usingMode {
		key = fmt.Sprintf("%s%d", key, uint16(entry.Mode()))
	}
	return key
}
Exemple #2
0
func (result *TreeDiff) detectModified() {
	var conflated []*TreeEdit
	paths := make(map[string]*TreeEdit)
	uniques := make(map[string]*TreeEdit)
	for _, edit := range result.edits {
		var blob *objects.TreeEntry
		switch edit.action {
		case Insert:
			blob = edit.After
		case Delete:
			blob = edit.Before
		default:
			return
		}
		if existing := paths[blob.Name()]; existing == nil {
			conflated = append(conflated, edit)
			paths[blob.Name()] = edit
			uniques[blob.Name()] = edit
		} else {
			delete(uniques, blob.Name())
			switch existing.action {
			case Insert:
				existing.Before = blob
			case Delete:
				existing.After = blob
			}
			existing.action = Modify
			result.modified = append(result.modified, existing)
		}
	}
	for _, edit := range uniques {
		switch edit.action {
		case Insert:
			result.insertEdits = append(result.insertEdits, edit)
		case Delete:
			result.deleteEdits = append(result.deleteEdits, edit)
		}
	}
	result.edits = conflated
}
Exemple #3
0
func treeFormat(prefix string, te *objects.TreeEntry) string {
	return fmt.Sprintf("%s %s", prefix, te.Name())
}