| 652 | } |
| 653 | |
| 654 | void show_submodule_inline_diff(struct diff_options *o, const char *path, |
| 655 | struct object_id *one, struct object_id *two, |
| 656 | unsigned dirty_submodule) |
| 657 | { |
| 658 | const struct object_id *old_oid = the_hash_algo->empty_tree, *new_oid = the_hash_algo->empty_tree; |
| 659 | struct commit *left = NULL, *right = NULL; |
| 660 | struct commit_list *merge_bases = NULL; |
| 661 | struct child_process cp = CHILD_PROCESS_INIT; |
| 662 | struct strbuf sb = STRBUF_INIT; |
| 663 | struct repository *sub; |
| 664 | |
| 665 | sub = open_submodule(path); |
| 666 | show_submodule_header(o, path, one, two, dirty_submodule, |
| 667 | sub, &left, &right, &merge_bases); |
| 668 | |
| 669 | /* We need a valid left and right commit to display a difference */ |
| 670 | if (!(left || is_null_oid(one)) || |
| 671 | !(right || is_null_oid(two))) |
| 672 | goto done; |
| 673 | |
| 674 | if (left) |
| 675 | old_oid = one; |
| 676 | if (right) |
| 677 | new_oid = two; |
| 678 | |
| 679 | cp.git_cmd = 1; |
| 680 | cp.dir = path; |
| 681 | cp.out = -1; |
| 682 | cp.no_stdin = 1; |
| 683 | |
| 684 | /* TODO: other options may need to be passed here. */ |
| 685 | strvec_pushl(&cp.args, "diff", "--submodule=diff", NULL); |
| 686 | strvec_pushf(&cp.args, "--color=%s", want_color(o->use_color) ? |
| 687 | "always" : "never"); |
| 688 | |
| 689 | if (o->flags.reverse_diff) { |
| 690 | strvec_pushf(&cp.args, "--src-prefix=%s%s/", |
| 691 | o->b_prefix, path); |
| 692 | strvec_pushf(&cp.args, "--dst-prefix=%s%s/", |
| 693 | o->a_prefix, path); |
| 694 | } else { |
| 695 | strvec_pushf(&cp.args, "--src-prefix=%s%s/", |
| 696 | o->a_prefix, path); |
| 697 | strvec_pushf(&cp.args, "--dst-prefix=%s%s/", |
| 698 | o->b_prefix, path); |
| 699 | } |
| 700 | strvec_push(&cp.args, oid_to_hex(old_oid)); |
| 701 | /* |
| 702 | * If the submodule has modified content, we will diff against the |
| 703 | * work tree, under the assumption that the user has asked for the |
| 704 | * diff format and wishes to actually see all differences even if they |
| 705 | * haven't yet been committed to the submodule yet. |
| 706 | */ |
| 707 | if (!(dirty_submodule & DIRTY_SUBMODULE_MODIFIED)) |
| 708 | strvec_push(&cp.args, oid_to_hex(new_oid)); |
| 709 | |
| 710 | prepare_submodule_repo_env(&cp.env); |
| 711 |
no test coverage detected