bisect: limit the searchspace by pathspecs
It was surprisingly easy to do. git bisect start <pathspec> followed by all the normal "git bisect good/bad" stuff. Almost totally untested, and I guarantee that if your pathnames have spaces in them (or your GIT_DIR has spaces in it) this won't work. I don't know how to fix that, my shell programming isn't good enough. This involves small changes to make "git-rev-list --bisect" work in the presense of a pathspec limiter, and then truly trivial (and that's the broken part) changes to make "git bisect" save away and use the pathspec. I tried one bisection, and a "git bisect visualize", and it all looked correct. But hey, don't be surprised if it has problems. Linus Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Nov 27, 2005 at 11:32 UTC
b3cfd939c330211c9812f814094aa1dbe9531bdc
2 files changed
+17
-11
git-bisect.sh
+5
-5
@@ -33,7 +33,6 @@ bisect_autostart() {
33
}
34
35
bisect_start() {
36
- case "$#" in 0) ;; *) usage ;; esac
36
#
37
# Verify HEAD. If we were bisecting before this, reset to the
38
# top-of-line master first!
@@ -57,7 +56,8 @@ bisect_start() {
56
rm -f "$GIT_DIR/refs/heads/bisect"
57
rm -rf "$GIT_DIR/refs/bisect/"
58
mkdir "$GIT_DIR/refs/bisect"
60
- echo "git-bisect start" >"$GIT_DIR/BISECT_LOG"
59
+ echo "git-bisect start $@" >"$GIT_DIR/BISECT_LOG"
60
+ echo "$@" > "$GIT_DIR/BISECT_NAMES"
61
}
62
63
bisect_bad() {
@@ -121,7 +121,7 @@ bisect_next() {
121
bad=$(git-rev-parse --verify refs/bisect/bad) &&
122
good=$(git-rev-parse --sq --revs-only --not \
123
$(cd "$GIT_DIR" && ls refs/bisect/good-*)) &&
124
- rev=$(eval "git-rev-list --bisect $good $bad") || exit
124
+ rev=$(eval "git-rev-list --bisect $good $bad -- $(cat $GIT_DIR/BISECT_NAMES)") || exit
125
if [ -z "$rev" ]; then
126
echo "$bad was both good and bad"
127
exit 1
@@ -131,7 +131,7 @@ bisect_next() {
131
git-diff-tree --pretty $rev
132
exit 0
133
fi
134
- nr=$(eval "git-rev-list $rev $good" | wc -l) || exit
134
+ nr=$(eval "git-rev-list $rev $good -- $(cat $GIT_DIR/BISECT_NAMES)" | wc -l) || exit
135
echo "Bisecting: $nr revisions left to test after this"
136
echo "$rev" > "$GIT_DIR/refs/heads/new-bisect"
137
git checkout new-bisect || exit
@@ -142,7 +142,7 @@ bisect_next() {
142
143
bisect_visualize() {
144
bisect_next_check fail
145
- gitk bisect/bad --not `cd "$GIT_DIR/refs" && echo bisect/good-*`
145
+ gitk bisect/bad --not `cd "$GIT_DIR/refs" && echo bisect/good-*` -- $(cat $GIT_DIR/BISECT_NAMES)
146
}
147
148
bisect_reset() {
rev-list.c
+12
-6
@@ -350,7 +350,8 @@ static int count_distance(struct commit_list *entry)
350
351
if (commit->object.flags & (UNINTERESTING | COUNTED))
352
break;
353
- nr++;
353
+ if (!paths || (commit->object.flags & TREECHANGE))
354
+ nr++;
355
commit->object.flags |= COUNTED;
356
p = commit->parents;
357
entry = p;
@@ -362,6 +363,7 @@ static int count_distance(struct commit_list *entry)
363
}
364
}
365
}
366
+
367
return nr;
368
}
369
@@ -382,15 +384,20 @@ static struct commit_list *find_bisection(struct commit_list *list)
384
nr = 0;
385
p = list;
386
while (p) {
385
- nr++;
387
+ if (!paths || (p->item->object.flags & TREECHANGE))
388
+ nr++;
389
p = p->next;
390
}
391
closest = 0;
392
best = list;
393
391
- p = list;
392
- while (p) {
393
- int distance = count_distance(p);
394
+ for (p = list; p; p = p->next) {
395
+ int distance;
396
+
397
+ if (paths && !(p->item->object.flags & TREECHANGE))
398
+ continue;
399
+
400
+ distance = count_distance(p);
401
clear_distance(list);
402
if (nr - distance < distance)
403
distance = nr - distance;
@@ -398,7 +405,6 @@ static struct commit_list *find_bisection(struct commit_list *list)
405
best = p;
406
closest = distance;
407
}
401
- p = p->next;
408
}
409
if (best)
410
best->next = NULL;