commit - 7e6fcaa81371396b915c5382bb6f05175313bc8a
commit + dee3d788b5980d09c1dac29e67844b3947488112
blob - a81121f951a231375922221fe3702b4f48c0d214
blob + 717a7c74d145e56db2a81a960f1739187059af09
--- got/got.c
+++ got/got.c
}
static char *
-get_datestr(time_t *time, char *datebuf)
+get_datestr(const time_t *time, char *datebuf)
{
struct tm mytm, *tm;
char *p, *s;
return NULL;
}
+/* print a date line unless an error occurs (or fail silently) */
+static void
+print_date(const char *prefix, const time_t *t)
+{
+ char datebuf[26];
+ char *datestr;
+
+ datestr = get_datestr(t, datebuf);
+ if (datestr)
+ printf("%s %s UTC\n", prefix, datestr);
+}
+
static const struct got_error *
print_commit(struct got_commit_object *commit, struct got_object_id *id,
struct got_repository *repo, const char *path,
{
const struct got_error *err = NULL;
FILE *f = NULL;
- char *id_str, *datestr, *logmsg0, *logmsg, *line;
- char datebuf[26];
- time_t committer_time;
+ char *id_str, *logmsg0, *logmsg, *line;
+ time_t author_time, committer_time;
const char *author, *committer;
char *refs_str = NULL;
id_str = NULL;
free(refs_str);
refs_str = NULL;
- printf("from: %s\n", got_object_commit_get_author(commit));
+
+ /* author and committer data */
author = got_object_commit_get_author(commit);
+ author_time = got_object_commit_get_author_time(commit);
committer = got_object_commit_get_committer(commit);
+ committer_time = got_object_commit_get_committer_time(commit);
+ printf("from: %s\n", author);
+ if (author_time != committer_time)
+ print_date("orig:", &author_time);
if (strcmp(author, committer) != 0)
printf("via: %s\n", committer);
- committer_time = got_object_commit_get_committer_time(commit);
- datestr = get_datestr(&committer_time, datebuf);
- if (datestr)
- printf("date: %s UTC\n", datestr);
+ print_date("date:", &committer_time);
+
+ /* parent commits */
if (got_object_commit_get_nparents(commit) > 1) {
const struct got_object_id_queue *parent_ids;
struct got_object_qid *qid;
blob - c824aaf0100a26fa4d112f62f5136272c5c82bbc
blob + aa8c37ce5f9af6c3b3fdf320c95dd8316334d667
--- regress/cmdline/rebase.sh
+++ regress/cmdline/rebase.sh
echo "modified alpha on branch" > $testroot/repo/alpha
git_commit $testroot/repo -m "modified alpha on newbranch"
- (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
- > $testroot/log.expected)
+ (cd $testroot/repo && got log -c newbranch -l2 | \
+ egrep -v '^(date|orig):' > $testroot/log.expected)
local orig_commit1=`git_show_parent_commit $testroot/repo`
local orig_commit2=`git_show_head $testroot/repo`
return 1
fi
- (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
- > $testroot/log)
+ (cd $testroot/wt && got log -c newbranch -l2 | \
+ egrep -v '^(date|orig):' > $testroot/log)
ed -s $testroot/log.expected <<-EOF
,s/$orig_commit1/$new_commit1/
,s/$orig_commit2/$new_commit2/