Skip to content

git lfs pull -I <argument> on already pulled files causes file to show as modified #2639

Closed

Description

@carlg1

After cloning the repo with git lfs configured to pull. I then pull again via 'git lfs -I' which results in the files being marked by git as modified.

I setup this repo on GitHub the can be used to recreate this issue.
[email protected]:carlg1/gitlfsbug1.git

carlg@carlg:~/Source/Debug/carlsgithub$ git version
git version 2.14.1

carlg@carlg:~/Source/Debug/carlsgithub$ git lfs version
git-lfs/2.3.1 (GitHub; linux amd64; go 1.8.1)

carlg@carlg:~/Source/Debug/carlsgithub$ git lfs env
git-lfs/2.3.1 (GitHub; linux amd64; go 1.8.1)
git version 2.14.1

LocalWorkingDir=
LocalGitDir=
LocalGitStorageDir=
LocalMediaDir=
LocalReferenceDir=
TempDir=/tmp/git-lfs
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

carlg@carlg:~/Source/Debug/carlsgithub$ git clone [email protected]:carlg1/gitlfsbug1.git gitlfsbug1_2
Cloning into 'gitlfsbug1_2'...
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 8 (delta 0), reused 8 (delta 0), pack-reused 0
Receiving objects: 100% (8/8), done.
Downloading dir1/yum-3.4.3.tar.gz (1.1 MB)
Downloading jars/qc.jar (10 KB)
Downloading jars/qc_json.jar (24 KB)
carlg@carlg:~/Source/Debug/carlsgithub$ 

carlg@carlg:~/Source/Debug/carlsgithub$ cd gitlfsbug1_2
carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2(master)$ cd jars/
carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ file qc.jar 
qc.jar: Java archive data (JAR)

carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ git st
carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ GIT_TRACE=1 GIT_CURL_VERBOSE=1 LFS_DEBUG_HTTP=1 DEBUG=1 git lfs pull -I'*.jar'
10:02:50.360735 git.c:560               trace: exec: 'git-lfs' 'pull' '-I*.jar'
10:02:50.360803 run-command.c:626       trace: run_command: 'git-lfs' 'pull' '-I*.jar'
trace git-lfs: run_command: 'git' version
trace git-lfs: run_command: 'git' config -l
trace git-lfs: run_command: 'git' -c filter.lfs.smudge= -c filter.lfs.clean= -c filter.lfs.process= -c filter.lfs.required=false rev-parse HEAD --symbolic-full-name HEAD
trace git-lfs: run_command: 'git' config branch.master.remote
trace git-lfs: run_command: 'git' -c filter.lfs.smudge= -c filter.lfs.clean= -c filter.lfs.process= -c filter.lfs.required=false rev-parse HEAD --symbolic-full-name HEAD
trace git-lfs: tq: running as batched queue, batch size of 100
trace git-lfs: run_command: git cat-file --batch
trace git-lfs: tq: sending batch of size 0

carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ git st
MM qc.jar
MM qc_json.jar

carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ git lfs fsck
Git LFS fsck OK
carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ git lfs ls-files
0178f97820 - dir1/yum-3.4.3.tar.gz
065040aae8 - jars/qc.jar
4da1bcae7e - jars/qc_json.jar

carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ file qc.jar 
qc.jar: Java archive data (JAR)

carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ git diff
diff --git a/jars/qc.jar b/jars/qc.jar
index 3ab609d..e62b364 100644
Binary files a/jars/qc.jar and b/jars/qc.jar differ
diff --git a/jars/qc_json.jar b/jars/qc_json.jar
index 7180586..b7c1610 100644
Binary files a/jars/qc_json.jar and b/jars/qc_json.jar differ

carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ git diff --staged
diff --git a/jars/qc.jar b/jars/qc.jar
index e62b364..3ab609d 100644
Binary files a/jars/qc.jar and b/jars/qc.jar differ
diff --git a/jars/qc_json.jar b/jars/qc_json.jar
index b7c1610..7180586 100644
Binary files a/jars/qc_json.jar and b/jars/qc_json.jar differ

