* A system administration use case for git
@ 2009-04-22 8:33 Jon Seymour
2009-04-22 8:48 ` Martin Langhoff
2009-04-23 9:55 ` Uwe Kleine-König
0 siblings, 2 replies; 8+ messages in thread
From: Jon Seymour @ 2009-04-22 8:33 UTC (permalink / raw)
To: Git Mailing List
Hello all, it's been quite a while.
And, no, I don't care that you ripped out git-rev-list --merge-order,
it was fun while it lasted and it was still a cool (if under
appreciated) algorithm :-)
I've got a system administration use case that I know git does 99.9%
of. I am wondering if the last 0.1%.
It'd be nice to do this on arbitrary (non-git-controlled) file system tree:
* calculate the git hashes of the tree (without making copies of the
files in the tree)
* archive the tree hashes
* rsync the tree hashes to another place
* work out which files aren't available in the other place's git repo
* rsync those files the the other place
Is there a way to easily achieve this with git's existing tool set or
a higher layer?
jon.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A system administration use case for git
2009-04-22 8:33 A system administration use case for git Jon Seymour
@ 2009-04-22 8:48 ` Martin Langhoff
[not found] ` <2cfc40320904220208g5acc2200w6144668ba2da5a09@mail.gmail.com>
2009-04-23 9:55 ` Uwe Kleine-König
1 sibling, 1 reply; 8+ messages in thread
From: Martin Langhoff @ 2009-04-22 8:48 UTC (permalink / raw)
To: Jon Seymour; +Cc: Git Mailing List
On Wed, Apr 22, 2009 at 10:33 AM, Jon Seymour <jon.seymour@gmail.com> wrote:
> Hello all, it's been quite a while.
> It'd be nice to do this on arbitrary (non-git-controlled) file system tree:
>
> * calculate the git hashes of the tree (without making copies of the
> files in the tree)
> * archive the tree hashes
> * rsync the tree hashes to another place
> * work out which files aren't available in the other place's git repo
> * rsync those files the the other place
Steps:
1 - rsync to the "other place"
2 - use the git repo in that "other place"
3 - if the tree hashes are needed "here", copy them from the "other
place" git to here.
rsync + git = awesomenesssssss
--
martin.langhoff@gmail.com
martin@laptop.org -- School Server Architect
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A system administration use case for git
2009-04-22 8:33 A system administration use case for git Jon Seymour
2009-04-22 8:48 ` Martin Langhoff
@ 2009-04-23 9:55 ` Uwe Kleine-König
2009-04-23 10:38 ` Johannes Sixt
1 sibling, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2009-04-23 9:55 UTC (permalink / raw)
To: Jon Seymour; +Cc: Git Mailing List
Hello Jon,
On Wed, Apr 22, 2009 at 06:33:12PM +1000, Jon Seymour wrote:
> * calculate the git hashes of the tree (without making copies of the
> files in the tree)
You can hand-craft a tree object:
for f in $filelist; 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 --stdin
You get some extra points for directories that include subdirs :-)
There is a problem though, I think it has to do with the order of the
files in the tree object. Here is a real-life example from the Linux
kernel (I choosed the usr subdirectory, because it's small and doesn't
contain subdirs):
ukleinek@cepheus:~/gsrc/linux-2.6/usr$ for f in .gitignore Kconfig Makefile gen_init_cpio.c initramfs_data.S initramfs_data.bz2.S initramfs_data.gz.S initramfs_data.lzma.S; 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 --stdin
64f2ca854bc19fd29479b198be11beba56a26b1e
ukleinek@cepheus:~/gsrc/linux-2.6/usr$ git rev-parse HEAD:usr
64f2ca854bc19fd29479b198be11beba56a26b1e
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
a0a6efb3f1de956badc7607c7d372cc325a18846
ukleinek@cepheus:~/gsrc/linux-2.6/usr$ git ls-tree a0a6efb3f1de956badc7607c7d372cc325a18846 | wc -l
0
doesn't work :-/
This would make a nice plumbing:
git hash-tree $directory
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A system administration use case for git
2009-04-23 9:55 ` Uwe Kleine-König
@ 2009-04-23 10:38 ` Johannes Sixt
2009-04-23 11:39 ` Uwe Kleine-König
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Sixt @ 2009-04-23 10:38 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: Jon Seymour, Git Mailing List
Uwe Kleine-König schrieb:
> 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
> a0a6efb3f1de956badc7607c7d372cc325a18846
Does ... $(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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A system administration use case for git
2009-04-23 10:38 ` Johannes Sixt
@ 2009-04-23 11:39 ` Uwe Kleine-König
0 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2009-04-23 11:39 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Jon Seymour, Git Mailing List
Hi Hannes,
On Thu, Apr 23, 2009 at 12:38:09PM +0200, Johannes Sixt wrote:
> Uwe Kleine-König schrieb:
> > 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
> > a0a6efb3f1de956badc7607c7d372cc325a18846
>
> Does ... $(LANG=C ls -A) ... make a difference for you?
oh, up to now I thought that C and en_US.UTF-8 use the same sorting. So
yes, it does it right then.
Best regards and thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-04-23 11:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-22 8:33 A system administration use case for git Jon Seymour
2009-04-22 8:48 ` Martin Langhoff
[not found] ` <2cfc40320904220208g5acc2200w6144668ba2da5a09@mail.gmail.com>
2009-04-22 9:22 ` Jon Seymour
2009-04-22 10:07 ` Martin Langhoff
2009-04-22 10:18 ` Jon Seymour
2009-04-23 9:55 ` Uwe Kleine-König
2009-04-23 10:38 ` Johannes Sixt
2009-04-23 11:39 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).