summaryrefslogtreecommitdiff
path: root/builtin/add.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2019-01-29 12:47:56 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-01-29 12:47:56 -0800
commit7fa92ba40abbe4236226e7d91e664bbeab8c43f2 (patch)
treea006af88cbd92c2d303387447e8120a046338d24 /builtin/add.c
parentMerge branch 'bc/tree-walk-oid' (diff)
parentadd --edit: truncate the patch file (diff)
downloadtgif-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
Diffstat (limited to 'builtin/add.c')
-rw-r--r--builtin/add.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 12247b48fd..d461ba08b9 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");