From: Siddharth Asthana Date: Mon, 20 Apr 2026 10:37:27 GMT Subject: Re: [PATCH v1 1/1] rev-list: add --missing=print-only mode Message-ID: <3363a365-9529-44e5-bc4e-ba19bf97ed97@gmail.com> In-Reply-To: <491a27af-3ea4-4978-9d51-9c540ad31589@gmail.com> On 20/04/26 14:27, Phillip Wood wrote: > On 20/04/2026 08:43, Patrick Steinhardt wrote: >> On Sun, Apr 19, 2026 at 02:18:40PM +0530, Siddharth Asthana wrote: >> >>>   static struct oidmap missing_objects; >>>   enum missing_action { >>> -    MA_ERROR = 0,    /* fail if any missing objects are encountered */ >>> -    MA_ALLOW_ANY,    /* silently allow ALL missing objects */ >>> -    MA_PRINT,        /* print ALL missing objects in special section */ >>> -    MA_PRINT_INFO,   /* same as MA_PRINT but also prints missing >>> object info */ >>> +    MA_ERROR = 0, /* fail if any missing objects are encountered */ >>> +    MA_ALLOW_ANY, /* silently allow ALL missing objects */ >>> +    MA_PRINT, /* print ALL missing objects in special section */ >>> +    MA_PRINT_INFO, /* same as MA_PRINT but also prints missing >>> object info */ >>> +    MA_PRINT_ONLY, /* print ONLY missing objects, without the "?" >>> prefix */ >> >> Makes me wonder whether we'll eventually also want to have >> `MA_PRINT_INFO_ONLY`. > > Perhaps we'd be better to add a "--missing-only" option that limits the > output to missing objects? That would avoid the problem of "-- Make sense, its orthogonal to --missing= and handles print-info-only for free. Question though: should --missing-only without --missing=print (or print-info) be an errro? I am leaning towards requiring it explicitly so the behavior is always obvious. Will rework v2 around this. > missing=print-only" not really explaining what it does as well. > >>> +for obj in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t" >>> +do >>> +    test_expect_success "rev-list --missing=print-only with missing >>> $obj" ' >>> +        oid="$(git rev-parse $obj)" && >>> +        path=".git/objects/$(test_oid_to_path $oid)" && >>> + >>> +        # Capture present OIDs before hiding anything. >>> +        git rev-list --objects --no-object-names HEAD ^$obj >>> >present.raw && >>> + >>> +        mv "$path" "$path.hidden" && >>> +        test_when_finished "mv $path.hidden $path" && >>> + >>> +        git rev-list --missing=print-only --objects --no-object-names \ >>> +            HEAD >actual && >>> + >>> +        # Only the missing OID should appear, without the "?" prefix. >>> +        grep "^$oid$" actual && >>> + >>> +        # Present objects must NOT appear in the output. >>> +        while read present_oid >>> +        do >>> +            ! grep "^$present_oid$" actual || return 1 >>> +        done > >> How many present object IDs do we have? I'm a bit worried that we now >> execute grep(1) hundreds of times. Can we maybe do some tricks with >> comm(1) instead? > > If we want to verify that it only prints a single oid then > >     echo $oid >expect && >     test_cmp expect actual > > would be much simpler more helpful if the test fails yeah much cleaner, will use it. Thanks > > Thanks > > Phil Thanks, Asthana