From: Jeff Garzik <hidden> Date: 2016-06-15 22:41:57
Being a weirdo, I don't use cogito for kernel development, just git
itself. I store branches in .git/refs/heads/ per the defacto standard,
and use the attached script to switch the working directory from one
branch to another.
Problem is, 'git-checkout-cache -q -f -a' really pounds the disk, and
takes quite a while.
Is there any way to avoid -f, while ensuring that the working directory
truly represents the new branch?
BitKeeper has a secret checkout arg '-S', which will leave files
untouched if the mtime/size information is unchanged.
Jeff
Problem is, 'git-checkout-cache -q -f -a' really pounds the disk, and
takes quite a while.
No. "git" is perfect, and "git-checkout-cache -f" already does exactly
what you want.
Is there any way to avoid -f, while ensuring that the working directory
truly represents the new branch?
You don't need to avoid -f, it already has the logic to avoid writing
files that are already up-to-date.
HOWEVER, your script is broken:
git-read-tree $(cat .git/HEAD) && \
git-checkout-cache -q -f -a && \
git-update-cache --refresh
you need to use the "-m" switch to git-read-tree to tell it to merge the
index information from your previous tree with the new one.
Also, don't do the "$(cat .git/HEAD)" thing any more, since modern git
does this so much more nicely, and allows you to use your branch names
directly.
Finally, use the new "-u" flag to git-checkout-cache, which will update
the cache as it goes along.
In other words, those lines in your script should look like this:
git-read-tree -m HEAD && git-checkout-cache -q -f -u -a
and you'll be a lot happier.
Linus
In other words, those lines in your script should look like this:
git-read-tree -m HEAD && git-checkout-cache -q -f -u -a
and you'll be a lot happier.
Btw, I do realize that I'm a total wiener, and that my inability to use
"getopt_long()" is shameful and stupid.
What can I say? I'm easily confused, and besides, I really seldom program
in user mode.
So if somebody were to getopt'ify git, _without_ adding crapola like
autoconf (which probably implies that git would just require GNU getopt),
and others agree that it's ok to just say that we expect getopt_long() to
exist, then I'd not have any objections to making the above just be
git-read-tree -m HEAD | git-checkout-cache -fqua
(to which the beavis-and-butthead in me says "hehhehhehh.. He said fqua.
Hehhehh. fire fire fire.")
Linus
From: Jeff Garzik <hidden> Date: 2016-06-15 22:41:58
Linus Torvalds wrote:
On Fri, 20 May 2005, Linus Torvalds wrote:
quoted
In other words, those lines in your script should look like this:
git-read-tree -m HEAD && git-checkout-cache -q -f -u -a
and you'll be a lot happier.
Btw, I do realize that I'm a total wiener, and that my inability to use
"getopt_long()" is shameful and stupid.
info libc argp :) argp is a lot more flexible, but with the same basic
structure as getopt_long().
If you pick a random git program, I would be willing to convert it as an
example. I attached my implementation of ipcrm[1] as an example.
Jeff
[1] from 'posixutils', my project to implement all the POSIX command
line utilities. Yes, I'm crazy too.