index.c: Read index after initialization
index.c: Read index after initialization

The current behaviour of git_index_open{bare,inrepo}() is unexpected.
When an index is opened, an in-memory index object is created that is
linked to the index discovered by git_repository_open(). However, this
index object is empty, as the on-disk index is not read. To fully open
the on-disk index file, git_index_read() has to be called. This leads to
confusing behaviour. Consider the following code:

	git_index *idx;
	git_index_open_inrepo(&idx, repo);
	git_index_write(idx);

You would expect this to have no effect, as the index is never
ostensibly manipulated. However, what actually happens is that the index
entries are removed from the on-disk index because the empty in-memory
index object created by open_inrepo() is written back to the disk.

This patch reads the index after opening it.

KTXSoftware/libgit2,leoyanggit/libgit2,Corillian/libgit2,falqas/libgit2,iankronquist/libgit2,stewid/libgit2,skabel/manguse,sygool/libgit2,KTXSoftware/libgit2,dleehr/libgit2,amyvmiwei/libgit2,amyvmiwei/libgit2,swisspol/DEMO-libgit2,since2014/libgit2,swisspol/DEMO-libgit2,mcanthony/libgit2,amyvmiwei/libgit2,MrHacky/libgit2,ardumont/libgit2,MrHacky/libgit2,raybrad/libit2,zodiac/libgit2.js,sim0629/libgit2,claudelee/libgit2,t0xicCode/libgit2,nacho/libgit2,evhan/libgit2,Snazz2001/libgit2,dleehr/libgit2,nokiddin/libgit2,chiayolin/libgit2,kenprice/libgit2,swisspol/DEMO-libgit2,stewid/libgit2,mingyaaaa/libgit2,JIghtuse/libgit2,rcorre/libgit2,linquize/libgit2,oaastest/libgit2,iankronquist/libgit2,joshtriplett/libgit2,iankronquist/libgit2,jamieleecool/ptest,mingyaaaa/libgit2,skabel/manguse,chiayolin/libgit2,t0xicCode/libgit2,nokiddin/libgit2,magnus98/TEST,nokiddin/libgit2,magnus98/TEST,mhp/libgit2,swisspol/DEMO-libgit2,mcanthony/libgit2,kissthink/libgit2,mrksrm/Mingijura,ardumont/libgit2,stewid/libgit2,linquize/libgit2,nacho/libgit2,whoisj/libgit2,saurabhsuniljain/libgit2,rcorre/libgit2,yongthecoder/libgit2,jeffhostetler/public_libgit2,MrHacky/libgit2,rcorre/libgit2,yongthecoder/libgit2,sygool/libgit2,raybrad/libit2,jeffhostetler/public_libgit2,yosefhackmon/libgit2,zodiac/libgit2.js,Snazz2001/libgit2,mingyaaaa/libgit2,Snazz2001/libgit2,t0xicCode/libgit2,spraints/libgit2,oaastest/libgit2,mrksrm/Mingijura,chiayolin/libgit2,zodiac/libgit2.js,since2014/libgit2,mhp/libgit2,JIghtuse/libgit2,raybrad/libit2,mingyaaaa/libgit2,sim0629/libgit2,yosefhackmon/libgit2,claudelee/libgit2,Corillian/libgit2,chiayolin/libgit2,kissthink/libgit2,kenprice/libgit2,since2014/libgit2,mhp/libgit2,whoisj/libgit2,raybrad/libit2,spraints/libgit2,skabel/manguse,KTXSoftware/libgit2,Tousiph/Demo1,ardumont/libgit2,mrksrm/Mingijura,kenprice/libgit2,skabel/manguse,yongthecoder/libgit2,oaastest/libgit2,whoisj/libgit2,kenprice/libgit2,spraints/libgit2,rcorre/libgit2,since2014/libgit2,KTXSoftware/libgit2,spraints/libgit2,mcanthony/libgit2,Snazz2001/libgit2,evhan/libgit2,mhp/libgit2,yosefhackmon/libgit2,maxiaoqian/libgit2,joshtriplett/libgit2,t0xicCode/libgit2,maxiaoqian/libgit2,claudelee/libgit2,whoisj/libgit2,mingyaaaa/libgit2,yongthecoder/libgit2,amyvmiwei/libgit2,Aorjoa/libgit2_maked_lib,claudelee/libgit2,stewid/libgit2,saurabhsuniljain/libgit2,maxiaoqian/libgit2,maxiaoqian/libgit2,oaastest/libgit2,since2014/libgit2,oaastest/libgit2,evhan/libgit2,rcorre/libgit2,swisspol/DEMO-libgit2,Snazz2001/libgit2,jflesch/libgit2-mariadb,jeffhostetler/public_libgit2,leoyanggit/libgit2,sygool/libgit2,Corillian/libgit2,jamieleecool/ptest,Corillian/libgit2,Aorjoa/libgit2_maked_lib,iankronquist/libgit2,dleehr/libgit2,jflesch/libgit2-mariadb,falqas/libgit2,maxiaoqian/libgit2,MrHacky/libgit2,magnus98/TEST,Snazz2001/libgit2,sygool/libgit2,Aorjoa/libgit2_maked_lib,t0xicCode/libgit2,claudelee/libgit2,saurabhsuniljain/libgit2,joshtriplett/libgit2,sim0629/libgit2,magnus98/TEST,jflesch/libgit2-mariadb,ardumont/libgit2,yosefhackmon/libgit2,jflesch/libgit2-mariadb,ardumont/libgit2,skabel/manguse,magnus98/TEST,linquize/libgit2,stewid/libgit2,jeffhostetler/public_libgit2,mcanthony/libgit2,jamieleecool/ptest,evhan/libgit2,mrksrm/Mingijura,zodiac/libgit2.js,mcanthony/libgit2,linquize/libgit2,kissthink/libgit2,mrksrm/Mingijura,since2014/libgit2,jeffhostetler/public_libgit2,nokiddin/libgit2,MrHacky/libgit2,KTXSoftware/libgit2,mhp/libgit2,yongthecoder/libgit2,yosefhackmon/libgit2,falqas/libgit2,sygool/libgit2,joshtriplett/libgit2,KTXSoftware/libgit2,claudelee/libgit2,whoisj/libgit2,saurabhsuniljain/libgit2,Aorjoa/libgit2_maked_lib,skabel/manguse,ardumont/libgit2,mhp/libgit2,Tousiph/Demo1,mingyaaaa/libgit2,iankronquist/libgit2,jamieleecool/ptest,jflesch/libgit2-mariadb,t0xicCode/libgit2,JIghtuse/libgit2,magnus98/TEST,nacho/libgit2,sim0629/libgit2,nacho/libgit2,joshtriplett/libgit2,falqas/libgit2,raybrad/libit2,linquize/libgit2,jflesch/libgit2-mariadb,linquize/libgit2,yongthecoder/libgit2,kissthink/libgit2,dleehr/libgit2,MrHacky/libgit2,kenprice/libgit2,leoyanggit/libgit2,dleehr/libgit2,chiayolin/libgit2,whoisj/libgit2,Corillian/libgit2,joshtriplett/libgit2,saurabhsuniljain/libgit2,chiayolin/libgit2,leoyanggit/libgit2,Tousiph/Demo1,Aorjoa/libgit2_maked_lib,Tousiph/Demo1,oaastest/libgit2,JIghtuse/libgit2,sim0629/libgit2,mrksrm/Mingijura,sygool/libgit2,mcanthony/libgit2,sim0629/libgit2,falqas/libgit2,leoyanggit/libgit2,saurabhsuniljain/libgit2,zodiac/libgit2.js,spraints/libgit2,amyvmiwei/libgit2,amyvmiwei/libgit2,Tousiph/Demo1,maxiaoqian/libgit2,kenprice/libgit2,stewid/libgit2,falqas/libgit2,spraints/libgit2,kissthink/libgit2,leoyanggit/libgit2,Corillian/libgit2,Tousiph/Demo1,dleehr/libgit2,JIghtuse/libgit2,JIghtuse/libgit2,yosefhackmon/libgit2,swisspol/DEMO-libgit2,kissthink/libgit2,nokiddin/libgit2,rcorre/libgit2,iankronquist/libgit2,nokiddin/libgit2,jeffhostetler/public_libgit2