git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: icase pathspec magic support in ls-tree

From
EEErik Cervin Edin <erik@cervined.in>
Date
Oct 14, 2022, 12:00 UTC
Message-ID
<CA+JQ7M9nEHeALeHKO465xsNwmP8C3TXXDjuXAN9cFMmC-XEJnA@mail.gmail.com>
In-Reply-To
<CAPMMpog94YUDPZswcGZ0ns10QXhaWOGmE95mgZEpdcx4GKsV3w@mail.gmail.com>
On Fri, Oct 14, 2022 at 10:58 AM Tao Klerks <tao@klerks.biz> wrote:
>
> I don't understand this suggestion; doesn't it only catch duplicates
> where both instances were introduced in the same 100-commit range?

Yes. It was a bit half-baked but the main idea was to limit the tree to a smaller subset (and not the whole tree) and incrementally checking for introduced duplicates instead of a full tree search. I think that's basically Elijah's idea. Get all (added?) files introduced in a certain revision range (last change, since yesterday etc.) and then only check those against the tree for duplicates in a manner of how you define duplicates

On Fri, Oct 14, 2022 at 10:50 AM Tao Klerks <tao@klerks.biz> wrote:
>
> Directories have been the problem, in "my" repo, around one-third of
> the time - typically someone does a directory rename, and someone else
> does a bad merge and reintroduces the old directory.

That adds a bit of complexity :/ but should still be doable.

Not perfect but maybe something along these lines? (caveat, possibly GNU only)
#!/bin/sh
# files added between revisions x y
added_files() {
    git diff --diff-filter=A --name-only --no-renames $1 $2 ;
}
# folders of those added files
added_folders() {
    added_files $1 $2 |
        sed -e '/[^\/]*/s@^@./@' -e 's@/[^/]*$@/@' |
         sort -u ;
}
# all files tracked by git in *those* folders at HEAD
possible_dupes() {
    added_folders $1 $2 |
        xargs git ls-tree --name-only HEAD ;
}
# case insensitive columns separated by \x1
# eg.
#path\x1PaTh
#path\x1path
case_insensitive() {
    sed -e 's@.*@\L\0\E\x1\0@' |
        sort ;
}
x=$1
y=$2
# Find all duplicates paths (case insensitive)
# in directories which were added between $x $y
possible_dupes $x $y |
    case_insensitive |
    awk -F '\x1' '
        # actual "duplicate" paths, column $2
        # as determined by case-insensitive column $1
        $1 in a { print a[$1]; print $2 }
        { a[$1]=$2 }
    '    | uniq
Previous: Tao KlerksNext: Elijah Newren
Message 13 of 16 in “icase pathspec magic support in ls-tree”
  1. Tao KlerksSep 30, 2022
  2. Ævar Arnfjörð BjarmasonSep 30, 2022
  3. brian m. carlsonOct 2, 2022
  4. Tao KlerksOct 13, 2022
  5. Torsten BögershausenOct 14, 2022
  6. Tao KlerksOct 14, 2022
  7. Erik Cervin EdinOct 14, 2022
  8. Elijah NewrenOct 14, 2022
  9. Erik Cervin EdinOct 14, 2022
  10. Tao KlerksOct 14, 2022
  11. Tao KlerksOct 14, 2022
  12. Tao KlerksOct 14, 2022
  13. Erik Cervin EdinOct 14, 2022
  14. Elijah NewrenOct 14, 2022
  15. Tao KlerksOct 15, 2022
  16. Tao KlerksOct 17, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.