aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2008-09-25 09:32:49 -0700
committerShawn O. Pearce <spearce@spearce.org>2008-09-25 09:32:49 -0700
commit6ef1daf77202aee71056771d91dd12121c6061fd (patch)
treecb25d90152aa22fdcf73e50c62cdc403c0d11666
parentd22d53db6550d9acc773c3896869cba812f7afb5 (diff)
parent4d6e4c4d34435c777bd844fe5ee0ec1ca06ffa4a (diff)
downloadgit-6ef1daf77202aee71056771d91dd12121c6061fd.tar.gz
git-6ef1daf77202aee71056771d91dd12121c6061fd.tar.xz
Merge branch 'am/status'
* am/status: wt-status: Teach how to discard changes in the working directory wt-status: Split header generation into three functions
-rwxr-xr-xt/t7502-status.sh10
-rw-r--r--wt-status.c35
2 files changed, 30 insertions, 15 deletions
diff --git a/t/t7502-status.sh b/t/t7502-status.sh
index c8e4c2e7b..1905fb34c 100755
--- a/t/t7502-status.sh
+++ b/t/t7502-status.sh
@@ -46,6 +46,7 @@ cat > expect << \EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
@@ -76,6 +77,7 @@ cat >expect <<EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
@@ -104,6 +106,7 @@ cat >expect <<EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
@@ -138,6 +141,7 @@ cat >expect <<EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
@@ -174,6 +178,7 @@ cat > expect << \EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: modified
#
@@ -204,6 +209,7 @@ cat > expect << \EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
@@ -267,6 +273,7 @@ cat >expect <<EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
@@ -297,6 +304,7 @@ cat >expect <<EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
@@ -326,6 +334,7 @@ cat >expect <<EOF
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
@@ -357,6 +366,7 @@ cat >expect <<EOF
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
diff --git a/wt-status.c b/wt-status.c
index 889e50f89..7cf890f24 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -22,12 +22,6 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
"\033[31m", /* WT_STATUS_NOBRANCH: red */
};
-static const char use_add_msg[] =
-"use \"git add <file>...\" to update what will be committed";
-static const char use_add_rm_msg[] =
-"use \"git add/rm <file>...\" to update what will be committed";
-static const char use_add_to_include_msg[] =
-"use \"git add <file>...\" to include in what will be committed";
enum untracked_status_type show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
static int parse_status_slot(const char *var, int offset)
@@ -76,12 +70,24 @@ static void wt_status_print_cached_header(struct wt_status *s)
color_fprintf_ln(s->fp, c, "#");
}
-static void wt_status_print_header(struct wt_status *s,
- const char *main, const char *sub)
+static void wt_status_print_dirty_header(struct wt_status *s,
+ int has_deleted)
{
const char *c = color(WT_STATUS_HEADER);
- color_fprintf_ln(s->fp, c, "# %s:", main);
- color_fprintf_ln(s->fp, c, "# (%s)", sub);
+ color_fprintf_ln(s->fp, c, "# Changed but not updated:");
+ if (!has_deleted)
+ color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to update what will be committed)");
+ else
+ color_fprintf_ln(s->fp, c, "# (use \"git add/rm <file>...\" to update what will be committed)");
+ color_fprintf_ln(s->fp, c, "# (use \"git checkout -- <file>...\" to discard changes in working directory)");
+ color_fprintf_ln(s->fp, c, "#");
+}
+
+static void wt_status_print_untracked_header(struct wt_status *s)
+{
+ const char *c = color(WT_STATUS_HEADER);
+ color_fprintf_ln(s->fp, c, "# Untracked files:");
+ color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)");
color_fprintf_ln(s->fp, c, "#");
}
@@ -166,14 +172,14 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
struct wt_status *s = data;
int i;
if (q->nr) {
- const char *msg = use_add_msg;
+ int has_deleted = 0;
s->workdir_dirty = 1;
for (i = 0; i < q->nr; i++)
if (q->queue[i]->status == DIFF_STATUS_DELETED) {
- msg = use_add_rm_msg;
+ has_deleted = 1;
break;
}
- wt_status_print_header(s, "Changed but not updated", msg);
+ wt_status_print_dirty_header(s, has_deleted);
}
for (i = 0; i < q->nr; i++)
wt_status_print_filepair(s, WT_STATUS_CHANGED, q->queue[i]);
@@ -291,8 +297,7 @@ static void wt_status_print_untracked(struct wt_status *s)
}
if (!shown_header) {
s->workdir_untracked = 1;
- wt_status_print_header(s, "Untracked files",
- use_add_to_include_msg);
+ wt_status_print_untracked_header(s);
shown_header = 1;
}
color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");