Teach Git how to parse standard power of 2 suffixes.

Sometimes its necessary to supply a value as a power of two in a
configuration parameter.  In this case the user may want to use the
standard suffixes such as K, M, or G to indicate that the numerical
value should be multiplied by a constant base before being used.

Shell scripts/etc. can also benefit from this automatic option
parsing with `git repo-config --int`.

[jc: with a couple of test and a slight input tightening]

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Shawn O. Pearce
2006-12-30 22:13:05 -05:00
committed by Junio C Hamano
parent 95d3c4f546
commit d77a64d353
3 changed files with 20 additions and 1 deletions

View File

@ -391,5 +391,15 @@ EOF
test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success numbers '
git-repo-config kilo.gram 1k &&
git-repo-config mega.ton 1m &&
k=$(git-repo-config --int --get kilo.gram) &&
test z1024 = "z$k" &&
m=$(git-repo-config --int --get mega.ton) &&
test z1048576 = "z$m"
'
test_done