# # # patch "cmd_ws_commit.cc" # from [54df19fed3d750a201af7c6274d534b0694b0dec] # to [c80c17bafef3305b0cfe4cc522835e38278cf443] # # patch "tests/mtn_execute_attr_respects_umask/__driver__.lua" # from [badff21ffe0f2e43ca68f4bd778d62e654b1e8a8] # to [f7750017ec2dcb74017c805a962b19c6aa4e30d7] # # patch "unix/process.cc" # from [94aac0a3c86589223c8165020ddb0cae00633985] # to [a4fbbe13d86d9ef8427ed44416737385e3616968] # ============================================================ --- cmd_ws_commit.cc 54df19fed3d750a201af7c6274d534b0694b0dec +++ cmd_ws_commit.cc c80c17bafef3305b0cfe4cc522835e38278cf443 @@ -314,7 +314,7 @@ CMD(revert, "revert", "", CMD_REF(worksp for (attr_map_t::const_iterator a = node->attrs.begin(); a != node->attrs.end(); ++a) { - P(F("reverting %s on %s") % a->first() % path); + L(FL("reverting %s on %s") % a->first() % path); if (a->second.first) app.lua.hook_set_attribute(a->first(), path, a->second.second()); ============================================================ --- tests/mtn_execute_attr_respects_umask/__driver__.lua badff21ffe0f2e43ca68f4bd778d62e654b1e8a8 +++ tests/mtn_execute_attr_respects_umask/__driver__.lua f7750017ec2dcb74017c805a962b19c6aa4e30d7 @@ -5,7 +5,7 @@ addfile("bar", "blah blah") addfile("foo", "blah blah") addfile("bar", "blah blah") -check(mtn("attr", "set", "foo", "mtn:execute", "true")) +check(mtn("attr", "set", "foo", "mtn:execute", "true"), 0, false, false) commit() R=base_revision() ============================================================ --- unix/process.cc 94aac0a3c86589223c8165020ddb0cae00633985 +++ unix/process.cc a4fbbe13d86d9ef8427ed44416737385e3616968 @@ -77,7 +77,7 @@ int change_xbits(const char *path, const int change_xbits(const char *path, const bool set) { - mode_t mode; + mode_t old_mode, new_mode; struct stat s; int fd = open(path, O_RDONLY); if (fd == -1) @@ -88,21 +88,38 @@ int change_xbits(const char *path, const } if (fstat(fd, &s)) return -1; - mode = s.st_mode; + old_mode = s.st_mode; if (set) { - mode |= ((S_IXUSR|S_IXGRP|S_IXOTH) & ~read_umask()); + new_mode = old_mode | ((S_IXUSR|S_IXGRP|S_IXOTH) & ~read_umask()); } else { - mode &= (~(S_IXUSR|S_IXGRP|S_IXOTH) & ~read_umask()); + new_mode = old_mode & (~(S_IXUSR|S_IXGRP|S_IXOTH) & ~read_umask()); } - L(FL("setting execute permission on path %s with mode %s") % path % mode); - int ret = fchmod(fd, mode); + + int status = 0; + if (new_mode != old_mode) + { + if (set) + { + P(F("setting execute permission on %s") % path); + L(FL("setting execute permission on %s with mode %s") % path % new_mode); + } + else + { + P(F("clearing execute permission on %s") % path); + L(FL("clearing execute permission on %s with mode %s") % path % new_mode); + } + + status = fchmod(fd, new_mode); + } + if (close(fd) != 0) { const int err = errno; E(false, origin::system, F("error closing file %s: %s") % path % os_strerror(err)); } - return ret; + + return status; } int set_executable(const char *path)