🌐 AI搜索 & 代理 主页
blob: 96ff2f8f564b907b9ef77bd2ea41b5e854a13085 [file] [log] [blame]
Junio C Hamano85023572006-12-19 22:34:121#include "cache.h"
Jeff Kingc91f0d92006-09-08 08:05:342#include "wt-status.h"
3#include "color.h"
Jeff Kingc91f0d92006-09-08 08:05:344#include "object.h"
5#include "dir.h"
6#include "commit.h"
7#include "diff.h"
8#include "revision.h"
9#include "diffcore.h"
Dmitry Potapova734d0b2008-03-07 02:30:5810#include "quote.h"
Ping Yinac8d5af2008-04-12 15:05:3211#include "run-command.h"
Junio C Hamanob6975ab2008-07-02 07:52:1612#include "remote.h"
Jeff Kingc91f0d92006-09-08 08:05:3413
Jeff King46f721c2007-12-07 21:26:0714int wt_status_relative_paths = 1;
Matthias Kestenholz6b2f2d92008-02-18 07:26:0315int wt_status_use_color = -1;
Ping Yinac8d5af2008-04-12 15:05:3216int wt_status_submodule_summary;
Jeff Kingc91f0d92006-09-08 08:05:3417static char wt_status_colors[][COLOR_MAXLEN] = {
18 "", /* WT_STATUS_HEADER: normal */
19 "\033[32m", /* WT_STATUS_UPDATED: green */
20 "\033[31m", /* WT_STATUS_CHANGED: red */
21 "\033[31m", /* WT_STATUS_UNTRACKED: red */
Chris Parsons950ce2e2008-05-22 12:50:0222 "\033[31m", /* WT_STATUS_NOBRANCH: red */
Jeff Kingc91f0d92006-09-08 08:05:3423};
Junio C Hamano4d229652007-01-11 23:34:4124
Marius Storm-Olsen4bfee302008-06-05 08:31:1925enum untracked_status_type show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
Jeff Kingc91f0d92006-09-08 08:05:3426
27static int parse_status_slot(const char *var, int offset)
28{
29 if (!strcasecmp(var+offset, "header"))
30 return WT_STATUS_HEADER;
Shawn O. Pearce82dca842006-12-16 02:53:1331 if (!strcasecmp(var+offset, "updated")
32 || !strcasecmp(var+offset, "added"))
Jeff Kingc91f0d92006-09-08 08:05:3433 return WT_STATUS_UPDATED;
34 if (!strcasecmp(var+offset, "changed"))
35 return WT_STATUS_CHANGED;
36 if (!strcasecmp(var+offset, "untracked"))
37 return WT_STATUS_UNTRACKED;
Chris Parsons950ce2e2008-05-22 12:50:0238 if (!strcasecmp(var+offset, "nobranch"))
39 return WT_STATUS_NOBRANCH;
Jeff Kingc91f0d92006-09-08 08:05:3440 die("bad config variable '%s'", var);
41}
42
43static const char* color(int slot)
44{
Matthias Kestenholz6b2f2d92008-02-18 07:26:0345 return wt_status_use_color > 0 ? wt_status_colors[slot] : "";
Jeff Kingc91f0d92006-09-08 08:05:3446}
47
48void wt_status_prepare(struct wt_status *s)
49{
50 unsigned char sha1[20];
51 const char *head;
52
Junio C Hamanocc46a742007-02-10 00:22:4253 memset(s, 0, sizeof(*s));
Junio C Hamano8da19772006-09-21 05:02:0154 head = resolve_ref("HEAD", sha1, 0, NULL);
Jeff Kingf62363f2006-09-18 02:13:5655 s->branch = head ? xstrdup(head) : NULL;
Jeff Kingc91f0d92006-09-08 08:05:3456 s->reference = "HEAD";
Kristian Høgsbergf26a0012007-09-18 00:06:4257 s->fp = stdout;
Kristian Høgsberg0f729f22007-09-18 00:06:4358 s->index_file = get_index_file();
Jeff Kingc91f0d92006-09-08 08:05:3459}
60
Kristian Høgsbergf26a0012007-09-18 00:06:4261static void wt_status_print_cached_header(struct wt_status *s)
Jürgen Rühle3c1eb9c2007-01-02 19:26:2162{
63 const char *c = color(WT_STATUS_HEADER);
Kristian Høgsbergf26a0012007-09-18 00:06:4264 color_fprintf_ln(s->fp, c, "# Changes to be committed:");
Jeff Kingff58b9a2008-02-12 05:45:1865 if (!s->is_initial) {
Kristian Høgsbergf26a0012007-09-18 00:06:4266 color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
Jürgen Rühle3c1eb9c2007-01-02 19:26:2167 } else {
Kristian Høgsbergf26a0012007-09-18 00:06:4268 color_fprintf_ln(s->fp, c, "# (use \"git rm --cached <file>...\" to unstage)");
Jürgen Rühle3c1eb9c2007-01-02 19:26:2169 }
Kristian Høgsbergf26a0012007-09-18 00:06:4270 color_fprintf_ln(s->fp, c, "#");
Jürgen Rühle3c1eb9c2007-01-02 19:26:2171}
72
Anders Melchiorsenbb914b12008-09-07 22:05:0273static void wt_status_print_dirty_header(struct wt_status *s,
74 int has_deleted)
Jeff Kingc91f0d92006-09-08 08:05:3475{
76 const char *c = color(WT_STATUS_HEADER);
Anders Melchiorsenbb914b12008-09-07 22:05:0277 color_fprintf_ln(s->fp, c, "# Changed but not updated:");
78 if (!has_deleted)
79 color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to update what will be committed)");
80 else
81 color_fprintf_ln(s->fp, c, "# (use \"git add/rm <file>...\" to update what will be committed)");
Anders Melchiorsen4d6e4c42008-09-07 22:05:0382 color_fprintf_ln(s->fp, c, "# (use \"git checkout -- <file>...\" to discard changes in working directory)");
Anders Melchiorsenbb914b12008-09-07 22:05:0283 color_fprintf_ln(s->fp, c, "#");
84}
85
86static void wt_status_print_untracked_header(struct wt_status *s)
87{
88 const char *c = color(WT_STATUS_HEADER);
89 color_fprintf_ln(s->fp, c, "# Untracked files:");
90 color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)");
Kristian Høgsbergf26a0012007-09-18 00:06:4291 color_fprintf_ln(s->fp, c, "#");
Jeff Kingc91f0d92006-09-08 08:05:3492}
93
Kristian Høgsbergf26a0012007-09-18 00:06:4294static void wt_status_print_trailer(struct wt_status *s)
Jeff Kingc91f0d92006-09-08 08:05:3495{
Kristian Høgsbergf26a0012007-09-18 00:06:4296 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
Jeff Kingc91f0d92006-09-08 08:05:3497}
98
Dmitry Potapova734d0b2008-03-07 02:30:5899#define quote_path quote_path_relative
Junio C Hamano3a946802006-11-08 21:20:46100
Kristian Høgsbergf26a0012007-09-18 00:06:42101static void wt_status_print_filepair(struct wt_status *s,
102 int t, struct diff_filepair *p)
Jeff Kingc91f0d92006-09-08 08:05:34103{
104 const char *c = color(t);
Junio C Hamano3a946802006-11-08 21:20:46105 const char *one, *two;
Brandon Caseyf285a2d2008-10-09 19:12:12106 struct strbuf onebuf = STRBUF_INIT, twobuf = STRBUF_INIT;
Junio C Hamano3a946802006-11-08 21:20:46107
Johannes Schindelin367c9882007-11-11 17:35:41108 one = quote_path(p->one->path, -1, &onebuf, s->prefix);
109 two = quote_path(p->two->path, -1, &twobuf, s->prefix);
Junio C Hamano3a946802006-11-08 21:20:46110
Kristian Høgsbergf26a0012007-09-18 00:06:42111 color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
Jeff Kingc91f0d92006-09-08 08:05:34112 switch (p->status) {
113 case DIFF_STATUS_ADDED:
Kristian Høgsbergf26a0012007-09-18 00:06:42114 color_fprintf(s->fp, c, "new file: %s", one);
Junio C Hamano3a946802006-11-08 21:20:46115 break;
Jeff Kingc91f0d92006-09-08 08:05:34116 case DIFF_STATUS_COPIED:
Kristian Høgsbergf26a0012007-09-18 00:06:42117 color_fprintf(s->fp, c, "copied: %s -> %s", one, two);
Jeff Kingc91f0d92006-09-08 08:05:34118 break;
119 case DIFF_STATUS_DELETED:
Kristian Høgsbergf26a0012007-09-18 00:06:42120 color_fprintf(s->fp, c, "deleted: %s", one);
Junio C Hamano3a946802006-11-08 21:20:46121 break;
Jeff Kingc91f0d92006-09-08 08:05:34122 case DIFF_STATUS_MODIFIED:
Kristian Høgsbergf26a0012007-09-18 00:06:42123 color_fprintf(s->fp, c, "modified: %s", one);
Junio C Hamano3a946802006-11-08 21:20:46124 break;
Jeff Kingc91f0d92006-09-08 08:05:34125 case DIFF_STATUS_RENAMED:
Kristian Høgsbergf26a0012007-09-18 00:06:42126 color_fprintf(s->fp, c, "renamed: %s -> %s", one, two);
Jeff Kingc91f0d92006-09-08 08:05:34127 break;
128 case DIFF_STATUS_TYPE_CHANGED:
Kristian Høgsbergf26a0012007-09-18 00:06:42129 color_fprintf(s->fp, c, "typechange: %s", one);
Junio C Hamano3a946802006-11-08 21:20:46130 break;
Jeff Kingc91f0d92006-09-08 08:05:34131 case DIFF_STATUS_UNKNOWN:
Kristian Høgsbergf26a0012007-09-18 00:06:42132 color_fprintf(s->fp, c, "unknown: %s", one);
Junio C Hamano3a946802006-11-08 21:20:46133 break;
Jeff Kingc91f0d92006-09-08 08:05:34134 case DIFF_STATUS_UNMERGED:
Kristian Høgsbergf26a0012007-09-18 00:06:42135 color_fprintf(s->fp, c, "unmerged: %s", one);
Junio C Hamano3a946802006-11-08 21:20:46136 break;
Jeff Kingc91f0d92006-09-08 08:05:34137 default:
138 die("bug: unhandled diff status %c", p->status);
139 }
Kristian Høgsbergf26a0012007-09-18 00:06:42140 fprintf(s->fp, "\n");
Johannes Schindelin367c9882007-11-11 17:35:41141 strbuf_release(&onebuf);
142 strbuf_release(&twobuf);
Jeff Kingc91f0d92006-09-08 08:05:34143}
144
145static void wt_status_print_updated_cb(struct diff_queue_struct *q,
146 struct diff_options *options,
147 void *data)
148{
149 struct wt_status *s = data;
150 int shown_header = 0;
151 int i;
Jeff Kingc91f0d92006-09-08 08:05:34152 for (i = 0; i < q->nr; i++) {
153 if (q->queue[i]->status == 'U')
154 continue;
155 if (!shown_header) {
Kristian Høgsbergf26a0012007-09-18 00:06:42156 wt_status_print_cached_header(s);
Jeff Kingc91f0d92006-09-08 08:05:34157 s->commitable = 1;
158 shown_header = 1;
159 }
Kristian Høgsbergf26a0012007-09-18 00:06:42160 wt_status_print_filepair(s, WT_STATUS_UPDATED, q->queue[i]);
Jeff Kingc91f0d92006-09-08 08:05:34161 }
162 if (shown_header)
Kristian Høgsbergf26a0012007-09-18 00:06:42163 wt_status_print_trailer(s);
Jeff Kingc91f0d92006-09-08 08:05:34164}
165
166static void wt_status_print_changed_cb(struct diff_queue_struct *q,
167 struct diff_options *options,
168 void *data)
169{
Jürgen Rühle6e458bf2007-01-02 19:26:22170 struct wt_status *s = data;
Jeff Kingc91f0d92006-09-08 08:05:34171 int i;
Jürgen Rühle6e458bf2007-01-02 19:26:22172 if (q->nr) {
Anders Melchiorsenbb914b12008-09-07 22:05:02173 int has_deleted = 0;
Jürgen Rühle2a3a3c22007-01-10 22:25:03174 s->workdir_dirty = 1;
Junio C Hamano4d229652007-01-11 23:34:41175 for (i = 0; i < q->nr; i++)
176 if (q->queue[i]->status == DIFF_STATUS_DELETED) {
Anders Melchiorsenbb914b12008-09-07 22:05:02177 has_deleted = 1;
Junio C Hamano4d229652007-01-11 23:34:41178 break;
179 }
Anders Melchiorsenbb914b12008-09-07 22:05:02180 wt_status_print_dirty_header(s, has_deleted);
Jürgen Rühle6e458bf2007-01-02 19:26:22181 }
Jeff Kingc91f0d92006-09-08 08:05:34182 for (i = 0; i < q->nr; i++)
Kristian Høgsbergf26a0012007-09-18 00:06:42183 wt_status_print_filepair(s, WT_STATUS_CHANGED, q->queue[i]);
Jeff Kingc91f0d92006-09-08 08:05:34184 if (q->nr)
Kristian Høgsbergf26a0012007-09-18 00:06:42185 wt_status_print_trailer(s);
Jeff Kingc91f0d92006-09-08 08:05:34186}
187
Jeff Kingc91f0d92006-09-08 08:05:34188static void wt_status_print_updated(struct wt_status *s)
189{
190 struct rev_info rev;
Jeff Kingc91f0d92006-09-08 08:05:34191 init_revisions(&rev, NULL);
Jeff Kingc1e255b2008-11-12 08:21:39192 setup_revisions(0, NULL, &rev,
193 s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
Jeff Kingc91f0d92006-09-08 08:05:34194 rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
195 rev.diffopt.format_callback = wt_status_print_updated_cb;
196 rev.diffopt.format_callback_data = s;
197 rev.diffopt.detect_rename = 1;
Jeff King50705912008-04-30 17:24:43198 rev.diffopt.rename_limit = 200;
Jeff Kingf714fb82007-12-03 06:58:37199 rev.diffopt.break_opt = 0;
Jeff Kingc91f0d92006-09-08 08:05:34200 run_diff_index(&rev, 1);
201}
202
203static void wt_status_print_changed(struct wt_status *s)
204{
205 struct rev_info rev;
Jeff Kingc91f0d92006-09-08 08:05:34206 init_revisions(&rev, "");
Jeff King49b8b292006-11-05 22:22:15207 setup_revisions(0, NULL, &rev, NULL);
Jeff Kingc91f0d92006-09-08 08:05:34208 rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
209 rev.diffopt.format_callback = wt_status_print_changed_cb;
210 rev.diffopt.format_callback_data = s;
211 run_diff_files(&rev, 0);
212}
213
Ping Yinac8d5af2008-04-12 15:05:32214static void wt_status_print_submodule_summary(struct wt_status *s)
215{
216 struct child_process sm_summary;
217 char summary_limit[64];
218 char index[PATH_MAX];
219 const char *env[] = { index, NULL };
220 const char *argv[] = {
221 "submodule",
222 "summary",
223 "--cached",
224 "--for-status",
225 "--summary-limit",
226 summary_limit,
227 s->amend ? "HEAD^" : "HEAD",
228 NULL
229 };
230
231 sprintf(summary_limit, "%d", wt_status_submodule_summary);
232 snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
233
234 memset(&sm_summary, 0, sizeof(sm_summary));
235 sm_summary.argv = argv;
236 sm_summary.env = env;
237 sm_summary.git_cmd = 1;
238 sm_summary.no_stdin = 1;
239 fflush(s->fp);
240 sm_summary.out = dup(fileno(s->fp)); /* run_command closes it */
241 run_command(&sm_summary);
242}
243
Jürgen Rühle6e458bf2007-01-02 19:26:22244static void wt_status_print_untracked(struct wt_status *s)
Jeff Kingc91f0d92006-09-08 08:05:34245{
246 struct dir_struct dir;
Jeff Kingc91f0d92006-09-08 08:05:34247 int i;
248 int shown_header = 0;
Brandon Caseyf285a2d2008-10-09 19:12:12249 struct strbuf buf = STRBUF_INIT;
Jeff Kingc91f0d92006-09-08 08:05:34250
Jeff Kingc91f0d92006-09-08 08:05:34251 memset(&dir, 0, sizeof(dir));
252
Johannes Schindelin2074cb02006-09-12 20:45:12253 if (!s->untracked) {
254 dir.show_other_directories = 1;
255 dir.hide_empty_directories = 1;
256 }
Junio C Hamano039bc642007-11-14 08:05:00257 setup_standard_excludes(&dir);
Jeff Kingc91f0d92006-09-08 08:05:34258
Linus Torvalds9fc42d62007-03-31 03:39:30259 read_directory(&dir, ".", "", 0, NULL);
Jeff Kingc91f0d92006-09-08 08:05:34260 for(i = 0; i < dir.nr; i++) {
Jeff Kingc91f0d92006-09-08 08:05:34261 struct dir_entry *ent = dir.entries[i];
Jeff King98fa4732008-10-16 15:07:26262 if (!cache_name_is_other(ent->name, ent->len))
263 continue;
Jeff Kingc91f0d92006-09-08 08:05:34264 if (!shown_header) {
Jürgen Rühle2a3a3c22007-01-10 22:25:03265 s->workdir_untracked = 1;
Anders Melchiorsenbb914b12008-09-07 22:05:02266 wt_status_print_untracked_header(s);
Jeff Kingc91f0d92006-09-08 08:05:34267 shown_header = 1;
268 }
Kristian Høgsbergf26a0012007-09-18 00:06:42269 color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
Johannes Schindelin367c9882007-11-11 17:35:41270 color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), "%s",
271 quote_path(ent->name, ent->len,
272 &buf, s->prefix));
Jeff Kingc91f0d92006-09-08 08:05:34273 }
Johannes Schindelin367c9882007-11-11 17:35:41274 strbuf_release(&buf);
Jeff Kingc91f0d92006-09-08 08:05:34275}
276
277static void wt_status_print_verbose(struct wt_status *s)
278{
279 struct rev_info rev;
Kristian Høgsberg99a12692007-11-22 02:54:49280
Jeff Kingc91f0d92006-09-08 08:05:34281 init_revisions(&rev, NULL);
Jeff King5ec11af2008-12-08 02:54:17282 DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
Jeff King1324fb62008-11-12 08:23:37283 setup_revisions(0, NULL, &rev,
284 s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
Jeff Kingc91f0d92006-09-08 08:05:34285 rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
286 rev.diffopt.detect_rename = 1;
Kristian Høgsberg4ba0cb22008-03-10 17:58:26287 rev.diffopt.file = s->fp;
288 rev.diffopt.close_file = 0;
Jeff King4f672ad2008-10-26 04:49:35289 /*
290 * If we're not going to stdout, then we definitely don't
291 * want color, since we are going to the commit message
292 * file (and even the "auto" setting won't work, since it
293 * will have checked isatty on stdout).
294 */
295 if (s->fp != stdout)
296 DIFF_OPT_CLR(&rev.diffopt, COLOR_DIFF);
Jeff Kingc91f0d92006-09-08 08:05:34297 run_diff_index(&rev, 1);
298}
299
Junio C Hamanob6975ab2008-07-02 07:52:16300static void wt_status_print_tracking(struct wt_status *s)
301{
302 struct strbuf sb = STRBUF_INIT;
303 const char *cp, *ep;
304 struct branch *branch;
305
306 assert(s->branch && !s->is_initial);
307 if (prefixcmp(s->branch, "refs/heads/"))
308 return;
309 branch = branch_get(s->branch + 11);
310 if (!format_tracking_info(branch, &sb))
311 return;
312
313 for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
314 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
315 "# %.*s", (int)(ep - cp), cp);
316 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
317}
318
Jeff Kingc91f0d92006-09-08 08:05:34319void wt_status_print(struct wt_status *s)
320{
Jürgen Rühle98bf8a42007-01-02 19:26:23321 unsigned char sha1[20];
Chris Parsons950ce2e2008-05-22 12:50:02322 const char *branch_color = color(WT_STATUS_HEADER);
Jürgen Rühle98bf8a42007-01-02 19:26:23323
Chris Parsons950ce2e2008-05-22 12:50:02324 s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
Junio C Hamanobda324c2007-01-03 09:09:34325 if (s->branch) {
326 const char *on_what = "On branch ";
327 const char *branch_name = s->branch;
Junio C Hamanocc44c762007-02-20 09:53:29328 if (!prefixcmp(branch_name, "refs/heads/"))
Junio C Hamanobda324c2007-01-03 09:09:34329 branch_name += 11;
330 else if (!strcmp(branch_name, "HEAD")) {
331 branch_name = "";
Chris Parsons950ce2e2008-05-22 12:50:02332 branch_color = color(WT_STATUS_NOBRANCH);
Junio C Hamanobda324c2007-01-03 09:09:34333 on_what = "Not currently on any branch.";
334 }
Chris Parsons950ce2e2008-05-22 12:50:02335 color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
336 color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
Junio C Hamanob6975ab2008-07-02 07:52:16337 if (!s->is_initial)
338 wt_status_print_tracking(s);
Junio C Hamanobda324c2007-01-03 09:09:34339 }
Jeff Kingc91f0d92006-09-08 08:05:34340
341 if (s->is_initial) {
Kristian Høgsbergf26a0012007-09-18 00:06:42342 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
343 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "# Initial commit");
344 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
Jeff Kingc91f0d92006-09-08 08:05:34345 }
346
Jeff Kingc1e255b2008-11-12 08:21:39347 wt_status_print_updated(s);
Jeff Kingc91f0d92006-09-08 08:05:34348 wt_status_print_changed(s);
Ping Yinac8d5af2008-04-12 15:05:32349 if (wt_status_submodule_summary)
350 wt_status_print_submodule_summary(s);
Marius Storm-Olsen6c2ce042008-06-05 12:22:56351 if (show_untracked_files)
352 wt_status_print_untracked(s);
353 else if (s->commitable)
354 fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
Jeff Kingc91f0d92006-09-08 08:05:34355
Jeff King1324fb62008-11-12 08:23:37356 if (s->verbose)
Jeff Kingc91f0d92006-09-08 08:05:34357 wt_status_print_verbose(s);
Jürgen Rühle6e458bf2007-01-02 19:26:22358 if (!s->commitable) {
359 if (s->amend)
Kristian Høgsbergf26a0012007-09-18 00:06:42360 fprintf(s->fp, "# No changes\n");
Junio C Hamano37d07f82007-12-13 03:09:16361 else if (s->nowarn)
362 ; /* nothing */
Jürgen Rühle2a3a3c22007-01-10 22:25:03363 else if (s->workdir_dirty)
Nicolas Pitredcbc7bb2007-01-14 02:23:55364 printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
Jürgen Rühle2a3a3c22007-01-10 22:25:03365 else if (s->workdir_untracked)
366 printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
367 else if (s->is_initial)
368 printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
Marius Storm-Olsen6c2ce042008-06-05 12:22:56369 else if (!show_untracked_files)
370 printf("nothing to commit (use -u to show untracked files)\n");
Jürgen Rühle2a3a3c22007-01-10 22:25:03371 else
372 printf("nothing to commit (working directory clean)\n");
Jürgen Rühle6e458bf2007-01-02 19:26:22373 }
Jeff Kingc91f0d92006-09-08 08:05:34374}
375
Johannes Schindelinef90d6d2008-05-14 17:46:53376int git_status_config(const char *k, const char *v, void *cb)
Jeff Kingc91f0d92006-09-08 08:05:34377{
Ping Yinac8d5af2008-04-12 15:05:32378 if (!strcmp(k, "status.submodulesummary")) {
379 int is_bool;
380 wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);
381 if (is_bool && wt_status_submodule_summary)
382 wt_status_submodule_summary = -1;
383 return 0;
384 }
Andy Parkinsa159ca02006-12-13 09:13:28385 if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
Junio C Hamano0f6f5a42007-12-06 01:26:11386 wt_status_use_color = git_config_colorbool(k, v, -1);
Jeff Kingc91f0d92006-09-08 08:05:34387 return 0;
388 }
Junio C Hamano1968d772007-02-20 09:55:07389 if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
Jeff Kingc91f0d92006-09-08 08:05:34390 int slot = parse_status_slot(k, 13);
Junio C Hamano451d36b2008-02-11 19:00:57391 if (!v)
392 return config_error_nonbool(k);
Jeff Kingc91f0d92006-09-08 08:05:34393 color_parse(v, k, wt_status_colors[slot]);
Jeff King46f721c2007-12-07 21:26:07394 return 0;
395 }
396 if (!strcmp(k, "status.relativepaths")) {
397 wt_status_relative_paths = git_config_bool(k, v);
398 return 0;
Jeff Kingc91f0d92006-09-08 08:05:34399 }
Marius Storm-Olsend6293d12008-06-05 12:47:50400 if (!strcmp(k, "status.showuntrackedfiles")) {
401 if (!v)
Christian Couderc96a6d32008-07-06 04:10:04402 return config_error_nonbool(k);
Marius Storm-Olsend6293d12008-06-05 12:47:50403 else if (!strcmp(v, "no"))
404 show_untracked_files = SHOW_NO_UNTRACKED_FILES;
405 else if (!strcmp(v, "normal"))
406 show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
407 else if (!strcmp(v, "all"))
408 show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
409 else
410 return error("Invalid untracked files mode '%s'", v);
411 return 0;
412 }
Jeff King4f672ad2008-10-26 04:49:35413 return git_diff_ui_config(k, v, cb);
Jeff Kingc91f0d92006-09-08 08:05:34414}