dolthub / dolt

Dolt – Git for Data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`filter-branch` destroys working and staged roots

timsehn opened this issue · comments

Repro:

$ mkdir test_filter_branch
$ cd test_filter_branch 
$ dolt init --fun
Successfully initialized dolt data repository.
$ dolt sql -q "create table t (id int primary key, words varchar(30))"
$ dolt commit -Am "created table"
commit a5jt4ri6hnm7nbmu8k38qgg4hlr87k6r (HEAD -> main) 
Author: timsehn <tim@dolthub.com>
Date:  Thu May 23 08:54:55 -0700 2024

        created table

$ dolt sql -q "insert into t values (0, 'first')"
Query OK, 1 row affected (0.00 sec)
$ dolt commit -Am "first row"                    
commit 8dl1jbmmta5m0o5fne86ee654ef58qmh (HEAD -> main) 
Author: timsehn <tim@dolthub.com>
Date:  Thu May 23 08:55:27 -0700 2024

        first row

$ dolt sql -q "insert into t values (1, 'second')"
Query OK, 1 row affected (0.00 sec)
$ dolt commit -Am "second row"                    
commit 8amosb3flu2gqabl6ierf3h0agrc9hn8 (HEAD -> main) 
Author: timsehn <tim@dolthub.com>
Date:  Thu May 23 08:55:44 -0700 2024

        second row

$ dolt sql -q "insert into t values (3, 'third')" 
Query OK, 1 row affected (0.00 sec)
$ dolt diff
diff --dolt a/t b/t
--- a/t
+++ b/t
+---+----+-------+
|   | id | words |
+---+----+-------+
| + | 3  | third |
+---+----+-------+

$ dolt filter-branch -q "alter table t add column filter int"
$ dolt diff                                                  
$ dolt status
On branch main
nothing to commit, working tree clean
$ dolt sql -q "select * from t"                              
+----+--------+--------+
| id | words  | filter |
+----+--------+--------+
| 0  | first  | NULL   |
| 1  | second | NULL   |
+----+--------+--------+

$ dolt sql -q "select * from t as of 'HEAD^'"
+----+-------+--------+
| id | words | filter |
+----+-------+--------+
| 0  | first | NULL   |
+----+-------+--------+

$ dolt sql -q "select * from t as of 'HEAD^^'"

In this case, I think the filter-branch should also execute the query on the WORKING and STAGED roots.

This will be a bit longer than our usual 24 hour turn around time. We'll have it fixed tomorrow or Monday.

So, git does not apply filter-branch changes to WORKING or STAGED roots. It forces you're working set to be clean to run filter-branch. We have matched that behavior in #7895 .

This customer requests an option to extend filter-branch to apply the query to any WORKING or STAGED roots. I'll make a new issue for that.