| 138 | } |
| 139 | |
| 140 | int cmd_credential_cache(int argc, |
| 141 | const char **argv, |
| 142 | const char *prefix, |
| 143 | struct repository *repo UNUSED) |
| 144 | { |
| 145 | const char *socket_path_arg = NULL; |
| 146 | char *socket_path; |
| 147 | int timeout = 900; |
| 148 | const char *op; |
| 149 | const char * const usage[] = { |
| 150 | "git credential-cache [<options>] <action>", |
| 151 | NULL |
| 152 | }; |
| 153 | struct option options[] = { |
| 154 | OPT_INTEGER(0, "timeout", &timeout, |
| 155 | "number of seconds to cache credentials"), |
| 156 | OPT_STRING(0, "socket", &socket_path_arg, "path", |
| 157 | "path of cache-daemon socket"), |
| 158 | OPT_END() |
| 159 | }; |
| 160 | |
| 161 | argc = parse_options(argc, argv, prefix, options, usage, 0); |
| 162 | if (!argc) |
| 163 | usage_with_options(usage, options); |
| 164 | op = argv[0]; |
| 165 | |
| 166 | if (!have_unix_sockets()) |
| 167 | die(_("credential-cache unavailable; no unix socket support")); |
| 168 | |
| 169 | socket_path = xstrdup_or_null(socket_path_arg); |
| 170 | if (!socket_path) |
| 171 | socket_path = get_socket_path(); |
| 172 | if (!socket_path) |
| 173 | die("unable to find a suitable socket path; use --socket"); |
| 174 | |
| 175 | if (!strcmp(op, "exit")) |
| 176 | do_cache(socket_path, op, timeout, 0); |
| 177 | else if (!strcmp(op, "get") || !strcmp(op, "erase")) |
| 178 | do_cache(socket_path, op, timeout, FLAG_RELAY); |
| 179 | else if (!strcmp(op, "store")) |
| 180 | do_cache(socket_path, op, timeout, FLAG_RELAY|FLAG_SPAWN); |
| 181 | else if (!strcmp(op, "capability")) |
| 182 | announce_capabilities(); |
| 183 | else |
| 184 | ; /* ignore unknown operation */ |
| 185 | |
| 186 | free(socket_path); |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | #else |
| 191 |
nothing calls this directly
no test coverage detected