Commit Diff


commit - dced00381a7c8b17b15e7f40210e5ab1ed071af0
commit + c56c5d8a20e8209334b5357111eddee0861cddae
blob - 093969a412f974c7bc0306e166d6d6d26eb60019
blob + 80ebfff77699c5f142553d1bb53741dd96067f3f
--- got/got.c
+++ got/got.c
@@ -504,7 +504,7 @@ edit_logmsg(char **logmsg, const char *editor, const c
 		return got_error_from_errno("malloc");
 	(*logmsg)[0] = '\0';
 
-	fp = fopen(logmsg_path, "r");
+	fp = fopen(logmsg_path, "re");
 	if (fp == NULL) {
 		err = got_error_from_errno("fopen");
 		goto done;
@@ -1236,7 +1236,7 @@ create_gotconfig(const char *proto, const char *host, 
 		err = got_error_from_errno("got_repo_get_path_gotconfig");
 		goto done;
 	}
-	gotconfig_file = fopen(gotconfig_path, "a");
+	gotconfig_file = fopen(gotconfig_path, "ae");
 	if (gotconfig_file == NULL) {
 		err = got_error_from_errno2("fopen", gotconfig_path);
 		goto done;
@@ -1296,7 +1296,7 @@ create_gitconfig(const char *git_url, const char *defa
 		err = got_error_from_errno("got_repo_get_path_gitconfig");
 		goto done;
 	}
-	gitconfig_file = fopen(gitconfig_path, "a");
+	gitconfig_file = fopen(gitconfig_path, "ae");
 	if (gitconfig_file == NULL) {
 		err = got_error_from_errno2("fopen", gitconfig_path);
 		goto done;
@@ -7296,7 +7296,7 @@ cmd_revert(int argc, char *argv[])
 		goto done;
 
 	if (patch_script_path) {
-		patch_script_file = fopen(patch_script_path, "r");
+		patch_script_file = fopen(patch_script_path, "re");
 		if (patch_script_file == NULL) {
 			error = got_error_from_errno2("fopen",
 			    patch_script_path);
@@ -7392,7 +7392,7 @@ read_prepared_logmsg(char **logmsg, const char *path)
 	*logmsg = NULL;
 	memset(&sb, 0, sizeof(sb));
 
-	f = fopen(path, "r");
+	f = fopen(path, "re");
 	if (f == NULL)
 		return got_error_from_errno2("fopen", path);
 
@@ -9824,7 +9824,7 @@ histedit_run_editor(struct got_histedit_list *histedit
 		goto done;
 	}
 
-	f = fopen(path, "r");
+	f = fopen(path, "re");
 	if (f == NULL) {
 		err = got_error_from_errno("fopen");
 		goto done;
@@ -9910,7 +9910,7 @@ histedit_save_list(struct got_histedit_list *histedit_
 	if (err)
 		return err;
 
-	f = fopen(path, "w");
+	f = fopen(path, "we");
 	if (f == NULL) {
 		err = got_error_from_errno2("fopen", path);
 		goto done;
@@ -9957,7 +9957,7 @@ histedit_load_list(struct got_histedit_list *histedit_
 	const struct got_error *err = NULL;
 	FILE *f = NULL;
 
-	f = fopen(path, "r");
+	f = fopen(path, "re");
 	if (f == NULL) {
 		err = got_error_from_errno2("fopen", path);
 		goto done;
@@ -11241,7 +11241,7 @@ cmd_stage(int argc, char *argv[])
 		goto done;
 
 	if (patch_script_path) {
-		patch_script_file = fopen(patch_script_path, "r");
+		patch_script_file = fopen(patch_script_path, "re");
 		if (patch_script_file == NULL) {
 			error = got_error_from_errno2("fopen",
 			    patch_script_path);
@@ -11361,7 +11361,7 @@ cmd_unstage(int argc, char *argv[])
 		goto done;
 
 	if (patch_script_path) {
-		patch_script_file = fopen(patch_script_path, "r");
+		patch_script_file = fopen(patch_script_path, "re");
 		if (patch_script_file == NULL) {
 			error = got_error_from_errno2("fopen",
 			    patch_script_path);
blob - 248a77e5bca676a06e63703fb30b6fd83aef15cd
blob + 7b57c645b008fa8fd0bb6c9d82f1befc4aa97cf6
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
@@ -2669,7 +2669,7 @@ gw_get_repo_description(char **description, struct gw_
 	if (asprintf(&d_file, "%s/description", dir) == -1)
 		return got_error_from_errno("asprintf");
 
-	f = fopen(d_file, "r");
+	f = fopen(d_file, "re");
 	if (f == NULL) {
 		if (errno == ENOENT || errno == EACCES)
 			return NULL;
@@ -2972,7 +2972,7 @@ gw_get_clone_url(char **url, struct gw_trans *gw_trans
 	if (asprintf(&d_file, "%s/cloneurl", dir) == -1)
 		return got_error_from_errno("asprintf");
 
-	f = fopen(d_file, "r");
+	f = fopen(d_file, "re");
 	if (f == NULL) {
 		if (errno != ENOENT && errno != EACCES)
 			error = got_error_from_errno2("fopen", d_file);
blob - 1d91c1f05c748a155769cbfd96cb8871ffd0c8cc
blob + dac1eae40679c47137747bc4f1d9aa0f054e8f59
--- gotweb/parse.y
+++ gotweb/parse.y
@@ -503,7 +503,7 @@ pushfile(struct file **nfile, const char *name)
 		free(nfile);
 		return got_error_from_errno2(__func__, "strdup");
 	}
-	if (((*nfile)->stream = fopen((*nfile)->name, "r")) == NULL) {
+	if (((*nfile)->stream = fopen((*nfile)->name, "re")) == NULL) {
 		char *msg = NULL;
 		if (asprintf(&msg, "%s", (*nfile)->name) == -1)
 			return got_error_from_errno("asprintf");
blob - b331de0ba24a050f33d26768b66e98fe04a3500d
blob + ba74c03c3d75ccde0afd53bfb6df4ffc4c086eb5
--- lib/diff3.c
+++ lib/diff3.c
@@ -206,12 +206,12 @@ diffreg(BUF **d, const char *path1, const char *path2,
 
 	*d = NULL;
 
-	f1 = fopen(path1, "r");
+	f1 = fopen(path1, "re");
 	if (f1 == NULL) {
 		err = got_error_from_errno2("fopen", path1);
 		goto done;
 	}
-	f2 = fopen(path2, "r");
+	f2 = fopen(path2, "re");
 	if (f1 == NULL) {
 		err = got_error_from_errno2("fopen", path2);
 		goto done;
@@ -459,11 +459,11 @@ diff3_internal(char *dp13, char *dp23, char *path1, ch
 	if (err)
 		return err;
 
-	if ((d3s->fp[0] = fopen(path1, "r")) == NULL)
-		return got_error_from_errno2("fopen", path1);
-	if ((d3s->fp[1] = fopen(path2, "r")) == NULL)
+	if ((d3s->fp[0] = fopen(path1, "re")) == NULL)
+		return got_error_from_errno2("fopen", path1);
+	if ((d3s->fp[1] = fopen(path2, "re")) == NULL)
 		return got_error_from_errno2("fopen", path2);
-	if ((d3s->fp[2] = fopen(path3, "r")) == NULL)
+	if ((d3s->fp[2] = fopen(path3, "re")) == NULL)
 		return got_error_from_errno2("fopen", path3);
 
 	return merge(m, n, d3s);
@@ -603,7 +603,7 @@ readin(size_t *n, char *name, struct diff **dd, struct
 
 	*n = 0;
 
-	f = fopen(name, "r");
+	f = fopen(name, "re");
 	if (f == NULL)
 		return got_error_from_errno2("fopen", name);
 	err = getchange(&p, f, d3s);
blob - 7178f338f771f22603b216cad0dd834dc6656298
blob + 0fd48e8e1fbc4f0f7faee3afa39df75a0ab22344
--- lib/reference.c
+++ lib/reference.c
@@ -188,7 +188,7 @@ parse_ref_file(struct got_reference **ref, const char 
 		}
 	}
 
-	f = fopen(abspath, "rb");
+	f = fopen(abspath, "rbe");
 	if (f == NULL) {
 		if (errno != ENOTDIR && errno != ENOENT)
 			err = got_error_from_errno2("fopen", abspath);
@@ -494,7 +494,7 @@ got_ref_open(struct got_reference **ref, struct got_re
 			if (err)
 				goto done;
 		}
-		f = fopen(packed_refs_path, "rb");
+		f = fopen(packed_refs_path, "rbe");
 		free(packed_refs_path);
 		if (f != NULL) {
 			struct stat sb;
@@ -1087,7 +1087,7 @@ got_ref_list(struct got_reflist_head *refs, struct got
 		goto done;
 	}
 
-	f = fopen(packed_refs_path, "r");
+	f = fopen(packed_refs_path, "re");
 	free(packed_refs_path);
 	if (f) {
 		size_t linesize = 0;
@@ -1341,7 +1341,7 @@ delete_packed_ref(struct got_reference *delref, struct
 			goto done;
 	}
 
-	f = fopen(packed_refs_path, "r");
+	f = fopen(packed_refs_path, "re");
 	if (f == NULL) {
 		err = got_error_from_errno2("fopen", packed_refs_path);
 		goto done;
blob - 5ff80e7c12f60902a2ac09403e9f24c9b77cc98e
blob + d94768b2398accc766c38e127453d48e2393841b
--- lib/worktree.c
+++ lib/worktree.c
@@ -2340,7 +2340,7 @@ open_fileindex(struct got_fileindex **fileindex, char 
 	if (err)
 		goto done;
 
-	index = fopen(*fileindex_path, "rb");
+	index = fopen(*fileindex_path, "rbe");
 	if (index == NULL) {
 		if (errno != ENOENT)
 			err = got_error_from_errno2("fopen", *fileindex_path);
@@ -3474,7 +3474,7 @@ add_ignores(struct got_pathlist_head *ignores, const c
 			}
 		}
 	} else {
-		ignoresfile = fopen(ignorespath, "r");
+		ignoresfile = fopen(ignorespath, "re");
 		if (ignoresfile == NULL) {
 			if (errno != ENOENT && errno != EACCES)
 				err = got_error_from_errno2("fopen",
@@ -8284,7 +8284,7 @@ unstage_hunks(struct got_object_id *staged_blob_id,
 			goto done;
 	}
 
-	f = fopen(path_unstaged_content, "r");
+	f = fopen(path_unstaged_content, "re");
 	if (f == NULL) {
 		err = got_error_from_errno2("fopen",
 		    path_unstaged_content);