git-apply working on an index with smudged entries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I see that when I call "git apply --3way ..." on an index which was
previously created
by JGit and which contains smudged entries the command fails with
message "error: foo.txt:
does not match index". If I do a "git status" afterwards and then the
same "git apply --3way ..." it
succeeds. Looks like "git status" corrected the index in a way so "git
apply" can accept it.

Question:
- is this because the index which jgit created is so corrupt that only
special commands
like "git status" can repair it?
- or is "git apply" not trying hard enough to consume a index with
smudged entries

Here is the trace of a script from Thomas which shows the effect:

> git --version
git version 2.19.1
> jgit --version
jgit version 5.2.0-SNAPSHOT
> git init
Initialized empty Git repository in /Users/d032780/tmp/a/.git/
> echo "foo" > foo.txt
> git add foo.txt
> git commit -m "Initial commit"
[master (root-commit) ff6c56c] Initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 foo.txt
> echo "bar" >> foo.txt
> git add foo.txt
> git commit -m "Second commit"
[master 2191919] Second commit
 1 file changed, 1 insertion(+)
> echo "baz" >> foo.txt
> git add foo.txt
> git commit -m "Third commit"
[master d863c4a] Third commit
 1 file changed, 1 insertion(+)
> git diff HEAD^1..HEAD foo.txt > ../foo.patch
> jgit reset --hard HEAD~
> git apply --3way ../foo.patch
error: foo.txt: does not match index
> git ls-files -sv --debug
H 100644 3bd1f0e29744a1f32b08d5650e62e2e62afb177c 0 foo.txt
  ctime: 0:0
  mtime: 1544782273:0
  dev: 0 ino: 0
  uid: 0 gid: 0
  size: 0 flags: 0
> git status
On branch master
Untracked files:
...
> git ls-files -sv --debug
H 100644 3bd1f0e29744a1f32b08d5650e62e2e62afb177c 0 foo.txt
  ctime: 1544782273:797529188
  mtime: 1544782273:796936707
  dev: 16777220 ino: 64184423
  uid: 503 gid: 20
  size: 8 flags: 0
> git apply --3way ../foo.patch
> cat foo.txt
foo
bar
baz
>



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux