[geany/geany-plugins] faf471: Merge pull request #1026 from nomadbyte/geanyvc/837-commit-stsmsg

Frank Lanitz git-noreply at xxxxx
Wed Sep 29 17:35:33 UTC 2021


Branch:      refs/heads/master
Author:      Frank Lanitz <frank at frank.uvena.de>
Committer:   GitHub <noreply at github.com>
Date:        Wed, 29 Sep 2021 17:35:33 UTC
Commit:      faf471271a9785bfd43f84370afc7baae9a9872b
             https://github.com/geany/geany-plugins/commit/faf471271a9785bfd43f84370afc7baae9a9872b

Log Message:
-----------
Merge pull request #1026 from nomadbyte/geanyvc/837-commit-stsmsg

GeanyVC: Report a completion status of the commit command


Modified Paths:
--------------
    geanyvc/src/geanyvc.c
    geanyvc/src/vc_git.c

Modified: geanyvc/src/geanyvc.c
28 lines changed, 27 insertions(+), 1 deletions(-)
===================================================================
@@ -591,6 +591,12 @@ execute_command(const VC_RECORD * vc, gchar ** std_out, gchar ** std_err, const
 	return ret;
 }
 
+static gint
+get_command_exit_status(gint exit_code)
+{
+	return (SPAWN_WIFEXITED(exit_code) ? SPAWN_WEXITSTATUS(exit_code) : exit_code);
+}
+
 /* Callback if menu item for a single file was activated */
 static void
 vcdiff_file_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata)
@@ -1800,8 +1806,28 @@ vccommit_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer
 		gtk_tree_model_foreach(model, get_commit_files_foreach, &selected_files);
 		if (!EMPTY(message) && selected_files)
 		{
-			execute_command(vc, NULL, NULL, dir, VC_COMMAND_COMMIT, selected_files,
+			gchar *err_output = NULL;
+			gint exit_code;
+
+			exit_code = execute_command(vc, NULL, &err_output, dir, VC_COMMAND_COMMIT, selected_files,
 					message);
+
+			if (err_output)
+			{
+				gint status = get_command_exit_status(exit_code);
+
+				/* - log the commit error (may be a very long message) into the Message Window
+				   - overwrite the status bar with a more concise message
+				*/
+				g_warning("geanyvc: vccommit_activated: Commit failed (status:%d).", status);
+				ui_set_statusbar(TRUE, _("Commit failed (status: %d, error: %s)."), status, err_output);
+				ui_set_statusbar(FALSE, _("Commit failed; see status in the Message window."));
+				g_free(err_output);
+			}
+			else
+			{
+				ui_set_statusbar(FALSE, _("Changes committed."));
+			}
 			free_text_list(selected_files);
 		}
 		g_free(message);


Modified: geanyvc/src/vc_git.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -49,7 +49,7 @@ git_commit(G_GNUC_UNUSED gchar ** std_out, G_GNUC_UNUSED gchar ** std_err, const
 		commit = g_slist_prepend(commit, (gchar *) tmp->data + len + 1);
 	}
 
-	ret = execute_custom_command(base_dir, argv, NULL, NULL, NULL, base_dir, commit, message);
+	ret = execute_custom_command(base_dir, argv, NULL, NULL, std_err, base_dir, commit, message);
 	g_slist_free(commit);
 	g_free(base_dir);
 	return ret;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list