From dd4a6cf555066441fc4a804d668a0003f923bb9e Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Fri, 10 Jul 2020 15:59:06 +0200 Subject: [PATCH] Pass stash args through As the stash reference does not necessarily match the line number anymore, take it from the output of git stash list. Closes #1022 --- NEWS.adoc | 1 + doc/tig.1.adoc | 2 +- src/stash.c | 8 ++++++-- src/tig.c | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index 4b25b2a29..96bcabbf2 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -10,6 +10,7 @@ Improvements: - Start blame of an uncommitted deleted line from HEAD so the line's origin can be traced. (#1008) - Add line-graphics = auto. (#834) - Allow maxwidth to be expressed in % of the view width. + - Pass stash args through. (#1022) Bug fixes: diff --git a/doc/tig.1.adoc b/doc/tig.1.adoc index a6c475272..1388dcb83 100644 --- a/doc/tig.1.adoc +++ b/doc/tig.1.adoc @@ -18,7 +18,7 @@ tig reflog [options] [revisions] tig blame [options] [rev] [--] path tig grep [options] [pattern] tig refs [options] -tig stash +tig stash [options] tig status tig < [Git command output] _______________________________________________________________________ diff --git a/src/stash.c b/src/stash.c index 72ce91fd0..232a6a328 100644 --- a/src/stash.c +++ b/src/stash.c @@ -20,7 +20,7 @@ static enum status_code stash_open(struct view *view, enum open_flags flags) { static const char *stash_argv[] = { "git", "stash", "list", - encoding_arg, "--no-color", "--pretty=raw", NULL }; + encoding_arg, "--no-color", "--pretty=raw", "%(revargs)", NULL }; struct main_state *state = view->private; state->with_graph = false; @@ -31,8 +31,12 @@ stash_open(struct view *view, enum open_flags flags) static void stash_select(struct view *view, struct line *line) { + struct main_state *state = view->private; + main_select(view, line); - string_format(view->env->stash, "stash@{%d}", line->lineno - 1); + assert(state->reflogs >= line->lineno); + string_ncopy(view->env->stash, state->reflog[line->lineno - 1] + STRING_SIZE("refs/"), + strlen(state->reflog[line->lineno - 1]) - STRING_SIZE("refs/")); string_copy(view->ref, view->env->stash); } diff --git a/src/tig.c b/src/tig.c index eedbf7906..c4ffa0ad6 100644 --- a/src/tig.c +++ b/src/tig.c @@ -378,7 +378,7 @@ static const char usage_string[] = " or: tig blame [options] [rev] [--] path\n" " or: tig grep [options] [pattern]\n" " or: tig refs [options]\n" -" or: tig stash\n" +" or: tig stash [options]\n" " or: tig status\n" " or: tig < [git command output]\n" "\n"