git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
AGAlexandr Miloslavskiy via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 28, 2019, 19:32 UTC
Message-ID
<pull.479.git.1574969538.gitgitgadget@gmail.com>
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
-- 
gitgitgadget
Next: Alexandr Miloslavskiy via GitGitGadget
Message 1 of 10 in “parse_branchname_arg(): make code easier to understand”
  1. 0/5 parse_branchname_arg(): make code easier to understandAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  2. 1/5 parse_branchname_arg(): fix dash_dash_pos, drop argcountAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  3. Junio C HamanoDec 18, 2019
  4. Alexandr MiloslavskiyDec 19, 2019
  5. 2/5 parse_branchname_arg(): introduce expect_commit_onlyAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  6. Junio C HamanoDec 18, 2019
  7. Alexandr MiloslavskiyDec 19, 2019
  8. 5/5 t2024: cover more casesAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  9. 4/5 parse_branchname_arg(): refactor the decision makingAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  10. 3/5 parse_branchname_arg(): update code commentsAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.