Skip to content

File Lock blocks git lfs checkout from replacing files #3102

Closed

Description

@FattyMieo

git lfs checkout throws error "Could not checkout <path>" due to the files are read-only set by the FIle Lock. How can I resolve this problem?

Activity

  1. ttaylorr commented on Jul 5, 2018

    @ttaylorr
    Contributor

    Hi @FattyMieo, thanks for opening this. It seems like a bug to me, and I think that we have a couple of options on how to go forward. My inclination is to suggest that you use git checkout instead of git lfs checkout, since it is deprecated and will n ot be included in future releases starting after v3.0.0.

    Alternatively, we could teach git lfs checkout to work around these, by first making the file writeable if it is not. That would look something like:

    diff --git a/lfs/gitfilter_smudge.go b/lfs/gitfilter_smudge.go
    index 0d1c0d1b..21886cb2 100644
    --- a/lfs/gitfilter_smudge.go
    +++ b/lfs/gitfilter_smudge.go
    @@ -21,6 +21,19 @@ func (f *GitFilter) SmudgeToFile(filename string, ptr *Pointer, download bool, m
     		return fmt.Errorf("Could not create working directory file: %v", err)
     	}
     	defer file.Close()
    +
    +	stat, err := file.Stat()
    +	if err != nil {
    +		return fmt.Errorf("Could not stat working directory file: %v", err)
    +	}
    +
    +	// When we're done, return the file back to its normal permission bits.
    +	defer file.Chmod(stat.Mode())
    +
    +	if err := file.Chmod(stat.Mode() | 0200); err != nil {
    +		return fmt.Errorf("Could not make file write-able for checkout")
    +	}
    +
     	if _, err := f.Smudge(file, ptr, filename, download, manifest, cb); err != nil {
     		if errors.IsDownloadDeclinedError(err) {
     			// write placeholder data instead

    But it might not be worthwhile if we're going to remove the command anyway.

    @larsxschneider @PastelMobileSuit what do you think?

  2. PastelMobileSuit commented on Jul 5, 2018

    @PastelMobileSuit
    Contributor

    @FattyMieo Thanks for opening the issue! In regards to @ttaylorr's comment above, I think git checkout is the best path forward here, since git lfs checkout is currently deprecated. I've also done a quick test locally and git checkout seems to work if a file is locked.

  3. FattyMieo commented on Jul 8, 2018

    @FattyMieo
    Author

    Thank you for the replies.

    My team was using Gitkraken and this was happening when I checkout between branches (and pulling new changes). Gitkraken doesn't throw any error logs and so is when I attempted to do git checkout in git bash; only the files are still remained pointers. The error log only shows up when I do git lfs checkout.

    I'm not sure if this affects if I were using a GUI client.

  4. ttaylorr commented on Jul 9, 2018

    @ttaylorr
    Contributor

    In regards to @ttaylorr's comment above, I think git checkout is the best path forward here, since git lfs checkout is currently deprecated.

    @PastelMobileSuit and I had another chance to chat about this, and we've decided to patch the deprecated git lfs checkout command so that this will work while users convert to using git-checkout(1).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions