1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2009 <jrliggett@cox.net>
6 * anjuta is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * anjuta is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "git-stash-save-command.h"
22 struct _GitStashSaveCommandPriv
28 G_DEFINE_TYPE (GitStashSaveCommand
, git_stash_save_command
, GIT_TYPE_COMMAND
);
31 git_stash_save_command_init (GitStashSaveCommand
*self
)
33 self
->priv
= g_new0 (GitStashSaveCommandPriv
, 1);
37 git_stash_save_command_finalize (GObject
*object
)
39 GitStashSaveCommand
*self
;
41 self
= GIT_STASH_SAVE_COMMAND (object
);
43 g_free (self
->priv
->message
);
46 G_OBJECT_CLASS (git_stash_save_command_parent_class
)->finalize (object
);
50 git_stash_save_command_run (AnjutaCommand
*command
)
52 GitStashSaveCommand
*self
;
54 self
= GIT_STASH_SAVE_COMMAND (command
);
56 git_command_add_arg (GIT_COMMAND (command
), "stash");
57 git_command_add_arg (GIT_COMMAND (command
), "save");
59 if (self
->priv
->keep_index
)
60 git_command_add_arg (GIT_COMMAND (command
), "--keep-index");
62 if (self
->priv
->message
)
63 git_command_add_arg (GIT_COMMAND (command
), self
->priv
->message
);
69 git_stash_save_command_class_init (GitStashSaveCommandClass
*klass
)
71 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
72 GitCommandClass
* parent_class
= GIT_COMMAND_CLASS (klass
);
73 AnjutaCommandClass
*command_class
= ANJUTA_COMMAND_CLASS (klass
);
75 object_class
->finalize
= git_stash_save_command_finalize
;
76 parent_class
->output_handler
= git_command_send_output_to_info
;
77 command_class
->run
= git_stash_save_command_run
;
82 git_stash_save_command_new (const gchar
*working_directory
,
83 gboolean keep_index
, const gchar
*message
)
85 GitStashSaveCommand
*self
;
87 self
= g_object_new (GIT_TYPE_STASH_SAVE_COMMAND
,
88 "working-directory", working_directory
,
89 "single-line-output", TRUE
,
92 self
->priv
->keep_index
= keep_index
;
93 self
->priv
->message
= g_strdup (message
);