| 715 | } |
| 716 | |
| 717 | int cmd_difftool(int argc, |
| 718 | const char **argv, |
| 719 | const char *prefix, |
| 720 | struct repository *repo) |
| 721 | { |
| 722 | int use_gui_tool = -1, dir_diff = 0, prompt = -1, tool_help = 0, no_index = 0; |
| 723 | static char *difftool_cmd = NULL, *extcmd = NULL; |
| 724 | struct difftool_options dt_options = { |
| 725 | .has_symlinks = 1, |
| 726 | .symlinks = 1, |
| 727 | .trust_exit_code = 0 |
| 728 | }; |
| 729 | struct option builtin_difftool_options[] = { |
| 730 | OPT_BOOL('g', "gui", &use_gui_tool, |
| 731 | N_("use `diff.guitool` instead of `diff.tool`")), |
| 732 | OPT_BOOL('d', "dir-diff", &dir_diff, |
| 733 | N_("perform a full-directory diff")), |
| 734 | OPT_SET_INT_F('y', "no-prompt", &prompt, |
| 735 | N_("do not prompt before launching a diff tool"), |
| 736 | 0, PARSE_OPT_NONEG), |
| 737 | OPT_SET_INT_F(0, "prompt", &prompt, NULL, |
| 738 | 1, PARSE_OPT_NONEG | PARSE_OPT_HIDDEN), |
| 739 | OPT_BOOL(0, "symlinks", &dt_options.symlinks, |
| 740 | N_("use symlinks in dir-diff mode")), |
| 741 | OPT_STRING('t', "tool", &difftool_cmd, N_("tool"), |
| 742 | N_("use the specified diff tool")), |
| 743 | OPT_BOOL(0, "tool-help", &tool_help, |
| 744 | N_("print a list of diff tools that may be used with " |
| 745 | "`--tool`")), |
| 746 | OPT_BOOL(0, "trust-exit-code", &dt_options.trust_exit_code, |
| 747 | N_("make 'git-difftool' exit when an invoked diff " |
| 748 | "tool returns a non-zero exit code")), |
| 749 | OPT_STRING('x', "extcmd", &extcmd, N_("command"), |
| 750 | N_("specify a custom command for viewing diffs")), |
| 751 | OPT_BOOL(0, "no-index", &no_index, N_("passed to `diff`")), |
| 752 | OPT_END() |
| 753 | }; |
| 754 | struct child_process child = CHILD_PROCESS_INIT; |
| 755 | |
| 756 | repo_config(repo, difftool_config, &dt_options); |
| 757 | dt_options.symlinks = dt_options.has_symlinks; |
| 758 | |
| 759 | argc = parse_options(argc, argv, prefix, builtin_difftool_options, |
| 760 | builtin_difftool_usage, PARSE_OPT_KEEP_UNKNOWN_OPT | |
| 761 | PARSE_OPT_KEEP_DASHDASH); |
| 762 | |
| 763 | if (tool_help) |
| 764 | return print_tool_help(); |
| 765 | |
| 766 | if (!no_index && !startup_info->have_repository) |
| 767 | die(_("difftool requires worktree or --no-index")); |
| 768 | |
| 769 | if (!no_index){ |
| 770 | setup_work_tree(repo); |
| 771 | setenv(GIT_DIR_ENVIRONMENT, absolute_path(repo_get_git_dir(repo)), 1); |
| 772 | setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(repo_get_work_tree(repo)), 1); |
| 773 | } else if (dir_diff) |
| 774 | die(_("options '%s' and '%s' cannot be used together"), "--dir-diff", "--no-index"); |
nothing calls this directly
no test coverage detected