Re: [PATCH 3/4] branch: add --dry-run option to branch
flat view
From: Glen Choo <hidden>
Date: 2021-11-23 18:42:27
Ævar Arnfjörð Bjarmason [off-list ref] writes:
On Mon, Nov 22 2021, Glen Choo wrote:quoted
Add a --dry-run option to branch creation that can check whether or not a branch name and start point would be valid for a repository without creating a branch. Refactor cmd_branch() to make the chosen action more obvious. [...] -'git branch' [--track | --no-track] [-f] <branchname> [<start-point>] +'git branch' [--track | --no-track] [-f] [--dry-run | -n] <branchname> [<start-point>] 'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>] 'git branch' --unset-upstream [<branchname>] 'git branch' (-m | -M) [<oldbranch>] <newbranch>@@ -205,6 +205,12 @@ This option is only applicable in non-verbose mode. --no-abbrev:: Display the full sha1s in the output listing rather than abbreviating them. +-n:: +--dry-run:: + Can only be used when creating a branch. If the branch creation + would fail, show the relevant error message. If the branch + creation would succeed, show nothing. +The usage & test show that we've got --dry-run for branch creation, but not the "creation" we do on --copy or --move.
Perhaps this is more of a wording issue i.e. 'creating a branch' is too unspecific. Maybe Can only be used when creating a new branch (without copying or moving an existing branch). If the branch creation would fail, show the relevant error message. If the branch creation would succeed, show nothing.
In any case, any reason to leave those out?
No long term reason. I left those out because "create brand new branch with --dry-run" was needed right now, but the others are not. For consistency, we'd want --dry-run for all other actions, including copy, move, delete, etc.