Merge branch 'md/list-lazy-objects-fix'

"git rev-list --exclude-promisor-objects" had to take an object
that does not exist locally (and is lazily available) from the
command line without barfing, but the code dereferenced NULL.

* md/list-lazy-objects-fix:
  list-objects.c: don't segfault for missing cmdline objects
This commit is contained in:
Junio C Hamano 2019-01-14 15:29:28 -08:00
Родитель ecbdaf0899 4cf67869b2
Коммит c333fe7368
2 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -1729,6 +1729,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
if (!cant_be_filename)
verify_non_filename(revs->prefix, arg);
object = get_reference(revs, arg, &oid, flags ^ local_flags);
if (!object)
return revs->ignore_missing ? 0 : -1;
add_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags);
add_pending_object_with_path(revs, object, arg, oc.mode, oc.path);
free(oc.path);

Просмотреть файл

@ -349,7 +349,7 @@ test_expect_success 'rev-list stops traversal at promisor commit, tree, and blob
grep $(git -C repo rev-parse bar) out # sanity check that some walking was done
'
test_expect_success 'rev-list accepts missing and promised objects on command line' '
test_expect_success 'rev-list dies for missing objects on cmd line' '
rm -rf repo &&
test_create_repo repo &&
test_commit -C repo foo &&
@ -366,7 +366,19 @@ 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"
for OBJ in "$COMMIT" "$TREE" "$BLOB"; do
test_must_fail git -C repo rev-list --objects \
--exclude-promisor-objects "$OBJ" &&
test_must_fail git -C repo rev-list --objects-edge-aggressive \
--exclude-promisor-objects "$OBJ" &&
# Do not die or crash when --ignore-missing is passed.
git -C repo rev-list --ignore-missing --objects \
--exclude-promisor-objects "$OBJ" &&
git -C repo rev-list --ignore-missing --objects-edge-aggressive \
--exclude-promisor-objects "$OBJ"
done
'
test_expect_success 'gc repacks promisor objects separately from non-promisor objects' '