Skip to content

Commit 1e8492c

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge remote-tracking branch 'dscho/rename-needs-stable-sort' into shears/next
See gitgitgadget#352 Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 0fe7b01 + a95cdf1 commit 1e8492c

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ LIB_OBJS += progress.o
958958
LIB_OBJS += promisor-remote.o
959959
LIB_OBJS += prompt.o
960960
LIB_OBJS += protocol.o
961+
LIB_OBJS += qsort.o
961962
LIB_OBJS += quote.o
962963
LIB_OBJS += range-diff.o
963964
LIB_OBJS += reachable.o
@@ -1737,7 +1738,6 @@ ifdef NO_GETPAGESIZE
17371738
endif
17381739
ifdef INTERNAL_QSORT
17391740
COMPAT_CFLAGS += -DINTERNAL_QSORT
1740-
COMPAT_OBJS += compat/qsort.o
17411741
endif
17421742
ifdef HAVE_ISO_QSORT_S
17431743
COMPAT_CFLAGS += -DHAVE_ISO_QSORT_S

compat/mingw.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,11 +1532,6 @@ static int wenvcmp(const void *a, const void *b)
15321532
return _wcsnicmp(p, q, p_len);
15331533
}
15341534

1535-
/* We need a stable sort to convert the environment between UTF-16 <-> UTF-8 */
1536-
#ifndef INTERNAL_QSORT
1537-
#include "qsort.c"
1538-
#endif
1539-
15401535
/*
15411536
* Build an environment block combining the inherited environment
15421537
* merged with the given list of settings.

diffcore-rename.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ void diffcore_rename(struct diff_options *options)
598598
stop_progress(&progress);
599599

600600
/* cost matrix sorted by most to least similar pair */
601-
QSORT(mx, dst_cnt * NUM_CANDIDATE_PER_DST, score_compare);
601+
QSORT_STABLE(mx, dst_cnt * NUM_CANDIDATE_PER_DST, score_compare);
602602

603603
rename_count += find_renames(mx, dst_cnt, minimum_score, 0);
604604
if (detect_rename == DIFF_DETECT_COPY)

git-compat-util.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,9 +1110,9 @@ static inline int strtol_i(char const *s, int base, int *result)
11101110
return 0;
11111111
}
11121112

1113-
#ifdef INTERNAL_QSORT
11141113
void git_qsort(void *base, size_t nmemb, size_t size,
11151114
int(*compar)(const void *, const void *));
1115+
#ifdef INTERNAL_QSORT
11161116
#define qsort git_qsort
11171117
#endif
11181118

@@ -1124,6 +1124,8 @@ static inline void sane_qsort(void *base, size_t nmemb, size_t size,
11241124
qsort(base, nmemb, size, compar);
11251125
}
11261126

1127+
#define QSORT_STABLE(base, n, compar) git_qsort((base), (n), sizeof(*(base)), compar)
1128+
11271129
#ifndef HAVE_ISO_QSORT_S
11281130
int git_qsort_s(void *base, size_t nmemb, size_t size,
11291131
int (*compar)(const void *, const void *, void *), void *ctx);

compat/qsort.c renamed to qsort.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../git-compat-util.h"
1+
#include "git-compat-util.h"
22

33
/*
44
* A merge sort implementation, simplified from the qsort implementation

0 commit comments

Comments
 (0)