about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2007-10-25 20:33:04 +0200
committerLars Hjemli <hjemli@gmail.com>2007-10-27 10:53:19 +0200
commitef1cc6ef941cedf2e34fa1ed34ca8cd8a0cfdacc (patch)
tree5c9d40e556a5787e9338bc506dec37360f54d8f5
parentUse reflist to print tag info (diff)
downloadcgit-pink-ef1cc6ef941cedf2e34fa1ed34ca8cd8a0cfdacc.tar.gz
cgit-pink-ef1cc6ef941cedf2e34fa1ed34ca8cd8a0cfdacc.zip
Sort tags by age
This adds a function to compare timestamps and then uses it as callback
for qsort() before printing out tags.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r--ui-summary.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/ui-summary.c b/ui-summary.c
index c684628..43582da 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -10,6 +10,23 @@
 
 static int header;
 
+static int cmp_tag_age(void *a, void *b)
+{
+	struct refinfo *r1 = *(struct refinfo **)a;
+	struct refinfo *r2 = *(struct refinfo **)b;
+
+	if (r1->tag->tagger_date != 0 && r2->tag->tagger_date != 0)
+		return r2->tag->tagger_date - r1->tag->tagger_date;
+
+	if (r1->tag->tagger_date == 0 && r2->tag->tagger_date == 0)
+		return 0;
+
+	if (r1 == 0)
+		return +1;
+
+	return -1;
+}
+
 static void cgit_print_branch(struct refinfo *ref)
 {
 	struct commit *commit;
@@ -156,6 +173,7 @@ static void cgit_print_tags()
 	for_each_tag_ref(cgit_refs_cb, &list);
 	if (list.count == 0)
 		return;
+	qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age);
 	print_tag_header();
 	for(i=0; i<list.count; i++)
 		print_tag(list.refs[i]);
2020-02-17Add Four Tet — HandsJune McEnroe One from the cafe that caught my attention. 2020-02-12Simplify macOS notify-sendJune McEnroe 2020-02-12Add imbox and notemap to pageJune McEnroe 2020-02-12Collapse simple linksJune McEnroe 2020-02-12Move catgirl up the pageJune McEnroe 2020-02-12Update catgirl pty grabJune McEnroe 2020-02-12Link to cgit /about pages where appropriateJune McEnroe 2020-02-11Separate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe Apparently sometimes it didn't like receiving its own internal storage to parse again. Understandable. 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe Wow. One of the best I've read. 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe Broke out LDLIBS for each bin, and made everything more uniform. 2020-01-28Change scout sensitivity to 1.4June McEnroe idk it seems to work. 2020-01-28Import shows.txtJune McEnroe