Skip to content

Error when tracking in non-git directory #200

Closed

Description

@PeterDaveHello

I think git-lfs can catch this exception and said:
fatal: Not a git repository (or any of the parent directories): .git
like git always does.

Currently, I got this:

$ git lfs track "*.sj"
panic: Error trying to create objects directory in '/home/peter/.git/lfs/objects': mkdir /home/peter/.git/lfs/objects: permission denied

goroutine 16 [running]:
runtime.panic(0x71a440, 0xc208000910)
        /opt/boxen/chgo/versions/1.3/src/pkg/runtime/panic.c:279 +0xf5
github.com/github/git-lfs/lfs.init·2()
        /Users/rick/github/git-lfs/.vendor/src/github.com/github/git-lfs/lfs/lfs.go:87 +0x3e3
github.com/github/git-lfs/lfs.init()
        /Users/rick/github/git-lfs/.vendor/src/github.com/github/git-lfs/lfs/util.go:88 +0x382
github.com/github/git-lfs/pointer.init()
        /Users/rick/github/git-lfs/.vendor/src/github.com/github/git-lfs/pointer/smudge.go:88 +0x85
github.com/github/git-lfs/scanner.init()
        /Users/rick/github/git-lfs/.vendor/src/github.com/github/git-lfs/scanner/scanner.go:367 +0x71
github.com/github/git-lfs/commands.init()
        /Users/rick/github/git-lfs/.vendor/src/github.com/github/git-lfs/commands/commands.go:167 +0x7b
main.init()
        /Users/rick/github/git-lfs/cmd/git-lfs.go:9 +0x46

goroutine 17 [runnable]:
runtime.MHeap_Scavenger()
        /opt/boxen/chgo/versions/1.3/src/pkg/runtime/mheap.c:507
runtime.goexit()
        /opt/boxen/chgo/versions/1.3/src/pkg/runtime/proc.c:1445

goroutine 18 [runnable]:
bgsweep()
        /opt/boxen/chgo/versions/1.3/src/pkg/runtime/mgc0.c:1976
runtime.goexit()
        /opt/boxen/chgo/versions/1.3/src/pkg/runtime/proc.c:1445

goroutine 19 [runnable]:
runfinq()
        /opt/boxen/chgo/versions/1.3/src/pkg/runtime/mgc0.c:2606
runtime.goexit()
        /opt/boxen/chgo/versions/1.3/src/pkg/runtime/proc.c:1445

Thanks!

Activity

  1. tclem commented on Apr 9, 2015

    @tclem
    Contributor

    Yup! Good catch and your suggestion sounds sensible.

  2. rubyist commented on Apr 9, 2015

    @rubyist
    Contributor

    Hmm, it actually looks like it doesn't have permissions to write to the .git/lfs/ directory. I think there are a couple things going on here.

    First, we can definitely handle this particular error better and put out a more helpful message about file permissions.

    Second, when git lfs track is run in a directory without a .git/ directory it will add the .gitattributes file no matter what. In a sense we want to be able to do that because a .gitattributes file can be in any folder in the repo, however, if we fail to calculate the LocalGitDir we should probably give the suggested error. There might be some other commands that should check this, too (git lfs env comes to mind, that will just print blank information if you're not in a repo).

    I am curious, though, how your .git/lfs folder got to be in a non-writeable state. Do you recall the steps you took before this error occurred? What are the permissions on the .git/lfs directory (e.g. ls -la .git)?

  3. PeterDaveHello commented on Apr 9, 2015

    @PeterDaveHello
    ContributorAuthor

    Hi @rubyist,

    The permission of my $HOME/.git is 755, so I have no idea what's the reason why it can't write into it, this is the first point.

    Another point is, $HOME/.git is not a repo directory, I put some git contrib files for personally use there, seems git-lfs only use filename to detect a git repo, this behavior may be not correct, right?

    Ths last thing is that I fount that if I remove .git under my home directory, then $ git lfs track "*.sj" can work anywhere(inside my home), is this behavior correct? I meant work without a git repo?

    Thanks a lot!

  4. rubyist commented on Apr 9, 2015

    @rubyist
    Contributor

    Ths last thing is that I fount that if I remove .git under my home directory, then $ git lfs track "*.sj" can work anywhere(inside my home), is this behavior correct? I meant work without a git repo?

    Yeah, I think this part is incorrect. That's what I was getting at in my second part, but in too many words 😄 We should definitely give a message that you're not in a repo when running that.

  5. PeterDaveHello commented on Apr 9, 2015

    @PeterDaveHello
    ContributorAuthor

    👍 agree, that's what I hope, sorry that I didn't write in golang, so I can just open issue instead of sending PR, thanks for your contribution 😄

  6. rubyist commented on Apr 9, 2015

    @rubyist
    Contributor

    No worries at all, the feedback you've been giving has been great, we really appreciate it!

  7. technoweenie commented on May 22, 2015

    @technoweenie
    Contributor

    Fixed in #323

  8. PeterDaveHello commented on May 23, 2015

    @PeterDaveHello
    ContributorAuthor

    👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions