Skip to content

Commit

Permalink
Single file view should enter blame mode on "b" #804
Browse files Browse the repository at this point in the history
  • Loading branch information
koutcher committed Dec 14, 2018
1 parent f7ad721 commit ee9972c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,20 @@ blame_open(struct view *view, enum open_flags flags)

blame_update_file_name_visibility(view);

if (!view->env->file[0])
return error("No file chosen, press %s to open tree view",
get_view_key(view, REQ_VIEW_TREE));
if (!view->env->file[0]) {
if (opt_file_args && !opt_file_args[1]) {
const char *ls_files_argv[] = {
"git", "ls-files", "--full-name", "--", opt_file_args[0], NULL
};
char name[SIZEOF_STR] = "";

io_run_buf(ls_files_argv, name, sizeof(name), NULL, false);
string_ncopy(view->env->file, name, strlen(name));
} else {
return error("No file chosen, press %s to open tree view",
get_view_key(view, REQ_VIEW_TREE));
}
}

if (!view->prev && *repo.prefix && !(flags & (OPEN_RELOAD | OPEN_REFRESH))) {
string_copy(path, view->env->file);
Expand Down

0 comments on commit ee9972c

Please sign in to comment.