Skip to content

parse_branchname_arg(): make code easier to understand

Alexandr Miloslavskiy via GitGitGadget git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5parse_branchname_arg(): fix dash_dash_pos, drop argcountbuiltin/checkout.c+14 -202 replies
2/5parse_branchname_arg(): introduce expect_commit_onlybuiltin/checkout.c+9 -62 replies
3/5parse_branchname_arg(): update code commentsbuiltin/checkout.c+21 -650 replies
4/5parse_branchname_arg(): refactor the decision makingbuiltin/checkout.c+42 -290 replies
5/5t2024: cover more casest/t2024-checkout-dwim.sh+27 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] parse_branchname_arg(): make code easier to understand

My bigger goal is to complete my --pathspec-from-file series of patches.

For this, I needed to evaluate whether parse_branchname_arg() heuristics needs any changes when pathspec is passed, but NOT in args.

I found it surprisingly hard to reason about the code in this function. This mostly happens due to "obfuscated" variables, where they have a clear name and a different actual meaning. Ultimately, it was hard to mentally expand them to true meaning AND see all possible combinations of branches at once.

I have split this refactoring in 4 patches, so that diffs are not too big in every single patch.

To my understanding, there should be no changes in git's behavior, except for a couple better die() messages.

Alexandr Miloslavskiy (5):
parse_branchname_arg(): fix dash_dash_pos, drop argcount parse_branchname_arg(): introduce expect_commit_only parse_branchname_arg(): update code comments parse_branchname_arg(): refactor the decision making
t2024: cover more cases

 builtin/checkout.c       | 174 ++++++++++++++++-----------------------
 t/t2024-checkout-dwim.sh |  27 ++++++
 2 files changed, 97 insertions(+), 104 deletions(-)

base-commit: d9f6f3b6195a0ca35642561e530798ad1469bd41
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-479%2FSyntevoAlex%2F%230225(git)_refactor_parse_branchname_arg-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-479/SyntevoAlex/#0225(git)_refactor_parse_branchname_arg-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/479

Signature · 1 line
gitgitgadget