[ostree] core: Make diff accept one argument too to mean "foo^ foo"
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Make diff accept one argument too to mean "foo^ foo"
- Date: Sun, 8 Jan 2012 19:21:33 +0000 (UTC)
commit 888d33c9431a070cbdb7e760955f26b84fa5d719
Author: Colin Walters <walters verbum org>
Date: Sun Jan 8 14:20:07 2012 -0500
core: Make diff accept one argument too to mean "foo^ foo"
src/ostree/ot-builtin-diff.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/ostree/ot-builtin-diff.c b/src/ostree/ot-builtin-diff.c
index c669aea..c11605f 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]