commit - 58e31a80da4f4a9e10eaea148672190f35107a47
commit + 497a59156be73918988396d3f7378fb8c7b6da8d
blob - 965f8606f5dc0febfa47fceeba356519258f1021
blob + 9c2a6eea387f21e2d874e520ee11a682facc654b
--- lib/patch.c
+++ lib/patch.c
goto done;
}
- if (*patch.cid != '\0' && *patch.blob != '\0') {
+ if (*patch.cid != '\0')
strlcpy(p->cid, patch.cid, sizeof(p->cid));
+
+ if (*patch.blob != '\0')
strlcpy(p->blob, patch.blob, sizeof(p->blob));
- }
/* automatically set strip=1 for git-style diffs */
if (strip == -1 && patch.git &&
goto done;
if (do_merge) {
+ const char *type, *id;
+
if (fseeko(afile, 0, SEEK_SET) == -1 ||
fseeko(oldfile, 0, SEEK_SET) == -1 ||
fseeko(tmpfile, 0, SEEK_SET) == -1) {
goto done;
}
- if (asprintf(&anclabel, "commit %s", p->cid) == -1) {
+ if (*p->cid != '\0') {
+ type = "commit";
+ id = p->cid;
+ } else {
+ type = "blob";
+ id = p->blob;
+ }
+
+ if (asprintf(&anclabel, "%s %s", type, id) == -1) {
err = got_error_from_errno("asprintf");
anclabel = NULL;
goto done;
blob - 05415ddde579ebfde446284ba961406bc37a4255
blob + 14191697a10b4dbbc2cd5609d898d7830564529a
--- libexec/got-read-patch/got-read-patch.c
+++ libexec/got-read-patch/got-read-patch.c
if (newname != NULL)
strlcpy(p.new, newname, sizeof(p.new));
- if (commitid != NULL && blob != NULL) {
+ if (commitid != NULL)
strlcpy(p.cid, commitid, sizeof(p.cid));
+
+ if (blob != NULL)
strlcpy(p.blob, blob, sizeof(p.blob));
- }
p.git = git;
if (imsg_compose(&ibuf, GOT_IMSG_PATCH, 0, 0, -1, &p, sizeof(p)) == -1)