| 1022 | } |
| 1023 | |
| 1024 | static int show_stash(int argc, const char **argv, const char *prefix, |
| 1025 | struct repository *repo UNUSED) |
| 1026 | { |
| 1027 | int i; |
| 1028 | int ret = -1; |
| 1029 | struct stash_info info = STASH_INFO_INIT; |
| 1030 | struct rev_info rev; |
| 1031 | struct strvec stash_args = STRVEC_INIT; |
| 1032 | struct strvec revision_args = STRVEC_INIT; |
| 1033 | enum { |
| 1034 | UNTRACKED_NONE, |
| 1035 | UNTRACKED_INCLUDE, |
| 1036 | UNTRACKED_ONLY |
| 1037 | } show_untracked = show_include_untracked ? UNTRACKED_INCLUDE : UNTRACKED_NONE; |
| 1038 | struct option options[] = { |
| 1039 | OPT_SET_INT('u', "include-untracked", &show_untracked, |
| 1040 | N_("include untracked files in the stash"), |
| 1041 | UNTRACKED_INCLUDE), |
| 1042 | OPT_SET_INT_F(0, "only-untracked", &show_untracked, |
| 1043 | N_("only show untracked files in the stash"), |
| 1044 | UNTRACKED_ONLY, PARSE_OPT_NONEG), |
| 1045 | OPT_END() |
| 1046 | }; |
| 1047 | int do_usage = 0; |
| 1048 | |
| 1049 | init_diff_ui_defaults(); |
| 1050 | repo_config(the_repository, git_diff_ui_config, NULL); |
| 1051 | repo_init_revisions(the_repository, &rev, prefix); |
| 1052 | |
| 1053 | argc = parse_options(argc, argv, prefix, options, git_stash_show_usage, |
| 1054 | PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT | |
| 1055 | PARSE_OPT_KEEP_DASHDASH); |
| 1056 | |
| 1057 | strvec_push(&revision_args, argv[0]); |
| 1058 | for (i = 1; i < argc; i++) { |
| 1059 | if (argv[i][0] != '-') |
| 1060 | strvec_push(&stash_args, argv[i]); |
| 1061 | else |
| 1062 | strvec_push(&revision_args, argv[i]); |
| 1063 | } |
| 1064 | |
| 1065 | if (get_stash_info(&info, stash_args.nr, stash_args.v)) |
| 1066 | goto cleanup; |
| 1067 | |
| 1068 | /* |
| 1069 | * The config settings are applied only if there are not passed |
| 1070 | * any options. |
| 1071 | */ |
| 1072 | if (revision_args.nr == 1) { |
| 1073 | if (show_stat) |
| 1074 | rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT; |
| 1075 | |
| 1076 | if (show_patch) |
| 1077 | rev.diffopt.output_format |= DIFF_FORMAT_PATCH; |
| 1078 | |
| 1079 | if (!show_stat && !show_patch) { |
| 1080 | ret = 0; |
| 1081 | goto cleanup; |
nothing calls this directly
no test coverage detected