{"thread":{"id":"58953","subject":"[BUG] git rev-list HEAD --objects -- WILDCARD-PATHSPEC","startedAt":"2022-12-15T00:27:16Z","lastAt":"2022-12-15T00:27:16Z","messageCount":1,"participants":["Andrew Olsen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"469064","messageId":"CAPJmHpWWJ4sssfG2oym7K=MsT3+KTHQP-QK88nfXNOtfcv07ew@mail.gmail.com","threadId":"58953","inReplyTo":null,"subject":"[BUG] git rev-list HEAD --objects -- WILDCARD-PATHSPEC","fromName":"Andrew Olsen","fromEmail":"andrew.olsen@koordinates.com","sentAt":"2022-12-15T00:26:54Z","receivedAt":"2022-12-15T00:27:16Z","isPatch":false,"sender":{"key":"andrew.olsen@koordinates.com","avatar":"https://gravatar.com/avatar/f316140b761c57e8a68f9f93ea80a2aceac0c1d37df1b4aec24997025d441a34?d=mp&s=160"},"body":"git rev-list --objects behaves strangely with certain wildcard\npathspecs, which seem to interact badly with its tree-walk recursion.\nTo see the weirdness, there should generally be a wildcard-star\noccurring somewhere early on in the pattern - wildcards as suffixes /\nwildcards filtering the name of the blob, seems to work better than\nwildcards as prefixes / wildcards filtering the name of trees.\nA simple example of a wildcard pathspec that doesn't work is `*/*`\n\n== Steps to reproduce ==\n1. Get a git repo with a few different files and folders that's not\ntoo overwhelming. You could make your own, I've cloned\nhttps://github.com/computationalmystic/toy-repository\n\n2. Run `git rev-list HEAD --objects -- PATHSPEC`\nwhere PATHSPEC has an early wildcard in. It will not give you the\nexpected results. Make sure you quote the PATHSPEC so that your shell\ndoesn't do any wildcard expansion, otherwise you are not testing\nrev-list's wildcard expansion.\n\nNote that whenever this is working and you match something so that it\nis output, generally all of its parent-trees and child-trees/blobs are\noutput too. I don't know if this is working as intended or not, it's\nnot documented in git rev-list.\n\nFor example, here is what I found on the toy-repository I cloned.\n\n== First the expected behaviour ==\nThese work since the first wildcard is towards the end and is doing\nsuffix-matching or matching the last blob:\n\nGroup01 -> matches all of tree Group01\nGroup01/ -> matches all of tree Group01\nGroup01/* -> matches all of tree Group01\nGroup01* -> matches all of tree Group01\n\nGroup0 -> doesn't match anything\nGroup0* -> matches Group01, Group02, Group03, etc\n\nGroup01/READ* -> matches Group01/README.md\nGroup01/*ME.md -> matches Group01/README.md\nGroup01/*.md -> matches all .md files in Group01\n\n== Possibly expected behaviour ==\nGroup0*/ -> doesn't output anything.\n\nThis is a bit weird since Group01/ does match some things, and\nGroup0*/ looks like it should match all of those same things at least,\nbut I think maybe the absence of wildcards altogether means that the\npathspec is considered to also match children of the matched object,\nwhereas if the pathspec contains a wildcard, it is stricter - you have\nto append \"/*\" to get the same effect.\n(I observed similar behaviour when testing git diff)\n\n== Unexpected behaviour ==\nThese don't work since there is a wildcard early on doing prefix\nmatching or trying to filter trees rather than blobs.\n\n*/* -> should match all the blobs, but only outputs root trees\n*/*.md -> should match nearly all the blobs, but only outputs root trees\n*README.md -> should match all README.md blobs, but only outputs the\nroot README.md blob and root trees.\n*/README.md -> should match all README.md blobs, but only outputs root trees\nGroup0*/* -> should match lots of blobs, but only outputs root trees.\n\n== Figuring out the specification ==\nYou can run `git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904..HEAD\n--name-only -- PATHSPEC` to get a second opinion of what things should\nmatch or not match your patchspec. This command seems to behave much\nbetter with wildcard pathspecs than `git rev-list --objects`\n"}]}