johnmehr / gitup

A minimalist, dependency-free FreeBSD program to clone/pull Git repositories.
BSD 2-Clause "Simplified" License
51 stars 9 forks source link

ignored paths aren't ignored #64

Closed nunotexbsd closed 3 years ago

nunotexbsd commented 3 years ago

Hello!

I've received an interesting PR:

"gitup currently does a complete walk of the specified target directory, including any paths marked as "ignore". In the case of (eg) ports, this means that the packages and distfiles directories will be unnecessarily scanned and hashed.

On my system that amounts to spending 4 hours hashing 100GB of data.

The attached patch skips ignored paths at all stages."

PR254971

Could you take a look?

Thanks

johnmehr commented 3 years ago

Thank you for letting me know about this! I incorporated most of Peter's patch but I think the additions to load_object() will cause gitup to abort if it tries to load an ignored file it needs to reconstruct pack file data and the additions to save_repairs() will cause gitup to always go into repair mode if it can't save a file it needs to save.

I also added a check to see if someone is trying to ignore a directory in the repository that they shouldn't (like /usr/ports/multimedia) and if so, exit with a warning.

How does it look?

peterjeremy commented 3 years ago

I haven't tested it but the patch looks reasonable. I hadn't considered the impact of trying to ignore paths that git needed to reconstruct the final result. I was primarily interested in preventing gitup from trying to hash all my package and distfiles archives.

johnmehr commented 3 years ago

No worries! I very much appreciate you letting me know about this problem and taking the time to write a patch.