Search code examples
gitgit-diff

git diff commits do not shows all the changed files' difference


When I from master branch merge a branch(wxc):

$ git merge wxc
Merge made by the 'recursive' strategy.
 Q2/__init__.py                                                                |   3 +
 Q2/common/GLOBAL_CONST.py                                                     |   8 +--
 Q2/urls.py                                                                    |   7 ---
 .../admin_productconfig_physicalserver/api/paginations.py"                   |   1 +
 .../admin_productconfig_physicalserver/api/serializers.py"                   |  22 ++++++-
 .../admin_productconfig_physicalserver/api/switch_cmd_util.py"               |  31 +---------
 .../admin_productconfig_physicalserver/api/urls.py"                          |   6 ++
 .../admin_productconfig_physicalserver/api/views.py"                         | 133 +++++++++++++++++++++++++++++++++++++++-
 .../admin_productconfig_physicalserver/migrations/0091_mg.py"                |  34 ++++++++++
 .../admin_productconfig_physicalserver/migrations/0092_mgnumber.py"          |  25 ++++++++
 .../migrations/0093_auto_20190902_1249.py"                                         |  19 ++++++
 .../migrations/0094_merge_20190906_0822.py"                                        |  16 +++++
 .../admin_productconfig_physicalserver/models.py"                            |  61 ++++++++++++++++--
 .../admin_usermanage/api/serializers.py"                                     |   2 +-
 .../admin_usermanage/api/views.py"                                           |   4 +-
 15 files changed, 318 insertions(+), 54 deletions(-)
 create mode 100644 "\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/qiyun_admin_productconfig_physicalserver/migrations/0091_mg.py"
 create mode 100644 "\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/qiyun_admin_productconfig_physicalserver/migrations/0092_mgnumber.py"
 create mode 100644 "\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/qiyun_admin_productconfig_physicalserver/migrations/0093_auto_20190902_1249.py"
 create mode 100644 "\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/qiyun_admin_productconfig_physicalserver/migrations/0094_merge_20190906_0822.py"

You see there are so many files changes, such as the Q2/__init__.py, Q2/common/GLOBAL_CONST.py, Q2/urls.py and so on:

then I check my master brach's latest two logs:

$ git log -n2
commit b63c3856677916f8008b338c139bd3b00c90593d (HEAD -> master)
Merge: 6b59b80 3e85a8d
Author: dale <dale@gmail.com>
Date:   Wed Sep 18 11:28:25 2019 +0800

    Merge branch 'wxc 20190917-wxc'

commit 3e85a8dfd0270f6fb0f3786b8761038df322890f (remote_repo/wxc, wxc)
Author: dale <dale@gmail.com>
Date:   Tue Sep 17 16:04:54 2019 +0800

    '2019-09-17-wxc-01'

I want to compare the latest two commits' difference:

dale-MBP:Q2 ldl$ git diff 3e85a8df b63c3856
diff --git "a/\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/admin_productconfig_physicalserver/api/whmcs/views.py" "b/\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/admin_productconfig_physicalserver/api/whmcs/views.py"
index ccc1ba3..9fac902 100644
--- "a/\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/admin_productconfig_physicalserver/api/whmcs/views.py"
+++ "b/\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/admin_productconfig_physicalserver/api/whmcs/views.py"
@@ -74,8 +74,11 @@ class WHMCSPhysicalServerIPMIManagementAPIView(APIView):

             if whmcs_site not in [
                 "www.44.hk",
+                "44.hk",
                 "www.44.com",
-                "www.44.net"
+                "44.com",
+                "www.44.net",
+                "44.net"
             ]:
                 return Response(status=HTTP_400_BAD_REQUEST, data="error")

@@ -100,6 +103,8 @@ class WHMCSPhysicalServerIPMIManagementAPIView(APIView):
             physical_server_name = request.data.get('physical_server_name')
             action = request.data.get('action')

+            physical_server_name = str(physical_server_name).split("/")[0]
+
             if not physical_server_name or not action:
                 return Response(data="invalid request data", status=HTTP_400_BAD_REQUEST)

you see there only compare one file(admin_productconfig_physicalserver/api/whmcs/views.py), why there do not compare the other files? and the other question is the admin_productconfig_physicalserver/api/whmcs/views.py did not exist in the merge file changed list:

 Q2/__init__.py                                                                |   3 +
 Q2/common/GLOBAL_CONST.py                                                     |   8 +--
 Q2/urls.py                                                                    |   7 ---
 .../admin_productconfig_physicalserver/api/paginations.py"                   |   1 +
 .../admin_productconfig_physicalserver/api/serializers.py"                   |  22 ++++++-
 .../admin_productconfig_physicalserver/api/switch_cmd_util.py"               |  31 +---------
 .../admin_productconfig_physicalserver/api/urls.py"                          |   6 ++
 .../admin_productconfig_physicalserver/api/views.py"                         | 133 +++++++++++++++++++++++++++++++++++++++-
 .../admin_productconfig_physicalserver/migrations/0091_mg.py"                |  34 ++++++++++
 .../admin_productconfig_physicalserver/migrations/0092_mgnumber.py"          |  25 ++++++++
 .../migrations/0093_auto_20190902_1249.py"                                         |  19 ++++++
 .../migrations/0094_merge_20190906_0822.py"                                        |  16 +++++
 .../admin_productconfig_physicalserver/models.py"                            |  61 ++++++++++++++++--
 .../admin_usermanage/api/serializers.py"                                     |   2 +-
 .../admin_usermanage/api/views.py"                                           |   4 +-
 15 files changed, 318 insertions(+), 54 deletions(-)
 create mode 100644 "\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/qiyun_admin_productconfig_physicalserver/migrations/0091_mg.py"
 create mode 100644 "\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/qiyun_admin_productconfig_physicalserver/migrations/0092_mgnumber.py"
 create mode 100644 "\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/qiyun_admin_productconfig_physicalserver/migrations/0093_auto_20190902_1249.py"
 create mode 100644 "\346\227\227\344\272\221\347\256\241\347\220\206\345\221\230\345\220\216\345\217\260/\344\272\247\345\223\201\351\205\215\347\275\256/qiyun_admin_productconfig_physicalserver/migrations/0094_merge_20190906_0822.py"

Solution

  • A merge commit records the combined changes from the branch(es) merged, along with references to the commits at the tips of what is merged.

    Condensed from man git-merge:

    Given:

          A---B---C topic
         /
    D---E---F---G master
    

    ...merging topic into master will give:

          A---B---C topic
         /         \
    D---E---F---G---H master
    

    Commit H, the merge commit, records the result of merging topic into master. Its first parent will be G (the commit right before the merge on master). Its second parent will be C (the last commit on topic).

    The commit that shows in your log under the merge commit is the second parent of the merge commit, i.e. the last commit of the branch you merged (C in the above example). To diff the master branch to its state before the merge (G in the above example), diff against the last commit in master before the merge. This will be the first parent.

    git diff master^1 master
    

    As a shorthand, you may leave out the 1 as it is implied:

    git diff master^ master
    

    More info on specifying revisions at man gitrevisions.