Commit 2ad902c0cee1b56de28385c8f1cd6c2d70131a82

Stefan Sperling 2019-12-15T11:03:52

use fchmod() instead of chmod() to tweak permissions of a merged temp file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/lib/worktree.c b/lib/worktree.c
index b463e74..dfe5cb1 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -802,8 +802,8 @@ merge_file(int *local_changes_subsumed, struct got_worktree *worktree,
 			goto done;
 	}
 
-	if (chmod(merged_path, st_mode) != 0) {
-		err = got_error_from_errno2("chmod", merged_path);
+	if (fchmod(merged_fd, st_mode) != 0) {
+		err = got_error_from_errno2("fchmod", merged_path);
 		goto done;
 	}