From: Christian Couder Date: Fri, 06 Jun 2014 15:44:59 GMT Subject: Re: [PATCH v3 1/4] replace: add --graft option Message-ID: In-Reply-To: On Fri, Jun 6, 2014 at 5:29 PM, Christian Couder wrote: > > Yeah, or I could just rely on the fact that lookup_commit_or_die() > already parses the commit, with something like this: > > if (get_sha1(old_ref, old) < 0) > die(_("Not a valid object name: '%s'"), old_ref); > > /* parse the commit buffer to make sure the commit is not corrupt */ > commit = lookup_commit_or_die(old, old_ref); > > /* find existing parents */ > parent_start = buf.buf; > parent_start += 46; /* "tree " + "hex sha1" + "\n" */ > parent_end = parent_start; This last part should be: /* find existing parents */ strbuf_addstr(&buf, commit->buffer); parent_start = buf.buf; parent_start += 46; /* "tree " + "hex sha1" + "\n" */ parent_end = parent_start; ... I will send an updated patch series soon.