Activity

  1. changed the title [-]git lfs pull -I <argument> on already pulled files causes file to show as modified twice[/-] [+]git lfs pull -I <argument> on already pulled files causes file to show as modified[/+] on Oct 3, 2017
  2. technoweenie commented on Oct 3, 2017

    @technoweenie
    Contributor

    I can't replicate it:

    ~g $ g clone [email protected]:carlg1/gitlfsbug1.git
    Cloning into 'gitlfsbug1'...
    remote: Counting objects: 8, done.
    remote: Compressing objects: 100% (7/7), done.
    remote: Total 8 (delta 0), reused 8 (delta 0), pack-reused 0
    Receiving objects: 100% (8/8), done.
    Downloading dir1/yum-3.4.3.tar.gz (1.1 MB)
    Downloading jars/qc.jar (10 KB)
    Downloading jars/qc_json.jar (24 KB)
    
    ~g $ cd gitlfsbug1
    ~g/gitlfsbug1 git:(master) ✗$ file jars/qc.jar
    jars/qc.jar: Java archive data (JAR)
    
    ~g/gitlfsbug1 git:(master) ✗$ gs
    ## master...origin/master
    
    ~g/gitlfsbug1 git:(master) ✗$  git lfs pull -I'*.jar'
    ~g/gitlfsbug1 git:(master) ✗$ gs
    ## master...origin/master
    ~g/gitlfsbug1 git:(master) ✗$ GIT_TRACE=1 GIT_CURL_VERBOSE=1 LFS_DEBUG_HTTP=1 DEBUG=1 git lfs pull -I'*.jar'
    10:08:07.697685 git.c:560               trace: exec: 'git-lfs' 'pull' '-I*.jar'
    10:08:07.698118 run-command.c:626       trace: run_command: 'git-lfs' 'pull' '-I*.jar'
    trace git-lfs: run_command: 'git' version
    trace git-lfs: run_command: 'git' config -l
    trace git-lfs: run_command: 'git' -c filter.lfs.smudge= -c filter.lfs.clean= -c filter.lfs.process= -c filter.lfs.required=false rev-parse HEAD --symbolic-full-name HEAD
    trace git-lfs: run_command: 'git' config branch.master.remote
    trace git-lfs: run_command: 'git' -c filter.lfs.smudge= -c filter.lfs.clean= -c filter.lfs.process= -c filter.lfs.required=false rev-parse HEAD --symbolic-full-name HEAD
    trace git-lfs: tq: running as batched queue, batch size of 100
    trace git-lfs: run_command: git cat-file --batch
    trace git-lfs: tq: sending batch of size 0
    
    ~g/gitlfsbug1 git:(master) ✗$ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    nothing to commit, working tree clean
    ~g/gitlfsbug1 git:(master) ✗$ git lfs status
    On branch master
    Git LFS objects to be pushed to origin/master:
    
    
    Git LFS objects to be committed:
    
    
    Git LFS objects not staged for commit:
    
    

    What does git lfs status show?

  3. carlg1 commented on Oct 3, 2017

    @carlg1
    Author
    carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ git lfs status
    On branch master
    Git LFS objects to be pushed to origin/master:
    
    
    Git LFS objects to be committed:
    
    
    Git LFS objects not staged for commit:
    
    
    carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ GIT_TRACE=1 GIT_CURL_VERBOSE=1 LFS_DEBUG_HTTP=1 DEBUG=1 git lfs pull -I'*.jar'
    10:11:08.692698 git.c:560               trace: exec: 'git-lfs' 'pull' '-I*.jar'
    10:11:08.692764 run-command.c:626       trace: run_command: 'git-lfs' 'pull' '-I*.jar'
    trace git-lfs: run_command: 'git' version
    trace git-lfs: run_command: 'git' config -l
    trace git-lfs: run_command: 'git' -c filter.lfs.smudge= -c filter.lfs.clean= -c filter.lfs.process= -c filter.lfs.required=false rev-parse HEAD --symbolic-full-name HEAD
    trace git-lfs: run_command: 'git' config branch.master.remote
    trace git-lfs: run_command: 'git' -c filter.lfs.smudge= -c filter.lfs.clean= -c filter.lfs.process= -c filter.lfs.required=false rev-parse HEAD --symbolic-full-name HEAD
    trace git-lfs: tq: running as batched queue, batch size of 100
    trace git-lfs: run_command: git cat-file --batch
    trace git-lfs: tq: sending batch of size 0
    carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ git lfs statusOn branch master
    Git LFS objects to be pushed to origin/master:
    
    
    Git LFS objects to be committed:
    
    	jars/qc.jar (LFS: 065040a -> Git: 065040a)
    	jars/qc_json.jar (LFS: 4da1bca -> Git: 4da1bca)
    
    Git LFS objects not staged for commit:
    
    open jars/qc.jar: no such file or directory
    carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ 
    
    
  4. carlg1 commented on Oct 3, 2017

    @carlg1
    Author

    carlg@carlg:~/Source/Debug/carlsgithub/gitlfsbug1_2/jars(master)$ cat /etc/issue
    Ubuntu 16.04.3 LTS \n \l

  5. carlg1 commented on Oct 3, 2017

    @carlg1
    Author

    I missed a step
    After the clone cd into 'jars' dir

  6. technoweenie commented on Oct 3, 2017

    @technoweenie
    Contributor

    Ah, that's the key then. It seems to work fine when run from the root. The git lfs status output is a little weird, it shows it changing from an LFS file to a Git file, with the same hash. I think it's an issue with the git index, since the file contents aren't actually changing.

    $ g ls-tree master -rl
    100644 blob e62b364939590e3146b853a83b4d7c8da3ddebe7     130	qc.jar
    100644 blob b7c1610cf26efa4628a51c8cf67e74201d8a5dc4     130	qc_json.jar
    

    The diff shows it changing to e62b364:

    $ git diff
    diff --git a/jars/qc.jar b/jars/qc.jar
    index 3ab609d..e62b364 100644
    Binary files a/jars/qc.jar and b/jars/qc.jar differ
    

    I think what's happening is that the file contents are being added to the git index, and then the LFS pointer is re-added. That's why git status shows the files twice:

    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
    	modified:   qc.jar
    	modified:   qc_json.jar
    
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
    	modified:   qc.jar
    	modified:   qc_json.jar
    

    It's definitely a bug. For now, just run that command from the root of the repository.

  7. carlg1 commented on Oct 3, 2017

    @carlg1
    Author

    Okay, thanks for the update.

  8. technoweenie commented on Oct 3, 2017

    @technoweenie
    Contributor

    Found the root cause. Good news is this will make the cut for v2.3.2 :) Thanks for the report!

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