Re: [PATCH v3 3/5] builtin/branch: clean up action-picking logic in cmd_branch()
flat view
From: Jonathan Tan <hidden>
Date: 2021-12-09 21:23:26
Glen Choo [off-list ref] writes:
Incidentally, fix an incorrect usage string that combined the 'list' usage of git branch (-l) with the 'create' usage; this string has been incorrect since its inception, a8dfd5eac4 (Make builtin-branch.c use parse_options., 2007-10-07).
I think that we implement such incidental fixes only when we're touching the relevant lines, but this change looks correct.
quoted hunk ↗ jump to hunk
- int delete = 0, rename = 0, copy = 0, force = 0, list = 0; - int show_current = 0; - int reflog = 0, edit_description = 0; - int quiet = 0, unset_upstream = 0; + /* possible actions */ + int delete = 0, rename = 0, copy = 0, force = 0, list = 0, + unset_upstream = 0, show_current = 0, edit_description = 0; + int noncreate_actions = 0; + /* possible options */ + int reflog = 0, quiet = 0, icase = 0;
[snip]
quoted hunk ↗ jump to hunk
- if (!!delete + !!rename + !!copy + !!new_upstream + !!show_current + - list + edit_description + unset_upstream > 1) + noncreate_actions = !!delete + !!rename + !!copy + !!new_upstream + + !!show_current + !!list + !!edit_description + + !!unset_upstream; + if (noncreate_actions > 1) usage_with_options(builtin_branch_usage, options);
Overall this change looks good, although if you're going to rearrange the variable declarations (e.g. the positions of show_current, edit_description, and unset_upstream have moved), you might as well make them consistent with the noncreate_actions statement, I guess. Also maybe move new_upstream closer.