From: Dirk Wallenstein <halsmit@t-online.de>
To: git@vger.kernel.org
Cc: Dirk Wallenstein <halsmit@t-online.de>
Subject: [PATCH 0/3] git-branch-head: recognize all refs pointing to the current branch head as such
Date: Wed, 25 Feb 2009 11:17:17 +0100 [thread overview]
Message-ID: <cover.1235499771.git.halsmit@t-online.de> (raw)
With git-show-branch I would like to specify "HEAD" or "<branchname>" on
the command line and have it flagged with '*'. A prerequisite for this
is that multiple columns can be flagged with '*'.
That is what the first patch does.
Currently the following is true:
* if you have a detached head and specify "HEAD" it is flagged with '*'
* on a branch, the only ref argument that is flagged with '*' is the
name of the branch (like "master"), and not 'HEAD' nor `git rev-parse HEAD`.
* no arguments (neither heads nor non-heads) are reduced to only one ref if
they point to the same object (except for identical refs)
The only problem of a sha1-only based solution for branch head determination
(comparing the sha1 of the current head and the specified ref) that I can
think about is that, if some other branch head shares the sha1 of the current
branch head (immediately after creation), one could name the other branch and
it would be flagged as current branch head.
If that is too much of a problem, I propose an exceptions for the case when
exactly "HEAD" is specified, and optionally if a sha1 is specified and matches
head (`git rev-parse HEAD`). To not mix up different solutions in the
posted patches I go with the sha1-only based proposal.
That is the second patch.
Maybe, with a detached head, nothing should be flagged as branch head.
If that is the case, the problem seems to be the retval from resolve_ref(),
which returns its argument unmodified if called with "HEAD" (and not NULL).
A local fix for that is in the third patch, which simply checks for that case.
The switch '--current' uses rev_is_head() to find out if the branchname has
been specified on the command line, and adds such a column if not. That seems
alright, as with this patch, you can now easily spot all columns that refer to
the branch head.
Some example calls of rev_is_head() while being on branch "callDemo":
Normal:
head=refs/heads/callDemo ; headlen=19 ; name=HEAD ; head_sha1=968d629 ; sha1=968d629
head=refs/heads/callDemo ; headlen=19 ; name=callDemo ; head_sha1=968d629 ; sha1=968d629
With '--current' (this adds a "<branchname>" column if it is not specified on the command line) :
head=refs/heads/callDemo ; headlen=19 ; name=HEAD ; head_sha1=968d629 ; sha1=<none>
head=refs/heads/callDemo ; headlen=19 ; name=callDemo ; head_sha1=968d629 ; sha1=<none>
With a detached head, with and without '--current' (without the third patch of
this thread. With that patch, head is a pointer to an empty string):
head=HEAD ; headlen=4 ; name=HEAD ; head_sha1=14706b5 ; sha1=<none>
head=HEAD ; headlen=4 ; name=HEAD ; head_sha1=14706b5 ; sha1=14706b5
head=HEAD ; headlen=4 ; name=callDemo ; head_sha1=14706b5 ; sha1=968d629
And an example of what would be the outcome of these patches while being on
branch "sha1BasedOnly":
git (sha1BasedOnly) $ ./git-show-branch --current HEAD^^ HEAD HEAD^ `git rev-parse HEAD` master
! [HEAD^^] git-show-branch: allow for multiple branch head columns
* [HEAD] git-show-branch: avoid any column to be flagged as branch head if head is detached
! [HEAD^] git-show-branch: sha1 based branch head determination
* [8e3c6fcd00a6a809bf1cca383a09c8d077c945d6] git-show-branch: avoid any column to be flagged as branch head if head is detached
! [master] Merge branch 'for-junio' of git://source.winehq.org/~julliard/git/git
* [sha1BasedOnly] git-show-branch: avoid any column to be flagged as branch head if head is detached
------
* * * [HEAD] git-show-branch: avoid any column to be flagged as branch head if head is detached
*+* * [HEAD^] git-show-branch: sha1 based branch head determination
+*+* * [HEAD^^] git-show-branch: allow for multiple branch head columns
------ [master] Merge branch 'for-junio' of git://source.winehq.org/~julliard/git/git
Dirk Wallenstein (3):
git-show-branch: allow for multiple branch head columns
git-show-branch: sha1 based branch head determination
git-show-branch: avoid any column to be flagged as branch head if
head is detached
builtin-show-branch.c | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
next reply other threads:[~2009-02-25 10:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-25 10:17 Dirk Wallenstein [this message]
2009-02-25 10:17 ` [PATCH 1/3] git-show-branch: allow for multiple branch head columns Dirk Wallenstein
2009-02-25 10:17 ` [PATCH 2/3] git-show-branch: sha1 based branch head determination Dirk Wallenstein
2009-02-25 10:17 ` [PATCH 3/3] git-show-branch: avoid any column to be flagged as branch head if head is detached Dirk Wallenstein
2009-02-25 10:29 ` [PATCH 0/3] git-branch-head: recognize all refs pointing to the current branch head as such (Ah! topic is supposed to be git-show-branch:) Halsmit
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=cover.1235499771.git.halsmit@t-online.de \
--to=halsmit@t-online.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).