summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorLiam Beguin <liambeguin@gmail.com>2017-06-17 22:30:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-19 05:17:47 (GMT)
commitc1b5d0194b98bd3d0acc9cec7070808fbbe6a740 (patch)
tree05c81f1a33815352c41e1a0b17bdeb005913379e /wt-status.c
parente01db917d8e5c66f9f90bf8c44995cf47200273a (diff)
downloadgit-c1b5d0194b98bd3d0acc9cec7070808fbbe6a740.zip
git-c1b5d0194b98bd3d0acc9cec7070808fbbe6a740.tar.gz
git-c1b5d0194b98bd3d0acc9cec7070808fbbe6a740.tar.bz2
status: add optional stash count information
Introduce '--show-stash' and its configuration option 'status.showStash' to allow git-status to show information about currently stashed entries. Signed-off-by: Liam Beguin <liambeguin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/wt-status.c b/wt-status.c
index bf651f1..7992a73 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;
}
@@ -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;
@@ -1642,6 +1664,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,