update-index --index-info producing spurious submodule commits
From: Greg Troxel <hidden>
Date: 2016-06-15 22:51:50
Subsystem:
the rest · Maintainer:
Linus Torvalds
For reasons too complicated to go into, I have a repository B which has
essentially been cloned from A, and there has been vast amounts of work
on B (thousands of commits, many branches). These changes have not
been merged back to A. I want to merge them back, but there's a
directory foo that has changes in B that I can't release.
So, I ran filter-branch with an index filter
found the merge base with A
removed foo
did ls-tree on foo from merge base
and updated the index
The theory is to make each commit in B look like no changes to anything
under foo, and otherwise the same.
After doing this, Richard noticed that the root tree of commits had a
foo object, but that it was labeled a commit instead of a tree (but in
fact it is a tree). He noticed because diffs looked like submodules.
I was able to produce a minimal test case, output below, script
attached. The below output is with 1.7.5.4 on NetBSD/i386 (and /amd64).
1.7.6 (ubuntu/amd64) has the same problem.
So:
Am I using "git update-index --index-info" wrong?
Or is there a bug?
Thanks,
Greg
Notice that "cat-file -p HEAD:" shows a tree before, and a commit
afterwards:
+ git init
Initialized empty Git repository in /usr/home/gdt/GIT_TEST/.git/
+ mkdir foo
+ touch foo/bar
+ git add foo
+ git commit -minitial content
[master (root-commit) 6755919] initial content
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 foo/bar
+ git cat-file -p HEAD
tree 72d67e6de0599f72f1265c925316f91f78395787
author Greg Troxel [off-list ref] 1313703545 -0400
committer Greg Troxel [off-list ref] 1313703545 -0400
initial content
+ git cat-file -p HEAD:
040000 tree d87cbcba0e2ede0752bdafc5938da35546803ba5 foo
+ git rm -r foo
rm 'foo/bar'
+ git ls-tree HEAD foo
040000 tree d87cbcba0e2ede0752bdafc5938da35546803ba5 foo
+ git ls-tree HEAD foo
+ git update-index --index-info
+ git diff --stageddiff --git a/foo b/foo
new file mode 160000
index 0000000..d87cbcb
--- /dev/null
+++ b/foo@@ -0,0 +1 @@ +Subproject commit d87cbcba0e2ede0752bdafc5938da35546803ba5
diff --git a/foo/bar b/foo/bar
deleted file mode 100644
index e69de29..0000000
+ git commit -mmunged foo[master 3348447] munged foo 1 files changed, 1 insertions(+), 0 deletions(-) create mode 160000 foo delete mode 100644 foo/bar + git cat-file -p HEAD tree 04fbd499dbd01afb3241d7f0af8171fde008bfe3 parent 6755919e289665ec46d270672d29b594f992fa03 author Greg Troxel [off-list ref] 1313703545 -0400 committer Greg Troxel [off-list ref] 1313703545 -0400 munged foo + git cat-file -p HEAD: 160000 commit d87cbcba0e2ede0752bdafc5938da35546803ba5 foo
Attachments
- (unnamed) [application/pgp-signature] 194 bytes