GDateTime *now = g_date_time_new_now_utc ();
timestamp = g_date_time_to_unix (now);
g_date_time_unref (now);
+
+ if (!ostree_repo_write_commit (repo, parent, opt_subject, opt_body, metadata,
+ OSTREE_REPO_FILE (root),
+ &commit_checksum, cancellable, error))
+ goto out;
}
else
{
goto out;
}
timestamp = ts.tv_sec;
- }
- if (!ostree_repo_write_commit_with_time (repo, parent, opt_subject, opt_body, metadata,
- OSTREE_REPO_FILE (root),
- timestamp,
- &commit_checksum, cancellable, error))
- goto out;
+ if (!ostree_repo_write_commit_with_time (repo, parent, opt_subject, opt_body, metadata,
+ OSTREE_REPO_FILE (root),
+ timestamp,
+ &commit_checksum, cancellable, error))
+ goto out;
+ }
if (detached_metadata)
{
#include "config.h"
+#include <err.h>
+
#include "ot-dump.h"
#include "otutil.h"
#include "ot-admin-functions.h"
}
static gchar *
-format_timestamp (guint64 timestamp)
+format_timestamp (guint64 timestamp,
+ GError **error)
{
GDateTime *dt;
gchar *str;
dt = g_date_time_new_from_unix_utc (timestamp);
if (dt == NULL)
- return NULL;
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
+ "Invalid timestamp: %" G_GUINT64_FORMAT, timestamp);
+ return NULL;
+ }
str = g_date_time_format (dt, "%Y-%m-%d %H:%M:%S +0000");
g_date_time_unref (dt);
guint64 timestamp;
g_autofree char *str = NULL;
g_autofree char *version = NULL;
+ g_autoptr(GError) local_error = NULL;
/* See OSTREE_COMMIT_GVARIANT_FORMAT */
g_variant_get (variant, "(a{sv}aya(say)&s&stayay)", NULL, NULL, NULL,
&subject, &body, ×tamp, NULL, NULL);
timestamp = GUINT64_FROM_BE (timestamp);
- str = format_timestamp (timestamp);
- if (str)
- g_print ("Date: %s\n", str);
+ str = format_timestamp (timestamp, &local_error);
+ if (!str)
+ errx (1, "Failed to read commit: %s", local_error->message);
+ g_print ("Date: %s\n", str);
if ((version = ot_admin_checksum_version (variant)))
{