Skip to content

Commit 3a3106e

Browse files
tamewarecursoragent
andcommitted
Allow --branch . to mean the current branch
Resolve a "." branch argument to the current branch (or HEAD when detached) before ref validation, so it can be compared without naming it explicitly. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b79dd45 commit 3a3106e

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

benchmark.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ Options:
8787
--max-deals N Include list10^n.txt files with 10^n <= N (default: 100; env: MAX_DEALS)
8888
(alias: --max_deals)
8989
--build Build branch dtest only (bazel build //library/tests:dtest)
90-
--branch NAME Git branch to build and compare. Once: compare the current branch
91-
against NAME. Twice (--branch A --branch B): compare A vs B and
92-
ignore the current branch. With --compare PATH: build NAME as the
93-
branch binary and compare it against PATH, ignoring the current
94-
branch. Each branch is checked out, dtest is built and its binary
95-
saved; the original branch is then restored. Requires a clean tree.
90+
--branch NAME Git branch to build and compare ("." means the current branch).
91+
Once: compare the current branch against NAME. Twice (--branch A
92+
--branch B): compare A vs B and ignore the current branch. With
93+
--compare PATH: build NAME as the branch binary and compare it
94+
against PATH, ignoring the current branch. Each branch is checked
95+
out, dtest is built and its binary saved; the original branch is
96+
then restored. Requires a clean tree.
9697
--compare PATH Second dtest binary (summary; transient progress on tty). May be
9798
combined with a single --branch NAME (NAME backs the branch binary).
9899
--details Keep per-run timing rows and build (git/bazel) output
@@ -272,6 +273,18 @@ setup_branches() {
272273
echo "error: --branch requires a git work tree at $ROOT" >&2
273274
exit 1
274275
fi
276+
277+
ORIG_BRANCH="$(git -C "$ROOT" symbolic-ref --quiet --short HEAD 2>/dev/null \
278+
|| git -C "$ROOT" rev-parse HEAD)"
279+
280+
# "." is shorthand for the current branch.
281+
local i
282+
for i in "${!BRANCH_NAMES[@]}"; do
283+
if [[ "${BRANCH_NAMES[$i]}" == "." ]]; then
284+
BRANCH_NAMES[$i]="$ORIG_BRANCH"
285+
fi
286+
done
287+
275288
local name
276289
for name in "${BRANCH_NAMES[@]}"; do
277290
if ! git -C "$ROOT" rev-parse --verify --quiet "$name" >/dev/null; then
@@ -284,9 +297,6 @@ setup_branches() {
284297
exit 1
285298
fi
286299

287-
ORIG_BRANCH="$(git -C "$ROOT" symbolic-ref --quiet --short HEAD 2>/dev/null \
288-
|| git -C "$ROOT" rev-parse HEAD)"
289-
290300
if [[ "$COMPARE_GIVEN" == "1" ]]; then
291301
# --branch NAME --compare PATH: build NAME as the branch binary and keep the
292302
# user-supplied compare path. The current branch's dtest is not used.

0 commit comments

Comments
 (0)