Re: A system administration use case for git
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Apr 23, 2009, 10:38 UTC
- Message-ID
- <49F04511.3070601@viscovery.net>
- In-Reply-To
- <20090423095533.GE13989@pengutronix.de>
Uwe Kleine-König schrieb:
Show 5 quoted lines
> There is a practical problem though: The filelist has to be sorted in a
> way that is not provided by ls, so:
>
> ukleinek@cepheus:~/gsrc/linux-2.6/usr$ for f in $(ls -A); do printf "100644 %s\x00" $f; git hash-object $f | perl -n -e 'chomp; for $c (split(/(.{2})/)) { printf("%c", hex($c)) if $c }'; done | git hash-object -t tree -w --stdin
> a0a6efb3f1de956badc7607c7d372cc325a18846Does ... $(LANG=C ls -A) ... make a difference for you?
But note that this is still not the whole story because, IIUC, in tree objects directories are sorted as if they had a slash appended; i.e. directory "foo" is sorted *after* file "foo.c", but *before* file "foo0".
-- Hannes