git-2.22.0/refs/ref-cache.c
/*
 * Sort the entries in dir non-recursively (if they are not already
 * sorted) and remove any duplicate entries.
 */
Sort the entries in dir non-recursively (if they are not already
sorted) and remove any duplicate entries.
Sort the entries in dir non - recursively ( if they are not already sorted ) and remove any duplicate entries .
static void sort_ref_dir(struct ref_dir *dir)
{
	int i, j;
	struct ref_entry *last = NULL;
	if (dir->sorted == dir->nr)
		return;
	QSORT(dir->entries, dir->nr, ref_entry_cmp);
	for (i = 0, j = 0; j < dir->nr; j++) {
		struct ref_entry *entry = dir->entries[j];
		if (last && is_dup_ref(last, entry))
			free_ref_entry(entry);
		else
			last = dir->entries[i++] = entry;
	}
	dir->sorted = dir->nr = i;
}
static void sort_ref_dir ( struct ref_dir * dir ) { int i , j ; struct ref_entry * last = NULL ; if ( dir -> sorted == dir -> nr ) return ; QSORT ( dir -> entries , dir -> nr , ref_entry_cmp ) ; for ( i = 0 , j = 0 ; j < dir -> nr ; j ++ ) { struct ref_entry * entry = dir -> entries [ j ] ; if ( last && is_dup_ref ( last , entry ) ) free_ref_entry ( entry ) ; else last = dir -> entries [ i ++ ] = entry ; } dir -> sorted = dir -> nr = i ; }
Sort the entries in dir non-recursively (if they are not already
 sorted) and remove any duplicate entries.
Sort the entries in dir non - recursively ( if they are not already sorted ) and remove any duplicate entries .
/*
	 * This check also prevents passing a zero-length array to qsort(),
	 * which is a problem on some platforms.
	 */ /* Remove any duplicates: */