summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-diff.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2012-01-08 14:20:07 -0500
committerColin Walters <walters@verbum.org>2012-01-08 14:20:07 -0500
commit888d33c9431a070cbdb7e760955f26b84fa5d719 (patch)
treee9de935795067fec2118550a2a964973d29b0b65 /src/ostree/ot-builtin-diff.c
parente21b181b4a688409c4b86db249e1f95326312477 (diff)
downloadostree-888d33c9431a070cbdb7e760955f26b84fa5d719.tar.gz
core: Make diff accept one argument too to mean "foo^ foo"
Diffstat (limited to 'src/ostree/ot-builtin-diff.c')
-rw-r--r--src/ostree/ot-builtin-diff.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/ostree/ot-builtin-diff.c b/src/ostree/ot-builtin-diff.c
index c669aeac..c11605f9 100644
--- a/src/ostree/ot-builtin-diff.c
+++ b/src/ostree/ot-builtin-diff.c
@@ -67,6 +67,7 @@ ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error)
GOptionContext *context;
gboolean ret = FALSE;
OstreeRepo *repo = NULL;
+ char *src_prev = NULL;
const char *src;
const char *target;
GFile *srcf = NULL;
@@ -87,18 +88,27 @@ ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error)
if (!ostree_repo_check (repo, error))
goto out;
- if (argc < 3)
+ if (argc < 2)
{
gchar *help = g_option_context_get_help (context, TRUE, NULL);
g_printerr ("%s\n", help);
g_free (help);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "REV and TARGETDIR must be specified");
+ "REV must be specified");
goto out;
}
- src = argv[1];
- target = argv[2];
+ if (argc == 2)
+ {
+ src_prev = g_strconcat (argv[1], "^", NULL);
+ src = src_prev;
+ target = argv[1];
+ }
+ else
+ {
+ src = argv[1];
+ target = argv[2];
+ }
cwd = ot_gfile_new_for_path (".");
@@ -135,6 +145,7 @@ ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error)
ret = TRUE;
out:
+ g_free (src_prev);
g_clear_object (&repo);
g_clear_object (&cwd);
g_clear_object (&srcf);