git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 0/5] Split-up "unpack_trees()" cleanup series
Date: Thu, 6 Mar 2008 18:04:17 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.1.00.0803061759430.12253@woody.linux-foundation.org> (raw)
In-Reply-To: <alpine.LNX.1.00.0803061901480.19665@iabervon.org>



On Thu, 6 Mar 2008, Daniel Barkalow wrote:
>
> On Wed, 5 Mar 2008, Linus Torvalds wrote:
> > 
> > It's a series of five patches:
> >  -  Add 'df_name_compare()' helper function
> >  - Make 'traverse_tree()' use linked structure rather than 'const char *base'
> >  - Add return value to 'traverse_tree()' callback
> >  - Make 'traverse_trees()' traverse conflicting DF entries in parallel
> >  - Move 'unpack_trees()' over to 'traverse_trees()' interface
> 
> This all looks good to me.

There's a really stupid bug in function that compares filenames using 
the the linked list structure which makes it not compare the first path 
component when using "--prefix".

So it can only hit in the case of us having a "prefix" entry that makes 
the name of the "root" info structure non-empty, and I suspect that 
because of all the other horrid crud we do for --prefix=xyzzy handling in 
builtin-read-tree.c you can't actually trigger this bug, but my other 
cleanups (which I'll send out once I've tested them a bit more) will make 
this bug trigger.

This fairly obvious patch fixes it by just making sure that we always end 
up having a ->prev entry if we have a pathname component.

			Linus

---
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Thu Mar 6 15:44:48 2008 -0800

Fix tree-walking compare_entry() in the presense of --prefix

When we make the "root" tree-walk info entry have a pathname in it, we
need to have a ->prev pointer so that compare_entry will actually notice
and traverse into the root.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 tree-walk.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tree-walk.c b/tree-walk.c
index 842cb6a..02e2aed 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -107,6 +107,7 @@ int tree_entry(struct tree_desc *desc, struct name_entry *entry)
 void setup_traverse_info(struct traverse_info *info, const char *base)
 {
 	int pathlen = strlen(base);
+	static struct traverse_info dummy;
 
 	memset(info, 0, sizeof(*info));
 	if (pathlen && base[pathlen-1] == '/')
@@ -114,6 +115,8 @@ void setup_traverse_info(struct traverse_info *info, const char *base)
 	info->pathlen = pathlen ? pathlen + 1 : 0;
 	info->name.path = base;
 	info->name.sha1 = (void *)(base + pathlen + 1);
+	if (pathlen)
+		info->prev = &dummy;
 }
 
 char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n)

      reply	other threads:[~2008-03-07  2:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-06  4:28 [PATCH 0/5] Split-up "unpack_trees()" cleanup series Linus Torvalds
2008-03-06  2:25 ` [PATCH 1/5] Add 'df_name_compare()' helper function Linus Torvalds
2008-03-06 13:03   ` David Kastrup
2008-03-06 15:58     ` Linus Torvalds
2008-03-06 21:50       ` David Kastrup
2008-03-06  2:59 ` [PATCH 2/5] Make 'traverse_tree()' use linked structure rather than 'const char *base' Linus Torvalds
2008-03-06  3:44 ` [PATCH 3/5] Add return value to 'traverse_tree()' callback Linus Torvalds
2008-03-06  4:06 ` [PATCH 4/5] Make 'traverse_trees()' traverse conflicting DF entries in parallel Linus Torvalds
2008-03-06  4:15 ` [PATCH 5/5] Move 'unpack_trees()' over to 'traverse_trees()' interface Linus Torvalds
2008-03-06  4:51 ` [PATCH 0/5] Split-up "unpack_trees()" cleanup series Linus Torvalds
2008-03-07  0:13 ` Daniel Barkalow
2008-03-07  2:04   ` Linus Torvalds [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=alpine.LFD.1.00.0803061759430.12253@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).