# pretty format can't work on cron job

7 messages from 2010-11-05 to 2010-11-08. Participants: chen_wang@trendmicro.com.cn, Johannes Sixt, Jeff King, Chen WANG, Thomas Rast.
Thread: https://gitlist.dev/t/25650

## chen_wang@trendmicro.com.cn, 2010-11-05 08:29

Subject: pretty format can't work on cron job
Message-ID: <7B2091481B9ED640A92789B0CA07059587CCF7@CDCEXMAIL02.tw.trendnet.org>
URL: https://gitlist.dev/e/7B2091481B9ED640A92789B0CA07059587CCF7%40CDCEXMAIL02.tw.trendnet.org

```

For the command: git log 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.. -M --date=short --pretty=format:"Author: %aN <%ae>; Date: %ad" --shortstat --dirstat --no-merges

I run it on shell by manual can create correct format of output, such as:
-------------------------------------------------
Author: Amit Shah <amit.shah@redhat.com>; Date: 2010-10-20
 1 files changed, 14 insertions(+), 3 deletions(-)
 100.0% drivers/char/
-------------------------------------------------

But when I put that command on cron job, even I run “. /etc/profile” and “. ~/.bash_profile” first, I can’t get correct format of output.
-------------------------------------------------
Author: %aN <amit.shah@redhat.com>; Date: Wed Oct 20 13:45:43 2010 +1030
 100.0% drivers/char/
 1 files changed, 14 insertions(+), 3 deletions(-)
-------------------------------------------------

My git version is git-1.7.3.2.

Does anyone know the reason?

Thanks
Chen

TREND MICRO EMAIL NOTICE
The information contained in this email and any attachments is confidential and may be subject to copyright or other intellectual property protection. If you are not the intended recipient, you are not authorized to use or disclose this information, and we request that you notify us by reply mail or telephone and delete the original message from your mail system.
```

## Johannes Sixt, 2010-11-05 08:37

Subject: Re: pretty format can't work on cron job
Message-ID: <4CD3C262.6080108@viscovery.net>
URL: https://gitlist.dev/e/4CD3C262.6080108%40viscovery.net
In-Reply-To: <7B2091481B9ED640A92789B0CA07059587CCF7@CDCEXMAIL02.tw.trendnet.org>

```
Am 11/5/2010 9:29, schrieb chen_wang@trendmicro.com.cn:
> 
> For the command: git log 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.. -M --date=short --pretty=format:"Author: %aN <%ae>; Date: %ad" --shortstat --dirstat --no-merges
> 
> I run it on shell by manual can create correct format of output, such as:
> -------------------------------------------------
> Author: Amit Shah <amit.shah@redhat.com>; Date: 2010-10-20
>  1 files changed, 14 insertions(+), 3 deletions(-)
>  100.0% drivers/char/
> -------------------------------------------------
> 
> But when I put that command on cron job, even I run “. /etc/profile” and “. ~/.bash_profile” first, I can’t get correct format of output.
> -------------------------------------------------
> Author: %aN <amit.shah@redhat.com>; Date: Wed Oct 20 13:45:43 2010 +1030
>  100.0% drivers/char/
>  1 files changed, 14 insertions(+), 3 deletions(-)
> -------------------------------------------------

% has a special meaning in a crontab. See man 5 crontab.

-- Hannes

```

## chen_wang@trendmicro.com.cn, 2010-11-05 08:47

Subject: RE: pretty format can't work on cron job
Message-ID: <7B2091481B9ED640A92789B0CA07059587CD03@CDCEXMAIL02.tw.trendnet.org>
URL: https://gitlist.dev/e/7B2091481B9ED640A92789B0CA07059587CD03%40CDCEXMAIL02.tw.trendnet.org
In-Reply-To: <4CD3C262.6080108@viscovery.net>

