summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c524ceb)
raw | patch | inline | side by side (parent: c524ceb)
author | Carlos Martín Nieto <cmn@elego.de> | |
Mon, 27 Feb 2012 15:11:53 +0000 (16:11 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 27 Feb 2012 19:35:33 +0000 (11:35 -0800) |
print_ref_list looks up the merge_filter_ref and assumes that a valid
pointer is returned. When the object doesn't exist, it tries to
dereference a NULL pointer. This can be the case when git branch
--merged is given an argument that isn't a valid commit name.
Check whether the lookup returns a NULL pointer and die with an error
if it does. Add a test, while we're at it.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pointer is returned. When the object doesn't exist, it tries to
dereference a NULL pointer. This can be the case when git branch
--merged is given an argument that isn't a valid commit name.
Check whether the lookup returns a NULL pointer and die with an error
if it does. Add a test, while we're at it.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c | patch | blob | history | |
t/t3200-branch.sh | patch | blob | history |
diff --git a/builtin/branch.c b/builtin/branch.c
index df908ed8f55838702299c9a687a98502f91cf5da..d6691af0a57f3ced2fc943e8a036ac1e03cb0566 100644 (file)
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -528,6 +528,10 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
if (merge_filter != NO_FILTER) {
struct commit *filter;
filter = lookup_commit_reference_gently(merge_filter_ref, 0);
+ if (!filter)
+ die("object '%s' does not point to a commit",
+ sha1_to_hex(merge_filter_ref));
+
filter->object.flags |= UNINTERESTING;
add_pending_object(&ref_list.revs,
(struct object *) filter, "");
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 76903323af37ed1a96b5a11c27eb1e9d63a0e9ef..6ad1763fda28cb86daf7e6baa901814d1a343517 100755 (executable)
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
'
+test_expect_success '--merged catches invalid object names' '
+ test_must_fail git branch --merged 0000000000000000000000000000000000000000
+'
+
test_done