Skip to contentSkip to conversation

value too great for base (error token is "-0800")

PATCH In review Pavel Roskin 6 participants 13 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 value too great for base (error token is "-0800")

Hello!

The current cogito has problems with timezones that are too far from the Greenwich meridian :-)

Bash interprets numbers beginning with 0 as octals. Therefore, we need to strip leading zeroes or zeroes following "-". But if we get too zealous and strip all digits, we'll need to restore one 0. I tried to write for sed portably, so I avoided some optimizations, such as s/^-\?$/0/

cg-Xlib +1 -1
@@ -65,7 +65,7 @@ showdate () {
 	[ "$format" ] || format=-R
 	sec=${date[0]}; tz=${date[1]}
 	if [ "$has_gnudate" ]; then
-	        dtz=${tz/+/}
+	        dtz=$(echo $tz | sed 's/^+//;s/^0*//;s/^-0*/-/;s/^$/0/;s/^-$/0/')
 		lsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))
 	        pdate="$(date -ud "1970-01-01 UTC + $lsec sec" "$format" 2>/dev/null)"
 	else
Signature · 2 lines
Regards,
Pavel Roskin
#1 lore raw

Re: [PATCH] Fix cogito handling of timezones

Hello,

FYI, from the contestants for the octal fix, I've chosen to take Dan's
solution - not that I'd think it's the best, but it's simple and mainly I'm taking other Dan's changes and I don't like solving conflicts.

Quoted 4 lines
(quoted diff) +4 -0
+	local secs=$1 tzhours=${2:0:3} tzmins=${2:0:1}${2:3} format=$3
+	# bash doesn't like leading zeros
+	[ "${tzhours:1:1}" = 0 ] && tzhours=${2:0:1}${2:2:1}
+	secs=$((secs + tzhours * 3600 + tzmins * 60))
Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..
#2 lore raw

[ANNOUNCE] Cogito-0.11.3

Hello,

it turned out that Cogito was so broken w.r.t. three-way merging that
I had to really release a bugfix version. So this version contains some cleanups of the merge script, some more portability fixes (it actually runs on Debian old stable now!), and especially few bugfixes - cg-log works with individual files passed to it now, and merging should hopefully work correctly now too.

You know what to do. :-)

Junio C Hamano:
Add read-tree -m 3-way merge tests.

Linus Torvalds:
One more time.. Clean up git-merge-one-file-script
Fix up git-merge-one-file-script
Merge my and Petr's git-merge-one-file-script modifications Make sure we error out if we can't remove a file on automatic merges.

Petr Baudis:
cogito-0.11.3
Fix cg-merge's three-way content merge
Support for compilation w/o OpenSSL
Portable stub for the stat call
Fix cg-diff -p to work with no -r specified git-merge-one-file-script cleanups from Cogito
Further converge git-merge-one-file-script and cg-Xmergefile Remove useless ret=0 in the onefile merge scripts
Make git-merge-one-file-script and cg-Xmergefile converge even more Fix cg-log called on specified files
Tidy up some rev-list-related stuff
Fix git-merge-one-file permissions auto-merging

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..
#3 lore raw

Re: [ANNOUNCE] Cogito-0.11.3

Quoted 10 lines · Petr Baudis

Hello,

it turned out that Cogito was so broken w.r.t. three-way merging that
I had to really release a bugfix version. So this version contains some cleanups of the merge script, some more portability fixes (it actually runs on Debian old stable now!), and especially few bugfixes - cg-log works with individual files passed to it now, and merging should hopefully work correctly now too.

You know what to do. :-)

Hi Petr,

I have updated to Cogito-0.11.3, it compiles and runs but make test returns multiple error messages (see below)

Rgds,
Konstantin

