summaryrefslogtreecommitdiffstats
path: root/modules/git/parse_nogogit.go
blob: e9e93f66fdc1128c1d83e1a5c5530fbd4745f575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

// +build !gogit

package git

import (
	"bytes"
	"fmt"
	"strconv"
	"strings"
)

// ParseTreeEntries parses the output of a `git ls-tree -l` command.
func ParseTreeEntries(data []byte) ([]*TreeEntry, error) {
	return parseTreeEntries(data, nil)
}

func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) {
	entries := make([]*TreeEntry, 0, 10)
	for pos := 0; pos < len(data); {
		// expect line to be of the form "<mode> <type> <sha> <space-padded-size>\t<filename>"
		entry := new(TreeEntry)
		entry.ptree = ptree
		if pos+6 > len(data) {
			return nil, fmt.Errorf("Invalid ls-tree output: %s", string(data))
		}
		switch string(data[pos : pos+6]) {
		case "100644":
			entry.entryMode = EntryModeBlob
			pos += 12 // skip over "100644 blob "
		case "100755":
			entry.entryMode = EntryModeExec
			pos += 12 // skip over "100755 blob "
		case "120000":
			entry.entryMode = EntryModeSymlink
			pos += 12 // skip over "120000 blob "
		case "160000":
			entry.entryMode = EntryModeCommit
			pos += 14 // skip over "160000 object "
		case "040000":
			entry.entryMode = EntryModeTree
			pos += 12 // skip over "040000 tree "
		default:
			return nil, fmt.Errorf("unknown type: %v", string(data[pos:pos+6]))
		}

		if pos+40 > len(data) {
			return nil, fmt.Errorf("Invalid ls-tree output: %s", string(data))
		}
		id, err := NewIDFromString(string(data[pos : pos+40]))
		if err != nil {
			return nil, fmt.Errorf("Invalid ls-tree output: %v", err)
		}
		entry.ID = id
		pos += 41 // skip over sha and trailing space

		end := pos + bytes.IndexByte(data[pos:], '\t')
		if end < pos {
			return nil, fmt.Errorf("Invalid ls-tree -l output: %s", string(data))
		}
		entry.size, _ = strconv.ParseInt(strings.TrimSpace(string(data[pos:end])), 10, 64)
		entry.sized = true

		pos = end + 1

		end = pos + bytes.IndexByte(data[pos:], '\n')
		if end < pos {
			return nil, fmt.Errorf("Invalid ls-tree output: %s", string(data))
		}

		// In case entry name is surrounded by double quotes(it happens only in git-shell).
		if data[pos] == '"' {
			entry.name, err = strconv.Unquote(string(data[pos:end]))
			if err != nil {
				return nil, fmt.Errorf("Invalid ls-tree output: %v", err)
			}
		} else {
			entry.name = string(data[pos:end])
		}

		pos = end + 1
		entries = append(entries, entry)
	}
	return entries, nil
}
35'>735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830
126.com
163.com
1gost.info
1stnationalbank.com
2o7.net
365online.com
4at1.com
53.com
5iantlavalamp.com
abl.com.pk
about.com
accessbankplc.com
adelphia.net
adib.ae
adobe.com
agora-inc.com
agoramedia.com
aibgb.co.uk
aib.ie
airdriesavingsbank.com
akamai.net
akamaitech.net
aldermore.co.uk
alexa.com
alliancebank.com.my
alliancefg.com
alliantcreditunion.com
alliantcreditunion.org
allianz.de
allybank.com
alterna.ca
amazon.com
americanexpress.ch
americanexpress.com
anadolubank.nl
ancestry.com
anz.com
anz.co.nz
aol.com
apache.org
apple.com
arbuthnotlatham.co.uk
arcamax.com
asb.co.nz
ask.com
astrology.com
atdmt.com
att.net
authorize.net
autorambler.ru
axisbank.co.in
axisbank.com
b2bbank.com
baaderbank.de
baidu.com
baloise.ch
baml.com
banamex.com
bancanetbsc.do
bancanetsantacruz.com.do
bancapulia.it
bancarios.com
bancastato.ch
bancatransilvania.ro
bancobase.com
bancobic.ao
bancobic.pt
bancobpi.pt
banco.bradesco
bancobrasil.com.br
bancochile.cl
bancochile.com
bancoestado.cl
bancofalabella.cl
bancofalabella.com.co
bancofalabella.pe
bancomer.com
bancopopolare.it
bancopostaclick.it
bancoposta.it
bancosantander.es
bancovotorantimcartoes.com.br
bank24.ru
bankalhabib.com
bankaustria.at
bank.barclays.co.uk
bankbgzbnpparibas.pl
bankcardservices.co.uk
bankcomm.com
bankcoop.ch
bankiabancapersonal.es
bankia.com
bankia.es
bankinter.com
bankinter.es
bankmutual.com
bankofamerica.com
bankofcanada.ca
bankofchina.com
bankofcyprus.com
bankofindia.co.nz
bankofireland.com
bank-of-ireland.co.uk
bankofirelanduk.com
bankofoklahoma.com
bankofscotland.co.uk
banksinarmas.com
bankvonroll.ch
bankwest.com.au
banque-casino.fr
banquepopulaire.fr
banquescotia.com
barclaycard.co.uk
barclaycard.de
barclaycard.es
barclays.com
barclays.co.uk
barclayspartnerfinance.com
barclays.sc
barodanzltd.co.nz
basler.ch
bbandt.com
bbc.co.uk
bcentral.com
bci.cl
bcp.com.pe
bcv.ch
bcvs.ch
bekb.ch
bellevue.ch
bellsouth.net
bendigobank.com.au
berliner-bank.de
berliner-sparkasse.de
bfanet.ao
bfi0.com
bgfi.com
bgfionline.com
bgzbnpparibas.pl
billmelater.com
bing.com
bkb.ch
bk.rw
bks.at
blkb.ch
bmocm.com
bmo.com
bmogam.com
bmoharris.com
bmoharrisprivatebankingonline.com
bmoinvestorline.com
bmonesbittburns.com
bnl.it
bnpparibas.com
bnpparibas.fr
boc.cnnz
bonuscard.ch
bpe-gruposantander.com
bpi.pt
bpostbank.be
bradescardonline.com.br
bradesco.com.br
bradescoseguranca.com.br
bridgetrack.com
bridgewaterbank.ca
bsibank.com
btrl.ro
bt-trade.ro
businessonline-boi.com
bzbank.ch
ca-cib.com
ca-egypt.com
cafbank.org
cafe24.com
cafonline.org
caisse-epargne.com
caisse-epargne.fr
caixabank.com
caixa.gov.br
cajasur.es
camsonline.com
canadiandirect.com
capitalone360.com
capitalone.com
capitaloneonline.co.uk
capitecbank.co.za
cariparma.it
carrefour-banque.fr
cartabcc.it
cartabccpos.it
cartasi.it
ca-suisse.com
catalunyacaixa.com
cbg.gm
cbonline.co.uk
cembra.ch
cenbank.org
centralbank.ae
charitybank.org
charter.net
chase.com
chebanca.it
chinatrust.com.tw
cial.ch
cibc.com
cic.ch
cimbclicks.com.my
citibank.ae
citibank.co.in
citibank.com
citibank.co.uk
citibankonline.com
citibusiness.com
citicards.com
citi.com
citi.co.nz
citi.eu
citigroup.com
citizensbank.ca
citizensbank.com
civibank.com
civibank.it
cjb.net
classmates.com
clickbank.net
closebrothers.com
closebrothers.co.uk
clubsc.ch
cnet.com
cnn.com
colpatria.com
colpatria.com.co
comcast.net
com.com
commbank.com.au
commerzbank.com
commerzbank.de
com.ne.kr
coopbank.dk
co-operativebank.co.uk
cornerbanca.ch
cornercard.ch
cornercard.com
corner.ch
corporate-ir.net
cosycard.ch
coutts.com
cox.net
craigslist.org
credit-agricole.com
credit-agricole.fr
creditagricole.rs
credit-suisse.com
cs.com
css.ch
ctbcbank.com
ctfs.com
custhelp.com
cwbank.com
cwbankgroup.com
cwt.ca
cybg.com
danskebankas.lt
danskebank.com
danskebank.co.uk
danskebank.de
danskebank.dk
danskebank.ee
danskebank.fi
danskebank.ie
danskebank.no
datatrans.biz
datatrans.ch
daum.net
db.com
dbs.com
dd.se
debian.org
dell.com
demirbank.kg
denizbank.com
desjardins.ca
desjardins.com
deutschebank.be
deutschebank.co.nz
deutsche-bank.de
diamondbank.com
dibpak.com
directnic.com
directtrack.com
discovercard.com
discover.com
discovery.co.za
dnbnord.lt
domain.com
doubleclick.com
dresdner-bank.de
dsbbank.sr
dsbl.org
duncanlawrie.com
earthlink.net
easybank.at
easylnk.com
ebay.com
ebay.co.uk
ebay.de
ebayimg.com
ebaystatic.com
ecobank.com
edgesuite.net
ediets.com
edwardjones.com
egroups.com
e-gulfbank.com
emode.com
esunbank.com.tw
example.com
example.net
example.org
excite.com
facebook.com
fedex.com
fednetbank.com
fidelity.com
fidor.de
finance.com
finansbank.com.tr
finasta.lt
fineco.it
firstbankcard.com
firstmerit.com
firstnational.com
firstnationalmerchantsolutions.com
firsttrustbank.co.uk
flickr.com
fnbc.ca
fnb.co.za
fnb-online.com
freebsd.org
free.fr
friuladria.it
f-secure.com
garantibank.eu
garantibank.nl
garanti.com.tr
gazprombank.ch
gazprombank.ru
generali.es
genevoise.ch
gentoo.org
geocities.com
gkb.ch
gmail.com
gmx.net
go.com
godaddy.com
googleadservices.com
google.co.in
google.com
google.it
google.ru
granitbank.hu
grisoft.com
gtbank.com
halifax.co.uk
hallmark.com
handelsbanken.se
harrodsbank.co.uk
hbl.com
hblibank.com
hblibank.com.pk
hdfcbank.com
heartland.co.nz
hellenicbank.com
hinet.net
hkbea.com
hlb.com.kh
hlb.com.my
hoaresbank.co.uk
home.barclays
hongleongconnect.com.kh
hongleongconnect.com.vn
hongleongconnect.my
hotbar.com
hotmail.com
hotpop.com
hp.com
hsbc.com
hsbc.com.ar
hsbc.com.hk
hsbc.co.nz
hsbc.co.uk
hypovereinsbank.co.uk
hypovereinsbank.de
ibm.com
icbcnz.com
icicibank.co.in
icicibank.com
icicibankprivatebanking.com
icorner.ch
icscards.de
icscards.nl
incredimail.com
ing.be
ing.com
ing-diba.de
ingdirect.ca
ing.lu
ing.nl
ingvysyabank.com
interac.ca
investorplace.com
iobnet.co.in
isbank.com.tr
isbank.de
isbank.ge
isbank.iq
isbankkosova.com
itau.com.br
ivillage.com
joingevalia.com
jpmchase.com
jpmorgan.com
jsafrasarasin.com
julianhodgebank.com
juliusbaer.com
juno.com
jyskebank.dk
kantonalbank.ch
kernel.org
key.com
kiwibank.co.nz
kotak.com
kredytbank.pl
kreissparkasse-schwalm-eder.de
ksklb.de
kutxabank.es
laboralkutxa.com
lacaixa.cat
lacaixa.es
laurentianbank.ca
lbb.de
lcl.com
lcl.fr
li.ru
list.ru
liveinternet.ru
livejournal.com
lloydsbank.com
lloydsbankcommercial.com
lloydsbankinggroup.com
lloydstsb.ch
lloydstsb.co.uk
lombardodier.com
loydsbank.com
lycos.com
m7z.net
mac.com
macromedia.com
maerki-baumann.ch
mail.com
mail.ru
mailscanner.info
mandtbank.com
manulifebank.ca
manulifebankselect.ca
manulife.com
manulifeone.ca
marketwatch.com
mashreqbank.com
mastercard.com
maybank2u.com
maybank2u.com.my
mcafee.com
mchsi.com
mdmbank.com
mechanicsbank.com
medbank.lt
messagelabs.com
metrobankdirect.com
metrobankonline.co.uk
microsoft.com
migbank.com
migrosbank.ch
military.com
mindspring.com
mit.edu
mizuhobank.co.jp
mmwarburg.lu
monster.com
montepio.pt
morganstanley.com
mozilla.com
mps.it
ms.com
msn.com
mufg.jp
myonlineresourcecenter.com
myonlineservices.ch
myspace.com
nate.com
nationalesuisse.ch
nationwide-communications.co.uk
nationwide.co.uk
nationwide-service.co.uk
natwest.com
navyfederal.org
nbc.ca
netflix.com
netscape.com
netscape.net
netzero.net
newyorkfed.org
nibl.com.np
nod32.com
nordea.fi
nordea.lt
nordfynsbank.dk
norisbank.de
norman.com
notenstein.ch
nuvisionfederal.com
nytimes.com
oceanbank.com
onlinesbi.com
openoffice.org
openxmlformats.org
optonline.net
orchardbank.com
osdn.com
ostsaechsische-sparkasse-dresden.de
overstock.com
pacbell.net
pandasoftware.com
passport.com
paylife.at
paypal.be
paypal-brasil.com.br
paypal.ca
paypal.ch
paypal.co.il
paypal.com
paypal.com.au
paypal.com.br
paypal-communication.com
paypal-community.com
paypal.com.mx
paypal.com.pt
paypal.co.uk
paypal-customerfeedback.com
paypal.de
paypal-deutschland.de
paypal.dk
paypal.es
paypal-exchanges.com
paypal.fr
paypal.it
paypal-marketing.co.uk
paypal-marketing.pl
paypal.net
paypal.nl
paypal.no
paypal-notify.com
paypal-now.com
paypalobjects.com
paypal-opwaarderen.nl
paypal-pages.com
paypal.pt
paypal.ru
paypal.se
paypal-search.com
paypal-shopping.co.uk
paypal-techsupport.com
pbebank.com
pcfinancial.ca
peoplepc.com
permanenttsb.ie
plaxo.com
pnc.com
popolarevicenza.it
postbank.de
postepay.it
postfinancearena.ch
postfinance.ch
postfinance.info
price.ru
prodigy.net
publicislamicbank.com.my
rabobank.com
rabobank.co.nz
rabobank.nl
radaruol.com.br
rahnbodmer.ch
raiffeisenbank.rs
raiffeisen.ch
raiffeisen.hu
raiffeisen.li
raiffeisen.ru
rambler-co.ru
rambler.ru
raphaelsbank.com
rbc.com
rbcroyalbank.com
rbs.co.uk
rbssecure.co.uk
rbsworldpay.com
rcb.at rcb.at
real.com
recordbank.be
redhat.com
rediff.com
regiobank.nl
regions.com
regionsnet.com
renasantbank.com
rhbgroup.com
rogersbank.com
rogers.com
rothschildbank.com
rothschild.com
royalbank.com
rr.com
sagepay.com
sagepay.co.uk
sainsburysbank.co.uk
samba.com
santander.cl
santander.com
santander.com.br
santander.com.mx
santandercorretora.com.br
santander.co.uk
santanderesfera.com.br
santandersantiago.cl
sarasin.ch
sbcglobal.net
sberbank.ch
sbs.net.nz
sc.com
schoellerbank.at
scotiabank.ca
scotiabank.com
scotiamocatta.com
scotiaonline.com
s.de
sec.gov
securetrustbank.com
service-sparkasse.de
serviciobancomer.com
sf.net
shawbrook.co.uk
shaw.ca
shkb.ch
shockwave.com
six-group.com
six-payment-services.com
skrill.com
sls-direkt.de
smithbarney.com
snb.ch snb.ch
snsbank.nl
societegenerale.fr
sourceforge.net
spamcop.net
sparda-a.de
sparda-bank-hamburg.de
sparda-b.de
sparda-bw.de
sparda-h.de
sparda-hessen.de
sparda-m.de
sparda-ms.de
sparda-n.de
sparda-ostbayern.de
sparda-sw.de
sparda-verband.de
sparda-west.de
sparkasse.at
sparkasse-bank-malta.com
sparkasse-bielefeld.de
sparkasseblog.de
sparkasse-bochum.de
sparkasse.ch
sparkasse.de
sparkasse-gera-greiz.de
sparkasse-hamm.de
sparkasse-heidelberg.de
sparkasse-ingolstadt.de
sparkasse-mittelthueringen.de
speedera.net
sportsline.com
standardbank.com
standardbank.co.za
standardchartered.com.gh
standardchartered.com.my
subscribe.ru
sun.com
suncorpbank.com.au
suntrust.com
swedbank.com
swedbank.ee
swedbank.lt
swedbank.lu
swedbank.se
swisscanto.ch
swisscaution.ch
swissquote.ch
sydbank.dk
sympatico.ca
tails.nl
tangerine.ca
tcb-bank.com.tw
tdbank.com
tdcommercialbanking.com
telus.net
terra.com.br
tescobank.com
ticketmaster.com
tinyurl.com
tiscali.co.uk
tns-counter.ru
tom.com
tone.co.nz
t-online.de
top4top.ru
tsbbank.co.nz
tsb.co.nz
tsb.co.uk
tux.org
twitter.com
ubibanca.com
ubs.com
ulsterbankanytimebanking.co.uk
ulsterbank.co.uk
unibancoconnect.pt
unibanco.pt
unicreditbank.lt
unicredit.eu
unicreditgroup.eu
unicredit.it
unionbankcameroon.com
unionbank.com
unity.co.uk
uob.com.sg
uobgroup.com
uol.com.br
ups.com
usbank.com
valianttrust.com
vaudoise.ch
venetobanca.it
venetobanka.al
verizon.net
versabank.com
videobank.it
virginmoney.com
visa.com.ar
visa.com.br
visaeurope.ch
visaeurope.com
viseca.ch
volksbank.de
volkswagenbank.de
vpbank.com
vr.de
vwbank.de
w3.org
wachovia.com
walmart.com
wamu.com
wanadoo.fr
washingtonpost.com
weatherbug.com
weatherbys.co.uk
web.de
webshots.com
webtv.net
wegelin.ch
wellsfargo.com
wellsfargoemail.com
westernunion.ca
westernunion.com
westernunion.fr
westernunion.se
westpac.com.au
westpac.co.nz
wir.ch
wordpress.com
worldbank.org
worldpay.com
wsj.com
wvb.de
xmlsoap.org
yacht.nl
yahoo.ca
yahoo.co.jp
yahoo.co.kr
yahoo.com
yahoo.com.br
yahoo.co.uk
yahoogroups.com
yandex.net
yandex.ru
ybonline.co.uk
yimg.com
yopi.de
yorkshirebank.co.uk
yourbankcard.com
yoursite.com
youtube.com
zagbank.ca
zdnet.com
zenithbank.com
zkb.ch
zugerkb.ch
vistaprint.dk
vistaprint.com
anpdm.com
dovecot.org
exacttarget.com
github.com
isc.org
# list-manage1.com # grey
# list-manage2.com # grey
# list-manage.com # grey
lists.isc.org
lists.roundcube.net
svn.apache.org
taggedmail.com
tumblr.com