git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/8] port the filtering part of branch.c to use ref-filter APIs
@ 2015-09-20 18:10 Karthik Nayak
  2015-09-20 18:10 ` [PATCH v5 1/8] branch: refactor width computation Karthik Nayak
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Karthik Nayak @ 2015-09-20 18:10 UTC (permalink / raw)
  To: git; +Cc: christian.couder, Matthieu.Moy, gitster, Karthik Nayak

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-09-21 11:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-20 18:10 [PATCH v5 0/8] port the filtering part of branch.c to use ref-filter APIs Karthik Nayak
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

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).