Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
koutcher committed May 10, 2024
2 parents d21cae3 + 587a59a commit e1796c9
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 29 deletions.
4 changes: 2 additions & 2 deletions INSTALL.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Download a tarball from https://github.com/jonas/tig/releases[] or clone the Tig
repository https://github.com/jonas/tig[https://github.com/jonas/tig.git].

The latest version is:
https://github.com/jonas/tig/releases/download/tig-2.5.9/tig-2.5.9.tar.gz[tig-2.5.9]
https://github.com/jonas/tig/releases/download/tig-2.5.9/tig-2.5.9.tar.gz.sha256[(sha256)]
https://github.com/jonas/tig/releases/download/tig-2.5.10/tig-2.5.10.tar.gz[tig-2.5.10]
https://github.com/jonas/tig/releases/download/tig-2.5.10/tig-2.5.10.tar.gz.sha256[(sha256)]

*Note:* Do not use the tar.gz file for version 2.0 because it will fail
to compile due to issue https://github.com/jonas/tig/pull/283[#283] and
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# The last tagged version. Can be overridden either by the version from
# git or from the value of the DIST_VERSION environment variable.
VERSION = 2.5.9
VERSION = 2.5.10

all:

Expand Down
13 changes: 13 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Release notes
=============

tig-2.5.10
----------

Bug fixes:

