author | Junio C Hamano <junkio@cox.net> | |
Fri, 23 Mar 2007 00:32:51 +0000 (17:32 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 23 Mar 2007 00:32:51 +0000 (17:32 -0700) | ||
commit | cc96fd092a55a7a8685f0dee1e287ded70bc08b7 | |
tree | 7f06e01abd58cbb9e6200dc8a2e16d8fc5687030 | tree | snapshot |
parent | 00cec846f157b5363b0967d1e4cba76b44d48e77 | commit | diff |
git-apply: Do not free the wrong buffer when we convert the data for writeout
When we write out the result of patch application, we sometimes
need to munge the data (e.g. under core.autocrlf). After doing
so, what we should free is the temporary buffer that holds the
converted data returned from convert_to_working_tree(), not the
original one.
This patch also moves the call to open() up in the function, as
the caller expects us to fail cheaply if leading directories
need to be created (and then the caller creates them and calls
us again). For that calling pattern, attempting conversion
before opening the file adds unnecessary overhead.
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
When we write out the result of patch application, we sometimes
need to munge the data (e.g. under core.autocrlf). After doing
so, what we should free is the temporary buffer that holds the
converted data returned from convert_to_working_tree(), not the
original one.
This patch also moves the call to open() up in the function, as
the caller expects us to fail cheaply if leading directories
need to be created (and then the caller creates them and calls
us again). For that calling pattern, attempting conversion
before opening the file adds unnecessary overhead.
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-apply.c | diff | blob | history |