```
> -----Original Message-----
> From: Johannes Sixt [mailto:j.sixt@viscovery.net]
> Sent: 2010年11月5日 16:38
> To: Chen Wang (QA-CN)
> Cc: git@vger.kernel.org; ellre923@gmail.com
> Subject: Re: pretty format can't work on cron job
> 
> Am 11/5/2010 9:29, schrieb chen_wang@trendmicro.com.cn:
> >
> > For the command: git log 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.. -M
> --date=short --pretty=format:"Author: %aN <%ae>; Date: %ad" --shortstat
> --dirstat --no-merges
> >
> > I run it on shell by manual can create correct format of output, such as:
> > -------------------------------------------------
> > Author: Amit Shah <amit.shah@redhat.com>; Date: 2010-10-20
> >  1 files changed, 14 insertions(+), 3 deletions(-)
> >  100.0% drivers/char/
> > -------------------------------------------------
> >
> > But when I put that command on cron job, even I run “. /etc/profile” and “.
> ~/.bash_profile” first, I can’t get correct format of output.
> > -------------------------------------------------
> > Author: %aN <amit.shah@redhat.com>; Date: Wed Oct 20 13:45:43 2010
> +1030
> >  100.0% drivers/char/
> >  1 files changed, 14 insertions(+), 3 deletions(-)
> > -------------------------------------------------
> 
> % has a special meaning in a crontab. See man 5 crontab.
> 

I warped this command in script and trigger script in crontab.
I think it's not the root cause, because %ae still works.

> -- Hannes

TREND MICRO EMAIL NOTICE
The information contained in this email and any attachments is confidential and may be subject to copyright or other intellectual property protection. If you are not the intended recipient, you are not authorized to use or disclose this information, and we request that you notify us by reply mail or telephone and delete the original message from your mail system.
```

## Jeff King, 2010-11-05 13:14

Subject: Re: pretty format can't work on cron job
Message-ID: <20101105131444.GB11707@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20101105131444.GB11707%40sigill.intra.peff.net
In-Reply-To: <7B2091481B9ED640A92789B0CA07059587CD03@CDCEXMAIL02.tw.trendnet.org>

```
On Fri, Nov 05, 2010 at 04:47:05PM +0800, chen_wang@trendmicro.com.cn wrote:

> > > But when I put that command on cron job, even I run “. /etc/profile” and “.
> > ~/.bash_profile” first, I can’t get correct format of output.
> > > -------------------------------------------------
> > > Author: %aN <amit.shah@redhat.com>; Date: Wed Oct 20 13:45:43 2010
> > +1030
> > >  100.0% drivers/char/
> > >  1 files changed, 14 insertions(+), 3 deletions(-)
> > > -------------------------------------------------
> > 
> > % has a special meaning in a crontab. See man 5 crontab.
> > 
> 
> I warped this command in script and trigger script in crontab.
> I think it's not the root cause, because %ae still works.

I notice that the only placeholder that is broken is %aN, which converts
using the .mailmap file. Maybe something in your environment is
preventing reading that file properly?

Can you show us the exact script you're calling from your crontab file?
I'm wondering if it's something to do with being in the same directory.

-Peff

```

## Chen WANG, 2010-11-06 04:42

Subject: RE: pretty format can't work on cron job
Message-ID: <01c101cb7d6c$fd053cf0$f70fb6d0$@com>
URL: https://gitlist.dev/e/01c101cb7d6c%24fd053cf0%24f70fb6d0%24%40com
In-Reply-To: <20101105131444.GB11707@sigill.intra.peff.net>

