当前位置: 首页 > 工具软件 > Gnome-gmail > 使用案例 >

gnome-logs开发记录2--合并git的多个commit--Gnome开发记录

司寇祖鹤
2023-12-01

经过这半个多月的工作,今天终于算是搞定了这个bug。于是按照gnome love的tutorial中的submitting patches的文章,生成了patch,并且提交到了bugzilla。可是毕竟是自己第一次参与gnome开发,自己的想法和实现也有一点差错。于是David King就回复了改进建议,如下:

The catalog parsing does not quite seem to cover what is specified in the
documentation:

http://www.freedesktop.org/wiki/Software/systemd/catalog/

Each header field can appear multiple times. You handle 2 documentation
headers, but there could be 0, 1, 2, or more. The order of header fields is not
specified, so you need to investigate if the fields can appear in different
orders.

Other than that, and the other comments, this looks good!

::: src/gl-eventviewdetail.c
@@ +278,3 @@
 {
     GlEventViewDetail *detail = GL_EVENT_VIEW_DETAIL (object);
+    

The seems like an unnecessary whitespace change, and should be removed.

::: src/gl-journal.c
@@ +245,2 @@
     ret = sd_journal_get_catalog (journal, &result->catalog);
+    

This looks like an unnecessary whitespace change, and should be removed.

::: src/gl-journal.h
@@ +69,3 @@
+    gchar *documentation1;
+    gchar *documentation2;
+    gchar *detailed_message;

It does not make much sense to add fields to the GlJournalResult struct if the
GlJournal API does not use them.

这里主要有三点,一是没有考虑各个field出现的顺序可能不定,二是没有考虑每一个field都可能出现0,1,2甚至更多次,三是结构体GlJournalResult中的subject的使用等没有必要。经过一番修改后,就又使用了同样的步骤生成了patch,提交到了bugzilla。

不过,这一次又出问题了,主要是出在Gedit的Use spaces for tabs这一设置上。我之前没有勾选,所以一百多行的缩进都要重新来弄。主要还是自己没有这方面的概念,不知道这个这么重要。

You should squash this patch into your previous patch, so that there is only a
single patch to apply.

There is also lots of indentation, and you should make sure that you are not
using tabs for indentation, as well as matching the indentation of surrounding
code.

Using g_strlcat() seems weird, and it is probably better to just use
g_strconcat().

::: data/gl-eventviewdetail.ui
@@ +188,3 @@
                 </child>
+                <child>
+                    <object class="GtkLabel" id="subject_field_label">

Strange indentation here, and throughout the remainder of the file.

::: src/gl-eventviewdetail.c
@@ +155,3 @@
+            {
+                str = " ";
+                str_field = strtok (str_copy, str);

There is no need to use a separate variable for the second argument to
strtok(), just use a string literal instead.

@@ +156,3 @@
+                str = " ";
+                str_field = strtok (str_copy, str);
+            }

Odd indentation again.

@@ +166,2 @@
             {
+                subject_count ++;

No space needed before the ++.

@@ +172,3 @@
+                    
+                    if (str_message && *str_message)
+                    {

Strange indentation.

@@ +180,3 @@
+                else
+                {
+                    str = "\n";

Odd indentation.

@@ +183,3 @@
+                    str_field = strtok (NULL, str);
+                    str_temp = gtk_label_get_text (GTK_LABEL
(priv->subject_label));
+                    str = g_strdup (str_temp);

There is no need for a separate variable here, just call g_strdup() on the
label text directly.

@@ +188,3 @@
+                    
+                    if (str && *str)
+                    {

Indentation.

@@ +206,3 @@
+                    
+                    if (str_message && *str_message)
+                    {

Odd indentation.

@@ +217,3 @@
+                    str_field = strtok (NULL, str);
+                    str_temp = gtk_label_get_text (GTK_LABEL
(priv->definedby_label));
+                    str = g_strdup (str_temp);

Strange indentation.

@@ +222,3 @@
+                    
+                    if (str && *str)
+                    {

Weird indentation.

@@ +244,3 @@
+                        gtk_widget_show (priv->support_field_label);
+                        gtk_widget_show (priv->support_label);
+                    }

Weird indentation.

@@ +251,3 @@
+                    str_field = strtok (NULL, str);
+                    str_temp = gtk_label_get_text (GTK_LABEL
(priv->support_label));
+                    str = g_strdup (str_temp);

Indentation.

@@ +274,3 @@
+                    
+                    if (str_message && *str_message)
+                    {

Indentation.

@@ +282,3 @@
+                else
+                {
+                    str = "\n";

Strange indentation.

@@ +290,3 @@
+                    
+                    if (str && *str)
+                    {

Odd indentation.

::: src/gl-journal.h
@@ +20,3 @@
 #define GL_JOURNAL_H_

+#include <gtk/gtk.h>

This looks like an unnecessary change.

squash, 怎么做? 不会啊。 不过通过email和David King交流,在这个链接找到了答案。

http://www.git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits

Squashing Commits

It’s also possible to take a series of commits and squash them down into a single commit with the interactive rebasing tool. The script puts helpful instructions in the rebase message:

git rebase -i

#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

If, instead of "pick" or "edit", you specify "squash", Git applies both that change and the change directly before it and makes you merge the commit messages together. So, if you want to make a single commit from these three commits, you make the script look like this:

pick f7f3f6d changed my name a bit
squash 310154e updated README formatting and added blame
squash a5f4a0d added cat-file

When you save and exit the editor, Git applies all three changes and then puts you back into the editor to merge the three commit messages:

# This is a combination of 3 commits.
# The first commit's message is:
changed my name a bit

# This is the 2nd commit message:

updated README formatting and added blame

# This is the 3rd commit message:

added cat-file

When you save that, you have a single commit that introduces the changes of all three previous commits.


下面大概总结以下:

git rebase -i进入编辑模式

在编辑模式中会显示你的commits 我一共又三个commit。想要合并它们,第一个pick不改,将第二个和第三个改成squash。保存退出,然后修改以下commit的信息。保存退出之后,就搞定了。

使用git format-patch HEAD^命令来生成patch。

现在patch提交到了bugzilla,刚刚寝室断电,一会儿需要把掉交换机上的网线插到电脑上来发表这篇blog了。之后在用手机通过gmail查看下关于这个bug的最新进展。

转载于:https://my.oschina.net/qingtingfengchui/blog/411008

 类似资料: