[PATCH] fast-import: do not clear notes in do_change_note_fanout()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 5edde51 (fast-import: filemodify after M 040000 <tree> ""
crashes, 2010-10-17) taught fast-import to load trees from the
object db as needed when it is time to access them.

But it went too far.  In change_note_fanout(), an empty,
not-loaded tree is not meant to destroy notes, so calling
load_tree() at that point is exactly the wrong thing to do.

Kudos to Johan Herland for t9301, which caught this failure.

Reported-by: Thomas Rast <trast@xxxxxxxxxxxxxxx>
Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
[cleared cc list.]

Jonathan Nieder wrote:

> +++ b/fast-import.c
[...]
> @@ -2056,13 +2065,16 @@ static uintmax_t do_change_note_fanout(
>  		char *fullpath, unsigned int fullpath_len,
>  		unsigned char fanout)
>  {
> -	struct tree_content *t = root->tree;
> +	struct tree_content *t;
>  	struct tree_entry *e, leaf;
>  	unsigned int i, tmp_hex_sha1_len, tmp_fullpath_len;
>  	uintmax_t num_notes = 0;
>  	unsigned char sha1[20];
>  	char realpath[60];
>  
> +	if (!root->tree);
> +		load_tree(root);
> +	t = root->tree;
>  	for (i = 0; t && i < t->entry_count; i++) {

Oops.  The !t case is normal here and certainly is not a request
to turn t into an empty tree.  Here's a minimal fix.

 fast-import.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index aaf47c5..d2458ea 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2065,16 +2065,13 @@ static uintmax_t do_change_note_fanout(
 		char *fullpath, unsigned int fullpath_len,
 		unsigned char fanout)
 {
-	struct tree_content *t;
+	struct tree_content *t = root->tree;
 	struct tree_entry *e, leaf;
 	unsigned int i, tmp_hex_sha1_len, tmp_fullpath_len;
 	uintmax_t num_notes = 0;
 	unsigned char sha1[20];
 	char realpath[60];
 
-	if (!root->tree);
-		load_tree(root);
-	t = root->tree;
 	for (i = 0; t && i < t->entry_count; i++) {
 		e = t->entries[i];
 		tmp_hex_sha1_len = hex_sha1_len + e->name->str_len;
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]