1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3
* Copyright (C) 2007 Imendio AB
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License as
7
* published by the Free Software Foundation; either version 2 of the
8
* License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* General Public License for more details.
15
* You should have received a copy of the GNU General Public
16
* License along with this program; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
23
#include "giggle-git-commit.h"
25
typedef struct GiggleGitCommitPriv GiggleGitCommitPriv;
27
struct GiggleGitCommitPriv {
32
static void git_commit_finalize (GObject *object);
33
static void git_commit_get_property (GObject *object,
37
static void git_commit_set_property (GObject *object,
42
static gboolean git_commit_get_command_line (GiggleJob *job,
43
gchar **command_line);
46
G_DEFINE_TYPE (GiggleGitCommit, giggle_git_commit, GIGGLE_TYPE_JOB)
48
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIGGLE_TYPE_GIT_COMMIT, GiggleGitCommitPriv))
57
giggle_git_commit_class_init (GiggleGitCommitClass *class)
59
GObjectClass *object_class = G_OBJECT_CLASS (class);
60
GiggleJobClass *job_class = GIGGLE_JOB_CLASS (class);
62
object_class->finalize = git_commit_finalize;
63
object_class->get_property = git_commit_get_property;
64
object_class->set_property = git_commit_set_property;
66
job_class->get_command_line = git_commit_get_command_line;
68
g_object_class_install_property (object_class,
70
g_param_spec_pointer ("files",
72
"List of files to commit",
74
g_object_class_install_property (object_class,
76
g_param_spec_string ("log",
78
"Log for the changeset",
82
g_type_class_add_private (object_class, sizeof (GiggleGitCommitPriv));
86
giggle_git_commit_init (GiggleGitCommit *dummy)
91
git_commit_finalize (GObject *object)
93
GiggleGitCommitPriv *priv;
95
priv = GET_PRIV (object);
99
g_list_foreach (priv->files, (GFunc) g_free, NULL);
100
g_list_free (priv->files);
102
G_OBJECT_CLASS (giggle_git_commit_parent_class)->finalize (object);
106
git_commit_get_property (GObject *object,
111
GiggleGitCommitPriv *priv;
113
priv = GET_PRIV (object);
117
g_value_set_pointer (value, priv->files);
120
g_value_set_string (value, priv->log);
123
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
129
git_commit_set_property (GObject *object,
134
GiggleGitCommitPriv *priv;
136
priv = GET_PRIV (object);
140
priv->files = g_value_get_pointer (value);
143
priv->log = g_value_dup_string (value);
146
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
152
git_commit_get_command_line (GiggleJob *job, gchar **command_line)
154
GiggleGitCommitPriv *priv;
159
priv = GET_PRIV (job);
161
str = g_string_new (GIT_COMMAND " commit");
164
escaped = g_strescape (priv->log, "\b\f\n\r\t\\");
166
escaped = g_strdup ("");
169
g_string_append_printf (str, " -m \"%s\"", escaped);
172
g_string_append_printf (str, " -a");
175
g_string_append_printf (str, " %s", (gchar *) files->data);
180
*command_line = g_string_free (str, FALSE);
185
giggle_git_commit_new (const gchar *log)
187
return g_object_new (GIGGLE_TYPE_GIT_COMMIT,
193
giggle_git_commit_set_files (GiggleGitCommit *commit,
196
g_return_if_fail (GIGGLE_IS_GIT_COMMIT (commit));
198
g_object_set (commit,