| 22 | } |
| 23 | |
| 24 | fn watch_repository(root: &Path) { |
| 25 | // --git-path resolves shared refs and worktree-local HEAD/index correctly. |
| 26 | // Watch loose refs as well as packed refs: an empty commit need not change |
| 27 | // any source file, and updating a packed branch can create a new loose ref. |
| 28 | for name in ["HEAD", "index", "packed-refs", "refs/heads"] { |
| 29 | if let Some(path) = git(root, &["rev-parse", "--git-path", name]) { |
| 30 | let path = root.join(path.trim()); |
| 31 | if path.exists() { |
| 32 | println!("cargo:rerun-if-changed={}", path.display()); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // Track unstaged edits too, including workspace files outside atomic-cli. |
| 38 | // Watching only the index would leave a cached dirty marker stale. |
| 39 | if let Some(files) = git(root, &["ls-files", "-z"]) { |
| 40 | for file in files.split('\0').filter(|file| !file.is_empty()) { |
| 41 | println!("cargo:rerun-if-changed={}", root.join(file).display()); |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | fn main() { |
| 47 | // libgit2 1.8 (libgit2-sys 0.17.0+1.8.1) references Advapi32 symbols |