From: Ole Tange <hidden> Date: 2016-06-15 23:08:08
git diff first looks for a file, then looks if it is a reference to a
revision. If the file fails due to being too long, the diff fails:
$ git init
$ git diff 'HEAD^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
HEAD
fatal: failed to stat
'HEAD^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^':
File name too long
If file name too long it should just try to see if it is a reference
to a revision.
/Ole
Noticed-by: Ole Tange [off-list ref]
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
On Sun, Feb 7, 2016 at 4:56 AM, Ole Tange [off-list ref] wrote:
> If file name too long it should just try to see if it is a reference
> to a revision.
Looks easy enough to fix.
setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -147,7 +147,7 @@ int check_filename(const char *prefix, const char *arg)name=arg;if(!lstat(name,&st))return1;/* file exists */-if(errno==ENOENT||errno==ENOTDIR)+if(errno==ENOENT||errno==ENOTDIR||errno==ENAMETOOLONG)return0;/* file does not exist */die_errno("failed to stat '%s'",arg);}
From: Johannes Schindelin <hidden> Date: 2016-06-15 23:08:09
Hi Duy,
On Sun, 7 Feb 2016, Nguyễn Thái Ngọc Duy wrote:
Noticed-by: Ole Tange [off-list ref]
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
On Sun, Feb 7, 2016 at 4:56 AM, Ole Tange [off-list ref] wrote:
> If file name too long it should just try to see if it is a reference
> to a revision.
Looks easy enough to fix.
Maybe with a little bit more informative commit message? ;-)
Something like
Avoid interpreting too-long parameter as file name
Even if it is easier to write HEAD~2000, it is legal to write
HEAD^^^... (repeats "^" 2000 times in total). However, such a
string is too long to be a legal filename (and on Windows, by
default even much, much shorter strings are still illegal
because they exceed MAX_PATH).
Therefore, if the check_filename() function encounters too long
a command-line parameter, it should interpet the error code
ENAMETOOLONG as a strong hint that this is not a file name
instead of dying with an error message.
Noticed-by: ...
What do you think?
Dscho
Even if it is easier to write HEAD~2000, it is legal to write
HEAD^^^... (repeats "^" 2000 times in total). However, such a string is
too long to be a legal filename (and on Windows, by default even much,
much shorter strings are still illegal because they exceed MAX_PATH).
Therefore, if the check_filename() function encounters too long a
command-line parameter, it should interpet the error code ENAMETOOLONG
as a strong hint that this is not a file name instead of dying with an
error message.
Noticed-by: Ole Tange [off-list ref]
Helped-by: Johannes Schindelin [off-list ref]
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
Note, git grep ENOENT.*ENOTDIR reveals a couple more matches, but I
didn't check if they should receive the same treatment.
Another option is just use file_exists() here instead, but I guess
that's too relaxing.
setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -147,7 +147,7 @@ int check_filename(const char *prefix, const char *arg)name=arg;if(!lstat(name,&st))return1;/* file exists */-if(errno==ENOENT||errno==ENOTDIR)+if(errno==ENOENT||errno==ENOTDIR||errno==ENAMETOOLONG)return0;/* file does not exist */die_errno("failed to stat '%s'",arg);}
From: Kevin Daudt <hidden> Date: 2016-06-15 23:08:23
On Sat, Feb 06, 2016 at 10:56:46PM +0100, Ole Tange wrote:
git diff first looks for a file, then looks if it is a reference to a
revision. If the file fails due to being too long, the diff fails:
$ git init
$ git diff 'HEAD^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
HEAD
fatal: failed to stat
'HEAD^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^':
File name too long
If file name too long it should just try to see if it is a reference
to a revision.
Is there a reason you are repeating 255 "^" instead of using HEAD~255?