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

diff-tree -r -t: include added/removed directories in the output

We used to include only the modified and typechanged directories in the ouptut, but for consistency's sake, we should also include added and removed ones as well. This makes the output more consistent, but it may break existing scripts that expect to see the current output which has long been the established behaviour. Signed-off-by: Nick Edelen <sirnot@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nick Edelen committed Jun 13, 2009 at 17:06 UTC df533f34a31890a43baaf00d03c0a7fa51886bc5
2 files changed +59
t/t4037-diff-r-t-dirs.sh new
+53
@@ -0,0 +1,53 @@
1 +#!/bin/sh
2 +
3 +test_description='diff -r -t shows directory additions and deletions'
4 +
5 +. ./test-lib.sh
6 +
7 +test_expect_success setup '
8 + mkdir dc dr dt &&
9 + >dc/1 &&
10 + >dr/2 &&
11 + >dt/3 &&
12 + >fc &&
13 + >fr &&
14 + >ft &&
15 + git add . &&
16 + test_tick &&
17 + git commit -m initial &&
18 +
19 + rm -fr dt dr ft fr &&
20 + mkdir da ft &&
21 + for p in dc/1 da/4 dt ft/5 fc
22 + do
23 + echo hello >$p || exit
24 + done &&
25 + git add -u &&
26 + git add . &&
27 + test_tick &&
28 + git commit -m second
29 +'
30 +
31 +cat >expect <<\EOF
32 +A da
33 +A da/4
34 +M dc
35 +M dc/1
36 +D dr
37 +D dr/2
38 +A dt
39 +D dt
40 +D dt/3
41 +M fc
42 +D fr
43 +D ft
44 +A ft
45 +A ft/5
46 +EOF
47 +
48 +test_expect_success verify '
49 + git diff-tree -r -t --name-status HEAD^ HEAD >actual &&
50 + test_cmp expect actual
51 +'
52 +
53 +test_done
tree-diff.c
+6
@@ -233,6 +233,12 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree
233 if (!tree || type != OBJ_TREE)
234 die("corrupt tree sha %s", sha1_to_hex(sha1));
235
236 + if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {
237 + newbase[baselen + pathlen] = 0;
238 + opt->add_remove(opt, *prefix, mode, sha1, newbase);
239 + newbase[baselen + pathlen] = '/';
240 + }
241 +
242 init_tree_desc(&inner, tree, size);
243 show_tree(opt, prefix, &inner, newbase, baselen + 1 + pathlen);
244