commit - e2752401e9de43f1f8c1e3a1601ec073cccab548
commit + d356bf7597557e6a57136825b8429c1117e70469
blob - 5be6a46cba0106ad052f2b730fe0227639eccb29
blob + 08acad083c18dda41826423076e5eae7d41bce82
--- got/got.c
+++ got/got.c
return err;
}
+static void
+format_gmtoff(char *buf, size_t sz, time_t gmtoff)
+{
+ long long h, m;
+ char sign = '+';
+
+ if (gmtoff < 0) {
+ sign = '-';
+ gmtoff = -gmtoff;
+ }
+
+ h = (long long)gmtoff / 3600;
+ m = ((long long)gmtoff - h*3600) / 60;
+ snprintf(buf, sz, "%c%02lld%02lld", sign, h, m);
+}
+
static const struct got_error *
cat_commit(struct got_object_id *id, struct got_repository *repo, FILE *outfile)
{
struct got_object_qid *pid;
char *id_str = NULL;
const char *logmsg = NULL;
+ char gmtoff[6];
err = got_object_open_as_commit(&commit, repo, id);
if (err)
fprintf(outfile, "%s%s\n", GOT_COMMIT_LABEL_PARENT, pid_str);
free(pid_str);
}
- fprintf(outfile, "%s%s %lld +0000\n", GOT_COMMIT_LABEL_AUTHOR,
+ format_gmtoff(gmtoff, sizeof(gmtoff),
+ got_object_commit_get_author_gmtoff(commit));
+ fprintf(outfile, "%s%s %lld %s\n", GOT_COMMIT_LABEL_AUTHOR,
got_object_commit_get_author(commit),
- (long long)got_object_commit_get_author_time(commit));
+ (long long)got_object_commit_get_author_time(commit),
+ gmtoff);
- fprintf(outfile, "%s%s %lld +0000\n", GOT_COMMIT_LABEL_COMMITTER,
+ format_gmtoff(gmtoff, sizeof(gmtoff),
+ got_object_commit_get_committer_gmtoff(commit));
+ fprintf(outfile, "%s%s %lld %s\n", GOT_COMMIT_LABEL_COMMITTER,
got_object_commit_get_author(commit),
- (long long)got_object_commit_get_committer_time(commit));
+ (long long)got_object_commit_get_committer_time(commit),
+ gmtoff);
logmsg = got_object_commit_get_logmsg_raw(commit);
fprintf(outfile, "messagelen %zd\n", strlen(logmsg));
struct got_tag_object *tag;
char *id_str = NULL;
const char *tagmsg = NULL;
+ char gmtoff[6];
err = got_object_open_as_tag(&tag, repo, id);
if (err)
fprintf(outfile, "%s%s\n", GOT_TAG_LABEL_TAG,
got_object_tag_get_name(tag));
- fprintf(outfile, "%s%s %lld +0000\n", GOT_TAG_LABEL_TAGGER,
+ format_gmtoff(gmtoff, sizeof(gmtoff),
+ got_object_tag_get_tagger_gmtoff(tag));
+ fprintf(outfile, "%s%s %lld %s\n", GOT_TAG_LABEL_TAGGER,
got_object_tag_get_tagger(tag),
- (long long)got_object_tag_get_tagger_time(tag));
+ (long long)got_object_tag_get_tagger_time(tag),
+ gmtoff);
tagmsg = got_object_tag_get_message(tag);
fprintf(outfile, "messagelen %zd\n", strlen(tagmsg));
blob - 0c5c8ea1db1ca05c383570fdf3d063cbf5825f73
blob + 332aac7daf0b874612728683bc951e0b30605f86
--- regress/cmdline/cat.sh
+++ regress/cmdline/cat.sh
local testroot=`test_init cat_basic`
local commit_id=`git_show_head $testroot/repo`
local author_time=`git_show_author_time $testroot/repo`
+ local gmtoff=`date +%z`
local alpha_id=`got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1`
local gamma_id=`got tree -r $testroot/repo -i | grep 'gamma/$' | cut -d' ' -f 1`
local delta_id=`got tree -r $testroot/repo -i gamma | grep 'delta$' | cut -d' ' -f 1`
git_show_tree $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
echo "numparents 0" >> $testroot/stdout.expected
- echo "author $GOT_AUTHOR $author_time +0000" >> $testroot/stdout.expected
- echo "committer $GOT_AUTHOR $author_time +0000" \
+ echo "author $GOT_AUTHOR $author_time $gmtoff" >> $testroot/stdout.expected
+ echo "committer $GOT_AUTHOR $author_time $gmtoff" \
>> $testroot/stdout.expected
echo "messagelen 22" >> $testroot/stdout.expected
printf "\nadding the test tree\n" >> $testroot/stdout.expected
local testroot=`test_init cat_submodule_of_same_repo`
local commit_id0=`git_show_head $testroot/repo`
local author_time=`git_show_author_time $testroot/repo`
+ local gmtoff=`date +%z`
(cd $testroot && git clone -q repo repo2 >/dev/null)
(cd $testroot/repo && git submodule -q add ../repo2)
# because a commit with the same ID exists in the outer repository
got cat -r $testroot/repo $commit_id0 | grep ^tree > $testroot/stdout.expected
echo "numparents 0" >> $testroot/stdout.expected
- echo "author $GOT_AUTHOR $author_time +0000" >> $testroot/stdout.expected
- echo "committer $GOT_AUTHOR $author_time +0000" \
+ echo "author $GOT_AUTHOR $author_time $gmtoff" >> $testroot/stdout.expected
+ echo "committer $GOT_AUTHOR $author_time $gmtoff" \
>> $testroot/stdout.expected
echo "messagelen 22" >> $testroot/stdout.expected
printf "\nadding the test tree\n" >> $testroot/stdout.expected