debug-manager: use g_spawn_sync() instead of fork() and waitpid()
[anjuta.git] / plugins / git / git-pull-command.c
blobdfe5ed916c5a2f776564984a4fff745fcc51849b
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
5 *
6 * anjuta is free software.
7 *
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
11 * any later version.
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "git-pull-command.h"
27 struct _GitPullCommandPriv
29 gchar *url;
30 gboolean rebase;
31 gboolean no_commit;
32 gboolean squash;
33 gboolean commit_fast_forward;
34 gboolean append_fetch_data;
35 gboolean force;
36 gboolean no_follow_tags;
39 G_DEFINE_TYPE (GitPullCommand, git_pull_command, GIT_TYPE_COMMAND);
41 static void
42 git_pull_command_init (GitPullCommand *self)
44 self->priv = g_new0 (GitPullCommandPriv, 1);
45 git_command_set_check_passwd_prompt (GIT_COMMAND (self), TRUE);
48 static void
49 git_pull_command_finalize (GObject *object)
51 GitPullCommand *self;
53 self = GIT_PULL_COMMAND (object);
55 g_free (self->priv->url);
56 g_free (self->priv);
58 G_OBJECT_CLASS (git_pull_command_parent_class)->finalize (object);
61 static guint
62 git_pull_command_run (AnjutaCommand *command)
64 GitPullCommand *self;
66 self = GIT_PULL_COMMAND (command);
68 git_command_add_arg (GIT_COMMAND (command), "pull");
70 if (self->priv->rebase)
71 git_command_add_arg (GIT_COMMAND (command), "--rebase");
73 if (self->priv->no_commit)
74 git_command_add_arg (GIT_COMMAND (command), "--no-commit");
76 if (self->priv->squash)
77 git_command_add_arg (GIT_COMMAND (command), "--squash");
79 if (self->priv->commit_fast_forward)
80 git_command_add_arg (GIT_COMMAND (command), "--no-ff");
82 if (self->priv->append_fetch_data)
83 git_command_add_arg (GIT_COMMAND (command), "-a");
85 if (self->priv->force)
86 git_command_add_arg (GIT_COMMAND (command), "-f");
88 if (self->priv->no_follow_tags)
89 git_command_add_arg (GIT_COMMAND (command), "--no-tags");
91 git_command_add_arg (GIT_COMMAND (command), self->priv->url);
93 return 0;
96 static void
97 git_pull_command_class_init (GitPullCommandClass *klass)
99 GObjectClass* object_class = G_OBJECT_CLASS (klass);
100 GitCommandClass* parent_class = GIT_COMMAND_CLASS (klass);
101 AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass);
103 object_class->finalize = git_pull_command_finalize;
104 parent_class->output_handler = git_command_send_output_to_info;
105 command_class->run = git_pull_command_run;
109 GitPullCommand *
110 git_pull_command_new (const gchar *working_directory,
111 const gchar *url,
112 gboolean rebase,
113 gboolean no_commit, gboolean squash,
114 gboolean commit_fast_forward,
115 gboolean append_fetch_data,
116 gboolean force, gboolean no_follow_tags)
118 GitPullCommand *self;
120 self = g_object_new (GIT_TYPE_PULL_COMMAND,
121 "working-directory", working_directory,
122 "single-line-output", TRUE,
123 NULL);
125 self->priv->url = g_strdup (url);
126 self->priv->rebase = rebase;
127 self->priv->no_commit = no_commit;
128 self->priv->squash = squash;
129 self->priv->commit_fast_forward = commit_fast_forward;
130 self->priv->append_fetch_data = append_fetch_data;
131 self->priv->force = force;
132 self->priv->no_follow_tags = no_follow_tags;
134 return self;