Re: [PATCH 0/2] branch: introduce --current display option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniels Umanovskis <daniels@xxxxxxxxxxxxx> writes:

> I often find myself needing the current branch name, for which
> currently there's git rev-parse --abrev-ref HEAD. I would expect
> `git branch` to have an option to output the branch name instead.

[jc:  wrapped an overlong line]

If "git branch" had many operations that work on multiple branches
by default, and we were adding an option to work on a single branch
that is currently checked out, then I would find "--current" is a
very good name for an option that turns all these operations to work
only on the one that is currently checked out.

But I do not think that is what is going on.  There is "--list" that
lists branches whose name match given patterns, and at the end-user
level (I haven't seen the implementation) this is another mode of
that operation that limits itself to the one that is currently
checked out, and you do not even allowed to give the "--list" option
explicitly so that in the future when "git branch" learns to perform
an operation other than "list" (let's call it 'distim') to bunch of
branches by default, you cannot say "git --distim --current" to
limit the distimming to the branch that you are currently on.

I do not offhand know if we want "show the current one only" option
that is "command mode" sitting next to "list", "delete", "rename"
etc., or "limit the operation to the one that is currently cheked
out".  If we want the former, the name of the option must *NOT* be
just "current".  Have a verb in its name to avoid it from getting
mistaken as a botched attempt to do the latter.  Somethng like
"--show-current", "--list-current", "--display-current", etc.

Even if we were doing the latter (i.e. focused "this is only for
listing/showing"), if we do not want to close the door to later
extend the concept of "current" to the former (i.e. "--show-current"
becomes a convenience synonym for "--list --current-only") we also
need to think about what to do with the detached HEAD state.  When
the concept of "current" is extended to become "usually an operation
can work on multiple branches but we are limiting it to the current
one", detached HEAD state is conceptually "not having any current
branch".  We could fail the operation (i.e. you told me to distim
the branch but there is no such branch) or make it a silent no-op
(i.e. you told me to distim no branch, so nothing happened and there
is no error).

My inclination is to recommend to:

 (1) name the "show the current one" not "--current" but with some
     verb

 (2) display nothing when there is no current branch (i.e. detached
     HEAD) and without any error.








[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux