mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-26 14:04:12 +03:00
main: Drop log builtin
We may revive this later, but commits in their current form aren't very useful for humans to read, so it doesn't make sense to have a tool to show a history of useless stuff. More interesting things are diffs between commits, object statistics, etc.
This commit is contained in:
parent
ea914e7e49
commit
3b9da094d8
@ -31,7 +31,6 @@ ostree_SOURCES = src/ostree/main.c \
|
||||
src/ostree/ot-builtin-fsck.c \
|
||||
src/ostree/ot-builtin-init.c \
|
||||
src/ostree/ot-builtin-pull-local.c \
|
||||
src/ostree/ot-builtin-log.c \
|
||||
src/ostree/ot-builtin-ls.c \
|
||||
src/ostree/ot-builtin-prune.c \
|
||||
src/ostree/ot-builtin-refs.c \
|
||||
|
@ -23,7 +23,6 @@ insttestdir=$(pkglibexecdir)/installed-tests
|
||||
testfiles = test-basic \
|
||||
test-archive \
|
||||
test-archivez \
|
||||
test-log \
|
||||
test-remote-add \
|
||||
test-corruption \
|
||||
test-libarchive \
|
||||
|
@ -36,46 +36,6 @@
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
|
||||
gboolean
|
||||
ot_util_spawn_pager (GOutputStream **out_stream,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
const char *pager;
|
||||
char *argv[2];
|
||||
int stdin_fd;
|
||||
pid_t pid;
|
||||
gs_free GOutputStream *ret_stream = NULL;
|
||||
|
||||
if (!isatty (1))
|
||||
{
|
||||
ret_stream = (GOutputStream*)g_unix_output_stream_new (1, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
pager = g_getenv ("GIT_PAGER");
|
||||
if (pager == NULL)
|
||||
pager = "less";
|
||||
|
||||
argv[0] = (char*)pager;
|
||||
argv[1] = NULL;
|
||||
|
||||
if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
NULL, NULL, &pid, &stdin_fd, NULL, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "%s", "Failed to spawn pager: ");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret_stream = (GOutputStream*)g_unix_output_stream_new (stdin_fd, TRUE);
|
||||
}
|
||||
|
||||
ot_transfer_out_value(out_stream, &ret_stream);
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ot_util_filename_validate (const char *name,
|
||||
GError **error)
|
||||
|
@ -36,8 +36,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean ot_util_spawn_pager (GOutputStream **out_stream, GError **error);
|
||||
|
||||
void ot_util_fatal_literal (const char *msg) G_GNUC_NORETURN;
|
||||
|
||||
void ot_util_fatal_gerror (GError *error) G_GNUC_NORETURN;
|
||||
|
@ -40,7 +40,6 @@ static OstreeCommand commands[] = {
|
||||
{ "diff", ostree_builtin_diff, 0 },
|
||||
{ "fsck", ostree_builtin_fsck, 0 },
|
||||
{ "init", ostree_builtin_init, 0 },
|
||||
{ "log", ostree_builtin_log, 0 },
|
||||
{ "ls", ostree_builtin_ls, 0 },
|
||||
{ "refs", ostree_builtin_refs, 0 },
|
||||
{ "prune", ostree_builtin_prune, 0 },
|
||||
|
@ -1,147 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Colin Walters <walters@verbum.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ot-builtins.h"
|
||||
#include "ostree.h"
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_log (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
const char *rev;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
gs_unref_object GOutputStream *pager = NULL;
|
||||
gs_unref_variant GVariant *commit = NULL;
|
||||
gs_free char *resolved_rev = NULL;
|
||||
|
||||
context = g_option_context_new ("- Show revision log");
|
||||
g_option_context_add_main_entries (context, options, NULL);
|
||||
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"A revision must be specified");
|
||||
goto out;
|
||||
}
|
||||
|
||||
rev = argv[1];
|
||||
|
||||
repo = ostree_repo_new (repo_path);
|
||||
if (!ostree_repo_check (repo, error))
|
||||
goto out;
|
||||
|
||||
if (!ot_util_spawn_pager (&pager, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error))
|
||||
goto out;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
char *formatted = NULL;
|
||||
GVariant *parent_csum_v = NULL;
|
||||
const char *subject;
|
||||
const char *body;
|
||||
guint64 timestamp;
|
||||
GVariant *content_csum_v = NULL;
|
||||
GVariant *metadata_csum_v = NULL;
|
||||
GDateTime *time_obj = NULL;
|
||||
char *formatted_date = NULL;
|
||||
const char *body_newline;
|
||||
gsize bytes_written;
|
||||
GVariant *commit_metadata = NULL;
|
||||
char *formatted_metadata = NULL;
|
||||
|
||||
g_clear_pointer (&commit, (GDestroyNotify) g_variant_unref);
|
||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, resolved_rev, &commit, error))
|
||||
goto out;
|
||||
|
||||
/* Ignore commit metadata for now */
|
||||
g_clear_pointer (&commit_metadata, (GDestroyNotify) g_variant_unref);
|
||||
g_clear_pointer (&parent_csum_v, (GDestroyNotify) g_variant_unref);
|
||||
g_clear_pointer (&content_csum_v, (GDestroyNotify) g_variant_unref);
|
||||
g_clear_pointer (&metadata_csum_v, (GDestroyNotify) g_variant_unref);
|
||||
g_variant_get (commit, "(@a{sv}@ay@a(say)&s&st@ay@ay)",
|
||||
&commit_metadata, &parent_csum_v, NULL, &subject, &body,
|
||||
×tamp, &content_csum_v, &metadata_csum_v);
|
||||
timestamp = GUINT64_FROM_BE (timestamp);
|
||||
time_obj = g_date_time_new_from_unix_utc (timestamp);
|
||||
formatted_date = g_date_time_format (time_obj, "%a %b %d %H:%M:%S %Y %z");
|
||||
g_date_time_unref (time_obj);
|
||||
time_obj = NULL;
|
||||
|
||||
g_clear_pointer (&commit_metadata, (GDestroyNotify) g_variant_unref);
|
||||
formatted = g_strdup_printf ("commit %s\nSubject: %s\nDate: %s\nMetadata: %s\n\n",
|
||||
resolved_rev, subject, formatted_date, formatted_metadata);
|
||||
g_free (formatted_metadata);
|
||||
g_free (formatted_date);
|
||||
formatted_date = NULL;
|
||||
|
||||
if (!g_output_stream_write_all (pager, formatted, strlen (formatted), &bytes_written, NULL, error))
|
||||
{
|
||||
g_free (formatted);
|
||||
goto out;
|
||||
}
|
||||
g_free (formatted);
|
||||
|
||||
body_newline = strchr (body, '\n');
|
||||
do {
|
||||
gsize len;
|
||||
if (!g_output_stream_write_all (pager, " ", 4, &bytes_written, NULL, error))
|
||||
goto out;
|
||||
len = body_newline ? body_newline - body : strlen (body);
|
||||
if (!g_output_stream_write_all (pager, body, len, &bytes_written, NULL, error))
|
||||
goto out;
|
||||
if (!g_output_stream_write_all (pager, "\n\n", 2, &bytes_written, NULL, error))
|
||||
goto out;
|
||||
body_newline = strchr (body, '\n');
|
||||
if (!body_newline)
|
||||
break;
|
||||
else
|
||||
body_newline += 1;
|
||||
} while (*body_newline);
|
||||
|
||||
if (g_variant_n_children (parent_csum_v) == 0)
|
||||
break;
|
||||
g_free (resolved_rev);
|
||||
resolved_rev = ostree_checksum_from_bytes_v (parent_csum_v);
|
||||
}
|
||||
|
||||
if (!g_output_stream_close (pager, NULL, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
}
|
@ -36,7 +36,6 @@ gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GCancella
|
||||
gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
|
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
set -e
|
||||
|
||||
. $(dirname $0)/libtest.sh
|
||||
|
||||
echo "1..1"
|
||||
|
||||
setup_test_repository "bare"
|
||||
$OSTREE log test2 > $test_tmpdir/log.txt
|
||||
assert_file_has_content $test_tmpdir/log.txt "Test Commit 1"
|
||||
assert_file_has_content $test_tmpdir/log.txt "Test Commit 2"
|
||||
echo "ok log"
|
Loading…
x
Reference in New Issue
Block a user