commit - 82f6abb8b1a22fe62d2a8a8d0cdbb73c9d85fcda
commit + bcb49d15e041ddffb59397d2fe851fdb1729b005
blob - 0a9f0472c3328f4c1e873ed61b40c7ea7ef1144a
blob + 228ca70ffc0b36c025622f32cdfdcb86916d687c
--- got/got.c
+++ got/got.c
int annotated;
char *id_str;
char *committer;
+ char datebuf[9]; /* YY-MM-DD + NUL */
};
struct blame_cb_args {
size_t linesize = 0;
struct got_commit_object *commit = NULL;
off_t offset;
+ struct tm tm;
+ time_t committer_time;
if (nlines != a->nlines ||
(lineno != -1 && lineno < 1) || lineno > a->nlines)
err = got_error_from_errno("strdup");
goto done;
}
+
+ committer_time = got_object_commit_get_committer_time(commit);
+ if (localtime_r(&committer_time, &tm) == NULL)
+ return got_error_from_errno("localtime_r");
+ if (strftime(bline->datebuf, sizeof(bline->datebuf), "%g/%m/%d",
+ &tm) >= sizeof(bline->datebuf)) {
+ err = got_error(GOT_ERR_NO_SPACE);
+ goto done;
+ }
bline->annotated = 1;
/* Print lines annotated so far. */
nl = strchr(line, '\n');
if (nl)
*nl = '\0';
- printf("%.*d) %.8s %-8s %s\n", a->nlines_prec, a->lineno_cur,
- bline->id_str, committer, line);
+ printf("%.*d) %.8s %s %-8s %s\n", a->nlines_prec, a->lineno_cur,
+ bline->id_str, bline->datebuf, committer, line);
a->lineno_cur++;
bline = &a->lines[a->lineno_cur - 1];
blob - ffd945039f1cf941bca4283e1957f71c3439a34a
blob + 60ecdd0c932486f6f73a0a6a29d9048339d48eae
--- regress/cmdline/blame.sh
+++ regress/cmdline/blame.sh
echo 3 >> $testroot/wt/alpha
(cd $testroot/wt && got commit -m "change 3" > /dev/null)
local commit3=`git_show_head $testroot/repo`
+ local author_time=`git_show_author_time $testroot/repo`
(cd $testroot/wt && got blame alpha > $testroot/stdout)
local short_commit2=`trim_obj_id 32 $commit2`
local short_commit3=`trim_obj_id 32 $commit3`
- echo "1) $short_commit1 $GOT_AUTHOR_8 1" > $testroot/stdout.expected
- echo "2) $short_commit2 $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
- echo "3) $short_commit3 $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
+ d=`date -r $author_time +"%g/%m/%d"`
+ echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
+ echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
+ echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
echo 3 >> $testroot/wt/alpha
(cd $testroot/wt && got commit -m "change 3" > /dev/null)
local commit3=`git_show_head $testroot/repo`
+ local author_time=`git_show_author_time $testroot/repo`
(cd $testroot/wt && got blame -c $tag alpha > $testroot/stdout)
local short_commit1=`trim_obj_id 32 $commit1`
local short_commit2=`trim_obj_id 32 $commit2`
- echo "1) $short_commit1 $GOT_AUTHOR_8 1" > $testroot/stdout.expected
- echo "2) $short_commit2 $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
+ d=`date -r $author_time +"%g/%m/%d"`
+ echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
+ echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
echo 1 > $testroot/wt/alpha
(cd $testroot/wt && got commit -m "change 1" > /dev/null)
local commit1=`git_show_head $testroot/repo`
+ local author_time=`git_show_author_time $testroot/repo`
(cd $testroot/wt && got blame alpha > $testroot/stdout)
local short_commit1=`trim_obj_id 32 $commit1`
- echo "1) $short_commit1 $GOT_AUTHOR_8 1" > $testroot/stdout.expected
+ d=`date -r $author_time +"%g/%m/%d"`
+ echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
echo -n 1 > $testroot/wt/alpha
(cd $testroot/wt && got commit -m "change 1" > /dev/null)
local commit1=`git_show_head $testroot/repo`
+ local author_time=`git_show_author_time $testroot/repo`
(cd $testroot/wt && got blame alpha > $testroot/stdout)
local short_commit1=`trim_obj_id 32 $commit1`
- echo "1) $short_commit1 $GOT_AUTHOR_8 1" > $testroot/stdout.expected
+ d=`date -r $author_time +"%g/%m/%d"`
+ echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
blob - 296735a35356574b58457b3b21280f4faf2bf2ab
blob + 0c8a19f4d7d1d2f8ab84f9b60b185526128a615b
--- regress/cmdline/common.sh
+++ regress/cmdline/common.sh
(cd $repo && git show --no-patch --pretty='format:%H')
}
+function git_show_author_time
+{
+ local repo="$1"
+ (cd $repo && git show --no-patch --pretty='format:%at')
+}
+
function git_show_parent_commit
{
local repo="$1"