All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCHv2 2/2] branch: name detached HEAD analogous to status
Date: Fri, 06 Mar 2015 12:23:55 -0800	[thread overview]
Message-ID: <xmqqtwxxyiw4.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <0ece5e04a3fb38bdc1201036d65ed98199758ba5.1425653932.git.git@drmicha.warpmail.net> (Michael J. Gruber's message of "Fri, 6 Mar 2015 16:04:07 +0100")

Michael J Gruber <git@drmicha.warpmail.net> writes:

> "git status" carefully names a detached HEAD "at" resp. "from" a rev or
> ref depending on whether the detached HEAD has moved since. "git branch"
> always uses "from", which can be confusing, because a status-aware user
> would interpret this as moved detached HEAD.
>
> Make "git branch" use the same logic and wording.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---
>
> Notes:
>     v2 uses the info from refactored wt-status.
>     
>     In addition, it tries to make sure that branch and status use the same
>     strings:
>     
>     HEAD detached at %s
>     * (HEAD detached at %s)
>     
>     (status first line, branch second line)
>     
>     Unfortunately, status strings are broken into pieces, so this can
>     be achieved by comments only.

It feels somewhat strange to have fields called detached-at and
detached-from in wt_status_state.

With this patch,

    * branch is either a string "HEAD" or the name of the branch we
      are on.

    * detached_from is the name of the branch HEAD detached from,
      or NULL if HEAD is on a branch.

    * detached_sha1[] is the object name of the commit we last
      moved to with "checkout --detach".

    * detached_at is a boolean that says the tip of detached_from
      and detached_sha1[] is the same.

There aren't that many users of these fields, so if we were to
rename them and clarify what they mean in order to make the code
more readable, we may be able to do so without too much churn.

Random conflicting/incoherent thoughts include:

 - perhaps branch can be NULL when detached?

 - perhaps branch can always point at the branch or the current
   detached-from?
 
 - perhaps detached_from can be renamed to make it more clear that
   it is the name of a branch (detached_sha1[] is fine, because it
   is clear what it is by having "sha1" in its name)?

 - perhaps detached_from/detached_at can be made into a single
   string that is set up by wt-status to hold either "HEAD detached
   at %s" or "HEAD detached from %s" to be used by its callers?

but I cannot yet reach a coherent whole to be called a suggestion
for a better organization X-<.

Will replace what was queued with this version.

Thanks.  

  reply	other threads:[~2015-03-06 20:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-22 17:38 [RFC/PATCH] branch: name detached HEAD analogous to status Michael J Gruber
2015-02-22 19:21 ` Junio C Hamano
2015-02-23  8:50   ` Michael J Gruber
2015-02-23 15:21   ` Marc Branchaud
2015-03-06 15:04     ` [PATCHv2 0/2] branch output for detached HEAD Michael J Gruber
2015-03-06 15:04       ` [PATCHv2 1/2] wt-status: refactor detached HEAD analysis Michael J Gruber
2015-03-06 15:04       ` [PATCHv2 2/2] branch: name detached HEAD analogous to status Michael J Gruber
2015-03-06 20:23         ` Junio C Hamano [this message]
2015-02-23 15:12 ` [RFC/PATCH] " Marc Branchaud
2015-02-23 16:24   ` Michael J Gruber
2015-02-23 17:23     ` Marc Branchaud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqtwxxyiw4.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.