An external diff command takes: * * diff-cmd name infile1 infile1-sha1 infile1-mode \ * infile2 infile2-sha1 infile2-mode [ rename-to ] * */
| 4775 | * |
| 4776 | */ |
| 4777 | static void run_external_diff(const struct external_diff *pgm, |
| 4778 | const char *name, |
| 4779 | const char *other, |
| 4780 | struct diff_filespec *one, |
| 4781 | struct diff_filespec *two, |
| 4782 | const char *xfrm_msg, |
| 4783 | struct diff_options *o) |
| 4784 | { |
| 4785 | struct child_process cmd = CHILD_PROCESS_INIT; |
| 4786 | struct diff_queue_struct *q = &diff_queued_diff; |
| 4787 | int rc; |
| 4788 | |
| 4789 | /* |
| 4790 | * Trivial equality is handled by diff_unmodified_pair() before |
| 4791 | * we get here. If we don't need to show the diff and the |
| 4792 | * external diff program lacks the ability to tell us whether |
| 4793 | * it's empty then we consider it non-empty without even asking. |
| 4794 | */ |
| 4795 | if (!pgm->trust_exit_code && !o->file) { |
| 4796 | o->found_changes = 1; |
| 4797 | return; |
| 4798 | } |
| 4799 | |
| 4800 | strvec_push(&cmd.args, pgm->cmd); |
| 4801 | strvec_push(&cmd.args, name); |
| 4802 | |
| 4803 | if (one && two) { |
| 4804 | add_external_diff_name(o->repo, &cmd.args, one); |
| 4805 | add_external_diff_name(o->repo, &cmd.args, two); |
| 4806 | if (other) { |
| 4807 | strvec_push(&cmd.args, other); |
| 4808 | if (xfrm_msg) |
| 4809 | strvec_push(&cmd.args, xfrm_msg); |
| 4810 | } |
| 4811 | } |
| 4812 | |
| 4813 | strvec_pushf(&cmd.env, "GIT_DIFF_PATH_COUNTER=%d", |
| 4814 | ++o->diff_path_counter); |
| 4815 | strvec_pushf(&cmd.env, "GIT_DIFF_PATH_TOTAL=%d", q->nr); |
| 4816 | |
| 4817 | diff_free_filespec_data(one); |
| 4818 | diff_free_filespec_data(two); |
| 4819 | cmd.use_shell = 1; |
| 4820 | if (!o->file) |
| 4821 | cmd.no_stdout = 1; |
| 4822 | else if (o->file != stdout) |
| 4823 | cmd.out = xdup(fileno(o->file)); |
| 4824 | rc = run_command(&cmd); |
| 4825 | if (!pgm->trust_exit_code && rc == 0) |
| 4826 | o->found_changes = 1; |
| 4827 | else if (pgm->trust_exit_code && rc == 0) |
| 4828 | ; /* nothing */ |
| 4829 | else if (pgm->trust_exit_code && rc == 1) |
| 4830 | o->found_changes = 1; |
| 4831 | else |
| 4832 | die(_("external diff died, stopping at %s"), name); |
| 4833 | |
| 4834 | remove_tempfile(); |
no test coverage detected