1

I like the idea of rerere, but have some possible concerns that it might potentially cause some issues with other directories that I don't want to have this enabled on. It would seem that this is an all or nothing thing. Is that correct, or can I set it up for only certain directories?

I'm considering having the rerere cache stored with the repo as given by this script, so need to know about this feature further.

EDIT

If not, would it be possible to enable rerere for the changes I'm interested in and then turn it off again to limit where this is used? If so, in what parts of the process would I do this?

Community
  • 1
  • 1
Adrian
  • 10,246
  • 4
  • 44
  • 110
  • The short answer is no. The much longer answer is that you can purge parts of the rerere cache, so you could write a script that does what you want, but it's at least a little bit tricky. I have not delved into the internal form of the cache so I'm not sure how you would pick out particular files. – torek Jan 02 '18 at 16:41
  • Hmmm, keeping a rerere cache for all files in a very large repo is wasteful when that info isn't needed, especially if I am going to put the rerere cache into the repo as well. – Adrian Jan 02 '18 at 16:44
  • Rerere *is* a cache. Git stores it the only way it can: as objects. They will get compressed as usual, stored in pack files, if they live long enough. There's a garbage collection pass run by `git gc` to toss them out once they're expired. Note that the front end command has `forget `, what you need is to get a list of all the ``s that are in the cache now and then filter it. – torek Jan 02 '18 at 16:48
  • @torek, hmmm, didn't consider the possibility of the items *expiring*, esp since the [docs](https://git-scm.com/docs/git-rerere) don't mention this and since this is a tool meant for merging long lived branches. At what point do they *expire*? Also, is the cache ignored if `rerere` is turned off? I would expect so, so would this be a reason for them expiring? – Adrian Jan 02 '18 at 17:04
  • See the `gc` subcommand—but, hm, maybe `git gc` doesn't run `git rerere gc` automatically. No, I was right the first time: https://github.com/git/git/blob/1eaabe34fc6f486367a176207420378f587d3b48/builtin/gc.c#L472-L473 Note that the defaults are 15 days if unresolved, 60 if resolved. – torek Jan 02 '18 at 17:50
  • @torek, so long lived doesn't meany any longer than 60 days? Hmmm, as we will be using this for a vendor branch and that we merge with their code every year or so, this doesn't seem all that useful for our use case, which can be found [here](https://stackoverflow.com/questions/47998535/best-way-to-merge-a-3rd-party-source-code-with-local-modifications-in-git/47998924#47998924) on SO. Would you agree? – Adrian Jan 02 '18 at 18:23
  • Well, by default at least: you can tweak those values. But I've been in that particular situation before (3rd party software which we must modify, where they won't take our changes) and there aren't any *good* solutions, just a bunch of different bad ones with different ways of being bad. The most helpful thing I had at the time was to commit their code into our VCS (which was never Git, back then). This let us see what *they* did, and hand-merge our changes however we had to; those were in effect on "our" branch (vs the "vendor branch"). – torek Jan 02 '18 at 18:28
  • @torek, well we moved to git and I'm trying to improve the process. I was thinking that using this procedure [here on SO](https://stackoverflow.com/a/12590387/1366368) might be a way to help with merging down the line. If I were to put the rerere-cache into git, would that protect the cached entries? And if so and if nobody turns on rerere except for these vendor branches, would only the info for those directories be saved? – Adrian Jan 02 '18 at 18:37
  • Again, that's getting deeper into the details of the cache than I have before, so I can't evaluate the examples. It does look like it might do what you intended. I actually like the train script in [this answer](https://stackoverflow.com/a/23561739/1256452) since it's something I think Git should provide as a built in. I'd have to think more about all of this before making any kind of recommendation, though. – torek Jan 02 '18 at 19:24

0 Answers0