| 698 | } |
| 699 | |
| 700 | int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid) |
| 701 | { |
| 702 | struct object *o; |
| 703 | struct commit *old_commit, *new_commit; |
| 704 | struct commit_list *old_commit_list = NULL; |
| 705 | int ret; |
| 706 | |
| 707 | /* |
| 708 | * Both new_commit and old_commit must be commit-ish and new_commit is descendant of |
| 709 | * old_commit. Otherwise we require --force. |
| 710 | */ |
| 711 | o = deref_tag(the_repository, parse_object(the_repository, old_oid), |
| 712 | NULL, 0); |
| 713 | if (!o || o->type != OBJ_COMMIT) |
| 714 | return 0; |
| 715 | old_commit = (struct commit *) o; |
| 716 | |
| 717 | o = deref_tag(the_repository, parse_object(the_repository, new_oid), |
| 718 | NULL, 0); |
| 719 | if (!o || o->type != OBJ_COMMIT) |
| 720 | return 0; |
| 721 | new_commit = (struct commit *) o; |
| 722 | |
| 723 | if (repo_parse_commit(the_repository, new_commit) < 0) |
| 724 | return 0; |
| 725 | |
| 726 | commit_list_insert(old_commit, &old_commit_list); |
| 727 | ret = repo_is_descendant_of(the_repository, |
| 728 | new_commit, old_commit_list); |
| 729 | if (ret < 0) |
| 730 | exit(128); |
| 731 | commit_list_free(old_commit_list); |
| 732 | return ret; |
| 733 | } |
| 734 | |
| 735 | /* |
| 736 | * Mimicking the real stack, this stack lives on the heap, avoiding stack |