Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitignore incompatibility with *~ #5059

Closed
hanwen-flow opened this issue Dec 9, 2024 · 6 comments
Closed

gitignore incompatibility with *~ #5059

hanwen-flow opened this issue Dec 9, 2024 · 6 comments

Comments

@hanwen-flow
Copy link

Description

I have trouble convincing jj to leave emacs backup files alone in new repos.

hanwen@hanwen-flow:/tmp$ mkdir jj-repro
hanwen@hanwen-flow:/tmp$ cd jj-repro/
hanwen@hanwen-flow:/tmp/jj-repro$ jj git init --colocate
Initialized repo in "."
hanwen@hanwen-flow:/tmp/jj-repro$ echo hoi > foo~
hanwen@hanwen-flow:/tmp/jj-repro$ ls
foo~
hanwen@hanwen-flow:/tmp/jj-repro$ jj diff --name-only|cat
foo~
hanwen@hanwen-flow:/tmp/jj-repro$ echo '*~' > .gitignore
hanwen@hanwen-flow:/tmp/jj-repro$ jj diff --name-only|cat
.gitignore
foo~
hanwen@hanwen-flow:/tmp/jj-repro$ jj commit -m 'ignore' .gitignore 
Working copy now at: ykkstpsq 1477f6a8 (no description set)
Parent commit      : vvvlpwkx a04d0c9c ignore
hanwen@hanwen-flow:/tmp/jj-repro$ jj diff --name-only|cat
foo~
hanwen@hanwen-flow:/tmp/jj-repro$ git status
HEAD detached at a04d0c9
nothing to commit, working tree clean

I am a bit stumped, because I have another repo on another machine where I got this to work, but I can't recall what I tweaked there.

Specifications

  • Platform: linux x64
  • Version: jj 0.21.0-d002a5ad35e624a731e96e85f490f28febc7797e
@yuja
Copy link
Contributor

yuja commented Dec 9, 2024

.gitignore only applies to new (untracked) files. You'll need to do jj file untrack 'glob:"*~"' to remove a tracked file from the commit. (see #4509 for why ~ needs quotes)

I think there's a feature request about newly-tracked ignored files, something like making jj status to show hint how to untrack these files.

@hanwen-flow
Copy link
Author

so if I understand correctly, any jj command takes a snapshot, making a *~ file be tracked before I add the pattern to .gitignore

that matches what I see,

hanwen@hanwen-flow:/tmp/zq$ jj git init --colocate
Initialized repo in "."
hanwen@hanwen-flow:/tmp/zq$ echo '*~' > .gitignore
hanwen@hanwen-flow:/tmp/zq$ touch foo~
hanwen@hanwen-flow:/tmp/zq$ jj diff --name-only|cat
.gitignore
hanwen@hanwen-flow:/tmp/zq$ 

the behavior is logical in retrospect, but maybe could be mentioned more explicitly in the docs.

@yuja
Copy link
Contributor

yuja commented Dec 11, 2024

any jj command takes a snapshot, making a *~ file be tracked before I add the pattern to .gitignore

Correct. A working-copy change is a commit in jj.

the behavior is logical in retrospect, but maybe could be mentioned more explicitly in the docs.

Do you have any suggestion? It's documented in tutorial, but the Git comparison table might be a better place.

https://martinvonz.github.io/jj/latest/tutorial/#creating-our-first-change
https://martinvonz.github.io/jj/latest/git-comparison/#command-equivalence-table

@hanwen-flow
Copy link
Author

"jj gitignore" on google doesn't bring up the tutorial in the first 10 results. instead, the first page is https://martinvonz.github.io/jj/latest/git-compatibility/, which just says " Ignores in .gitignore files are supported. So are ignores in .git/info/exclude or configured via Git's core.excludesfile config. The .gitignore support uses a native implementation, so please report a bug if you notice any difference compared to git."

maybe something like

"Patterns for untracked files in .gitignore files are supported. So are ignores in .git/info/exclude or configured via Git's core.excludesfile config. For tracked files, see 'jj untrack'. The .gitignore support uses a native implementation, ... "

@joyously
Copy link

It could also mention that if you know you need a pattern ignored, make the ignore file before the init command.

@hanwen-flow
Copy link
Author

thanks, Yuya!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants