git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 v6 0/8] port branch.c to use the filtering part of ref-filter.
Date: Wed, 23 Sep 2015 23:41:05 +0530	[thread overview]
Message-ID: <1443031873-25280-1-git-send-email-Karthik.188@gmail.com> (raw)

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

             reply	other threads:[~2015-09-23 18:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-23 18:11 Karthik Nayak [this message]
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

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=1443031873-25280-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).