X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=rev-list.c;h=3a32e405a38faebe0d4b7ec3b743fe3e15cfd3cf;hb=750a09a7de63c92868cff41a3151eac320c77fa0;hp=523fda07e1eef4b3a1a801abbf94358d06af17fd;hpb=dbc37438687e110697574d175e4eca5f9cbeae81;p=git.git diff --git a/rev-list.c b/rev-list.c index 523fda07..3a32e405 100644 --- a/rev-list.c +++ b/rev-list.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "refs.h" #include "tag.h" #include "commit.h" #include "tree.h" @@ -194,7 +195,17 @@ static void show_commit_list(struct commit_list *list) die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name); } while (objects) { - printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name); + /* An object with name "foo\n0000000000000000000000000000000000000000" + * can be used confuse downstream git-pack-objects very badly. + */ + const char *ep = strchr(objects->name, '\n'); + if (ep) { + printf("%s %.*s\n", sha1_to_hex(objects->item->sha1), + (int) (ep - objects->name), + objects->name); + } + else + printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name); objects = objects->next; } } @@ -479,6 +490,22 @@ static void handle_one_commit(struct commit *com, struct commit_list **lst) commit_list_insert(com, lst); } +/* for_each_ref() callback does not allow user data -- Yuck. */ +static struct commit_list **global_lst; + +static int include_one_commit(const char *path, const unsigned char *sha1) +{ + struct commit *com = get_commit_reference(path, 0); + handle_one_commit(com, global_lst); + return 0; +} + +static void handle_all(struct commit_list **lst) +{ + global_lst = lst; + for_each_ref(include_one_commit); + global_lst = NULL; +} int main(int argc, char **argv) { @@ -532,6 +559,10 @@ int main(int argc, char **argv) bisect_list = 1; continue; } + if (!strcmp(arg, "--all")) { + handle_all(&list); + continue; + } if (!strcmp(arg, "--objects")) { tag_objects = 1; tree_objects = 1; @@ -593,6 +624,11 @@ int main(int argc, char **argv) if (!merge_order) { sort_by_date(&list); + if (list && !limited && max_count == 1 && + !tag_objects && !tree_objects && !blob_objects) { + show_commit(list->item); + return 0; + } if (limited) list = limit_list(list); if (topo_order)