diff --git a/modules/git/commit.go b/modules/git/commit.go index c44882d8861..b09be25ba09 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -495,7 +495,7 @@ func GetCommitFileStatus(ctx context.Context, repoPath, commitID string) (*Commi }() stderr := new(bytes.Buffer) - err := NewCommand(ctx, "log", "--name-status", "-c", "--pretty=format:", "--parents", "--no-renames", "-z", "-1").AddDynamicArguments(commitID).Run(&RunOpts{ + err := NewCommand(ctx, "log", "--name-status", "-m", "--pretty=format:", "--first-parent", "--no-renames", "-z", "-1").AddDynamicArguments(commitID).Run(&RunOpts{ Dir: repoPath, Stdout: w, Stderr: stderr, diff --git a/modules/git/commit_test.go b/modules/git/commit_test.go index acf4beb029f..ac586fdf09d 100644 --- a/modules/git/commit_test.go +++ b/modules/git/commit_test.go @@ -255,3 +255,26 @@ func TestParseCommitFileStatus(t *testing.T) { assert.Equal(t, kase.modified, fileStatus.Modified) } } + +func TestGetCommitFileStatusMerges(t *testing.T) { + bareRepo1Path := filepath.Join(testReposDir, "repo6_merge") + + commitFileStatus, err := GetCommitFileStatus(DefaultContext, bareRepo1Path, "022f4ce6214973e018f02bf363bf8a2e3691f699") + assert.NoError(t, err) + + expected := CommitFileStatus{ + []string{ + "add_file.txt", + }, + []string{ + "to_remove.txt", + }, + []string{ + "to_modify.txt", + }, + } + + assert.Equal(t, commitFileStatus.Added, expected.Added) + assert.Equal(t, commitFileStatus.Removed, expected.Removed) + assert.Equal(t, commitFileStatus.Modified, expected.Modified) +} diff --git a/modules/git/tests/repos/repo6_merge/HEAD b/modules/git/tests/repos/repo6_merge/HEAD new file mode 100644 index 00000000000..b870d82622c --- /dev/null +++ b/modules/git/tests/repos/repo6_merge/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/modules/git/tests/repos/repo6_merge/objects/02/2f4ce6214973e018f02bf363bf8a2e3691f699 b/modules/git/tests/repos/repo6_merge/objects/02/2f4ce6214973e018f02bf363bf8a2e3691f699 new file mode 100644 index 00000000000..0778a1c88c7 Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/02/2f4ce6214973e018f02bf363bf8a2e3691f699 differ diff --git a/modules/git/tests/repos/repo6_merge/objects/05/45879290cc368a8becebc4aa34002c52d5fecc b/modules/git/tests/repos/repo6_merge/objects/05/45879290cc368a8becebc4aa34002c52d5fecc new file mode 100644 index 00000000000..c71794f3291 Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/05/45879290cc368a8becebc4aa34002c52d5fecc differ diff --git a/modules/git/tests/repos/repo6_merge/objects/1e/5d0a65fe099ef12d24b28f783896e4b8172576 b/modules/git/tests/repos/repo6_merge/objects/1e/5d0a65fe099ef12d24b28f783896e4b8172576 new file mode 100644 index 00000000000..365f368d35b Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/1e/5d0a65fe099ef12d24b28f783896e4b8172576 differ diff --git a/modules/git/tests/repos/repo6_merge/objects/37/d35c7ed39e4e16d0b579a5b995b7e30b0e9411 b/modules/git/tests/repos/repo6_merge/objects/37/d35c7ed39e4e16d0b579a5b995b7e30b0e9411 new file mode 100644 index 00000000000..83890b5d0b1 --- /dev/null +++ b/modules/git/tests/repos/repo6_merge/objects/37/d35c7ed39e4e16d0b579a5b995b7e30b0e9411 @@ -0,0 +1,2 @@ +xM +1 a=E$LAī'iRg~_u1N@mZ)g2Dj*_fs 4amnp>>!#1;p]xuyIwN4 \ No newline at end of file diff --git a/modules/git/tests/repos/repo6_merge/objects/38/ec3e0cdc88bde01014bda4a5dd9fc835f41439 b/modules/git/tests/repos/repo6_merge/objects/38/ec3e0cdc88bde01014bda4a5dd9fc835f41439 new file mode 100644 index 00000000000..582d98ce306 --- /dev/null +++ b/modules/git/tests/repos/repo6_merge/objects/38/ec3e0cdc88bde01014bda4a5dd9fc835f41439 @@ -0,0 +1,2 @@ +xM +0a9M2 U =yv/ 0:@$UѬ.[> lIsx 8'TRĤS,$x. ֚=n[נus!+9BGvfm ur> \ No newline at end of file diff --git a/modules/git/tests/repos/repo6_merge/objects/66/7e0fbc6bc02c2285d17f542e89b23c0fa5482b b/modules/git/tests/repos/repo6_merge/objects/66/7e0fbc6bc02c2285d17f542e89b23c0fa5482b new file mode 100644 index 00000000000..d7faff6bf24 Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/66/7e0fbc6bc02c2285d17f542e89b23c0fa5482b differ diff --git a/modules/git/tests/repos/repo6_merge/objects/9f/d90b1d524c0fea776ed5e6476da02ea1740597 b/modules/git/tests/repos/repo6_merge/objects/9f/d90b1d524c0fea776ed5e6476da02ea1740597 new file mode 100644 index 00000000000..8ac2814c0fc Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/9f/d90b1d524c0fea776ed5e6476da02ea1740597 differ diff --git a/modules/git/tests/repos/repo6_merge/objects/ae/4b035e7c4afbc000576cee3f713ea0c2f1e1e2 b/modules/git/tests/repos/repo6_merge/objects/ae/4b035e7c4afbc000576cee3f713ea0c2f1e1e2 new file mode 100644 index 00000000000..c0f6b1334ff --- /dev/null +++ b/modules/git/tests/repos/repo6_merge/objects/ae/4b035e7c4afbc000576cee3f713ea0c2f1e1e2 @@ -0,0 +1,5 @@ +xM +1 @a=E?i*mǑxO=x.lORZ80\[*%b +&q IȚ灝 +7ԋF쨜wcuzx?0 +1 :m6LS>& \ No newline at end of file diff --git a/modules/git/tests/repos/repo6_merge/objects/ba/2906d0666cf726c7eaadd2cd3db615dedfdf3a b/modules/git/tests/repos/repo6_merge/objects/ba/2906d0666cf726c7eaadd2cd3db615dedfdf3a new file mode 100644 index 00000000000..edef2a7f0cb Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/ba/2906d0666cf726c7eaadd2cd3db615dedfdf3a differ diff --git a/modules/git/tests/repos/repo6_merge/objects/c1/a95c2eff8151c6d1437a0d5d3322a73ff38fb8 b/modules/git/tests/repos/repo6_merge/objects/c1/a95c2eff8151c6d1437a0d5d3322a73ff38fb8 new file mode 100644 index 00000000000..353d86ccdb7 Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/c1/a95c2eff8151c6d1437a0d5d3322a73ff38fb8 differ diff --git a/modules/git/tests/repos/repo6_merge/objects/cc/d1d4d594029e68c388ecef5aa3063fa1055831 b/modules/git/tests/repos/repo6_merge/objects/cc/d1d4d594029e68c388ecef5aa3063fa1055831 new file mode 100644 index 00000000000..5449d726cd8 Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/cc/d1d4d594029e68c388ecef5aa3063fa1055831 differ diff --git a/modules/git/tests/repos/repo6_merge/objects/cd/fc1aaf7a149151cb7bff639fafe05668d4bbd2 b/modules/git/tests/repos/repo6_merge/objects/cd/fc1aaf7a149151cb7bff639fafe05668d4bbd2 new file mode 100644 index 00000000000..030eb980f6e Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/cd/fc1aaf7a149151cb7bff639fafe05668d4bbd2 differ diff --git a/modules/git/tests/repos/repo6_merge/objects/d1/792641396ff7630d35fbb0b74b86b0c71bca77 b/modules/git/tests/repos/repo6_merge/objects/d1/792641396ff7630d35fbb0b74b86b0c71bca77 new file mode 100644 index 00000000000..867e4c0b866 Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/d1/792641396ff7630d35fbb0b74b86b0c71bca77 differ diff --git a/modules/git/tests/repos/repo6_merge/objects/ec/d11d8da0f25eaa99f64a37a82da98685f381e2 b/modules/git/tests/repos/repo6_merge/objects/ec/d11d8da0f25eaa99f64a37a82da98685f381e2 new file mode 100644 index 00000000000..52d300cdf18 Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/ec/d11d8da0f25eaa99f64a37a82da98685f381e2 differ diff --git a/modules/git/tests/repos/repo6_merge/objects/fa/49b077972391ad58037050f2a75f74e3671e92 b/modules/git/tests/repos/repo6_merge/objects/fa/49b077972391ad58037050f2a75f74e3671e92 new file mode 100644 index 00000000000..112998d4257 Binary files /dev/null and b/modules/git/tests/repos/repo6_merge/objects/fa/49b077972391ad58037050f2a75f74e3671e92 differ diff --git a/modules/git/tests/repos/repo6_merge/refs/heads/main b/modules/git/tests/repos/repo6_merge/refs/heads/main new file mode 100644 index 00000000000..adf9e86717a --- /dev/null +++ b/modules/git/tests/repos/repo6_merge/refs/heads/main @@ -0,0 +1 @@ +022f4ce6214973e018f02bf363bf8a2e3691f699 diff --git a/modules/git/tests/repos/repo6_merge/refs/heads/merge/add_file b/modules/git/tests/repos/repo6_merge/refs/heads/merge/add_file new file mode 100644 index 00000000000..035ad11863a --- /dev/null +++ b/modules/git/tests/repos/repo6_merge/refs/heads/merge/add_file @@ -0,0 +1 @@ +ae4b035e7c4afbc000576cee3f713ea0c2f1e1e2 diff --git a/modules/git/tests/repos/repo6_merge/refs/heads/merge/modify_file b/modules/git/tests/repos/repo6_merge/refs/heads/merge/modify_file new file mode 100644 index 00000000000..f0d5105f54f --- /dev/null +++ b/modules/git/tests/repos/repo6_merge/refs/heads/merge/modify_file @@ -0,0 +1 @@ +d1792641396ff7630d35fbb0b74b86b0c71bca77 diff --git a/modules/git/tests/repos/repo6_merge/refs/heads/merge/remove_file b/modules/git/tests/repos/repo6_merge/refs/heads/merge/remove_file new file mode 100644 index 00000000000..ada3c8b3f4e --- /dev/null +++ b/modules/git/tests/repos/repo6_merge/refs/heads/merge/remove_file @@ -0,0 +1 @@ +38ec3e0cdc88bde01014bda4a5dd9fc835f41439