public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha•warpmail.net>
To: Johannes Sixt <j.sixt@viscovery•net>
Cc: git@vger•kernel.org, Andrei Thorp <garoth@gmail•com>,
	Junio C Hamano <gitster@pobox•com>
Subject: Re: [PATCH 2/2] git submodule: Fix adding of submodules at paths with ./
Date: Wed, 25 Feb 2009 13:35:33 +0100	[thread overview]
Message-ID: <49A53B15.4060608@drmicha.warpmail.net> (raw)
In-Reply-To: <49A529AB.8010700@viscovery.net>

Johannes Sixt venit, vidit, dixit 25.02.2009 12:21:
> Michael J Gruber schrieb:
>> +	# strip superfluous ./ from path
>> +	path=$(echo "$path" | sed -e 's|^\(\./\)*||' -e's|/\./|/|g')
> 
> At a minimum:
> 
> 	path=$(echo "$path" | sed -e 's|^/\(\./\)*|/|g' -e's|^\./||')
> 
> Otherwise you would turn "foo./bar" into "foobar", right?

Wrong.

My regexp:
echo "foo./bar"  | sed -e 's|^\(\./\)*||' -e's|/\./|/|g'
foo./bar

echo "foo/./bar" | sed -e 's|^\(\./\)*||' -e's|/\./|/|g'
foo/bar


Your regexp:
echo "foo./bar"  | sed -e 's|^/\(\./\)*|/|g' -e's|^\./||'
foo./bar

echo "foo/./bar" | sed -e 's|^/\(\./\)*|/|g' -e's|^\./||'
foo/./bar

Testing your claim isn't that hard to do before hand...

> But why only care about ./ but not ../ or /// or trailing / as well?

You really haven't even looked at the included context of the patch
(which you stripped), have you? I mean, I'm open for suggestions and
criticism, but please don't shoot blindly.

./ have been reported and are a common use case.

Trailing / are dealt with by the code (see context).

Now, the /// are in fact a valid concern[1], although probably not that
common an isue. If we really want to cater for that (and more) we need
to implement normalize_path_copy() (from path.c). There it says:

* Performs the following normalizations on src, storing the result in dst:
 * - Ensures that components are separated by '/' (Windows only)
 * - Squashes sequences of '/'.
 * - Removes "." components.
 * - Removes ".." components, and the components the precede them.
 * Returns failure (non-zero) if a ".." component appears as first path
 * component anytime during the normalization. Otherwise, returns
success (0).

OK, two more regexps for sed. Thanks, I don't need suggestions for the
regexps ;)

I can add /// and .. testing and handling in a v2, but I'll definitely
leave the Windoze paths to someone who can actually test on Win.

Michael

[1] git sm init uses git ls-files, which in turn,..., which calls
normalize_path_copy. git sm add can't use git ls-files because it has to
deal with an as yet unknown path.

  reply	other threads:[~2009-02-25 12:37 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <80055d7c0902241541o5c8fad50ra4eace5919bcf6df@mail.gmail.com>
2009-02-24 23:56 ` Fwd: Git Submodule Misbehaviour With ./ Andrei Thorp
2009-02-25 11:03   ` [PATCH 0/2] Fix git submodule add for paths with ./ Michael J Gruber
2009-02-25 11:03     ` [PATCH 1/2] git submodule: Add test cases for git submodule add Michael J Gruber
2009-02-25 11:03       ` [PATCH 2/2] git submodule: Fix adding of submodules at paths with ./ Michael J Gruber
2009-02-25 11:21         ` Johannes Sixt
2009-02-25 12:35           ` Michael J Gruber [this message]
2009-02-25 13:04             ` Johannes Sixt
2009-02-25 13:26               ` [PATCHv2 0/4] Fix git submodule add for funky paths Michael J Gruber
2009-02-25 13:26                 ` [PATCHv2 1/4] git submodule: Add test cases for git submodule add Michael J Gruber
2009-02-25 13:26                   ` [PATCHv2 2/4] git submodule: Fix adding of submodules at paths with ./ Michael J Gruber
2009-02-25 13:26                     ` [PATCHv2 3/4] git submodule: Add more tests for add with funky paths Michael J Gruber
2009-02-25 13:26                       ` [PATCHv2 4/4] git submodule: Fix handling of // and /.. in paths for added submodules Michael J Gruber
2009-02-25 14:06                         ` Johannes Sixt
2009-02-25 14:33                           ` Michael J Gruber
2009-02-25 15:03                             ` Johannes Sixt
2009-02-25 21:25                               ` Junio C Hamano
2009-02-26  9:05                                 ` Michael J Gruber
2009-02-26 17:04                                   ` Junio C Hamano
2009-03-03 12:39                                     ` [PATCHv3 0/2] git submodule: normalize paths before adding Michael J Gruber
2009-03-03 12:39                                       ` [PATCHv3 1/2] git submodule: Add test cases for git submodule add Michael J Gruber
2009-03-03 12:39                                         ` [PATCHv3 2/2] git submodule: Fix adding of submodules at paths with ./, .. and // Michael J Gruber
2009-03-03 13:08                                           ` Johannes Sixt
2009-03-03 14:09                                             ` Michael J Gruber
2009-03-03 15:08                                               ` [PATCHv4 0/2] git submodule: normalize paths before adding Michael J Gruber
2009-03-03 15:08                                                 ` [PATCHv4 1/2] git submodule: Add test cases for git submodule add Michael J Gruber
2009-03-03 15:08                                                   ` [PATCHv4 2/2] git submodule: Fix adding of submodules at paths with ./, .. and // Michael J Gruber
2009-03-03 15:28                                                     ` Johannes Sixt
2009-03-03 15:39                                                       ` Michael J Gruber
2009-03-03 16:32                                                 ` [PATCHv4 0/2] git submodule: normalize paths before adding Junio C Hamano
2009-03-03 15:36                                             ` [PATCHv3 2/2] git submodule: Fix adding of submodules at paths with ./, .. and // Junio C Hamano
2009-03-03 15:48                                               ` Michael J Gruber
2009-03-03 14:29                                           ` Johannes Schindelin
2009-03-03 14:58                                             ` Michael J Gruber
2009-02-25 21:25               ` [PATCH 2/2] git submodule: Fix adding of submodules at paths with ./ Junio C Hamano
2009-02-25 21:24       ` [PATCH 1/2] git submodule: Add test cases for git submodule add 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=49A53B15.4060608@drmicha.warpmail.net \
    --to=git@drmicha$(echo .)warpmail.net \
    --cc=garoth@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=j.sixt@viscovery$(echo .)net \
    /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