From: Karthik Nayak <karthik.188@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, Matthieu.Moy@grenoble-inp.fr,
gitster@pobox.com, Karthik Nayak <Karthik.188@gmail.com>,
Karthik Nayak <karthik.188@gmail.com>
Subject: [PATCH v4 2/8] branch: bump get_head_description() to the top
Date: Sun, 13 Sep 2015 12:53:49 +0530 [thread overview]
Message-ID: <1442129035-31386-3-git-send-email-Karthik.188@gmail.com> (raw)
In-Reply-To: <1442129035-31386-1-git-send-email-Karthik.188@gmail.com>
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 <peff@peff.net>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
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
next prev parent reply other threads:[~2015-09-13 7:24 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-13 7:23 [PATCH v4 0/8] port the filtering part of branch.c to use ref-filter APIs Karthik Nayak
2015-09-13 7:23 ` [PATCH v4 1/8] branch: refactor width computation Karthik Nayak
2015-09-13 11:51 ` Matthieu Moy
2015-09-13 12:23 ` Karthik Nayak
2015-09-13 12:33 ` Matthieu Moy
2015-09-13 7:23 ` Karthik Nayak [this message]
2015-09-13 7:23 ` [PATCH v4 3/8] branch: roll show_detached HEAD into regular ref_list Karthik Nayak
2015-09-13 12:12 ` Matthieu Moy
2015-09-13 13:24 ` Karthik Nayak
2015-09-13 16:46 ` Eric Sunshine
2015-09-13 18:31 ` Eric Sunshine
2015-09-14 14:48 ` Karthik Nayak
2015-09-14 14:54 ` Matthieu Moy
2015-09-14 19:35 ` Junio C Hamano
2015-09-16 6:23 ` Karthik Nayak
2015-09-17 9:47 ` Karthik Nayak
2015-09-17 14:18 ` Matthieu Moy
2015-09-17 15:15 ` Junio C Hamano
2015-09-17 15:43 ` Matthieu Moy
2015-09-17 16:49 ` Junio C Hamano
2015-09-17 17:08 ` Matthieu Moy
2015-09-17 17:21 ` Junio C Hamano
2015-09-17 18:25 ` Karthik Nayak
2015-09-13 7:23 ` [PATCH v4 4/8] branch: move 'current' check down to the presentation layer Karthik Nayak
2015-09-13 12:15 ` Matthieu Moy
2015-09-13 13:22 ` Karthik Nayak
2015-09-13 15:35 ` Karthik Nayak
2015-09-13 7:23 ` [PATCH v4 5/8] branch: drop non-commit error reporting Karthik Nayak
2015-09-14 19:49 ` Junio C Hamano
2015-09-16 6:04 ` Karthik Nayak
2015-09-13 7:23 ` [PATCH v4 6/8] branch.c: use 'ref-filter' data structures Karthik Nayak
2015-09-13 12:26 ` Matthieu Moy
2015-09-13 13:19 ` Karthik Nayak
2015-09-13 17:49 ` Matthieu Moy
2015-09-13 7:23 ` Karthik Nayak
2015-09-13 7:32 ` Karthik Nayak
2015-09-13 7:23 ` [PATCH v4 8/8] branch: add '--points-at' option Karthik Nayak
2015-09-13 7:29 ` [PATCH v4 7/8] branch.c: use 'ref-filter' APIs Karthik Nayak
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=1442129035-31386-3-git-send-email-Karthik.188@gmail.com \
--to=karthik.188@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).