public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail•com>
Cc: git@vger•kernel.org, ole@tange•dk, Johannes.Schindelin@gmx•de
Subject: Re: [PATCH] Avoid interpreting too-long parameter as file name
Date: Mon, 08 Feb 2016 12:46:51 -0800	[thread overview]
Message-ID: <xmqq4mdj7ww4.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1454908588-22475-1-git-send-email-pclouds@gmail.com> ("Nguyễn	Thái Ngọc Duy"'s message of "Mon, 8 Feb 2016 12:16:28 +0700")

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.

  reply	other threads:[~2016-02-08 20:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2016-02-23 20:58 ` git diff HEAD^(255) fails Kevin Daudt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq4mdj7ww4.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=Johannes.Schindelin@gmx$(echo .)de \
    --cc=git@vger$(echo .)kernel.org \
    --cc=ole@tange$(echo .)dk \
    --cc=pclouds@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox