From: Junio C Hamano <junkio@cox.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Santi Béjar" <sbejar@gmail.com>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: [PATCH 3/4] git-bundle: various fixups
Date: Mon, 05 Mar 2007 16:41:39 -0800	[thread overview]
Message-ID: <7vtzwzurss.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 7vk5xvw6mg.fsf@assigned-by-dhcp.cox.net
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: Junio C Hamano <junkio@cox.net>
---
 builtin-bundle.c |   46 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/builtin-bundle.c b/builtin-bundle.c
index 0265845..9286f3d 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -189,7 +189,7 @@ static int verify_bundle(struct bundle_header *header)
 			error(message);
 		error("%s %s", sha1_to_hex(e->sha1), e->name);
 	}
-	if (revs.pending.nr == 0)
+	if (revs.pending.nr != p->nr)
 		return ret;
 	req_nr = revs.pending.nr;
 	setup_revisions(2, argv, &revs, NULL);
@@ -274,6 +274,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
 	int pid, in, out, i, status;
 	char buffer[1024];
 	struct rev_info revs;
+	struct object_array tips;
 
 	bundle_fd = (!strcmp(path, "-") ? 1 :
 			open(path, O_CREAT | O_WRONLY, 0666));
@@ -311,19 +312,23 @@ static int create_bundle(struct bundle_header *header, const char *path,
 	argc = setup_revisions(argc, argv, &revs, NULL);
 	if (argc > 1)
 		return error("unrecognized argument: %s'", argv[1]);
+
+	memset(&tips, 0, sizeof(tips));
 	for (i = 0; i < revs.pending.nr; i++) {
 		struct object_array_entry *e = revs.pending.objects + i;
-		if (!(e->item->flags & UNINTERESTING)) {
-			unsigned char sha1[20];
-			char *ref;
-			if (dwim_ref(e->name, strlen(e->name), sha1, &ref) != 1)
-				continue;
-			write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40);
-			write_or_die(bundle_fd, " ", 1);
-			write_or_die(bundle_fd, ref, strlen(ref));
-			write_or_die(bundle_fd, "\n", 1);
-			free(ref);
-		}
+		unsigned char sha1[20];
+		char *ref;
+
+		if (e->item->flags & UNINTERESTING)
+			continue;
+		if (dwim_ref(e->name, strlen(e->name), sha1, &ref) != 1)
+			continue;
+		write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40);
+		write_or_die(bundle_fd, " ", 1);
+		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 */
@@ -350,7 +355,22 @@ static int create_bundle(struct bundle_header *header, const char *path,
 			return -1;
 	if (!WIFEXITED(status) || WEXITSTATUS(status))
 		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,
-- 
1.5.0.3.862.g71037
next prev parent reply	other threads:[~2007-03-06  0:41 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-05 10:02 [BUG] git-rev-list: --topo-order --boundary and --max-count Santi Béjar
2007-03-05 10:39 ` Junio C Hamano
2007-03-05 12:15   ` Junio C Hamano
2007-03-05 17:05   ` Linus Torvalds
2007-03-05 18:55   ` [PATCH] revision walker: Fix --boundary when limited Johannes Schindelin
2007-03-05 19:00     ` Johannes Schindelin
2007-03-05 19:39     ` Linus Torvalds
2007-03-05 19:57       ` Linus Torvalds
2007-03-05 21:10         ` Junio C Hamano
2007-03-06  1:12           ` Johannes Schindelin
2007-03-06  1:32             ` Junio C Hamano
2007-03-06  1:44               ` Johannes Schindelin
2007-03-06  1:58                 ` Junio C Hamano
2007-03-05 23:17         ` Johannes Schindelin
2007-03-06  0:36           ` Junio C Hamano
2007-03-06  0:41             ` [PATCH 2/4] revision traversal: retire BOUNDARY_SHOW Junio C Hamano
2007-03-06  2:05               ` Johannes Schindelin
2007-03-06  2:17                 ` Junio C Hamano
2007-03-06  2:23                   ` SHOWN means shown Junio C Hamano
2007-03-06  2:29                   ` [PATCH 2/4] revision traversal: retire BOUNDARY_SHOW Johannes Schindelin
2007-03-06 11:34                     ` Junio C Hamano
2007-03-06 15:52                       ` Johannes Schindelin
2007-03-06  0:41             ` Junio C Hamano [this message]
2007-03-06  2:13               ` [PATCH 3/4] git-bundle: various fixups Johannes Schindelin
2007-03-06  0:41             ` [PATCH 4/4] git-bundle: --list-prereqs Junio C Hamano
2007-03-05 21:10     ` [PATCH] revision walker: Fix --boundary when limited Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=7vtzwzurss.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=sbejar@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).