*** t6001-rev-list-merge-order.sh ***
fatal: merge order sort unsupported, OpenSSL not linked
fatal: merge order sort unsupported, OpenSSL not linked
* ok 1: Testing that the rev-list has correct number of entries
* FAIL 2: Testing that --merge-order produces the correct result diff expected-merge-order actual-merge-order
* ok 3: Testing that --merge-order produces as many or fewer
discontinuities
fatal: merge order sort unsupported, OpenSSL not linked
* FAIL 4: Testing multiple heads diff expected-merge-order-1 actual-merge-order-1
fatal: merge order sort unsupported, OpenSSL not linked
* FAIL 5: Testing stop diff expected-merge-order-2 actual-merge-order-2
fatal: merge order sort unsupported, OpenSSL not linked
* FAIL 6: Testing stop in linear epoch diff expected-merge-order-3 actual-merge-order-3
fatal: merge order sort unsupported, OpenSSL not linked
* FAIL 7: Testing start in linear epoch, stop after non-linear epoch diff expected-merge-order-4 actual-merge-order-4
* FAIL 8: Testing duplicated start arguments diff expected-merge-order-4 actual-merge-order-5
* FAIL 9: Testing exclusion near merge git-rev-list --merge-order $a4 ^$c3 2>/dev/null
* failed 7 among 9 test(s)
make[1]: *** [all] Error 1
make[1]: Leaving directory `/home/konstantin/git/cogito/t'
make: *** [test] Error 2

Quoted 1 line
Signature · 3 lines
Konstantin Antselovich
mailto: [email protected]
http://konstantin.antselovich.com
#4 lore raw

Re: [ANNOUNCE] Cogito-0.11.3

Quoted 2 lines · Konstantin Antselovich

I have updated to Cogito-0.11.3, it compiles and runs but make test returns multiple error messages (see below)

There's a typo in rev-list.c. This fixes the tests for me:

rev-list.c +1 -1
@@ -218,7 +218,7 @@ int main(int argc, char **argv)
                        list = limit_list(list);
                show_commit_list(list);
        } else {
-#ifdef NO_OPENSSL
+#ifndef NO_OPENSSL
                if (sort_list_in_merge_order(list, &process_commit)) {
                          die("merge order sort failed\n");
                }
#5 lore raw

Re: [ANNOUNCE] Cogito-0.11.3

Quoted 5 lines · * Dan Holmsand ([email protected]) wrote:
Quoted 2 lines · Konstantin Antselovich

I have updated to Cogito-0.11.3, it compiles and runs but make test returns multiple error messages (see below)

There's a typo in rev-list.c. This fixes the tests for me:

This patch is white space damaged. I fixed it, and added it to the cogito-0.11.3 rpm. Below is the refreshed patch.

thanks,
-chris
--

From: Dan Holmsand <[email protected]>

There's a typo in rev-list.c. This fixes the tests for me:

rev-list.c +1 -1
@@ -218,7 +218,7 @@ int main(int argc, char **argv)
 			list = limit_list(list);
 		show_commit_list(list);
 	} else {
-#ifdef NO_OPENSSL
+#ifndef NO_OPENSSL
 		if (sort_list_in_merge_order(list, &process_commit)) {
 			  die("merge order sort failed\n");
 		}
#6 lore raw

Re: [ANNOUNCE] Cogito-0.11.3

Quoted 9 lines · * Chris Wright ([email protected]) wrote:
Quoted 5 lines · * Dan Holmsand ([email protected]) wrote:
Quoted 2 lines · Konstantin Antselovich

I have updated to Cogito-0.11.3, it compiles and runs but make test returns multiple error messages (see below)

There's a typo in rev-list.c. This fixes the tests for me:

This patch is white space damaged. I fixed it, and added it to the cogito-0.11.3 rpm. Below is the refreshed patch.

Looks like showdate() is having some minor trouble. A simple cg-log gave me errors indicating the tz is being interpreted as octal. There's probably a better way, but bruteforce works ;-) This patch is in the RPM packages which are now uploading.

thanks,
-chris
--

Strip leading zero from timezone to keep it from being interpreted as octal causing error such as:

/usr/lib/cogito/cg-Xlib: line 69: 0800: value too great for base (error token is "0800")

cg-Xlib +3 -1
@@ -65,7 +65,9 @@ showdate () {
 	[ "$format" ] || format=-R
 	sec=${date[0]}; tz=${date[1]}
 	if [ "$has_gnudate" ]; then
-	        dtz=${tz/+/}
+	        dtz=${tz/-0/-}
+	        dtz=${dtz/+/}
+	        dtz=${dtz/#0/}
 		lsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))
 	        pdate="$(date -ud "1970-01-01 UTC + $lsec sec" "$format" 2>/dev/null)"
 	else
#7 lore raw

PATCH 1/1 Fix cogito handling of timezones

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Current cogito behavior treats the timezone offset as if it's decimal, but most zone offsets begin with a 0. As a result, the computation in cg-Xlib uses the zone offset as an octal number. -0700 looks like 4 1/2 hours offset, rather than 7, and -0800 is an invalid octal number.

This patch fixes the behavior to strip off leading 0s. It's ugly, but it should produce the right values until someone with better bash scripting skills than I can fix it.

cg-Xlib +0 -0

- --- a/cg-Xlib
+++ b/cg-Xlib
@@ -6,6 +6,8 @@
# This file provides a library containing common code shared with all the # Cogito programs.

+shopt -s extglob
+
_cg_cmd=${0##*/}

_git=${GIT_DIR:-.git}
@@ -51,8 +53,12 @@ showdate () {
[ "$format" ] || format=-R
sec=${date[0]}; tz=${date[1]}
if [ "$has_gnudate" ]; then
- - dtz=${tz/+/}
- - lsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))
+ sign=${tz%%[0-9]*}
+ sign=${sign:?+}
+ dtz=${tz/[+-]}
+ dtz=${dtz##*(0)}
+ dtz=${dtz:?0}
+ lsec=$(($sec + $dtz % 100 $sign $dtz / 100 * 3600))
pdate="$(date -ud "1970-01-01 UTC + $lsec sec" "$format" 2>/dev/null)"
else
# FIXME: $format

Frank
- --
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCp7oXaI0dwg4A47wRAnOFAJ4jsaQodgxOr3gp8jMYhOxuJ98GFgCgnclC Zd68hflXn8pV39zBF4YOlUc=
=C+hn
-----END PGP SIGNATURE-----

#8 lore raw

Re: [PATCH] Fix cogito handling of timezones

Dear diary, on Thu, Jun 09, 2005 at 05:40:07AM CEST, I got a letter where Frank Sorenson <[email protected]> told me that...

Quoted 17 lines

Current cogito behavior treats the timezone offset as if it's decimal, but most zone offsets begin with a 0. As a result, the computation in cg-Xlib uses the zone offset as an octal number. -0700 looks like 4 1/2 hours offset, rather than 7, and -0800 is an invalid octal number.

This patch fixes the behavior to strip off leading 0s. It's ugly, but it should produce the right values until someone with better bash scripting skills than I can fix it.

cg-Xlib +0 -0
@@ -51,8 +53,12 @@ showdate () {
 	[ "$format" ] || format=-R

cg-Xlib showdate () { · line 61

Quoted 10 lines
cg-Xlib +6 -2
 	sec=${date[0]}; tz=${date[1]}
 	if [ "$has_gnudate" ]; then
-	        dtz=${tz/+/}
-		lsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))
+		sign=${tz%%[0-9]*}
+		sign=${sign:?+}
+		dtz=${tz/[+-]}
+		dtz=${dtz##*(0)}
+		dtz=${dtz:?0}
+		lsec=$(($sec + $dtz % 100 $sign $dtz / 100 * 3600))

It looks ok, but shouldn't this be
+ lsec=$(($sec + $dtz % 100 * 60 $sign $dtz / 100 * 3600))

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..
#9 lore raw

Re: [PATCH] Fix cogito handling of timezones

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Review

Quoted 2 lines · Petr Baudis

It looks ok, but shouldn't this be

(quoted diff) +1 -0
+		lsec=$(($sec + $dtz % 100 * 60 $sign $dtz / 100 * 3600))

Ah, yes, of course. I see that Dan Holmsand has also sent a patch (3/6) to fix this. I haven't tested his very much, but it looks like a cleaner and more comprehensive solution. Sigh.

Frank
- --
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCqFAtaI0dwg4A47wRAlaEAJ0Ui38Yrwp7r0QUseI5/7n4kbnRaACfZBv0 M5TClhJuvD2y7fz/Fm9pNes=
=SOdU
-----END PGP SIGNATURE-----

#10 lore raw

PATCH 3/6 Make showdate use "Linus format"

This makes showdate use the same date format as git-rev-list --pretty, and gives some speedup. It might also be more portable.

Note that this changes the calling convention: the previous version used seconds from $1, but timezone from the global variable $date. cg-mkpatch is modified to the new way.

Also fixes bash's belief that number literals starting with zero are octal.

---

 cg-Xlib    |   18 ++++++++----------
 cg-mkpatch |    2 +-
 2 files changed, 9 insertions(+), 11 deletions(-)
cg-Xlib +8 -10
@@ -60,19 +60,17 @@ stat () {
 }
 
 showdate () {
-	date="$1"
-	format="$2"
-	[ "$format" ] || format=-R
-	sec=${date[0]}; tz=${date[1]}
+	local secs=$1 tzhours=${2:0:3} tzmins=${2:0:1}${2:3} format=$3
+	# bash doesn't like leading zeros
+	[ "${tzhours:1:1}" = 0 ] && tzhours=${2:0:1}${2:2:1}
+	secs=$((secs + tzhours * 3600 + tzmins * 60))
 	if [ "$has_gnudate" ]; then
-	        dtz=${tz/+/}
-		lsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))
-	        pdate="$(date -ud "1970-01-01 UTC + $lsec sec" "$format" 2>/dev/null)"
+		[ "$format" ] || format="+%a %b %-d %H:%M:%S %Y $2"
+		LANG=C date -ud "1970-01-01 UTC + $secs sec" "$format"
 	else
-		# FIXME: $format
-	        pdate="$(date -u -r ${date[0]} 2>/dev/null)"
+		[ "$format" ] || format="+%a %b %d %H:%M:%S %Y $2"
+		date -u -r $secs "$format"
 	fi
-	echo "${pdate/+0000/$tz}"
 }
 
 # Usage: tree_timewarp [--no-head-update] DIRECTION_STR ROLLBACK_BOOL BASE BRANCH
cg-mkpatch +1 -1
@@ -52,7 +52,7 @@ showpatch () {
 		case "$key" in
 		"author"|"committer")
 			date=(${rest#*> })
-			pdate="$(showdate $date)"
+			pdate="$(showdate ${date[*]})"
 			[ "$pdate" ] && rest="${rest%> *}> $pdate"
 			echo $key $rest >>$header
 			;;
Applied
#11 lore raw

Re: [PATCH 3/6] Make showdate use "Linus format"

Thanks, applied.

Dear diary, on Thu, Jun 09, 2005 at 01:19:30PM CEST, I got a letter where Dan Holmsand <[email protected]> told me that...

Quoted 3 lines

This makes showdate use the same date format as git-rev-list --pretty, and gives some speedup. It might also be more portable.

I dropped the format change bit, because I really think the Linus' date format is bad. The current standardized, international and most widely used (even your mailer agent used it in your Date: header) date format is RFC 822, so please let's stick with it. It's perfect for our use, and better human-readable too. The date part isn't split all around but concentrated in the first half while the second half is dedicated to time.

Quoted 3 lines

Note that this changes the calling convention: the previous version used seconds from $1, but timezone from the global variable $date. cg-mkpatch is modified to the new way.

You forgot to modify cg-log accordingly. (I fixed that.)

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..
#12 lore raw

Re: [PATCH 3/6] Make showdate use "Linus format"

Quoted 10 lines · Petr Baudis

Thanks, applied.

Dear diary, on Thu, Jun 09, 2005 at 01:19:30PM CEST, I got a letter where Dan Holmsand <[email protected]> told me that...

Quoted 3 lines

This makes showdate use the same date format as git-rev-list --pretty, and gives some speedup. It might also be more portable.

Quoted 7 lines

I dropped the format change bit, because I really think the Linus' date format is bad. The current standardized, international and most widely used (even your mailer agent used it in your Date: header) date format is RFC 822, so please let's stick with it. It's perfect for our use, and better human-readable too. The date part isn't split all around but concentrated in the first half while the second half is dedicated to time.

Ok, I really have nothing against RFC822. But if Linus' format is bad, then git-rev-list --pretty should be fixed (or, rather, date.c). It doesn't make any sense to me to have different formats between cogito and core git.

And I'd really, really like to use as much of git-rev-list --pretty output as possible in cg-log. That makes the whole thing some orders of magnitude faster, and thus more usable.

Quoted 6 lines
Quoted 3 lines

Note that this changes the calling convention: the previous version used seconds from $1, but timezone from the global variable $date. cg-mkpatch is modified to the new way.

You forgot to modify cg-log accordingly. (I fixed that.)

Thanks. I did the "hope he takes my other patch too" thing... Sorry 'bout that.

/dan