paulfitz / daff

align and compare tables
https://paulfitz.github.io/daff
MIT License
790 stars 68 forks source link

Rebase unexpectedly changes order of cells in patch log #198

Open turion opened 6 months ago

turion commented 6 months ago

I created a csv file, made some changes, added the .gitattributes and config as proposed by daff git:

commit 216ada897191ad861c8bbb39e8c90bade87f0da8
Author: Manuel Bärenz <m.baerenz@sonnen.de>
Date:   Tue Feb 27 10:10:30 2024 +0100

    .gitattributes

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..42861f2
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+*.csv merge=daff-csv diff=daff-csv

commit 993c1bd24a328e2e8bfd7ba62eecb84e522d4ad4
Author: Manuel Bärenz <m.baerenz@sonnen.de>
Date:   Tue Feb 27 10:09:26 2024 +0100

    Change cell 2

diff --git a/test.csv b/test.csv
index 932416e..41215ec 100644
--- a/test.csv
+++ b/test.csv
@@ -1 +1 @@
-fooooo,bar
+fooooo,baaaaar

commit 0a80e7cc6bb5f1ed62689c749f6d20edd540b5fb
Author: Manuel Bärenz <m.baerenz@sonnen.de>
Date:   Tue Feb 27 10:09:06 2024 +0100

    Change cell 1

diff --git a/test.csv b/test.csv
index 47929ee..932416e 100644
--- a/test.csv
+++ b/test.csv
@@ -1 +1 @@
-foo,bar
+fooooo,bar

commit d2269a0b612d1eda99bd1d6ae6c3c503ab1d4790
Author: Manuel Bärenz <m.baerenz@sonnen.de>
Date:   Tue Feb 27 10:08:33 2024 +0100

    Init

diff --git a/test.csv b/test.csv
new file mode 100644
index 0000000..47929ee
--- /dev/null
+++ b/test.csv
@@ -0,0 +1 @@
+foo,bar

Now I did two changes in two different cells which ought to be compatible:

❯ git commit -a -m "Change cell 1"
[master 0a80e7c] Change cell 1
 1 file changed, 1 insertion(+), 1 deletion(-)
commit 0a80e7cc6bb5f1ed62689c749f6d20edd540b5fb
Author: Manuel Bärenz <m.baerenz@sonnen.de>
Date:   Tue Feb 27 10:09:06 2024 +0100

    Change cell 1

❯ git show --oneline 0a80e7c
0a80e7c Change cell 1
diff --git a/test.csv b/test.csv
index 47929ee..932416e 100644
--- a/test.csv
+++ b/test.csv
@@ -1 +1 @@
-foo,bar
+fooooo,bar

❯ git commit -a -m "Change cell 2"
[master 89f14ed] Change cell 2
 1 file changed, 1 insertion(+), 1 deletion(-)

❯ git show --oneline 89f14ed
89f14ed Change cell 2
diff --git a/test.csv b/test.csv
index b40e72f..74028bd 100644
--- a/test.csv
+++ b/test.csv
@@ -1 +1 @@
-fooo,baaaaar
+fooo,baaar

Now I did an interactive rebase where I swapped the order of the commits. This ought to work with daff, I believe? And indeed the rebase succeeded without conflicts and the final CSV was correct!

But the commit history is now messed up:

commit 9f8698ad722e2b7d05ea895c21f260ab9c469dce (HEAD -> master)
Author: Manuel Bärenz <m.baerenz@sonnen.de>
Date:   Tue Feb 27 10:11:28 2024 +0100

    Change cell 1

diff --git a/test.csv b/test.csv
index bcce775..74028bd 100644
--- a/test.csv
+++ b/test.csv
@@ -1 +1 @@
-baaar,fooooo
+fooo,baaar

commit 5c89e542ce5781793a2565b53963b1024b8dfc12
Author: Manuel Bärenz <m.baerenz@sonnen.de>
Date:   Tue Feb 27 10:11:48 2024 +0100

    Change cell 2

diff --git a/test.csv b/test.csv
index 41215ec..bcce775 100644
--- a/test.csv
+++ b/test.csv
@@ -1 +1 @@
-fooooo,baaaaar
+baaar,fooooo

In the penultimate commit, the cells swapped place!