From 5f3cab5c51ddf78a907499bf3bc19f0c2def4735 Mon Sep 17 00:00:00 2001 From: Tharre Date: Tue, 25 Oct 2016 21:50:01 +0200 Subject: Make redo shortcut again --- src/build.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/build.c b/src/build.c index 659f1cf..bd4da3c 100644 --- a/src/build.c +++ b/src/build.c @@ -520,21 +520,26 @@ static int handle_c(dep_info *dep) { if (fstat(fileno(targetfd), &curr_st)) fatal("redo: failed to stat() %s", dep->target); + /* store the hash now, as build_target() will need it for comparison */ + unsigned char *old_hash = xmalloc(20); + hex_to_sha1(ctx_dep.fields[0], old_hash); /* TODO: error checking */ + dep->hash = old_hash; + if (dep->ctime.tv_sec != curr_st.st_ctim.tv_sec || dep->ctime.tv_nsec != curr_st.st_ctim.tv_nsec) { /* ctime doesn't match */ dep->ctime = curr_st.st_ctim; /* so check the hash */ - unsigned char old_hash[20]; - hex_to_sha1(ctx_dep.fields[0], old_hash); /* TODO: error checking */ dep->hash = hash_file(targetfd); if (memcmp(old_hash, dep->hash, 20)) { /* target hash doesn't match */ + free(old_hash); retval = build_target(dep); goto exit3; } + free(old_hash); /* update ctime hash */ write_dep_information(dep); -- cgit v1.2.3-70-g09d2