Skip to content

.gitconfig rewritten on launch #4602

Closed
Closed

Description

@LazyBoot

Description

I noticed that my .gitconfig file gets deleted and recreated every time I launch Github Desktop. This resulted in me losing my config file due to a bsod (unrelated to desktop) that occurred while desktop was starting up, corrupting the entire file.
Also, could this not result in a race-condition if I were to start Desktop and another program that reads the .gitconfig at the same time? Like Visual Studio that has a git client as an extension.

Version

  • GitHub Desktop: 1.1.1
  • Operating system: Windows 10 (1709)

Steps to Reproduce

  1. Open the .gitconfig location in explorer
  2. Start GitHub Desktop
  3. notice that the .gitconfig file has moved to the end, and that the file created/modified times have been reset to the current time.

Expected Behavior

I'd expect Desktop to read the .gitconfig file, but leave it unchanged.

Actual Behavior

The .gitconfig file is read, deleted, and created again with the same contents.

Additional Information

Logs

Activity

  1. niik commented on May 4, 2018

    @niik
    Member

    Hey @LazyBoot, thanks for opening this.

    Looks like this is caused by us running git lfs install --skip-repo in order to install the global LFS filters. I was under the impression that unless passed --force git lfs wouldn't try to overwrite the values but it seems it does. Reading through https://github.com/git-lfs/git-lfs/blob/98288ae18899244501850a92065b207ce18821f7/lfs/attribute.go#L126-L152 it certainly seems like there's provisions in there for not overwriting unless necessary.

    Running git lfs install --skip-repo with the GIT_TRACE=1 environment variable confirms this

    C02Q60DMGCN2:git-core markus$ GIT_TRACE=1 ./git-lfs install --skip-repo
    16:38:58.656296 trace git-lfs: exec: git 'version'
    16:38:58.669961 trace git-lfs: exec: git 'config' '--global' 'filter.lfs.process'
    16:38:58.686455 trace git-lfs: exec: git 'config' '--global' '--replace-all' 'filter.lfs.process' 'git-lfs filter-process'
    16:38:58.714318 trace git-lfs: exec: git 'config' '--global' 'filter.lfs.required'
    16:38:58.735164 trace git-lfs: exec: git 'config' '--global' 'filter.lfs.clean'
    16:38:58.755172 trace git-lfs: exec: git 'config' '--global' 'filter.lfs.smudge'
    16:38:58.772220 trace git-lfs: exec: git 'config' '--global' '--replace-all' 'filter.lfs.smudge' 'git-lfs smudge -- %f'
    Git LFS initialized.
    

    While it doesn't attempt to replace filter.lfs.required or filter.lfs.clean it does try to replace the filter.lfs.smudge and filter.lfs.process.

    I think this (though I'm certainly not well-versed in the git-lfs code base) that this is because the default value of, say, filter.lfs.process (git-lfs filter-process) is listed as an 'upgradeable' value in https://github.com/git-lfs/git-lfs/blob/1a98fa5c4065e0b692c181ddc4551d21c72945e2/lfs/attribute.go#L88 which ought to mean that shouldReset in https://github.com/git-lfs/git-lfs/blob/1a98fa5c4065e0b692c181ddc4551d21c72945e2/lfs/attribute.go#L136 will return true and force the replace.

    I'm afraid that ultimately this will have to be something that's addressed in the git-lfs project as I don't see any (easy) way for us to work around this in Desktop.

    I've opened git-lfs/git-lfs#2993 to see if the git-lfs team can take a look at it and verify or shoot down my hypothesis.

  2. added
    bug
    on May 4, 2018
  3. self-assigned this
    on May 27, 2018
  4. locked as resolved and limited conversation to collaborators on Aug 21, 2018
  5. unlocked this conversation on Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions