summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-01-29 12:47:56 -0800
committerJunio C Hamano <gitster@pobox.com>2019-01-29 12:47:56 -0800
commit7fa92ba40abbe4236226e7d91e664bbeab8c43f2 (patch)
treea006af88cbd92c2d303387447e8120a046338d24
parent371820d5f1bb3c3e691ad21cee652c02c36ea758 (diff)
parentfa6f225e0141ec0df1e131e894a3a7d7dea168f5 (diff)
downloadgit-7fa92ba40abbe4236226e7d91e664bbeab8c43f2.tar.gz
git-7fa92ba40abbe4236226e7d91e664bbeab8c43f2.tar.xz
Merge branch 'js/add-e-clear-patch-before-stating'
"git add -e" got confused when the change it wants to let the user edit is smaller than the previous change that was left over in a temporary file. * js/add-e-clear-patch-before-stating: add --edit: truncate the patch file
-rw-r--r--builtin/add.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 12247b48f..d461ba08b 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -239,7 +239,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
rev.diffopt.use_color = 0;
rev.diffopt.flags.ignore_dirty_submodules = 1;
- out = open(file, O_CREAT | O_WRONLY, 0666);
+ out = open(file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (out < 0)
die(_("Could not open '%s' for writing."), file);
rev.diffopt.file = xfdopen(out, "w");