All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Eric Wong <normalperson@yhbt.net>,
	git@vger.kernel.org, Anton Gyllenberg <anton@iki.fi>
Subject: Re: [PATCH] git-svn: fix ls-tree usage with dash-prefixed paths
Date: Mon, 30 Mar 2009 07:28:17 +0200	[thread overview]
Message-ID: <20090330052817.GB2681@atjola.homenet> (raw)
In-Reply-To: <7v8wmoqdc1.fsf@gitster.siamese.dyndns.org>

On 2009.03.29 13:33:02 -0700, Junio C Hamano wrote:
> Eric Wong <normalperson@yhbt.net> writes:
> 
> > To find the blob object name given a tree and pathname, we were
> > incorrectly calling "git ls-tree" with a "--" argument followed
> > by the pathname of the file we wanted to get.
> >
> >   git ls-tree <TREE> -- --dashed/path/name.c
> >
> > Unlike many command-line interfaces, the "--" alone does not
> > symbolize the end of non-option arguments on the command-line.
> >
> > ls-tree interprets the "--" as a prefix to match against, thus
> > the entire contents of the --dashed/* hierarchy would be
> > returned because the "--" matches "--dashed" and every path
> > under it.
> 
> The above makes only half a sense to me.  In an empty directory:
> 
>     $ git init
>     Initialized empty Git repository in /tmp/empty/.git
>     $ mkdir -p ./--dashed/path
>     $ >./--dashed/path/name
>     $ git add .
>     $ git ls-files
>     --dashed/path/name
>     $ git commit -a -m initial
>     [master (root-commit) cd44284] initial
>      0 files changed, 0 insertions(+), 0 deletions(-)
>      create mode 100644 --dashed/path/name
>     $ git ls-tree HEAD^{tree} --
>     $ git ls-tree HEAD^{tree} -- --dashed/path/name
>     100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	--dashed/path/name
>     $ mkdir ./--
>     $ >./--/eman
>     $ git add .
>     $ git commit -m second
>     [master 80f8ef9] second
>      0 files changed, 0 insertions(+), 0 deletions(-)
>      create mode 100644 --/eman
>     $ git ls-tree HEAD^{tree} -- --dashed/path
>     100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	--/eman
>     040000 tree 23e59e0c91294c39ac7c5a2e39efb01d878de9a0	--dashed/path
>     $ exit
> 
> Perhaps the problem repository had a pathname that is exactly -- (in
> addition to --dashed/), and ls-tree emitted everything under --/
> hierarchy?  In other words, your fix to git-svn may be correct and I am
> reading your problem description above incorrectly?

Your test case is flawed, because you only have a single path in
--dashed/

Initialized empty Git repository in /home/doener/test/.git/
$ mkdir ./--dashed
$ touch ./--dashed/{1,2}
$ git add .
$ git ls-files
--dashed/1
--dashed/2
$ git commit -m init
[master (root-commit) ae7cd83] init
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 --dashed/1
 create mode 100644 --dashed/2
$ git ls-tree HEAD^{tree}
040000 tree f353b342b53872c6a510229524f819c4fe0d5c1b	--dashed
$ git ls-tree HEAD^{tree} --
$ git ls-tree HEAD^{tree} -- --dashed
040000 tree f353b342b53872c6a510229524f819c4fe0d5c1b	--dashed
$ git ls-tree HEAD^{tree} -- --dashed/
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	--dashed/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	--dashed/2
$ git ls-tree HEAD^{tree} -- --dashed/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	--dashed/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	--dashed/2

Or even more weird (at least to me):

Initialized empty Git repository in /home/doener/test/.git/
$ mkdir foo fab
$ touch {foo,fab}/{1,2}
$ git add .
$ git commit -m init
[master (root-commit) fdb7bb3] init
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 fab/1
 create mode 100644 fab/2
 create mode 100644 foo/1
 create mode 100644 foo/2
$ git ls-files foo/1 fab/1
fab/1
foo/1
$ git ls-files foo/1 fab/1 f
fab/1
foo/1
$ git ls-tree HEAD^{tree} foo/1 fab/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	fab/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	foo/1
$ git ls-tree HEAD^{tree} foo/1 fab/1 f
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	fab/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	fab/2
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	foo/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391	foo/2

So if you go into some tree, any additional pattern that is a prefix of
the tree name will match the tree and its contents.

Björn

  parent reply	other threads:[~2009-03-30  6:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26 10:31 svn clone Checksum mismatch question Gilbert Liddell
2009-03-26 13:02 ` Björn Steinbrink
2009-03-26 13:28   ` Gilbert Liddell
2009-03-26 13:54     ` Sverre Rabbelier
2009-03-26 14:18       ` Gilbert Liddell
2009-03-26 14:34       ` Johannes Schindelin
2009-03-26 14:35   ` Anton Gyllenberg
2009-03-27 11:18     ` Anton Gyllenberg
2009-03-29  6:08       ` Eric Wong
2009-03-29  6:10         ` [PATCH] git-svn: fix ls-tree usage with dash-prefixed paths Eric Wong
2009-03-29 20:33           ` Junio C Hamano
2009-03-29 21:56             ` Eric Wong
2009-03-30  6:44               ` Junio C Hamano
2009-03-30 17:41                 ` Eric Wong
2009-03-30 18:05                   ` Junio C Hamano
2009-03-30 22:58                     ` Eric Wong
2009-03-31  7:11                       ` Björn Steinbrink
2009-03-31  7:31                         ` Björn Steinbrink
2009-03-31  9:41                           ` Björn Steinbrink
2009-03-31 15:05                             ` [PATCH] tree_entry_interesting: Only recurse when the pathspec is a leading path component Björn Steinbrink
2009-04-02  4:32                               ` Junio C Hamano
2009-04-02  4:41                                 ` [PATCH] match_tree_entry(): a pathspec only matches at directory boundaries Junio C Hamano
2009-04-02 16:36                                   ` Linus Torvalds
2009-04-02 11:38                                 ` [PATCH] tree_entry_interesting: Only recurse when the pathspec is a leading path component Björn Steinbrink
2009-04-03 16:25                                   ` Junio C Hamano
2009-03-30  5:28             ` Björn Steinbrink [this message]
2009-03-30  7:26         ` svn clone Checksum mismatch question Anton Gyllenberg
2009-03-26 14:34 ` Peter Harris

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=20090330052817.GB2681@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=anton@iki.fi \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=normalperson@yhbt.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.