Don't default to "master", require a branch
It doesn't really make sense to have a default branch, since we expect people to have multiple roots. Thus, require a branch specification always.
This commit is contained in:
1 parent
d145b0426c
commit
ee4edf114b
15 files changed
+105
-45
No files matched your search
+21
-15
@@ -1452,15 +1452,16 @@ import_root (OstreeRepo *self,
|
||||
|
||||
gboolean
|
||||
ostree_repo_commit (OstreeRepo *self,
|
||||
const char *branch,
|
||||
const char *subject,
|
||||
const char *body,
|
||||
GVariant *metadata,
|
||||
const char *base,
|
||||
GPtrArray *modified_files,
|
||||
GPtrArray *removed_files,
|
||||
GChecksum **out_commit,
|
||||
GError **error)
|
||||
const char *branch,
|
||||
const char *parent,
|
||||
const char *subject,
|
||||
const char *body,
|
||||
GVariant *metadata,
|
||||
const char *base,
|
||||
GPtrArray *modified_files,
|
||||
GPtrArray *removed_files,
|
||||
GChecksum **out_commit,
|
||||
GError **error)
|
||||
{
|
||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||
gboolean ret = FALSE;
|
||||
@@ -1473,11 +1474,13 @@ ostree_repo_commit (OstreeRepo *self,
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
g_return_val_if_fail (priv->inited, FALSE);
|
||||
g_return_val_if_fail (branch != NULL, FALSE);
|
||||
g_return_val_if_fail (subject != NULL, FALSE);
|
||||
|
||||
if (branch == NULL)
|
||||
branch = "master";
|
||||
if (parent == NULL)
|
||||
parent = branch;
|
||||
|
||||
if (!resolve_rev (self, branch, TRUE, ¤t_head, error))
|
||||
if (!resolve_rev (self, parent, TRUE, ¤t_head, error))
|
||||
goto out;
|
||||
|
||||
if (current_head)
|
||||
@@ -1529,6 +1532,7 @@ ostree_repo_commit (OstreeRepo *self,
|
||||
gboolean
|
||||
ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
||||
const char *branch,
|
||||
const char *parent,
|
||||
const char *subject,
|
||||
const char *body,
|
||||
GVariant *metadata,
|
||||
@@ -1553,15 +1557,17 @@ ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
g_return_val_if_fail (priv->inited, FALSE);
|
||||
g_return_val_if_fail (branch != NULL, FALSE);
|
||||
g_return_val_if_fail (subject != NULL, FALSE);
|
||||
|
||||
if (branch == NULL)
|
||||
branch = "master";
|
||||
if (parent == NULL)
|
||||
parent = branch;
|
||||
|
||||
/* We're overwriting the tree */
|
||||
if (!import_root (self, base, &root, error))
|
||||
goto out;
|
||||
|
||||
if (!resolve_rev (self, branch, TRUE, ¤t_head, error))
|
||||
if (!resolve_rev (self, parent, TRUE, ¤t_head, error))
|
||||
goto out;
|
||||
|
||||
in = (GUnixInputStream*)g_unix_input_stream_new (fd, FALSE);
|
||||
|
||||
@@ -70,8 +70,9 @@ gboolean ostree_repo_load_variant (OstreeRepo *self,
|
||||
GVariant **out_variant,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_repo_commit (OstreeRepo *self,
|
||||
gboolean ostree_repo_commit (OstreeRepo *self,
|
||||
const char *branch,
|
||||
const char *parent,
|
||||
const char *subject,
|
||||
const char *body,
|
||||
GVariant *metadata,
|
||||
@@ -81,8 +82,9 @@ gboolean ostree_repo_commit (OstreeRepo *self,
|
||||
GChecksum **out_commit,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
||||
gboolean ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
||||
const char *branch,
|
||||
const char *parent,
|
||||
const char *subject,
|
||||
const char *body,
|
||||
GVariant *metadata,
|
||||
|
||||
+11
-2
@@ -33,6 +33,7 @@ static gboolean from_stdin;
|
||||
static char *from_file;
|
||||
static char *subject;
|
||||
static char *body;
|
||||
static char *parent;
|
||||
static char *branch;
|
||||
static char **additions;
|
||||
static char **removals;
|
||||
@@ -42,6 +43,7 @@ static GOptionEntry options[] = {
|
||||
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
|
||||
{ "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
|
||||
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" },
|
||||
{ "parent", 'p', 0, G_OPTION_ARG_STRING, &parent, "Parent commit", "commit" },
|
||||
{ "from-fd", 0, 0, G_OPTION_ARG_INT, &from_fd, "Read new tree files from fd", "file descriptor" },
|
||||
{ "from-stdin", 0, 0, G_OPTION_ARG_NONE, &from_stdin, "Read new tree files from stdin", "file descriptor" },
|
||||
{ "from-file", 0, 0, G_OPTION_ARG_FILENAME, &from_file, "Read new tree files from another file", "path" },
|
||||
@@ -95,6 +97,13 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!branch)
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"A branch must be specified with --branch");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!subject)
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
@@ -115,7 +124,7 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
|
||||
for (iter = removals; *iter; iter++)
|
||||
g_ptr_array_add (removals_array, *iter);
|
||||
|
||||
if (!ostree_repo_commit (repo, branch, subject, body, NULL,
|
||||
if (!ostree_repo_commit (repo, branch, parent, subject, body, NULL,
|
||||
prefix, additions_array,
|
||||
removals_array,
|
||||
&commit_checksum,
|
||||
@@ -139,7 +148,7 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
|
||||
}
|
||||
from_fd = temp_fd;
|
||||
}
|
||||
if (!ostree_repo_commit_from_filelist_fd (repo, branch, subject, body, NULL,
|
||||
if (!ostree_repo_commit_from_filelist_fd (repo, branch, parent, subject, body, NULL,
|
||||
prefix, from_fd, separator,
|
||||
&commit_checksum, error))
|
||||
{
|
||||
|
||||
@@ -40,8 +40,8 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
|
||||
gboolean ret = FALSE;
|
||||
OstreeRepo *repo = NULL;
|
||||
GOutputStream *pager = NULL;
|
||||
const char *rev;
|
||||
GVariant *commit = NULL;
|
||||
const char *rev = "master";
|
||||
char *resolved_rev;
|
||||
|
||||
context = g_option_context_new ("- Show revision log");
|
||||
@@ -55,8 +55,14 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
|
||||
if (prefix == NULL)
|
||||
prefix = ".";
|
||||
|
||||
if (argc > 1)
|
||||
rev = argv[1];
|
||||
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))
|
||||
|
||||
Reference in new issue
Block a user