mirror of
https://github.com/jarun/nnn.git
synced 2025-01-22 08:46:38 +00:00
Fix gitstatus regression/restore preview conflict
This commit is contained in:
parent
1020f37320
commit
17bf7c97f6
|
@ -6,7 +6,7 @@
|
||||||
# Authors: Luuk van Baal, @crides
|
# Authors: Luuk van Baal, @crides
|
||||||
|
|
||||||
diff --git a/src/nnn.c b/src/nnn.c
|
diff --git a/src/nnn.c b/src/nnn.c
|
||||||
index 88263beb..597ff2b3 100644
|
index 897c32f1..00b57c2e 100644
|
||||||
--- a/src/nnn.c
|
--- a/src/nnn.c
|
||||||
+++ b/src/nnn.c
|
+++ b/src/nnn.c
|
||||||
@@ -285,6 +285,7 @@ typedef struct entry {
|
@@ -285,6 +285,7 @@ typedef struct entry {
|
||||||
|
@ -61,6 +61,7 @@ index 88263beb..597ff2b3 100644
|
||||||
+ char workdir[PATH_MAX], *ret;
|
+ char workdir[PATH_MAX], *ret;
|
||||||
+ FILE *fp = popen(gitrev, "r");
|
+ FILE *fp = popen(gitrev, "r");
|
||||||
+
|
+
|
||||||
|
+ git_statuses.show = FALSE;
|
||||||
+ ret = fgets(workdir, PATH_MAX, fp);
|
+ ret = fgets(workdir, PATH_MAX, fp);
|
||||||
+ pclose(fp);
|
+ pclose(fp);
|
||||||
+ if (!ret)
|
+ if (!ret)
|
||||||
|
@ -69,7 +70,6 @@ index 88263beb..597ff2b3 100644
|
||||||
+ static char gitstat[] = "git -c core.quotePath= status --porcelain --ignored=matching -u ";
|
+ static char gitstat[] = "git -c core.quotePath= status --porcelain --ignored=matching -u ";
|
||||||
+ char pathspec[PATH_MAX], status[PATH_MAX];
|
+ char pathspec[PATH_MAX], status[PATH_MAX];
|
||||||
+ size_t i = -1;
|
+ size_t i = -1;
|
||||||
+ git_statuses.show = FALSE;
|
|
||||||
+ workdir[xstrlen(workdir) - 1] = '\0';
|
+ workdir[xstrlen(workdir) - 1] = '\0';
|
||||||
+ snprintf(pathspec, PATH_MAX, "%s\"%s\"%s 2>/dev/null", gitstat, path, cfg.showhidden ? "" : "/*");
|
+ snprintf(pathspec, PATH_MAX, "%s\"%s\"%s 2>/dev/null", gitstat, path, cfg.showhidden ? "" : "/*");
|
||||||
+ fp = popen(pathspec, "r");
|
+ fp = popen(pathspec, "r");
|
||||||
|
@ -113,17 +113,20 @@ index 88263beb..597ff2b3 100644
|
||||||
#if _POSIX_C_SOURCE >= 200112L
|
#if _POSIX_C_SOURCE >= 200112L
|
||||||
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
|
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||||
#endif
|
#endif
|
||||||
@@ -5746,6 +5800,36 @@ static int dentfill(char *path, struct entry **ppdents)
|
@@ -5746,6 +5800,39 @@ static int dentfill(char *path, struct entry **ppdents)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
+ if (git_statuses.len) {
|
+ if (git_statuses.len) {
|
||||||
+ char dentpath[PATH_MAX], prefix[PATH_MAX + 1];
|
+ char dentpath[PATH_MAX];
|
||||||
+ size_t pathlen = mkpath(linkpath, dentp->name, dentpath);
|
+ size_t pathlen = mkpath(linkpath, dentp->name, dentpath);
|
||||||
+ snprintf(prefix, PATH_MAX + 1, "%s/", dentpath);
|
|
||||||
+ dentp->git_status[0] = dentp->git_status[1] = '-';
|
+ dentp->git_status[0] = dentp->git_status[1] = '-';
|
||||||
+
|
+
|
||||||
+ if (dentp->flags & DIR_OR_DIRLNK) {
|
+ if (dentp->flags & DIR_OR_DIRLNK) {
|
||||||
|
+ char prefix[PATH_MAX];
|
||||||
|
+ memccpy(prefix, dentpath, '\0', PATH_MAX);
|
||||||
|
+ prefix[pathlen - 1] = '/';
|
||||||
|
+
|
||||||
+ for (size_t i = 0; i < git_statuses.len; ++i)
|
+ for (size_t i = 0; i < git_statuses.len; ++i)
|
||||||
+ if (is_prefix(git_statuses.statuses[i].path, prefix, pathlen)) {
|
+ if (is_prefix(git_statuses.statuses[i].path, prefix, pathlen)) {
|
||||||
+ if ((dentp->git_status[0] == '-') && (git_statuses.statuses[i].status[0] != '-'))
|
+ if ((dentp->git_status[0] == '-') && (git_statuses.statuses[i].status[0] != '-'))
|
||||||
|
@ -150,7 +153,7 @@ index 88263beb..597ff2b3 100644
|
||||||
++ndents;
|
++ndents;
|
||||||
} while ((dp = readdir(dirp)));
|
} while ((dp = readdir(dirp)));
|
||||||
|
|
||||||
@@ -6270,11 +6354,12 @@ static int adjust_cols(int n)
|
@@ -6270,11 +6357,12 @@ static int adjust_cols(int n)
|
||||||
#endif
|
#endif
|
||||||
if (cfg.showdetail) {
|
if (cfg.showdetail) {
|
||||||
/* Fallback to light mode if less than 35 columns */
|
/* Fallback to light mode if less than 35 columns */
|
||||||
|
@ -166,7 +169,7 @@ index 88263beb..597ff2b3 100644
|
||||||
|
|
||||||
/* 2 columns for preceding space and indicator */
|
/* 2 columns for preceding space and indicator */
|
||||||
return (n - 2);
|
return (n - 2);
|
||||||
@@ -8034,6 +8119,7 @@ static void usage(void)
|
@@ -8030,6 +8118,7 @@ static void usage(void)
|
||||||
" -F val fifo mode [0:preview 1:explore]\n"
|
" -F val fifo mode [0:preview 1:explore]\n"
|
||||||
#endif
|
#endif
|
||||||
" -g regex filters\n"
|
" -g regex filters\n"
|
||||||
|
@ -174,7 +177,7 @@ index 88263beb..597ff2b3 100644
|
||||||
" -H show hidden files\n"
|
" -H show hidden files\n"
|
||||||
" -J no auto-proceed on select\n"
|
" -J no auto-proceed on select\n"
|
||||||
" -K detect key collision\n"
|
" -K detect key collision\n"
|
||||||
@@ -8174,6 +8260,7 @@ static void cleanup(void)
|
@@ -8170,6 +8259,7 @@ static void cleanup(void)
|
||||||
free(hostname);
|
free(hostname);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -182,7 +185,7 @@ index 88263beb..597ff2b3 100644
|
||||||
free(selpath);
|
free(selpath);
|
||||||
free(plgpath);
|
free(plgpath);
|
||||||
free(cfgpath);
|
free(cfgpath);
|
||||||
@@ -8218,7 +8305,7 @@ int main(int argc, char *argv[])
|
@@ -8214,7 +8304,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while ((opt = (env_opts_id > 0
|
while ((opt = (env_opts_id > 0
|
||||||
? env_opts[--env_opts_id]
|
? env_opts[--env_opts_id]
|
||||||
|
@ -191,7 +194,7 @@ index 88263beb..597ff2b3 100644
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
#ifndef NOFIFO
|
#ifndef NOFIFO
|
||||||
case 'a':
|
case 'a':
|
||||||
@@ -8269,6 +8356,9 @@ int main(int argc, char *argv[])
|
@@ -8265,6 +8355,9 @@ int main(int argc, char *argv[])
|
||||||
cfg.regex = 1;
|
cfg.regex = 1;
|
||||||
filterfn = &visible_re;
|
filterfn = &visible_re;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
# Authors: Luuk van Baal, @crides
|
# Authors: Luuk van Baal, @crides
|
||||||
|
|
||||||
diff --git a/src/nnn.c b/src/nnn.c
|
diff --git a/src/nnn.c b/src/nnn.c
|
||||||
index 55f32e73..ed771826 100644
|
index 5801e28e..8a88d5e7 100644
|
||||||
--- a/src/nnn.c
|
--- a/src/nnn.c
|
||||||
+++ b/src/nnn.c
|
+++ b/src/nnn.c
|
||||||
@@ -285,6 +285,7 @@ typedef struct entry {
|
@@ -285,6 +285,7 @@ typedef struct entry {
|
||||||
|
@ -52,7 +52,7 @@ index 55f32e73..ed771826 100644
|
||||||
};
|
};
|
||||||
|
|
||||||
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
|
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
|
||||||
@@ -3822,6 +3835,38 @@ static int get_kv_key(kv *kvarr, char *val, uchar_t max, uchar_t id)
|
@@ -3822,6 +3835,39 @@ static int get_kv_key(kv *kvarr, char *val, uchar_t max, uchar_t id)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ index 55f32e73..ed771826 100644
|
||||||
+ char workdir[PATH_MAX], *ret;
|
+ char workdir[PATH_MAX], *ret;
|
||||||
+ FILE *fp = popen(gitrev, "r");
|
+ FILE *fp = popen(gitrev, "r");
|
||||||
+
|
+
|
||||||
|
+ git_statuses.show = FALSE;
|
||||||
+ ret = fgets(workdir, PATH_MAX, fp);
|
+ ret = fgets(workdir, PATH_MAX, fp);
|
||||||
+ pclose(fp);
|
+ pclose(fp);
|
||||||
+ if (!ret)
|
+ if (!ret)
|
||||||
|
@ -91,7 +92,7 @@ index 55f32e73..ed771826 100644
|
||||||
static void resetdircolor(int flags)
|
static void resetdircolor(int flags)
|
||||||
{
|
{
|
||||||
/* Directories are always shown on top, clear the color when moving to first file */
|
/* Directories are always shown on top, clear the color when moving to first file */
|
||||||
@@ -4132,6 +4177,9 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
|
@@ -4132,6 +4178,9 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
|
||||||
int attrs = 0, namelen;
|
int attrs = 0, namelen;
|
||||||
uchar_t color_pair = get_color_pair_name_ind(ent, &ind, &attrs);
|
uchar_t color_pair = get_color_pair_name_ind(ent, &ind, &attrs);
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ index 55f32e73..ed771826 100644
|
||||||
addch((ent->flags & FILE_SELECTED) ? '+' | A_REVERSE | A_BOLD : ' ');
|
addch((ent->flags & FILE_SELECTED) ? '+' | A_REVERSE | A_BOLD : ' ');
|
||||||
|
|
||||||
if (g_state.oldcolor)
|
if (g_state.oldcolor)
|
||||||
@@ -5554,6 +5602,11 @@ static int dentfill(char *path, struct entry **ppdents)
|
@@ -5554,6 +5603,11 @@ static int dentfill(char *path, struct entry **ppdents)
|
||||||
attron(COLOR_PAIR(cfg.curctx + 1));
|
attron(COLOR_PAIR(cfg.curctx + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,17 +114,20 @@ index 55f32e73..ed771826 100644
|
||||||
#if _POSIX_C_SOURCE >= 200112L
|
#if _POSIX_C_SOURCE >= 200112L
|
||||||
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
|
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||||
#endif
|
#endif
|
||||||
@@ -5752,6 +5805,36 @@ static int dentfill(char *path, struct entry **ppdents)
|
@@ -5752,6 +5806,39 @@ static int dentfill(char *path, struct entry **ppdents)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
+ if (git_statuses.len) {
|
+ if (git_statuses.len) {
|
||||||
+ char dentpath[PATH_MAX], prefix[PATH_MAX + 1];
|
+ char dentpath[PATH_MAX];
|
||||||
+ size_t pathlen = mkpath(linkpath, dentp->name, dentpath);
|
+ size_t pathlen = mkpath(linkpath, dentp->name, dentpath);
|
||||||
+ snprintf(prefix, PATH_MAX + 1, "%s/", dentpath);
|
|
||||||
+ dentp->git_status[0] = dentp->git_status[1] = '-';
|
+ dentp->git_status[0] = dentp->git_status[1] = '-';
|
||||||
+
|
+
|
||||||
+ if (dentp->flags & DIR_OR_DIRLNK) {
|
+ if (dentp->flags & DIR_OR_DIRLNK) {
|
||||||
|
+ char prefix[PATH_MAX];
|
||||||
|
+ memccpy(prefix, dentpath, '\0', PATH_MAX);
|
||||||
|
+ prefix[pathlen - 1] = '/';
|
||||||
|
+
|
||||||
+ for (size_t i = 0; i < git_statuses.len; ++i)
|
+ for (size_t i = 0; i < git_statuses.len; ++i)
|
||||||
+ if (is_prefix(git_statuses.statuses[i].path, prefix, pathlen)) {
|
+ if (is_prefix(git_statuses.statuses[i].path, prefix, pathlen)) {
|
||||||
+ if ((dentp->git_status[0] == '-') && (git_statuses.statuses[i].status[0] != '-'))
|
+ if ((dentp->git_status[0] == '-') && (git_statuses.statuses[i].status[0] != '-'))
|
||||||
|
@ -150,7 +154,7 @@ index 55f32e73..ed771826 100644
|
||||||
++ndents;
|
++ndents;
|
||||||
} while ((dp = readdir(dirp)));
|
} while ((dp = readdir(dirp)));
|
||||||
|
|
||||||
@@ -6267,7 +6350,8 @@ static int adjust_cols(int n)
|
@@ -6267,7 +6354,8 @@ static int adjust_cols(int n)
|
||||||
cfg.showdetail ^= 1;
|
cfg.showdetail ^= 1;
|
||||||
else /* 2 more accounted for below */
|
else /* 2 more accounted for below */
|
||||||
n -= (dtls.maxentln - 2 - dtls.maxnameln);
|
n -= (dtls.maxentln - 2 - dtls.maxnameln);
|
||||||
|
@ -160,7 +164,7 @@ index 55f32e73..ed771826 100644
|
||||||
|
|
||||||
/* 2 columns for preceding space and indicator */
|
/* 2 columns for preceding space and indicator */
|
||||||
return (n - 2);
|
return (n - 2);
|
||||||
@@ -6422,7 +6506,7 @@ static void redraw(char *path)
|
@@ -6422,7 +6510,7 @@ static void redraw(char *path)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -169,7 +173,7 @@ index 55f32e73..ed771826 100644
|
||||||
}
|
}
|
||||||
|
|
||||||
ncols = adjust_cols(ncols);
|
ncols = adjust_cols(ncols);
|
||||||
@@ -8040,6 +8124,7 @@ static void usage(void)
|
@@ -8036,6 +8124,7 @@ static void usage(void)
|
||||||
" -F val fifo mode [0:preview 1:explore]\n"
|
" -F val fifo mode [0:preview 1:explore]\n"
|
||||||
#endif
|
#endif
|
||||||
" -g regex filters\n"
|
" -g regex filters\n"
|
||||||
|
@ -177,7 +181,7 @@ index 55f32e73..ed771826 100644
|
||||||
" -H show hidden files\n"
|
" -H show hidden files\n"
|
||||||
" -J no auto-proceed on select\n"
|
" -J no auto-proceed on select\n"
|
||||||
" -K detect key collision\n"
|
" -K detect key collision\n"
|
||||||
@@ -8180,6 +8265,7 @@ static void cleanup(void)
|
@@ -8176,6 +8265,7 @@ static void cleanup(void)
|
||||||
free(hostname);
|
free(hostname);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -185,7 +189,7 @@ index 55f32e73..ed771826 100644
|
||||||
free(selpath);
|
free(selpath);
|
||||||
free(plgpath);
|
free(plgpath);
|
||||||
free(cfgpath);
|
free(cfgpath);
|
||||||
@@ -8224,7 +8310,7 @@ int main(int argc, char *argv[])
|
@@ -8220,7 +8310,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while ((opt = (env_opts_id > 0
|
while ((opt = (env_opts_id > 0
|
||||||
? env_opts[--env_opts_id]
|
? env_opts[--env_opts_id]
|
||||||
|
@ -194,7 +198,7 @@ index 55f32e73..ed771826 100644
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
#ifndef NOFIFO
|
#ifndef NOFIFO
|
||||||
case 'a':
|
case 'a':
|
||||||
@@ -8275,6 +8361,9 @@ int main(int argc, char *argv[])
|
@@ -8271,6 +8361,9 @@ int main(int argc, char *argv[])
|
||||||
cfg.regex = 1;
|
cfg.regex = 1;
|
||||||
filterfn = &visible_re;
|
filterfn = &visible_re;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# Authors: Luuk van Baal
|
# Authors: Luuk van Baal
|
||||||
|
|
||||||
diff --git a/src/nnn.c b/src/nnn.c
|
diff --git a/src/nnn.c b/src/nnn.c
|
||||||
index 88263beb..8aa24712 100644
|
index 897c32f1..cf589bc8 100644
|
||||||
--- a/src/nnn.c
|
--- a/src/nnn.c
|
||||||
+++ b/src/nnn.c
|
+++ b/src/nnn.c
|
||||||
@@ -367,7 +367,8 @@ typedef struct {
|
@@ -367,7 +367,8 @@ typedef struct {
|
||||||
|
@ -193,22 +193,22 @@ index 88263beb..8aa24712 100644
|
||||||
if (cfg.filtermode) {
|
if (cfg.filtermode) {
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
clearfilter();
|
clearfilter();
|
||||||
@@ -7206,7 +7245,14 @@ nochange:
|
@@ -7206,8 +7245,14 @@ nochange:
|
||||||
copycurname();
|
copycurname();
|
||||||
goto nochange;
|
goto nochange;
|
||||||
case SEL_EDIT:
|
case SEL_EDIT:
|
||||||
+ if (g_state.previewer)
|
+ if (g_state.previewer)
|
||||||
+ notify_fifo(FALSE, TRUE);
|
+ notify_fifo(FALSE, TRUE);
|
||||||
spawn(editor, newpath, NULL, NULL, F_CLI);
|
if (!g_state.picker)
|
||||||
|
spawn(editor, newpath, NULL, NULL, F_CLI);
|
||||||
+ if (g_state.previewer) {
|
+ if (g_state.previewer) {
|
||||||
+ pkey = previewkey;
|
+ pkey = previewkey;
|
||||||
+ goto run_plugin;
|
+ goto run_plugin;
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
continue;
|
continue;
|
||||||
default: /* SEL_LOCK */
|
default: /* SEL_LOCK */
|
||||||
lock_terminal();
|
lock_terminal();
|
||||||
@@ -7566,6 +7612,7 @@ nochange:
|
@@ -7567,6 +7612,7 @@ nochange:
|
||||||
|
|
||||||
goto begin;
|
goto begin;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ index 88263beb..8aa24712 100644
|
||||||
case SEL_PLUGIN:
|
case SEL_PLUGIN:
|
||||||
/* Check if directory is accessible */
|
/* Check if directory is accessible */
|
||||||
if (!xdiraccess(plgpath)) {
|
if (!xdiraccess(plgpath)) {
|
||||||
@@ -7591,6 +7638,12 @@ nochange:
|
@@ -7592,6 +7638,12 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ index 88263beb..8aa24712 100644
|
||||||
if (tmp[0] == '-' && tmp[1]) {
|
if (tmp[0] == '-' && tmp[1]) {
|
||||||
++tmp;
|
++tmp;
|
||||||
r = FALSE; /* Do not refresh dir after completion */
|
r = FALSE; /* Do not refresh dir after completion */
|
||||||
@@ -8189,8 +8242,10 @@ static void cleanup(void)
|
@@ -8185,8 +8237,10 @@ static void cleanup(void)
|
||||||
if (g_state.autofifo)
|
if (g_state.autofifo)
|
||||||
unlink(fifopath);
|
unlink(fifopath);
|
||||||
#endif
|
#endif
|
||||||
|
@ -241,7 +241,7 @@ index 88263beb..8aa24712 100644
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
disabledbg();
|
disabledbg();
|
||||||
#endif
|
#endif
|
||||||
@@ -8689,7 +8744,7 @@ int main(int argc, char *argv[])
|
@@ -8690,7 +8744,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
#ifndef NOFIFO
|
#ifndef NOFIFO
|
||||||
if (!g_state.fifomode)
|
if (!g_state.fifomode)
|
||||||
|
|
Loading…
Reference in a new issue