aboutsummaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/wt-status.c b/wt-status.c
index c711ef86e..8d2fb35b0 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -137,6 +137,7 @@ void wt_status_prepare(struct wt_status *s)
s->untracked.strdup_strings = 1;
s->ignored.strdup_strings = 1;
s->show_branch = -1; /* unspecified */
+ s->show_stash = 0;
s->display_comment_prefix = 0;
}
@@ -665,7 +666,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
dir.untracked = the_index.untracked;
setup_standard_excludes(&dir);
- fill_directory(&dir, &s->pathspec);
+ fill_directory(&dir, &the_index, &s->pathspec);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
@@ -801,6 +802,27 @@ static void wt_longstatus_print_changed(struct wt_status *s)
wt_longstatus_print_trailer(s);
}
+static int stash_count_refs(struct object_id *ooid, struct object_id *noid,
+ const char *email, timestamp_t timestamp, int tz,
+ const char *message, void *cb_data)
+{
+ int *c = cb_data;
+ (*c)++;
+ return 0;
+}
+
+static void wt_longstatus_print_stash_summary(struct wt_status *s)
+{
+ int stash_count = 0;
+
+ for_each_reflog_ent("refs/stash", stash_count_refs, &stash_count);
+ if (stash_count > 0)
+ status_printf_ln(s, GIT_COLOR_NORMAL,
+ Q_("Your stash currently has %d entry",
+ "Your stash currently has %d entries", stash_count),
+ stash_count);
+}
+
static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncommitted)
{
struct child_process sm_summary = CHILD_PROCESS_INIT;
@@ -1003,7 +1025,7 @@ static void wt_longstatus_print_tracking(struct wt_status *s)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
comment_line_char);
else
- fputs("", s->fp);
+ fputs("\n", s->fp);
}
static int has_unmerged(struct wt_status *s)
@@ -1066,7 +1088,8 @@ static void show_am_in_progress(struct wt_status *s,
static char *read_line_from_git_path(const char *filename)
{
struct strbuf buf = STRBUF_INIT;
- FILE *fp = fopen(git_path("%s", filename), "r");
+ FILE *fp = fopen_or_warn(git_path("%s", filename), "r");
+
if (!fp) {
strbuf_release(&buf);
return NULL;
@@ -1389,7 +1412,7 @@ struct grab_1st_switch_cbdata {
};
static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,
- const char *email, unsigned long timestamp, int tz,
+ const char *email, timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{
struct grab_1st_switch_cbdata *cb = cb_data;
@@ -1430,7 +1453,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
/* sha1 is a commit? match without further lookup */
(!oidcmp(&cb.noid, &oid) ||
/* perhaps sha1 is a tag, try to dereference to a commit */
- ((commit = lookup_commit_reference_gently(oid.hash, 1)) != NULL &&
+ ((commit = lookup_commit_reference_gently(&oid, 1)) != NULL &&
!oidcmp(&cb.noid, &commit->object.oid)))) {
const char *from = ref;
if (!skip_prefix(from, "refs/tags/", &from))
@@ -1644,6 +1667,8 @@ static void wt_longstatus_print(struct wt_status *s)
} else
printf(_("nothing to commit, working tree clean\n"));
}
+ if(s->show_stash)
+ wt_longstatus_print_stash_summary(s);
}
static void wt_shortstatus_unmerged(struct string_list_item *it,