@matheusbsbs / matheus-bagliano / commits / 0faf2da7e5
Fork 0

Fix "git log --diff-filter" bug

In commit b7bb760d5ed4881422673d32f869d140221d3564 (Fix revision log diff setup, avoid unnecessary diff generation) an optimization was made to avoid unnecessary diff generation. This was partly fixed in 99516e35d096f41e7133cacde8fbed8ee9a3ecd0 (Fix embarrassing "git log --follow" bug). The '--diff-filter' option also needs the diff machinery in action. Signed-off-by: Arjen Laarhoven <arjen@yaph.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Arjen Laarhoven committed Dec 25, 2007 at 12:06 UTC 0faf2da7e5ee5c2f472d8a7afaf8616101f34e80
2 files changed +78 -2
revision.c
+4 -2
@@ -1290,8 +1290,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1290 if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
1291 revs->diff = 1;
1292
1293 - /* Pickaxe and rename following needs diffs */
1294 - if (revs->diffopt.pickaxe || DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
1293 + /* Pickaxe, diff-filter and rename following need diffs */
1294 + if (revs->diffopt.pickaxe ||
1295 + revs->diffopt.filter ||
1296 + DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
1297 revs->diff = 1;
1298
1299 if (revs->topo_order)
t/t4202-log.sh new
+74
@@ -0,0 +1,74 @@
1 +#!/bin/sh
2 +
3 +test_description='git log'
4 +
5 +. ./test-lib.sh
6 +
7 +test_expect_success setup '
8 +
9 + echo one >one &&
10 + git add one &&
11 + test_tick &&
12 + git commit -m initial &&
13 +
14 + echo ichi >one &&
15 + git add one &&
16 + test_tick &&
17 + git commit -m second &&
18 +
19 + mkdir a &&
20 + echo ni >a/two &&
21 + git add a/two &&
22 + test_tick &&
23 + git commit -m third &&
24 +
25 + echo san >a/three &&
26 + git add a/three &&
27 + test_tick &&
28 + git commit -m fourth &&
29 +
30 + git rm a/three &&
31 + test_tick &&
32 + git commit -m fifth
33 +
34 +'
35 +
36 +test_expect_success 'diff-filter=A' '
37 +
38 + actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) &&
39 + expect=$(echo fourth ; echo third ; echo initial) &&
40 + test "$actual" = "$expect" || {
41 + echo Oops
42 + echo "Actual: $actual"
43 + false
44 + }
45 +
46 +'
47 +
48 +test_expect_success 'diff-filter=M' '
49 +
50 + actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
51 + expect=$(echo second) &&
52 + test "$actual" = "$expect" || {
53 + echo Oops
54 + echo "Actual: $actual"
55 + false
56 + }
57 +
58 +'
59 +
60 +test_expect_success 'diff-filter=D' '
61 +
62 + actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
63 + expect=$(echo fifth) &&
64 + test "$actual" = "$expect" || {
65 + echo Oops
66 + echo "Actual: $actual"
67 + false
68 + }
69 +
70 +'
71 +
72 +
73 +
74 +test_done
\ No newline at end of file