From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karthik Nayak Subject: [PATCH v6 2/8] branch: bump get_head_description() to the top Date: Wed, 23 Sep 2015 23:41:07 +0530 Message-ID: <1443031873-25280-3-git-send-email-Karthik.188@gmail.com> References: <1443031873-25280-1-git-send-email-Karthik.188@gmail.com> Cc: christian.couder@gmail.com, Matthieu.Moy@grenoble-inp.fr, gitster@pobox.com, Karthik Nayak , Karthik Nayak To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Wed Sep 23 20:11:43 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZeoW2-0001pw-Tc for gcvg-git-2@plane.gmane.org; Wed, 23 Sep 2015 20:11:39 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753733AbbIWSLX (ORCPT ); Wed, 23 Sep 2015 14:11:23 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:33196 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753509AbbIWSLU (ORCPT ); Wed, 23 Sep 2015 14:11:20 -0400 Received: by pacex6 with SMTP id ex6so47026571pac.0 for ; Wed, 23 Sep 2015 11:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6wIbDE4hX1auiwSwaAxrI36IYV1orklJ85Lr+smr7Ps=; b=zppGbFA5nGgPVyg+BX6b5F3B7pXcWseHoEp9gQ5F8hIsPzL6upEq884durEIuYDy6g 4fzox7go56xv/hOVOm5WgmFJts00oeqKjkuhOj2Mu5Utt80q4pJPY32O0Rg2Cb5/bvCp kl06lMl6vFZt43eCgfWFGe4QtqSytE757NnfL3sgfNRMHjPA4ExN//2seCejaFcq/r9J 8/v/qklYr1bNK+iI5vgBl9dpBdBGb96xcrpOK8ozbJE77BkZQ3wVRjCEVI1pr8vdaC3w Xt9ZjVmMUwP+vuFJm5YgLBJ0GxSD4QVNSWO5PzO3Uvsvej4I1DIf3IPkChZ25Qc0H3gm n/lA== X-Received: by 10.68.68.197 with SMTP id y5mr38889790pbt.88.1443031868897; Wed, 23 Sep 2015 11:11:08 -0700 (PDT) Received: from ashley.localdomain ([106.51.130.23]) by smtp.gmail.com with ESMTPSA id bs3sm9107777pbd.89.2015.09.23.11.11.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Sep 2015 11:11:08 -0700 (PDT) X-Google-Original-From: Karthik Nayak X-Mailer: git-send-email 2.5.1 In-Reply-To: <1443031873-25280-1-git-send-email-Karthik.188@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: This is a preperatory patch for 'roll show_detached HEAD into regular ref_list'. This patch moves get_head_description() to the top so that it can be used in print_ref_item(). Based-on-patch-by: Jeff King Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- builtin/branch.c | 62 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index 28a10d6..193296a 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -497,6 +497,37 @@ static void add_verbose_info(struct strbuf *out, struct ref_item *item, strbuf_release(&subject); } +static char *get_head_description(void) +{ + struct strbuf desc = STRBUF_INIT; + struct wt_status_state state; + memset(&state, 0, sizeof(state)); + wt_status_get_state(&state, 1); + if (state.rebase_in_progress || + state.rebase_interactive_in_progress) + strbuf_addf(&desc, _("(no branch, rebasing %s)"), + state.branch); + else if (state.bisect_in_progress) + strbuf_addf(&desc, _("(no branch, bisect started on %s)"), + state.branch); + else if (state.detached_from) { + /* TRANSLATORS: make sure these match _("HEAD detached at ") + and _("HEAD detached from ") in wt-status.c */ + if (state.detached_at) + strbuf_addf(&desc, _("(HEAD detached at %s)"), + state.detached_from); + else + strbuf_addf(&desc, _("(HEAD detached from %s)"), + state.detached_from); + } + else + strbuf_addstr(&desc, _("(no branch)")); + free(state.branch); + free(state.onto); + free(state.detached_from); + return strbuf_detach(&desc, NULL); +} + static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, int abbrev, int current, const char *remote_prefix) { @@ -570,37 +601,6 @@ static int calc_maxwidth(struct ref_list *refs, int remote_bonus) return max; } -static char *get_head_description(void) -{ - struct strbuf desc = STRBUF_INIT; - struct wt_status_state state; - memset(&state, 0, sizeof(state)); - wt_status_get_state(&state, 1); - if (state.rebase_in_progress || - state.rebase_interactive_in_progress) - strbuf_addf(&desc, _("(no branch, rebasing %s)"), - state.branch); - else if (state.bisect_in_progress) - strbuf_addf(&desc, _("(no branch, bisect started on %s)"), - state.branch); - else if (state.detached_from) { - /* TRANSLATORS: make sure these match _("HEAD detached at ") - and _("HEAD detached from ") in wt-status.c */ - if (state.detached_at) - strbuf_addf(&desc, _("(HEAD detached at %s)"), - state.detached_from); - else - strbuf_addf(&desc, _("(HEAD detached from %s)"), - state.detached_from); - } - else - strbuf_addstr(&desc, _("(no branch)")); - free(state.branch); - free(state.onto); - free(state.detached_from); - return strbuf_detach(&desc, NULL); -} - static void show_detached(struct ref_list *ref_list, int maxwidth) { struct commit *head_commit = lookup_commit_reference_gently(head_sha1, 1); -- 2.5.1