From: Junio C Hamano Date: Sat, 11 Aug 2007 05:43:42 GMT Subject: Re: [PATCH resend] git-apply: apply submodule changes Message-ID: <7vd4xupqwh.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <20070810135744.GA29243MdfPADPa@greensroom.kotnet.org> Sven Verdoolaege writes: > @@ -1994,20 +2014,18 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry * > alloc = 0; > buf = NULL; > if (cached) { > - if (ce) { > - enum object_type type; > - buf = read_sha1_file(ce->sha1, &type, &size); > - if (!buf) > - return error("read of %s failed", > - patch->old_name); > - alloc = size; > - } > + if (read_file_or_gitlink(ce, &buf, &size)) > + return error("read of %s failed", patch->old_name); > + alloc = size; > } > else if (patch->old_name) { > size = xsize_t(st->st_size); > alloc = size + 8192; > buf = xmalloc(alloc); > - if (read_old_data(st, patch->old_name, &buf, &alloc, &size)) > + if (S_ISGITLINK(patch->old_mode)) > + size = snprintf(buf, alloc, > + "Subproject commit %s\n", sha1_to_hex(ce->sha1)); > + else if (read_old_data(st, patch->old_name, &buf, &alloc, &size)) Who guarantees that ce is given to apply_data() in this codepath?