[2/4] Sorting commits by date

2005-04-18 Thread Daniel Barkalow
Functions for a date-ordered queue of commits, progressively pulled out of
the history incrementally. Linus wanted this for finding the most recent
common ancestor, and it might be relevant to logging.

Signed-Off-By: Daniel Barkalow [EMAIL PROTECTED]
Index: commit.c
===
--- b3cf8daf9b619ae9f06a28f42a4ae01b69729206/commit.c  (mode:100644 
sha1:0099baa63971d86ee30ef2a7da25057f0f45a964)
+++ 7e5a0d93117ecadfb15de3a6bebdb1aa94234fde/commit.c  (mode:100644 
sha1:ef9af397471817837e1799d72f6707e0ccc949b9)
@@ -83,3 +83,47 @@
free(temp);
}
 }
+
+static void insert_by_date(struct commit_list **list, struct commit *item)
+{
+   struct commit_list **pp = list;
+   struct commit_list *p;
+   while ((p = *pp) != NULL) {
+   if (p-item-date  item-date) {
+   break;
+   }
+   pp = p-next;
+   }
+   struct commit_list *insert = malloc(sizeof(struct commit_list));
+   insert-next = *pp;
+   *pp = insert;
+   insert-item = item;
+}
+
+   
+void sort_by_date(struct commit_list **list)
+{
+   struct commit_list *ret = NULL;
+   while (*list) {
+   insert_by_date(ret, (*list)-item);
+   *list = (*list)-next;
+   }
+   *list = ret;
+}
+
+struct commit *pop_most_recent_commit(struct commit_list **list)
+{
+   struct commit *ret = (*list)-item;
+   struct commit_list *parents = ret-parents;
+   struct commit_list *old = *list;
+
+   *list = (*list)-next;
+   free(old);
+
+   while (parents) {
+   parse_commit(parents-item);
+   insert_by_date(list, parents-item);
+   parents = parents-next;
+   }
+   return ret;
+}
Index: commit.h
===
--- b3cf8daf9b619ae9f06a28f42a4ae01b69729206/commit.h  (mode:100644 
sha1:8cd20b046875f5f7e534b0607fdd97f330f53272)
+++ 7e5a0d93117ecadfb15de3a6bebdb1aa94234fde/commit.h  (mode:100644 
sha1:35679482132ae5a6b7d72bbb684f21472470717c)
@@ -24,4 +24,8 @@
 
 void free_commit_list(struct commit_list *list);
 
+void sort_by_date(struct commit_list **list);
+
+struct commit *pop_most_recent_commit(struct commit_list **list);
+
 #endif /* COMMIT_H */

-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [2/4] Sorting commits by date

2005-04-18 Thread Petr Baudis
Dear diary, on Tue, Apr 19, 2005 at 03:54:56AM CEST, I got a letter
where Daniel Barkalow [EMAIL PROTECTED] told me that...
 Index: commit.c
 ===
 --- b3cf8daf9b619ae9f06a28f42a4ae01b69729206/commit.c  (mode:100644 
 sha1:0099baa63971d86ee30ef2a7da25057f0f45a964)
 +++ 7e5a0d93117ecadfb15de3a6bebdb1aa94234fde/commit.c  (mode:100644 
 sha1:ef9af397471817837e1799d72f6707e0ccc949b9)
 @@ -83,3 +83,47 @@
   free(temp);
   }
  }
 +
 +static void insert_by_date(struct commit_list **list, struct commit *item)
 +{
 + struct commit_list **pp = list;
 + struct commit_list *p;
 + while ((p = *pp) != NULL) {
 + if (p-item-date  item-date) {
 + break;
 + }
 + pp = p-next;
 + }
 + struct commit_list *insert = malloc(sizeof(struct commit_list));
 + insert-next = *pp;
 + *pp = insert;
 + insert-item = item;
 +}

Note that you are breaking gcc-2.95 compatibility when using declarator
in the middle of a block. Not that it might be a necessarily bad thing
;-) (although I still use gcc-2.95 a lot), just to ring a bell so that
it doesn't slip through unnoticed and we can decide on a policy
regarding this.

-- 
Petr Pasky Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [2/4] Sorting commits by date

2005-04-18 Thread David A. Wheeler
Petr Baudis wrote:
[Re: Daniel Barkalow [EMAIL PROTECTED]'s patch] 
Note that you are breaking gcc-2.95 compatibility when using declarator
in the middle of a block. Not that it might be a necessarily bad thing
;-) (although I still use gcc-2.95 a lot), just to ring a bell so that
it doesn't slip through unnoticed and we can decide on a policy
regarding this.
I, at least, would REALLY like to see _highly_ portable C code;
I'm looking at git as a potential long-term useful SCM tool for
LOTS of projects, and if you're going to write C, it'd be nice
to just write it portably to start with. There's certainly
no crisis in using separate declarators.
In fact, in the LONG term I'd like to see the shell code
replaced with code that easily runs everywhere (Windows, etc.),
again, for portability's sake.  I think that would be unwise to
do that right now; the shell is an excellent prototyping tool.
But once things have settled down  there's been some experience
with the tools, the pieces could be slowly recoded.
(Yes, I know of  use Cygwin. And I prefer Python over Perl,
but I'm really uninterested in language wars.)
--- David A. Wheeler
-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [2/4] Sorting commits by date

2005-04-18 Thread Petr Baudis
Dear diary, on Tue, Apr 19, 2005 at 04:52:26AM CEST, I got a letter
where Daniel Barkalow [EMAIL PROTECTED] told me that...
 because I can't find a way to make recent GCC reject C99 features but not
 old GNU extensions.

Do we use any?

-- 
Petr Pasky Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html