@@ -638,3 +638,58 @@ begin_test "prune keep stashed changes"
638
638
)
639
639
end_test
640
640
641
+ begin_test " prune keep stashed changes in index"
642
+ (
643
+ set -e
644
+
645
+ reponame=" prune_keep_stashed_index"
646
+ setup_remote_repo " remote_$reponame "
647
+
648
+ clone_repo " remote_$reponame " " clone_$reponame "
649
+
650
+ git lfs track " *.dat" 2>&1 | tee track.log
651
+ grep " Tracking \" \*.dat\" " track.log
652
+
653
+ # generate content we'll use
654
+ content_inrepo=" This is the original committed data"
655
+ oid_inrepo=$( calc_oid " $content_inrepo " )
656
+ content_indexstashed=" This data will be stashed from the index and should not be deleted"
657
+ oid_indexstashed=$( calc_oid " $content_indexstashed " )
658
+ content_stashed=" This data will be stashed and should not be deleted"
659
+ oid_stashed=$( calc_oid " $content_stashed " )
660
+
661
+ # We just need one commit of base data, makes it easier to test stash
662
+ echo " [
663
+ {
664
+ \" CommitDate\" :\" $( get_date -1d) \" ,
665
+ \" Files\" :[
666
+ {\" Filename\" :\" stashedfile.dat\" ,\" Size\" :${# content_inrepo} , \" Data\" :\" $content_inrepo \" }]
667
+ }
668
+ ]" | lfstest-testutils addcommits
669
+
670
+ # now modify the file, and add it to the index
671
+ echo -n " $content_indexstashed " > stashedfile.dat
672
+ git add stashedfile.dat
673
+
674
+ # now modify the file again, and stash it
675
+ echo -n " $content_stashed " > stashedfile.dat
676
+
677
+ git stash
678
+
679
+ # Prove that the stashed data was stored in LFS (should call clean filter)
680
+ assert_local_object " $oid_stashed " " ${# content_stashed} "
681
+ assert_local_object " $oid_indexstashed " " ${# content_indexstashed} "
682
+
683
+ # Prune data, should NOT delete stashed file or stashed changes to index
684
+ git lfs prune
685
+
686
+ assert_local_object " $oid_stashed " " ${# content_stashed} "
687
+ assert_local_object " $oid_indexstashed " " ${# content_indexstashed} "
688
+
689
+ # Restore working tree from stash
690
+ git stash pop --index
691
+
692
+ # Reset working tree to index from stash
693
+ git checkout .
694
+ )
695
+ end_test
0 commit comments