You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rtk git branch --form: a long option abbreviation is not read as --format, adding a blank line #5174
rtk git branch --form=<template>, an abbreviation of --format that git accepts, is not read as --format, so the listing goes through the default-layout compaction and comes back with an extra blank line.
Reproduction
D=$(mktemp -d);cd"$D"; git init -q -b main .&& git -c user.name=t -c user.email=t@t commit -q --allow-empty -m init
export LC_ALL=C
git branch --format='%(refname:short)'| od -c # main\n
rtk git branch --format='%(refname:short)'| od -c # main\n (git's bytes)
git branch --form='%(refname:short)'| od -c # main\n
rtk git branch --form='%(refname:short)'| od -c # main\n\n <- extra blank line
Built from develop at 3ab08be (Linux, git 2.53.0).
Mechanism
BRANCH_GRAMMAR in src/cmds/git/git_cmd.rs is declared with Dialect::Posix, which has no unique-prefix abbreviation, so --form is an undeclared flag. It is not a list flag either, so run_branch adds -a and runs filter_branch_output over lines that are the caller's template, not git's default layout.
git's option parser accepts any unambiguous prefix of a long option (--form and --forma work; --for is ambiguous between --force and --format). The same holds for the other git grammars declared with Dialect::Posix, so this is not specific to branch.
Open question
Whether a git grammar should opt into Abbreviation::UniquePrefix. That changes how every git flag token is read, so it wants a pass over each git grammar rather than a one-flag patch. I am offering the work, not asking anyone to take it on.
Activity