-
Notifications
You must be signed in to change notification settings - Fork 614
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
e: Failed to open file which filename has space #1035
Comments
Okay, turns out that Tentative fix: diff --git a/include/tig/diff.h b/include/tig/diff.h
index 4e873088..10a9831c 100644
--- a/include/tig/diff.h
+++ b/include/tig/diff.h
@@ -31,7 +31,7 @@ struct diff_state {
};
enum request diff_common_edit(struct view *view, enum request request, struct line *line);
-bool diff_common_read(struct view *view, const char *data, struct diff_state *state);
+bool diff_common_read(struct view *view, char *data, struct diff_state *state);
enum request diff_common_enter(struct view *view, enum request request, struct line *line);
struct line *diff_common_add_diff_stat(struct view *view, const char *text, size_t offset);
void diff_common_select(struct view *view, struct line *line, const char *changes_msg);
diff --git a/src/diff.c b/src/diff.c
index 211ca894..4fd870cb 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -300,7 +300,7 @@ diff_common_highlight(struct view *view, const char *text, enum line_type type)
}
bool
-diff_common_read(struct view *view, const char *data, struct diff_state *state)
+diff_common_read(struct view *view, char *data, struct diff_state *state)
{
enum line_type type = get_line_type(data);
@@ -308,6 +308,13 @@ diff_common_read(struct view *view, const char *data, struct diff_state *state)
if (!state->combined_diff && (type == LINE_DIFF_ADD2 || type == LINE_DIFF_DEL2))
type = LINE_DEFAULT;
+ // If the filename contains a space, Git adds a tab at the end of
+ // the line, to satisfy GNU patch. Drop it to correct the filename.
+ if (type == LINE_DIFF_ADD_FILE || type == LINE_DIFF_DEL_FILE) {
+ char *tab;
+ if ((tab = strchr(data, '\t')) && !tab[1])
+ *tab = '\0';
+ }
/* DEL_FILE, ADD_FILE and START are only valid outside diff chunks */
if (state->reading_diff_chunk) {
if (type == LINE_DIFF_DEL_FILE || type == LINE_DIFF_START) |
If you don't want to recompile, you can create a wrapper script that removes the spurious tab before calling your editor: #/bin/sh
set -- "${@% }"
exec vim "$@" |
@krobelus thanks, with the diff, it work fine |
koutcher
added a commit
that referenced
this issue
Dec 13, 2020
As reported by Johannes Altmanninger, if the filename contains a space, Git adds a tab at the end of the line, to satisfy GNU patch. Drop it to correct the filename. Fixes #1035
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in some git repo, it have some file which filename has space, ex:
a b.txt
.when I use
e
to open this file, it will be failed.Is there any setting to solve this problem?
The text was updated successfully, but these errors were encountered: