This adds --date-order to rev-list; it is similar to topo order
in the sense that no parent comes before all of its children,
but otherwise things are still ordered in the commit timestamp
order.
The same flag is also added to show-branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
/*
* Performs an in-place topological sort on the list supplied.
*/
/*
* Performs an in-place topological sort on the list supplied.
*/
-void sort_in_topological_order(struct commit_list ** list)
+void sort_in_topological_order(struct commit_list ** list, int lifo)
{
struct commit_list * next = *list;
struct commit_list * work = NULL, **insert;
{
struct commit_list * next = *list;
struct commit_list * work = NULL, **insert;
/* process the list in topological order */
/* process the list in topological order */
+ if (!lifo)
+ sort_by_date(&work);
while (work) {
struct commit * work_item = pop_commit(&work);
struct sort_node * work_node = (struct sort_node *)work_item->object.util;
while (work) {
struct commit * work_item = pop_commit(&work);
struct sort_node * work_node = (struct sort_node *)work_item->object.util;
* guaranteeing topological order.
*/
pn->indegree--;
* guaranteeing topological order.
*/
pn->indegree--;
- if (!pn->indegree)
- commit_list_insert(parent, &work);
+ if (!pn->indegree) {
+ if (!lifo)
+ insert_by_date(parent, &work);
+ else
+ commit_list_insert(parent, &work);
+ }
}
parents=parents->next;
}
}
parents=parents->next;
}
* Post-conditions:
* invariant of resulting list is:
* a reachable from b => ord(b) < ord(a)
* Post-conditions:
* invariant of resulting list is:
* a reachable from b => ord(b) < ord(a)
+ * in addition, when lifo == 0, commits on parallel tracks are
+ * sorted in the dates order.
-void sort_in_topological_order(struct commit_list ** list);
+void sort_in_topological_order(struct commit_list ** list, int lifo);
" ordering output:\n"
" --merge-order [ --show-breaks ]\n"
" --topo-order\n"
" ordering output:\n"
" --merge-order [ --show-breaks ]\n"
" --topo-order\n"
" formatting output:\n"
" --parents\n"
" --objects\n"
" formatting output:\n"
" --parents\n"
" --objects\n"
static int show_breaks = 0;
static int stop_traversal = 0;
static int topo_order = 0;
static int show_breaks = 0;
static int stop_traversal = 0;
static int topo_order = 0;
static int no_merges = 0;
static const char **paths = NULL;
static int remove_empty_trees = 0;
static int no_merges = 0;
static const char **paths = NULL;
static int remove_empty_trees = 0;
}
if (!strcmp(arg, "--topo-order")) {
topo_order = 1;
}
if (!strcmp(arg, "--topo-order")) {
topo_order = 1;
+ lifo = 1;
+ limited = 1;
+ continue;
+ }
+ if (!strcmp(arg, "--date-order")) {
+ topo_order = 1;
+ lifo = 0;
if (limited)
list = limit_list(list);
if (topo_order)
if (limited)
list = limit_list(list);
if (topo_order)
- sort_in_topological_order(&list);
+ sort_in_topological_order(&list, lifo);
show_commit_list(list);
} else {
#ifndef NO_OPENSSL
show_commit_list(list);
} else {
#ifndef NO_OPENSSL
"--show-breaks",
"--sparse",
"--topo-order",
"--show-breaks",
"--sparse",
"--topo-order",
int num_rev, i, extra = 0;
int all_heads = 0, all_tags = 0;
int all_mask, all_revs;
int num_rev, i, extra = 0;
int all_heads = 0, all_tags = 0;
int all_mask, all_revs;
char head_path[128];
const char *head_path_p;
int head_path_len;
char head_path[128];
const char *head_path_p;
int head_path_len;
int no_name = 0;
int sha1_name = 0;
int shown_merge_point = 0;
int no_name = 0;
int sha1_name = 0;
int shown_merge_point = 0;
int with_current_branch = 0;
int head_at = -1;
int with_current_branch = 0;
int head_at = -1;
else if (!strcmp(arg, "--independent"))
independent = 1;
else if (!strcmp(arg, "--topo-order"))
else if (!strcmp(arg, "--independent"))
independent = 1;
else if (!strcmp(arg, "--topo-order"))
+ lifo = 1;
+ else if (!strcmp(arg, "--date-order"))
+ lifo = 0;
else
usage(show_branch_usage);
ac--; av++;
else
usage(show_branch_usage);
ac--; av++;
exit(0);
/* Sort topologically */
exit(0);
/* Sort topologically */
- if (topo_order)
- sort_in_topological_order(&seen);
+ sort_in_topological_order(&seen, lifo);
/* Give names to commits */
if (!sha1_name && !no_name)
/* Give names to commits */
if (!sha1_name && !no_name)