From: Matthew DeVore <matvore@google.com>
To: git@vger.kernel.org
Cc: Matthew DeVore <matvore@google.com>,
gitster@pobox.com, jonathantanmy@google.com,
jeffhost@microsoft.com, ramsay@ramsayjones.plus.com
Subject: [PATCH] revision.c: drop missing objects from cmdline
Date: Tue, 23 Oct 2018 14:57:45 -0700 [thread overview]
Message-ID: <20181023215745.245333-1-matvore@google.com> (raw)
No code which reads cmdline in struct rev_info can handle NULL objects
in cmdline.rev[i].item, so stop adding them to the cmdline.rev array.
Objects in cmdline are NULL when the given object is promisor and
--exclude-promisor-objects is enabled.
This new behavior avoids a segmentation fault in the added test case in
t0410.
We could simply die if add_rev_cmdline is called with a NULL item,
(rather than warn if --exclude-promisor-objects is set) but because the
amended test case already expects the command to finish successfully,
difference and show a warning. Note that this command:
git rev-list --objects --missing=print $missing_hash
Already fails with a "fatal: bad object HASH" message and this patch
does not change that.
Signed-off-by: Matthew DeVore <matvore@google.com>
---
revision.c | 12 ++++++++++++
t/t0410-partial-clone.sh | 11 ++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/revision.c b/revision.c
index a1ddb9e11c..8724dca2e2 100644
--- a/revision.c
+++ b/revision.c
@@ -1148,6 +1148,18 @@ static void add_rev_cmdline(struct rev_info *revs,
int whence,
unsigned flags)
{
+ if (!item) {
+ /*
+ * item is likely a promisor object returned from get_reference.
+ */
+ if (revs->exclude_promisor_objects) {
+ warning(_("ignoring missing object %s"), name);
+ return;
+ } else {
+ die(_("missing object %s"), name);
+ }
+ }
+
struct rev_cmdline_info *info = &revs->cmdline;
unsigned int nr = info->nr;
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index ba3887f178..e02cd3f818 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -366,7 +366,16 @@ test_expect_success 'rev-list accepts missing and promised objects on command li
git -C repo config core.repositoryformatversion 1 &&
git -C repo config extensions.partialclone "arbitrary string" &&
- git -C repo rev-list --exclude-promisor-objects --objects "$COMMIT" "$TREE" "$BLOB"
+
+ printf "warning: ignoring missing object %s\n" \
+ "$COMMIT" "$TREE" "$BLOB" >expect &&
+ git -C repo rev-list --objects \
+ --exclude-promisor-objects "$COMMIT" "$TREE" "$BLOB" 2>actual &&
+ test_cmp expect actual &&
+
+ git -C repo rev-list --objects-edge-aggressive \
+ --exclude-promisor-objects "$COMMIT" "$TREE" "$BLOB" 2>actual &&
+ test_cmp expect actual
'
test_expect_success 'gc repacks promisor objects separately from non-promisor objects' '
--
2.19.1.568.g152ad8e336-goog
next reply other threads:[~2018-10-23 21:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-23 21:57 Matthew DeVore [this message]
2018-10-24 4:54 ` [PATCH] revision.c: drop missing objects from cmdline Junio C Hamano
2018-10-25 23:13 ` Matthew DeVore
2018-10-25 23:53 ` [PATCH v2] list-objects.c: don't segfault for missing cmdline objects Matthew DeVore
2018-10-29 0:06 ` Junio C Hamano
2018-12-05 21:43 ` [PATCH v3] " Matthew DeVore
2018-12-06 1:12 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181023215745.245333-1-matvore@google.com \
--to=matvore@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jeffhost@microsoft.com \
--cc=jonathantanmy@google.com \
--cc=ramsay@ramsayjones.plus.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).