MCPcopy Create free account
hub / github.com/git/git / approx_halfway

Function approx_halfway

bisect.c:110–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110static inline int approx_halfway(struct commit_list *p, int nr)
111{
112 int diff;
113
114 /*
115 * Don't short-cut something we are not going to return!
116 */
117 if (p->item->object.flags & TREESAME)
118 return 0;
119 if (DEBUG_BISECT)
120 return 0;
121 /*
122 * For small number of commits 2 and 3 are halfway of 5, and
123 * 3 is halfway of 6 but 2 and 4 are not.
124 */
125 diff = 2 * weight(p) - nr;
126 switch (diff) {
127 case -1: case 0: case 1:
128 return 1;
129 default:
130 /*
131 * For large number of commits we are not so strict, it's
132 * good enough if it's within ~0.1% of the halfway point,
133 * e.g. 5000 is exactly halfway of 10000, but we consider
134 * the values [4996, 5004] as halfway as well.
135 */
136 if (abs(diff) < nr / 1024)
137 return 1;
138 return 0;
139 }
140}
141
142static void show_list(const char *debug, int counted, int nr,
143 struct commit_list *list)

Callers 1

do_find_bisectionFunction · 0.85

Calls 1

weightFunction · 0.85

Tested by

no test coverage detected