jj icon indicating copy to clipboard operation
jj copied to clipboard

Cannot untrack rediscovered git submodule

Open thomasa88 opened this issue 1 month ago • 5 comments

Description

Setup: Git repo with submodules. One moves back in history past the submodule creation and then forward to the future again. The submodule is no longer ignored and the directory shows up as "D submodule". It seems impossible to get out of this state, without commiting to the submodule directory being removed. Trying exclude files and untrack does not help.

Steps to Reproduce the Problem

#!/bin/bash

set -ex

git clone https://github.com/thomasa88/jj-submodule-bug.git
cd jj-submodule-bug
jj git init
jj bookmark track main@origin
jj new 258c2b20
jj st
jj new 3ef6b442
jj st
echo sub >> .git/info/exclude
jj file untrack sub
jj new 3ef6b442
jj st
jj abandon

Expected Behavior

Way to recover from the submodule directory not being ignored any longer.

Actual Behavior

> jj abandon
Abandoned 1 commits:
  kkmqxzlx cf2309a1 (no description set)
Working copy  (@) now at: wszxoryo 59e34e67 (empty) (no description set)
Parent commit (@-)      : lmywpurl 3ef6b442 main | Add simple test runner script
Added 1 files, modified 0 files, removed 0 files
Warning: 1 of those updates were skipped because there were conflicting changes in the working copy.
Hint: Inspect the changes compared to the intended target with `jj diff --from 59e34e679671`.
Discard the conflicting changes with `jj restore --from 59e34e679671`.

> jj st
Working copy changes:
D sub
Working copy  (@) : wszxoryo 1c8d0bb7 (no description set)
Parent commit (@-): lmywpurl 3ef6b442 main | Add simple test runner script

Cannot get rid of the change by abandon or new to the past.

Specifications

  • Platform: Ubuntu 25.04
  • Version: 0.35.0-aa2b76978c4a23cb01c61629a11b1254af3ad0d9

thomasa88 avatar Nov 18 '25 18:11 thomasa88

https://github.com/jj-vcs/jj/pull/826 is possibly related

thomasa88 avatar Nov 27 '25 20:11 thomasa88

Short update: This appears to be fixed by ensuring the submodule store directory is always created on init. In lib/src/default_submodule_store.rs, I updated SubmoduleStore::init to call std::fs::create_dir_all(store_path) before returning Self { path: store_path.to_path_buf() }. This prevents the missing-directory state for submodules, and the behavior now matches expectations. Validated in test reproduction repo with all tests passing and clean release build.

rammaruboina-rgb avatar Nov 27 '25 23:11 rammaruboina-rgb

I'm sorry rammaruboina-rgb, but both your first (now deleted) comment and your comment above sounds like AI slob.

Would you mind pointing to a branch or PR with your changes? What is the output of my test sequence in the issue description if you run with with your updated code? Thanks.

thomasa88 avatar Nov 28 '25 03:11 thomasa88

JJ no longer picks up files, from left-over submodule directories, that are not tracked, since version 0.36:

https://github.com/jj-vcs/jj/issues/4349#issuecomment-2316502441 https://github.com/jj-vcs/jj/pull/8157

However, I'm still seeing the problem of the "deleted" submodule directory when moving forwards in history. My suggested solution is in https://github.com/jj-vcs/jj/pull/8225

thomasa88 avatar Dec 07 '25 12:12 thomasa88

Future Problem & Resolution

The "deleted submodule directory when moving forwards in history" issue will persist until PR #8225 is merged and released. After that version ships, this edge case should be resolved. However, keep in mind that submodule handling in version control systems can still surface new edge cases, so it's worth monitoring for any related issues even after the fix lands.

rammaruboina-rgb avatar Dec 08 '25 01:12 rammaruboina-rgb