I ran into a problem with Git. I used Git Gui, because the edits I was working 
on turned out to contain two different classes of edits. One was the code 
changes for the branch I was on, and the other was just general code cleanup 
that belong in a different branch.

One hunk in particular, started with a close comment that belonged to the code 
cleanup branch, and then new routines that belonged to the dev branch.

Git Gui gave me no problems; it committed the half chunk just fine. Then, I try 
to check out a new branch to commit the general code cleanup changes.

Git complained that doing so would overwrite my local changes.

Here's the offending block after the merge:

keybounceMBP:Finite-Fluids michael$ git checkout -b cleanup develop
error: Your local changes to the following files would be overwritten by 
checkout:
        src/main/java/com/mcfht/realisticfluids/FluidData.java
        src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java
Please commit your changes or stash them before you switch branches.
Aborting
keybounceMBP:Finite-Fluids michael$ git checkout -m -b cleanup develop
M       src/main/java/com/mcfht/realisticfluids/FluidData.java
M       src/main/java/com/mcfht/realisticfluids/commands/CommandEnableFlow.java
M       src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java
M       src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteLava.java
Switched to a new branch 'cleanup'
keybounceMBP:Finite-Fluids michael$ git diff
diff --cc src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java
index 443c227,02d77bc..0000000
--- a/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java
+++ b/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java
@@@ -719,5 -724,42 +720,81 @@@ public class BlockFiniteFluid extends B
      {
          return super.disableStats();
      }
++<<<<<<< develop
++||||||| feature/IBlockFluid
++    @Override
++    public Fluid getFluid()
++    {
++        if (Material.water == this.blockMaterial)
++            return FluidRegistry.WATER;
++        else
++            return FluidRegistry.LAVA;
++    }
++
++    @Override
++    public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
++    {
++        FluidStack output = new FluidStack(getFluid(), getBucketAmount(world, 
x, y, z));
++        if (doDrain)
++            FluidData.setLevelWorld(world, x, y, z, 0);
++        return output;
++    }
++
++    private int getBucketAmount(World world, int x, int y, int z)
++    {
++        return (int) (getFilledPercentage(world, x, y, z) * 1000);
++    }
++
++    @Override
++    public boolean canDrain(World world, int x, int y, int z)
++    {
++        return true;
++    }
++
++    @Override
++    public float getFilledPercentage(World world, int x, int y, int z)
++    {
++        int level=FluidData.getLevelWorld(world, x, y, z);
++        return (float)level/RealisticFluids.MAX_FLUID;
++    }
++=======
+ */
+ 
+     @Override
+     public Fluid getFluid()
+     {
+         if (Material.water == this.blockMaterial)
+             return FluidRegistry.WATER;
+         else
+             return FluidRegistry.LAVA;
+     }
+ 
+     @Override
+     public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
+     {
+         FluidStack output = new FluidStack(getFluid(), getBucketAmount(world, 
x, y, z));
+         if (doDrain)
+             FluidData.setLevelWorld(world, x, y, z, 0);
+         return output;
+     }
+ 
+     private int getBucketAmount(World world, int x, int y, int z)
+     {
+         return (int) (getFilledPercentage(world, x, y, z) * 1000);
+     }
+ 
+     @Override
+     public boolean canDrain(World world, int x, int y, int z)
+     {
+         return true;
+     }
+ 
+     @Override
+     public float getFilledPercentage(World world, int x, int y, int z)
+     {
+         int level=FluidData.getLevelWorld(world, x, y, z);
+         return (float)level/RealisticFluids.MAX_FLUID;
+     }
++>>>>>>> local
  
  }

The only thing that should go into this location -- branch cleanup -- is just 
"*/".
Everything else was committed into feature/iBlockFluid

Here is the diff before the switch and merge:

