Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stash view when using tig --all or tig revs #1147

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/stash.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,35 @@ 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", "%(revargs)", NULL };
encoding_arg, "--no-color", "--pretty=raw", NULL };
const char **argv = NULL;
struct main_state *state = view->private;
enum status_code code;

if (!(repo.is_inside_work_tree || *repo.worktree))
return error("The stash view requires a working tree");

/* git stash list only works well with commit limiting options,
* so filter --all, --branches, --remotes and revisions from
* %(revargs). */
if (!argv_append_array(&argv, stash_argv))
return ERROR_OUT_OF_MEMORY;
if (opt_rev_args) {
int i;
for (i = 0; opt_rev_args[i]; i++) {
const char *arg = opt_rev_args[i];
if (arg[0] == '-' && strcmp(arg, "--all") &&
strcmp(arg, "--branches") && strcmp(arg, "--remotes"))
argv_append(&argv, arg);
}
}

state->with_graph = false;
watch_register(&view->watch, WATCH_STASH);
return begin_update(view, NULL, stash_argv, flags | OPEN_RELOAD);
code = begin_update(view, NULL, argv, flags | OPEN_RELOAD);
argv_free(argv);
free(argv);
return code;
}

static void
Expand Down