```
> -----Original Message-----
> From: Jeff King [mailto:peff@peff.net]
> Sent: 2010年11月5日 21:15
> To: chen_wang@trendmicro.com.cn
> Cc: j.sixt@viscovery.net; git@vger.kernel.org; ellre923@gmail.com
> Subject: Re: pretty format can't work on cron job
> 
> On Fri, Nov 05, 2010 at 04:47:05PM +0800, chen_wang@trendmicro.com.cn
> wrote:
> 
> > > > But when I put that command on cron job, even I run “. /etc/profile” and
> “.
> > > ~/.bash_profile” first, I can’t get correct format of output.
> > > > -------------------------------------------------
> > > > Author: %aN <amit.shah@redhat.com>; Date: Wed Oct 20 13:45:43 2010
> > > +1030
> > > >  100.0% drivers/char/
> > > >  1 files changed, 14 insertions(+), 3 deletions(-)
> > > > -------------------------------------------------
> > >
> > > % has a special meaning in a crontab. See man 5 crontab.
> > >
> >
> > I warped this command in script and trigger script in crontab.
> > I think it's not the root cause, because %ae still works.
> 
> I notice that the only placeholder that is broken is %aN, which converts
> using the .mailmap file. Maybe something in your environment is
> preventing reading that file properly?
> 

$ ll .mailmap
-rw-r--r-- 1 wangchen club 4021 Oct 15 06:18 .mailmap

> Can you show us the exact script you're calling from your crontab file?
> I'm wondering if it's something to do with being in the same directory.
> 

Sure.
$ crontab -l
58 06 * * * /home/wangchen/kps_update
$ cat /home/wangchen/kps_update
#!/bin/bash
su wangchen -
. /etc/profile
. ~/.bash_profile
cd /home/wangchen/kps
git pull
make
cd /home/wangchen/linux-2.6
git pull
/home/wangchen/kps/kps_web/kps_do /home/wangchen/linux-2.6 /home/wangchen/kps
$ cat /home/wangchen/kps/kps_web/kps_do
#!/bin/sh
#check script parameters
if [ -r $1 -a -w $2 ]; then
        echo "begin to update kps_result"
        readonly LGP=$1
        KGP=$2
        KGP=${KGP%%/}
else
        echo "usage: $0 linux_kernel_source_dir kps_source_dir"
        exit 1
fi
cd $LGP
git log 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.. -M --date=short --pretty=format:"Author: %aN <%ae>; Date: %ad" --shortstat --dirstat --no-merges >/tmp/ChangeLog-all

> -Peff

```

## Thomas Rast, 2010-11-07 19:18

Subject: Re: pretty format can't work on cron job
Message-ID: <201011072018.31740.trast@student.ethz.ch>
URL: https://gitlist.dev/e/201011072018.31740.trast%40student.ethz.ch
In-Reply-To: <01c101cb7d6c$fd053cf0$f70fb6d0$@com>

```
Chen WANG wrote:
> $ cat /home/wangchen/kps_update
> #!/bin/bash
> su wangchen -

What is this 'su' supposed to do?  AFAICS you would have to run
another script with 'su' if you really want to change user.

> git log 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.. -M --date=short --pretty=format:"Author: %aN <%ae>; Date: %ad" --shortstat --dirstat --no-merges >/tmp/ChangeLog-all
[%aN does not expand to anything within the cron runs]

Also, what git version(s) do you have installed?  %aN appeared in
1.5.6.4 and 1.6.0, so it is entirely possible that the $PATH within
your cronjob runs an older version which fails to expand it to
anything.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```

## Chen WANG, 2010-11-08 02:30

Subject: RE: pretty format can't work on cron job
Message-ID: <020101cb7eec$e5d1baa0$b1752fe0$@com>
URL: https://gitlist.dev/e/020101cb7eec%24e5d1baa0%24b1752fe0%24%40com
In-Reply-To: <201011072018.31740.trast@student.ethz.ch>

```
> -----Original Message-----
> From: Thomas Rast [mailto:trast@student.ethz.ch]
> Sent: 2010年11月8日 3:19
> To: Chen WANG
> Cc: 'Jeff King'; Chen Wang (QA-CN); j.sixt@viscovery.net; git@vger.kernel.
org
> Subject: Re: pretty format can't work on cron job
> 
> Chen WANG wrote:
> > $ cat /home/wangchen/kps_update
> > #!/bin/bash
> > su wangchen -
> 
> What is this 'su' supposed to do?  AFAICS you would have to run
> another script with 'su' if you really want to change user.
> 

Ignore it please. I put a lot rubbish here to try to figure out the issue.

> > git log 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.. -M --date=short
> --pretty=format:"Author: %aN <%ae>; Date: %ad" --shortstat --dirstat
> --no-merges >/tmp/ChangeLog-all
> [%aN does not expand to anything within the cron runs]
> 
> Also, what git version(s) do you have installed?  %aN appeared in
> 1.5.6.4 and 1.6.0, so it is entirely possible that the $PATH within
> your cronjob runs an older version which fails to expand it to
> anything.
> 

Absolutely right.
I was keeping figure out the difference between manual run and cron job for
git.
But seems my administrator installed a 1.5.5.4 for global, but my local bin
has a higher version of git which support %aN.
Thanks guys. Thanks Thomas.

> --
> Thomas Rast
> trast@{inf,student}.ethz.ch

```
