On Sat, Jan 12, 2008 at 06:54:13PM +0100, Steffen Prohaska wrote:This check is okay, however this is not, because if you really want to be sure that file will not be mangled by checkout, you should not allow a text file with naked LF when autocrlf=true. And the following lines after gather_stats() can cause: /* No CR? Nothing to convert, regardless. */ if (!stats.cr) return 0; So, I propose a slightly different patch for convert.c: diff --git a/convert.c b/convert.c index 4df7559..9fd88d9 100644 --- a/convert.c +++ b/convert.c @@ -90,9 +90,6 @@ static int crlf_to_git(const char *path, const char *src, size_t len, return 0; gather_stats(src, len, &stats); - /* No CR? Nothing to convert, regardless. */ - if (!stats.cr) - return 0; if (action == CRLF_GUESS) { /* @@ -108,8 +105,23 @@ static int crlf_to_git(const char *path, const char *src, size_t len, */ if (is_binary(len, &stats)) return 0; + + if (safe_crlf) { + /* check if we have "naked" LFs */ + if (stats.lf != stats.crlf) { + if (safe_crlf == SAFE_CRLF_WARN) + warning( + "Checkout will replace LFs with CRLF in %s", path); + else + die("Checkout would replace LFs with CRLF in %s", path); + } + } } + /* No CR? Nothing to convert, regardless. */ + if (!stats.cr) + return 0; + /* only grow if not in place */ if (strbuf_avail(buf) + buf->len < len) strbuf_grow(buf, len - buf->len); @@ -131,6 +143,16 @@ static int crlf_to_git(const char *path, const char *src, size_t len, if (! (c == '\r' && (1 < len && *src == '\n'))) *dst++ = c; } while (--len); + + if (safe_crlf && (action == CRLF_INPUT || auto_crlf <= 0)) { + /* autocrlf=input: check if we removed CRLFs */ + if (buf->len != dst - buf->buf) { + if (safe_crlf == SAFE_CRLF_WARN) + warning("Stripped CRLF from %s.", path); + else + die("Refusing to strip CRLF from %s.", path); + } + } } strbuf_setlen(buf, dst - buf->buf); return 1; Dmitry - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Linus Torvalds | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Tony Lindgren | [PATCH 37/90] ARM: OMAP: MPUIO wake updates |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Miklos Szeredi | -rt doesn't compile for UML |
git: | |
| Florian Weimer | Re: Handling large files with GIT |
| Dana How | [PATCH] Prevent megablobs from gunking up git packs |
| Denis Bueno | Recovering from repository corruption |
| Peter Stahlir | Git as a filesystem |
| Richard Stallman | Real men don't attack straw men |
| Brian A. Seklecki | sshd_config(5) PermitRootLogin yes |
| Theo de Raadt | Re: dmesg IBM x3650 OpenBSD 4.3 |
| Stuart Henderson | Re: Actual BIND error - Patching OpenBSD 4.3 named ? |
| Auke Kok | [PATCH 5/6] e1000: Secondary unicast address support |
| Jon Nelson | tg3: strange errors and non-working-ness |
| Indan Zupancic | Re: Realtek 8111C transmit timed out |
| Brandeburg, Jesse | RE: 2.6.24 BUG: soft lockup - CPU#X |
| usb mic not detected | 4 hours ago | Applications and Utilities |
| Problem in Inserting a module | 4 hours ago | Linux kernel |
| Treason Uncloaked | 10 hours ago | Linux kernel |
| Shared swap partition | 21 hours ago | Linux general |
| high memory | 2 days ago | Linux kernel |
| semaphore access speed | 2 days ago | Applications and Utilities |
| the kernel how to power off the machine | 2 days ago | Linux kernel |
| Easter Eggs in windows XP | 2 days ago | Windows |
| Root password | 3 days ago | Linux general |
| Where/when DNOTIFY is used? | 3 days ago | Linux kernel |
