git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: mhagger@alum.mit.edu
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Sixt <j6t@kdbg.org>,
	git@vger.kernel.org, Michael Haggerty <mhagger@alum.mit.edu>
Subject: [PATCH 0/7] Fix some bugs in abspath.c
Date: Tue,  4 Sep 2012 10:14:23 +0200	[thread overview]
Message-ID: <1346746470-23127-1-git-send-email-mhagger@alum.mit.edu> (raw)

From: Michael Haggerty <mhagger@alum.mit.edu>

I really just wanted to tidy up filter_refs(), but I've been sucked
into a cascade of recursive yak shaving.  This is my first attempt to
pop the yak stack.

I want to use real_path() for making the handling of
GIT_CEILING_DIRECTORIES more robust, but I noticed that it is broken
for some cases that will be important in this context.  This patch
series adds some new tests of that function and fixes the ones that
are broken, including a similar breakage in absolute_path().  It
applies to the current master.

Please note that both absolute_path("") and real_path("") used to
return the current directory followed by a slash.  I believe that this
was a bug, and that it is more appropriate for both functions to
reject the empty string.  The evidence is as follows:

* If this were intended behavior, presumably the return value would
  *not* have a trailing slash.

* I couldn't find any callers that appeared to depend on the old
  behavior.

* The test suite runs without errors after the change.

But I didn't do a thorough code review to ensure that no callers ever
rely on the old behavior.  The most likely scenario would be if one of
these functions were used to parse something like $PATH, where the
empty string denotes the current directory, but I didn't see any
callers that seemed to be doing anything like this.

Michael Haggerty (7):
  t0000: verify that absolute_path() fails if passed the empty string
  absolute_path(): reject the empty string
  t0000: verify that real_path() fails if passed the empty string
  real_path(): reject the empty string
  t0000: verify that real_path() works correctly with absolute paths
  real_path(): properly handle nonexistent top-level paths
  t0000: verify that real_path() removes extra slashes

 abspath.c        | 12 ++++++++++--
 t/t0000-basic.sh | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 3 deletions(-)

-- 
1.7.11.3

             reply	other threads:[~2012-09-04  8:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-04  8:14 mhagger [this message]
2012-09-04  8:14 ` [PATCH 1/7] t0000: verify that absolute_path() fails if passed the empty string mhagger
2012-09-04  8:14 ` [PATCH 2/7] absolute_path(): reject " mhagger
2012-09-04  8:14 ` [PATCH 3/7] t0000: verify that real_path() fails if passed " mhagger
2012-09-04  8:14 ` [PATCH 4/7] real_path(): reject " mhagger
2012-09-04  8:14 ` [PATCH 5/7] t0000: verify that real_path() works correctly with absolute paths mhagger
2012-09-05  8:40   ` Johannes Sixt
2012-09-06 21:11     ` Michael Haggerty
2012-09-06 23:08   ` Junio C Hamano
2012-09-09  4:31     ` Michael Haggerty
2012-09-09  4:50       ` Junio C Hamano
2012-09-09  5:27         ` Junio C Hamano
2012-09-04  8:14 ` [PATCH 6/7] real_path(): properly handle nonexistent top-level paths mhagger
2012-09-04  8:14 ` [PATCH 7/7] t0000: verify that real_path() removes extra slashes mhagger
2012-09-04 18:19   ` Junio C Hamano
2012-09-05 10:52     ` Nguyen Thai Ngoc Duy
     [not found]       ` <CAGHpTB+LipLt3CgVt5O0s9xj5HHf9Y5z9QWEy+FKYH8s4O7Q2w@mail.gmail.com>
2012-09-05 11:13         ` Nguyen Thai Ngoc Duy
2012-09-06  3:23       ` Junio C Hamano
2012-09-06  5:44         ` Nguyen Thai Ngoc Duy
2012-09-06 17:34           ` Junio C Hamano
2012-09-07  1:18             ` Nguyen Thai Ngoc Duy
2012-09-05  8:40   ` Johannes Sixt
2012-09-06 22:30     ` Michael Haggerty
2012-09-04 18:08 ` [PATCH 0/7] Fix some bugs in abspath.c Junio C Hamano
2012-09-04 19:03   ` Junio C Hamano

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=1346746470-23127-1-git-send-email-mhagger@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).