зеркало из https://github.com/microsoft/git.git
Merge branch 'ow/stash-count-in-status-porcelain-output'
Allow "git status --porcelain=v2" to show the number of stash entries with --show-stash like the normal output does. * ow/stash-count-in-status-porcelain-output: status: print stash info with --porcelain=v2 --show-stash status: count stash entries in separate function
This commit is contained in:
Коммит
dea96aae4d
|
@ -314,6 +314,14 @@ Line Notes
|
|||
------------------------------------------------------------
|
||||
....
|
||||
|
||||
Stash Information
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
If `--show-stash` is given, one line is printed showing the number of stash
|
||||
entries if non-zero:
|
||||
|
||||
# stash <N>
|
||||
|
||||
Changed Tracked Entries
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -113,6 +113,21 @@ test_expect_success 'after first commit, create unstaged changes' '
|
|||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'after first commit, stash existing changes' '
|
||||
cat >expect <<-EOF &&
|
||||
# branch.oid $H0
|
||||
# branch.head initial-branch
|
||||
# stash 2
|
||||
EOF
|
||||
|
||||
test_when_finished "git stash pop && git stash pop" &&
|
||||
|
||||
git stash -- file_x &&
|
||||
git stash &&
|
||||
git status --porcelain=v2 --branch --show-stash --untracked-files=no >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'after first commit but omit untracked files and branch' '
|
||||
cat >expect <<-EOF &&
|
||||
1 .M N... 100644 100644 100644 $OID_X $OID_X file_x
|
||||
|
|
25
wt-status.c
25
wt-status.c
|
@ -948,11 +948,17 @@ static int stash_count_refs(struct object_id *ooid, struct object_id *noid,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int count_stash_entries(void)
|
||||
{
|
||||
int n = 0;
|
||||
for_each_reflog_ent("refs/stash", stash_count_refs, &n);
|
||||
return n;
|
||||
}
|
||||
|
||||
static void wt_longstatus_print_stash_summary(struct wt_status *s)
|
||||
{
|
||||
int stash_count = 0;
|
||||
int stash_count = count_stash_entries();
|
||||
|
||||
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",
|
||||
|
@ -2176,6 +2182,18 @@ static void wt_porcelain_v2_print_tracking(struct wt_status *s)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the stash count in a porcelain-friendly format
|
||||
*/
|
||||
static void wt_porcelain_v2_print_stash(struct wt_status *s)
|
||||
{
|
||||
int stash_count = count_stash_entries();
|
||||
char eol = s->null_termination ? '\0' : '\n';
|
||||
|
||||
if (stash_count > 0)
|
||||
fprintf(s->fp, "# stash %d%c", stash_count, eol);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert various submodule status values into a
|
||||
* fixed-length string of characters in the buffer provided.
|
||||
|
@ -2437,6 +2455,9 @@ static void wt_porcelain_v2_print(struct wt_status *s)
|
|||
if (s->show_branch)
|
||||
wt_porcelain_v2_print_tracking(s);
|
||||
|
||||
if (s->show_stash)
|
||||
wt_porcelain_v2_print_stash(s);
|
||||
|
||||
for (i = 0; i < s->change.nr; i++) {
|
||||
it = &(s->change.items[i]);
|
||||
d = it->util;
|
||||
|
|
Загрузка…
Ссылка в новой задаче