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>
Subject: [PATCH v5 0/8] port the filtering part of branch.c to use ref-filter APIs
Date: Sun, 20 Sep 2015 23:40:19 +0530 [thread overview]
Message-ID: <1442772627-25421-1-git-send-email-Karthik.188@gmail.com> (raw)
This is part of porting 'branch -l' to use ref-filter APIs
The previous version of this series (v4) can be found here:
thread.gmane.org/gmane.comp.version-control.git/277761
Changes in this version include:
* Now we sort by 'refname' by default, this eliminates the need
for attaching the detached head at the end of the array and printing
it initially.
* Fix broken tests.
Karthik Nayak (8):
branch: refactor width computation
branch: bump get_head_description() to the top
branch: roll show_detached HEAD into regular ref_list
branch: move 'current' check down to the presentation layer
branch: drop non-commit error reporting
branch.c: use 'ref-filter' data structures
branch.c: use 'ref-filter' APIs
branch: add '--points-at' option
Documentation/git-branch.txt | 13 +-
builtin/branch.c | 501 +++++++++++++------------------------------
ref-filter.c | 2 +-
ref-filter.h | 6 +-
t/t1430-bad-ref-name.sh | 31 ++-
t/t3203-branch-output.sh | 20 ++
6 files changed, 207 insertions(+), 366 deletions(-)
Interdiff:
diff --git a/builtin/branch.c b/builtin/branch.c
index 32a0d11..9065c70 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -480,7 +480,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
int maxwidth = 0;
const char *remote_prefix = "";
struct ref_sorting def_sorting;
- const char *sort_type = "type";
+ const char *sort_type = "refname";
/*
* If we are listing more than just remote branches,
@@ -498,13 +498,6 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
if (filter->verbose)
maxwidth = calc_maxwidth(&array, strlen(remote_prefix));
- /* Print detached HEAD before sorting and printing the rest */
- if (filter->kind & FILTER_REFS_DETACHED_HEAD) {
- format_and_print_ref_item(array.items[array.nr - 1], maxwidth, filter, remote_prefix);
- free_array_item(array.items[array.nr - 1]);
- array.nr--;
- }
-
if (!sorting) {
def_sorting.next = NULL;
def_sorting.atom = parse_ref_filter_atom(sort_type,
diff --git a/ref-filter.c b/ref-filter.c
index c536aea..dbd8fce 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1356,7 +1356,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
}
/* Free memory allocated for a ref_array_item */
-void free_array_item(struct ref_array_item *item)
+static void free_array_item(struct ref_array_item *item)
{
free((char *)item->symref);
free(item);
diff --git a/ref-filter.h b/ref-filter.h
index 9316031..14d435e 100644
--- a/ref-filter.h
+++ b/ref-filter.h
@@ -90,8 +90,6 @@ struct ref_filter_cbdata {
* filtered refs in the ref_array structure.
*/
int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int type);
-/* Clear memory allocated to a ref_array_item */
-void free_array_item(struct ref_array_item *item);
/* Clear all memory allocated to ref_array */
void ref_array_clear(struct ref_array *array);
/* Parse format string and sort specifiers */
diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh
index 070cf06..c465abe 100755
--- a/t/t1430-bad-ref-name.sh
+++ b/t/t1430-bad-ref-name.sh
@@ -139,7 +139,7 @@ test_expect_failure 'push --mirror can delete badly named ref' '
) &&
git -C src push --mirror "file://$top/dest" &&
git -C dest branch >output 2>error &&
- ! grep -e "broken\.\.\.ref" error
+ ! grep -e "broken\.\.\.ref" error &&
! grep -e "broken\.\.\.ref" output
'
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index c819f3e..f1ae5ff 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -145,8 +145,8 @@ EOF
test_expect_success 'git branch `--sort` option' '
cat >expect <<-\EOF &&
- * (HEAD detached from fromtag)
branch-two
+ * (HEAD detached from fromtag)
branch-one
master
EOF
@@ -156,8 +156,8 @@ test_expect_success 'git branch `--sort` option' '
test_expect_success 'git branch --points-at option' '
cat >expect <<-\EOF &&
- master
branch-one
+ master
EOF
git branch --points-at=branch-one >actual &&
test_cmp expect actual
--
2.5.1
next reply other threads:[~2015-09-20 18:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-20 18:10 Karthik Nayak [this message]
2015-09-20 18:10 ` [PATCH v5 1/8] branch: refactor width computation Karthik Nayak
2015-09-20 18:10 ` [PATCH v5 2/8] branch: bump get_head_description() to the top Karthik Nayak
2015-09-20 18:10 ` [PATCH v5 3/8] branch: roll show_detached HEAD into regular ref_list Karthik Nayak
2015-09-20 19:11 ` Matthieu Moy
2015-09-20 18:10 ` [PATCH v5 4/8] branch: move 'current' check down to the presentation layer Karthik Nayak
2015-09-20 18:10 ` [PATCH v5 5/8] branch: drop non-commit error reporting Karthik Nayak
2015-09-20 19:16 ` Matthieu Moy
2015-09-21 10:20 ` Karthik Nayak
2015-09-21 11:35 ` Karthik Nayak
2015-09-20 18:10 ` [PATCH v5 6/8] branch.c: use 'ref-filter' data structures Karthik Nayak
2015-09-20 18:10 ` [PATCH v5 7/8] branch.c: use 'ref-filter' APIs Karthik Nayak
2015-09-20 19:24 ` Matthieu Moy
2015-09-21 10:21 ` Karthik Nayak
2015-09-20 18:10 ` [PATCH v5 8/8] branch: add '--points-at' option Karthik Nayak
2015-09-20 19:00 ` [PATCH v5 0/8] port the filtering part of branch.c to use ref-filter APIs Matthieu Moy
2015-09-21 6:11 ` Karthik Nayak
2015-09-21 6:23 ` Matthieu Moy
2015-09-21 10:15 ` 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=1442772627-25421-1-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).