summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-09-01 17:23:44 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-09-01 17:23:44 +0200
commitbd5d53f9e3eda65e69557b2551d2b37e0bdc5fc8 (patch)
tree0f4ec45c51ae803727c023ff15175f2f31824565
parent4de1ce83e1d45bb3206770895dc84b26aaf76f18 (diff)
downloadredo-c-bd5d53f9e3eda65e69557b2551d2b37e0bdc5fc8.tar.gz
redo-c-bd5d53f9e3eda65e69557b2551d2b37e0bdc5fc8.tar.xz
redo-c-bd5d53f9e3eda65e69557b2551d2b37e0bdc5fc8.zip
Store hash for foo in .foo.dep too, to detect changes to targets
-rw-r--r--redo.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/redo.c b/redo.c
index 5dc8064..8bdf85d 100644
--- a/redo.c
+++ b/redo.c
@@ -677,14 +677,22 @@ redo_ifchange(int targetc, char *targetv[])
 			char *target = targetchdir(job->target);
 			char *depfile = targetdep(target);
 
-			rename(job->temp_depfile, depfile);
-
 			if (stat(job->temp_target, &st) == 0 &&
 			    st.st_size > 0) {
+				int dfd, tfd;
+
+				dfd = open(job->temp_depfile, O_WRONLY|O_APPEND);
+				tfd = open(job->temp_target, O_RDONLY);
+				dprintf(dfd, "=%s@%s\n", hashfile(tfd), target);
+				close(dfd);
+				close(tfd);
+
 				rename(job->temp_target, target);
 			} else {
 				remove(job->temp_target);
 			}
+
+			rename(job->temp_depfile, depfile);
 		}
 
 		vacate(job->implicit);