[BUG] git rev-list HEAD --objects -- WILDCARD-PATHSPEC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



git rev-list --objects behaves strangely with certain wildcard
pathspecs, which seem to interact badly with its tree-walk recursion.
To see the weirdness, there should generally be a wildcard-star
occurring somewhere early on in the pattern - wildcards as suffixes /
wildcards filtering the name of the blob, seems to work better than
wildcards as prefixes / wildcards filtering the name of trees.
A simple example of a wildcard pathspec that doesn't work is `*/*`

== Steps to reproduce ==
1. Get a git repo with a few different files and folders that's not
too overwhelming. You could make your own, I've cloned
https://github.com/computationalmystic/toy-repository

2. Run `git rev-list HEAD --objects -- PATHSPEC`
where PATHSPEC has an early wildcard in. It will not give you the
expected results. Make sure you quote the PATHSPEC so that your shell
doesn't do any wildcard expansion, otherwise you are not testing
rev-list's wildcard expansion.

Note that whenever this is working and you match something so that it
is output, generally all of its parent-trees and child-trees/blobs are
output too. I don't know if this is working as intended or not, it's
not documented in git rev-list.

For example, here is what I found on the toy-repository I cloned.

== First the expected behaviour ==
These work since the first wildcard is towards the end and is doing
suffix-matching or matching the last blob:

Group01 -> matches all of tree Group01
Group01/ -> matches all of tree Group01
Group01/* -> matches all of tree Group01
Group01* -> matches all of tree Group01

Group0 -> doesn't match anything
Group0* -> matches Group01, Group02, Group03, etc

Group01/READ* -> matches Group01/README.md
Group01/*ME.md -> matches Group01/README.md
Group01/*.md -> matches all .md files in Group01

== Possibly expected behaviour ==
Group0*/ -> doesn't output anything.

This is a bit weird since Group01/ does match some things, and
Group0*/ looks like it should match all of those same things at least,
but I think maybe the absence of wildcards altogether means that the
pathspec is considered to also match children of the matched object,
whereas if the pathspec contains a wildcard, it is stricter - you have
to append "/*" to get the same effect.
(I observed similar behaviour when testing git diff)

== Unexpected behaviour ==
These don't work since there is a wildcard early on doing prefix
matching or trying to filter trees rather than blobs.

*/* -> should match all the blobs, but only outputs root trees
*/*.md -> should match nearly all the blobs, but only outputs root trees
*README.md -> should match all README.md blobs, but only outputs the
root README.md blob and root trees.
*/README.md -> should match all README.md blobs, but only outputs root trees
Group0*/* -> should match lots of blobs, but only outputs root trees.

== Figuring out the specification ==
You can run `git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904..HEAD
--name-only -- PATHSPEC` to get a second opinion of what things should
match or not match your patchspec. This command seems to behave much
better with wildcard pathspecs than `git rev-list --objects`



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux