Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Daniels Umanovskis
On 10/12/18 12:56 AM, SZEDER Gábor wrote: > Ah, OK, just noticed v3 which has already fixed this. > Yeah - squashed the wrong commits locally for v2. Thanks for pointing this out anyway!

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread SZEDER Gábor
On Fri, Oct 12, 2018 at 12:53:26AM +0200, SZEDER Gábor wrote: > On Wed, Oct 10, 2018 at 10:54:32PM +0200, Daniels Umanovskis wrote: > > [...] > > > diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh > > index ee6787614..e9bc3b05f 100755 > > --- a/t/t3203-branch-output.sh > > +++ b/t

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread SZEDER Gábor
On Wed, Oct 10, 2018 at 10:54:32PM +0200, Daniels Umanovskis wrote: [...] > diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh > index ee6787614..e9bc3b05f 100755 > --- a/t/t3203-branch-output.sh > +++ b/t/t3203-branch-output.sh > @@ -100,6 +100,47 @@ test_expect_success 'git branch

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Rafael Ascensão
On Thu, Oct 11, 2018 at 04:53:23PM -0400, Jeff King wrote: > Right, I like that part. It's just that putting "HEAD" there already has > a meaning: it would find refs/heads/HEAD. > > Now I'll grant that's a bad name for a branch (and the source of other > confusions, and I think perhaps even someth

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Jeff King
On Thu, Oct 11, 2018 at 09:35:28PM +0100, Rafael Ascensão wrote: > On Thu, Oct 11, 2018 at 01:51:36PM -0400, Jeff King wrote: > > Yeah, I agree. > > Not sure which parts you meant, so I'll assume you didn't agree > with me. Correct. ;) I like your general idea, but I agree with Daniel that it i

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Daniels Umanovskis
On 10/11/18 10:35 PM, Rafael Ascensão wrote: > The output of the proposed command is also a bit inconsistent with the > usual output given by git branch, specifically the space alignment on > the left, color and * marker. The proposed command therefore takes a new switch. It's definitely not perfe

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Rafael Ascensão
On Thu, Oct 11, 2018 at 06:36:02PM +0200, Daniels Umanovskis wrote: > I am not a fan because it would be yet another inconsistency in the Git > command interface. The output of the proposed command is also a bit inconsistent with the usual output given by git branch, specifically the space alignme

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Jeff King
On Thu, Oct 11, 2018 at 07:29:58PM +0200, Daniels Umanovskis wrote: > > Without passing the &flag argument, I do not think there is a > > reliable way to ask resolve_ref_unsafe() if "HEAD" is a symbolic > > ref. > > If I'm reading the code correctly, resolve_ref_unsafe() will return > "HEAD" or N

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Jeff King
On Thu, Oct 11, 2018 at 06:36:02PM +0200, Daniels Umanovskis wrote: > On 10/11/18 5:43 PM, Rafael Ascensão wrote: > > I agree it feels a bit out of place, and still think that > > > > $ git branch --list HEAD > > > > would be a good candidate to be taught how to print the current branch. >

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Daniels Umanovskis
On 10/11/18 8:54 AM, Junio C Hamano wrote: > Is it a normal situation to have refname==NULL, or is it something > worth reporting as an error? Looks like that would be in the case of looping symrefs or file backend failure, so seems a good idea to die() in that case. > Without passing the &flag a

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Daniels Umanovskis
On 10/11/18 5:43 PM, Rafael Ascensão wrote: > I agree it feels a bit out of place, and still think that > > $ git branch --list HEAD > > would be a good candidate to be taught how to print the current branch. I am not a fan because it would be yet another inconsistency in the Git command int

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-11 Thread Rafael Ascensão
On Wed, Oct 10, 2018 at 08:34:40PM -0400, Jeff King wrote: > It just seems like in its current form it might be in an uncanny valley > where it is not quite scriptable plumbing, but not as informative as > other porcelain. I agree it feels a bit out of place, and still think that $ git branch

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-10 Thread Junio C Hamano
Daniels Umanovskis writes: > +static void print_current_branch_name() > +{ > + const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, NULL); > + const char *shortname; > + if (refname == NULL || !strcmp(refname, "HEAD")) > + return; Is it a normal situation to have ref

Re: [PATCH v2 1/1] branch: introduce --show-current display option

2018-10-10 Thread Jeff King
On Wed, Oct 10, 2018 at 10:54:32PM +0200, Daniels Umanovskis wrote: > When called with --show-current, git branch will print the current > branch name and terminate. Only the actual name gets printed, > without refs/heads. In detached HEAD state, nothing is output. I also wondered what happens in

[PATCH v2 1/1] branch: introduce --show-current display option

2018-10-10 Thread Daniels Umanovskis
When called with --show-current, git branch will print the current branch name and terminate. Only the actual name gets printed, without refs/heads. In detached HEAD state, nothing is output. Intended both for scripting and interactive/informative use. Unlike git branch --list, no filtering is nee