[PATCH v2 3/4] status: show more info than "currently not on any branch"

2013-03-06 Thread Nguyễn Thái Ngọc Duy
When a remote ref or a tag is checked out, HEAD is automatically detached. There is no user-friendly way to find out what ref is checked out in this case. This patch digs in reflog for this information and shows "HEAD detached from origin/master" or "HEAD detached at v1.8.0" instead of "currently n

Re: [PATCH v2 3/4] status: show more info than "currently not on any branch"

2013-03-06 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy writes: > +static void wt_status_get_detached_from(struct wt_status_state *state) > +{ > + struct grab_1st_switch_cbdata cb; > + struct commit *commit; > + unsigned char sha1[20]; > + char *ref = NULL; > + > + strbuf_init(&cb.buf, 0); > + if (for_each

Re: [PATCH v2 3/4] status: show more info than "currently not on any branch"

2013-03-08 Thread Duy Nguyen
On Thu, Mar 7, 2013 at 2:16 AM, Junio C Hamano wrote: > Nguyễn Thái Ngọc Duy writes: > >> +static void wt_status_get_detached_from(struct wt_status_state *state) >> +{ >> + struct grab_1st_switch_cbdata cb; >> + struct commit *commit; >> + unsigned char sha1[20]; >> + char *ref =

Re: [PATCH v2 3/4] status: show more info than "currently not on any branch"

2013-03-08 Thread Junio C Hamano
Duy Nguyen writes: >> It should be more like this, I would think: >> >> for_each_recent_reflog_ent(); >> if (!found) >> for_each_reflog_ent(); >> if (!found) >> return; > > Yes. This "recent" optimization is tricky. Not really. What is tri