| 2732 | } |
| 2733 | |
| 2734 | int cmd_cherry(int argc, |
| 2735 | const char **argv, |
| 2736 | const char *prefix, |
| 2737 | struct repository *repo UNUSED) |
| 2738 | { |
| 2739 | struct rev_info revs; |
| 2740 | struct patch_ids ids; |
| 2741 | struct commit *commit; |
| 2742 | struct commit_list *list = NULL; |
| 2743 | struct branch *current_branch; |
| 2744 | const char *upstream; |
| 2745 | const char *head = "HEAD"; |
| 2746 | const char *limit = NULL; |
| 2747 | int verbose = 0, abbrev = 0; |
| 2748 | |
| 2749 | struct option options[] = { |
| 2750 | OPT__ABBREV(&abbrev), |
| 2751 | OPT__VERBOSE(&verbose, N_("be verbose")), |
| 2752 | OPT_END() |
| 2753 | }; |
| 2754 | |
| 2755 | argc = parse_options(argc, argv, prefix, options, cherry_usage, 0); |
| 2756 | |
| 2757 | switch (argc) { |
| 2758 | case 3: |
| 2759 | limit = argv[2]; |
| 2760 | /* FALLTHROUGH */ |
| 2761 | case 2: |
| 2762 | head = argv[1]; |
| 2763 | /* FALLTHROUGH */ |
| 2764 | case 1: |
| 2765 | upstream = argv[0]; |
| 2766 | break; |
| 2767 | default: |
| 2768 | current_branch = branch_get(NULL); |
| 2769 | upstream = branch_get_upstream(current_branch, NULL); |
| 2770 | if (!upstream) { |
| 2771 | fprintf(stderr, _("Could not find a tracked" |
| 2772 | " remote branch, please" |
| 2773 | " specify <upstream> manually.\n")); |
| 2774 | usage_with_options(cherry_usage, options); |
| 2775 | } |
| 2776 | } |
| 2777 | |
| 2778 | repo_init_revisions(the_repository, &revs, prefix); |
| 2779 | revs.max_parents = 1; |
| 2780 | |
| 2781 | if (add_pending_commit(head, &revs, 0)) |
| 2782 | die(_("unknown commit %s"), head); |
| 2783 | if (add_pending_commit(upstream, &revs, UNINTERESTING)) |
| 2784 | die(_("unknown commit %s"), upstream); |
| 2785 | |
| 2786 | /* Don't say anything if head and upstream are the same. */ |
| 2787 | if (revs.pending.nr == 2) { |
| 2788 | struct object_array_entry *o = revs.pending.objects; |
| 2789 | if (oideq(&o[0].item->oid, &o[1].item->oid)) |
| 2790 | return 0; |
| 2791 | } |
nothing calls this directly
no test coverage detected