* git diff HEAD^(255) fails @ 2016-02-06 21:56 Ole Tange 2016-02-06 23:23 ` [PATCH] setup.c: make check_filename() return 0 on ENAMETOOLONG Nguyễn Thái Ngọc Duy 2016-02-23 20:58 ` git diff HEAD^(255) fails Kevin Daudt 0 siblings, 2 replies; 6+ messages in thread From: Ole Tange @ 2016-02-06 21:56 UTC (permalink / raw) To: git 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] setup.c: make check_filename() return 0 on ENAMETOOLONG 2016-02-06 21:56 git diff HEAD^(255) fails Ole Tange @ 2016-02-06 23:23 ` Nguyễn Thái Ngọc Duy 2016-02-07 12:23 ` Johannes Schindelin 2016-02-23 20:58 ` git diff HEAD^(255) fails Kevin Daudt 1 sibling, 1 reply; 6+ messages in thread From: Nguyễn Thái Ngọc Duy @ 2016-02-06 23:23 UTC (permalink / raw) To: git; +Cc: ole, Nguyễn Thái Ngọc Duy Noticed-by: Ole Tange <ole@tange.dk> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- On Sun, Feb 7, 2016 at 4:56 AM, Ole Tange <ole@tange.dk> 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(-) diff --git a/setup.c b/setup.c index 2c4b22c..ab8f85d 100644 --- a/setup.c +++ b/setup.c @@ -147,7 +147,7 @@ int check_filename(const char *prefix, const char *arg) name = arg; if (!lstat(name, &st)) return 1; /* file exists */ - if (errno == ENOENT || errno == ENOTDIR) + if (errno == ENOENT || errno == ENOTDIR || errno == ENAMETOOLONG) return 0; /* file does not exist */ die_errno("failed to stat '%s'", arg); } -- 2.7.0.377.g4cd97dd ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] setup.c: make check_filename() return 0 on ENAMETOOLONG 2016-02-06 23:23 ` [PATCH] setup.c: make check_filename() return 0 on ENAMETOOLONG Nguyễn Thái Ngọc Duy @ 2016-02-07 12:23 ` Johannes Schindelin 2016-02-08 5:16 ` [PATCH] Avoid interpreting too-long parameter as file name Nguyễn Thái Ngọc Duy 0 siblings, 1 reply; 6+ messages in thread From: Johannes Schindelin @ 2016-02-07 12:23 UTC (permalink / raw) To: Nguyễn Thái Ngọc Duy; +Cc: git, ole [-- Attachment #1: Type: text/plain, Size: 1080 bytes --] Hi Duy, On Sun, 7 Feb 2016, Nguyễn Thái Ngọc Duy wrote: > Noticed-by: Ole Tange <ole@tange.dk> > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> > --- > On Sun, Feb 7, 2016 at 4:56 AM, Ole Tange <ole@tange.dk> 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Avoid interpreting too-long parameter as file name 2016-02-07 12:23 ` Johannes Schindelin @ 2016-02-08 5:16 ` Nguyễn Thái Ngọc Duy 2016-02-08 20:46 ` Junio C Hamano 0 siblings, 1 reply; 6+ messages in thread From: Nguyễn Thái Ngọc Duy @ 2016-02-08 5:16 UTC (permalink / raw) To: git; +Cc: ole, Johannes.Schindelin, Nguyễn Thái Ngọc Duy 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 <ole@tange.dk> Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- 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(-) diff --git a/setup.c b/setup.c index 2c4b22c..ab8f85d 100644 --- a/setup.c +++ b/setup.c @@ -147,7 +147,7 @@ int check_filename(const char *prefix, const char *arg) name = arg; if (!lstat(name, &st)) return 1; /* file exists */ - if (errno == ENOENT || errno == ENOTDIR) + if (errno == ENOENT || errno == ENOTDIR || errno == ENAMETOOLONG) return 0; /* file does not exist */ die_errno("failed to stat '%s'", arg); } -- 2.7.0.377.g4cd97dd ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Avoid interpreting too-long parameter as file name 2016-02-08 5:16 ` [PATCH] Avoid interpreting too-long parameter as file name Nguyễn Thái Ngọc Duy @ 2016-02-08 20:46 ` Junio C Hamano 0 siblings, 0 replies; 6+ messages in thread From: Junio C Hamano @ 2016-02-08 20:46 UTC (permalink / raw) To: Nguyễn Thái Ngọc Duy; +Cc: git, ole, Johannes.Schindelin Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes: > 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 <ole@tange.dk> > Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> > --- While I think it is a good thing to try solving, i.e. it would be nicer to the user if "git foo HEAD^^^^..." can be spelled without needing a "--" disambiguation, I am not sure this patch solves it at the right level. The log message is unclear if the patch author even thought about ramifications of the callers not involved in the case written in it. For example, verify_filename() calls this function, saying "This string must name a file and otherwise I want you to die". There is a direct call to check_filename() in builtin/checkout.c; it is unclear how it would interact with this change, either. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: git diff HEAD^(255) fails 2016-02-06 21:56 git diff HEAD^(255) fails Ole Tange 2016-02-06 23:23 ` [PATCH] setup.c: make check_filename() return 0 on ENAMETOOLONG Nguyễn Thái Ngọc Duy @ 2016-02-23 20:58 ` Kevin Daudt 1 sibling, 0 replies; 6+ messages in thread From: Kevin Daudt @ 2016-02-23 20:58 UTC (permalink / raw) To: Ole Tange; +Cc: git 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? ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-02-23 20:58 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-02-06 21:56 git diff HEAD^(255) fails Ole Tange 2016-02-06 23:23 ` [PATCH] setup.c: make check_filename() return 0 on ENAMETOOLONG Nguyễn Thái Ngọc Duy 2016-02-07 12:23 ` Johannes Schindelin 2016-02-08 5:16 ` [PATCH] Avoid interpreting too-long parameter as file name Nguyễn Thái Ngọc Duy 2016-02-08 20:46 ` Junio C Hamano 2016-02-23 20:58 ` git diff HEAD^(255) fails Kevin Daudt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).