- Fix `stat-*` coloring file names in `tig status` instead of just
markers (regression in 2.5.9). (#1326)
- Fix keybinding with +[cmd] not triggering view refreshing. (#1324)
- Fix reopening the blame view from the main view.
- Fix editing when stdin is redirected. (#1330)
- Fix compilation warnings with ncurses 6.5.
- Make `Ctrl-C` to kill only the command running in the foreground. (#1331)

tig-2.5.9
---------
Expand Down
2 changes: 1 addition & 1 deletion include/tig/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool io_done(struct io *io);
bool io_exec(struct io *io, enum io_type type, const char *dir, char * const env[], const char *argv[], int custom);
bool io_run(struct io *io, enum io_type type, const char *dir, char * const env[], const char *argv[]);
bool io_run_bg(const char **argv, const char *dir);
bool io_run_fg(const char **argv, const char *dir);
bool io_run_fg(const char **argv, const char *dir, int fd);
bool io_run_append(const char **argv, int fd);
bool io_eof(struct io *io);
int io_error(struct io *io);
Expand Down
2 changes: 2 additions & 0 deletions include/tig/tig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
#endif

/* necessary on Snow Leopard to use WINDOW struct */
#if defined(NCURSES_VERSION_PATCH) && NCURSES_VERSION_PATCH < 20110226
#ifdef NCURSES_OPAQUE
#undef NCURSES_OPAQUE
#endif
#define NCURSES_OPAQUE 0
#endif


#include <assert.h>
Expand Down
11 changes: 9 additions & 2 deletions src/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ blame_open(struct view *view, enum open_flags flags)

if (!view->env->file[0] && opt_file_args && !opt_file_args[1]) {
const char *ls_tree_argv[] = {
"git", "ls-tree", "-d", "-z", *view->env->ref ? view->env->ref : view->env->commit, opt_file_args[0], NULL
"git", "ls-tree", "-d", "-z", *view->env->ref ? view->env->ref : "HEAD", opt_file_args[0], NULL
};
char buf[SIZEOF_STR] = "";

Expand Down Expand Up @@ -457,6 +457,10 @@ blame_request(struct view *view, enum request request, struct line *line)
open_main_view(view, OPEN_RELOAD);
break;

case REQ_VIEW_BLOB:
string_ncopy(view->env->file, blame->commit->filename, strlen(blame->commit->filename));
return request;

default:
return request;
}
Expand All @@ -482,7 +486,10 @@ blame_select(struct view *view, struct line *line)
string_format(view->ref, "%s changed %s", commit->id, commit->filename);
}

string_ncopy(view->env->file, commit->filename, strlen(commit->filename));
if (strcmp(commit->filename, view->env->file))
string_format(view->env->file_old, "%s", commit->filename);
else
view->env->file_old[0] = '\0';

view->env->lineno = view->pos.lineno + 1;
string_ncopy(view->env->text, text, strlen(text));
Expand Down
15 changes: 7 additions & 8 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,23 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf
bool ok;

if (echo) {
struct io io;
char buf[SIZEOF_STR] = "";

io_run_buf(argv, buf, sizeof(buf), dir, false);
if (*buf) {
ok = io_exec(&io, IO_RD, dir, NULL, argv, IO_RD_WITH_STDERR) && io_read_buf(&io, buf, sizeof(buf), true);
if (*buf)
report("%s", buf);
return true;
} else {
report("No output");
return false;
}

} else if (silent || is_script_executing()) {
ok = io_run_bg(argv, dir);

} else {
signal(SIGINT, SIG_IGN);
clear();
refresh();
endwin(); /* restore original tty modes */
tcsetattr(opt_tty.fd, TCSAFLUSH, opt_tty.attr);
ok = io_run_fg(argv, dir);
ok = io_run_fg(argv, dir, opt_tty.fd);
if (confirm || !ok) {
if (!ok && *notice)
fprintf(stderr, "%s", notice);
Expand All @@ -104,6 +102,7 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf
fseek(opt_tty.file, 0, SEEK_END);
tcsetattr(opt_tty.fd, TCSAFLUSH, opt_tty.attr);
set_terminal_modes();
signal(SIGINT, SIG_DFL);
}

if (watch_update(WATCH_EVENT_AFTER_COMMAND) && do_refresh) {
Expand Down
12 changes: 7 additions & 5 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,12 @@ draw_id(struct view *view, struct view_column *column, const char *id)
}

static bool
draw_filename(struct view *view, struct view_column *column, enum line_type type, const char *filename)
draw_filename(struct view *view, struct view_column *column, const char *filename, mode_t mode)
{
size_t width = filename ? utf8_width(filename) : 0;
bool trim = width >= column->width;
/* Note, type for filename field is independent from line->type. */
enum line_type type = S_ISDIR(mode) ? LINE_DIRECTORY : LINE_FILE;
int column_width = column->width ? column->width : width;

if (column->opt.file_name.display == FILENAME_NO)
Expand All @@ -289,9 +291,9 @@ draw_filename(struct view *view, struct view_column *column, enum line_type type
}

static bool
draw_file_size(struct view *view, struct view_column *column, enum line_type type, unsigned long size)
draw_file_size(struct view *view, struct view_column *column, unsigned long size, mode_t mode)
{
const char *str = type == LINE_FILE ? mkfilesize(size, column->opt.file_size.display) : NULL;
const char *str = S_ISREG(mode) ? mkfilesize(size, column->opt.file_size.display) : NULL;

if (!column->width || column->opt.file_size.display == FILE_SIZE_NO)
return false;
Expand Down Expand Up @@ -517,7 +519,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno)
continue;

case VIEW_COLUMN_FILE_SIZE:
if (draw_file_size(view, column, line->type, column_data.file_size ? *column_data.file_size : 0))
if (draw_file_size(view, column, column_data.file_size ? *column_data.file_size : 0, mode))
return true;
continue;

Expand All @@ -528,7 +530,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno)
continue;

case VIEW_COLUMN_FILE_NAME:
if (draw_filename(view, column, line->type, column_data.file_name))
if (draw_filename(view, column, column_data.file_name, mode))
return true;
continue;

Expand Down
18 changes: 15 additions & 3 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ open_trace(int devnull, const char *argv[])
bool
io_trace(const char *fmt, ...)
{
static FILE *trace_out; /* Intensionally leaked. */
static FILE *trace_out; /* Intentionally leaked. */
va_list args;
int retval;

Expand Down Expand Up @@ -418,6 +418,11 @@ io_exec(struct io *io, enum io_type type, const char *dir, char * const env[], c
close(pipefds[0]);
if (pipefds[1] != -1)
close(pipefds[1]);
} else {
if (custom != -1) {
dup2(custom, STDIN_FILENO);
close(custom);
}
}

if (dir && *dir && chdir(dir) == -1)
Expand All @@ -431,6 +436,13 @@ io_exec(struct io *io, enum io_type type, const char *dir, char * const env[], c
putenv(env[i]);
}

signal(SIGHUP, SIG_DFL);
signal(SIGINT, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
#ifdef DEBUG
signal(SIGSEGV, SIG_DFL);
#endif

execvp(argv[0], (char *const*) argv);

close(STDOUT_FILENO);
Expand Down Expand Up @@ -463,9 +475,9 @@ io_run_bg(const char **argv, const char *dir)
}

bool
io_run_fg(const char **argv, const char *dir)
io_run_fg(const char **argv, const char *dir, int fd)
{
return io_complete(IO_FG, argv, dir, -1);
return io_complete(IO_FG, argv, dir, fd);
}

bool
Expand Down
8 changes: 8 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ main_request(struct view *view, enum request request, struct line *line)
line->type == LINE_STAT_STAGED ||
line->type == LINE_STAT_UNTRACKED))
? OPEN_SPLIT : OPEN_DEFAULT;
struct commit *commit = line->data;

switch (request) {
case REQ_VIEW_DIFF:
Expand Down Expand Up @@ -576,6 +577,13 @@ main_request(struct view *view, enum request request, struct line *line)
return request;
break;

case REQ_VIEW_BLAME:
if (string_rev_is_null(commit->id))
view->env->ref[0] = 0;
else
string_copy_rev(view->env->ref, commit->id);
return request;

case REQ_REFRESH:
load_refs(true);
refresh_view(view);
Expand Down
4 changes: 2 additions & 2 deletions src/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,13 @@ status_revert(struct status *status, enum line_type type, bool has_none)
reset_argv[4] = NULL;
}

if (!io_run_fg(reset_argv, repo.exec_dir))
if (!io_run_fg(reset_argv, repo.exec_dir, -1))
return false;
if (status->old.mode == 0 && status->new.mode == 0)
return true;
}

return io_run_fg(checkout_argv, repo.exec_dir);
return io_run_fg(checkout_argv, repo.exec_dir, -1);
}

return false;
Expand Down
5 changes: 2 additions & 3 deletions src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ tree_read(struct view *view, struct buffer *buf, bool force_stop)
struct tree_state *state = view->private;
struct tree_entry *data;
struct line *entry, *line;
enum line_type type;
/* Note, type computed here is only used for sorting, not for drawing. */
enum line_type type = LINE_DEFAULT;
char *pos;
char *mode;
char *id;
Expand All @@ -238,8 +239,6 @@ tree_read(struct view *view, struct buffer *buf, bool force_stop)
type = LINE_FILE;
else if (!strncmp(pos, "tree", STRING_SIZE("tree")))
type = LINE_DIRECTORY;
else
type = LINE_DEFAULT;

/* 95925677ca47beb0b8cce7c0e0011bcc3f61470f */
id = strchr(pos, ' ');
Expand Down
5 changes: 3 additions & 2 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,10 @@ load_view(struct view *view, struct view *prev, enum open_flags flags)
* the screen. */
werase(view->win);
/* Do not clear the position if it is the first view. */
if (view->prev && !(flags & (OPEN_RELOAD | OPEN_REFRESH)))
if (view->prev && !(flags & (OPEN_RELOAD | OPEN_REFRESH))) {
clear_position(&view->prev_pos);
report_clear();
report_clear();
}
} else if (view_is_displayed(view)) {
redraw_view(view);
report_clear();
Expand Down

0 comments on commit e1796c9

Please sign in to comment.