* Error pushing new branch: value too great for base (error token is...
@ 2015-08-05 17:32 Gaurav Chhabra
2015-08-05 17:53 ` Eric Sunshine
0 siblings, 1 reply; 6+ messages in thread
From: Gaurav Chhabra @ 2015-08-05 17:32 UTC (permalink / raw)
To: git@vger.kernel.org
I had written the following code to check whether a push is for branch deletion:
#!/bin/bash
NULL="0000000000000000000000000000000000000000"
while read old_sha new_sha refname ; do
echo "Stdin: [$old_sha] [$new_sha] [$refname]"
if [[ "$new_sha" -eq "$NULL" ]]; then # Line 17
echo "Skipping checks..."
continue
fi
...
...
...
done
While it works fine for branch deletion, i noticed that if i create a
branch and push it to remote, i get the following error due to the
above-mentioned code:
$ git push origin rel-a
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 407 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Stdin: [0000000000000000000000000000000000000000]
[9226289d2416af4cb7365d7aaa5e382bdb3d9a89] [refs/heads/rel-a]
remote:
remote: hooks/pre-receive: line 17: [[:
9226289d2416af4cb7365d7aaa5e382bdb3d9a89: value too great for base
(error token is "922628
9d2416af4cb7365d7aaa5e382bdb3d9a89")
Although the new branch gets pushed to remote but i'm not sure why i'm
getting this error and how can i fix it. I checked online and i get
few links where folks had similar issue but in each such case, the
error token was 08 or 09. I still tried the suggestion of using "10#"
in front of my $new_sha variable but to no avail.
Any suggestions?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error pushing new branch: value too great for base (error token is...
2015-08-05 17:32 Error pushing new branch: value too great for base (error token is Gaurav Chhabra
@ 2015-08-05 17:53 ` Eric Sunshine
[not found] ` <CAGDgvc2hc+f5CuPXc2pr5uYd9kniVpuffrb6z416CicxBgVxJQ@mail.gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Eric Sunshine @ 2015-08-05 17:53 UTC (permalink / raw)
To: Gaurav Chhabra; +Cc: git@vger.kernel.org
On Wed, Aug 5, 2015 at 1:32 PM, Gaurav Chhabra <varuag.chhabra@gmail.com> wrote:
> I had written the following code to check whether a push is for branch deletion:
>
> #!/bin/bash
>
> NULL="0000000000000000000000000000000000000000"
> if [[ "$new_sha" -eq "$NULL" ]]; then # Line 17
> remote: Stdin: [0000000000000000000000000000000000000000]
> [9226289d2416af4cb7365d7aaa5e382bdb3d9a89] [refs/heads/rel-a]
> remote:
> remote: hooks/pre-receive: line 17: [[:
> 9226289d2416af4cb7365d7aaa5e382bdb3d9a89: value too great for base
> (error token is "922628
> 9d2416af4cb7365d7aaa5e382bdb3d9a89")
>
> Although the new branch gets pushed to remote but i'm not sure why i'm
> getting this error and how can i fix it. I checked online and i get
> few links where folks had similar issue but in each such case, the
> error token was 08 or 09. I still tried the suggestion of using "10#"
> in front of my $new_sha variable but to no avail.
>
> Any suggestions?
Yes, try using the string comparison '=' operator rather than the
numeric comparison operator '-eq'.
if [[ "$new_sha" = "$NULL" ]]; then
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error pushing new branch: value too great for base (error token is...
[not found] ` <CAGDgvc2hc+f5CuPXc2pr5uYd9kniVpuffrb6z416CicxBgVxJQ@mail.gmail.com>
@ 2015-08-10 9:54 ` Gaurav Chhabra
2015-08-10 22:29 ` Jacob Keller
0 siblings, 1 reply; 6+ messages in thread
From: Gaurav Chhabra @ 2015-08-10 9:54 UTC (permalink / raw)
To: git@vger.kernel.org
Apologies for the delay in reply! I tried your suggestion and it
works. Thanks! :)
I'm curious why integer comparison is throwing error. Shouldn't i be
comparing numbers with numeric operator?
On Mon, Aug 10, 2015 at 3:23 PM, Gaurav Chhabra
<varuag.chhabra@gmail.com> wrote:
> Apologies for the delay in reply! I tried your suggestion and it works.
> Thanks! :)
>
> I'm curious why integer comparison is throwing error. Shouldn't i be
> comparing numbers with numeric operator?
>
>
> On Wed, Aug 5, 2015 at 11:23 PM, Eric Sunshine <sunshine@sunshineco.com>
> wrote:
>>
>> On Wed, Aug 5, 2015 at 1:32 PM, Gaurav Chhabra <varuag.chhabra@gmail.com>
>> wrote:
>> > I had written the following code to check whether a push is for branch
>> > deletion:
>> >
>> > #!/bin/bash
>> >
>> > NULL="0000000000000000000000000000000000000000"
>> > if [[ "$new_sha" -eq "$NULL" ]]; then # Line 17
>> > remote: Stdin: [0000000000000000000000000000000000000000]
>> > [9226289d2416af4cb7365d7aaa5e382bdb3d9a89] [refs/heads/rel-a]
>> > remote:
>> > remote: hooks/pre-receive: line 17: [[:
>> > 9226289d2416af4cb7365d7aaa5e382bdb3d9a89: value too great for base
>> > (error token is "922628
>> > 9d2416af4cb7365d7aaa5e382bdb3d9a89")
>> >
>> > Although the new branch gets pushed to remote but i'm not sure why i'm
>> > getting this error and how can i fix it. I checked online and i get
>> > few links where folks had similar issue but in each such case, the
>> > error token was 08 or 09. I still tried the suggestion of using "10#"
>> > in front of my $new_sha variable but to no avail.
>> >
>> > Any suggestions?
>>
>> Yes, try using the string comparison '=' operator rather than the
>> numeric comparison operator '-eq'.
>>
>> if [[ "$new_sha" = "$NULL" ]]; then
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error pushing new branch: value too great for base (error token is...
2015-08-10 9:54 ` Gaurav Chhabra
@ 2015-08-10 22:29 ` Jacob Keller
2015-08-10 22:47 ` Eric Sunshine
0 siblings, 1 reply; 6+ messages in thread
From: Jacob Keller @ 2015-08-10 22:29 UTC (permalink / raw)
To: Gaurav Chhabra; +Cc: git@vger.kernel.org
On Mon, Aug 10, 2015 at 2:54 AM, Gaurav Chhabra
<varuag.chhabra@gmail.com> wrote:
> Apologies for the delay in reply! I tried your suggestion and it
> works. Thanks! :)
>
> I'm curious why integer comparison is throwing error. Shouldn't i be
> comparing numbers with numeric operator?
>
Yes, but shell doesn't treat hex numbers as numbers. So it will work
only if the string is a decimal number.
Regards,
Jake
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error pushing new branch: value too great for base (error token is...
2015-08-10 22:29 ` Jacob Keller
@ 2015-08-10 22:47 ` Eric Sunshine
2015-08-11 6:30 ` Gaurav Chhabra
0 siblings, 1 reply; 6+ messages in thread
From: Eric Sunshine @ 2015-08-10 22:47 UTC (permalink / raw)
To: Jacob Keller; +Cc: Gaurav Chhabra, git@vger.kernel.org
On Mon, Aug 10, 2015 at 6:29 PM, Jacob Keller <jacob.keller@gmail.com> wrote:
> On Mon, Aug 10, 2015 at 2:54 AM, Gaurav Chhabra
> <varuag.chhabra@gmail.com> wrote:
>> Apologies for the delay in reply! I tried your suggestion and it
>> works. Thanks! :)
>>
>> I'm curious why integer comparison is throwing error. Shouldn't i be
>> comparing numbers with numeric operator?
>
> Yes, but shell doesn't treat hex numbers as numbers. So it will work
> only if the string is a decimal number.
This particular case deserves a bit more explanation. The expression
in question was this:
if [[ "$new_sha" -eq "$NULL" ]]; then
where 'new_sha' was 9226289d2416af4cb7365d7aaa5e382bdb3d9a89.
In Bash, inside the [[ .. ]], it did attempt evaluating the SHA1 as a
*decimal* number, however, when it encountered the "d", it complained
that it was outside the allowed range of decimal digits ("0"..."9").
Had the SHA1 been prefixed by a "0x", the [[...]] context would have
dealt with it just fine.
Outside the [[...]] context, arguments to -eq do need to be base-10 integers.
Nevertheless, a SHA1 is effective an opaque value. There's little, if
anything, to be gained by treating it as a numeric quantity, hence
string '=' makes more sense than numeric '-eq'.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Error pushing new branch: value too great for base (error token is...
2015-08-10 22:47 ` Eric Sunshine
@ 2015-08-11 6:30 ` Gaurav Chhabra
0 siblings, 0 replies; 6+ messages in thread
From: Gaurav Chhabra @ 2015-08-11 6:30 UTC (permalink / raw)
To: git@vger.kernel.org
Thanks for the detailed explanation Eric! That really helped clear my
doubts. Also tried with "0x" and it's working fine however, as
suggested by you, i will use '='
Thanks again! :)
On Tue, Aug 11, 2015 at 4:17 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Mon, Aug 10, 2015 at 6:29 PM, Jacob Keller <jacob.keller@gmail.com> wrote:
>> On Mon, Aug 10, 2015 at 2:54 AM, Gaurav Chhabra
>> <varuag.chhabra@gmail.com> wrote:
>>> Apologies for the delay in reply! I tried your suggestion and it
>>> works. Thanks! :)
>>>
>>> I'm curious why integer comparison is throwing error. Shouldn't i be
>>> comparing numbers with numeric operator?
>>
>> Yes, but shell doesn't treat hex numbers as numbers. So it will work
>> only if the string is a decimal number.
>
> This particular case deserves a bit more explanation. The expression
> in question was this:
>
> if [[ "$new_sha" -eq "$NULL" ]]; then
>
> where 'new_sha' was 9226289d2416af4cb7365d7aaa5e382bdb3d9a89.
>
> In Bash, inside the [[ .. ]], it did attempt evaluating the SHA1 as a
> *decimal* number, however, when it encountered the "d", it complained
> that it was outside the allowed range of decimal digits ("0"..."9").
> Had the SHA1 been prefixed by a "0x", the [[...]] context would have
> dealt with it just fine.
>
> Outside the [[...]] context, arguments to -eq do need to be base-10 integers.
>
> Nevertheless, a SHA1 is effective an opaque value. There's little, if
> anything, to be gained by treating it as a numeric quantity, hence
> string '=' makes more sense than numeric '-eq'.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-08-11 6:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-05 17:32 Error pushing new branch: value too great for base (error token is Gaurav Chhabra
2015-08-05 17:53 ` Eric Sunshine
[not found] ` <CAGDgvc2hc+f5CuPXc2pr5uYd9kniVpuffrb6z416CicxBgVxJQ@mail.gmail.com>
2015-08-10 9:54 ` Gaurav Chhabra
2015-08-10 22:29 ` Jacob Keller
2015-08-10 22:47 ` Eric Sunshine
2015-08-11 6:30 ` Gaurav Chhabra
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).