keybounceMBP:Finite-Fluids michael$ git diff
diff --git a/src/main/java/com/mcfht/realisticfluids/FluidData.java 
b/src/main/java/com/mcfht/realisticfluids/FluidData.java
index cf2b155..93c5eca 100644
--- a/src/main/java/com/mcfht/realisticfluids/FluidData.java
+++ b/src/main/java/com/mcfht/realisticfluids/FluidData.java
@@ -42,6 +42,7 @@ package com.mcfht.realisticfluids;
 
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
+
 import net.minecraft.block.Block;
 import net.minecraft.block.material.Material;
 import net.minecraft.init.Blocks;
@@ -637,7 +638,7 @@ public class FluidData
      */
     public static ChunkData testCurrentChunkData(final ChunkData data0, final 
int x1, final int z1)
     {
-        final Chunk cOut = data0.w.getChunkFromChunkCoords(x1 >> 4, z1 >> 4);
+        final Chunk cOut = data0.w.getChunkFromBlockCoords(x1, z1);
         if (!cOut.isChunkLoaded)
             return null;
         if (cOut.xPosition != data0.c.xPosition || cOut.zPosition != 
data0.c.zPosition)
@@ -661,7 +662,7 @@ public class FluidData
     {
 //        try
         {
-            Chunk cOut = data0.w.getChunkFromChunkCoords(x1 >> 4, z1 >> 4);
+            Chunk cOut = data0.w.getChunkFromBlockCoords(x1, z1);
 //            if (!cOut.isChunkLoaded)
 //                ;
 //            {
diff --git 
a/src/main/java/com/mcfht/realisticfluids/commands/CommandEnableFlow.java 
b/src/main/java/com/mcfht/realisticfluids/commands/CommandEnableFlow.java
index 26c6ebc..5ab6a22 100644
--- a/src/main/java/com/mcfht/realisticfluids/commands/CommandEnableFlow.java
+++ b/src/main/java/com/mcfht/realisticfluids/commands/CommandEnableFlow.java
@@ -59,6 +59,7 @@ public class CommandEnableFlow extends CommandBase
         return "rff-enableflow <true|false>";
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public List<String> addTabCompletionOptions(ICommandSender sender, 
String[] args)
     {
diff --git 
a/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java 
b/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java
index ea1b2a7..02d77bc 100644
--- a/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java
+++ b/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteFluid.java
@@ -675,6 +675,7 @@ public class BlockFiniteFluid extends BlockDynamicLiquid 
implements IFluidBlock
         // Blocks.flowing_lava, xl, yl, zl, ll - (3 * lw) / 2, false);
     }
 
+/*
     // Because bad stuff seems to be happening when these methods are not
     // present... they should be inherited, but apparently not D:
     @Override
@@ -723,6 +724,8 @@ public class BlockFiniteFluid extends BlockDynamicLiquid 
implements IFluidBlock
     {
         return super.disableStats();
     }
+*/
+
     @Override
     public Fluid getFluid()
     {
diff --git 
a/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteLava.java 
b/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteLava.java
index 74fef5a..aaa4355 100644
--- a/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteLava.java
+++ b/src/main/java/com/mcfht/realisticfluids/fluids/BlockFiniteLava.java
@@ -185,7 +185,7 @@ public final class BlockFiniteLava extends BlockFiniteFluid
                return 0;
        }
 
-       @Override
+/*     @Override
        public Block setHardness(final float f)
        {
                return super.setHardness(f);
@@ -221,4 +221,5 @@ public final class BlockFiniteLava extends BlockFiniteFluid
        {
                return super.disableStats();
        }
+*/
 }

Here's the issue:
** This is exactly what I wanted to commit into the cleanup branch **

There is one chunk in that list of diffs that is a half-commit. As a pure 
"apply this diff patch", it would fail because the bottom context lines do not 
match. 

Somehow, git brought the entire set of changes in the file -- not just the "not 
checked in changes" -- over to the cleanup branch.
And, this *After* knowing that a commit that had that had been checked in.

Now, manually fixing it this time is trivial. But I want to know why it 
happened, and how to prevent this from happening in the future.

Specifically, is there any way to improve the "check in specific lines in Git 
Gui" to prevent this type of conflict from happening? 
---
Entertaining minecraft videos
http://YouTube.com/keybounce

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to