git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [TESTCASE] Failing 'git am' when core.autocrlf=true
@ 2007-08-23 14:07 Marius Storm-Olsen
  2007-08-23 17:18 ` Linus Torvalds
  0 siblings, 1 reply; 8+ messages in thread
From: Marius Storm-Olsen @ 2007-08-23 14:07 UTC (permalink / raw)
  To: Git Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 950 bytes --]

Hi,

I have an issue with git-rebase failing on a repository using
     core.autocrlf=true

I've tracked it down to git-am failing with core.autocrlf=true and 
passing with core.autocrlf=false. I've tried digging deeper into the 
code, but for some reason ce_match_stat_basic() (read-cache.c:~187) 
reports the size of the file in the index to be 0 (when 
core.autocrlf=true), which is why git-am bails out on the patch. 
(ce->ce_size == 0, while st->st_size == the correct size on disk)

If I force the bailout in check_patch() (builtin-apply.c:~2101) to 
_not_ happen, the patch applies without problems.

Can anyone please enlighten me on why this may happen?

I've attached a SH script which will reproduce the problem. Simply run
     ./git_am_crlf_testcase.sh
to reproduce the problem, and run
     ./git_am_crlf_testcase.sh --no-crlf
to show it working when core.autocrlf=false.

Thanks for your help!

--
.marius


[-- Attachment #1.2: git_am_crlf_testcase.sh --]
[-- Type: text/plain, Size: 3002 bytes --]

#!/bin/sh
#
# Testcase for failing 'git am' on a repository with core.autocrlf = true
#     ./git_am_crlf_testcase.sh              fails for Git 1.5.3.rc4
#     ./git_am_crlf_testcase.sh --no-crlf    passes
#
# --------------------------------------------------------------------------------------------------

TESTCASE_REPO=git_am_crlf_testcase
GIT_AUTOCRLF=true

# parse the arguments
while [ "$#" -gt 0 ]; do
    case "$1" in
    --no-crlf) # Turn off autocrlf for the repository
        GIT_AUTOCRLF=false
        ;;
    --crlf) # Turn on autocrlf for the repository
        GIT_AUTOCRLF=true
        ;;
    esac
    shift
done


# Functions ----------------------------------------------------------------------------------------

die() {
    echo >&2 "$@"
    exit 1
}

print_patch() {
cat << __END_OF_PATCH__
From 38be10072e45dd6b08ce40851e3fca60a31a340b Mon Sep 17 00:00:00 2001
From: Marius Storm-Olsen <x@y.com>
Date: Thu, 23 Aug 2007 13:00:00 +0200
Subject: test1

---
 foo |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo

diff --git a/foo b/foo
new file mode 100644
index 0000000000000000000000000000000000000000..5716ca5987cbf97d6bb54920bea6adde242d87e6
--- /dev/null
+++ b/foo
@@ -0,0 +1 @@
+bar
-- 
1.5.3.rc4.mingw.2.3.g3318a-dirty


From 3bb3855cf028fc90010e2f51aceb6d3a90039c5c Mon Sep 17 00:00:00 2001
From: Marius Storm-Olsen <x@y.com>
Date: Thu, 23 Aug 2007 13:00:01 +0200
Subject: test2

---
 foo |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/foo b/foo
index 5716ca5987cbf97d6bb54920bea6adde242d87e6..e2994c5ae2f7c41a306d9b41b64af4d6b7242793 100644
--- a/foo
+++ b/foo
@@ -1 +1,2 @@
 bar
+baz
-- 
1.5.3.rc4.mingw.2.3.g3318a-dirty


From 38212fd002da735b3626c6f1d801c8ca37ce04e6 Mon Sep 17 00:00:00 2001
From: Marius Storm-Olsen <x@y.com>
Date: Thu, 23 Aug 2007 13:00:02 +0200
Subject: test3

---
 foo |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/foo b/foo
index e2994c5ae2f7c41a306d9b41b64af4d6b7242793..ad94f9e431a24bbe67e9e5935e2a8cf20a73e723 100644
--- a/foo
+++ b/foo
@@ -1,2 +1,3 @@
 bar
 baz
+blah
-- 
1.5.3.rc4.mingw.2.3.g3318a-dirty
__END_OF_PATCH__
}


# 'main' -------------------------------------------------------------------------------------------

# Kill old testcase repository
test -d "$TESTCASE_REPO" && rm -rf $TESTCASE_REPO

# Create new testcase repository
mkdir $TESTCASE_REPO &&
cd $TESTCASE_REPO &&
git init || die "Couldn\'t create testcase repository \'$TESTCASE_REPO\'!"

# Set autocrlf explicitly
git config core.autocrlf $GIT_AUTOCRLF || die "Couldn\'t set core.autocrlf to \'$GIT_AUTOCRLF\'!"

# Create initial commit
(echo foo > bar &&
git add bar &&
git commit -m "initial commit") || die "Couldn\'t create initial file!"

# Apply failing patch set
print_patch | git am --binary -3 || die "Applying patch set to autocrlf=true repo failed!"

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 187 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-08-23 20:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-23 14:07 [TESTCASE] Failing 'git am' when core.autocrlf=true Marius Storm-Olsen
2007-08-23 17:18 ` Linus Torvalds
2007-08-23 17:45   ` Marius Storm-Olsen
2007-08-23 18:41   ` Junio C Hamano
2007-08-23 19:25     ` Linus Torvalds
2007-08-23 19:23   ` Linus Torvalds
2007-08-23 19:44     ` Junio C Hamano
2007-08-23 20:11     ` Marius Storm-Olsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).