0

What I'm trying to do is know what particular subdirectories have changed after pulling from a git repository. I was thinking I could compute the hash of all the subdirectories in the root directory, then pull git, then compute the hashes again. If the hashes don't match, then I know which directories have changed.

Is there a common way to compute the hash of a directory tree? I feel like this is pretty much what git does internally to track its files.

I would prefer a C, or better yet, objective-c api to do this, but i'd settle for a unix command to do it.

thanks for any tips.

D.C.
  • 15,340
  • 19
  • 71
  • 102
  • Does this answer your question? [Linux: compute a single hash for a given folder & contents?](https://stackoverflow.com/questions/545387/linux-compute-a-single-hash-for-a-given-folder-contents) – OverShifted Aug 09 '21 at 12:22

1 Answers1

1

Computing a hash of a directory hierarchy is expensive, especially in a large git repository.

You should look at the API provided by git. There may be a way to ask git to tell you what it is changing.

You should look at OS X's file system events API. This can send your app a notification when something in a directory hierarchy changes. https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/FSEvents_ProgGuide/Introduction/Introduction.html

Greg Parker
  • 7,972
  • 2
  • 24
  • 21