[ostree] config-diff: Properly print files relative to root
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] config-diff: Properly print files relative to root
- Date: Tue, 12 Mar 2013 17:34:12 +0000 (UTC)
commit ae3945210c5b420f40632cf5f05bd6d6ea898813
Author: Colin Walters <walters verbum org>
Date: Tue Mar 12 08:47:11 2013 -0400
config-diff: Properly print files relative to root
Just less ugly.
src/libostree/ostree-diff.c | 34 ++++++++++++++++++++++------------
src/libostree/ostree-diff.h | 3 ++-
src/ostree/ot-admin-builtin-diff.c | 2 +-
src/ostree/ot-builtin-diff.c | 2 +-
4 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/src/libostree/ostree-diff.c b/src/libostree/ostree-diff.c
index 94083eb..ccae4ed 100644
--- a/src/libostree/ostree-diff.c
+++ b/src/libostree/ostree-diff.c
@@ -367,8 +367,25 @@ ostree_diff_dirs (GFile *a,
return ret;
}
+static void
+print_diff_item (char prefix,
+ GFile *base,
+ GFile *file)
+{
+ if (g_file_is_native (file))
+ {
+ gs_free char *relpath = g_file_get_relative_path (base, file);
+ g_print ("%c %s\n", prefix, relpath);
+ }
+ else
+ {
+ g_print ("%c %s\n", prefix, gs_file_get_path_cached (file));
+ }
+}
+
void
-ostree_diff_print (GFile *base,
+ostree_diff_print (GFile *a,
+ GFile *b,
GPtrArray *modified,
GPtrArray *removed,
GPtrArray *added)
@@ -378,23 +395,16 @@ ostree_diff_print (GFile *base,
for (i = 0; i < modified->len; i++)
{
OstreeDiffItem *diff = modified->pdata[i];
- g_print ("M %s\n", gs_file_get_path_cached (diff->src));
+ print_diff_item ('M', a, diff->src);
}
for (i = 0; i < removed->len; i++)
{
- g_print ("D %s\n", gs_file_get_path_cached (removed->pdata[i]));
+ GFile *removed_file = removed->pdata[i];
+ print_diff_item ('D', a, removed_file);
}
for (i = 0; i < added->len; i++)
{
GFile *added_f = added->pdata[i];
- if (g_file_is_native (added_f))
- {
- char *relpath = g_file_get_relative_path (base, added_f);
- g_assert (relpath != NULL);
- g_print ("A /%s\n", relpath);
- g_free (relpath);
- }
- else
- g_print ("A %s\n", gs_file_get_path_cached (added_f));
+ print_diff_item ('A', b, added_f);
}
}
diff --git a/src/libostree/ostree-diff.h b/src/libostree/ostree-diff.h
index 5784ce4..ba6d63f 100644
--- a/src/libostree/ostree-diff.h
+++ b/src/libostree/ostree-diff.h
@@ -54,7 +54,8 @@ gboolean ostree_diff_dirs (GFile *a,
GCancellable *cancellable,
GError **error);
-void ostree_diff_print (GFile *base,
+void ostree_diff_print (GFile *a,
+ GFile *b,
GPtrArray *modified,
GPtrArray *removed,
GPtrArray *added);
diff --git a/src/ostree/ot-admin-builtin-diff.c b/src/ostree/ot-admin-builtin-diff.c
index af2b288..7792db3 100644
--- a/src/ostree/ot-admin-builtin-diff.c
+++ b/src/ostree/ot-admin-builtin-diff.c
@@ -96,7 +96,7 @@ ot_admin_builtin_diff (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GE
cancellable, error))
goto out;
- ostree_diff_print (new_etc_path, modified, removed, added);
+ ostree_diff_print (orig_etc_path, new_etc_path, modified, removed, added);
ret = TRUE;
out:
diff --git a/src/ostree/ot-builtin-diff.c b/src/ostree/ot-builtin-diff.c
index d3bd17c..daa544e 100644
--- a/src/ostree/ot-builtin-diff.c
+++ b/src/ostree/ot-builtin-diff.c
@@ -122,7 +122,7 @@ ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error)
if (!ostree_diff_dirs (srcf, targetf, modified, removed, added, cancellable, error))
goto out;
- ostree_diff_print (targetf, modified, removed, added);
+ ostree_diff_print (srcf, targetf, modified, removed, added);
ret = TRUE;
out:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]