xwmx / nb

CLI and local web plain text note‑taking, bookmarking, and archiving with linking, tagging, filtering, search, Git versioning & syncing, Pandoc conversion, + more, in a single portable script.
https://xwmx.github.io/nb
GNU Affero General Public License v3.0
6.43k stars 180 forks source link

No error when git fails to add/commit #276

Open jorgen99 opened 9 months ago

jorgen99 commented 9 months ago

I had problems importing multiple files. It looked like the files are imported ok. But running "nb git log" I could see that some imports was not commited. "nb git status" lists them as untracked.

It's my git config that doesn't let me add files with CRLF line terminators so nb fails to add them to the index.

Since the repo is now out of sync with the files on disk, when I try to delete one of them I get an error:

fatal: pathspec '/Users/jorgen/.nb/home/somefile.org' did not match any files

The workaround of course is to fix my files so that git will accept them, but it would also be nice if nb would tell you that something went wrong.

How to reproduce:

$ git config --global core.safecrlf true
<create file with CRLF>
$ nb import <file>
<file is imported fine>
$ nb delete <id> // will be an error
$ nb git status // the file will be listed as untracked
xwmx commented 8 months ago

@jorgen99 Thanks for the information.

Currently the git operations are handled in the background after the item is added to the .index. Checking for git errors seems like it would require revering that order of operations and waiting for the git operations to finish. It might be better to allow them in the .index and ignore the git error during operations like delete, though this would result in clones having entries in .index that reference files that aren't in the repo.

I'll have to think more about how to handle these files.