git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Dmitry Ivankov <divanorama@gmail.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	David Barr <davidbarr@google.com>,
	"Shawn O. Pearce" <spearce@spearce.org>,
	Dmitry Ivankov <divanorama@gmail.com>
Subject: [PATCH 1/2] fast-import: be saner with temporary trees
Date: Tue, 16 Aug 2011 16:08:56 +0600	[thread overview]
Message-ID: <1313489337-2523-2-git-send-email-divanorama@gmail.com> (raw)
In-Reply-To: <1313489337-2523-1-git-send-email-divanorama@gmail.com>

new_tree_entry/release_tree_entry manage a stack of tree_entry structs
to use as temporaries. Initializing them is the responsibility of the
caller, both after allocation with xmalloc() when existing temporaries
are exhausted and after used entries are pushed with release_tree_entry.

parse_ls doesn't set root->versions[0] fields, making root an invalid
entry. The problem could arise if store_tree(root) is called. parse_ls
calls store_tree on the node corresponding to the path it is called on.

Do initialize entry->versions[0]. As of now, ls command can not list
the topmost tree so this change is just to avoid surprises in case
things will change around ls or tree_content_get.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
---
 fast-import.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 7cc2262..3a0aaad 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2951,6 +2951,9 @@ static void parse_ls(struct branch *b)
 	} else {
 		struct object_entry *e = parse_treeish_dataref(&p);
 		root = new_tree_entry();
+		hashclr(root->versions[0].sha1);
+		root->versions[0].mode = 0;
+		root->versions[1].mode = S_IFDIR;
 		hashcpy(root->versions[1].sha1, e->idx.sha1);
 		load_tree(root);
 		if (*p++ != ' ')
-- 
1.7.3.4

  reply	other threads:[~2011-08-16 10:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-16 10:08 [PATCH 0/2] fast-import: allow more operations on root directory Dmitry Ivankov
2011-08-16 10:08 ` Dmitry Ivankov [this message]
2012-03-08 19:12   ` [PATCH 1/2] fast-import: be saner with temporary trees Jonathan Nieder
2011-08-16 10:08 ` [PATCH 2/2] fast-import: allow top directory as an argument for some commands Dmitry Ivankov

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=1313489337-2523-2-git-send-email-divanorama@gmail.com \
    --to=divanorama@gmail.com \
    --cc=davidbarr@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=spearce@spearce.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).