jj icon indicating copy to clipboard operation
jj copied to clipboard

Support unignoring files/folders in .gitignore

Open Brixy opened this issue 1 year ago • 1 comments

Description

jj seems to ignore ! in .gitignore.

Steps to Reproduce the Problem

I have not tested it extensively, but this is a common use case for demonstration:

mkdir test
touch test/unignore_me
echo -e 'test/*\n!test/unignore_me' > .gitignore
git init
jj init --git-repo=.
jj commit -m 'Init'
jj st # The working copy is clean
git status # Unversioned files: test/

Also tested with test/** in .gitignore.

If it really is a jj issue it might be crucial. (I am pretty new to jj and have not followed all discussions. But I did search for similar issues.)

Expected Behavior

jj should add test/unignore_me in the initial revision -- like ‘pure’ git.

Actual Behavior

jj ignores test/unignore_me.

Specifications

  • Platform: Linux 6.7, wayland
  • Version: jj 0.13.0-5450e6c9bae40b941b05942bdd78a88e1b9093a6

Brixy avatar Feb 12 '24 10:02 Brixy

Looks like a bug. visit_directory() first tests the directory "test/", and it doesn't match the negative pattern literally, the whole directory is ignored. #2499 might fix the issue, but I have no idea.

yuja avatar Feb 12 '24 14:02 yuja

#3071 will fix it. with jj 0.14.0

 //.../workspace/jj/issue_3031 ❯ git init
Initialized empty Git repository in /Users/daehyeok/workspace/jj/issue_3031/.git/
 //.../workspace/jj/issue_3031 ❯ jj init --git-repo=.
warning: `--git` and `--git-repo` are deprecated.
Use `jj git init` instead
Initialized repo in "."
 //.../workspace/jj/issue_3031 ❯ jj st
Working copy changes:
A .gitignore
Working copy : uqptwszk e79a4a6b (no description set)
Parent commit: zzzzzzzz 00000000 (empty) (no description set)
 //.../workspace/jj/issue_3031 ❯

with PR.

 //.../workspace/jj/issue_3031 ❯ git init
Initialized empty Git repository in /Users/daehyeok/workspace/jj/issue_3031/.git/
 //.../workspace/jj/issue_3031 ❯ ../target/debug/jj init --git-repo=.
warning: `--git` and `--git-repo` are deprecated.
Use `jj git init` instead
Initialized repo in "."
 //.../workspace/jj/issue_3031 ❯ ../target/debug/jj st
Working copy changes:
A .gitignore
A test/unignore_me
Working copy : mrwntuvm ae763def (no description set)
Parent commit: zzzzzzzz 00000000 (empty) (no description set)

daehyeok avatar Feb 18 '24 21:02 daehyeok