Skip to content

Commit 346365d

Browse files
committed
add --edit: truncate the patch file
If there is already a .git/ADD_EDIT.patch file, we fail to truncate it properly, which could result in very funny errors. Let's just truncate it and not worry about it too much. Reported by J Wyman. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 453ee1f commit 346365d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/add.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
239239
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
240240
rev.diffopt.use_color = 0;
241241
rev.diffopt.flags.ignore_dirty_submodules = 1;
242-
out = open(file, O_CREAT | O_WRONLY, 0666);
242+
out = open(file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
243243
if (out < 0)
244244
die(_("Could not open '%s' for writing."), file);
245245
rev.diffopt.file = xfdopen(out, "w");

0 commit comments

Comments
 (0)