Skip to content

Commit

Permalink
Pass stash args through
Browse files Browse the repository at this point in the history
As the stash reference does not necessarily match the line number anymore,
take it from the output of git stash list.

Closes jonas#1022
  • Loading branch information
koutcher committed Oct 13, 2020
1 parent e0fc1f4 commit 7e5e23d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ master
Improvements:

- Jump from blame to commit. (#355)
- Pass stash args through. (#1022)

Bug fixes:

Expand Down
2 changes: 1 addition & 1 deletion doc/tig.1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
_______________________________________________________________________
Expand Down
8 changes: 6 additions & 2 deletions src/stash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/tig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7e5e23d

Please sign in to comment.