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

Re: RCS Keywords in Git done right

From
Derek Moore <derek.p.moore@gmail.com>
Date
Dec 2, 2014, 16:31 UTC
Message-ID
<CAMsgyKZWr-1isLvRXMFdzOYu0Yfm3vN_bdk4oRg6UhzSOMq_yQ@mail.gmail.com>
In-Reply-To
<CAGZ79kZLAHDG8h5DMQdOH2cQtaMs_iCtC-xsoKst966a+jaBNA@mail.gmail.com>
I've finished testing this work in larger repositories.

While the approach is performant and works nicely in small repos, but in larger repos one of the requirements for the "correctness" of substitutions slows things down (1 or 2 minutes to perform checkouts between branches with 10,000+ files).

The operation that is slowing things down is discovering the relative complement of commits between the common files of two branches (i.e., which files are common between two branches but differ in their latest commit).

My current approach is:
1) find files common between @ & @{-1}, "ls-tree --full-tree
--name-only -r" both branches, take the intersection
2) find current branch's commits for common files, for each file in
intersection "log -1 --format=%H $current_branch -- $file"
3) find common files where latest commits differ, for each file in
intersection keep the file if current branche's latest commit does not
equal prior branch's latest commit
4) overwrite all kept files with the results of git-archive

It is steps 2 & 3 that consume the most time in a large repo with large intersections of common files between branches.

I've tried to conceive of other ways to arriving at the same "filename"/"latest current branch commit hash" pairs where filenames are common between branches and latest current branch commit hash differs from latest prior branch commit hash. I've thought maybe I could traverse commits starting from merge-base instead of traversing files, but that doesn't seem like it would be a huge improvement.

I'm sure internal to git in C there would be a better/faster way (and it would probably look like writing Btrieve queries). Can anyone think of a good solution for the intersection of files and complement of commits using only the git CLI tools?

Thanks,
Derek
Previous: Stefan BellerNext: Derek Moore
Message 5 of 7 in “RCS Keywords in Git done right”
  1. Derek MooreNov 26, 2014
  2. Stefan BellerNov 26, 2014
  3. Derek MooreNov 26, 2014
  4. Stefan BellerNov 26, 2014
  5. Derek MooreDec 2, 2014
  6. Derek MooreDec 2, 2014
  7. Derek MooreDec 2, 2014

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.