提交 c2dea5a1 编写于 作者: J Junio C Hamano

git-bundle: various fixups

verify_bundle() returned with an error early only when all
prerequisite commits were missing.  It should error out much
earlier when some are missing.

When the rev-list is limited in ways other than revision range
(e.g. --max-count or --max-age), create_bundle() listed all
positive refs given from the command line as if they are
available, but resulting pack may not have some of them.  Add a
logic to make sure all of them are included, and error out
otherwise.
Signed-off-by: NJunio C Hamano <junkio@cox.net>
上级 2b064697
...@@ -189,7 +189,7 @@ static int verify_bundle(struct bundle_header *header) ...@@ -189,7 +189,7 @@ static int verify_bundle(struct bundle_header *header)
error(message); error(message);
error("%s %s", sha1_to_hex(e->sha1), e->name); error("%s %s", sha1_to_hex(e->sha1), e->name);
} }
if (revs.pending.nr == 0) if (revs.pending.nr != p->nr)
return ret; return ret;
req_nr = revs.pending.nr; req_nr = revs.pending.nr;
setup_revisions(2, argv, &revs, NULL); setup_revisions(2, argv, &revs, NULL);
...@@ -279,6 +279,7 @@ static int create_bundle(struct bundle_header *header, const char *path, ...@@ -279,6 +279,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
int pid, in, out, i, status; int pid, in, out, i, status;
char buffer[1024]; char buffer[1024];
struct rev_info revs; struct rev_info revs;
struct object_array tips;
bundle_fd = (!strcmp(path, "-") ? 1 : bundle_fd = (!strcmp(path, "-") ? 1 :
open(path, O_CREAT | O_WRONLY, 0666)); open(path, O_CREAT | O_WRONLY, 0666));
...@@ -316,19 +317,23 @@ static int create_bundle(struct bundle_header *header, const char *path, ...@@ -316,19 +317,23 @@ static int create_bundle(struct bundle_header *header, const char *path,
argc = setup_revisions(argc, argv, &revs, NULL); argc = setup_revisions(argc, argv, &revs, NULL);
if (argc > 1) if (argc > 1)
return error("unrecognized argument: %s'", argv[1]); return error("unrecognized argument: %s'", argv[1]);
memset(&tips, 0, sizeof(tips));
for (i = 0; i < revs.pending.nr; i++) { for (i = 0; i < revs.pending.nr; i++) {
struct object_array_entry *e = revs.pending.objects + i; struct object_array_entry *e = revs.pending.objects + i;
if (!(e->item->flags & UNINTERESTING)) { unsigned char sha1[20];
unsigned char sha1[20]; char *ref;
char *ref;
if (dwim_ref(e->name, strlen(e->name), sha1, &ref) != 1) if (e->item->flags & UNINTERESTING)
continue; continue;
write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40); if (dwim_ref(e->name, strlen(e->name), sha1, &ref) != 1)
write_or_die(bundle_fd, " ", 1); continue;
write_or_die(bundle_fd, ref, strlen(ref)); write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40);
write_or_die(bundle_fd, "\n", 1); write_or_die(bundle_fd, " ", 1);
free(ref); write_or_die(bundle_fd, ref, strlen(ref));
} write_or_die(bundle_fd, "\n", 1);
add_object_array(e->item, e->name, &tips);
free(ref);
} }
/* end header */ /* end header */
...@@ -356,7 +361,22 @@ static int create_bundle(struct bundle_header *header, const char *path, ...@@ -356,7 +361,22 @@ static int create_bundle(struct bundle_header *header, const char *path,
return -1; return -1;
if (!WIFEXITED(status) || WEXITSTATUS(status)) if (!WIFEXITED(status) || WEXITSTATUS(status))
return error ("pack-objects died"); return error ("pack-objects died");
return 0;
/*
* Make sure the refs we wrote out is correct; --max-count and
* other limiting options could have prevented all the tips
* from getting output.
*/
status = 0;
for (i = 0; i < tips.nr; i++) {
if (!(tips.objects[i].item->flags & SHOWN)) {
status = 1;
error("%s: not included in the resulting pack",
tips.objects[i].name);
}
}
return status;
} }
static int unbundle(struct bundle_header *header, int bundle_fd, static int unbundle(struct bundle_header *header, int bundle_fd,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册