Joe C
Joe C

Reputation: 3546

Git diff shows the wrong changes

I've updated a four lines of code in a file, verified everything is working, and went to commit my code.

I check the git status and see that git recognizes that I've changed the file I've been working on.

However, when I do a git diff, it says I've changed a different line of code, and that the lines I did change were not changed.

How can I get fix this and get git to recognize my changes correctly?

My code in question (changed lines marked in comments):

<cfcomponent displayname="Config" output="false" alias="com.ams.sms.timekeeper.ConfigBean">

        <cfproperty name="Config_ID" type="numeric" default="" />
        <cfproperty name="School_ID" type="numeric" default="" />
        <cfproperty name="Is_Recycled" type="numeric" default="" />
        <cfproperty name="Period_Type" type="numeric" default="" />
        <cfproperty name="Rounding_Unit" type="numeric" default="" />
        <cfproperty name="Grace_Time" type="numeric" default="" />
        <cfproperty name="Auto_Create_Periods" type="boolean" default="" />
        <cfproperty name="Verification_Method" type="numeric" default="" />
        <cfproperty name="Allow_Manual" type="boolean" default="" />

    <!---
    PROPERTIES
    --->
    <cfscript>
        variables.Config_ID="";
        variables.School_ID="";
        variables.Is_Recycled=0; // changed
        variables.Period_Type=1;
        variables.Rounding_Unit=0; //changed
        variables.Grace_Time=0; //changed
        variables.Auto_Create_Periods=true;
        variables.Verification_Method=0; //changed
        variables.Allow_Manual=true;
    </cfscript>

git diff returns the following, saying that I've updated the line 1, which I haven't, and ignores the changes on the lines further in:

$ git diff
diff --git a/ams/sms/timekeeper/ConfigBean.cfc b/ams/sms/timekeeper/ConfigBean.cfc
index e2db893..9dabfc9 100644
--- a/ams/sms/timekeeper/ConfigBean.cfc
+++ b/ams/sms/timekeeper/ConfigBean.cfc
@@ -1 +1 @@
-<cfcomponent displayname="Config" output="false" alias="com.ams.sms.timekeeper.ConfigBean">^M^M
\ No newline at end of file
+<cfcomponent displayname="Config" output="false" alias="com.ams.sms.timekeeper.ConfigBean">^M^M
\ No newline at end of file
(END)

Upvotes: 0

Views: 3255

Answers (1)

Vampire
Vampire

Reputation: 38619

I'd say your line separators are a bit bogus.
Do you have old mac line endings in the file (only \r)?
Because the diff sees the whole file as one line (you see that as after your first line it says "No newline at end of file" which means that after that line the file is finished already) and vim just doesn't display the rest of the line or something like that.

Upvotes: 1

Related Questions