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

The previous iteration of the same can be found:
http://www.mail-archive.com/git@vger.kernel.org/msg78153.html

Changes in this version:
* use ref_default_sorting()
* Improve documentation, comments and commit message.

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 |  16 +-
 builtin/branch.c             | 502 +++++++++++++------------------------------
 ref-filter.c                 |   2 +-
 ref-filter.h                 |   6 +-
 t/t1430-bad-ref-name.sh      |  31 ++-
 t/t3203-branch-output.sh     |  20 ++
 6 files changed, 211 insertions(+), 366 deletions(-)

Interdiff:

diff --git a/builtin/branch.c b/builtin/branch.c
index b0a96e1..b7a60f4 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -479,8 +479,6 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
 	struct ref_array array;
 	int maxwidth = 0;
 	const char *remote_prefix = "";
-	struct ref_sorting def_sorting;
-	const char *sort_type = "refname";
 
 	/*
 	 * If we are listing more than just remote branches,
@@ -498,12 +496,15 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
 	if (filter->verbose)
 		maxwidth = calc_maxwidth(&array, strlen(remote_prefix));
 
-	if (!sorting) {
-		def_sorting.next = NULL;
-		def_sorting.atom = parse_ref_filter_atom(sort_type,
-							 sort_type + strlen(sort_type));
-		sorting = &def_sorting;
-	}
+	/*
+	 * If no sorting parameter is given then we default to sorting
+	 * by 'refname'. This would give us an alphabetically sorted
+	 * array with the 'HEAD' ref at the beginning followed by
+	 * local branches 'refs/heads/...' and finally remote-tacking
+	 * branches 'refs/remotes/...'.
+	 */
+	if (!sorting)
+		sorting = ref_default_sorting();
 	ref_array_sort(sorting, &array);

diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 647a9cf..03c7af1 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -237,8 +235,11 @@ start-point is either a local or remote-tracking branch.
 	order of the value. You may use the --sort=<key> option
 	multiple times, in which case the last key becomes the primary
 	key. The keys supported are the same as those in `git
-	for-each-ref`. Sort order defaults to sorting based on branch
-	type.
+	for-each-ref`. Sort order defaults to sorting based on the
+	full refname (including `refs/...` prefix). This lists
+	detached HEAD (if present) first, then local branches and
+	finally remote-tracking branches.
+
 
 --points-at <object>::
 	Only list branches of the given object.

 
-- 
2.5.1

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

end of thread, other threads:[~2015-09-25 18:37 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-23 18:11 [PATCH v6 0/8] port branch.c to use the filtering part of ref-filter Karthik Nayak
2015-09-23 18:11 ` [PATCH v6 1/8] branch: refactor width computation Karthik Nayak
2015-09-23 18:11 ` [PATCH v6 2/8] branch: bump get_head_description() to the top Karthik Nayak
2015-09-23 18:11 ` [PATCH v6 3/8] branch: roll show_detached HEAD into regular ref_list Karthik Nayak
2015-09-23 18:11 ` [PATCH v6 4/8] branch: move 'current' check down to the presentation layer Karthik Nayak
2015-09-23 18:11 ` [PATCH v6 5/8] branch: drop non-commit error reporting Karthik Nayak
2015-09-23 18:57   ` Matthieu Moy
2015-09-24  6:19     ` Karthik Nayak
2015-09-23 19:14   ` Junio C Hamano
2015-09-23 20:10     ` Matthieu Moy
2015-09-23 20:29       ` Junio C Hamano
2015-09-23 20:38         ` Junio C Hamano
2015-09-23 21:44           ` Junio C Hamano
2015-09-24  6:46             ` Matthieu Moy
2015-09-23 22:50       ` Junio C Hamano
2015-09-24  6:23     ` Karthik Nayak
2015-09-23 18:11 ` [PATCH v6 6/8] branch.c: use 'ref-filter' data structures Karthik Nayak
2015-09-23 18:11 ` [PATCH v6 7/8] branch.c: use 'ref-filter' APIs Karthik Nayak
2015-09-23 18:11 ` [PATCH v6 8/8] branch: add '--points-at' option Karthik Nayak
2015-09-23 19:00 ` [PATCH v6 0/8] port branch.c to use the filtering part of ref-filter Matthieu Moy
2015-09-23 19:16   ` Junio C Hamano
2015-09-24  6:01     ` Karthik Nayak
2015-09-24 18:09 ` [PATCH v6b 5/8] branch: drop non-commit error reporting Karthik Nayak
2015-09-25  5:55   ` Matthieu Moy
2015-09-25 16:00     ` Junio C Hamano
2015-09-25 16:30       ` Matthieu Moy
2015-09-25 18:37       ` Karthik Nayak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.