Message ID | 6e1c3f2c5816f09aab561bc7dec2b7455d70aaec.1708087213.git.dsimic@manjaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] branch: rework the descriptions of rename and copy operations | expand |
Dragan Simic <dsimic@manjaro.org> writes: > Move the descriptions of the <oldbranch> and <newbranch> arguments to the > descriptions of the branch rename and copy operations, where they naturally > belong. Also, improve the descriptions of these two branch operations and, > for completeness, describe the outcomes of forced operations. > > Describing the arguments together with their respective operations, instead > of describing them separately in a rather unfortunate attempt to squeeze more > meaning out of fewer words, flows much better and makes the git-branch(1) > man page significantly more usable. The intention to remove non-option from the OPTIONS enumeration, and to explain <new> and <old> used as arguments to -m and -c where these options are described, are both very good (heh, after all, they are parts of what I envisioned to be the way to go in the longer term ;-). > overridden by using the `--track` and `--no-track` options, and > changed later using `git branch --set-upstream-to`. > > -With a `-m` or `-M` option, <oldbranch> will be renamed to <newbranch>. > -If <oldbranch> had a corresponding reflog, it is renamed to match > -<newbranch>, and a reflog entry is created to remember the branch > -renaming. If <newbranch> exists, -M must be used to force the rename > -to happen. > - > -The `-c` and `-C` options have the exact same semantics as `-m` and > -`-M`, except instead of the branch being renamed, it will be copied to a > -new name, along with its config and reflog. > - > With a `-d` or `-D` option, `<branchname>` will be deleted. You may > specify more than one branch for deletion. If the branch currently > has a reflog then the reflog will also be deleted. But the halfway modification to the description section in this patch is not an improvement. It makes some options described there while -m and -c are completely missing now, making the section incomplete and coverage of the operating modes of the command uneven. > +-m [<oldbranch>] <newbranch>:: > +--move [<oldbranch>] <newbranch>:: > + Rename an existing branch `<oldbranch>` to `<newbranch>`; if left > + unspecified, `<oldbranch>` defaults to the current branch. The > + configuration variables for the `<oldbranch>` branch and its reflog > + are also renamed appropriately to be used with `<newbranch>`. In > + addition, a reflog entry is created to remember the branch renaming. > + Renaming fails if branch `<newbranch>` already exists, but `-M` > + or `--move --force` can be used to overwrite the contents of the > + existing branch `<newbranch>` while renaming. OK. This is way more readable than the previous attempts we made. The description of the single failure mode still worries me (see my previous message on this). Here is my attempt: When the command fails due to an existing '<newbranch>', you can use `-M` (or `--move --force`) to force overwriting it. to hint that there may be other ways for the command to fail, and hint that `-M` may not always resolve issues, but I do not know how successful it is. I could add Note that `-M <old> <new>` will not resolve an error if the reason why `-m` fails is to protect the other worktree that checks out (or otherwise uses) <old> and <new> points at a different commit. but we do not necessarily want to appear to be exhaustive here, so, I dunno. > +-M [<oldbranch>] <newbranch>:: > Shortcut for `--move --force`. OK. > +--copy [<oldbranch>] <newbranch>:: > + Copy an existing branch `<oldbranch>` to `<newbranch>`; if left > + unspecified, `<oldbranch>` defaults to the current branch. The > + configuration variables for the `<oldbranch>` branch and its reflog > + are also copied appropriately to be used with `<newbranch>`. > + Copying fails if branch `<newbranch>` already exists, but `-C` > + or `--copy --force` can be used to overwrite the contents of the > + existing branch `<newbranch>` while copying. Exactly the same comment on "other failure modes" applies here. > -<oldbranch>:: > - The name of an existing branch. If this option is omitted, > - the name of the current branch will be used instead. > - > -<newbranch>:: > - The new name for an existing branch. The same restrictions as for > - <branchname> apply. > - Removals of these lines are very pleasing ;-).
Hello Junio, On 2024-02-16 20:59, Junio C Hamano wrote: > Dragan Simic <dsimic@manjaro.org> writes: > >> Move the descriptions of the <oldbranch> and <newbranch> arguments to >> the >> descriptions of the branch rename and copy operations, where they >> naturally >> belong. Also, improve the descriptions of these two branch operations >> and, >> for completeness, describe the outcomes of forced operations. >> >> Describing the arguments together with their respective operations, >> instead >> of describing them separately in a rather unfortunate attempt to >> squeeze more >> meaning out of fewer words, flows much better and makes the >> git-branch(1) >> man page significantly more usable. > > The intention to remove non-option from the OPTIONS enumeration, > and to explain <new> and <old> used as arguments to -m and -c where > these options are described, are both very good (heh, after all, > they are parts of what I envisioned to be the way to go in the > longer term ;-). Yes, that's what I plan to work on after this patch is, hopefully, accepted (see also below). My initial hope was that we'd define the general outline for the completely reworked git-branch(1) even further with this patch, which should in turn make the future work more efficient. I think we're on a good way. :) >> overridden by using the `--track` and `--no-track` options, and >> changed later using `git branch --set-upstream-to`. >> >> -With a `-m` or `-M` option, <oldbranch> will be renamed to >> <newbranch>. >> -If <oldbranch> had a corresponding reflog, it is renamed to match >> -<newbranch>, and a reflog entry is created to remember the branch >> -renaming. If <newbranch> exists, -M must be used to force the rename >> -to happen. >> - >> -The `-c` and `-C` options have the exact same semantics as `-m` and >> -`-M`, except instead of the branch being renamed, it will be copied >> to a >> -new name, along with its config and reflog. >> - >> With a `-d` or `-D` option, `<branchname>` will be deleted. You may >> specify more than one branch for deletion. If the branch currently >> has a reflog then the reflog will also be deleted. > > But the halfway modification to the description section in this > patch is not an improvement. It makes some options described there > while -m and -c are completely missing now, making the section > incomplete and coverage of the operating modes of the command > uneven. If I got it right, you'd prefer this patch not to be accepted separately, but as part of the future series that would rework the entire git-branch(1) man page? I'm fine with that as well. >> +-m [<oldbranch>] <newbranch>:: >> +--move [<oldbranch>] <newbranch>:: >> + Rename an existing branch `<oldbranch>` to `<newbranch>`; if left >> + unspecified, `<oldbranch>` defaults to the current branch. The >> + configuration variables for the `<oldbranch>` branch and its reflog >> + are also renamed appropriately to be used with `<newbranch>`. In >> + addition, a reflog entry is created to remember the branch renaming. >> + Renaming fails if branch `<newbranch>` already exists, but `-M` >> + or `--move --force` can be used to overwrite the contents of the >> + existing branch `<newbranch>` while renaming. > > OK. This is way more readable than the previous attempts we made. > > The description of the single failure mode still worries me (see my > previous message on this). Here is my attempt: > > When the command fails due to an existing '<newbranch>', you > can use `-M` (or `--move --force`) to force overwriting it. > > to hint that there may be other ways for the command to fail, and > hint that `-M` may not always resolve issues, but I do not know how > successful it is. I could add Makes sense. It's intentionally a bit vague, but should work fine. I'd just replace "the command" with "renaming", and avoid addressing the reader directly. > Note that `-M <old> <new>` will not resolve an error if the > reason why `-m` fails is to protect the other worktree that > checks out (or otherwise uses) <old> and <new> points at a > different commit. > > but we do not necessarily want to appear to be exhaustive here, so, > I dunno. Huh-uh... I'm not sure that such an exhaustive explanation would make it more clear to the majority of users. Perhaps it's better to remain a bit vague, at least for now, and omit such details. >> +-M [<oldbranch>] <newbranch>:: >> Shortcut for `--move --force`. > > OK. > >> +--copy [<oldbranch>] <newbranch>:: >> + Copy an existing branch `<oldbranch>` to `<newbranch>`; if left >> + unspecified, `<oldbranch>` defaults to the current branch. The >> + configuration variables for the `<oldbranch>` branch and its reflog >> + are also copied appropriately to be used with `<newbranch>`. >> + Copying fails if branch `<newbranch>` already exists, but `-C` >> + or `--copy --force` can be used to overwrite the contents of the >> + existing branch `<newbranch>` while copying. > > Exactly the same comment on "other failure modes" applies here. Noted. >> -<oldbranch>:: >> - The name of an existing branch. If this option is omitted, >> - the name of the current branch will be used instead. >> - >> -<newbranch>:: >> - The new name for an existing branch. The same restrictions as for >> - <branchname> apply. >> - > > Removals of these lines are very pleasing ;-). Oh yes, it's like a clear embodiment of making the current mess a little bit smaller. :)
Dragan Simic <dsimic@manjaro.org> writes: >> But the halfway modification to the description section in this >> patch is not an improvement. It makes some options described there >> while -m and -c are completely missing now, making the section >> incomplete and coverage of the operating modes of the command >> uneven. > > If I got it right, you'd prefer this patch not to be accepted > separately, but as part of the future series that would rework the > entire git-branch(1) man page? I'm fine with that as well. Not necessarily. If you wanted to this this in multiple steps, we can first whip the OPTIONS part into a good shape, and then fix the DESCRIPTION part. What we want to avoid (not limited to this topic) is to say "this temporarily makes things worse here, but trust me it will eventually become perfect". Removing only -m/-c from the description section makes the description section worse than before the patch---we'd be better off leaving the original as-is if we are not revamping the entire section.
On 2024-02-16 22:45, Junio C Hamano wrote: > Dragan Simic <dsimic@manjaro.org> writes: > >>> But the halfway modification to the description section in this >>> patch is not an improvement. It makes some options described there >>> while -m and -c are completely missing now, making the section >>> incomplete and coverage of the operating modes of the command >>> uneven. >> >> If I got it right, you'd prefer this patch not to be accepted >> separately, but as part of the future series that would rework the >> entire git-branch(1) man page? I'm fine with that as well. > > Not necessarily. If you wanted to this this in multiple steps, we > can first whip the OPTIONS part into a good shape, and then fix the > DESCRIPTION part. I'll think a bit more about it, to see what might be our best choice moving forward. > What we want to avoid (not limited to this topic) is to say "this > temporarily makes things worse here, but trust me it will eventually > become perfect". Removing only -m/-c from the description section > makes the description section worse than before the patch---we'd be > better off leaving the original as-is if we are not revamping the > entire section. The way you wrote this brought a smile to my face. :) I agree, making things a bit worse while promising perfection later is rarely justified. Perhaps only when some nasty bug has to be fixed ASAP.
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 0b0844293235..d52b5e8dbacd 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -72,16 +72,6 @@ the remote-tracking branch. This behavior may be changed via the global overridden by using the `--track` and `--no-track` options, and changed later using `git branch --set-upstream-to`. -With a `-m` or `-M` option, <oldbranch> will be renamed to <newbranch>. -If <oldbranch> had a corresponding reflog, it is renamed to match -<newbranch>, and a reflog entry is created to remember the branch -renaming. If <newbranch> exists, -M must be used to force the rename -to happen. - -The `-c` and `-C` options have the exact same semantics as `-m` and -`-M`, except instead of the branch being renamed, it will be copied to a -new name, along with its config and reflog. - With a `-d` or `-D` option, `<branchname>` will be deleted. You may specify more than one branch for deletion. If the branch currently has a reflog then the reflog will also be deleted. @@ -128,18 +118,31 @@ Note that 'git branch -f <branchname> [<start-point>]', even with '-f', refuses to change an existing branch `<branchname>` that is checked out in another worktree linked to the same repository. --m:: ---move:: - Move/rename a branch, together with its config and reflog. - --M:: +-m [<oldbranch>] <newbranch>:: +--move [<oldbranch>] <newbranch>:: + Rename an existing branch `<oldbranch>` to `<newbranch>`; if left + unspecified, `<oldbranch>` defaults to the current branch. The + configuration variables for the `<oldbranch>` branch and its reflog + are also renamed appropriately to be used with `<newbranch>`. In + addition, a reflog entry is created to remember the branch renaming. + Renaming fails if branch `<newbranch>` already exists, but `-M` + or `--move --force` can be used to overwrite the contents of the + existing branch `<newbranch>` while renaming. + +-M [<oldbranch>] <newbranch>:: Shortcut for `--move --force`. --c:: ---copy:: - Copy a branch, together with its config and reflog. - --C:: +-c [<oldbranch>] <newbranch>:: +--copy [<oldbranch>] <newbranch>:: + Copy an existing branch `<oldbranch>` to `<newbranch>`; if left + unspecified, `<oldbranch>` defaults to the current branch. The + configuration variables for the `<oldbranch>` branch and its reflog + are also copied appropriately to be used with `<newbranch>`. + Copying fails if branch `<newbranch>` already exists, but `-C` + or `--copy --force` can be used to overwrite the contents of the + existing branch `<newbranch>` while copying. + +-C [<oldbranch>] <newbranch>:: Shortcut for `--copy --force`. --color[=<when>]:: @@ -311,14 +314,6 @@ superproject's "origin/main", but tracks the submodule's "origin/main". given as a branch name, a commit-id, or a tag. If this option is omitted, the current HEAD will be used instead. -<oldbranch>:: - The name of an existing branch. If this option is omitted, - the name of the current branch will be used instead. - -<newbranch>:: - The new name for an existing branch. The same restrictions as for - <branchname> apply. - --sort=<key>:: Sort based on the key given. Prefix `-` to sort in descending order of the value. You may use the --sort=<key> option
Move the descriptions of the <oldbranch> and <newbranch> arguments to the descriptions of the branch rename and copy operations, where they naturally belong. Also, improve the descriptions of these two branch operations and, for completeness, describe the outcomes of forced operations. Describing the arguments together with their respective operations, instead of describing them separately in a rather unfortunate attempt to squeeze more meaning out of fewer words, flows much better and makes the git-branch(1) man page significantly more usable. The subsequent improvements shall continue this approach by either dissolving as many sentences from the "Description" section into the "Options" section, or by having those sentences converted into some kind of more readable and better flowing prose, as already discussed and outlined. [1][2] [1] https://lore.kernel.org/git/xmqqttmmlahf.fsf@gitster.g/T/#u [2] https://lore.kernel.org/git/xmqq8r4zln08.fsf@gitster.g/T/#u Signed-off-by: Dragan Simic <dsimic@manjaro.org> --- Notes: This patch was originally named "branch: clarify <oldbranch> and <newbranch> terms further", submitted and discussed in another thread, [3] but the nature of the patch has changed, causing the patch subject to be adjusted to match. Consequently, the version 1 is effectively version 2 of the original patch. The version 1 of the patch includes detailed feedback from Kyle and Junio, who suggested moving/adding the argument descriptions to their respective commands. This resulted in more significant changes to the contents of the git-branch(1) man page, in an attempt to make it more readable. The version 2 includes feedback from Kristoffer and Junio, by improving the wording of the opening sentences in the descriptions of branch rename and copy operations, and by mentioning the additional reflog entry created while renaming a branch, which was omitted in the v1 by mistake. [3] https://lore.kernel.org/git/e2eb777bca8ffeec42bdd684837d28dd52cfc9c3.1707136999.git.dsimic@manjaro.org/T/#u Documentation/git-branch.txt | 51 ++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 28 deletions(-)