{"thread":{"id":"61459","subject":"[PATCH] fetch-pack: Remove unused struct 'loose_object_iter'","startedAt":"2024-05-12T00:59:20Z","lastAt":"2024-05-15T10:41:58Z","messageCount":5,"participants":["Dr. David Alan Gilbert","Patrick Steinhardt","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"494550","messageId":"20240512005913.342287-1-dave@treblig.org","threadId":"61459","inReplyTo":null,"subject":"[PATCH] fetch-pack: Remove unused struct 'loose_object_iter'","fromName":"Dr. David Alan Gilbert","fromEmail":"dave@treblig.org","sentAt":"2024-05-12T00:59:13Z","receivedAt":"2024-05-12T00:59:20Z","isPatch":true,"sender":{"key":"dave@treblig.org","avatar":null},"body":"'loose_object_iter' in fetch-pack.c is unused since\ncommit 97b2fa08b6b9ee3e (\"fetch-pack: drop custom loose object cache\")\nRemove it.\n\nSigned-off-by: Dr. David Alan Gilbert <dave@treblig.org>\n---\n fetch-pack.c | 5 -----\n 1 file changed, 5 deletions(-)\n\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 091f9a80a9..28a62e502e 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -732,11 +732,6 @@ static void mark_alternate_complete(struct fetch_negotiator *negotiator UNUSED,\n \tmark_complete(&obj->oid);\n }\n \n-struct loose_object_iter {\n-\tstruct oidset *loose_object_set;\n-\tstruct ref *refs;\n-};\n-\n /*\n  * Mark recent commits available locally and reachable from a local ref as\n  * COMPLETE.\n-- \n2.45.0\n\n"},{"id":"494604","messageId":"ZkHlUkKtqbXSvVNS@tanuki","threadId":"61459","inReplyTo":"20240512005913.342287-1-dave@treblig.org","subject":"Re: [PATCH] fetch-pack: Remove unused struct 'loose_object_iter'","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-05-13T10:02:58Z","receivedAt":"2024-05-13T10:03:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, May 12, 2024 at 01:59:13AM +0100, Dr. David Alan Gilbert wrote:\n\nTiny nit: we don't capitalize the first letter after the colon in the\nsubject. I don't think this warrants a reroll of this patch though.\n\n> 'loose_object_iter' in fetch-pack.c is unused since\n> commit 97b2fa08b6b9ee3e (\"fetch-pack: drop custom loose object cache\")\n> Remove it.\n\nGood catch, and thanks for providing historical context. The patch looks\nobviously good to me.\n\nPatrick\n"},{"id":"494683","messageId":"xmqq34qlcllg.fsf@gitster.g","threadId":"61459","inReplyTo":"ZkHlUkKtqbXSvVNS@tanuki","subject":"Re: [PATCH] fetch-pack: Remove unused struct 'loose_object_iter'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-05-13T23:56:27Z","receivedAt":"2024-05-13T23:56:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Sun, May 12, 2024 at 01:59:13AM +0100, Dr. David Alan Gilbert wrote:\n>\n> Tiny nit: we don't capitalize the first letter after the colon in the\n> subject. I don't think this warrants a reroll of this patch though.\n>\n>> 'loose_object_iter' in fetch-pack.c is unused since\n>> commit 97b2fa08b6b9ee3e (\"fetch-pack: drop custom loose object cache\")\n>> Remove it.\n>\n> Good catch, and thanks for providing historical context. The patch looks\n> obviously good to me.\n\nThanks, both.  Will queue with a slight copy-editing of the proposed\nlog message.\n"},{"id":"494787","messageId":"20240515064658.GE110841@coredump.intra.peff.net","threadId":"61459","inReplyTo":"20240512005913.342287-1-dave@treblig.org","subject":"Re: [PATCH] fetch-pack: Remove unused struct 'loose_object_iter'","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-05-15T06:46:58Z","receivedAt":"2024-05-15T06:47:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, May 12, 2024 at 01:59:13AM +0100, Dr. David Alan Gilbert wrote:\n\n> 'loose_object_iter' in fetch-pack.c is unused since\n> commit 97b2fa08b6b9ee3e (\"fetch-pack: drop custom loose object cache\")\n> Remove it.\n\nThanks, this was my fault for leaving it in. The patch looks obviously\ngood.\n\nI wish there was a good way to get the compiler to report on unused\ntypes, but I don't think there is (it's a complicated problem in\ngeneral, but file-local ones like this feel like they should be easy to\nspot).\n\nHere's a really hacky (and quadratic) attempt to find defined structs\nthat aren't mentioned elsewhere:\n\n  for i in $(git grep -ho '^struct [a-z_]* {' | cut -d' ' -f2)\n  do\n\tused=$(git grep -Phc \"\\b$i\\b\" |\n\t       perl -ne '$x += $_; END { print $x }')\n\techo \"$used $i\"\n  done |\n  sort -n\n\nwhich finds exactly one unused struct, the one in this patch.\n\n-Peff\n"},{"id":"494806","messageId":"ZkSRbSgQ-whUdms-@gallifrey","threadId":"61459","inReplyTo":"20240515064658.GE110841@coredump.intra.peff.net","subject":"Re: [PATCH] fetch-pack: Remove unused struct 'loose_object_iter'","fromName":"Dr. David Alan Gilbert","fromEmail":"dave@treblig.org","sentAt":"2024-05-15T10:41:49Z","receivedAt":"2024-05-15T10:41:58Z","isPatch":true,"sender":{"key":"dave@treblig.org","avatar":null},"body":"* Jeff King (peff@peff.net) wrote:\n> On Sun, May 12, 2024 at 01:59:13AM +0100, Dr. David Alan Gilbert wrote:\n> \n> > 'loose_object_iter' in fetch-pack.c is unused since\n> > commit 97b2fa08b6b9ee3e (\"fetch-pack: drop custom loose object cache\")\n> > Remove it.\n> \n> Thanks, this was my fault for leaving it in. The patch looks obviously\n> good.\n\nThanks.\nMost projects I've looked at seem to have one or more.\n\n> I wish there was a good way to get the compiler to report on unused\n> types, but I don't think there is (it's a complicated problem in\n> general, but file-local ones like this feel like they should be easy to\n> spot).\n\nAlas not.\n\n> Here's a really hacky (and quadratic) attempt to find defined structs\n> that aren't mentioned elsewhere:\n> \n>   for i in $(git grep -ho '^struct [a-z_]* {' | cut -d' ' -f2)\n>   do\n> \tused=$(git grep -Phc \"\\b$i\\b\" |\n> \t       perl -ne '$x += $_; END { print $x }')\n> \techo \"$used $i\"\n>   done |\n>   sort -n\n> \n> which finds exactly one unused struct, the one in this patch.\n\nMy similarly hacky script was:\n  \n  grep -r '^struct [^(=]* {'| tr ':' ' ' |\n  while read FNAME STRUCT NAME TAIL\n  do\n    echo \"$FNAME\" | grep -q '[.]c$' || continue\n  echo \">>>\" $FNAME ' : ' $NAME\n  echo -n \"Count: \"\n  grep $NAME $FNAME | wc -l \n  #grep $VARNAME $FNAME\n  done\n\n(A count of 1 being the unused ones).\n\nDave\n\n\n> \n> -Peff\n-- \n -----Open up your eyes, open up your mind, open up your code -------   \n/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \\ \n\\        dave @ treblig.org |                               | In Hex /\n \\ _________________________|_____ http://www.treblig.org   |_______/\n"}]}