+ fsck_sha1_list();
+
+ heads = 0;
+ for (i = 1; i < argc; i++) {
+ const char *arg = argv[i];
+
+ if (*arg == '-')
+ continue;
+
+ if (!get_sha1(arg, head_sha1)) {
+ struct object *obj = lookup_object(head_sha1);
+
+ /* Error is printed by lookup_object(). */
+ if (!obj)
+ continue;
+
+ obj->used = 1;
+ mark_reachable(obj, REACHABLE);
+ heads++;
+ continue;
+ }
+ error("expected sha1, got %s", arg);
+ }
+
+ if (keep_cache_objects) {
+ int i;
+ read_cache();
+ for (i = 0; i < active_nr; i++) {
+ struct blob *blob = lookup_blob(active_cache[i]->sha1);
+ struct object *obj;
+ if (!blob)
+ continue;
+ obj = &blob->object;
+ obj->used = 1;
+ mark_reachable(obj, REACHABLE);
+ }
+ }
+
+ if (!heads && !keep_cache_objects) {
+ if (show_unreachable) {
+ fprintf(stderr, "unable to do reachability without a head nor --cache\n");
+ show_unreachable = 0;
+ }
+ if (!heads)
+ fprintf(stderr, "expect dangling commits - potential heads - due to lack of head information\n");
+ }
+