Optimize .dockerignore when there are exclusions
Optimize .dockerignore when there are exclusions

Closes #20470

Before this PR we used to scan the entire build context when there were
exclusions in the .dockerignore file (paths that started with !). Now we
only traverse into subdirs when one of the exclusions starts with that dir
path.

Signed-off-by: Doug Davis <ff3bde741799c0eff815b83a54eda3fc494df54f@us.ibm.com>

PatrickLang/moby,denverdino/denverdino.github.io,menglingwei/denverdino.github.io,cnaize/docker,sanjeo/docker,hustcat/docker,denverdino/docker.github.io,moby/moby,dnephin/docker,nawawi/docker,gigidwan/docker,charleszheng44/moby,bluebreezecf/docker,dims/docker,msabansal/docker,rkazak/docker,docker/docker,yasiramin10p/moby,joaofnfernandes/docker.github.io,pyotr777/docker,OnePaaS/docker,liaoqingwei/docker,lixiaobing10051267/docker,HackToday/docker,madhanrm/docker,shubheksha/docker.github.io,mstanleyjones/docker,HideoYamauchi/docker,amatsus/docker,nguyentm83/docker,alfred-landrum/docker,michelvocks/docker,zhuguihua/docker,maxamillion/docker,estesp/docker,justyntemme/docker,diogomonica/docker,HuKeping/docker,johnstep/moby-moby,bonczj/moby-json-file-logger,bearstech/moby,solganik/docker,johnstep/docker.github.io,darrenstahlmsft/docker,londoncalling/docker.github.io,danyalKhaliq10p/moby,estesp/docker,Mashimiao/docker,gdevillele/docker.github.io,afein/docker,joeuo/docker.github.io,rremer/moby,mahak/docker,bonczj/moby-json-file-logger,haveatry/docker,cyphar/docker,dmcgowan/docker,mathewkoshy493/docker,bdwill/docker.github.io,haveatry/docker,mstanleyjones/docker,sheimi/docker,geekylucas/docker,darrenstahlmsft/moby,ZJU-SEL/docker,gdevillele/docker.github.io,rancher/docker,docker/docker.github.io,crosbymichael/docker,erikh/docker,gjaskiewicz/moby,pecameron/docker,ndeloof/docker,willmtemple/docker,jhorwit2/docker,YuPengZTE/docker,stainboy/docker,mtesselH/docker,ndeloof/docker,allencloud/docker,rremer/moby,laijs/docker,yongtang/docker,Morsicus/docker,coreos/docker,mtesselH/docker,jongiddy/docker,thaJeztah/docker,shubheksha/docker.github.io,yp-engineering/docker,portworx/docker,rillig/docker.github.io,xuxinkun/docker,sdurrheimer/docker,alexisbellido/docker.github.io,Mokolea/docker,eskaaren/docker,solganik/docker,sfsmithcha/docker,alfred-landrum/docker,ivansaracino/docker,anujbahuguna/docker,ailispaw/docker,tophj-ibm/moby,vdemeester/docker,hypriot/docker,icaoweiwei/docker,unclejack/docker,jameszhan/docker,fcrisciani/docker,docker/docker.github.io,sanscontext/docker.github.io,docker-zh/docker.github.io,tonistiigi/docker,anortef/docker,13W/docker,charleszheng44/moby,flavio/docker,tagomoris/docker,BSWANG/denverdino.github.io,ajaymdesai/docker,inatatsu/docker,tpounds/docker,crosbymichael/docker,shishir-a412ed/docker,tklauser/docker,rancher/docker,isubuz/docker,madhanrm/docker,wenchma/docker,michael-holzheu/docker,phiroict/docker,brahmaroutu/docker,xuxinkun/docker,rhatdan/storage,darrenstahlmsft/moby,OnePaaS/docker,bonczj/moby-json-file-logger,mtanlee/docker,thtanaka/docker,tklauser/docker,scollier/docker,endophage/docker,Altiscale/docker,cpuguy83/docker,sterchelen/docker,HideoYamauchi/docker,TrumanLing/docker,yongtang/docker,splunk/docker,denverdino/docker.github.io,jzwlqx/denverdino.github.io,amatsus/docker,dsau/docker,whuwxl/docker,troy0820/docker.github.io,ColinHebert/docker,mkumatag/docker,splunk/docker,duglin/docker,maxamillion/docker,wenchma/docker,SvenDowideit/docker,pramodhkp/moby,medallia/docker,OnePaaS/docker,naveed-jamil-tenpearls/moby,asbjornenge/docker,vdemeester/docker,bdwill/docker.github.io,docker-zh/docker.github.io,johnstep/moby-moby,pramodhkp/moby,13W/docker,ivansaracino/docker,shhsu/docker,yasiramin10p/moby,srust/docker,umerazad/docker,konstruktoid/docker-upstream,docker-zh/docker.github.io,gjaskiewicz/moby,laijs/docker,gdevillele/docker.github.io,nalind/docker,pramodhkp/moby,scotttlin/docker,hustcat/docker,mstanleyjones/docker,mtanlee/docker,troy0820/docker.github.io,TheBigBear/docker,ibuildthecloud/docker,londoncalling/docker.github.io,pradipd/moby,projectatomic/docker,docker/docker.github.io,xuxinkun/docker,lixiaobing1/docker,sheimi/docker,trebonian/docker,bluebreezecf/docker,ivansaracino/docker,jwhonce/docker,13W/docker,portworx/docker,BSWANG/denverdino.github.io,miminar/docker,sarnautov/moby,shin-/docker.github.io,aduermael/docker.github.io,troy0820/docker.github.io,justincormack/docker,geekylucas/docker,AkihiroSuda/docker,mike1729/docker,yosifkit/docker,danix800/docker.github.io,sarnautov/moby,mgoelzer/docker,mikedougherty/docker,contiv/docker,docker/docker,shin-/docker.github.io,nghiant2710/docker,prertik/docker,laijs/docker,johnstep/docker.github.io,nghiant2710/docker,jlebon/docker,lixiaobing1/docker,sean-jc/docker,13W/docker,trebonian/docker,BenHall/docker,joeuo/docker.github.io,cyli/docker,kojiromike/docker,BSWANG/denverdino.github.io,djs55/docker,tmp6154/docker,erikstmartin/docker,Mokolea/docker,erikstmartin/docker,qudongfang/docker,nawawi/docker,diogomonica/docker,afein/docker,bfirsh/docker,shin-/docker.github.io,errordeveloper/docker,vdemeester/docker,menglingwei/denverdino.github.io,Syntaxide/docker,ibuildthecloud/docker,jzwlqx/denverdino.github.io,tianon/docker,resin-io/docker,michelvocks/docker,unclejack/docker,denverdino/denverdino.github.io,charleswhchan/docker,troy0820/docker.github.io,nalind/docker,mixja/docker,tpounds/docker,LaynePeng/docker,hqhq/moby,sanscontext/docker.github.io,Tenk42/docker,asbjornenge/docker,bdwill/docker.github.io,ibuildthecloud/docker,runcom/docker,harche/docker,moby/moby,thaJeztah/docker.github.io,sanscontext/docker.github.io,jvanz/docker,phiroict/docker,JMesser81/docker,nawawi/docker,bfirsh/docker,msabansal/docker,paralin/docker,cr7pt0gr4ph7/docker,cnaize/docker,dperny/docker,ajaymdesai/docker,Altiscale/docker,pecameron/docker,thaJeztah/docker.github.io,dgageot/docker,jwhonce/docker,ripcurld0/moby,containers/storage,medallia/docker,mohmost12/docker,kunalkushwaha/docker,phiroict/docker,KarthikNayak/docker,denverdino/docker.github.io,x1022as/docker,geekylucas/docker,jameszhan/docker,mtrmac/docker,ibuildthecloud/docker,diogomonica/docker,tonistiigi/docker,14rcole/docker,jimjag/docker,kunalkushwaha/docker,sunyuan3/docker,ndeloof/docker,flavio/docker,danix800/docker.github.io,mixja/docker,dims/docker,catinthesky/docker,zhuguihua/docker,naveed-jamil-tenpearls/moby,raja-sami-10p/moby,jecarey/docker,Ramzec/docker,brahmaroutu/docker,cpuguy83/docker,anweiss/docker.github.io,kencochrane/docker,stainboy/docker,jlebon/docker,dims/docker,johnstep/moby-moby,tophj-ibm/moby,whuwxl/docker,johnstep/docker.github.io,fcrisciani/docker,cyphar/docker,AkihiroSuda/docker,inatatsu/docker,mikebrow/docker,sunyuan3/docker,tpounds/docker,rremer/moby,fcrisciani/docker,kojiromike/docker,runcom/docker,dnephin/docker,catinthesky/docker,Ramzec/docker,sfsmithcha/docker,akira-baruah/docker,achanda/docker,Tenk42/docker,cloudflare/docker,denverdino/denverdino.github.io,mikedougherty/docker,menglingwei/denverdino.github.io,zhuguihua/docker,aduermael/docker.github.io,q384566678/docker,erikh/docker,toli/docker,docker/docker.github.io,mkumatag/docker,konstruktoid/docker-1,dmcgowan/docker,jthelin/docker,JimGalasyn/docker.github.io,Microsoft/docker,sarnautov/moby,coreos/docker,xiaods/docker,runcom/docker,LuisBosquez/docker.github.io,mixja/docker,rkazak/docker,nalind/docker,joaofnfernandes/docker.github.io,konstruktoid/docker-1,nghiant2710/docker,londoncalling/docker.github.io,jecarey/docker,londoncalling/docker.github.io,alexisbellido/docker.github.io,jwhonce/docker,DoraALin/docker,ZJU-SEL/docker,gschaetz/moby,rhatdan/storage,AkihiroSuda/docker,jhorwit2/docker,jimjag/docker,TheBigBear/docker,miminar/docker,rhatdan/docker,jameszhan/docker,yummypeng/docker,YuPengZTE/docker,darrenstahlmsft/docker,dongjoon-hyun/docker,dongjoon-hyun/docker,dmcgowan/docker,mathewkoshy493/docker,wenchma/docker,charleswhchan/docker,shin-/docker.github.io,abhinavdahiya/docker,kerneltime/docker,tophj-ibm/docker,nalind/docker,nguyentm83/docker,dperny/docker,coreos/docker,qudongfang/docker,kolyshkin/docker,paralin/docker,LuisBosquez/docker.github.io,menglingwei/denverdino.github.io,gdevillele/docker.github.io,erikstmartin/docker,raja-sami-10p/moby,Shopify/docker,cpuguy83/docker,moby/moby,sterchelen/docker,kerneltime/docker,nawawi/docker,haveatry/docker,LaynePeng/docker,sunyuan3/docker,BenHall/docker,cr7pt0gr4ph7/docker,ripcurld0/moby,sean-jc/docker,cnaize/docker,Morsicus/docker,mathewkoshy493/docker,lixiaobing1/docker,stevvooe/docker,joaofnfernandes/docker.github.io,naveed-jamil-tenpearls/moby,achanda/docker,whuwxl/docker,gnailuy/docker,hustcat/docker,tklauser/docker,prertik/docker,tkopczynski/docker,KingEmet/docker,mikebrow/docker,SvenDowideit/docker,justyntemme/docker,toli/docker,alexisbellido/docker.github.io,brahmaroutu/docker,jlebon/docker,jzwlqx/denverdino.github.io,denverdino/docker.github.io,liaoqingwei/docker,bluebreezecf/docker,shubheksha/docker.github.io,imkin/moby,jthelin/docker,allencloud/docker,JMesser81/docker,anweiss/docker.github.io,YuPengZTE/docker,konstruktoid/docker-upstream,danyalKhaliq10p/moby,Morsicus/docker,rancher/docker,contiv/docker,alexisbellido/docker.github.io,mohmost12/docker,Ramzec/docker,shishir-a412ed/docker,stevvooe/docker,rkazak/docker,ibuildthecloud/docker,HideoYamauchi/docker,madhanrm/docker,mohmost12/docker,crosbymichael/docker,kolyshkin/moby,docker/docker.github.io,shin-/docker.github.io,x1022as/docker,twaugh/docker,cyli/docker,isubuz/docker,pradipd/moby,toli/docker,projectatomic/docker,thaJeztah/docker,shishir-a412ed/docker,POLJM242/docker,xiekeyang/docker,sheimi/docker,Mokolea/docker,phiroict/docker,dsheets/moby,eskaaren/docker,ColinHebert/docker,TrumanLing/docker,bfirsh/docker,xiekeyang/docker,coolljt0725/docker,scotttlin/docker,TrumanLing/docker,Shopify/docker,JimGalasyn/docker.github.io,moul/docker,dsau/docker,HuKeping/docker,JimGalasyn/docker.github.io,ailispaw/docker,sanscontext/docker.github.io,denverdino/denverdino.github.io,bearstech/moby,kencochrane/docker,danix800/docker.github.io,dccurtis/docker,noxiouz/docker,unclejack/docker,SvenDowideit/docker,gigidwan/docker,Syntaxide/docker,michael-holzheu/docker,laijs/moby,harche/docker,dperny/docker,joaofnfernandes/docker.github.io,willmtemple/docker,achanda/docker,xiekeyang/docker,ffoysal/docker,cr7pt0gr4ph7/docker,danix800/docker.github.io,YujiOshima/docker,Altiscale/docker,konstruktoid/docker-1,BSWANG/denverdino.github.io,jlhawn/docker,rhatdan/docker,mgoelzer/docker,flavio/docker,dgageot/docker,johnstep/docker.github.io,rillig/docker.github.io,anweiss/docker.github.io,jzwlqx/denverdino.github.io,medallia/docker,tmp6154/docker,bearstech/moby,thtanaka/docker,denverdino/docker.github.io,pradipd/moby,flavio/docker,sfsmithcha/docker,duglin/docker,Ramzec/docker,jvanz/docker,LuisBosquez/docker.github.io,docker-zh/docker.github.io,thtanaka/docker,moul/docker,raja-sami-10p/moby,coolljt0725/docker,erikh/docker,duglin/docker,sanjeo/docker,resin-io/docker,eskaaren/docker,justincormack/docker,jhorwit2/docker,noironetworks/docker,kolyshkin/docker,konstruktoid/docker-upstream,PatrickLang/moby,harche/docker,trebonian/docker,moypray/docker,hqhq/moby,mike1729/docker,qudongfang/docker,darrenstahlmsft/moby,thaJeztah/docker.github.io,Syntaxide/docker,Mashimiao/docker,joeuo/docker.github.io,contiv/docker,HuKeping/docker,maxamillion/docker,Microsoft/docker,LuisBosquez/docker.github.io,justyntemme/docker,hypriot/docker,michael-holzheu/docker,TheBigBear/docker,errordeveloper/docker,thaJeztah/docker.github.io,joaofnfernandes/docker.github.io,dsau/docker,HackToday/docker,dsheets/moby,kerneltime/docker,trebonian/docker,shubheksha/docker.github.io,AkihiroSuda/docker,dccurtis/docker,charleszheng44/moby,jongiddy/docker,gnailuy/docker,moul/docker,twaugh/docker,estesp/docker,rhardih/docker,anweiss/docker.github.io,jzwlqx/denverdino.github.io,denverdino/denverdino.github.io,moxiegirl/docker,mike1729/docker,bdwill/docker.github.io,djs55/docker,abhinavdahiya/docker,mtanlee/docker,rillig/docker.github.io,DoraALin/docker,LuisBosquez/docker.github.io,abhinavdahiya/docker,sdurrheimer/docker,laijs/moby,JimGalasyn/docker.github.io,mtrmac/docker,ailispaw/docker,rhatdan/storage,akira-baruah/docker,isubuz/docker,shhsu/docker,imkin/moby,mikedougherty/docker,anortef/docker,pyotr777/docker,thaJeztah/docker,Microsoft/docker,londoncalling/docker.github.io,medallia/docker,yosifkit/docker,paralin/docker,tonistiigi/docker,mikebrow/docker,endophage/docker,14rcole/docker,KingEmet/docker,joeuo/docker.github.io,tagomoris/docker,konstruktoid/docker-upstream,sean-jc/docker,anujbahuguna/docker,ajaymdesai/docker,docker/docker,docker-zh/docker.github.io,allencloud/docker,tagomoris/docker,endophage/docker,danyalKhaliq10p/moby,justincormack/docker,noxiouz/docker,pyotr777/docker,cyphar/docker,tmp6154/docker,Shopify/docker,imkin/moby,icaoweiwei/docker,solganik/docker,stainboy/docker,scollier/docker,JimGalasyn/docker.github.io,thaJeztah/docker,rhardih/docker,moul/docker,errordeveloper/docker,moby/moby,rhatdan/docker,KarthikNayak/docker,resin-io/docker,ColinHebert/docker,containers/storage,johnstep/docker.github.io,umerazad/docker,srust/docker,bdwill/docker.github.io,splunk/docker,yp-engineering/docker,q384566678/docker,scotttlin/docker,jlhawn/docker,alexisbellido/docker.github.io,BenHall/docker,JMesser81/docker,yasiramin10p/moby,ffoysal/docker,cloudflare/docker,noironetworks/docker,moxiegirl/docker,twaugh/docker,darrenstahlmsft/docker,kolyshkin/moby,aduermael/docker.github.io,mtesselH/docker,YujiOshima/docker,BSWANG/denverdino.github.io,miminar/docker,HackToday/docker,inatatsu/docker,srust/docker,gschaetz/moby,gnailuy/docker,alfred-landrum/docker,gjaskiewicz/moby,noxiouz/docker,lixiaobing10051267/docker,gnailuy/docker,mgoelzer/docker,ripcurld0/moby,gdevillele/docker.github.io,amatsus/docker,portworx/docker,kunalkushwaha/docker,YujiOshima/docker,dgageot/docker,tophj-ibm/docker,ffoysal/docker,thaJeztah/docker.github.io,Tenk42/docker,projectatomic/docker,michelvocks/docker,mahak/docker,dccurtis/docker,moxiegirl/docker,KingEmet/docker,DoraALin/docker,liaoqingwei/docker,asbjornenge/docker,anortef/docker,joeuo/docker.github.io,xiaods/docker,jlhawn/docker,yummypeng/docker,umerazad/docker,yummypeng/docker,q384566678/docker,icaoweiwei/docker,xiaods/docker,mkumatag/docker,tkopczynski/docker,moypray/docker,mahak/docker,x1022as/docker,djs55/docker,shubheksha/docker.github.io,anujbahuguna/docker,jvanz/docker,anweiss/docker.github.io,aduermael/docker.github.io,yosifkit/docker,dongjoon-hyun/docker,tophj-ibm/docker,PatrickLang/moby,dsheets/moby,kencochrane/docker,cpuguy83/docker,containers/storage,jongiddy/docker,yosifkit/docker,paralin/docker,coolljt0725/docker,phiroict/docker,Mokolea/docker,sterchelen/docker,cloudflare/docker,noironetworks/docker,charleswhchan/docker,sanscontext/docker.github.io,mtrmac/docker,gigidwan/docker,afein/docker,POLJM242/docker,yongtang/docker,sdurrheimer/docker,shhsu/docker,laijs/moby,kojiromike/docker,catinthesky/docker,kolyshkin/moby,pecameron/docker,prertik/docker,Mashimiao/docker,hqhq/moby,jimjag/docker,mahak/docker,tkopczynski/docker,gschaetz/moby,tophj-ibm/moby,sanjeo/docker,KarthikNayak/docker,yp-engineering/docker,jimjag/docker,menglingwei/denverdino.github.io,moypray/docker,hypriot/docker,willmtemple/docker,dnephin/docker,msabansal/docker,LaynePeng/docker,cyli/docker,13W/docker,rillig/docker.github.io,stevvooe/docker,lixiaobing10051267/docker,bearstech/moby,tianon/docker