Re: [PATCH] branch_get_push: do not segfault when HEAD is detached

2017-01-09 Thread Junio C Hamano
Jeff King writes: > On Fri, Jan 06, 2017 at 08:19:53PM -0500, Kyle Meyer wrote: > >> > The other option is just "git checkout --detach", which is also used in >> > the test suite. I tend to prefer it because it's a little more obvious >> > to a reader. >> >> True, that does seem clearer. Seems

Re: [PATCH] branch_get_push: do not segfault when HEAD is detached

2017-01-06 Thread Jeff King
On Fri, Jan 06, 2017 at 08:19:53PM -0500, Kyle Meyer wrote: > > The other option is just "git checkout --detach", which is also used in > > the test suite. I tend to prefer it because it's a little more obvious > > to a reader. > > True, that does seem clearer. Seems I should've waited a bit bef

Re: [PATCH] branch_get_push: do not segfault when HEAD is detached

2017-01-06 Thread Kyle Meyer
Jeff King writes: > On Fri, Jan 06, 2017 at 08:09:32PM -0500, Kyle Meyer wrote: > >> > $ git grep -c HEAD^{} junio/pu -- t/ >> > junio/pu:t/t3200-branch.sh:3 >> > >> > Maybe use HEAD^0 just for consistency? >> >> Yes, thanks for pointing that out. > > The other option is just "git checkout --deta

Re: [PATCH] branch_get_push: do not segfault when HEAD is detached

2017-01-06 Thread Jeff King
On Fri, Jan 06, 2017 at 08:09:32PM -0500, Kyle Meyer wrote: > > $ git grep -c HEAD^{} junio/pu -- t/ > > junio/pu:t/t3200-branch.sh:3 > > > > Maybe use HEAD^0 just for consistency? > > Yes, thanks for pointing that out. The other option is just "git checkout --detach", which is also used in the

Re: [PATCH] branch_get_push: do not segfault when HEAD is detached

2017-01-06 Thread Kyle Meyer
Johannes Schindelin writes: [...] >> +test_expect_success 'resolving @{push} fails with a detached HEAD' ' >> +git checkout HEAD^{} && > > I seem to recall that we prefer HEAD^0 over HEAD^{} and the existing > scripts seem to agree with me: > > $ git grep -c HEAD^0 junio/pu -- t/ > junio/pu:

Re: [PATCH] branch_get_push: do not segfault when HEAD is detached

2017-01-06 Thread Johannes Schindelin
Hi Kyle, On Thu, 5 Jan 2017, Kyle Meyer wrote: > Move the detached HEAD check from branch_get_push_1() to > branch_get_push() to avoid setting branch->push_tracking_ref when > branch is NULL. > > Signed-off-by: Kyle Meyer Good point. > diff --git a/remote.c b/remote.c > index ad6c5424e..d5eae

Re: [PATCH] branch_get_push: do not segfault when HEAD is detached

2017-01-05 Thread Jeff King
On Thu, Jan 05, 2017 at 11:56:23PM -0500, Kyle Meyer wrote: > Move the detached HEAD check from branch_get_push_1() to > branch_get_push() to avoid setting branch->push_tracking_ref when > branch is NULL. Yep, I think this is the right fix. > diff --git a/t/t1514-rev-parse-push.sh b/t/t1514-rev-

[PATCH] branch_get_push: do not segfault when HEAD is detached

2017-01-05 Thread Kyle Meyer
Move the detached HEAD check from branch_get_push_1() to branch_get_push() to avoid setting branch->push_tracking_ref when branch is NULL. Signed-off-by: Kyle Meyer --- remote.c | 6 +++--- t/t1514-rev-parse-push.sh | 6 ++ 2 files changed, 9 insertions(+), 3 deletions(-) d