From b65bc21e7d8dc8cafc70dfa6354cb66b8874b2d9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 24 Jun 2006 00:59:49 -0700 Subject: Makefile: add framework to verify and bench sha1 implementations. Signed-off-by: Junio C Hamano --- Makefile | 6 +++++ test-sha1.c | 24 ++++++++++++++++++ test-sha1.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 test-sha1.c create mode 100755 test-sha1.sh diff --git a/Makefile b/Makefile index e29e3fa38..ea0044d62 100644 --- a/Makefile +++ b/Makefile @@ -636,6 +636,12 @@ test-delta$X: test-delta.c diff-delta.o patch-delta.o test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS) $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) +test-sha1$X: test-sha1.o $(GITLIBS) + $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) + +check-sha1:: test-sha1$X + ./test-sha1.sh + check: for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done diff --git a/test-sha1.c b/test-sha1.c new file mode 100644 index 000000000..2efc315ee --- /dev/null +++ b/test-sha1.c @@ -0,0 +1,24 @@ +#include "cache.h" + +int main(int ac, char **av) +{ + SHA_CTX ctx; + unsigned char sha1[20]; + + SHA1_Init(&ctx); + + while (1) { + ssize_t sz; + char buffer[8192]; + sz = xread(0, buffer, sizeof(buffer)); + if (sz == 0) + break; + if (sz < 0) + die("test-sha1: %s", strerror(errno)); + SHA1_Update(&ctx, buffer, sz); + } + SHA1_Final(sha1, &ctx); + puts(sha1_to_hex(sha1)); + exit(0); +} + diff --git a/test-sha1.sh b/test-sha1.sh new file mode 100755 index 000000000..01bbb5782 --- /dev/null +++ b/test-sha1.sh @@ -0,0 +1,83 @@ +#!/bin/sh + +dd if=/dev/zero bs=1048576 count=100 2>/dev/null | +/usr/bin/time ./test-sha1 >/dev/null + +while read expect cnt pfx +do + case "$expect" in '#'*) continue ;; esac + actual=` + { + test -z "$pfx" || echo "$pfx" + dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null | + tr '[\0]' '[g]' + } | ./test-sha1 + ` + if test "$expect" = "$actual" + then + echo "OK: $expect $cnt $pfx" + else + echo >&2 "OOPS: $cnt" + echo >&2 "expect: $expect" + echo >&2 "actual: $actual" + exit 1 + fi +done </dev/null | + tr '[\0]' '[g]' + } | sha1sum | + sed -e 's/ .*//' + ` + echo "$actual $cnt $pfx" +done < Date: Sat, 24 Jun 2006 02:59:20 -0700 Subject: test-sha1: test hashing large buffer test to hash a large buffer in one go is more important than hashing large amount of data in small fixed chunks. Signed-off-by: Junio C Hamano --- test-sha1.c | 39 +++++++++++++++++++++++++++++++-------- test-sha1.sh | 2 +- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/test-sha1.c b/test-sha1.c index 2efc315ee..78d7e983a 100644 --- a/test-sha1.c +++ b/test-sha1.c @@ -4,21 +4,44 @@ int main(int ac, char **av) { SHA_CTX ctx; unsigned char sha1[20]; + unsigned bufsz = 8192; + char *buffer; + + if (ac == 2) + bufsz = strtoul(av[1], NULL, 10) * 1024 * 1024; + + if (!bufsz) + bufsz = 8192; + + while ((buffer = malloc(bufsz)) == NULL) { + fprintf(stderr, "bufsz %u is too big, halving...\n", bufsz); + bufsz /= 2; + if (bufsz < 1024) + die("OOPS"); + } SHA1_Init(&ctx); while (1) { - ssize_t sz; - char buffer[8192]; - sz = xread(0, buffer, sizeof(buffer)); - if (sz == 0) + ssize_t sz, this_sz; + char *cp = buffer; + unsigned room = bufsz; + this_sz = 0; + while (room) { + sz = xread(0, cp, room); + if (sz == 0) + break; + if (sz < 0) + die("test-sha1: %s", strerror(errno)); + this_sz += sz; + cp += sz; + room -= sz; + } + if (this_sz == 0) break; - if (sz < 0) - die("test-sha1: %s", strerror(errno)); - SHA1_Update(&ctx, buffer, sz); + SHA1_Update(&ctx, buffer, this_sz); } SHA1_Final(sha1, &ctx); puts(sha1_to_hex(sha1)); exit(0); } - diff --git a/test-sha1.sh b/test-sha1.sh index 01bbb5782..640856af5 100755 --- a/test-sha1.sh +++ b/test-sha1.sh @@ -11,7 +11,7 @@ do test -z "$pfx" || echo "$pfx" dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null | tr '[\0]' '[g]' - } | ./test-sha1 + } | ./test-sha1 $cnt ` if test "$expect" = "$actual" then -- cgit v1.2.1 From 84702995f89361c5872029cb93983c704d80e993 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 24 Jun 2006 02:31:20 -0700 Subject: A better-scheduled PPC SHA-1 implementation. This is about 15% faster that the current sha1ppc.S on a G4, and 5% faster on a G5 when hashing 10 million bytes, unaligned. (The G5 ratio seems to get better as the sizes fall.) It's also somewhat smaller, due to using load-multiple instructions. No copyright is claimed on the changes to Paul Mackerras' work below. --- ppc/sha1ppc.S | 351 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 195 insertions(+), 156 deletions(-) diff --git a/ppc/sha1ppc.S b/ppc/sha1ppc.S index e85611a4e..f591d98b3 100644 --- a/ppc/sha1ppc.S +++ b/ppc/sha1ppc.S @@ -3,183 +3,222 @@ * * Copyright (C) 2005 Paul Mackerras */ -#define FS 80 /* - * We roll the registers for T, A, B, C, D, E around on each - * iteration; T on iteration t is A on iteration t+1, and so on. - * We use registers 7 - 12 for this. + * PowerPC calling convention: + * %r0 - volatile temp + * %r1 - stack pointer. + * %r2 - reserved + * %r3-%r12 - Incoming arguments & return values; volatile. + * %r13-%r31 - Callee-save registers + * %lr - Return address, volatile + * %ctr - volatile + * + * Register usage in this routine: + * %r0 - temp + * %r3 - argument (pointer to 5 words of SHA state) + * %r4 - argument (pointer to data to hash) + * %r5 - Contant K in SHA round (initially number of blocks to hash) + * %r6-%r10 - Working copies of SHA variables A..E (actually E..A order) + * %r11-%r26 - Data being hashed W[]. + * %r27-%r31 - Previous copies of A..E, for final add back. + * %ctr - loop count + */ + + +/* + * We roll the registers for A, B, C, D, E around on each + * iteration; E on iteration t is D on iteration t+1, and so on. + * We use registers 6 - 10 for this. (Registers 27 - 31 hold + * the previous values.) */ -#define RT(t) ((((t)+5)%6)+7) -#define RA(t) ((((t)+4)%6)+7) -#define RB(t) ((((t)+3)%6)+7) -#define RC(t) ((((t)+2)%6)+7) -#define RD(t) ((((t)+1)%6)+7) -#define RE(t) ((((t)+0)%6)+7) - -/* We use registers 16 - 31 for the W values */ -#define W(t) (((t)%16)+16) - -#define STEPD0(t) \ - and %r6,RB(t),RC(t); \ - andc %r0,RD(t),RB(t); \ - rotlwi RT(t),RA(t),5; \ - rotlwi RB(t),RB(t),30; \ - or %r6,%r6,%r0; \ - add %r0,RE(t),%r15; \ - add RT(t),RT(t),%r6; \ - add %r0,%r0,W(t); \ - add RT(t),RT(t),%r0 - -#define STEPD1(t) \ - xor %r6,RB(t),RC(t); \ - rotlwi RT(t),RA(t),5; \ - rotlwi RB(t),RB(t),30; \ - xor %r6,%r6,RD(t); \ - add %r0,RE(t),%r15; \ - add RT(t),RT(t),%r6; \ - add %r0,%r0,W(t); \ - add RT(t),RT(t),%r0 - -#define STEPD2(t) \ - and %r6,RB(t),RC(t); \ - and %r0,RB(t),RD(t); \ - rotlwi RT(t),RA(t),5; \ - rotlwi RB(t),RB(t),30; \ - or %r6,%r6,%r0; \ - and %r0,RC(t),RD(t); \ - or %r6,%r6,%r0; \ - add %r0,RE(t),%r15; \ - add RT(t),RT(t),%r6; \ - add %r0,%r0,W(t); \ - add RT(t),RT(t),%r0 - -#define LOADW(t) \ - lwz W(t),(t)*4(%r4) - -#define UPDATEW(t) \ - xor %r0,W((t)-3),W((t)-8); \ - xor W(t),W((t)-16),W((t)-14); \ - xor W(t),W(t),%r0; \ - rotlwi W(t),W(t),1 - -#define STEP0LD4(t) \ - STEPD0(t); LOADW((t)+4); \ - STEPD0((t)+1); LOADW((t)+5); \ - STEPD0((t)+2); LOADW((t)+6); \ - STEPD0((t)+3); LOADW((t)+7) - -#define STEPUP4(t, fn) \ - STEP##fn(t); UPDATEW((t)+4); \ - STEP##fn((t)+1); UPDATEW((t)+5); \ - STEP##fn((t)+2); UPDATEW((t)+6); \ - STEP##fn((t)+3); UPDATEW((t)+7) - -#define STEPUP20(t, fn) \ - STEPUP4(t, fn); \ - STEPUP4((t)+4, fn); \ - STEPUP4((t)+8, fn); \ - STEPUP4((t)+12, fn); \ - STEPUP4((t)+16, fn) +#define RA(t) (((t)+4)%5+6) +#define RB(t) (((t)+3)%5+6) +#define RC(t) (((t)+2)%5+6) +#define RD(t) (((t)+1)%5+6) +#define RE(t) (((t)+0)%5+6) + +/* We use registers 11 - 26 for the W values */ +#define W(t) ((t)%16+11) + +/* Register 5 is used for the constant k */ + +/* + * The basic SHA-1 round function is: + * E += ROTL(A,5) + F(B,C,D) + W[i] + K; B = ROTL(B,30) + * Then the variables are renamed: (A,B,C,D,E) = (E,A,B,C,D). + * + * Every 20 rounds, the function F() and the contant K changes: + * - 20 rounds of f0(b,c,d) = "bit wise b ? c : d" = (^b & d) + (b & c) + * - 20 rounds of f1(b,c,d) = b^c^d = (b^d)^c + * - 20 rounds of f2(b,c,d) = majority(b,c,d) = (b&d) + ((b^d)&c) + * - 20 more rounds of f1(b,c,d) + * + * These are all scheduled for near-optimal performance on a G4. + * The G4 is a 3-issue out-of-order machine with 3 ALUs, but it can only + * *consider* starting the oldest 3 instructions per cycle. So to get + * maximum performace out of it, you have to treat it as an in-order + * machine. Which means interleaving the computation round t with the + * computation of W[t+4]. + * + * The first 16 rounds use W values loaded directly from memory, while the + * remianing 64 use values computed from those first 16. We preload + * 4 values before starting, so there are three kinds of rounds: + * - The first 12 (all f0) also load the W values from memory. + * - The next 64 compute W(i+4) in parallel. 8*f0, 20*f1, 20*f2, 16*f1. + * - The last 4 (all f1) do not do anything with W. + * + * Therefore, we have 6 different round functions: + * STEPD0_LOAD(t,s) - Perform round t and load W(s). s < 16 + * STEPD0_UPDATE(t,s) - Perform round t and compute W(s). s >= 16. + * STEPD1_UPDATE(t,s) + * STEPD2_UPDATE(t,s) + * STEPD1(t) - Perform round t with no load or update. + * + * The G5 is more fully out-of-order, and can find the parallelism + * by itself. The big limit is that it has a 2-cycle ALU latency, so + * even though it's 2-way, the code has to be scheduled as if it's + * 4-way, which can be a limit. To help it, we try to schedule the + * read of RA(t) as late as possible so it doesn't stall waiting for + * the previous round's RE(t-1), and we try to rotate RB(t) as early + * as possible while reading RC(t) (= RB(t-1)) as late as possible. + */ + +/* the initial loads. */ +#define LOADW(s) \ + lwz W(s),(s)*4(%r4) + +/* + * Perform a step with F0, and load W(s). Uses W(s) as a temporary + * before loading it. + * This is actually 10 instructions, which is an awkward fit. + * It can execute grouped as listed, or delayed one instruction. + * (If delayed two instructions, there is a stall before the start of the + * second line.) Thus, two iterations take 7 cycles, 3.5 cycles per round. + */ +#define STEPD0_LOAD(t,s) \ +add RE(t),RE(t),W(t); andc %r0,RD(t),RB(t); and W(s),RC(t),RB(t); \ +add RE(t),RE(t),%r0; rotlwi %r0,RA(t),5; rotlwi RB(t),RB(t),30; \ +add RE(t),RE(t),W(s); add %r0,%r0,%r5; lwz W(s),(s)*4(%r4); \ +add RE(t),RE(t),%r0 + +/* + * This is likewise awkward, 13 instructions. However, it can also + * execute starting with 2 out of 3 possible moduli, so it does 2 rounds + * in 9 cycles, 4.5 cycles/round. + */ +#define STEPD0_UPDATE(t,s,loadk...) \ +add RE(t),RE(t),W(t); andc %r0,RD(t),RB(t); xor W(s),W((s)-16),W((s)-3); \ +add RE(t),RE(t),%r0; and %r0,RC(t),RB(t); xor W(s),W(s),W((s)-8); \ +add RE(t),RE(t),%r0; rotlwi %r0,RA(t),5; xor W(s),W(s),W((s)-14); \ +add RE(t),RE(t),%r5; loadk; rotlwi RB(t),RB(t),30; rotlwi W(s),W(s),1; \ +add RE(t),RE(t),%r0 + +/* Nicely optimal. Conveniently, also the most common. */ +#define STEPD1_UPDATE(t,s,loadk...) \ +add RE(t),RE(t),W(t); xor %r0,RD(t),RB(t); xor W(s),W((s)-16),W((s)-3); \ +add RE(t),RE(t),%r5; loadk; xor %r0,%r0,RC(t); xor W(s),W(s),W((s)-8); \ +add RE(t),RE(t),%r0; rotlwi %r0,RA(t),5; xor W(s),W(s),W((s)-14); \ +add RE(t),RE(t),%r0; rotlwi RB(t),RB(t),30; rotlwi W(s),W(s),1 + +/* + * The naked version, no UPDATE, for the last 4 rounds. 3 cycles per. + * We could use W(s) as a temp register, but we don't need it. + */ +#define STEPD1(t) \ + add RE(t),RE(t),W(t); xor %r0,RD(t),RB(t); \ +rotlwi RB(t),RB(t),30; add RE(t),RE(t),%r5; xor %r0,%r0,RC(t); \ +add RE(t),RE(t),%r0; rotlwi %r0,RA(t),5; /* spare slot */ \ +add RE(t),RE(t),%r0 + +/* + * 14 instructions, 5 cycles per. The majority function is a bit + * awkward to compute. This can execute with a 1-instruction delay, + * but it causes a 2-instruction delay, which triggers a stall. + */ +#define STEPD2_UPDATE(t,s,loadk...) \ +add RE(t),RE(t),W(t); and %r0,RD(t),RB(t); xor W(s),W((s)-16),W((s)-3); \ +add RE(t),RE(t),%r0; xor %r0,RD(t),RB(t); xor W(s),W(s),W((s)-8); \ +add RE(t),RE(t),%r5; loadk; and %r0,%r0,RC(t); xor W(s),W(s),W((s)-14); \ +add RE(t),RE(t),%r0; rotlwi %r0,RA(t),5; rotlwi W(s),W(s),1; \ +add RE(t),RE(t),%r0; rotlwi RB(t),RB(t),30 + +#define STEP0_LOAD4(t,s) \ + STEPD0_LOAD(t,s); \ + STEPD0_LOAD((t+1),(s)+1); \ + STEPD0_LOAD((t)+2,(s)+2); \ + STEPD0_LOAD((t)+3,(s)+3) + +#define STEPUP4(fn, t, s, loadk...) \ + STEP##fn##_UPDATE(t,s,); \ + STEP##fn##_UPDATE((t)+1,(s)+1,); \ + STEP##fn##_UPDATE((t)+2,(s)+2,); \ + STEP##fn##_UPDATE((t)+3,(s)+3,loadk) + +#define STEPUP20(fn, t, s, loadk...) \ + STEPUP4(fn, t, s,); \ + STEPUP4(fn, (t)+4, (s)+4,); \ + STEPUP4(fn, (t)+8, (s)+8,); \ + STEPUP4(fn, (t)+12, (s)+12,); \ + STEPUP4(fn, (t)+16, (s)+16, loadk) .globl sha1_core sha1_core: - stwu %r1,-FS(%r1) - stw %r15,FS-68(%r1) - stw %r16,FS-64(%r1) - stw %r17,FS-60(%r1) - stw %r18,FS-56(%r1) - stw %r19,FS-52(%r1) - stw %r20,FS-48(%r1) - stw %r21,FS-44(%r1) - stw %r22,FS-40(%r1) - stw %r23,FS-36(%r1) - stw %r24,FS-32(%r1) - stw %r25,FS-28(%r1) - stw %r26,FS-24(%r1) - stw %r27,FS-20(%r1) - stw %r28,FS-16(%r1) - stw %r29,FS-12(%r1) - stw %r30,FS-8(%r1) - stw %r31,FS-4(%r1) + stwu %r1,-80(%r1) + stmw %r13,4(%r1) /* Load up A - E */ - lwz RA(0),0(%r3) /* A */ - lwz RB(0),4(%r3) /* B */ - lwz RC(0),8(%r3) /* C */ - lwz RD(0),12(%r3) /* D */ - lwz RE(0),16(%r3) /* E */ + lmw %r27,0(%r3) mtctr %r5 -1: LOADW(0) +1: + LOADW(0) + lis %r5,0x5a82 + mr RE(0),%r31 LOADW(1) + mr RD(0),%r30 + mr RC(0),%r29 LOADW(2) + ori %r5,%r5,0x7999 /* K0-19 */ + mr RB(0),%r28 LOADW(3) + mr RA(0),%r27 + + STEP0_LOAD4(0, 4) + STEP0_LOAD4(4, 8) + STEP0_LOAD4(8, 12) + STEPUP4(D0, 12, 16,) + STEPUP4(D0, 16, 20, lis %r5,0x6ed9) - lis %r15,0x5a82 /* K0-19 */ - ori %r15,%r15,0x7999 - STEP0LD4(0) - STEP0LD4(4) - STEP0LD4(8) - STEPUP4(12, D0) - STEPUP4(16, D0) - - lis %r15,0x6ed9 /* K20-39 */ - ori %r15,%r15,0xeba1 - STEPUP20(20, D1) - - lis %r15,0x8f1b /* K40-59 */ - ori %r15,%r15,0xbcdc - STEPUP20(40, D2) - - lis %r15,0xca62 /* K60-79 */ - ori %r15,%r15,0xc1d6 - STEPUP4(60, D1) - STEPUP4(64, D1) - STEPUP4(68, D1) - STEPUP4(72, D1) + ori %r5,%r5,0xeba1 /* K20-39 */ + STEPUP20(D1, 20, 24, lis %r5,0x8f1b) + + ori %r5,%r5,0xbcdc /* K40-59 */ + STEPUP20(D2, 40, 44, lis %r5,0xca62) + + ori %r5,%r5,0xc1d6 /* K60-79 */ + STEPUP4(D1, 60, 64,) + STEPUP4(D1, 64, 68,) + STEPUP4(D1, 68, 72,) + STEPUP4(D1, 72, 76,) + addi %r4,%r4,64 STEPD1(76) STEPD1(77) STEPD1(78) STEPD1(79) - lwz %r20,16(%r3) - lwz %r19,12(%r3) - lwz %r18,8(%r3) - lwz %r17,4(%r3) - lwz %r16,0(%r3) - add %r20,RE(80),%r20 - add RD(0),RD(80),%r19 - add RC(0),RC(80),%r18 - add RB(0),RB(80),%r17 - add RA(0),RA(80),%r16 - mr RE(0),%r20 - stw RA(0),0(%r3) - stw RB(0),4(%r3) - stw RC(0),8(%r3) - stw RD(0),12(%r3) - stw RE(0),16(%r3) + /* Add results to original values */ + add %r31,%r31,RE(0) + add %r30,%r30,RD(0) + add %r29,%r29,RC(0) + add %r28,%r28,RB(0) + add %r27,%r27,RA(0) - addi %r4,%r4,64 bdnz 1b - lwz %r15,FS-68(%r1) - lwz %r16,FS-64(%r1) - lwz %r17,FS-60(%r1) - lwz %r18,FS-56(%r1) - lwz %r19,FS-52(%r1) - lwz %r20,FS-48(%r1) - lwz %r21,FS-44(%r1) - lwz %r22,FS-40(%r1) - lwz %r23,FS-36(%r1) - lwz %r24,FS-32(%r1) - lwz %r25,FS-28(%r1) - lwz %r26,FS-24(%r1) - lwz %r27,FS-20(%r1) - lwz %r28,FS-16(%r1) - lwz %r29,FS-12(%r1) - lwz %r30,FS-8(%r1) - lwz %r31,FS-4(%r1) - addi %r1,%r1,FS + /* Save final hash, restore registers, and return */ + stmw %r27,0(%r3) + lmw %r13,4(%r1) + addi %r1,%r1,80 blr -- cgit v1.2.1 From 3c2f75b590c35675cc67dc43cabe2298bec86afc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 26 Jun 2006 13:46:52 -0700 Subject: t4013: add tests for diff/log family output options. Signed-off-by: Junio C Hamano --- t/t4013-diff-various.sh | 202 +++++++++++++++++++++ t/t4013/diff.diff-tree_--cc_master | 30 +++ t/t4013/diff.diff-tree_--patch-with-raw_initial | 2 + t/t4013/diff.diff-tree_--patch-with-stat_initial | 2 + ...-tree_--pretty=oneline_--patch-with-raw_initial | 2 + ...tree_--pretty=oneline_--patch-with-stat_initial | 2 + ...-pretty=oneline_--root_--patch-with-raw_initial | 33 ++++ ...pretty=oneline_--root_--patch-with-stat_initial | 35 ++++ ...ff.diff-tree_--pretty=oneline_--root_-p_initial | 29 +++ .../diff.diff-tree_--pretty=oneline_--root_initial | 6 + t/t4013/diff.diff-tree_--pretty=oneline_-p_initial | 2 + t/t4013/diff.diff-tree_--pretty=oneline_initial | 2 + ...iff.diff-tree_--pretty_--patch-with-raw_initial | 2 + ...ff.diff-tree_--pretty_--patch-with-stat_initial | 2 + .../diff.diff-tree_--pretty_--patch-with-stat_side | 43 +++++ ...f-tree_--pretty_--root_--patch-with-raw_initial | 38 ++++ ...-tree_--pretty_--root_--patch-with-stat_initial | 39 ++++ ...f-tree_--pretty_--root_--stat_--summary_initial | 15 ++ .../diff.diff-tree_--pretty_--root_--stat_initial | 12 ++ t/t4013/diff.diff-tree_--pretty_--root_-p_initial | 34 ++++ t/t4013/diff.diff-tree_--pretty_--root_initial | 11 ++ ...iff.diff-tree_--pretty_--stat_--summary_initial | 2 + t/t4013/diff.diff-tree_--pretty_--stat_initial | 2 + t/t4013/diff.diff-tree_--pretty_--summary_initial | 2 + t/t4013/diff.diff-tree_--pretty_-p_initial | 2 + t/t4013/diff.diff-tree_--pretty_-p_side | 38 ++++ t/t4013/diff.diff-tree_--pretty_initial | 2 + t/t4013/diff.diff-tree_--pretty_side | 11 ++ t/t4013/diff.diff-tree_--root_--abbrev_initial | 6 + .../diff.diff-tree_--root_--patch-with-raw_initial | 33 ++++ ...diff.diff-tree_--root_--patch-with-stat_initial | 34 ++++ t/t4013/diff.diff-tree_--root_-p_initial | 29 +++ .../diff.diff-tree_--root_-r_--abbrev=4_initial | 6 + t/t4013/diff.diff-tree_--root_-r_--abbrev_initial | 6 + t/t4013/diff.diff-tree_--root_-r_initial | 6 + t/t4013/diff.diff-tree_--root_initial | 6 + t/t4013/diff.diff-tree_-c_--abbrev_master | 5 + t/t4013/diff.diff-tree_-c_master | 5 + t/t4013/diff.diff-tree_-p_-m_master | 80 ++++++++ t/t4013/diff.diff-tree_-p_initial | 2 + t/t4013/diff.diff-tree_-p_master | 2 + t/t4013/diff.diff-tree_-r_--abbrev=4_initial | 2 + t/t4013/diff.diff-tree_-r_--abbrev_initial | 2 + t/t4013/diff.diff-tree_-r_initial | 2 + t/t4013/diff.diff-tree_initial | 2 + t/t4013/diff.diff-tree_master | 2 + t/t4013/diff.log_--patch-with-stat_master | 127 +++++++++++++ t/t4013/diff.log_--patch-with-stat_master_--_dir_ | 72 ++++++++ t/t4013/diff.log_--root_--patch-with-stat_master | 159 ++++++++++++++++ t/t4013/diff.log_--root_-p_master | 140 ++++++++++++++ t/t4013/diff.log_--root_master | 32 ++++ t/t4013/diff.log_-SF_master | 8 + t/t4013/diff.log_-p_master | 113 ++++++++++++ t/t4013/diff.log_master | 32 ++++ t/t4013/diff.show_--patch-with-raw_side | 42 +++++ t/t4013/diff.show_--patch-with-stat_--summary_side | 44 +++++ t/t4013/diff.show_--patch-with-stat_side | 43 +++++ t/t4013/diff.show_--root_initial | 34 ++++ t/t4013/diff.show_--stat_--summary_side | 13 ++ t/t4013/diff.show_--stat_side | 12 ++ t/t4013/diff.show_initial | 7 + t/t4013/diff.show_master | 36 ++++ t/t4013/diff.show_side | 38 ++++ t/t4013/diff.whatchanged_--patch-with-stat_master | 114 ++++++++++++ ...ff.whatchanged_--patch-with-stat_master_--_dir_ | 59 ++++++ ...anged_--root_--patch-with-stat_--summary_master | 158 ++++++++++++++++ ...iff.whatchanged_--root_--patch-with-stat_master | 152 ++++++++++++++++ t/t4013/diff.whatchanged_--root_-p_master | 133 ++++++++++++++ t/t4013/diff.whatchanged_--root_master | 40 ++++ t/t4013/diff.whatchanged_-SF_master | 9 + t/t4013/diff.whatchanged_-p_master | 100 ++++++++++ t/t4013/diff.whatchanged_master | 30 +++ 72 files changed, 2579 insertions(+) create mode 100755 t/t4013-diff-various.sh create mode 100644 t/t4013/diff.diff-tree_--cc_master create mode 100644 t/t4013/diff.diff-tree_--patch-with-raw_initial create mode 100644 t/t4013/diff.diff-tree_--patch-with-stat_initial create mode 100644 t/t4013/diff.diff-tree_--pretty=oneline_--patch-with-raw_initial create mode 100644 t/t4013/diff.diff-tree_--pretty=oneline_--patch-with-stat_initial create mode 100644 t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-raw_initial create mode 100644 t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial create mode 100644 t/t4013/diff.diff-tree_--pretty=oneline_--root_-p_initial create mode 100644 t/t4013/diff.diff-tree_--pretty=oneline_--root_initial create mode 100644 t/t4013/diff.diff-tree_--pretty=oneline_-p_initial create mode 100644 t/t4013/diff.diff-tree_--pretty=oneline_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--patch-with-raw_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--patch-with-stat_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--patch-with-stat_side create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_--patch-with-raw_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_--patch-with-stat_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_--stat_--summary_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_--stat_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_-p_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--stat_--summary_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--stat_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--summary_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_-p_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_-p_side create mode 100644 t/t4013/diff.diff-tree_--pretty_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_side create mode 100644 t/t4013/diff.diff-tree_--root_--abbrev_initial create mode 100644 t/t4013/diff.diff-tree_--root_--patch-with-raw_initial create mode 100644 t/t4013/diff.diff-tree_--root_--patch-with-stat_initial create mode 100644 t/t4013/diff.diff-tree_--root_-p_initial create mode 100644 t/t4013/diff.diff-tree_--root_-r_--abbrev=4_initial create mode 100644 t/t4013/diff.diff-tree_--root_-r_--abbrev_initial create mode 100644 t/t4013/diff.diff-tree_--root_-r_initial create mode 100644 t/t4013/diff.diff-tree_--root_initial create mode 100644 t/t4013/diff.diff-tree_-c_--abbrev_master create mode 100644 t/t4013/diff.diff-tree_-c_master create mode 100644 t/t4013/diff.diff-tree_-p_-m_master create mode 100644 t/t4013/diff.diff-tree_-p_initial create mode 100644 t/t4013/diff.diff-tree_-p_master create mode 100644 t/t4013/diff.diff-tree_-r_--abbrev=4_initial create mode 100644 t/t4013/diff.diff-tree_-r_--abbrev_initial create mode 100644 t/t4013/diff.diff-tree_-r_initial create mode 100644 t/t4013/diff.diff-tree_initial create mode 100644 t/t4013/diff.diff-tree_master create mode 100644 t/t4013/diff.log_--patch-with-stat_master create mode 100644 t/t4013/diff.log_--patch-with-stat_master_--_dir_ create mode 100644 t/t4013/diff.log_--root_--patch-with-stat_master create mode 100644 t/t4013/diff.log_--root_-p_master create mode 100644 t/t4013/diff.log_--root_master create mode 100644 t/t4013/diff.log_-SF_master create mode 100644 t/t4013/diff.log_-p_master create mode 100644 t/t4013/diff.log_master create mode 100644 t/t4013/diff.show_--patch-with-raw_side create mode 100644 t/t4013/diff.show_--patch-with-stat_--summary_side create mode 100644 t/t4013/diff.show_--patch-with-stat_side create mode 100644 t/t4013/diff.show_--root_initial create mode 100644 t/t4013/diff.show_--stat_--summary_side create mode 100644 t/t4013/diff.show_--stat_side create mode 100644 t/t4013/diff.show_initial create mode 100644 t/t4013/diff.show_master create mode 100644 t/t4013/diff.show_side create mode 100644 t/t4013/diff.whatchanged_--patch-with-stat_master create mode 100644 t/t4013/diff.whatchanged_--patch-with-stat_master_--_dir_ create mode 100644 t/t4013/diff.whatchanged_--root_--patch-with-stat_--summary_master create mode 100644 t/t4013/diff.whatchanged_--root_--patch-with-stat_master create mode 100644 t/t4013/diff.whatchanged_--root_-p_master create mode 100644 t/t4013/diff.whatchanged_--root_master create mode 100644 t/t4013/diff.whatchanged_-SF_master create mode 100644 t/t4013/diff.whatchanged_-p_master create mode 100644 t/t4013/diff.whatchanged_master diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh new file mode 100755 index 000000000..802e0ba01 --- /dev/null +++ b/t/t4013-diff-various.sh @@ -0,0 +1,202 @@ +#!/bin/sh +# +# Copyright (c) 2006 Junio C Hamano +# + +test_description='Various diff formatting options' + +. ./test-lib.sh + +test_expect_success setup ' + + GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" && + GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" && + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + + mkdir dir && + for i in 1 2 3; do echo $i; done >file0 && + for i in A B; do echo $i; done >dir/sub && + cat file0 >file2 && + git add file0 file2 dir/sub && + git commit -m Initial && + + git branch initial && + git branch side && + + GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" && + GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" && + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + + for i in 4 5 6; do echo $i; done >>file0 && + for i in C D; do echo $i; done >>dir/sub && + rm -f file2 && + git update-index --remove file0 file2 dir/sub && + git commit -m Second && + + GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" && + GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" && + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + + for i in A B C; do echo $i; done >file1 && + git add file1 && + for i in E F; do echo $i; done >>dir/sub && + git update-index dir/sub && + git commit -m Third && + + GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" && + GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" && + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + + git checkout side && + for i in A B C; do echo $i; done >>file0 && + for i in 1 2; do echo $i; done >>dir/sub && + cat dir/sub >file3 && + git add file3 && + git update-index file0 dir/sub && + git commit -m Side && + + GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" && + GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" && + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + + git checkout master && + git pull -s ours . side && + + GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" && + GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" && + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + + for i in A B C; do echo $i; done >>file0 && + for i in 1 2; do echo $i; done >>dir/sub && + git update-index file0 dir/sub && + + EDITOR=: VISUAL=: git commit --amend && + git show-branch +' + +: <<\EOF +! [initial] Initial + * [master] Merge branch 'side' + ! [side] Side +--- + - [master] Merge branch 'side' + *+ [side] Side + * [master^] Second ++*+ [initial] Initial +EOF + +while read cmd +do + case "$cmd" in + '' | '#'*) continue ;; + esac + test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'` + cnt=`expr $test_count + 1` + pfx=`printf "%04d" $cnt` + expect="../t4013/diff.$test" + actual="$pfx-diff.$test" + + test_expect_success "git $cmd" ' + { + echo "\$ git $cmd" + git $cmd + echo "\$" + } >"$actual" && + if test -f "$expect" + then + diff -u "$expect" "$actual" && + rm -f "$actual" + else + # this is to help developing new tests. + cp "$actual" "$expect" + false + fi + ' +done <<\EOF +diff-tree initial +diff-tree -r initial +diff-tree -r --abbrev initial +diff-tree -r --abbrev=4 initial +diff-tree --root initial +diff-tree --root --abbrev initial +diff-tree --root -r initial +diff-tree --root -r --abbrev initial +diff-tree --root -r --abbrev=4 initial +diff-tree -p initial +diff-tree --root -p initial +diff-tree --patch-with-stat initial +diff-tree --root --patch-with-stat initial +diff-tree --patch-with-raw initial +diff-tree --root --patch-with-raw initial + +diff-tree --pretty initial +diff-tree --pretty --root initial +diff-tree --pretty -p initial +diff-tree --pretty --stat initial +diff-tree --pretty --summary initial +diff-tree --pretty --stat --summary initial +diff-tree --pretty --root -p initial +diff-tree --pretty --root --stat initial +#diff-tree --pretty --root --summary initial +diff-tree --pretty --root --stat --summary initial +diff-tree --pretty --patch-with-stat initial +diff-tree --pretty --root --patch-with-stat initial +diff-tree --pretty --patch-with-raw initial +diff-tree --pretty --root --patch-with-raw initial + +diff-tree --pretty=oneline initial +diff-tree --pretty=oneline --root initial +diff-tree --pretty=oneline -p initial +diff-tree --pretty=oneline --root -p initial +diff-tree --pretty=oneline --patch-with-stat initial +diff-tree --pretty=oneline --root --patch-with-stat initial +diff-tree --pretty=oneline --patch-with-raw initial +diff-tree --pretty=oneline --root --patch-with-raw initial + +diff-tree --pretty side +diff-tree --pretty -p side +diff-tree --pretty --patch-with-stat side + +diff-tree master +diff-tree -p master +diff-tree -p -m master +diff-tree -c master +diff-tree -c --abbrev master +diff-tree --cc master + +log master +log -p master +log --root master +log --root -p master +log --patch-with-stat master +log --root --patch-with-stat master +#log --root --patch-with-stat --summary master +log -SF master + +whatchanged master +whatchanged -p master +whatchanged --root master +whatchanged --root -p master +whatchanged --patch-with-stat master +whatchanged --root --patch-with-stat master +whatchanged --root --patch-with-stat --summary master +whatchanged -SF master + +log --patch-with-stat master -- dir/ +whatchanged --patch-with-stat master -- dir/ + +show initial +show --root initial +show side +show master +show --stat side +show --stat --summary side +show --patch-with-stat side +show --patch-with-raw side +show --patch-with-stat --summary side + + + +EOF + +test_done diff --git a/t/t4013/diff.diff-tree_--cc_master b/t/t4013/diff.diff-tree_--cc_master new file mode 100644 index 000000000..e57d943bd --- /dev/null +++ b/t/t4013/diff.diff-tree_--cc_master @@ -0,0 +1,30 @@ +$ git diff-tree --cc master +176b998f5d647cbd77a9d8acf4531e930754d16d +diff --cc dir/sub +index cead32e,7289e35..992913c +--- a/dir/sub ++++ b/dir/sub +@@@ -1,6 -1,4 +1,8 @@@ + A + B + +C + +D + +E + +F ++ 1 ++ 2 +diff --cc file0 +index b414108,f4615da..10a8a9f +--- a/file0 ++++ b/file0 +@@@ -1,6 -1,6 +1,9 @@@ + 1 + 2 + 3 + +4 + +5 + +6 ++ A ++ B ++ C +$ diff --git a/t/t4013/diff.diff-tree_--patch-with-raw_initial b/t/t4013/diff.diff-tree_--patch-with-raw_initial new file mode 100644 index 000000000..fc177ab3f --- /dev/null +++ b/t/t4013/diff.diff-tree_--patch-with-raw_initial @@ -0,0 +1,2 @@ +$ git diff-tree --patch-with-raw initial +$ diff --git a/t/t4013/diff.diff-tree_--patch-with-stat_initial b/t/t4013/diff.diff-tree_--patch-with-stat_initial new file mode 100644 index 000000000..bd905b1c5 --- /dev/null +++ b/t/t4013/diff.diff-tree_--patch-with-stat_initial @@ -0,0 +1,2 @@ +$ git diff-tree --patch-with-stat initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_--patch-with-raw_initial b/t/t4013/diff.diff-tree_--pretty=oneline_--patch-with-raw_initial new file mode 100644 index 000000000..7bb8b45e3 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty=oneline_--patch-with-raw_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty=oneline --patch-with-raw initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_--patch-with-stat_initial b/t/t4013/diff.diff-tree_--pretty=oneline_--patch-with-stat_initial new file mode 100644 index 000000000..cbdde4f40 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty=oneline_--patch-with-stat_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty=oneline --patch-with-stat initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-raw_initial b/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-raw_initial new file mode 100644 index 000000000..cd79f1a0f --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-raw_initial @@ -0,0 +1,33 @@ +$ git diff-tree --pretty=oneline --root --patch-with-raw initial +444ac553ac7612cc88969031b02b3767fb8a353a Initial +:000000 100644 0000000000000000000000000000000000000000 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e A dir/sub +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0 +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial b/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial new file mode 100644 index 000000000..49e26fb99 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial @@ -0,0 +1,35 @@ +$ git diff-tree --pretty=oneline --root --patch-with-stat initial +444ac553ac7612cc88969031b02b3767fb8a353a Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_--root_-p_initial b/t/t4013/diff.diff-tree_--pretty=oneline_--root_-p_initial new file mode 100644 index 000000000..3c5092c69 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty=oneline_--root_-p_initial @@ -0,0 +1,29 @@ +$ git diff-tree --pretty=oneline --root -p initial +444ac553ac7612cc88969031b02b3767fb8a353a Initial +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_--root_initial b/t/t4013/diff.diff-tree_--pretty=oneline_--root_initial new file mode 100644 index 000000000..08920ac65 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty=oneline_--root_initial @@ -0,0 +1,6 @@ +$ git diff-tree --pretty=oneline --root initial +444ac553ac7612cc88969031b02b3767fb8a353a Initial +:000000 040000 0000000000000000000000000000000000000000 da7a33fa77d8066d6698643940ce5860fe2d7fb3 A dir +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0 +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2 +$ diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_-p_initial b/t/t4013/diff.diff-tree_--pretty=oneline_-p_initial new file mode 100644 index 000000000..94b76bfef --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty=oneline_-p_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty=oneline -p initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_initial b/t/t4013/diff.diff-tree_--pretty=oneline_initial new file mode 100644 index 000000000..d50970d57 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty=oneline_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty=oneline initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--patch-with-raw_initial b/t/t4013/diff.diff-tree_--pretty_--patch-with-raw_initial new file mode 100644 index 000000000..3a85316d8 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--patch-with-raw_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty --patch-with-raw initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--patch-with-stat_initial b/t/t4013/diff.diff-tree_--pretty_--patch-with-stat_initial new file mode 100644 index 000000000..2e08239a4 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--patch-with-stat_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty --patch-with-stat initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--patch-with-stat_side b/t/t4013/diff.diff-tree_--pretty_--patch-with-stat_side new file mode 100644 index 000000000..4d30e7edd --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--patch-with-stat_side @@ -0,0 +1,43 @@ +$ git diff-tree --pretty --patch-with-stat side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-raw_initial b/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-raw_initial new file mode 100644 index 000000000..a3203bd19 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-raw_initial @@ -0,0 +1,38 @@ +$ git diff-tree --pretty --root --patch-with-raw initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + +:000000 100644 0000000000000000000000000000000000000000 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e A dir/sub +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0 +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-stat_initial b/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-stat_initial new file mode 100644 index 000000000..7dfa6af3c --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-stat_initial @@ -0,0 +1,39 @@ +$ git diff-tree --pretty --root --patch-with-stat initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--stat_--summary_initial b/t/t4013/diff.diff-tree_--pretty_--root_--stat_--summary_initial new file mode 100644 index 000000000..43bfce253 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--root_--stat_--summary_initial @@ -0,0 +1,15 @@ +$ git diff-tree --pretty --root --stat --summary initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + create mode 100644 dir/sub + create mode 100644 file0 + create mode 100644 file2 +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--stat_initial b/t/t4013/diff.diff-tree_--pretty_--root_--stat_initial new file mode 100644 index 000000000..9154aa4d4 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--root_--stat_initial @@ -0,0 +1,12 @@ +$ git diff-tree --pretty --root --stat initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--root_-p_initial b/t/t4013/diff.diff-tree_--pretty_--root_-p_initial new file mode 100644 index 000000000..d0411f64e --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--root_-p_initial @@ -0,0 +1,34 @@ +$ git diff-tree --pretty --root -p initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--root_initial b/t/t4013/diff.diff-tree_--pretty_--root_initial new file mode 100644 index 000000000..94e32eabb --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--root_initial @@ -0,0 +1,11 @@ +$ git diff-tree --pretty --root initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + +:000000 040000 0000000000000000000000000000000000000000 da7a33fa77d8066d6698643940ce5860fe2d7fb3 A dir +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0 +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2 +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--stat_--summary_initial b/t/t4013/diff.diff-tree_--pretty_--stat_--summary_initial new file mode 100644 index 000000000..c22983ac4 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--stat_--summary_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty --stat --summary initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--stat_initial b/t/t4013/diff.diff-tree_--pretty_--stat_initial new file mode 100644 index 000000000..8fdcfb4c0 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--stat_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty --stat initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--summary_initial b/t/t4013/diff.diff-tree_--pretty_--summary_initial new file mode 100644 index 000000000..9bc2c4fba --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--summary_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty --summary initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty_-p_initial b/t/t4013/diff.diff-tree_--pretty_-p_initial new file mode 100644 index 000000000..3c9942faf --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_-p_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty -p initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty_-p_side b/t/t4013/diff.diff-tree_--pretty_-p_side new file mode 100644 index 000000000..b993aa7b8 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_-p_side @@ -0,0 +1,38 @@ +$ git diff-tree --pretty -p side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff-tree_--pretty_initial b/t/t4013/diff.diff-tree_--pretty_initial new file mode 100644 index 000000000..14715bf7d --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_initial @@ -0,0 +1,2 @@ +$ git diff-tree --pretty initial +$ diff --git a/t/t4013/diff.diff-tree_--pretty_side b/t/t4013/diff.diff-tree_--pretty_side new file mode 100644 index 000000000..e9b6e1c10 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_side @@ -0,0 +1,11 @@ +$ git diff-tree --pretty side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +:040000 040000 da7a33fa77d8066d6698643940ce5860fe2d7fb3 f977ed46ae6873c1c30ab878e15a4accedc3618b M dir +:100644 100644 01e79c32a8c99c557f0757da7cb6d65b3414466d f4615da674c09df322d6ba8d6b21ecfb1b1ba510 M file0 +:000000 100644 0000000000000000000000000000000000000000 7289e35bff32727c08dda207511bec138fdb9ea5 A file3 +$ diff --git a/t/t4013/diff.diff-tree_--root_--abbrev_initial b/t/t4013/diff.diff-tree_--root_--abbrev_initial new file mode 100644 index 000000000..5aa84b2a8 --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_--abbrev_initial @@ -0,0 +1,6 @@ +$ git diff-tree --root --abbrev initial +444ac553ac7612cc88969031b02b3767fb8a353a +:000000 040000 0000000... da7a33f... A dir +:000000 100644 0000000... 01e79c3... A file0 +:000000 100644 0000000... 01e79c3... A file2 +$ diff --git a/t/t4013/diff.diff-tree_--root_--patch-with-raw_initial b/t/t4013/diff.diff-tree_--root_--patch-with-raw_initial new file mode 100644 index 000000000..d295e475d --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_--patch-with-raw_initial @@ -0,0 +1,33 @@ +$ git diff-tree --root --patch-with-raw initial +444ac553ac7612cc88969031b02b3767fb8a353a +:000000 100644 0000000000000000000000000000000000000000 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e A dir/sub +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0 +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--root_--patch-with-stat_initial b/t/t4013/diff.diff-tree_--root_--patch-with-stat_initial new file mode 100644 index 000000000..1562b6270 --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_--patch-with-stat_initial @@ -0,0 +1,34 @@ +$ git diff-tree --root --patch-with-stat initial +444ac553ac7612cc88969031b02b3767fb8a353a + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--root_-p_initial b/t/t4013/diff.diff-tree_--root_-p_initial new file mode 100644 index 000000000..3219c72fc --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_-p_initial @@ -0,0 +1,29 @@ +$ git diff-tree --root -p initial +444ac553ac7612cc88969031b02b3767fb8a353a +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--root_-r_--abbrev=4_initial b/t/t4013/diff.diff-tree_--root_-r_--abbrev=4_initial new file mode 100644 index 000000000..0c5361688 --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_-r_--abbrev=4_initial @@ -0,0 +1,6 @@ +$ git diff-tree --root -r --abbrev=4 initial +444ac553ac7612cc88969031b02b3767fb8a353a +:000000 100644 0000... 35d2... A dir/sub +:000000 100644 0000... 01e7... A file0 +:000000 100644 0000... 01e7... A file2 +$ diff --git a/t/t4013/diff.diff-tree_--root_-r_--abbrev_initial b/t/t4013/diff.diff-tree_--root_-r_--abbrev_initial new file mode 100644 index 000000000..c7b460faf --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_-r_--abbrev_initial @@ -0,0 +1,6 @@ +$ git diff-tree --root -r --abbrev initial +444ac553ac7612cc88969031b02b3767fb8a353a +:000000 100644 0000000... 35d242b... A dir/sub +:000000 100644 0000000... 01e79c3... A file0 +:000000 100644 0000000... 01e79c3... A file2 +$ diff --git a/t/t4013/diff.diff-tree_--root_-r_initial b/t/t4013/diff.diff-tree_--root_-r_initial new file mode 100644 index 000000000..eed435e17 --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_-r_initial @@ -0,0 +1,6 @@ +$ git diff-tree --root -r initial +444ac553ac7612cc88969031b02b3767fb8a353a +:000000 100644 0000000000000000000000000000000000000000 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e A dir/sub +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0 +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2 +$ diff --git a/t/t4013/diff.diff-tree_--root_initial b/t/t4013/diff.diff-tree_--root_initial new file mode 100644 index 000000000..ddf6b068a --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_initial @@ -0,0 +1,6 @@ +$ git diff-tree --root initial +444ac553ac7612cc88969031b02b3767fb8a353a +:000000 040000 0000000000000000000000000000000000000000 da7a33fa77d8066d6698643940ce5860fe2d7fb3 A dir +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0 +:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2 +$ diff --git a/t/t4013/diff.diff-tree_-c_--abbrev_master b/t/t4013/diff.diff-tree_-c_--abbrev_master new file mode 100644 index 000000000..39d511a7c --- /dev/null +++ b/t/t4013/diff.diff-tree_-c_--abbrev_master @@ -0,0 +1,5 @@ +$ git diff-tree -c --abbrev master +176b998f5d647cbd77a9d8acf4531e930754d16d +::100644 100644 100644 cead32e... 7289e35... 992913c... MM dir/sub +::100644 100644 100644 b414108... f4615da... 10a8a9f... MM file0 +$ diff --git a/t/t4013/diff.diff-tree_-c_master b/t/t4013/diff.diff-tree_-c_master new file mode 100644 index 000000000..c258efe22 --- /dev/null +++ b/t/t4013/diff.diff-tree_-c_master @@ -0,0 +1,5 @@ +$ git diff-tree -c master +176b998f5d647cbd77a9d8acf4531e930754d16d +::100644 100644 100644 cead32e925b1420c84c14cbf7cf755e7e45af8ad 7289e35bff32727c08dda207511bec138fdb9ea5 992913c5aa0a5476d10c49ed0f21fc0c6d1aedf3 MM dir/sub +::100644 100644 100644 b414108e81e5091fe0974a1858b4d0d22b107f70 f4615da674c09df322d6ba8d6b21ecfb1b1ba510 10a8a9f3657f91a156b9f0184ed79a20adef9f7f MM file0 +$ diff --git a/t/t4013/diff.diff-tree_-p_-m_master b/t/t4013/diff.diff-tree_-p_-m_master new file mode 100644 index 000000000..1be721560 --- /dev/null +++ b/t/t4013/diff.diff-tree_-p_-m_master @@ -0,0 +1,80 @@ +$ git diff-tree -p -m master +176b998f5d647cbd77a9d8acf4531e930754d16d +diff --git a/dir/sub b/dir/sub +index cead32e..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -4,3 +4,5 @@ C + D + E + F ++1 ++2 +diff --git a/file0 b/file0 +index b414108..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -4,3 +4,6 @@ + 4 + 5 + 6 ++A ++B ++C +176b998f5d647cbd77a9d8acf4531e930754d16d +diff --git a/dir/sub b/dir/sub +index 7289e35..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,4 +1,8 @@ + A + B ++C ++D ++E ++F + 1 + 2 +diff --git a/file0 b/file0 +index f4615da..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -1,6 +1,9 @@ + 1 + 2 + 3 ++4 ++5 ++6 + A + B + C +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 +diff --git a/file3 b/file3 +deleted file mode 100644 +index 7289e35..0000000 +--- a/file3 ++++ /dev/null +@@ -1,4 +0,0 @@ +-A +-B +-1 +-2 +$ diff --git a/t/t4013/diff.diff-tree_-p_initial b/t/t4013/diff.diff-tree_-p_initial new file mode 100644 index 000000000..e20ce8837 --- /dev/null +++ b/t/t4013/diff.diff-tree_-p_initial @@ -0,0 +1,2 @@ +$ git diff-tree -p initial +$ diff --git a/t/t4013/diff.diff-tree_-p_master b/t/t4013/diff.diff-tree_-p_master new file mode 100644 index 000000000..b182875fb --- /dev/null +++ b/t/t4013/diff.diff-tree_-p_master @@ -0,0 +1,2 @@ +$ git diff-tree -p master +$ diff --git a/t/t4013/diff.diff-tree_-r_--abbrev=4_initial b/t/t4013/diff.diff-tree_-r_--abbrev=4_initial new file mode 100644 index 000000000..c5a3aa5aa --- /dev/null +++ b/t/t4013/diff.diff-tree_-r_--abbrev=4_initial @@ -0,0 +1,2 @@ +$ git diff-tree -r --abbrev=4 initial +$ diff --git a/t/t4013/diff.diff-tree_-r_--abbrev_initial b/t/t4013/diff.diff-tree_-r_--abbrev_initial new file mode 100644 index 000000000..0b689b773 --- /dev/null +++ b/t/t4013/diff.diff-tree_-r_--abbrev_initial @@ -0,0 +1,2 @@ +$ git diff-tree -r --abbrev initial +$ diff --git a/t/t4013/diff.diff-tree_-r_initial b/t/t4013/diff.diff-tree_-r_initial new file mode 100644 index 000000000..1765d83ce --- /dev/null +++ b/t/t4013/diff.diff-tree_-r_initial @@ -0,0 +1,2 @@ +$ git diff-tree -r initial +$ diff --git a/t/t4013/diff.diff-tree_initial b/t/t4013/diff.diff-tree_initial new file mode 100644 index 000000000..b49fc5345 --- /dev/null +++ b/t/t4013/diff.diff-tree_initial @@ -0,0 +1,2 @@ +$ git diff-tree initial +$ diff --git a/t/t4013/diff.diff-tree_master b/t/t4013/diff.diff-tree_master new file mode 100644 index 000000000..fe9226f8a --- /dev/null +++ b/t/t4013/diff.diff-tree_master @@ -0,0 +1,2 @@ +$ git diff-tree master +$ diff --git a/t/t4013/diff.log_--patch-with-stat_master b/t/t4013/diff.log_--patch-with-stat_master new file mode 100644 index 000000000..b97969dc9 --- /dev/null +++ b/t/t4013/diff.log_--patch-with-stat_master @@ -0,0 +1,127 @@ +$ git log --patch-with-stat master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.log_--patch-with-stat_master_--_dir_ b/t/t4013/diff.log_--patch-with-stat_master_--_dir_ new file mode 100644 index 000000000..71a6d0f85 --- /dev/null +++ b/t/t4013/diff.log_--patch-with-stat_master_--_dir_ @@ -0,0 +1,72 @@ +$ git log --patch-with-stat master -- dir/ +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.log_--root_--patch-with-stat_master b/t/t4013/diff.log_--root_--patch-with-stat_master new file mode 100644 index 000000000..1e9bdc4c1 --- /dev/null +++ b/t/t4013/diff.log_--root_--patch-with-stat_master @@ -0,0 +1,159 @@ +$ git log --root --patch-with-stat master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.log_--root_-p_master b/t/t4013/diff.log_--root_-p_master new file mode 100644 index 000000000..2296986ad --- /dev/null +++ b/t/t4013/diff.log_--root_-p_master @@ -0,0 +1,140 @@ +$ git log --root -p master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.log_--root_master b/t/t4013/diff.log_--root_master new file mode 100644 index 000000000..7554a468d --- /dev/null +++ b/t/t4013/diff.log_--root_master @@ -0,0 +1,32 @@ +$ git log --root master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.log_-SF_master b/t/t4013/diff.log_-SF_master new file mode 100644 index 000000000..f307b4d2a --- /dev/null +++ b/t/t4013/diff.log_-SF_master @@ -0,0 +1,8 @@ +$ git log -SF master +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +$ diff --git a/t/t4013/diff.log_-p_master b/t/t4013/diff.log_-p_master new file mode 100644 index 000000000..e82a72f6f --- /dev/null +++ b/t/t4013/diff.log_-p_master @@ -0,0 +1,113 @@ +$ git log -p master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.log_master b/t/t4013/diff.log_master new file mode 100644 index 000000000..7b86ed1f5 --- /dev/null +++ b/t/t4013/diff.log_master @@ -0,0 +1,32 @@ +$ git log master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.show_--patch-with-raw_side b/t/t4013/diff.show_--patch-with-raw_side new file mode 100644 index 000000000..221b46a7c --- /dev/null +++ b/t/t4013/diff.show_--patch-with-raw_side @@ -0,0 +1,42 @@ +$ git show --patch-with-raw side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +:100644 100644 35d242b... 7289e35... M dir/sub +:100644 100644 01e79c3... f4615da... M file0 +:000000 100644 0000000... 7289e35... A file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.show_--patch-with-stat_--summary_side b/t/t4013/diff.show_--patch-with-stat_--summary_side new file mode 100644 index 000000000..377f2b7b7 --- /dev/null +++ b/t/t4013/diff.show_--patch-with-stat_--summary_side @@ -0,0 +1,44 @@ +$ git show --patch-with-stat --summary side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.show_--patch-with-stat_side b/t/t4013/diff.show_--patch-with-stat_side new file mode 100644 index 000000000..fb14c530d --- /dev/null +++ b/t/t4013/diff.show_--patch-with-stat_side @@ -0,0 +1,43 @@ +$ git show --patch-with-stat side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.show_--root_initial b/t/t4013/diff.show_--root_initial new file mode 100644 index 000000000..8c89136c4 --- /dev/null +++ b/t/t4013/diff.show_--root_initial @@ -0,0 +1,34 @@ +$ git show --root initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.show_--stat_--summary_side b/t/t4013/diff.show_--stat_--summary_side new file mode 100644 index 000000000..5bd597762 --- /dev/null +++ b/t/t4013/diff.show_--stat_--summary_side @@ -0,0 +1,13 @@ +$ git show --stat --summary side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 +$ diff --git a/t/t4013/diff.show_--stat_side b/t/t4013/diff.show_--stat_side new file mode 100644 index 000000000..3b22327e4 --- /dev/null +++ b/t/t4013/diff.show_--stat_side @@ -0,0 +1,12 @@ +$ git show --stat side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) +$ diff --git a/t/t4013/diff.show_initial b/t/t4013/diff.show_initial new file mode 100644 index 000000000..4c4066ae4 --- /dev/null +++ b/t/t4013/diff.show_initial @@ -0,0 +1,7 @@ +$ git show initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.show_master b/t/t4013/diff.show_master new file mode 100644 index 000000000..3772a87e1 --- /dev/null +++ b/t/t4013/diff.show_master @@ -0,0 +1,36 @@ +$ git show master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +diff --cc dir/sub +index cead32e,7289e35..992913c +--- a/dir/sub ++++ b/dir/sub +@@@ -1,6 -1,4 +1,8 @@@ + A + B + +C + +D + +E + +F ++ 1 ++ 2 +diff --cc file0 +index b414108,f4615da..10a8a9f +--- a/file0 ++++ b/file0 +@@@ -1,6 -1,6 +1,9 @@@ + 1 + 2 + 3 + +4 + +5 + +6 ++ A ++ B ++ C +$ diff --git a/t/t4013/diff.show_side b/t/t4013/diff.show_side new file mode 100644 index 000000000..530a073b1 --- /dev/null +++ b/t/t4013/diff.show_side @@ -0,0 +1,38 @@ +$ git show side +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.whatchanged_--patch-with-stat_master b/t/t4013/diff.whatchanged_--patch-with-stat_master new file mode 100644 index 000000000..a89b573f4 --- /dev/null +++ b/t/t4013/diff.whatchanged_--patch-with-stat_master @@ -0,0 +1,114 @@ +$ git whatchanged --patch-with-stat master +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 +$ diff --git a/t/t4013/diff.whatchanged_--patch-with-stat_master_--_dir_ b/t/t4013/diff.whatchanged_--patch-with-stat_master_--_dir_ new file mode 100644 index 000000000..b6d975216 --- /dev/null +++ b/t/t4013/diff.whatchanged_--patch-with-stat_master_--_dir_ @@ -0,0 +1,59 @@ +$ git whatchanged --patch-with-stat master -- dir/ +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +$ diff --git a/t/t4013/diff.whatchanged_--root_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_--patch-with-stat_--summary_master new file mode 100644 index 000000000..f707bfa3a --- /dev/null +++ b/t/t4013/diff.whatchanged_--root_--patch-with-stat_--summary_master @@ -0,0 +1,158 @@ +$ git whatchanged --root --patch-with-stat --summary master +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + create mode 100644 dir/sub + create mode 100644 file0 + create mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.whatchanged_--root_--patch-with-stat_master b/t/t4013/diff.whatchanged_--root_--patch-with-stat_master new file mode 100644 index 000000000..61aca4171 --- /dev/null +++ b/t/t4013/diff.whatchanged_--root_--patch-with-stat_master @@ -0,0 +1,152 @@ +$ git whatchanged --root --patch-with-stat master +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.whatchanged_--root_-p_master b/t/t4013/diff.whatchanged_--root_-p_master new file mode 100644 index 000000000..b4cd05e57 --- /dev/null +++ b/t/t4013/diff.whatchanged_--root_-p_master @@ -0,0 +1,133 @@ +$ git whatchanged --root -p master +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.whatchanged_--root_master b/t/t4013/diff.whatchanged_--root_master new file mode 100644 index 000000000..011a22178 --- /dev/null +++ b/t/t4013/diff.whatchanged_--root_master @@ -0,0 +1,40 @@ +$ git whatchanged --root master +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +:100644 100644 35d242b... 7289e35... M dir/sub +:100644 100644 01e79c3... f4615da... M file0 +:000000 100644 0000000... 7289e35... A file3 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +:100644 100644 8422d40... cead32e... M dir/sub +:000000 100644 0000000... b1e6722... A file1 + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + +:100644 100644 35d242b... 8422d40... M dir/sub +:100644 100644 01e79c3... b414108... M file0 +:100644 000000 01e79c3... 0000000... D file2 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + +:000000 100644 0000000... 35d242b... A dir/sub +:000000 100644 0000000... 01e79c3... A file0 +:000000 100644 0000000... 01e79c3... A file2 +$ diff --git a/t/t4013/diff.whatchanged_-SF_master b/t/t4013/diff.whatchanged_-SF_master new file mode 100644 index 000000000..a4fe6f8a3 --- /dev/null +++ b/t/t4013/diff.whatchanged_-SF_master @@ -0,0 +1,9 @@ +$ git whatchanged -SF master +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +:100644 100644 8422d40... cead32e... M dir/sub +$ diff --git a/t/t4013/diff.whatchanged_-p_master b/t/t4013/diff.whatchanged_-p_master new file mode 100644 index 000000000..f9a445672 --- /dev/null +++ b/t/t4013/diff.whatchanged_-p_master @@ -0,0 +1,100 @@ +$ git whatchanged -p master +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 +$ diff --git a/t/t4013/diff.whatchanged_master b/t/t4013/diff.whatchanged_master new file mode 100644 index 000000000..c22416c00 --- /dev/null +++ b/t/t4013/diff.whatchanged_master @@ -0,0 +1,30 @@ +$ git whatchanged master +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +:100644 100644 35d242b... 7289e35... M dir/sub +:100644 100644 01e79c3... f4615da... M file0 +:000000 100644 0000000... 7289e35... A file3 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +:100644 100644 8422d40... cead32e... M dir/sub +:000000 100644 0000000... b1e6722... A file1 + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + +:100644 100644 35d242b... 8422d40... M dir/sub +:100644 100644 01e79c3... b414108... M file0 +:100644 000000 01e79c3... 0000000... D file2 +$ -- cgit v1.2.1 From c6744349df5089133b7662e67aba28282b6a963f Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sat, 24 Jun 2006 20:21:53 +0300 Subject: Merge with_raw, with_stat and summary variables to output_format DIFF_FORMAT_* are now bit-flags instead of enumerated values. Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- builtin-diff.c | 2 +- builtin-log.c | 4 +- combine-diff.c | 55 ++++++++--------- diff.c | 183 +++++++++++++++++++++++++++------------------------------ diff.h | 27 +++++---- log-tree.c | 9 ++- 6 files changed, 136 insertions(+), 144 deletions(-) diff --git a/builtin-diff.c b/builtin-diff.c index 99a2f7660..3b44296ff 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -56,7 +56,7 @@ static int builtin_diff_files(struct rev_info *revs, 3 < revs->max_count) usage(builtin_diff_usage); if (revs->max_count < 0 && - (revs->diffopt.output_format == DIFF_FORMAT_PATCH)) + (revs->diffopt.output_format & DIFF_FORMAT_PATCH)) revs->combine_merges = revs->dense_combined_merges = 1; /* * Backward compatibility wart - "diff-files -s" used to diff --git a/builtin-log.c b/builtin-log.c index 44d2d136f..e321959c5 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -176,11 +176,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp) rev.commit_format = CMIT_FMT_EMAIL; rev.verbose_header = 1; rev.diff = 1; - rev.diffopt.with_raw = 0; - rev.diffopt.with_stat = 1; rev.combine_merges = 0; rev.ignore_merges = 1; - rev.diffopt.output_format = DIFF_FORMAT_PATCH; + rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH; git_config(git_format_config); rev.extra_headers = extra_headers; diff --git a/combine-diff.c b/combine-diff.c index 64b20cce2..3daa8cb13 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -771,7 +771,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re if (rev->loginfo) show_log(rev, rev->loginfo, "\n"); - if (opt->output_format == DIFF_FORMAT_RAW) { + if (opt->output_format & DIFF_FORMAT_RAW) { offset = strlen(COLONS) - num_parent; if (offset < 0) offset = 0; @@ -791,8 +791,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re printf(" %s ", diff_unique_abbrev(p->sha1, opt->abbrev)); } - if (opt->output_format == DIFF_FORMAT_RAW || - opt->output_format == DIFF_FORMAT_NAME_STATUS) { + if (opt->output_format & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS)) { for (i = 0; i < num_parent; i++) putchar(p->parent[i].status); putchar(inter_name_termination); @@ -818,17 +817,12 @@ void show_combined_diff(struct combine_diff_path *p, struct diff_options *opt = &rev->diffopt; if (!p->len) return; - switch (opt->output_format) { - case DIFF_FORMAT_RAW: - case DIFF_FORMAT_NAME_STATUS: - case DIFF_FORMAT_NAME: + if (opt->output_format & (DIFF_FORMAT_RAW | + DIFF_FORMAT_NAME | + DIFF_FORMAT_NAME_STATUS)) { show_raw_diff(p, num_parent, rev); - return; - case DIFF_FORMAT_PATCH: + } else if (opt->output_format & DIFF_FORMAT_PATCH) { show_patch_diff(p, num_parent, dense, rev); - return; - default: - return; } } @@ -842,13 +836,9 @@ void diff_tree_combined(const unsigned char *sha1, struct diff_options diffopts; struct combine_diff_path *p, *paths = NULL; int i, num_paths; - int do_diffstat; - do_diffstat = (opt->output_format == DIFF_FORMAT_DIFFSTAT || - opt->with_stat); diffopts = *opt; - diffopts.with_raw = 0; - diffopts.with_stat = 0; + diffopts.output_format &= ~(DIFF_FORMAT_RAW | DIFF_FORMAT_DIFFSTAT); diffopts.recursive = 1; /* find set of paths that everybody touches */ @@ -856,19 +846,18 @@ void diff_tree_combined(const unsigned char *sha1, /* show stat against the first parent even * when doing combined diff. */ - if (i == 0 && do_diffstat) - diffopts.output_format = DIFF_FORMAT_DIFFSTAT; + if (i == 0 && opt->output_format & DIFF_FORMAT_DIFFSTAT) + diffopts.output_format |= DIFF_FORMAT_DIFFSTAT; else - diffopts.output_format = DIFF_FORMAT_NO_OUTPUT; + diffopts.output_format |= DIFF_FORMAT_NO_OUTPUT; diff_tree_sha1(parent[i], sha1, "", &diffopts); diffcore_std(&diffopts); paths = intersect_paths(paths, i, num_parent); - if (do_diffstat && rev->loginfo) - show_log(rev, rev->loginfo, - opt->with_stat ? "---\n" : "\n"); + if (opt->output_format & DIFF_FORMAT_DIFFSTAT && rev->loginfo) + show_log(rev, rev->loginfo, "---\n"); diff_flush(&diffopts); - if (opt->with_stat) + if (opt->output_format & DIFF_FORMAT_DIFFSTAT) putchar('\n'); } @@ -878,17 +867,21 @@ void diff_tree_combined(const unsigned char *sha1, num_paths++; } if (num_paths) { - if (opt->with_raw) { - int saved_format = opt->output_format; - opt->output_format = DIFF_FORMAT_RAW; + if (opt->output_format & (DIFF_FORMAT_RAW | + DIFF_FORMAT_NAME | + DIFF_FORMAT_NAME_STATUS)) { for (p = paths; p; p = p->next) { - show_combined_diff(p, num_parent, dense, rev); + if (p->len) + show_raw_diff(p, num_parent, rev); } - opt->output_format = saved_format; putchar(opt->line_termination); } - for (p = paths; p; p = p->next) { - show_combined_diff(p, num_parent, dense, rev); + if (opt->output_format & DIFF_FORMAT_PATCH) { + for (p = paths; p; p = p->next) { + if (p->len) + show_patch_diff(p, num_parent, dense, + rev); + } } } diff --git a/diff.c b/diff.c index fbb6c26cd..49b2eeb74 100644 --- a/diff.c +++ b/diff.c @@ -1438,23 +1438,27 @@ int diff_setup_done(struct diff_options *options) (0 <= options->rename_limit && !options->detect_rename)) return -1; + if (options->output_format & DIFF_FORMAT_NO_OUTPUT) + options->output_format = 0; + + if (options->output_format & (DIFF_FORMAT_NAME | + DIFF_FORMAT_NAME_STATUS | + DIFF_FORMAT_CHECKDIFF | + DIFF_FORMAT_NO_OUTPUT)) + options->output_format &= ~(DIFF_FORMAT_RAW | + DIFF_FORMAT_DIFFSTAT | + DIFF_FORMAT_SUMMARY | + DIFF_FORMAT_PATCH); + /* * These cases always need recursive; we do not drop caller-supplied * recursive bits for other formats here. */ - if ((options->output_format == DIFF_FORMAT_PATCH) || - (options->output_format == DIFF_FORMAT_DIFFSTAT) || - (options->output_format == DIFF_FORMAT_CHECKDIFF)) + if (options->output_format & (DIFF_FORMAT_PATCH | + DIFF_FORMAT_DIFFSTAT | + DIFF_FORMAT_CHECKDIFF)) options->recursive = 1; - /* - * These combinations do not make sense. - */ - if (options->output_format == DIFF_FORMAT_RAW) - options->with_raw = 0; - if (options->output_format == DIFF_FORMAT_DIFFSTAT) - options->with_stat = 0; - if (options->detect_rename && options->rename_limit < 0) options->rename_limit = diff_rename_limit_default; if (options->setup & DIFF_SETUP_USE_CACHE) { @@ -1526,22 +1530,20 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) { const char *arg = av[0]; if (!strcmp(arg, "-p") || !strcmp(arg, "-u")) - options->output_format = DIFF_FORMAT_PATCH; + options->output_format |= DIFF_FORMAT_PATCH; else if (opt_arg(arg, 'U', "unified", &options->context)) - options->output_format = DIFF_FORMAT_PATCH; + options->output_format |= DIFF_FORMAT_PATCH; else if (!strcmp(arg, "--patch-with-raw")) { - options->output_format = DIFF_FORMAT_PATCH; - options->with_raw = 1; + options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW; } else if (!strcmp(arg, "--stat")) - options->output_format = DIFF_FORMAT_DIFFSTAT; + options->output_format |= DIFF_FORMAT_DIFFSTAT; else if (!strcmp(arg, "--check")) - options->output_format = DIFF_FORMAT_CHECKDIFF; + options->output_format |= DIFF_FORMAT_CHECKDIFF; else if (!strcmp(arg, "--summary")) - options->summary = 1; + options->output_format |= DIFF_FORMAT_SUMMARY; else if (!strcmp(arg, "--patch-with-stat")) { - options->output_format = DIFF_FORMAT_PATCH; - options->with_stat = 1; + options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT; } else if (!strcmp(arg, "-z")) options->line_termination = 0; @@ -1550,19 +1552,20 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) else if (!strcmp(arg, "--full-index")) options->full_index = 1; else if (!strcmp(arg, "--binary")) { - options->output_format = DIFF_FORMAT_PATCH; + options->output_format |= DIFF_FORMAT_PATCH; options->full_index = options->binary = 1; } else if (!strcmp(arg, "--name-only")) - options->output_format = DIFF_FORMAT_NAME; + options->output_format |= DIFF_FORMAT_NAME; else if (!strcmp(arg, "--name-status")) - options->output_format = DIFF_FORMAT_NAME_STATUS; + options->output_format |= DIFF_FORMAT_NAME_STATUS; else if (!strcmp(arg, "-R")) options->reverse_diff = 1; else if (!strncmp(arg, "-S", 2)) options->pickaxe = arg + 2; - else if (!strcmp(arg, "-s")) - options->output_format = DIFF_FORMAT_NO_OUTPUT; + else if (!strcmp(arg, "-s")) { + options->output_format |= DIFF_FORMAT_NO_OUTPUT; + } else if (!strncmp(arg, "-O", 2)) options->orderfile = arg + 2; else if (!strncmp(arg, "--diff-filter=", 14)) @@ -1737,15 +1740,17 @@ const char *diff_unique_abbrev(const unsigned char *sha1, int len) } static void diff_flush_raw(struct diff_filepair *p, - int line_termination, - int inter_name_termination, - struct diff_options *options, - int output_format) + struct diff_options *options) { int two_paths; char status[10]; int abbrev = options->abbrev; const char *path_one, *path_two; + int inter_name_termination = '\t'; + int line_termination = options->line_termination; + + if (!line_termination) + inter_name_termination = 0; path_one = p->one->path; path_two = p->two->path; @@ -1774,7 +1779,7 @@ static void diff_flush_raw(struct diff_filepair *p, two_paths = 0; break; } - if (output_format != DIFF_FORMAT_NAME_STATUS) { + if (!(options->output_format & DIFF_FORMAT_NAME_STATUS)) { printf(":%06o %06o %s ", p->one->mode, p->two->mode, diff_unique_abbrev(p->one->sha1, abbrev)); @@ -1983,48 +1988,30 @@ static void diff_resolve_rename_copy(void) diff_debug_queue("resolve-rename-copy done", q); } -static void flush_one_pair(struct diff_filepair *p, - int diff_output_format, - struct diff_options *options, - struct diffstat_t *diffstat) +static int check_pair_status(struct diff_filepair *p) { - int inter_name_termination = '\t'; - int line_termination = options->line_termination; - if (!line_termination) - inter_name_termination = 0; - switch (p->status) { case DIFF_STATUS_UNKNOWN: - break; + return 0; case 0: die("internal error in diff-resolve-rename-copy"); - break; default: - switch (diff_output_format) { - case DIFF_FORMAT_DIFFSTAT: - diff_flush_stat(p, options, diffstat); - break; - case DIFF_FORMAT_CHECKDIFF: - diff_flush_checkdiff(p, options); - break; - case DIFF_FORMAT_PATCH: - diff_flush_patch(p, options); - break; - case DIFF_FORMAT_RAW: - case DIFF_FORMAT_NAME_STATUS: - diff_flush_raw(p, line_termination, - inter_name_termination, - options, diff_output_format); - break; - case DIFF_FORMAT_NAME: - diff_flush_name(p, line_termination); - break; - case DIFF_FORMAT_NO_OUTPUT: - break; - } + return 1; } } +static void flush_one_pair(struct diff_filepair *p, struct diff_options *opt) +{ + int fmt = opt->output_format; + + if (fmt & DIFF_FORMAT_CHECKDIFF) + diff_flush_checkdiff(p, opt); + else if (fmt & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS)) + diff_flush_raw(p, opt); + else if (fmt & DIFF_FORMAT_NAME) + diff_flush_name(p, opt->line_termination); +} + static void show_file_mode_name(const char *newdelete, struct diff_filespec *fs) { if (fs->mode) @@ -2107,55 +2094,61 @@ static void diff_summary(struct diff_filepair *p) void diff_flush(struct diff_options *options) { struct diff_queue_struct *q = &diff_queued_diff; - int i; - int diff_output_format = options->output_format; - struct diffstat_t *diffstat = NULL; + int i, output_format = options->output_format; - if (diff_output_format == DIFF_FORMAT_DIFFSTAT || options->with_stat) { - diffstat = xcalloc(sizeof (struct diffstat_t), 1); - diffstat->xm.consume = diffstat_consume; - } + /* + * Order: raw, stat, summary, patch + * or: name/name-status/checkdiff (other bits clear) + */ - if (options->with_raw) { + if (output_format & (DIFF_FORMAT_RAW | + DIFF_FORMAT_NAME | + DIFF_FORMAT_NAME_STATUS | + DIFF_FORMAT_CHECKDIFF)) { for (i = 0; i < q->nr; i++) { struct diff_filepair *p = q->queue[i]; - flush_one_pair(p, DIFF_FORMAT_RAW, options, NULL); + if (check_pair_status(p)) + flush_one_pair(p, options); } - putchar(options->line_termination); } - if (options->with_stat) { + + if (output_format & DIFF_FORMAT_DIFFSTAT) { + struct diffstat_t *diffstat; + + diffstat = xcalloc(sizeof (struct diffstat_t), 1); + diffstat->xm.consume = diffstat_consume; for (i = 0; i < q->nr; i++) { struct diff_filepair *p = q->queue[i]; - flush_one_pair(p, DIFF_FORMAT_DIFFSTAT, options, - diffstat); + if (check_pair_status(p)) + diff_flush_stat(p, options, diffstat); } show_stats(diffstat); free(diffstat); - diffstat = NULL; - if (options->summary) - for (i = 0; i < q->nr; i++) - diff_summary(q->queue[i]); - if (options->stat_sep) - fputs(options->stat_sep, stdout); - else - putchar(options->line_termination); - } - for (i = 0; i < q->nr; i++) { - struct diff_filepair *p = q->queue[i]; - flush_one_pair(p, diff_output_format, options, diffstat); } - if (diffstat) { - show_stats(diffstat); - free(diffstat); + if (output_format & DIFF_FORMAT_SUMMARY) { + for (i = 0; i < q->nr; i++) + diff_summary(q->queue[i]); } - for (i = 0; i < q->nr; i++) { - if (diffstat && options->summary) - diff_summary(q->queue[i]); - diff_free_filepair(q->queue[i]); + if (output_format & DIFF_FORMAT_PATCH) { + if (output_format & (DIFF_FORMAT_DIFFSTAT | + DIFF_FORMAT_SUMMARY)) { + if (options->stat_sep) + fputs(options->stat_sep, stdout); + else + putchar(options->line_termination); + } + + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + if (check_pair_status(p)) + diff_flush_patch(p, options); + } } + for (i = 0; i < q->nr; i++) + diff_free_filepair(q->queue[i]); free(q->queue); q->queue = NULL; q->nr = q->alloc = 0; diff --git a/diff.h b/diff.h index b61fdc8f1..2b6dc0cbe 100644 --- a/diff.h +++ b/diff.h @@ -20,19 +20,31 @@ typedef void (*add_remove_fn_t)(struct diff_options *options, const unsigned char *sha1, const char *base, const char *path); +#define DIFF_FORMAT_RAW 0x0001 +#define DIFF_FORMAT_DIFFSTAT 0x0002 +#define DIFF_FORMAT_SUMMARY 0x0004 +#define DIFF_FORMAT_PATCH 0x0008 + +/* These override all above */ +#define DIFF_FORMAT_NAME 0x0010 +#define DIFF_FORMAT_NAME_STATUS 0x0020 +#define DIFF_FORMAT_CHECKDIFF 0x0040 + +/* Same as output_format = 0 but we know that -s flag was given + * and we should not give default value to output_format. + */ +#define DIFF_FORMAT_NO_OUTPUT 0x0080 + struct diff_options { const char *filter; const char *orderfile; const char *pickaxe; unsigned recursive:1, - with_raw:1, - with_stat:1, tree_in_recursive:1, binary:1, full_index:1, silent_on_remove:1, find_copies_harder:1, - summary:1, color_diff:1; int context; int break_opt; @@ -151,15 +163,6 @@ extern void diffcore_std_no_resolve(struct diff_options *); " show all files diff when -S is used and hit is found.\n" extern int diff_queue_is_empty(void); - -#define DIFF_FORMAT_RAW 1 -#define DIFF_FORMAT_PATCH 2 -#define DIFF_FORMAT_NO_OUTPUT 3 -#define DIFF_FORMAT_NAME 4 -#define DIFF_FORMAT_NAME_STATUS 5 -#define DIFF_FORMAT_DIFFSTAT 6 -#define DIFF_FORMAT_CHECKDIFF 7 - extern void diff_flush(struct diff_options*); /* diff-raw status letters */ diff --git a/log-tree.c b/log-tree.c index ebb49f297..7d4c51f95 100644 --- a/log-tree.c +++ b/log-tree.c @@ -163,8 +163,13 @@ int log_tree_diff_flush(struct rev_info *opt) return 0; } - if (opt->loginfo && !opt->no_commit_id) - show_log(opt, opt->loginfo, opt->diffopt.with_stat ? "---\n" : "\n"); + if (opt->loginfo && !opt->no_commit_id) { + if (opt->diffopt.output_format & DIFF_FORMAT_DIFFSTAT) { + show_log(opt, opt->loginfo, "---\n"); + } else { + show_log(opt, opt->loginfo, "\n"); + } + } diff_flush(&opt->diffopt); return 1; } -- cgit v1.2.1 From a610786f4bc282410d348aba97316115a57740a0 Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sat, 24 Jun 2006 20:23:06 +0300 Subject: Make --raw option available for all diff commands Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- builtin-diff.c | 48 ++++++++++++------------------------------------ diff.c | 2 ++ 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/builtin-diff.c b/builtin-diff.c index 3b44296ff..91235a118 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -39,8 +39,6 @@ static int builtin_diff_files(struct rev_info *revs, revs->max_count = 3; else if (!strcmp(arg, "-q")) silent = 1; - else if (!strcmp(arg, "--raw")) - revs->diffopt.output_format = DIFF_FORMAT_RAW; else usage(builtin_diff_usage); argv++; argc--; @@ -107,14 +105,9 @@ static int builtin_diff_b_f(struct rev_info *revs, /* Blob vs file in the working tree*/ struct stat st; - while (1 < argc) { - const char *arg = argv[1]; - if (!strcmp(arg, "--raw")) - revs->diffopt.output_format = DIFF_FORMAT_RAW; - else - usage(builtin_diff_usage); - argv++; argc--; - } + if (argc > 1) + usage(builtin_diff_usage); + if (lstat(path, &st)) die("'%s': %s", path, strerror(errno)); if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))) @@ -137,14 +130,9 @@ static int builtin_diff_blobs(struct rev_info *revs, */ unsigned mode = canon_mode(S_IFREG | 0644); - while (1 < argc) { - const char *arg = argv[1]; - if (!strcmp(arg, "--raw")) - revs->diffopt.output_format = DIFF_FORMAT_RAW; - else - usage(builtin_diff_usage); - argv++; argc--; - } + if (argc > 1) + usage(builtin_diff_usage); + stuff_change(&revs->diffopt, mode, mode, blob[1].sha1, blob[0].sha1, @@ -162,8 +150,6 @@ static int builtin_diff_index(struct rev_info *revs, const char *arg = argv[1]; if (!strcmp(arg, "--cached")) cached = 1; - else if (!strcmp(arg, "--raw")) - revs->diffopt.output_format = DIFF_FORMAT_RAW; else usage(builtin_diff_usage); argv++; argc--; @@ -185,14 +171,9 @@ static int builtin_diff_tree(struct rev_info *revs, { const unsigned char *(sha1[2]); int swap = 0; - while (1 < argc) { - const char *arg = argv[1]; - if (!strcmp(arg, "--raw")) - revs->diffopt.output_format = DIFF_FORMAT_RAW; - else - usage(builtin_diff_usage); - argv++; argc--; - } + + if (argc > 1) + usage(builtin_diff_usage); /* We saw two trees, ent[0] and ent[1]. * if ent[1] is unintesting, they are swapped @@ -214,14 +195,9 @@ static int builtin_diff_combined(struct rev_info *revs, const unsigned char (*parent)[20]; int i; - while (1 < argc) { - const char *arg = argv[1]; - if (!strcmp(arg, "--raw")) - revs->diffopt.output_format = DIFF_FORMAT_RAW; - else - usage(builtin_diff_usage); - argv++; argc--; - } + if (argc > 1) + usage(builtin_diff_usage); + if (!revs->dense_combined_merges && !revs->combine_merges) revs->dense_combined_merges = revs->combine_merges = 1; parent = xmalloc(ents * sizeof(*parent)); diff --git a/diff.c b/diff.c index 49b2eeb74..12f655a2f 100644 --- a/diff.c +++ b/diff.c @@ -1533,6 +1533,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) options->output_format |= DIFF_FORMAT_PATCH; else if (opt_arg(arg, 'U', "unified", &options->context)) options->output_format |= DIFF_FORMAT_PATCH; + else if (!strcmp(arg, "--raw")) + options->output_format |= DIFF_FORMAT_RAW; else if (!strcmp(arg, "--patch-with-raw")) { options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW; } -- cgit v1.2.1 From c9b5ef998a3027d9f11b0820bb13896096833ccb Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sat, 24 Jun 2006 20:24:14 +0300 Subject: Set default diff output format after parsing command line Initialize output_format to 0 instead of DIFF_FORMAT_RAW so that we can see later if any command line options changed it. Default value is set only if output format was not specified. Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 3 +++ builtin-diff-index.c | 3 +++ builtin-diff-stages.c | 3 +++ builtin-diff-tree.c | 3 +++ builtin-diff.c | 4 +++- builtin-log.c | 4 +++- diff.c | 1 - 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 5afc1d720..a655eea91 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -36,6 +36,9 @@ int cmd_diff_files(int argc, const char **argv, char **envp) usage(diff_files_usage); argv++; argc--; } + if (!rev.diffopt.output_format) + rev.diffopt.output_format = DIFF_FORMAT_RAW; + /* * Make sure there are NO revision (i.e. pending object) parameter, * rev.max_count is reasonable (0 <= n <= 3), diff --git a/builtin-diff-index.c b/builtin-diff-index.c index c42ef9a7a..b37c9e8cc 100644 --- a/builtin-diff-index.c +++ b/builtin-diff-index.c @@ -28,6 +28,9 @@ int cmd_diff_index(int argc, const char **argv, char **envp) else usage(diff_cache_usage); } + if (!rev.diffopt.output_format) + rev.diffopt.output_format = DIFF_FORMAT_RAW; + /* * Make sure there is one revision (i.e. pending object), * and there is no revision filtering parameters. diff --git a/builtin-diff-stages.c b/builtin-diff-stages.c index 7c157ca88..30931fe04 100644 --- a/builtin-diff-stages.c +++ b/builtin-diff-stages.c @@ -85,6 +85,9 @@ int cmd_diff_stages(int ac, const char **av, char **envp) ac--; av++; } + if (!diff_options.output_format) + diff_options.output_format = DIFF_FORMAT_RAW; + if (ac < 3 || sscanf(av[1], "%d", &stage1) != 1 || ! (0 <= stage1 && stage1 <= 3) || diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c index 3409a39a9..ae1cde9d0 100644 --- a/builtin-diff-tree.c +++ b/builtin-diff-tree.c @@ -84,6 +84,9 @@ int cmd_diff_tree(int argc, const char **argv, char **envp) usage(diff_tree_usage); } + if (!opt->diffopt.output_format) + opt->diffopt.output_format = DIFF_FORMAT_RAW; + /* * NOTE! We expect "a ^b" to be equal to "a..b", so we * reverse the order of the objects if the second one diff --git a/builtin-diff.c b/builtin-diff.c index 91235a118..47e0a37e2 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -252,9 +252,11 @@ int cmd_diff(int argc, const char **argv, char **envp) git_config(git_diff_config); init_revisions(&rev); - rev.diffopt.output_format = DIFF_FORMAT_PATCH; argc = setup_revisions(argc, argv, &rev, NULL); + if (!rev.diffopt.output_format) + rev.diffopt.output_format = DIFF_FORMAT_PATCH; + /* Do we have --cached and not have a pending object, then * default to HEAD by hand. Eek. */ diff --git a/builtin-log.c b/builtin-log.c index e321959c5..c1bf9d4ee 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -178,7 +178,6 @@ int cmd_format_patch(int argc, const char **argv, char **envp) rev.diff = 1; rev.combine_merges = 0; rev.ignore_merges = 1; - rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH; git_config(git_format_config); rev.extra_headers = extra_headers; @@ -247,6 +246,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp) if (argc > 1) die ("unrecognized argument: %s", argv[1]); + if (!rev.diffopt.output_format) + rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH; + if (output_directory) { if (use_stdout) die("standard output, or directory, which one?"); diff --git a/diff.c b/diff.c index 12f655a2f..928345199 100644 --- a/diff.c +++ b/diff.c @@ -1420,7 +1420,6 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o) void diff_setup(struct diff_options *options) { memset(options, 0, sizeof(*options)); - options->output_format = DIFF_FORMAT_RAW; options->line_termination = '\n'; options->break_opt = -1; options->rename_limit = -1; -- cgit v1.2.1 From 0e677e1a6b0d1c0e848ed19d18dda1c3c797c75e Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sat, 24 Jun 2006 20:25:08 +0300 Subject: DIFF_FORMAT_RAW is not default anymore diff_setup() used to initialize output_format to DIFF_FORMAT_RAW. Now the default is 0 (no output) so don't compare against DIFF_FORMAT_RAW to see if any diff format command line flags were given. Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- builtin-log.c | 5 +---- revision.c | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index c1bf9d4ee..4e5273aec 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -24,11 +24,8 @@ static int cmd_log_wc(int argc, const char **argv, char **envp, rev->verbose_header = 1; argc = setup_revisions(argc, argv, rev, "HEAD"); if (rev->always_show_header) { - if (rev->diffopt.pickaxe || rev->diffopt.filter) { + if (rev->diffopt.pickaxe || rev->diffopt.filter) rev->always_show_header = 0; - if (rev->diffopt.output_format == DIFF_FORMAT_RAW) - rev->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT; - } } if (argc > 1) diff --git a/revision.c b/revision.c index b963f2adf..ae4ca8200 100644 --- a/revision.c +++ b/revision.c @@ -851,8 +851,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch } if (revs->combine_merges) { revs->ignore_merges = 0; - if (revs->dense_combined_merges && - (revs->diffopt.output_format != DIFF_FORMAT_DIFFSTAT)) + if (revs->dense_combined_merges && !revs->diffopt.output_format) revs->diffopt.output_format = DIFF_FORMAT_PATCH; } revs->diffopt.abbrev = revs->abbrev; -- cgit v1.2.1 From 39bc9a6c2051a9fc31dc9b34b40bdd3dd94a8afb Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sun, 25 Jun 2006 13:54:14 +0300 Subject: Add msg_sep to diff_options Add msg_sep variable to struct diff_options. msg_sep is printed after commit message. Default is "\n", format-patch sets it to "---\n". This also removes the second argument from show_log() because all callers derived it from the first argument: show_log(rev, rev->loginfo, ... Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- builtin-log.c | 1 + combine-diff.c | 7 ++++--- diff.c | 1 + diff.h | 1 + log-tree.c | 15 ++++++--------- log-tree.h | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index 4e5273aec..71ae6c98a 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -175,6 +175,7 @@ int cmd_format_patch(int argc, const char **argv, char **envp) rev.diff = 1; rev.combine_merges = 0; rev.ignore_merges = 1; + rev.diffopt.msg_sep = "---\n"; git_config(git_format_config); rev.extra_headers = extra_headers; diff --git a/combine-diff.c b/combine-diff.c index 3daa8cb13..39fb10c14 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -701,7 +701,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent, const char *abb; if (rev->loginfo) - show_log(rev, rev->loginfo, "\n"); + show_log(rev, opt->msg_sep); dump_quoted_path(dense ? "diff --cc " : "diff --combined ", elem->path); printf("index "); for (i = 0; i < num_parent; i++) { @@ -769,7 +769,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re inter_name_termination = 0; if (rev->loginfo) - show_log(rev, rev->loginfo, "\n"); + show_log(rev, opt->msg_sep); if (opt->output_format & DIFF_FORMAT_RAW) { offset = strlen(COLONS) - num_parent; @@ -855,7 +855,8 @@ void diff_tree_combined(const unsigned char *sha1, paths = intersect_paths(paths, i, num_parent); if (opt->output_format & DIFF_FORMAT_DIFFSTAT && rev->loginfo) - show_log(rev, rev->loginfo, "---\n"); + show_log(rev, opt->msg_sep); + diff_flush(&diffopts); if (opt->output_format & DIFF_FORMAT_DIFFSTAT) putchar('\n'); diff --git a/diff.c b/diff.c index 928345199..491b846f6 100644 --- a/diff.c +++ b/diff.c @@ -1424,6 +1424,7 @@ void diff_setup(struct diff_options *options) options->break_opt = -1; options->rename_limit = -1; options->context = 3; + options->msg_sep = "\n"; options->change = diff_change; options->add_remove = diff_addremove; diff --git a/diff.h b/diff.h index 2b6dc0cbe..729cd0251 100644 --- a/diff.h +++ b/diff.h @@ -57,6 +57,7 @@ struct diff_options { int rename_limit; int setup; int abbrev; + const char *msg_sep; const char *stat_sep; long xdl_opts; diff --git a/log-tree.c b/log-tree.c index 7d4c51f95..ab6b68222 100644 --- a/log-tree.c +++ b/log-tree.c @@ -43,9 +43,10 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff) return at; } -void show_log(struct rev_info *opt, struct log_info *log, const char *sep) +void show_log(struct rev_info *opt, const char *sep) { static char this_header[16384]; + struct log_info *log = opt->loginfo; struct commit *commit = log->commit, *parent = log->parent; int abbrev = opt->diffopt.abbrev; int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40; @@ -163,13 +164,9 @@ int log_tree_diff_flush(struct rev_info *opt) return 0; } - if (opt->loginfo && !opt->no_commit_id) { - if (opt->diffopt.output_format & DIFF_FORMAT_DIFFSTAT) { - show_log(opt, opt->loginfo, "---\n"); - } else { - show_log(opt, opt->loginfo, "\n"); - } - } + if (opt->loginfo && !opt->no_commit_id) + show_log(opt, opt->diffopt.msg_sep); + diff_flush(&opt->diffopt); return 1; } @@ -266,7 +263,7 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit) shown = log_tree_diff(opt, commit, &log); if (!shown && opt->loginfo && opt->always_show_header) { log.parent = NULL; - show_log(opt, opt->loginfo, ""); + show_log(opt, ""); shown = 1; } opt->loginfo = NULL; diff --git a/log-tree.h b/log-tree.h index a26e4841f..e82b56a20 100644 --- a/log-tree.h +++ b/log-tree.h @@ -11,6 +11,6 @@ void init_log_tree_opt(struct rev_info *); int log_tree_diff_flush(struct rev_info *); int log_tree_commit(struct rev_info *, struct commit *); int log_tree_opt_parse(struct rev_info *, const char **, int); -void show_log(struct rev_info *opt, struct log_info *log, const char *sep); +void show_log(struct rev_info *opt, const char *sep); #endif -- cgit v1.2.1 From 5e2b0636c709884e45ef941cd4514c225f204982 Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sun, 25 Jun 2006 14:28:19 +0300 Subject: Don't xcalloc() struct diffstat_t Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- diff.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/diff.c b/diff.c index 491b846f6..54698f511 100644 --- a/diff.c +++ b/diff.c @@ -2115,17 +2115,16 @@ void diff_flush(struct diff_options *options) } if (output_format & DIFF_FORMAT_DIFFSTAT) { - struct diffstat_t *diffstat; + struct diffstat_t diffstat; - diffstat = xcalloc(sizeof (struct diffstat_t), 1); - diffstat->xm.consume = diffstat_consume; + memset(&diffstat, 0, sizeof(struct diffstat_t)); + diffstat.xm.consume = diffstat_consume; for (i = 0; i < q->nr; i++) { struct diff_filepair *p = q->queue[i]; if (check_pair_status(p)) - diff_flush_stat(p, options, diffstat); + diff_flush_stat(p, options, &diffstat); } - show_stats(diffstat); - free(diffstat); + show_stats(&diffstat); } if (output_format & DIFF_FORMAT_SUMMARY) { -- cgit v1.2.1 From 9dafea267806988d7f5821780de688ca84766a40 Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sun, 25 Jun 2006 15:39:35 +0300 Subject: whatchanged: Default to DIFF_FORMAT_RAW Split cmd_log_wc() to cmd_log_init() and cmd_log_walk() and set default diff output format for whatchanged to DIFF_FORMAT_RAW. Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- builtin-log.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index 71ae6c98a..3b7574f6d 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -14,22 +14,22 @@ /* this is in builtin-diff.c */ void add_head(struct rev_info *revs); -static int cmd_log_wc(int argc, const char **argv, char **envp, +static void cmd_log_init(int argc, const char **argv, char **envp, struct rev_info *rev) { - struct commit *commit; - rev->abbrev = DEFAULT_ABBREV; rev->commit_format = CMIT_FMT_DEFAULT; rev->verbose_header = 1; argc = setup_revisions(argc, argv, rev, "HEAD"); - if (rev->always_show_header) { - if (rev->diffopt.pickaxe || rev->diffopt.filter) - rev->always_show_header = 0; - } - + if (rev->diffopt.pickaxe || rev->diffopt.filter) + rev->always_show_header = 0; if (argc > 1) die("unrecognized argument: %s", argv[1]); +} + +static int cmd_log_walk(struct rev_info *rev) +{ + struct commit *commit; prepare_revision_walk(rev); setup_pager(); @@ -51,7 +51,10 @@ int cmd_whatchanged(int argc, const char **argv, char **envp) rev.diff = 1; rev.diffopt.recursive = 1; rev.simplify_history = 0; - return cmd_log_wc(argc, argv, envp, &rev); + cmd_log_init(argc, argv, envp, &rev); + if (!rev.diffopt.output_format) + rev.diffopt.output_format = DIFF_FORMAT_RAW; + return cmd_log_walk(&rev); } int cmd_show(int argc, const char **argv, char **envp) @@ -66,7 +69,8 @@ int cmd_show(int argc, const char **argv, char **envp) rev.always_show_header = 1; rev.ignore_merges = 0; rev.no_walk = 1; - return cmd_log_wc(argc, argv, envp, &rev); + cmd_log_init(argc, argv, envp, &rev); + return cmd_log_walk(&rev); } int cmd_log(int argc, const char **argv, char **envp) @@ -76,7 +80,8 @@ int cmd_log(int argc, const char **argv, char **envp) init_revisions(&rev); rev.always_show_header = 1; rev.diffopt.recursive = 1; - return cmd_log_wc(argc, argv, envp, &rev); + cmd_log_init(argc, argv, envp, &rev); + return cmd_log_walk(&rev); } static int istitlechar(char c) -- cgit v1.2.1 From 47979d5d5bb86d058dce77801648734abe1e593b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 26 Jun 2006 23:29:11 -0700 Subject: t4013: add more tests around -c and --cc Signed-off-by: Junio C Hamano --- t/t4013-diff-various.sh | 28 ++- ...ff-tree_--cc_--patch-with-stat_--summary_master | 35 ++++ ...diff-tree_--cc_--patch-with-stat_--summary_side | 39 ++++ .../diff.diff-tree_--cc_--stat_--summary_master | 6 + t/t4013/diff.diff-tree_--cc_--stat_--summary_side | 8 + t/t4013/diff.diff-tree_--cc_--stat_master | 6 + t/t4013/diff.diff-tree_-c_--stat_--summary_master | 6 + t/t4013/diff.diff-tree_-c_--stat_--summary_side | 8 + t/t4013/diff.diff-tree_-c_--stat_master | 6 + ....log_--patch-with-stat_--summary_master_--_dir_ | 72 ++++++++ ..._--root_--cc_--patch-with-stat_--summary_master | 198 +++++++++++++++++++++ ...f.log_--root_--patch-with-stat_--summary_master | 165 +++++++++++++++++ ...og_--root_-c_--patch-with-stat_--summary_master | 198 +++++++++++++++++++++ t/t4013/diff.log_-SF_-p_master | 18 ++ ...nged_--patch-with-stat_--summary_master_--_dir_ | 59 ++++++ ..._--root_--cc_--patch-with-stat_--summary_master | 198 +++++++++++++++++++++ ...ed_--root_-c_--patch-with-stat_--summary_master | 198 +++++++++++++++++++++ t/t4013/diff.whatchanged_-SF_-p_master | 18 ++ 18 files changed, 1263 insertions(+), 3 deletions(-) create mode 100644 t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master create mode 100644 t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_side create mode 100644 t/t4013/diff.diff-tree_--cc_--stat_--summary_master create mode 100644 t/t4013/diff.diff-tree_--cc_--stat_--summary_side create mode 100644 t/t4013/diff.diff-tree_--cc_--stat_master create mode 100644 t/t4013/diff.diff-tree_-c_--stat_--summary_master create mode 100644 t/t4013/diff.diff-tree_-c_--stat_--summary_side create mode 100644 t/t4013/diff.diff-tree_-c_--stat_master create mode 100644 t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ create mode 100644 t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master create mode 100644 t/t4013/diff.log_--root_--patch-with-stat_--summary_master create mode 100644 t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master create mode 100644 t/t4013/diff.log_-SF_-p_master create mode 100644 t/t4013/diff.whatchanged_--patch-with-stat_--summary_master_--_dir_ create mode 100644 t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master create mode 100644 t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master create mode 100644 t/t4013/diff.whatchanged_-SF_-p_master diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 802e0ba01..22984e3db 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -163,6 +163,22 @@ diff-tree -p -m master diff-tree -c master diff-tree -c --abbrev master diff-tree --cc master +# stat only should show the diffstat with the first parent +diff-tree -c --stat master +diff-tree --cc --stat master +diff-tree -c --stat --summary master +diff-tree --cc --stat --summary master +# stat summary should show the diffstat and summary with the first parent +diff-tree -c --stat --summary side +diff-tree --cc --stat --summary side +# this one gives an extra newline after stat, which should be removed +# diff-tree --cc --patch-with-stat master +# this one gives an extra newline after stat, which should be removed +# other than that it shows the correct example -- stat and summary are +# against the first parent, and patch-looking combined diff follows. +diff-tree --cc --patch-with-stat --summary master +# this is correct +diff-tree --cc --patch-with-stat --summary side log master log -p master @@ -170,8 +186,11 @@ log --root master log --root -p master log --patch-with-stat master log --root --patch-with-stat master -#log --root --patch-with-stat --summary master +log --root --patch-with-stat --summary master +log --root -c --patch-with-stat --summary master +log --root --cc --patch-with-stat --summary master log -SF master +log -SF -p master whatchanged master whatchanged -p master @@ -180,10 +199,15 @@ whatchanged --root -p master whatchanged --patch-with-stat master whatchanged --root --patch-with-stat master whatchanged --root --patch-with-stat --summary master +whatchanged --root -c --patch-with-stat --summary master +whatchanged --root --cc --patch-with-stat --summary master whatchanged -SF master +whatchanged -SF -p master log --patch-with-stat master -- dir/ whatchanged --patch-with-stat master -- dir/ +log --patch-with-stat --summary master -- dir/ +whatchanged --patch-with-stat --summary master -- dir/ show initial show --root initial @@ -195,8 +219,6 @@ show --patch-with-stat side show --patch-with-raw side show --patch-with-stat --summary side - - EOF test_done diff --git a/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master new file mode 100644 index 000000000..e6d0c8056 --- /dev/null +++ b/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master @@ -0,0 +1,35 @@ +$ git diff-tree --cc --patch-with-stat --summary master +176b998f5d647cbd77a9d8acf4531e930754d16d + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + + +diff --cc dir/sub +index cead32e,7289e35..992913c +--- a/dir/sub ++++ b/dir/sub +@@@ -1,6 -1,4 +1,8 @@@ + A + B + +C + +D + +E + +F ++ 1 ++ 2 +diff --cc file0 +index b414108,f4615da..10a8a9f +--- a/file0 ++++ b/file0 +@@@ -1,6 -1,6 +1,9 @@@ + 1 + 2 + 3 + +4 + +5 + +6 ++ A ++ B ++ C +$ diff --git a/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_side b/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_side new file mode 100644 index 000000000..a61ad8cb1 --- /dev/null +++ b/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_side @@ -0,0 +1,39 @@ +$ git diff-tree --cc --patch-with-stat --summary side +c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff-tree_--cc_--stat_--summary_master b/t/t4013/diff.diff-tree_--cc_--stat_--summary_master new file mode 100644 index 000000000..712ffd2d8 --- /dev/null +++ b/t/t4013/diff.diff-tree_--cc_--stat_--summary_master @@ -0,0 +1,6 @@ +$ git diff-tree --cc --stat --summary master +176b998f5d647cbd77a9d8acf4531e930754d16d + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) +$ diff --git a/t/t4013/diff.diff-tree_--cc_--stat_--summary_side b/t/t4013/diff.diff-tree_--cc_--stat_--summary_side new file mode 100644 index 000000000..50362be7b --- /dev/null +++ b/t/t4013/diff.diff-tree_--cc_--stat_--summary_side @@ -0,0 +1,8 @@ +$ git diff-tree --cc --stat --summary side +c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 +$ diff --git a/t/t4013/diff.diff-tree_--cc_--stat_master b/t/t4013/diff.diff-tree_--cc_--stat_master new file mode 100644 index 000000000..8d5bdc985 --- /dev/null +++ b/t/t4013/diff.diff-tree_--cc_--stat_master @@ -0,0 +1,6 @@ +$ git diff-tree --cc --stat master +176b998f5d647cbd77a9d8acf4531e930754d16d + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) +$ diff --git a/t/t4013/diff.diff-tree_-c_--stat_--summary_master b/t/t4013/diff.diff-tree_-c_--stat_--summary_master new file mode 100644 index 000000000..2d239feb5 --- /dev/null +++ b/t/t4013/diff.diff-tree_-c_--stat_--summary_master @@ -0,0 +1,6 @@ +$ git diff-tree -c --stat --summary master +176b998f5d647cbd77a9d8acf4531e930754d16d + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) +$ diff --git a/t/t4013/diff.diff-tree_-c_--stat_--summary_side b/t/t4013/diff.diff-tree_-c_--stat_--summary_side new file mode 100644 index 000000000..2afcca11f --- /dev/null +++ b/t/t4013/diff.diff-tree_-c_--stat_--summary_side @@ -0,0 +1,8 @@ +$ git diff-tree -c --stat --summary side +c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 +$ diff --git a/t/t4013/diff.diff-tree_-c_--stat_master b/t/t4013/diff.diff-tree_-c_--stat_master new file mode 100644 index 000000000..226300b93 --- /dev/null +++ b/t/t4013/diff.diff-tree_-c_--stat_master @@ -0,0 +1,6 @@ +$ git diff-tree -c --stat master +176b998f5d647cbd77a9d8acf4531e930754d16d + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) +$ diff --git a/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ b/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ new file mode 100644 index 000000000..cc5537697 --- /dev/null +++ b/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ @@ -0,0 +1,72 @@ +$ git log --patch-with-stat --summary master -- dir/ +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master new file mode 100644 index 000000000..fafd9ee59 --- /dev/null +++ b/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master @@ -0,0 +1,198 @@ +$ git log --root --cc --patch-with-stat --summary master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' +--- + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + + +diff --cc dir/sub +index cead32e,7289e35..992913c +--- a/dir/sub ++++ b/dir/sub +@@@ -1,6 -1,4 +1,8 @@@ + A + B + +C + +D + +E + +F ++ 1 ++ 2 +diff --cc file0 +index b414108,f4615da..10a8a9f +--- a/file0 ++++ b/file0 +@@@ -1,6 -1,6 +1,9 @@@ + 1 + 2 + 3 + +4 + +5 + +6 ++ A ++ B ++ C + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + create mode 100644 dir/sub + create mode 100644 file0 + create mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.log_--root_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_--patch-with-stat_--summary_master new file mode 100644 index 000000000..b24a50475 --- /dev/null +++ b/t/t4013/diff.log_--root_--patch-with-stat_--summary_master @@ -0,0 +1,165 @@ +$ git log --root --patch-with-stat --summary master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + create mode 100644 dir/sub + create mode 100644 file0 + create mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master new file mode 100644 index 000000000..51e39cda0 --- /dev/null +++ b/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master @@ -0,0 +1,198 @@ +$ git log --root -c --patch-with-stat --summary master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' +--- + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + + +diff --combined dir/sub +index cead32e,7289e35..992913c +--- a/dir/sub ++++ b/dir/sub +@@@ -1,6 -1,4 +1,8 @@@ + A + B + +C + +D + +E + +F ++ 1 ++ 2 +diff --combined file0 +index b414108,f4615da..10a8a9f +--- a/file0 ++++ b/file0 +@@@ -1,6 -1,6 +1,9 @@@ + 1 + 2 + 3 + +4 + +5 + +6 ++ A ++ B ++ C + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + create mode 100644 dir/sub + create mode 100644 file0 + create mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.log_-SF_-p_master b/t/t4013/diff.log_-SF_-p_master new file mode 100644 index 000000000..db2264c6e --- /dev/null +++ b/t/t4013/diff.log_-SF_-p_master @@ -0,0 +1,18 @@ +$ git log -SF -p master +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +$ diff --git a/t/t4013/diff.whatchanged_--patch-with-stat_--summary_master_--_dir_ b/t/t4013/diff.whatchanged_--patch-with-stat_--summary_master_--_dir_ new file mode 100644 index 000000000..054513f31 --- /dev/null +++ b/t/t4013/diff.whatchanged_--patch-with-stat_--summary_master_--_dir_ @@ -0,0 +1,59 @@ +$ git whatchanged --patch-with-stat --summary master -- dir/ +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +$ diff --git a/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master new file mode 100644 index 000000000..370b5810e --- /dev/null +++ b/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master @@ -0,0 +1,198 @@ +$ git whatchanged --root --cc --patch-with-stat --summary master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' +--- + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + + +diff --cc dir/sub +index cead32e,7289e35..992913c +--- a/dir/sub ++++ b/dir/sub +@@@ -1,6 -1,4 +1,8 @@@ + A + B + +C + +D + +E + +F ++ 1 ++ 2 +diff --cc file0 +index b414108,f4615da..10a8a9f +--- a/file0 ++++ b/file0 +@@@ -1,6 -1,6 +1,9 @@@ + 1 + 2 + 3 + +4 + +5 + +6 ++ A ++ B ++ C + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + create mode 100644 dir/sub + create mode 100644 file0 + create mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master new file mode 100644 index 000000000..d6404b11b --- /dev/null +++ b/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master @@ -0,0 +1,198 @@ +$ git whatchanged --root -c --patch-with-stat --summary master +commit 176b998f5d647cbd77a9d8acf4531e930754d16d +Merge: 889b315... c7a2ab9... +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' +--- + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + + +diff --combined dir/sub +index cead32e,7289e35..992913c +--- a/dir/sub ++++ b/dir/sub +@@@ -1,6 -1,4 +1,8 @@@ + A + B + +C + +D + +E + +F ++ 1 ++ 2 +diff --combined file0 +index b414108,f4615da..10a8a9f +--- a/file0 ++++ b/file0 +@@@ -1,6 -1,6 +1,9 @@@ + 1 + 2 + 3 + +4 + +5 + +6 ++ A ++ B ++ C + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 7952a93e09bf565b5592766a438b40cd81f4846f +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + create mode 100644 dir/sub + create mode 100644 file0 + create mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000..35d242b +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000..01e79c3 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.whatchanged_-SF_-p_master b/t/t4013/diff.whatchanged_-SF_-p_master new file mode 100644 index 000000000..6a76f4e60 --- /dev/null +++ b/t/t4013/diff.whatchanged_-SF_-p_master @@ -0,0 +1,18 @@ +$ git whatchanged -SF -p master +commit 889b315013ef9f2e2f90aa0b054b267c8a557847 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +$ -- cgit v1.2.1 From 946c3784a3586e70c70c3a676f590654ca39a3cb Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Tue, 27 Jun 2006 15:09:17 +0300 Subject: Print empty line between raw, stat, summary and patch Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- diff.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/diff.c b/diff.c index 54698f511..71fb0967f 100644 --- a/diff.c +++ b/diff.c @@ -2093,15 +2093,43 @@ static void diff_summary(struct diff_filepair *p) } } +static int is_summary_empty(const struct diff_queue_struct *q) +{ + int i; + + for (i = 0; i < q->nr; i++) { + const struct diff_filepair *p = q->queue[i]; + + switch (p->status) { + case DIFF_STATUS_DELETED: + case DIFF_STATUS_ADDED: + case DIFF_STATUS_COPIED: + case DIFF_STATUS_RENAMED: + return 0; + default: + if (p->score) + return 0; + if (p->one->mode && p->two->mode && + p->one->mode != p->two->mode) + return 0; + break; + } + } + return 1; +} + void diff_flush(struct diff_options *options) { struct diff_queue_struct *q = &diff_queued_diff; int i, output_format = options->output_format; + int separator = 0; /* * Order: raw, stat, summary, patch * or: name/name-status/checkdiff (other bits clear) */ + if (!q->nr) + goto free_queue; if (output_format & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME | @@ -2112,11 +2140,15 @@ void diff_flush(struct diff_options *options) if (check_pair_status(p)) flush_one_pair(p, options); } + separator++; } if (output_format & DIFF_FORMAT_DIFFSTAT) { struct diffstat_t diffstat; + if (separator++) + putchar('\n'); + memset(&diffstat, 0, sizeof(struct diffstat_t)); diffstat.xm.consume = diffstat_consume; for (i = 0; i < q->nr; i++) { @@ -2127,18 +2159,22 @@ void diff_flush(struct diff_options *options) show_stats(&diffstat); } - if (output_format & DIFF_FORMAT_SUMMARY) { + if (output_format & DIFF_FORMAT_SUMMARY && !is_summary_empty(q)) { + if (separator++) + putchar('\n'); + for (i = 0; i < q->nr; i++) diff_summary(q->queue[i]); } if (output_format & DIFF_FORMAT_PATCH) { - if (output_format & (DIFF_FORMAT_DIFFSTAT | - DIFF_FORMAT_SUMMARY)) { - if (options->stat_sep) + if (separator) { + if (options->stat_sep) { + /* attach patch instead of inline */ fputs(options->stat_sep, stdout); - else + } else { putchar(options->line_termination); + } } for (i = 0; i < q->nr; i++) { @@ -2150,6 +2186,7 @@ void diff_flush(struct diff_options *options) for (i = 0; i < q->nr; i++) diff_free_filepair(q->queue[i]); +free_queue: free(q->queue); q->queue = NULL; q->nr = q->alloc = 0; -- cgit v1.2.1 From f005df391057ce8487a6b2f9896f8e0507351be8 Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Tue, 27 Jun 2006 15:39:29 +0300 Subject: diff-tree: Use ---\n as a message separator Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- builtin-diff-tree.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c index ae1cde9d0..1e66fcac2 100644 --- a/builtin-diff-tree.c +++ b/builtin-diff-tree.c @@ -72,6 +72,7 @@ int cmd_diff_tree(int argc, const char **argv, char **envp) init_revisions(opt); opt->abbrev = 0; opt->diff = 1; + opt->diffopt.msg_sep = "---\n"; argc = setup_revisions(argc, argv, opt, NULL); while (--argc > 0) { -- cgit v1.2.1 From 17985627455901b6ae3a471b67d46239463cebb5 Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Tue, 27 Jun 2006 16:27:51 +0300 Subject: log --raw: Don't descend into subdirectories by default Only do so when -r is given. Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- builtin-log.c | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin-log.c b/builtin-log.c index 3b7574f6d..debddb97a 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -79,7 +79,6 @@ int cmd_log(int argc, const char **argv, char **envp) init_revisions(&rev); rev.always_show_header = 1; - rev.diffopt.recursive = 1; cmd_log_init(argc, argv, envp, &rev); return cmd_log_walk(&rev); } -- cgit v1.2.1 From 3223847a8fbd6200e38f4a8f1146ca9dc20a813e Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Tue, 27 Jun 2006 19:43:22 +0300 Subject: Fix diff-tree -s setup_revisions() calls diff_setup_done() before we can set default value for output_format. Don't convert DIFF_FORMAT_NO_OUTPUT to 0 in diff_setup_done(), it is useless and makes diff-tree believe no diff format parameters were given and thus lets it reset output_format to DIFF_FORMAT_RAW. Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- diff.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/diff.c b/diff.c index 71fb0967f..6d04be49d 100644 --- a/diff.c +++ b/diff.c @@ -1438,9 +1438,6 @@ int diff_setup_done(struct diff_options *options) (0 <= options->rename_limit && !options->detect_rename)) return -1; - if (options->output_format & DIFF_FORMAT_NO_OUTPUT) - options->output_format = 0; - if (options->output_format & (DIFF_FORMAT_NAME | DIFF_FORMAT_NAME_STATUS | DIFF_FORMAT_CHECKDIFF | -- cgit v1.2.1 From 3969cf7db1a13a78f3b7a36d8c1084bbe0a53459 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 27 Jun 2006 15:08:19 -0700 Subject: Fix some more diff options changes. This fixes various problems in the new diff options code. - Fix --cc/-c --patch; it showed two-tree diff used internally. - Use "---\n" only where it matters -- that is, use it immediately after the commit log text when we show a commit log and something else before the patch text. - Do not output spurious extra "\n"; have an extra newline after the commit log text always when we have diff output and we are not doing oneline. - When running a pickaxe you need to go recursive. Signed-off-by: Junio C Hamano --- builtin-diff-tree.c | 1 - combine-diff.c | 24 +++++++++++++++--------- diff.c | 15 ++++++++------- log-tree.c | 17 +++++++++++++++-- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c index 1e66fcac2..ae1cde9d0 100644 --- a/builtin-diff-tree.c +++ b/builtin-diff-tree.c @@ -72,7 +72,6 @@ int cmd_diff_tree(int argc, const char **argv, char **envp) init_revisions(opt); opt->abbrev = 0; opt->diff = 1; - opt->diffopt.msg_sep = "---\n"; argc = setup_revisions(argc, argv, opt, NULL); while (--argc > 0) { diff --git a/combine-diff.c b/combine-diff.c index 39fb10c14..7178b25c5 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -835,31 +835,33 @@ void diff_tree_combined(const unsigned char *sha1, struct diff_options *opt = &rev->diffopt; struct diff_options diffopts; struct combine_diff_path *p, *paths = NULL; - int i, num_paths; + int i, num_paths, needsep, show_log_first; diffopts = *opt; - diffopts.output_format &= ~(DIFF_FORMAT_RAW | DIFF_FORMAT_DIFFSTAT); + diffopts.output_format = DIFF_FORMAT_NO_OUTPUT; diffopts.recursive = 1; + show_log_first = rev->loginfo; + needsep = 0; /* find set of paths that everybody touches */ for (i = 0; i < num_parent; i++) { /* show stat against the first parent even * when doing combined diff. */ if (i == 0 && opt->output_format & DIFF_FORMAT_DIFFSTAT) - diffopts.output_format |= DIFF_FORMAT_DIFFSTAT; + diffopts.output_format = DIFF_FORMAT_DIFFSTAT; else - diffopts.output_format |= DIFF_FORMAT_NO_OUTPUT; + diffopts.output_format = DIFF_FORMAT_NO_OUTPUT; diff_tree_sha1(parent[i], sha1, "", &diffopts); diffcore_std(&diffopts); paths = intersect_paths(paths, i, num_parent); - if (opt->output_format & DIFF_FORMAT_DIFFSTAT && rev->loginfo) + if (show_log_first && i == 0) { show_log(rev, opt->msg_sep); - + if (rev->verbose_header && opt->output_format) + putchar(opt->line_termination); + } diff_flush(&diffopts); - if (opt->output_format & DIFF_FORMAT_DIFFSTAT) - putchar('\n'); } /* find out surviving paths */ @@ -875,9 +877,13 @@ void diff_tree_combined(const unsigned char *sha1, if (p->len) show_raw_diff(p, num_parent, rev); } - putchar(opt->line_termination); + needsep = 1; } + else if (opt->output_format & DIFF_FORMAT_DIFFSTAT) + needsep = 1; if (opt->output_format & DIFF_FORMAT_PATCH) { + if (needsep) + putchar(opt->line_termination); for (p = paths; p; p = p->next) { if (p->len) show_patch_diff(p, num_parent, dense, diff --git a/diff.c b/diff.c index 6d04be49d..1c131ff4d 100644 --- a/diff.c +++ b/diff.c @@ -1424,7 +1424,7 @@ void diff_setup(struct diff_options *options) options->break_opt = -1; options->rename_limit = -1; options->context = 3; - options->msg_sep = "\n"; + options->msg_sep = ""; options->change = diff_change; options->add_remove = diff_addremove; @@ -1455,6 +1455,11 @@ int diff_setup_done(struct diff_options *options) DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_CHECKDIFF)) options->recursive = 1; + /* + * Also pickaxe would not work very well if you do not say recursive + */ + if (options->pickaxe) + options->recursive = 1; if (options->detect_rename && options->rename_limit < 0) options->rename_limit = diff_rename_limit_default; @@ -2143,9 +2148,6 @@ void diff_flush(struct diff_options *options) if (output_format & DIFF_FORMAT_DIFFSTAT) { struct diffstat_t diffstat; - if (separator++) - putchar('\n'); - memset(&diffstat, 0, sizeof(struct diffstat_t)); diffstat.xm.consume = diffstat_consume; for (i = 0; i < q->nr; i++) { @@ -2154,14 +2156,13 @@ void diff_flush(struct diff_options *options) diff_flush_stat(p, options, &diffstat); } show_stats(&diffstat); + separator++; } if (output_format & DIFF_FORMAT_SUMMARY && !is_summary_empty(q)) { - if (separator++) - putchar('\n'); - for (i = 0; i < q->nr; i++) diff_summary(q->queue[i]); + separator++; } if (output_format & DIFF_FORMAT_PATCH) { diff --git a/log-tree.c b/log-tree.c index ab6b68222..9d8d46fa0 100644 --- a/log-tree.c +++ b/log-tree.c @@ -164,9 +164,22 @@ int log_tree_diff_flush(struct rev_info *opt) return 0; } - if (opt->loginfo && !opt->no_commit_id) + if (opt->loginfo && !opt->no_commit_id) { + /* When showing a verbose header (i.e. log message), + * and not in --pretty=oneline format, we would want + * an extra newline between the end of log and the + * output for readability. + */ show_log(opt, opt->diffopt.msg_sep); - + if (opt->verbose_header && + opt->commit_format != CMIT_FMT_ONELINE) { + int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH; + if ((pch & opt->diffopt.output_format) == pch) + printf("---%c", opt->diffopt.line_termination); + else + putchar(opt->diffopt.line_termination); + } + } diff_flush(&opt->diffopt); return 1; } -- cgit v1.2.1 From 9e76bab14e50c46c624ae35f13c527a7a1b1185d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 27 Jun 2006 15:36:19 -0700 Subject: t4013 test updates for new output code. These are updates to the test vector that shows the "incompatibility" of the new output code. The changes are actually the good ones, so instead of keeping the older output we adjust the test to the new code. Signed-off-by: Junio C Hamano --- t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master | 1 - .../diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial | 1 - t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master | 3 +-- t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master | 3 +-- .../diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master | 3 +-- t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master | 3 +-- 6 files changed, 4 insertions(+), 10 deletions(-) diff --git a/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master index e6d0c8056..0ac980091 100644 --- a/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master +++ b/t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master @@ -4,7 +4,6 @@ $ git diff-tree --cc --patch-with-stat --summary master file0 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) - diff --cc dir/sub index cead32e,7289e35..992913c --- a/dir/sub diff --git a/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial b/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial index 49e26fb99..d5c333a37 100644 --- a/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial +++ b/t/t4013/diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial @@ -1,6 +1,5 @@ $ git diff-tree --pretty=oneline --root --patch-with-stat initial 444ac553ac7612cc88969031b02b3767fb8a353a Initial ---- dir/sub | 2 ++ file0 | 3 +++ file2 | 3 +++ diff --git a/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master index fafd9ee59..b652c6a82 100644 --- a/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master +++ b/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master @@ -5,12 +5,11 @@ Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 Merge branch 'side' ---- + dir/sub | 2 ++ file0 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) - diff --cc dir/sub index cead32e,7289e35..992913c --- a/dir/sub diff --git a/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master index 51e39cda0..3a155d288 100644 --- a/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master +++ b/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master @@ -5,12 +5,11 @@ Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 Merge branch 'side' ---- + dir/sub | 2 ++ file0 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) - diff --combined dir/sub index cead32e,7289e35..992913c --- a/dir/sub diff --git a/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master index 370b5810e..e9e17cdaf 100644 --- a/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master +++ b/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master @@ -5,12 +5,11 @@ Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 Merge branch 'side' ---- + dir/sub | 2 ++ file0 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) - diff --cc dir/sub index cead32e,7289e35..992913c --- a/dir/sub diff --git a/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master index d6404b11b..596765e80 100644 --- a/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master +++ b/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master @@ -5,12 +5,11 @@ Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 Merge branch 'side' ---- + dir/sub | 2 ++ file0 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) - diff --combined dir/sub index cead32e,7289e35..992913c --- a/dir/sub -- cgit v1.2.1 From 2c0b4dfd5a2099bdbbdfad71c3193a25c9052f2d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 28 Jun 2006 01:46:41 -0700 Subject: combine-diff.c: type sanity. In diff_tree_combined(), show_log_first boolean is initialized with rev->loginfo (pointer to a string); the intention is that if we have some string to be emitted we would want to remember that fact. Picky compilers are offended by this, so make the expression a bit type-safer. Signed-off-by: Junio C Hamano --- combine-diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/combine-diff.c b/combine-diff.c index 7178b25c5..2fd0ced39 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -841,7 +841,7 @@ void diff_tree_combined(const unsigned char *sha1, diffopts.output_format = DIFF_FORMAT_NO_OUTPUT; diffopts.recursive = 1; - show_log_first = rev->loginfo; + show_log_first = !!rev->loginfo; needsep = 0; /* find set of paths that everybody touches */ for (i = 0; i < num_parent; i++) { -- cgit v1.2.1 From a9ed376b158faf82d3685b51d546ccaeda716da3 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 28 Jun 2006 21:57:12 -0700 Subject: xdiff: generate "anti-diffs" aka what is common to two files This fairly trivial patch adds a new XDL_EMIT_xxx flag to tell libxdiff that we don't want to generate the _diff_ between two files, we want to see the lines that are _common_ to two files. So when you set XDL_EMIT_COMMON, xdl_diff() will do everything exactly like it used to do, but the output records it generates just contain the lines that aren't part of the diff. This is for doing things like generating the common base case for a file that was added in both branches. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- xdiff/xdiff.h | 1 + xdiff/xemit.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h index 2ce10b4c0..c9f817818 100644 --- a/xdiff/xdiff.h +++ b/xdiff/xdiff.h @@ -39,6 +39,7 @@ extern "C" { #define XDL_PATCH_IGNOREBSPACE (1 << 8) #define XDL_EMIT_FUNCNAMES (1 << 0) +#define XDL_EMIT_COMMON (1 << 1) #define XDL_MMB_READONLY (1 << 0) diff --git a/xdiff/xemit.c b/xdiff/xemit.c index ad5bfb191..714c56354 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -100,6 +100,21 @@ static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll) { } +int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, + xdemitconf_t const *xecfg) { + xdfile_t *xdf = &xe->xdf1; + const char *rchg = xdf->rchg; + long ix; + + for (ix = 0; ix < xdf->nrec; ix++) { + if (rchg[ix]) + continue; + if (xdl_emit_record(xdf, ix, "", ecb)) + return -1; + } + return 0; +} + int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg) { long s1, s2, e1, e2, lctx; @@ -107,6 +122,9 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, char funcbuf[40]; long funclen = 0; + if (xecfg->flags & XDL_EMIT_COMMON) + return xdl_emit_common(xe, xscr, ecb, xecfg); + for (xch = xche = xscr; xch; xch = xche->next) { xche = xdl_get_hunk(xch, xecfg); -- cgit v1.2.1 From 83788070a3dd0a4905dd76c865320c51f7d74a83 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 28 Jun 2006 11:18:27 -0700 Subject: Prepare "git-merge-tree" for future work This changes how "git-merge-tree" works in two ways: - instead of printing things out as we walk the trees, we save the results in memory. - when we've walked the tree fully, we print out the results in a more explicit way, describing the data. This is basically preparatory work for extending the git-merge-tree functionality in interesting directions. In particular, git-merge-tree is also how you would create a diff between two trees _without_ necessarily creating the merge commit itself. In other words, if you were to just wonder what another branch adds, you should be able to (eventually) just do git merge-tree -p $base HEAD $otherbranch to generate a diff of what the merge would look like. The current merge tree already basically has all the smarts for this, and the explanation of the results just means that hopefully somebody else than me could do the boring work. (You'd basically be able to do the above diff by just changing the printout format for the explanation, and making the "changed in both" first do a three-way merge before it diffs the result). The other thing that the in-memory format allows is rename detection (which the current code does not do). That's the basic reason why we don't want to just explain the differences as we go along - because we want to be able to look at the _other_ differences to see whether the reason an entry got deleted in either branch was perhaps because it got added in another place.. Rename detection should be a fairly trivial pass in between the tree diffing and the explanation. In the meantime, this doesn't actually do anything new, it just outputs the information in a more verbose manner. For an example merge, commit 5ab2c0a47574c92f92ea3709b23ca35d96319edd in the git tree works well and shows renames, along with true removals and additions and files that got changed in both branches. To see that as a tree merge, do: git-merge-tree 64e86c57 c5c23745 928e47e3 where the two last ones are the tips that got merged, and the first one is the merge base. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- merge-tree.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 119 insertions(+), 15 deletions(-) diff --git a/merge-tree.c b/merge-tree.c index 9dcaab7a8..fd0c2111c 100644 --- a/merge-tree.c +++ b/merge-tree.c @@ -1,11 +1,79 @@ #include "cache.h" #include "tree-walk.h" +#include "blob.h" static const char merge_tree_usage[] = "git-merge-tree "; static int resolve_directories = 1; +struct merge_list { + struct merge_list *next; + struct merge_list *link; /* other stages for this object */ + + unsigned int stage : 2, + flags : 30; + unsigned int mode; + const char *path; + struct blob *blob; +}; + +static struct merge_list *merge_result, **merge_result_end = &merge_result; + +static void add_merge_entry(struct merge_list *entry) +{ + *merge_result_end = entry; + merge_result_end = &entry->next; +} + static void merge_trees(struct tree_desc t[3], const char *base); +static const char *explanation(struct merge_list *entry) +{ + switch (entry->stage) { + case 0: + return "merged"; + case 3: + return "added in remote"; + case 2: + if (entry->link) + return "added in both"; + return "added in local"; + } + + /* Existed in base */ + entry = entry->link; + if (!entry) + return "removed in both"; + + if (entry->link) + return "changed in both"; + + if (entry->stage == 3) + return "removed in local"; + return "removed in remote"; +} + +static void show_result_list(struct merge_list *entry) +{ + printf("%s\n", explanation(entry)); + do { + struct merge_list *link = entry->link; + static const char *desc[4] = { "result", "base", "our", "their" }; + printf(" %-6s %o %s %s\n", desc[entry->stage], entry->mode, sha1_to_hex(entry->blob->object.sha1), entry->path); + entry = link; + } while (entry); +} + +static void show_result(void) +{ + struct merge_list *walk; + + walk = merge_result; + while (walk) { + show_result_list(walk); + walk = walk->next; + } +} + /* An empty entry never compares same, not even to another empty entry */ static int same_entry(struct name_entry *a, struct name_entry *b) { @@ -15,24 +83,34 @@ static int same_entry(struct name_entry *a, struct name_entry *b) a->mode == b->mode; } -static const char *sha1_to_hex_zero(const unsigned char *sha1) +static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path) { - if (sha1) - return sha1_to_hex(sha1); - return "0000000000000000000000000000000000000000"; + struct merge_list *res = xmalloc(sizeof(*res)); + + memset(res, 0, sizeof(*res)); + res->stage = stage; + res->path = path; + res->mode = mode; + res->blob = lookup_blob(sha1); + return res; } static void resolve(const char *base, struct name_entry *branch1, struct name_entry *result) { + struct merge_list *orig, *final; + const char *path; + /* If it's already branch1, don't bother showing it */ if (!branch1) return; - printf("0 %06o->%06o %s->%s %s%s\n", - branch1->mode, result->mode, - sha1_to_hex_zero(branch1->sha1), - sha1_to_hex_zero(result->sha1), - base, result->path); + path = strdup(mkpath("%s%s", base, result->path)); + orig = create_entry(2, branch1->mode, branch1->sha1, path); + final = create_entry(0, result->mode, result->sha1, path); + + final->link = orig; + + add_merge_entry(final); } static int unresolved_directory(const char *base, struct name_entry n[3]) @@ -71,16 +149,40 @@ static int unresolved_directory(const char *base, struct name_entry n[3]) return 1; } + +static struct merge_list *link_entry(unsigned stage, const char *base, struct name_entry *n, struct merge_list *entry) +{ + const char *path; + struct merge_list *link; + + if (!n->mode) + return entry; + if (entry) + path = entry->path; + else + path = strdup(mkpath("%s%s", base, n->path)); + link = create_entry(stage, n->mode, n->sha1, path); + link->link = entry; + return link; +} + static void unresolved(const char *base, struct name_entry n[3]) { + struct merge_list *entry = NULL; + if (unresolved_directory(base, n)) return; - if (n[0].sha1) - printf("1 %06o %s %s%s\n", n[0].mode, sha1_to_hex(n[0].sha1), base, n[0].path); - if (n[1].sha1) - printf("2 %06o %s %s%s\n", n[1].mode, sha1_to_hex(n[1].sha1), base, n[1].path); - if (n[2].sha1) - printf("3 %06o %s %s%s\n", n[2].mode, sha1_to_hex(n[2].sha1), base, n[2].path); + + /* + * Do them in reverse order so that the resulting link + * list has the stages in order - link_entry adds new + * links at the front. + */ + entry = link_entry(3, base, n + 2, entry); + entry = link_entry(2, base, n + 1, entry); + entry = link_entry(1, base, n + 0, entry); + + add_merge_entry(entry); } /* @@ -172,5 +274,7 @@ int main(int argc, char **argv) free(buf1); free(buf2); free(buf3); + + show_result(); return 0; } -- cgit v1.2.1 From 0c7993839b92f466278439a724023f8be50391c1 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 28 Jun 2006 22:06:36 -0700 Subject: Improved three-way blob merging code This fleshes out the code that generates a three-way merge of a set of blobs. It still actually does the three-way merge using an external executable (ie just calling "merge"), but the interfaces have been cleaned up a lot and are now fully based on the 'mmfile_t' interface, so if libxdiff were to ever grow a compatible three-way-merge, it could probably be directly plugged in. It also uses the previous XDL_EMIT_COMMON functionality extension to libxdiff to generate a made-up base file for the merge for the case where no base file previously existed. This should be equivalent to what we currently do in git-merge-one-file.sh: diff -u -La/$orig -Lb/$orig $orig $src2 | git-apply --no-add except it should be much simpler and can be done using the direct libxdiff interfaces. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- Makefile | 2 +- merge-file.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ merge-tree.c | 73 ++++++++++++++++++++++++++ 3 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 merge-file.c diff --git a/Makefile b/Makefile index cde619c49..e88045752 100644 --- a/Makefile +++ b/Makefile @@ -217,7 +217,7 @@ LIB_OBJS = \ server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \ tag.o tree.o usage.o config.o environment.o ctype.o copy.o \ fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \ - alloc.o $(DIFF_OBJS) + alloc.o merge-file.o $(DIFF_OBJS) BUILTIN_OBJS = \ builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \ diff --git a/merge-file.c b/merge-file.c new file mode 100644 index 000000000..f32c65382 --- /dev/null +++ b/merge-file.c @@ -0,0 +1,166 @@ +#include "cache.h" +#include "run-command.h" +#include "xdiff-interface.h" +#include "blob.h" + +static void rm_temp_file(const char *filename) +{ + unlink(filename); + free((void *)filename); +} + +static const char *write_temp_file(mmfile_t *f) +{ + int fd; + const char *tmp = getenv("TMPDIR"); + char *filename; + + if (!tmp) + tmp = "/tmp"; + filename = mkpath("%s/%s", tmp, "git-tmp-XXXXXX"); + fd = mkstemp(filename); + if (fd < 0) + return NULL; + filename = strdup(filename); + if (f->size != xwrite(fd, f->ptr, f->size)) { + rm_temp_file(filename); + return NULL; + } + close(fd); + return filename; +} + +static void *read_temp_file(const char *filename, unsigned long *size) +{ + struct stat st; + char *buf = NULL; + int fd = open(filename, O_RDONLY); + if (fd < 0) + return NULL; + if (!fstat(fd, &st)) { + *size = st.st_size; + buf = xmalloc(st.st_size); + if (st.st_size != xread(fd, buf, st.st_size)) { + free(buf); + buf = NULL; + } + } + close(fd); + return buf; +} + +static int fill_mmfile_blob(mmfile_t *f, struct blob *obj) +{ + void *buf; + unsigned long size; + char type[20]; + + buf = read_sha1_file(obj->object.sha1, type, &size); + if (!buf) + return -1; + if (strcmp(type, blob_type)) + return -1; + f->ptr = buf; + f->size = size; + return 0; +} + +static void free_mmfile(mmfile_t *f) +{ + free(f->ptr); +} + +static void *three_way_filemerge(mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size) +{ + void *res; + const char *t1, *t2, *t3; + + t1 = write_temp_file(base); + t2 = write_temp_file(our); + t3 = write_temp_file(their); + res = NULL; + if (t1 && t2 && t3) { + int code = run_command("merge", t2, t1, t3, NULL); + if (!code || code == -1) + res = read_temp_file(t2, size); + } + rm_temp_file(t1); + rm_temp_file(t2); + rm_temp_file(t3); + return res; +} + +static int common_outf(void *priv_, mmbuffer_t *mb, int nbuf) +{ + int i; + mmfile_t *dst = priv_; + + for (i = 0; i < nbuf; i++) { + memcpy(dst->ptr + dst->size, mb[i].ptr, mb[i].size); + dst->size += mb[i].size; + } + return 0; +} + +static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2) +{ + unsigned long size = f1->size < f2->size ? f1->size : f2->size; + void *ptr = xmalloc(size); + xpparam_t xpp; + xdemitconf_t xecfg; + xdemitcb_t ecb; + + xpp.flags = XDF_NEED_MINIMAL; + xecfg.ctxlen = 3; + xecfg.flags = XDL_EMIT_COMMON; + ecb.outf = common_outf; + + res->ptr = ptr; + res->size = 0; + + ecb.priv = res; + return xdl_diff(f1, f2, &xpp, &xecfg, &ecb); +} + +void *merge_file(struct blob *base, struct blob *our, struct blob *their, unsigned long *size) +{ + void *res = NULL; + mmfile_t f1, f2, common; + + /* + * Removed in either branch? + * + * NOTE! This depends on the caller having done the + * proper warning about removing a file that got + * modified in the other branch! + */ + if (!our || !their) { + char type[20]; + if (base) + return NULL; + if (!our) + our = their; + return read_sha1_file(our->object.sha1, type, size); + } + + if (fill_mmfile_blob(&f1, our) < 0) + goto out_no_mmfile; + if (fill_mmfile_blob(&f2, their) < 0) + goto out_free_f1; + + if (base) { + if (fill_mmfile_blob(&common, base) < 0) + goto out_free_f2_f1; + } else { + if (generate_common_file(&common, &f1, &f2) < 0) + goto out_free_f2_f1; + } + res = three_way_filemerge(&common, &f1, &f2, size); + free_mmfile(&common); +out_free_f2_f1: + free_mmfile(&f2); +out_free_f1: + free_mmfile(&f1); +out_no_mmfile: + return res; +} diff --git a/merge-tree.c b/merge-tree.c index fd0c2111c..7cf00be6d 100644 --- a/merge-tree.c +++ b/merge-tree.c @@ -1,5 +1,6 @@ #include "cache.h" #include "tree-walk.h" +#include "xdiff-interface.h" #include "blob.h" static const char merge_tree_usage[] = "git-merge-tree "; @@ -52,6 +53,77 @@ static const char *explanation(struct merge_list *entry) return "removed in remote"; } +extern void *merge_file(struct blob *, struct blob *, struct blob *, unsigned long *); + +static void *result(struct merge_list *entry, unsigned long *size) +{ + char type[20]; + struct blob *base, *our, *their; + + if (!entry->stage) + return read_sha1_file(entry->blob->object.sha1, type, size); + base = NULL; + if (entry->stage == 1) { + base = entry->blob; + entry = entry->link; + } + our = NULL; + if (entry && entry->stage == 2) { + our = entry->blob; + entry = entry->link; + } + their = NULL; + if (entry) + their = entry->blob; + return merge_file(base, our, their, size); +} + +static void *origin(struct merge_list *entry, unsigned long *size) +{ + char type[20]; + while (entry) { + if (entry->stage == 2) + return read_sha1_file(entry->blob->object.sha1, type, size); + entry = entry->link; + } + return NULL; +} + +static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf) +{ + int i; + for (i = 0; i < nbuf; i++) + printf("%.*s", (int) mb[i].size, mb[i].ptr); + return 0; +} + +static void show_diff(struct merge_list *entry) +{ + unsigned long size; + mmfile_t src, dst; + xpparam_t xpp; + xdemitconf_t xecfg; + xdemitcb_t ecb; + + xpp.flags = XDF_NEED_MINIMAL; + xecfg.ctxlen = 3; + xecfg.flags = 0; + ecb.outf = show_outf; + ecb.priv = NULL; + + src.ptr = origin(entry, &size); + if (!src.ptr) + size = 0; + src.size = size; + dst.ptr = result(entry, &size); + if (!dst.ptr) + size = 0; + dst.size = size; + xdl_diff(&src, &dst, &xpp, &xecfg, &ecb); + free(src.ptr); + free(dst.ptr); +} + static void show_result_list(struct merge_list *entry) { printf("%s\n", explanation(entry)); @@ -70,6 +142,7 @@ static void show_result(void) walk = merge_result; while (walk) { show_result_list(walk); + show_diff(walk); walk = walk->next; } } -- cgit v1.2.1 From 27e1b127f32640bea68b84e0ff57d640fd31cc92 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 29 Jun 2006 00:18:52 -0700 Subject: format-patch: fix diff format option implementation The updates forgot to make the diff go recursive. --- builtin-log.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin-log.c b/builtin-log.c index debddb97a..bcd4e5e16 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -179,7 +179,8 @@ int cmd_format_patch(int argc, const char **argv, char **envp) rev.diff = 1; rev.combine_merges = 0; rev.ignore_merges = 1; - rev.diffopt.msg_sep = "---\n"; + rev.diffopt.msg_sep = ""; + rev.diffopt.recursive = 1; git_config(git_format_config); rev.extra_headers = extra_headers; -- cgit v1.2.1 From d410e43b35a8044472606a7e7018aa64d96a5f0f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 29 Jun 2006 00:01:07 -0700 Subject: t4013: add format-patch tests. Signed-off-by: Junio C Hamano --- t/t4013-diff-various.sh | 10 +- ....format-patch_--attach_--stdout_initial..master | 165 +++++++++++++++++++++ ...format-patch_--attach_--stdout_initial..master^ | 106 +++++++++++++ ...ff.format-patch_--attach_--stdout_initial..side | 60 ++++++++ t/t4013/diff.format-patch_--stdout_initial..master | 120 +++++++++++++++ .../diff.format-patch_--stdout_initial..master^ | 76 ++++++++++ t/t4013/diff.format-patch_--stdout_initial..side | 45 ++++++ 7 files changed, 581 insertions(+), 1 deletion(-) create mode 100644 t/t4013/diff.format-patch_--attach_--stdout_initial..master create mode 100644 t/t4013/diff.format-patch_--attach_--stdout_initial..master^ create mode 100644 t/t4013/diff.format-patch_--attach_--stdout_initial..side create mode 100644 t/t4013/diff.format-patch_--stdout_initial..master create mode 100644 t/t4013/diff.format-patch_--stdout_initial..master^ create mode 100644 t/t4013/diff.format-patch_--stdout_initial..side diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 22984e3db..f4f3c3a56 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -85,6 +85,7 @@ test_expect_success setup ' +*+ [initial] Initial EOF +V=`git version | sed -e 's/^git version //'` while read cmd do case "$cmd" in @@ -99,7 +100,7 @@ do test_expect_success "git $cmd" ' { echo "\$ git $cmd" - git $cmd + git $cmd | sed -e "s/$V/g-i-t--v-e-r-s-i-o-n/" echo "\$" } >"$actual" && if test -f "$expect" @@ -219,6 +220,13 @@ show --patch-with-stat side show --patch-with-raw side show --patch-with-stat --summary side +format-patch --stdout initial..side +format-patch --stdout initial..master^ +format-patch --stdout initial..master +format-patch --attach --stdout initial..side +format-patch --attach --stdout initial..master^ +format-patch --attach --stdout initial..master + EOF test_done diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master b/t/t4013/diff.format-patch_--attach_--stdout_initial..master new file mode 100644 index 000000000..a89bbbbcf --- /dev/null +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master @@ -0,0 +1,165 @@ +$ git format-patch --attach --stdout initial..master +From 7952a93e09bf565b5592766a438b40cd81f4846f Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [PATCH] Second +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; + name="7952a93e09bf565b5592766a438b40cd81f4846f.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; + filename="7952a93e09bf565b5592766a438b40cd81f4846f.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +--------------g-i-t--v-e-r-s-i-o-n-- + + + +From 889b315013ef9f2e2f90aa0b054b267c8a557847 Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [PATCH] Third +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; + name="889b315013ef9f2e2f90aa0b054b267c8a557847.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; + filename="889b315013ef9f2e2f90aa0b054b267c8a557847.diff" + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +--------------g-i-t--v-e-r-s-i-o-n-- + + + +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [PATCH] Side +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; + name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; + filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +--------------g-i-t--v-e-r-s-i-o-n-- + + +$ diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ new file mode 100644 index 000000000..4de9091a4 --- /dev/null +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ @@ -0,0 +1,106 @@ +$ git format-patch --attach --stdout initial..master^ +From 7952a93e09bf565b5592766a438b40cd81f4846f Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [PATCH] Second +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; + name="7952a93e09bf565b5592766a438b40cd81f4846f.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; + filename="7952a93e09bf565b5592766a438b40cd81f4846f.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +--------------g-i-t--v-e-r-s-i-o-n-- + + + +From 889b315013ef9f2e2f90aa0b054b267c8a557847 Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [PATCH] Third +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; + name="889b315013ef9f2e2f90aa0b054b267c8a557847.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; + filename="889b315013ef9f2e2f90aa0b054b267c8a557847.diff" + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +--------------g-i-t--v-e-r-s-i-o-n-- + + +$ diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..side b/t/t4013/diff.format-patch_--attach_--stdout_initial..side new file mode 100644 index 000000000..3769fa6da --- /dev/null +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..side @@ -0,0 +1,60 @@ +$ git format-patch --attach --stdout initial..side +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [PATCH] Side +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; + name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; + filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +--------------g-i-t--v-e-r-s-i-o-n-- + + +$ diff --git a/t/t4013/diff.format-patch_--stdout_initial..master b/t/t4013/diff.format-patch_--stdout_initial..master new file mode 100644 index 000000000..b7b4e7ca9 --- /dev/null +++ b/t/t4013/diff.format-patch_--stdout_initial..master @@ -0,0 +1,120 @@ +$ git format-patch --stdout initial..master +From 7952a93e09bf565b5592766a438b40cd81f4846f Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [PATCH] Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 +-- +g-i-t--v-e-r-s-i-o-n + + +From 889b315013ef9f2e2f90aa0b054b267c8a557847 Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [PATCH] Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C +-- +g-i-t--v-e-r-s-i-o-n + + +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [PATCH] Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +-- +g-i-t--v-e-r-s-i-o-n + +$ diff --git a/t/t4013/diff.format-patch_--stdout_initial..master^ b/t/t4013/diff.format-patch_--stdout_initial..master^ new file mode 100644 index 000000000..e56dd98df --- /dev/null +++ b/t/t4013/diff.format-patch_--stdout_initial..master^ @@ -0,0 +1,76 @@ +$ git format-patch --stdout initial..master^ +From 7952a93e09bf565b5592766a438b40cd81f4846f Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [PATCH] Second +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 +-- +g-i-t--v-e-r-s-i-o-n + + +From 889b315013ef9f2e2f90aa0b054b267c8a557847 Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [PATCH] Third +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C +-- +g-i-t--v-e-r-s-i-o-n + +$ diff --git a/t/t4013/diff.format-patch_--stdout_initial..side b/t/t4013/diff.format-patch_--stdout_initial..side new file mode 100644 index 000000000..e7ddbf481 --- /dev/null +++ b/t/t4013/diff.format-patch_--stdout_initial..side @@ -0,0 +1,45 @@ +$ git format-patch --stdout initial..side +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [PATCH] Side +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +-- +g-i-t--v-e-r-s-i-o-n + +$ -- cgit v1.2.1 From 026625e78eaf8ea2ae960525c367b5e8f1629fd4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 29 Jun 2006 12:00:12 -0700 Subject: t4013: note improvements brought by the new output code. Signed-off-by: Junio C Hamano --- t/t4013-diff-various.sh | 18 ++++++++---- .../diff.diff-tree_--cc_--patch-with-stat_master | 34 ++++++++++++++++++++++ ....diff-tree_--pretty_--root_--summary_-r_initial | 11 +++++++ ...iff.diff-tree_--pretty_--root_--summary_initial | 11 +++++++ 4 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 t/t4013/diff.diff-tree_--cc_--patch-with-stat_master create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_--summary_-r_initial create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_--summary_initial diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index f4f3c3a56..026832761 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -138,7 +138,10 @@ diff-tree --pretty --summary initial diff-tree --pretty --stat --summary initial diff-tree --pretty --root -p initial diff-tree --pretty --root --stat initial -#diff-tree --pretty --root --summary initial +# improved by Timo's patch +diff-tree --pretty --root --summary initial +# improved by Timo's patch +diff-tree --pretty --root --summary -r initial diff-tree --pretty --root --stat --summary initial diff-tree --pretty --patch-with-stat initial diff-tree --pretty --root --patch-with-stat initial @@ -150,6 +153,7 @@ diff-tree --pretty=oneline --root initial diff-tree --pretty=oneline -p initial diff-tree --pretty=oneline --root -p initial diff-tree --pretty=oneline --patch-with-stat initial +# improved by Timo's patch diff-tree --pretty=oneline --root --patch-with-stat initial diff-tree --pretty=oneline --patch-with-raw initial diff-tree --pretty=oneline --root --patch-with-raw initial @@ -172,11 +176,9 @@ diff-tree --cc --stat --summary master # stat summary should show the diffstat and summary with the first parent diff-tree -c --stat --summary side diff-tree --cc --stat --summary side -# this one gives an extra newline after stat, which should be removed -# diff-tree --cc --patch-with-stat master -# this one gives an extra newline after stat, which should be removed -# other than that it shows the correct example -- stat and summary are -# against the first parent, and patch-looking combined diff follows. +# improved by Timo's patch +diff-tree --cc --patch-with-stat master +# improved by Timo's patch diff-tree --cc --patch-with-stat --summary master # this is correct diff-tree --cc --patch-with-stat --summary side @@ -188,7 +190,9 @@ log --root -p master log --patch-with-stat master log --root --patch-with-stat master log --root --patch-with-stat --summary master +# improved by Timo's patch log --root -c --patch-with-stat --summary master +# improved by Timo's patch log --root --cc --patch-with-stat --summary master log -SF master log -SF -p master @@ -200,7 +204,9 @@ whatchanged --root -p master whatchanged --patch-with-stat master whatchanged --root --patch-with-stat master whatchanged --root --patch-with-stat --summary master +# improved by Timo's patch whatchanged --root -c --patch-with-stat --summary master +# improved by Timo's patch whatchanged --root --cc --patch-with-stat --summary master whatchanged -SF master whatchanged -SF -p master diff --git a/t/t4013/diff.diff-tree_--cc_--patch-with-stat_master b/t/t4013/diff.diff-tree_--cc_--patch-with-stat_master new file mode 100644 index 000000000..f6ecf7636 --- /dev/null +++ b/t/t4013/diff.diff-tree_--cc_--patch-with-stat_master @@ -0,0 +1,34 @@ +$ git diff-tree --cc --patch-with-stat master +176b998f5d647cbd77a9d8acf4531e930754d16d + dir/sub | 2 ++ + file0 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + +diff --cc dir/sub +index cead32e,7289e35..992913c +--- a/dir/sub ++++ b/dir/sub +@@@ -1,6 -1,4 +1,8 @@@ + A + B + +C + +D + +E + +F ++ 1 ++ 2 +diff --cc file0 +index b414108,f4615da..10a8a9f +--- a/file0 ++++ b/file0 +@@@ -1,6 -1,6 +1,9 @@@ + 1 + 2 + 3 + +4 + +5 + +6 ++ A ++ B ++ C +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--summary_-r_initial b/t/t4013/diff.diff-tree_--pretty_--root_--summary_-r_initial new file mode 100644 index 000000000..ccdaafb37 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--root_--summary_-r_initial @@ -0,0 +1,11 @@ +$ git diff-tree --pretty --root --summary -r initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + + create mode 100644 dir/sub + create mode 100644 file0 + create mode 100644 file2 +$ diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial b/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial new file mode 100644 index 000000000..ea4820553 --- /dev/null +++ b/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial @@ -0,0 +1,11 @@ +$ git diff-tree --pretty --root --summary initial +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial + + create mode 040000 dir + create mode 100644 file0 + create mode 100644 file2 +$ -- cgit v1.2.1 From 52cab8a0848463d793a3fc819b6d604ffc077ac1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 29 Jun 2006 15:16:46 +0200 Subject: refactor merge_bases() as preparation to libify merge-base Signed-off-by: Junio C Hamano --- merge-base.c | 64 +++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/merge-base.c b/merge-base.c index 4856ca01c..7d87c20b7 100644 --- a/merge-base.c +++ b/merge-base.c @@ -124,8 +124,6 @@ static struct commit *interesting(struct commit_list *list) * to contaminate D and E. */ -static int show_all = 0; - static void mark_reachable_commits(struct commit_list *result, struct commit_list *list) { @@ -167,34 +165,33 @@ static void mark_reachable_commits(struct commit_list *result, } } -static int merge_base(struct commit *rev1, struct commit *rev2) +struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2) { struct commit_list *list = NULL; struct commit_list *result = NULL; struct commit_list *tmp = NULL; - if (rev1 == rev2) { - printf("%s\n", sha1_to_hex(rev1->object.sha1)); - return 0; - } + if (rev1 == rev2) + return commit_list_insert(rev1, &result); parse_commit(rev1); parse_commit(rev2); - rev1->object.flags |= 1; - rev2->object.flags |= 2; + rev1->object.flags |= PARENT1; + rev2->object.flags |= PARENT2; insert_by_date(rev1, &list); insert_by_date(rev2, &list); while (interesting(list)) { struct commit *commit = list->item; struct commit_list *parents; - int flags = commit->object.flags & 7; + int flags = commit->object.flags + & (PARENT1 | PARENT2 | UNINTERESTING); tmp = list; list = list->next; free(tmp); - if (flags == 3) { + if (flags == (PARENT1 | PARENT2)) { insert_by_date(commit, &result); /* Mark parents of a found merge uninteresting */ @@ -213,21 +210,52 @@ static int merge_base(struct commit *rev1, struct commit *rev2) } if (!result) - return 1; + return NULL; if (result->next && list) mark_reachable_commits(result, list); + /* cull duplicates */ + for (tmp = result, list = NULL; tmp; ) { + struct commit *commit = tmp->item; + struct commit_list *next = tmp->next; + if (commit->object.flags & UNINTERESTING) { + if (list != NULL) + list->next = next; + free(tmp); + } else { + if (list == NULL) + result = tmp; + list = tmp; + commit->object.flags |= UNINTERESTING; + } + + tmp = next; + } + + /* reset flags */ + clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING); + clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING); + + return result; +} + +static int show_all = 0; + +static int merge_base(struct commit *rev1, struct commit *rev2) +{ + struct commit_list *result = get_merge_bases(rev1, rev2); + + if (!result) + return 1; + while (result) { - struct commit *commit = result->item; - result = result->next; - if (commit->object.flags & UNINTERESTING) - continue; - printf("%s\n", sha1_to_hex(commit->object.sha1)); + printf("%s\n", sha1_to_hex(result->item->object.sha1)); if (!show_all) return 0; - commit->object.flags |= UNINTERESTING; + result = result->next; } + return 0; } -- cgit v1.2.1 From 7c6f8aaf6d795f0c9a75671acceb9754ea06fd81 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 29 Jun 2006 15:17:32 +0200 Subject: move get_merge_bases() to core lib. Signed-off-by: Junio C Hamano --- commit.c | 240 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ commit.h | 2 + merge-base.c | 238 ---------------------------------------------------------- 3 files changed, 242 insertions(+), 238 deletions(-) diff --git a/commit.c b/commit.c index e51ffa1c6..0431027ef 100644 --- a/commit.c +++ b/commit.c @@ -846,3 +846,243 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, } free(nodes); } + +/* merge-rebase stuff */ + +#define PARENT1 1 +#define PARENT2 2 +#define UNINTERESTING 4 + +static struct commit *interesting(struct commit_list *list) +{ + while (list) { + struct commit *commit = list->item; + list = list->next; + if (commit->object.flags & UNINTERESTING) + continue; + return commit; + } + return NULL; +} + +/* + * A pathological example of how this thing works. + * + * Suppose we had this commit graph, where chronologically + * the timestamp on the commit are A <= B <= C <= D <= E <= F + * and we are trying to figure out the merge base for E and F + * commits. + * + * F + * / \ + * E A D + * \ / / + * B / + * \ / + * C + * + * First we push E and F to list to be processed. E gets bit 1 + * and F gets bit 2. The list becomes: + * + * list=F(2) E(1), result=empty + * + * Then we pop F, the newest commit, from the list. Its flag is 2. + * We scan its parents, mark them reachable from the side that F is + * reachable from, and push them to the list: + * + * list=E(1) D(2) A(2), result=empty + * + * Next pop E and do the same. + * + * list=D(2) B(1) A(2), result=empty + * + * Next pop D and do the same. + * + * list=C(2) B(1) A(2), result=empty + * + * Next pop C and do the same. + * + * list=B(1) A(2), result=empty + * + * Now it is B's turn. We mark its parent, C, reachable from B's side, + * and push it to the list: + * + * list=C(3) A(2), result=empty + * + * Now pop C and notice it has flags==3. It is placed on the result list, + * and the list now contains: + * + * list=A(2), result=C(3) + * + * We pop A and do the same. + * + * list=B(3), result=C(3) + * + * Next, we pop B and something very interesting happens. It has flags==3 + * so it is also placed on the result list, and its parents are marked + * uninteresting, retroactively, and placed back on the list: + * + * list=C(7), result=C(7) B(3) + * + * Now, list does not have any interesting commit. So we find the newest + * commit from the result list that is not marked uninteresting. Which is + * commit B. + * + * + * Another pathological example how this thing used to fail to mark an + * ancestor of a merge base as UNINTERESTING before we introduced the + * postprocessing phase (mark_reachable_commits). + * + * 2 + * H + * 1 / \ + * G A \ + * |\ / \ + * | B \ + * | \ \ + * \ C F + * \ \ / + * \ D / + * \ | / + * \| / + * E + * + * list A B C D E F G H + * G1 H2 - - - - - - 1 2 + * H2 E1 B1 - 1 - - 1 - 1 2 + * F2 E1 B1 A2 2 1 - - 1 2 1 2 + * E3 B1 A2 2 1 - - 3 2 1 2 + * B1 A2 2 1 - - 3 2 1 2 + * C1 A2 2 1 1 - 3 2 1 2 + * D1 A2 2 1 1 1 3 2 1 2 + * A2 2 1 1 1 3 2 1 2 + * B3 2 3 1 1 3 2 1 2 + * C7 2 3 7 1 3 2 1 2 + * + * At this point, unfortunately, everybody in the list is + * uninteresting, so we fail to complete the following two + * steps to fully marking uninteresting commits. + * + * D7 2 3 7 7 3 2 1 2 + * E7 2 3 7 7 7 2 1 2 + * + * and we ended up showing E as an interesting merge base. + * The postprocessing phase re-injects C and continues traversal + * to contaminate D and E. + */ + +static void mark_reachable_commits(struct commit_list *result, + struct commit_list *list) +{ + struct commit_list *tmp; + + /* + * Postprocess to fully contaminate the well. + */ + for (tmp = result; tmp; tmp = tmp->next) { + struct commit *c = tmp->item; + /* Reinject uninteresting ones to list, + * so we can scan their parents. + */ + if (c->object.flags & UNINTERESTING) + commit_list_insert(c, &list); + } + while (list) { + struct commit *c = list->item; + struct commit_list *parents; + + tmp = list; + list = list->next; + free(tmp); + + /* Anything taken out of the list is uninteresting, so + * mark all its parents uninteresting. We do not + * parse new ones (we already parsed all the relevant + * ones). + */ + parents = c->parents; + while (parents) { + struct commit *p = parents->item; + parents = parents->next; + if (!(p->object.flags & UNINTERESTING)) { + p->object.flags |= UNINTERESTING; + commit_list_insert(p, &list); + } + } + } +} + +struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2) +{ + struct commit_list *list = NULL; + struct commit_list *result = NULL; + struct commit_list *tmp = NULL; + + if (rev1 == rev2) + return commit_list_insert(rev1, &result); + + parse_commit(rev1); + parse_commit(rev2); + + rev1->object.flags |= PARENT1; + rev2->object.flags |= PARENT2; + insert_by_date(rev1, &list); + insert_by_date(rev2, &list); + + while (interesting(list)) { + struct commit *commit = list->item; + struct commit_list *parents; + int flags = commit->object.flags + & (PARENT1 | PARENT2 | UNINTERESTING); + + tmp = list; + list = list->next; + free(tmp); + if (flags == (PARENT1 | PARENT2)) { + insert_by_date(commit, &result); + + /* Mark parents of a found merge uninteresting */ + flags |= UNINTERESTING; + } + parents = commit->parents; + while (parents) { + struct commit *p = parents->item; + parents = parents->next; + if ((p->object.flags & flags) == flags) + continue; + parse_commit(p); + p->object.flags |= flags; + insert_by_date(p, &list); + } + } + + if (!result) + return NULL; + + if (result->next && list) + mark_reachable_commits(result, list); + + /* cull duplicates */ + for (tmp = result, list = NULL; tmp; ) { + struct commit *commit = tmp->item; + struct commit_list *next = tmp->next; + if (commit->object.flags & UNINTERESTING) { + if (list != NULL) + list->next = next; + free(tmp); + } else { + if (list == NULL) + result = tmp; + list = tmp; + commit->object.flags |= UNINTERESTING; + } + + tmp = next; + } + + /* reset flags */ + clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING); + clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING); + + return result; +} diff --git a/commit.h b/commit.h index 7c9ca3fbe..89b9dad7c 100644 --- a/commit.h +++ b/commit.h @@ -105,4 +105,6 @@ struct commit_graft *read_graft_line(char *buf, int len); int register_commit_graft(struct commit_graft *, int); int read_graft_file(const char *graft_file); +extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2); + #endif /* COMMIT_H */ diff --git a/merge-base.c b/merge-base.c index 7d87c20b7..b41f76cb7 100644 --- a/merge-base.c +++ b/merge-base.c @@ -2,244 +2,6 @@ #include "cache.h" #include "commit.h" -#define PARENT1 1 -#define PARENT2 2 -#define UNINTERESTING 4 - -static struct commit *interesting(struct commit_list *list) -{ - while (list) { - struct commit *commit = list->item; - list = list->next; - if (commit->object.flags & UNINTERESTING) - continue; - return commit; - } - return NULL; -} - -/* - * A pathological example of how this thing works. - * - * Suppose we had this commit graph, where chronologically - * the timestamp on the commit are A <= B <= C <= D <= E <= F - * and we are trying to figure out the merge base for E and F - * commits. - * - * F - * / \ - * E A D - * \ / / - * B / - * \ / - * C - * - * First we push E and F to list to be processed. E gets bit 1 - * and F gets bit 2. The list becomes: - * - * list=F(2) E(1), result=empty - * - * Then we pop F, the newest commit, from the list. Its flag is 2. - * We scan its parents, mark them reachable from the side that F is - * reachable from, and push them to the list: - * - * list=E(1) D(2) A(2), result=empty - * - * Next pop E and do the same. - * - * list=D(2) B(1) A(2), result=empty - * - * Next pop D and do the same. - * - * list=C(2) B(1) A(2), result=empty - * - * Next pop C and do the same. - * - * list=B(1) A(2), result=empty - * - * Now it is B's turn. We mark its parent, C, reachable from B's side, - * and push it to the list: - * - * list=C(3) A(2), result=empty - * - * Now pop C and notice it has flags==3. It is placed on the result list, - * and the list now contains: - * - * list=A(2), result=C(3) - * - * We pop A and do the same. - * - * list=B(3), result=C(3) - * - * Next, we pop B and something very interesting happens. It has flags==3 - * so it is also placed on the result list, and its parents are marked - * uninteresting, retroactively, and placed back on the list: - * - * list=C(7), result=C(7) B(3) - * - * Now, list does not have any interesting commit. So we find the newest - * commit from the result list that is not marked uninteresting. Which is - * commit B. - * - * - * Another pathological example how this thing used to fail to mark an - * ancestor of a merge base as UNINTERESTING before we introduced the - * postprocessing phase (mark_reachable_commits). - * - * 2 - * H - * 1 / \ - * G A \ - * |\ / \ - * | B \ - * | \ \ - * \ C F - * \ \ / - * \ D / - * \ | / - * \| / - * E - * - * list A B C D E F G H - * G1 H2 - - - - - - 1 2 - * H2 E1 B1 - 1 - - 1 - 1 2 - * F2 E1 B1 A2 2 1 - - 1 2 1 2 - * E3 B1 A2 2 1 - - 3 2 1 2 - * B1 A2 2 1 - - 3 2 1 2 - * C1 A2 2 1 1 - 3 2 1 2 - * D1 A2 2 1 1 1 3 2 1 2 - * A2 2 1 1 1 3 2 1 2 - * B3 2 3 1 1 3 2 1 2 - * C7 2 3 7 1 3 2 1 2 - * - * At this point, unfortunately, everybody in the list is - * uninteresting, so we fail to complete the following two - * steps to fully marking uninteresting commits. - * - * D7 2 3 7 7 3 2 1 2 - * E7 2 3 7 7 7 2 1 2 - * - * and we ended up showing E as an interesting merge base. - * The postprocessing phase re-injects C and continues traversal - * to contaminate D and E. - */ - -static void mark_reachable_commits(struct commit_list *result, - struct commit_list *list) -{ - struct commit_list *tmp; - - /* - * Postprocess to fully contaminate the well. - */ - for (tmp = result; tmp; tmp = tmp->next) { - struct commit *c = tmp->item; - /* Reinject uninteresting ones to list, - * so we can scan their parents. - */ - if (c->object.flags & UNINTERESTING) - commit_list_insert(c, &list); - } - while (list) { - struct commit *c = list->item; - struct commit_list *parents; - - tmp = list; - list = list->next; - free(tmp); - - /* Anything taken out of the list is uninteresting, so - * mark all its parents uninteresting. We do not - * parse new ones (we already parsed all the relevant - * ones). - */ - parents = c->parents; - while (parents) { - struct commit *p = parents->item; - parents = parents->next; - if (!(p->object.flags & UNINTERESTING)) { - p->object.flags |= UNINTERESTING; - commit_list_insert(p, &list); - } - } - } -} - -struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2) -{ - struct commit_list *list = NULL; - struct commit_list *result = NULL; - struct commit_list *tmp = NULL; - - if (rev1 == rev2) - return commit_list_insert(rev1, &result); - - parse_commit(rev1); - parse_commit(rev2); - - rev1->object.flags |= PARENT1; - rev2->object.flags |= PARENT2; - insert_by_date(rev1, &list); - insert_by_date(rev2, &list); - - while (interesting(list)) { - struct commit *commit = list->item; - struct commit_list *parents; - int flags = commit->object.flags - & (PARENT1 | PARENT2 | UNINTERESTING); - - tmp = list; - list = list->next; - free(tmp); - if (flags == (PARENT1 | PARENT2)) { - insert_by_date(commit, &result); - - /* Mark parents of a found merge uninteresting */ - flags |= UNINTERESTING; - } - parents = commit->parents; - while (parents) { - struct commit *p = parents->item; - parents = parents->next; - if ((p->object.flags & flags) == flags) - continue; - parse_commit(p); - p->object.flags |= flags; - insert_by_date(p, &list); - } - } - - if (!result) - return NULL; - - if (result->next && list) - mark_reachable_commits(result, list); - - /* cull duplicates */ - for (tmp = result, list = NULL; tmp; ) { - struct commit *commit = tmp->item; - struct commit_list *next = tmp->next; - if (commit->object.flags & UNINTERESTING) { - if (list != NULL) - list->next = next; - free(tmp); - } else { - if (list == NULL) - result = tmp; - list = tmp; - commit->object.flags |= UNINTERESTING; - } - - tmp = next; - } - - /* reset flags */ - clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING); - clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING); - - return result; -} - static int show_all = 0; static int merge_base(struct commit *rev1, struct commit *rev2) -- cgit v1.2.1 From e14421b9aa85f11853a0dacae09498515daab7b8 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 29 Jun 2006 22:11:25 +0200 Subject: Allow INSTALL, bindir, mandir to be set in main Makefile Makefiles in subdirectories now use existing value of INSTALL, bindir, mandir if it is set, allowing those to be set in main Makefile or in included config.mak. Main Makefile exports variables which it sets. Accidentally it renames bin to bindir in Documentation/Makefile (should be bindir from start, but is unused, perhaps to be removed). Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- Documentation/Makefile | 4 ++-- Makefile | 2 ++ contrib/emacs/Makefile | 4 ++-- contrib/git-svn/Makefile | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 2b0efe792..ca6b77df2 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -25,8 +25,8 @@ DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) prefix?=$(HOME) -bin=$(prefix)/bin -mandir=$(prefix)/man +bindir?=$(prefix)/bin +mandir?=$(prefix)/man man1=$(mandir)/man1 man7=$(mandir)/man7 # DESTDIR= diff --git a/Makefile b/Makefile index cde619c49..b8fe66972 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,8 @@ template_dir = $(prefix)/share/git-core/templates/ GIT_PYTHON_DIR = $(prefix)/share/git-core/python # DESTDIR= +export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR + CC = gcc AR = ar TAR = tar diff --git a/contrib/emacs/Makefile b/contrib/emacs/Makefile index d3619db51..350846de9 100644 --- a/contrib/emacs/Makefile +++ b/contrib/emacs/Makefile @@ -3,9 +3,9 @@ EMACS = emacs ELC = git.elc vc-git.elc -INSTALL = install +INSTALL ?= install INSTALL_ELC = $(INSTALL) -m 644 -prefix = $(HOME) +prefix ?= $(HOME) emacsdir = $(prefix)/share/emacs/site-lisp all: $(ELC) diff --git a/contrib/git-svn/Makefile b/contrib/git-svn/Makefile index 7c2094694..1a6585eee 100644 --- a/contrib/git-svn/Makefile +++ b/contrib/git-svn/Makefile @@ -1,8 +1,8 @@ all: git-svn prefix?=$(HOME) -bindir=$(prefix)/bin -mandir=$(prefix)/man +bindir?=$(prefix)/bin +mandir?=$(prefix)/man man1=$(mandir)/man1 INSTALL?=install doc_conf=../../Documentation/asciidoc.conf -- cgit v1.2.1 From 7b8cf0cf2973cc8df3bdd36b9b36542b1f04d70a Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 29 Jun 2006 23:26:54 +0200 Subject: Rename man1 and man7 variables to man1dir and man7dir This patch renames man1 and man7 variables to man1dir and man7dir, according to "Makefile Conventions: Variables for Installation Directories" in make.info of GNU Make. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- Documentation/Makefile | 10 +++++----- Makefile | 4 ++-- contrib/git-svn/Makefile | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index ca6b77df2..cc8361058 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -27,8 +27,8 @@ DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) prefix?=$(HOME) bindir?=$(prefix)/bin mandir?=$(prefix)/man -man1=$(mandir)/man1 -man7=$(mandir)/man7 +man1dir=$(mandir)/man1 +man7dir=$(mandir)/man7 # DESTDIR= INSTALL?=install @@ -52,9 +52,9 @@ man1: $(DOC_MAN1) man7: $(DOC_MAN7) install: man - $(INSTALL) -d -m755 $(DESTDIR)$(man1) $(DESTDIR)$(man7) - $(INSTALL) $(DOC_MAN1) $(DESTDIR)$(man1) - $(INSTALL) $(DOC_MAN7) $(DESTDIR)$(man7) + $(INSTALL) -d -m755 $(DESTDIR)$(man1dir) $(DESTDIR)$(man7dir) + $(INSTALL) $(DOC_MAN1) $(DESTDIR)$(man1dir) + $(INSTALL) $(DOC_MAN7) $(DESTDIR)$(man7dir) # diff --git a/Makefile b/Makefile index b8fe66972..ccd7c62e5 100644 --- a/Makefile +++ b/Makefile @@ -714,8 +714,8 @@ dist-doc: rm -fr .doc-tmp-dir mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7 $(MAKE) -C Documentation DESTDIR=./ \ - man1=../.doc-tmp-dir/man1 \ - man7=../.doc-tmp-dir/man7 \ + man1dir=../.doc-tmp-dir/man1 \ + man7dir=../.doc-tmp-dir/man7 \ install cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar . gzip -n -9 -f $(manpages).tar diff --git a/contrib/git-svn/Makefile b/contrib/git-svn/Makefile index 1a6585eee..8cac68873 100644 --- a/contrib/git-svn/Makefile +++ b/contrib/git-svn/Makefile @@ -3,7 +3,7 @@ all: git-svn prefix?=$(HOME) bindir?=$(prefix)/bin mandir?=$(prefix)/man -man1=$(mandir)/man1 +man1dir=$(mandir)/man1 INSTALL?=install doc_conf=../../Documentation/asciidoc.conf -include ../../config.mak @@ -17,7 +17,7 @@ install: all $(INSTALL) git-svn $(DESTDIR)$(bindir) install-doc: doc - $(INSTALL) git-svn.1 $(DESTDIR)$(man1) + $(INSTALL) git-svn.1 $(DESTDIR)$(man1dir) doc: git-svn.1 git-svn.1 : git-svn.xml -- cgit v1.2.1 From 31609c17251f368584f7b94d44b06194112b4251 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Sun, 2 Jul 2006 01:29:26 +0200 Subject: Add get_merge_bases_clean() Add get_merge_bases_clean(), a wrapper for get_merge_bases() that cleans up after doing its work and make get_merge_bases() NOT clean up. Single-shot programs like git-merge-base can use the dirty and fast version. Also move the object flags used in get_merge_bases() out of the range defined in revision.h. This fixes the "66ae0c77...ced9456a 89719209...262a6ef7" test of the ... operator which is introduced with the next patch. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- commit.c | 20 ++++++++++++++++---- commit.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/commit.c b/commit.c index 0431027ef..593414df3 100644 --- a/commit.c +++ b/commit.c @@ -849,9 +849,10 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, /* merge-rebase stuff */ -#define PARENT1 1 -#define PARENT2 2 -#define UNINTERESTING 4 +/* bits #0..7 in revision.h */ +#define PARENT1 (1u<< 8) +#define PARENT2 (1u<< 9) +#define UNINTERESTING (1u<<10) static struct commit *interesting(struct commit_list *list) { @@ -1080,9 +1081,20 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2) tmp = next; } - /* reset flags */ + return result; +} + +struct commit_list *get_merge_bases_clean(struct commit *rev1, + struct commit *rev2) +{ + unsigned int flags1 = rev1->object.flags; + unsigned int flags2 = rev2->object.flags; + struct commit_list *result = get_merge_bases(rev1, rev2); + clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING); clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING); + rev1->object.flags = flags1; + rev2->object.flags = flags2; return result; } diff --git a/commit.h b/commit.h index 89b9dad7c..3a26e29ce 100644 --- a/commit.h +++ b/commit.h @@ -106,5 +106,6 @@ int register_commit_graft(struct commit_graft *, int); int read_graft_file(const char *graft_file); extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2); +extern struct commit_list *get_merge_bases_clean(struct commit *rev1, struct commit *rev2); #endif /* COMMIT_H */ -- cgit v1.2.1 From 0d2c9d67d9e1a2fd87b2daeefffffaff0b3f3a49 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Sun, 2 Jul 2006 01:29:37 +0200 Subject: Add '...' operator for revisions 'A...B' is a shortcut for 'A B --not $(git-merge-base --all A B)'. This XOR-like operation is called symmetric difference in set theory. The symbol '...' has been chosen because it's rather similar to the existing '..' operator and the somewhat more natural caret ('^') is already taken. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- Documentation/git-rev-list.txt | 14 ++++++++++++ revision.c | 48 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index ad6d14c55..6c370e1be 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -15,6 +15,7 @@ SYNOPSIS [ \--sparse ] [ \--no-merges ] [ \--remove-empty ] + [ \--not ] [ \--all ] [ \--topo-order ] [ \--parents ] @@ -37,6 +38,14 @@ not in 'baz'". A special notation .. can be used as a short-hand for {caret} . +Another special notation is ... which is useful for +merges. The resulting set of commits is the symmetric difference +between the two operands. The following two commands are equivalent: + +------------ +$ git-rev-list A B --not $(git-merge-base --all A B) +$ git-rev-list A...B +------------ OPTIONS ------- @@ -93,6 +102,11 @@ OPTIONS --remove-empty:: Stop when a given path disappears from the tree. +--not:: + Reverses the meaning of the '{caret}' prefix (or lack + thereof) for all following revision specifiers, up to + the next `--not`. + --all:: Pretend as if all the refs in `$GIT_DIR/refs/` are listed on the command line as . diff --git a/revision.c b/revision.c index b963f2adf..9eb0b6da9 100644 --- a/revision.c +++ b/revision.c @@ -536,6 +536,18 @@ void init_revisions(struct rev_info *revs) diff_setup(&revs->diffopt); } +static void add_pending_commit_list(struct rev_info *revs, + struct commit_list *commit_list, + unsigned int flags) +{ + while (commit_list) { + struct object *object = &commit_list->item->object; + object->flags |= flags; + add_pending_object(revs, object, sha1_to_hex(object->sha1)); + commit_list = commit_list->next; + } +} + /* * Parse revision information, filling in the "rev_info" structure, * and removing the used arguments from the argument list. @@ -771,27 +783,45 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch unsigned char from_sha1[20]; const char *next = dotdot + 2; const char *this = arg; + int symmetric = *next == '.'; + unsigned int flags_exclude = flags ^ UNINTERESTING; + *dotdot = 0; + next += symmetric; + if (!*next) next = "HEAD"; if (dotdot == arg) this = "HEAD"; if (!get_sha1(this, from_sha1) && !get_sha1(next, sha1)) { - struct object *exclude; - struct object *include; - - exclude = get_reference(revs, this, from_sha1, flags ^ UNINTERESTING); - include = get_reference(revs, next, sha1, flags); - if (!exclude || !include) - die("Invalid revision range %s..%s", arg, next); + struct commit *a, *b; + struct commit_list *exclude; + + a = lookup_commit_reference(from_sha1); + b = lookup_commit_reference(sha1); + if (!a || !b) { + die(symmetric ? + "Invalid symmetric difference expression %s...%s" : + "Invalid revision range %s..%s", + arg, next); + } if (!seen_dashdash) { *dotdot = '.'; verify_non_filename(revs->prefix, arg); } - add_pending_object(revs, exclude, this); - add_pending_object(revs, include, next); + + if (symmetric) { + exclude = get_merge_bases_clean(a, b); + add_pending_commit_list(revs, exclude, + flags_exclude); + a->object.flags |= flags; + } else + a->object.flags |= flags_exclude; + b->object.flags |= flags; + add_pending_object(revs, &a->object, this); + add_pending_object(revs, &b->object, next); continue; } *dotdot = '.'; -- cgit v1.2.1 From 31aea7ef77aff64a02afe1ea5f10375565911808 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Sun, 2 Jul 2006 01:29:58 +0200 Subject: Make clear_commit_marks() clean harder Don't care if objects have been parsed or not and don't stop when we reach a commit that is already clean -- its parents could be dirty. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- commit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/commit.c b/commit.c index 593414df3..70a4effe5 100644 --- a/commit.c +++ b/commit.c @@ -397,13 +397,12 @@ void clear_commit_marks(struct commit *commit, unsigned int mark) { struct commit_list *parents; + if (!commit) + return; parents = commit->parents; commit->object.flags &= ~mark; while (parents) { - struct commit *parent = parents->item; - if (parent && parent->object.parsed && - (parent->object.flags & mark)) - clear_commit_marks(parent, mark); + clear_commit_marks(parents->item, mark); parents = parents->next; } } -- cgit v1.2.1 From cdd4037d7053647c97139ac77d4319124f17d47e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 30 Jun 2006 18:54:32 -0700 Subject: gitweb: optimize per-file history generation The rev-list command that is recent enough can filter commits based on paths they touch, so use it instead of generating the full list and limiting it by passing it with diff-tree --stdin. [jc: The patch originally came from Luben Tuikov but the it was corrupt, but it was short enough to be applied by hand. I added the --full-history to make the output compatible with the original while doing so.] Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 035e76d0a..100774215 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -2295,16 +2295,13 @@ sub git_history { "\n"; print "
/" . esc_html($file_name) . "
\n"; - open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -- \'$file_name\'"; - my $commit; + open my $fd, "-|", + "$gitbin/git-rev-list --full-history $hash -- \'$file_name\'"; print "\n"; my $alternate = 0; while (my $line = <$fd>) { if ($line =~ m/^([0-9a-fA-F]{40})/){ - $commit = $1; - next; - } - if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/ && (defined $commit)) { + my $commit = $1; my %co = git_read_commit($commit); if (!%co) { next; @@ -2336,7 +2333,6 @@ sub git_history { } print "\n" . "\n"; - undef $commit; } } print "
\n"; -- cgit v1.2.1 From 85b7cfb1036b4218d13cbc215729ad083a61a0ea Mon Sep 17 00:00:00 2001 From: Luben Tuikov Date: Fri, 30 Jun 2006 19:11:18 -0700 Subject: gitweb: Enable tree (directory) history display This patch allows history display of whole trees/directories a la "git-rev-list HEAD -- ". I find this useful especially when a project lives in its own subdirectory, as opposed to being all of the GIT repository (i.e. when a sub-project is merged into a super-project). Signed-off-by: Luben Tuikov Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 1 + 1 file changed, 1 insertion(+) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 100774215..efffc8d07 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -1676,6 +1676,7 @@ sub git_tree { "\n" . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") . "\n"; } print "\n"; -- cgit v1.2.1 From 4a87b43e374626a95c14362f21c9ca1023638a2c Mon Sep 17 00:00:00 2001 From: Dennis Stosberg Date: Wed, 21 Jun 2006 15:07:08 +0200 Subject: gitweb: Declare global variables with "our" Variables declared with "my" in the file scope cannot be accessed from subroutines with mod_perl. Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index efffc8d07..3e2790c5d 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -16,21 +16,21 @@ use Encode; use Fcntl ':mode'; binmode STDOUT, ':utf8'; -my $cgi = new CGI; -my $version = "267"; -my $my_url = $cgi->url(); -my $my_uri = $cgi->url(-absolute => 1); -my $rss_link = ""; +our $cgi = new CGI; +our $version = "267"; +our $my_url = $cgi->url(); +our $my_uri = $cgi->url(-absolute => 1); +our $rss_link = ""; # location of the git-core binaries -my $gitbin = "/usr/bin"; +our $gitbin = "/usr/bin"; # absolute fs-path which will be prepended to the project path -#my $projectroot = "/pub/scm"; -my $projectroot = "/home/kay/public_html/pub/scm"; +#our $projectroot = "/pub/scm"; +our $projectroot = "/home/kay/public_html/pub/scm"; # version of the git-core binaries -my $git_version = qx($gitbin/git --version); +our $git_version = qx($gitbin/git --version); if ($git_version =~ m/git version (.*)$/) { $git_version = $1; } else { @@ -38,32 +38,31 @@ if ($git_version =~ m/git version (.*)$/) { } # location for temporary files needed for diffs -my $git_temp = "/tmp/gitweb"; +our $git_temp = "/tmp/gitweb"; # target of the home link on top of all pages -my $home_link = $my_uri; +our $home_link = $my_uri; # html text to include at home page -my $home_text = "indextext.html"; +our $home_text = "indextext.html"; # URI of default stylesheet -my $stylesheet = "gitweb.css"; +our $stylesheet = "gitweb.css"; # source of projects list -#my $projects_list = $projectroot; -my $projects_list = "index/index.aux"; +#our $projects_list = $projectroot; +our $projects_list = "index/index.aux"; # default blob_plain mimetype and default charset for text/plain blob -my $default_blob_plain_mimetype = 'text/plain'; -my $default_text_plain_charset = undef; +our $default_blob_plain_mimetype = 'text/plain'; +our $default_text_plain_charset = undef; # file to use for guessing MIME types before trying /etc/mime.types # (relative to the current git repository) -my $mimetypes_file = undef; - +our $mimetypes_file = undef; # input validation and dispatch -my $action = $cgi->param('a'); +our $action = $cgi->param('a'); if (defined $action) { if ($action =~ m/[^0-9a-zA-Z\.\-_]/) { undef $action; @@ -78,7 +77,7 @@ if (defined $action) { } } -my $order = $cgi->param('o'); +our $order = $cgi->param('o'); if (defined $order) { if ($order =~ m/[^0-9a-zA-Z_]/) { undef $order; @@ -86,7 +85,7 @@ if (defined $order) { } } -my $project = ($cgi->param('p') || $ENV{'PATH_INFO'}); +our $project = ($cgi->param('p') || $ENV{'PATH_INFO'}); if (defined $project) { $project =~ s|^/||; $project =~ s|/$||; $project = validate_input($project); @@ -109,7 +108,7 @@ if (defined $project) { exit; } -my $file_name = $cgi->param('f'); +our $file_name = $cgi->param('f'); if (defined $file_name) { $file_name = validate_input($file_name); if (!defined($file_name)) { @@ -117,7 +116,7 @@ if (defined $file_name) { } } -my $hash = $cgi->param('h'); +our $hash = $cgi->param('h'); if (defined $hash) { $hash = validate_input($hash); if (!defined($hash)) { @@ -125,7 +124,7 @@ if (defined $hash) { } } -my $hash_parent = $cgi->param('hp'); +our $hash_parent = $cgi->param('hp'); if (defined $hash_parent) { $hash_parent = validate_input($hash_parent); if (!defined($hash_parent)) { @@ -133,7 +132,7 @@ if (defined $hash_parent) { } } -my $hash_base = $cgi->param('hb'); +our $hash_base = $cgi->param('hb'); if (defined $hash_base) { $hash_base = validate_input($hash_base); if (!defined($hash_base)) { @@ -141,7 +140,7 @@ if (defined $hash_base) { } } -my $page = $cgi->param('pg'); +our $page = $cgi->param('pg'); if (defined $page) { if ($page =~ m/[^0-9]$/) { undef $page; @@ -149,7 +148,7 @@ if (defined $page) { } } -my $searchtext = $cgi->param('s'); +our $searchtext = $cgi->param('s'); if (defined $searchtext) { if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) { undef $searchtext; -- cgit v1.2.1 From b00d7079ce000afe8803b6e88a7ab0f09942462d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 30 Jun 2006 18:54:32 -0700 Subject: gitweb: optimize per-file history generation The rev-list command that is recent enough can filter commits based on paths they touch, so use it instead of generating the full list and limiting it by passing it with diff-tree --stdin. [jc: The patch originally came from Luben Tuikov but the it was corrupt, but it was short enough to be applied by hand. I added the --full-history to make the output compatible with the original while doing so.] Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 035e76d0a..100774215 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -2295,16 +2295,13 @@ sub git_history { "\n"; print "
/" . esc_html($file_name) . "
\n"; - open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -- \'$file_name\'"; - my $commit; + open my $fd, "-|", + "$gitbin/git-rev-list --full-history $hash -- \'$file_name\'"; print "\n"; my $alternate = 0; while (my $line = <$fd>) { if ($line =~ m/^([0-9a-fA-F]{40})/){ - $commit = $1; - next; - } - if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/ && (defined $commit)) { + my $commit = $1; my %co = git_read_commit($commit); if (!%co) { next; @@ -2336,7 +2333,6 @@ sub git_history { } print "\n" . "\n"; - undef $commit; } } print "
\n"; -- cgit v1.2.1 From e0becd944578ed2a38742911dff75fa7774059e5 Mon Sep 17 00:00:00 2001 From: Luben Tuikov Date: Fri, 30 Jun 2006 19:11:18 -0700 Subject: gitweb: Enable tree (directory) history display This patch allows history display of whole trees/directories a la "git-rev-list HEAD -- ". I find this useful especially when a project lives in its own subdirectory, as opposed to being all of the GIT repository (i.e. when a sub-project is merged into a super-project). Signed-off-by: Luben Tuikov Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 1 + 1 file changed, 1 insertion(+) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 100774215..efffc8d07 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -1676,6 +1676,7 @@ sub git_tree { "\n" . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") . "\n"; } print "\n"; -- cgit v1.2.1 From dc6d9b4999bfdf6bcabf8803f9fa886eb9eaba28 Mon Sep 17 00:00:00 2001 From: Dennis Stosberg Date: Wed, 21 Jun 2006 15:07:08 +0200 Subject: gitweb: Declare global variables with "our" Variables declared with "my" in the file scope cannot be accessed from subroutines with mod_perl. Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index efffc8d07..3e2790c5d 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -16,21 +16,21 @@ use Encode; use Fcntl ':mode'; binmode STDOUT, ':utf8'; -my $cgi = new CGI; -my $version = "267"; -my $my_url = $cgi->url(); -my $my_uri = $cgi->url(-absolute => 1); -my $rss_link = ""; +our $cgi = new CGI; +our $version = "267"; +our $my_url = $cgi->url(); +our $my_uri = $cgi->url(-absolute => 1); +our $rss_link = ""; # location of the git-core binaries -my $gitbin = "/usr/bin"; +our $gitbin = "/usr/bin"; # absolute fs-path which will be prepended to the project path -#my $projectroot = "/pub/scm"; -my $projectroot = "/home/kay/public_html/pub/scm"; +#our $projectroot = "/pub/scm"; +our $projectroot = "/home/kay/public_html/pub/scm"; # version of the git-core binaries -my $git_version = qx($gitbin/git --version); +our $git_version = qx($gitbin/git --version); if ($git_version =~ m/git version (.*)$/) { $git_version = $1; } else { @@ -38,32 +38,31 @@ if ($git_version =~ m/git version (.*)$/) { } # location for temporary files needed for diffs -my $git_temp = "/tmp/gitweb"; +our $git_temp = "/tmp/gitweb"; # target of the home link on top of all pages -my $home_link = $my_uri; +our $home_link = $my_uri; # html text to include at home page -my $home_text = "indextext.html"; +our $home_text = "indextext.html"; # URI of default stylesheet -my $stylesheet = "gitweb.css"; +our $stylesheet = "gitweb.css"; # source of projects list -#my $projects_list = $projectroot; -my $projects_list = "index/index.aux"; +#our $projects_list = $projectroot; +our $projects_list = "index/index.aux"; # default blob_plain mimetype and default charset for text/plain blob -my $default_blob_plain_mimetype = 'text/plain'; -my $default_text_plain_charset = undef; +our $default_blob_plain_mimetype = 'text/plain'; +our $default_text_plain_charset = undef; # file to use for guessing MIME types before trying /etc/mime.types # (relative to the current git repository) -my $mimetypes_file = undef; - +our $mimetypes_file = undef; # input validation and dispatch -my $action = $cgi->param('a'); +our $action = $cgi->param('a'); if (defined $action) { if ($action =~ m/[^0-9a-zA-Z\.\-_]/) { undef $action; @@ -78,7 +77,7 @@ if (defined $action) { } } -my $order = $cgi->param('o'); +our $order = $cgi->param('o'); if (defined $order) { if ($order =~ m/[^0-9a-zA-Z_]/) { undef $order; @@ -86,7 +85,7 @@ if (defined $order) { } } -my $project = ($cgi->param('p') || $ENV{'PATH_INFO'}); +our $project = ($cgi->param('p') || $ENV{'PATH_INFO'}); if (defined $project) { $project =~ s|^/||; $project =~ s|/$||; $project = validate_input($project); @@ -109,7 +108,7 @@ if (defined $project) { exit; } -my $file_name = $cgi->param('f'); +our $file_name = $cgi->param('f'); if (defined $file_name) { $file_name = validate_input($file_name); if (!defined($file_name)) { @@ -117,7 +116,7 @@ if (defined $file_name) { } } -my $hash = $cgi->param('h'); +our $hash = $cgi->param('h'); if (defined $hash) { $hash = validate_input($hash); if (!defined($hash)) { @@ -125,7 +124,7 @@ if (defined $hash) { } } -my $hash_parent = $cgi->param('hp'); +our $hash_parent = $cgi->param('hp'); if (defined $hash_parent) { $hash_parent = validate_input($hash_parent); if (!defined($hash_parent)) { @@ -133,7 +132,7 @@ if (defined $hash_parent) { } } -my $hash_base = $cgi->param('hb'); +our $hash_base = $cgi->param('hb'); if (defined $hash_base) { $hash_base = validate_input($hash_base); if (!defined($hash_base)) { @@ -141,7 +140,7 @@ if (defined $hash_base) { } } -my $page = $cgi->param('pg'); +our $page = $cgi->param('pg'); if (defined $page) { if ($page =~ m/[^0-9]$/) { undef $page; @@ -149,7 +148,7 @@ if (defined $page) { } } -my $searchtext = $cgi->param('s'); +our $searchtext = $cgi->param('s'); if (defined $searchtext) { if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) { undef $searchtext; -- cgit v1.2.1 From a51d37c1df66386a4d9b7559d64a39241d4e47da Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 1 Jul 2006 15:14:14 -0700 Subject: Add git-instaweb, instantly browse the working repo with gitweb I got tired of having to configure gitweb for every repository I work on. I sometimes prefer gitweb to standard GUIs like gitk or gitview; so this lets me automatically configure gitweb to browse my working repository and also opens my browser to it. Updates from the original patch: Added Apache/mod_perl2 compatibility if Dennis Stosberg's gitweb has been applied, too: <20060621130708.Gcbc6e5c@leonov.stosberg.net> General cleanups in shell code usage. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- .gitignore | 1 + Documentation/git-instaweb.txt | 84 +++++++++++++++ Makefile | 16 ++- git-instaweb.sh | 235 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 Documentation/git-instaweb.txt create mode 100755 git-instaweb.sh diff --git a/.gitignore b/.gitignore index 7b954d587..2bcc604af 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ git-http-push git-imap-send git-index-pack git-init-db +git-instaweb git-local-fetch git-log git-lost-found diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt new file mode 100644 index 000000000..7dd393b97 --- /dev/null +++ b/Documentation/git-instaweb.txt @@ -0,0 +1,84 @@ +git-instaweb(1) +=============== + +NAME +---- +git-instaweb - instantly browse your working repository in gitweb + +SYNOPSIS +-------- +'git-instaweb' [--local] [--httpd=] [--port=] [--browser=] + +'git-instaweb' [--start] [--stop] [--restart] + +DESCRIPTION +----------- +A simple script to setup gitweb and a web server for browsing the local +repository. + +OPTIONS +------- + +-l|--local:: + Only bind the web server to the local IP (127.0.0.1). + +-d|--httpd:: + The HTTP daemon command-line that will be executed. + Command-line options may be specified here, and the + configuration file will be added at the end of the command-line. + Currently, lighttpd and apache2 are the only supported servers. + (Default: lighttpd) + +-m|--module-path:: + The module path (only needed if httpd is Apache). + (Default: /usr/lib/apache2/modules) + +-p|--port:: + The port number to bind the httpd to. (Default: 1234) + +-b|--browser:: + + The web browser command-line to execute to view the gitweb page. + If blank, the URL of the gitweb instance will be printed to + stdout. (Default: 'firefox') + +--start:: + Start the httpd instance and exit. This does not generate + any of the configuration files for spawning a new instance. + +--stop:: + Stop the httpd instance and exit. This does not generate + any of the configuration files for spawning a new instance, + nor does it close the browser. + +--restart:: + Restart the httpd instance and exit. This does not generate + any of the configuration files for spawning a new instance. + +CONFIGURATION +------------- + +You may specify configuration in your .git/config + +----------------------------------------------------------------------- +[instaweb] + local = true + httpd = apache2 -f + port = 4321 + browser = konqueror + modulepath = /usr/lib/apache2/modules + +----------------------------------------------------------------------- + +Author +------ +Written by Eric Wong + +Documentation +-------------- +Documentation by Eric Wong . + +GIT +--- +Part of the gitlink:git[7] suite + diff --git a/Makefile b/Makefile index cde619c49..83d892229 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ SCRIPT_PYTHON = \ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ $(patsubst %.py,%,$(SCRIPT_PYTHON)) \ - git-cherry-pick git-status + git-cherry-pick git-status git-instaweb # The ones that do not have to link with lcrypto, lz nor xdiff. SIMPLE_PROGRAMS = \ @@ -545,6 +545,20 @@ git-status: git-commit cp $< $@+ mv $@+ $@ +git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css + rm -f $@ $@+ + sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ + -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ + -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ + -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \ + $@.sh | sed \ + -e 's|@@GITWEB_CGI@@|#!$(PERL_PATH_SQ)|; T; r gitweb/gitweb.cgi' \ + | sed \ + -e 's|@@GITWEB_CSS@@||; T; r gitweb/gitweb.css' \ + > $@+ + chmod +x $@+ + mv $@+ $@ + # These can record GIT_VERSION git$X git.spec \ $(patsubst %.sh,%,$(SCRIPT_SH)) \ diff --git a/git-instaweb.sh b/git-instaweb.sh new file mode 100755 index 000000000..51067d967 --- /dev/null +++ b/git-instaweb.sh @@ -0,0 +1,235 @@ +#!/bin/sh +# +# Copyright (c) 2006 Eric Wong +# +USAGE='[--start] [--stop] [--restart] + [--local] [--httpd=] [--port=] [--browser=] + [--module-path= (for Apache2 only)]' + +. git-sh-setup + +case "$GIT_DIR" in +/*) + fqgitdir="$GIT_DIR" ;; +*) + fqgitdir="$PWD/$GIT_DIR" ;; +esac + +local="`git repo-config --bool --get instaweb.local`" +httpd="`git repo-config --get instaweb.httpd`" +browser="`git repo-config --get instaweb.browser`" +port=`git repo-config --get instaweb.port` +module_path="`git repo-config --get instaweb.modulepath`" + +conf=$GIT_DIR/gitweb/httpd.conf + +# Defaults: + +# if installed, it doens't need further configuration (module_path) +test -z "$httpd" && httpd='lighttpd -f' + +# probably the most popular browser among gitweb users +test -z "$browser" && browser='firefox' + +# any untaken local port will do... +test -z "$port" && port=1234 + +start_httpd () { + httpd_only="`echo $httpd | cut -f1 -d' '`" + if test "`expr index $httpd_only /`" -eq '1' || \ + which $httpd_only >/dev/null + then + $httpd $fqgitdir/gitweb/httpd.conf + else + # many httpds are installed in /usr/sbin or /usr/local/sbin + # these days and those are not in most users $PATHs + for i in /usr/local/sbin /usr/sbin + do + if test -x "$i/$httpd_only" + then + # don't quote $httpd, there can be + # arguments to it (-f) + $i/$httpd "$fqgitdir/gitweb/httpd.conf" + return + fi + done + fi +} + +stop_httpd () { + test -f "$fqgitdir/pid" && kill `cat "$fqgitdir/pid"` +} + +while case "$#" in 0) break ;; esac +do + case "$1" in + --stop|stop) + stop_httpd + exit 0 + ;; + --start|start) + start_httpd + exit 0 + ;; + --restart|restart) + stop_httpd + start_httpd + exit 0 + ;; + --local|-l) + local=true + ;; + -d|--httpd|--httpd=*) + case "$#,$1" in + *,*=*) + httpd=`expr "$1" : '-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + httpd="$2" + shift ;; + esac + ;; + -b|--browser|--browser=*) + case "$#,$1" in + *,*=*) + browser=`expr "$1" : '-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + browser="$2" + shift ;; + esac + ;; + -p|--port|--port=*) + case "$#,$1" in + *,*=*) + port=`expr "$1" : '-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + port="$2" + shift ;; + esac + ;; + -m|--module-path=*|--module-path) + case "$#,$1" in + *,*=*) + module_path=`expr "$1" : '-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + module_path="$2" + shift ;; + esac + ;; + *) + usage + ;; + esac + shift +done + +mkdir -p "$GIT_DIR/gitweb/tmp" +GIT_EXEC_PATH="`git --exec-path`" +GIT_DIR="$fqgitdir" +export GIT_EXEC_PATH GIT_DIR + + +lighttpd_conf () { + cat > "$conf" < "" ) +mimetype.assign = ( ".css" => "text/css" ) +EOF + test "$local" = true && echo 'server.bind = "127.0.0.1"' >> "$conf" +} + +apache2_conf () { + test -z "$module_path" && module_path=/usr/lib/apache2/modules + mkdir -p "$GIT_DIR/gitweb/logs" + bind= + test "$local" = true && bind='127.0.0.1:' + echo 'text/css css' > $fqgitdir/mime.types + cat > "$conf" <) has been applied + if test -f "$module_path/mod_perl.so" && grep '^our $gitbin' \ + "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null + then + # favor mod_perl if available + cat >> "$conf" < + SetHandler perl-script + PerlResponseHandler ModPerl::Registry + PerlOptions +ParseHeaders + Options +ExecCGI + +EOF + else + # plain-old CGI + cat >> "$conf" < + Options +ExecCGI + +EOF + fi +} + +script=' +s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'`dirname $fqgitdir`'";#; +s#\(my\|our\) $gitbin =.*#\1 $gitbin = "'$GIT_EXEC_PATH'";#; +s#\(my\|our\) $projects_list =.*#\1 $projects_list = $projectroot;#; +s#\(my\|our\) $git_temp =.*#\1 $git_temp = "'$fqgitdir/gitweb/tmp'";#' + +gitweb_cgi () { + cat > "$1.tmp" <<\EOFGITWEB +@@GITWEB_CGI@@ +EOFGITWEB + sed "$script" "$1.tmp" > "$1" + chmod +x "$1" + rm -f "$1.tmp" +} + +gitweb_css () { + cat > "$1" <<\EOFGITWEB +@@GITWEB_CSS@@ +EOFGITWEB +} + +gitweb_cgi $GIT_DIR/gitweb/gitweb.cgi +gitweb_css $GIT_DIR/gitweb/gitweb.css + +case "$httpd" in +*lighttpd*) + lighttpd_conf + ;; +*apache2*) + apache2_conf + ;; +*) + echo "Unknown httpd specified: $httpd" + exit 1 + ;; +esac + +start_httpd +test -z "$browser" && browser=echo +$browser http://127.0.0.1:$port -- cgit v1.2.1 From b319b02e2a75bfe71829cfe1506b86ec7644987d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 1 Jul 2006 22:02:17 -0700 Subject: t4013: add "diff" UI program tests. Signed-off-by: Junio C Hamano --- t/t4013-diff-various.sh | 9 ++++++ t/t4013/diff.diff_--abbrev_initial..side | 32 +++++++++++++++++++ .../diff.diff_--patch-with-raw_-r_initial..side | 36 +++++++++++++++++++++ t/t4013/diff.diff_--patch-with-raw_initial..side | 36 +++++++++++++++++++++ .../diff.diff_--patch-with-stat_-r_initial..side | 37 ++++++++++++++++++++++ t/t4013/diff.diff_--patch-with-stat_initial..side | 37 ++++++++++++++++++++++ t/t4013/diff.diff_--stat_initial..side | 6 ++++ t/t4013/diff.diff_-r_--stat_initial..side | 6 ++++ t/t4013/diff.diff_-r_initial..side | 32 +++++++++++++++++++ t/t4013/diff.diff_initial..side | 32 +++++++++++++++++++ 10 files changed, 263 insertions(+) create mode 100644 t/t4013/diff.diff_--abbrev_initial..side create mode 100644 t/t4013/diff.diff_--patch-with-raw_-r_initial..side create mode 100644 t/t4013/diff.diff_--patch-with-raw_initial..side create mode 100644 t/t4013/diff.diff_--patch-with-stat_-r_initial..side create mode 100644 t/t4013/diff.diff_--patch-with-stat_initial..side create mode 100644 t/t4013/diff.diff_--stat_initial..side create mode 100644 t/t4013/diff.diff_-r_--stat_initial..side create mode 100644 t/t4013/diff.diff_-r_initial..side create mode 100644 t/t4013/diff.diff_initial..side diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index f4f3c3a56..1d2f7f9f7 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -227,6 +227,15 @@ format-patch --attach --stdout initial..side format-patch --attach --stdout initial..master^ format-patch --attach --stdout initial..master +diff --abbrev initial..side +diff -r initial..side +diff --stat initial..side +diff -r --stat initial..side +diff initial..side +diff --patch-with-stat initial..side +diff --patch-with-raw initial..side +diff --patch-with-stat -r initial..side +diff --patch-with-raw -r initial..side EOF test_done diff --git a/t/t4013/diff.diff_--abbrev_initial..side b/t/t4013/diff.diff_--abbrev_initial..side new file mode 100644 index 000000000..a88e66f81 --- /dev/null +++ b/t/t4013/diff.diff_--abbrev_initial..side @@ -0,0 +1,32 @@ +$ git diff --abbrev initial..side +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff_--patch-with-raw_-r_initial..side b/t/t4013/diff.diff_--patch-with-raw_-r_initial..side new file mode 100644 index 000000000..3590dc79a --- /dev/null +++ b/t/t4013/diff.diff_--patch-with-raw_-r_initial..side @@ -0,0 +1,36 @@ +$ git diff --patch-with-raw -r initial..side +:100644 100644 35d242b... 7289e35... M dir/sub +:100644 100644 01e79c3... f4615da... M file0 +:000000 100644 0000000... 7289e35... A file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff_--patch-with-raw_initial..side b/t/t4013/diff.diff_--patch-with-raw_initial..side new file mode 100644 index 000000000..b21d5dc6f --- /dev/null +++ b/t/t4013/diff.diff_--patch-with-raw_initial..side @@ -0,0 +1,36 @@ +$ git diff --patch-with-raw initial..side +:100644 100644 35d242b... 7289e35... M dir/sub +:100644 100644 01e79c3... f4615da... M file0 +:000000 100644 0000000... 7289e35... A file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff_--patch-with-stat_-r_initial..side b/t/t4013/diff.diff_--patch-with-stat_-r_initial..side new file mode 100644 index 000000000..9ed317a19 --- /dev/null +++ b/t/t4013/diff.diff_--patch-with-stat_-r_initial..side @@ -0,0 +1,37 @@ +$ git diff --patch-with-stat -r initial..side + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff_--patch-with-stat_initial..side b/t/t4013/diff.diff_--patch-with-stat_initial..side new file mode 100644 index 000000000..8b50629e6 --- /dev/null +++ b/t/t4013/diff.diff_--patch-with-stat_initial..side @@ -0,0 +1,37 @@ +$ git diff --patch-with-stat initial..side + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff_--stat_initial..side b/t/t4013/diff.diff_--stat_initial..side new file mode 100644 index 000000000..0517b5d63 --- /dev/null +++ b/t/t4013/diff.diff_--stat_initial..side @@ -0,0 +1,6 @@ +$ git diff --stat initial..side + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) +$ diff --git a/t/t4013/diff.diff_-r_--stat_initial..side b/t/t4013/diff.diff_-r_--stat_initial..side new file mode 100644 index 000000000..245220d3f --- /dev/null +++ b/t/t4013/diff.diff_-r_--stat_initial..side @@ -0,0 +1,6 @@ +$ git diff -r --stat initial..side + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) +$ diff --git a/t/t4013/diff.diff_-r_initial..side b/t/t4013/diff.diff_-r_initial..side new file mode 100644 index 000000000..5bb2fe2f2 --- /dev/null +++ b/t/t4013/diff.diff_-r_initial..side @@ -0,0 +1,32 @@ +$ git diff -r initial..side +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ diff --git a/t/t4013/diff.diff_initial..side b/t/t4013/diff.diff_initial..side new file mode 100644 index 000000000..c8adaf595 --- /dev/null +++ b/t/t4013/diff.diff_initial..side @@ -0,0 +1,32 @@ +$ git diff initial..side +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +$ -- cgit v1.2.1 From 047fbe906b375e8a3a7564ad0e4443f62dd528a2 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 1 Jul 2006 22:15:40 -0700 Subject: builtin-diff: turn recursive on when defaulting to --patch format. Signed-off-by: Junio C Hamano --- builtin-diff.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin-diff.c b/builtin-diff.c index 47e0a37e2..d520c7ca2 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -254,8 +254,10 @@ int cmd_diff(int argc, const char **argv, char **envp) init_revisions(&rev); argc = setup_revisions(argc, argv, &rev, NULL); - if (!rev.diffopt.output_format) + if (!rev.diffopt.output_format) { rev.diffopt.output_format = DIFF_FORMAT_PATCH; + diff_setup_done(&rev.diffopt); + } /* Do we have --cached and not have a pending object, then * default to HEAD by hand. Eek. -- cgit v1.2.1 From c0fa8255c652e148f0910425d2cc2b8029065008 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Sun, 2 Jul 2006 11:49:38 +0200 Subject: Fold get_merge_bases_clean() into get_merge_bases() Change get_merge_bases() to be able to clean up after itself if needed by adding a cleanup parameter. We don't need to save the flags and restore them afterwards anymore; that was a leftover from before the flags were moved out of the range used in revision.c. clear_commit_marks() sets them to zero, which is enough. Signed-off-by: Rene Scharfe Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- commit.c | 21 ++++++--------------- commit.h | 3 +-- merge-base.c | 2 +- revision.c | 2 +- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/commit.c b/commit.c index 70a4effe5..94c1d0ec5 100644 --- a/commit.c +++ b/commit.c @@ -1012,7 +1012,8 @@ static void mark_reachable_commits(struct commit_list *result, } } -struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2) +struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, + int cleanup) { struct commit_list *list = NULL; struct commit_list *result = NULL; @@ -1080,20 +1081,10 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2) tmp = next; } - return result; -} - -struct commit_list *get_merge_bases_clean(struct commit *rev1, - struct commit *rev2) -{ - unsigned int flags1 = rev1->object.flags; - unsigned int flags2 = rev2->object.flags; - struct commit_list *result = get_merge_bases(rev1, rev2); - - clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING); - clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING); - rev1->object.flags = flags1; - rev2->object.flags = flags2; + if (cleanup) { + clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING); + clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING); + } return result; } diff --git a/commit.h b/commit.h index 3a26e29ce..779ed82ed 100644 --- a/commit.h +++ b/commit.h @@ -105,7 +105,6 @@ struct commit_graft *read_graft_line(char *buf, int len); int register_commit_graft(struct commit_graft *, int); int read_graft_file(const char *graft_file); -extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2); -extern struct commit_list *get_merge_bases_clean(struct commit *rev1, struct commit *rev2); +extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup); #endif /* COMMIT_H */ diff --git a/merge-base.c b/merge-base.c index b41f76cb7..59f723f40 100644 --- a/merge-base.c +++ b/merge-base.c @@ -6,7 +6,7 @@ static int show_all = 0; static int merge_base(struct commit *rev1, struct commit *rev2) { - struct commit_list *result = get_merge_bases(rev1, rev2); + struct commit_list *result = get_merge_bases(rev1, rev2, 0); if (!result) return 1; diff --git a/revision.c b/revision.c index 9eb0b6da9..27fc1e307 100644 --- a/revision.c +++ b/revision.c @@ -813,7 +813,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch } if (symmetric) { - exclude = get_merge_bases_clean(a, b); + exclude = get_merge_bases(a, b, 1); add_pending_commit_list(revs, exclude, flags_exclude); a->object.flags |= flags; -- cgit v1.2.1 From 07002287f3e219a16a948a8a6eca0a41162a491f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 2 Jul 2006 11:31:30 +0200 Subject: Makefile: replace ugly and unportable sed invocation Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 83d892229..05a00083e 100644 --- a/Makefile +++ b/Makefile @@ -551,11 +551,11 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \ - $@.sh | sed \ - -e 's|@@GITWEB_CGI@@|#!$(PERL_PATH_SQ)|; T; r gitweb/gitweb.cgi' \ - | sed \ - -e 's|@@GITWEB_CSS@@||; T; r gitweb/gitweb.css' \ - > $@+ + -e '/@@GITWEB_CGI@@/rgitweb/gitweb.cgi' \ + -e '/@@GITWEB_CGI@@/d' \ + -e '/@@GITWEB_CSS@@/rgitweb/gitweb.css' \ + -e '/@@GITWEB_CSS@@/d' \ + $@.sh > $@+ chmod +x $@+ mv $@+ $@ -- cgit v1.2.1 From 6ee030d68adc1fb51c3abda458999fa7afc43db5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 2 Jul 2006 04:56:16 -0700 Subject: instaweb: fix unportable ';' usage in sed Hint taken from Johannes. I've tested this with sed --posix on my system with GNU sed and it works fine with and also without it. Further portability testing/review would be good. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-instaweb.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-instaweb.sh b/git-instaweb.sh index 51067d967..69aef3c20 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -194,9 +194,9 @@ EOF } script=' -s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'`dirname $fqgitdir`'";#; -s#\(my\|our\) $gitbin =.*#\1 $gitbin = "'$GIT_EXEC_PATH'";#; -s#\(my\|our\) $projects_list =.*#\1 $projects_list = $projectroot;#; +s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'`dirname $fqgitdir`'";# +s#\(my\|our\) $gitbin =.*#\1 $gitbin = "'$GIT_EXEC_PATH'";# +s#\(my\|our\) $projects_list =.*#\1 $projects_list = $projectroot;# s#\(my\|our\) $git_temp =.*#\1 $git_temp = "'$fqgitdir/gitweb/tmp'";#' gitweb_cgi () { -- cgit v1.2.1 From 542ccefe896a8960a6ce0b0ba4519537649ae29a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 2 Jul 2006 11:34:17 -0700 Subject: commit.c: do not redefine UNINTERESTING bit. Signed-off-by: Junio C Hamano --- commit.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/commit.c b/commit.c index 94c1d0ec5..a608faf23 100644 --- a/commit.c +++ b/commit.c @@ -851,14 +851,14 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, /* bits #0..7 in revision.h */ #define PARENT1 (1u<< 8) #define PARENT2 (1u<< 9) -#define UNINTERESTING (1u<<10) +#define STALE (1u<<10) static struct commit *interesting(struct commit_list *list) { while (list) { struct commit *commit = list->item; list = list->next; - if (commit->object.flags & UNINTERESTING) + if (commit->object.flags & STALE) continue; return commit; } @@ -920,17 +920,17 @@ static struct commit *interesting(struct commit_list *list) * * Next, we pop B and something very interesting happens. It has flags==3 * so it is also placed on the result list, and its parents are marked - * uninteresting, retroactively, and placed back on the list: + * stale, retroactively, and placed back on the list: * * list=C(7), result=C(7) B(3) * * Now, list does not have any interesting commit. So we find the newest - * commit from the result list that is not marked uninteresting. Which is + * commit from the result list that is not marked stale. Which is * commit B. * * * Another pathological example how this thing used to fail to mark an - * ancestor of a merge base as UNINTERESTING before we introduced the + * ancestor of a merge base as STALE before we introduced the * postprocessing phase (mark_reachable_commits). * * 2 @@ -960,8 +960,8 @@ static struct commit *interesting(struct commit_list *list) * C7 2 3 7 1 3 2 1 2 * * At this point, unfortunately, everybody in the list is - * uninteresting, so we fail to complete the following two - * steps to fully marking uninteresting commits. + * stale, so we fail to complete the following two + * steps to fully marking stale commits. * * D7 2 3 7 7 3 2 1 2 * E7 2 3 7 7 7 2 1 2 @@ -981,10 +981,10 @@ static void mark_reachable_commits(struct commit_list *result, */ for (tmp = result; tmp; tmp = tmp->next) { struct commit *c = tmp->item; - /* Reinject uninteresting ones to list, + /* Reinject stale ones to list, * so we can scan their parents. */ - if (c->object.flags & UNINTERESTING) + if (c->object.flags & STALE) commit_list_insert(c, &list); } while (list) { @@ -995,8 +995,8 @@ static void mark_reachable_commits(struct commit_list *result, list = list->next; free(tmp); - /* Anything taken out of the list is uninteresting, so - * mark all its parents uninteresting. We do not + /* Anything taken out of the list is stale, so + * mark all its parents stale. We do not * parse new ones (we already parsed all the relevant * ones). */ @@ -1004,8 +1004,8 @@ static void mark_reachable_commits(struct commit_list *result, while (parents) { struct commit *p = parents->item; parents = parents->next; - if (!(p->object.flags & UNINTERESTING)) { - p->object.flags |= UNINTERESTING; + if (!(p->object.flags & STALE)) { + p->object.flags |= STALE; commit_list_insert(p, &list); } } @@ -1034,7 +1034,7 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, struct commit *commit = list->item; struct commit_list *parents; int flags = commit->object.flags - & (PARENT1 | PARENT2 | UNINTERESTING); + & (PARENT1 | PARENT2 | STALE); tmp = list; list = list->next; @@ -1042,8 +1042,8 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, if (flags == (PARENT1 | PARENT2)) { insert_by_date(commit, &result); - /* Mark parents of a found merge uninteresting */ - flags |= UNINTERESTING; + /* Mark parents of a found merge stale */ + flags |= STALE; } parents = commit->parents; while (parents) { @@ -1067,7 +1067,7 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, for (tmp = result, list = NULL; tmp; ) { struct commit *commit = tmp->item; struct commit_list *next = tmp->next; - if (commit->object.flags & UNINTERESTING) { + if (commit->object.flags & STALE) { if (list != NULL) list->next = next; free(tmp); @@ -1075,15 +1075,15 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, if (list == NULL) result = tmp; list = tmp; - commit->object.flags |= UNINTERESTING; + commit->object.flags |= STALE; } tmp = next; } if (cleanup) { - clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING); - clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING); + clear_commit_marks(rev1, PARENT1 | PARENT2 | STALE); + clear_commit_marks(rev2, PARENT1 | PARENT2 | STALE); } return result; -- cgit v1.2.1 From 556677144b55aad8457851a9019e86c3676bd422 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Mon, 3 Jul 2006 01:56:48 +0200 Subject: autoconf: Use autoconf to write installation directories to config.mak.autogen This is beginning of patch series introducing installation configuration using autoconf (and no other autotools) to git. The idea is to generate config.mak.autogen using ./configure (generated from configure.ac by running autoconf) from config.mak.in, so one can use autoconf as an _alternative_ to ordinary Makefile, and creating one's own config.mak. Local settings in config.mak override generated settings in config.mak.autogen This patch includes minimal configure.ac and config.mak.in, so one can set installation directories using autoconf generated ./configure script e.g. ./configure --prefix=/usr Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- .gitignore | 6 ++++++ INSTALL | 9 +++++++++ Makefile | 1 + config.mak.in | 18 ++++++++++++++++++ configure.ac | 14 ++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 config.mak.in create mode 100644 configure.ac diff --git a/.gitignore b/.gitignore index 7b954d587..e10377702 100644 --- a/.gitignore +++ b/.gitignore @@ -135,4 +135,10 @@ git-core.spec *.[ao] *.py[co] config.mak +autom4te.cache +config.log +config.status +config.mak.in +config.mak.autogen +configure git-blame diff --git a/INSTALL b/INSTALL index f8337e2a4..28245b3e6 100644 --- a/INSTALL +++ b/INSTALL @@ -13,6 +13,15 @@ that uses $prefix, the built results have some paths encoded, which are derived from $prefix, so "make all; make prefix=/usr install" would not work. +Alternatively you can use autoconf generated ./configure script to +set up install paths (via config.mak.autogen), so you can write instead + + $ autoconf ;# as yourself if ./configure doesn't exist yet + $ ./configure --prefix=/usr ;# as yourself + $ make all doc ;# as yourself + # make install install-doc ;# as root + + Issues of note: - git normally installs a helper script wrapper called "git", which diff --git a/Makefile b/Makefile index ccd7c62e5..a37d40059 100644 --- a/Makefile +++ b/Makefile @@ -333,6 +333,7 @@ ifneq (,$(findstring arm,$(uname_M))) ARM_SHA1 = YesPlease endif +-include config.mak.autogen -include config.mak ifdef WITH_OWN_SUBPROCESS_PY diff --git a/config.mak.in b/config.mak.in new file mode 100644 index 000000000..82c9781f0 --- /dev/null +++ b/config.mak.in @@ -0,0 +1,18 @@ +# git Makefile configuration, included in main Makefile +# @configure_input@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +#gitexecdir = @libexecdir@/git-core/ +template_dir = @datadir@/git-core/templates/ +GIT_PYTHON_DIR = @datadir@/git-core/python + +mandir=@mandir@ + +srcdir = @srcdir@ +VPATH = @srcdir@ + +export exec_prefix mandir +export srcdir VPATH + diff --git a/configure.ac b/configure.ac new file mode 100644 index 000000000..a0374d4d5 --- /dev/null +++ b/configure.ac @@ -0,0 +1,14 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.59) +AC_INIT([git], [1.4.1], [git@vger.kernel.org]) + +AC_CONFIG_SRCDIR([git.c]) + +config_file=config.mak.autogen +config_in=config.mak.in + +# Output files +AC_CONFIG_FILES(["${config_file}":"${config_in}"]) +AC_OUTPUT -- cgit v1.2.1 From 8fced61cbc32f0c4b81a3dcecfeb40b7d96339ce Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 3 Jul 2006 00:53:13 -0700 Subject: Makefile: tighten git-http-{fetch,push} dependencies Although our "git-%$X:" implicit target had dependency on $(GITLIBS) which included xdiff/lib.a, git-http-{fetch,push} had their own building rules and with an obsolete dependency on $(LIB_FILES). Update the rules to depend on $(GITLIBS), to make parallel build work correctly. Signed-off-by: Junio C Hamano --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cde619c49..76abcc473 100644 --- a/Makefile +++ b/Makefile @@ -587,11 +587,11 @@ git-ssh-push$X: rsh.o git-imap-send$X: imap-send.o $(LIB_FILE) http.o http-fetch.o http-push.o: http.h -git-http-fetch$X: fetch.o http.o http-fetch.o $(LIB_FILE) +git-http-fetch$X: fetch.o http.o http-fetch.o $(GITLIBS) $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) -git-http-push$X: revision.o http.o http-push.o $(LIB_FILE) +git-http-push$X: revision.o http.o http-push.o $(GITLIBS) $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) -- cgit v1.2.1 From 2ef108013ec15e8d5feee6d5c42692ae956ee302 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 3 Jul 2006 03:02:27 -0700 Subject: get_merge_bases: clean up even when there is no common commit. Actually in this case we would have traversed a lot of commits, so cleaning things up is even more important. Signed-off-by: Junio C Hamano --- commit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commit.c b/commit.c index a608faf23..12882fd49 100644 --- a/commit.c +++ b/commit.c @@ -1058,7 +1058,7 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, } if (!result) - return NULL; + goto finish; if (result->next && list) mark_reachable_commits(result, list); @@ -1081,6 +1081,7 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, tmp = next; } + finish: if (cleanup) { clear_commit_marks(rev1, PARENT1 | PARENT2 | STALE); clear_commit_marks(rev2, PARENT1 | PARENT2 | STALE); -- cgit v1.2.1 From 160b7983034cdd24ea1bf6ef7a2532a2296461c6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 3 Jul 2006 03:05:20 -0700 Subject: revert clear-commit-marks for now. Earlier change broke "git describe A B" among other things. Revert it for now, and clean the commits smudged by get_merge_bases using clear_object_marks() function. For complex commit ancestry graph, this is way cheaper as well. Signed-off-by: Junio C Hamano --- commit.c | 13 ++++++------- object.c | 9 +++++++++ object.h | 2 ++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/commit.c b/commit.c index 12882fd49..04390643e 100644 --- a/commit.c +++ b/commit.c @@ -397,12 +397,13 @@ void clear_commit_marks(struct commit *commit, unsigned int mark) { struct commit_list *parents; - if (!commit) - return; parents = commit->parents; commit->object.flags &= ~mark; while (parents) { - clear_commit_marks(parents->item, mark); + struct commit *parent = parents->item; + if (parent && parent->object.parsed && + (parent->object.flags & mark)) + clear_commit_marks(parent, mark); parents = parents->next; } } @@ -1082,10 +1083,8 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, } finish: - if (cleanup) { - clear_commit_marks(rev1, PARENT1 | PARENT2 | STALE); - clear_commit_marks(rev2, PARENT1 | PARENT2 | STALE); - } + if (cleanup) + clear_object_marks(PARENT1 | PARENT2 | STALE); return result; } diff --git a/object.c b/object.c index 37784cee9..9caba4fac 100644 --- a/object.c +++ b/object.c @@ -217,3 +217,12 @@ void add_object_array(struct object *obj, const char *name, struct object_array objects[nr].name = name; array->nr = ++nr; } + +void clear_object_marks(unsigned mark) +{ + int i; + + for (i = 0; i < obj_allocs; i++) + if (objs[i]) + objs[i]->flags &= ~mark; +} diff --git a/object.h b/object.h index 6f23a9a18..7ac10111c 100644 --- a/object.h +++ b/object.h @@ -83,4 +83,6 @@ int object_list_contains(struct object_list *list, struct object *obj); /* Object array handling .. */ void add_object_array(struct object *obj, const char *name, struct object_array *array); +void clear_object_marks(unsigned); + #endif /* OBJECT_H */ -- cgit v1.2.1 From 12f6c308d53509dcb11e309604457d21d60438db Mon Sep 17 00:00:00 2001 From: Joachim B Haga Date: Mon, 3 Jul 2006 22:11:47 +0200 Subject: Make zlib compression level configurable, and change default. With the change in default, "git add ." on kernel dir is about twice as fast as before, with only minimal (0.5%) change in object size. The speed difference is even more noticeable when committing large files, which is now up to 8 times faster. The configurability is through setting core.compression = [-1..9] which maps to the zlib constants; -1 is the default, 0 is no compression, and 1..9 are various speed/size tradeoffs, 9 being slowest. Signed-off-by: Joachim B Haga (cjhaga@fys.uio.no) Acked-by: Linus Torvalds Signed-off-by: Junio C Hamano --- Documentation/config.txt | 6 ++++++ cache.h | 1 + config.c | 10 ++++++++++ csum-file.c | 2 +- diff.c | 2 +- environment.c | 1 + http-push.c | 2 +- sha1_file.c | 4 ++-- 8 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index a04c5adf8..16bdd5523 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -91,6 +91,12 @@ core.warnAmbiguousRefs:: If true, git will warn you if the ref name you passed it is ambiguous and might match multiple refs in the .git/refs/ tree. True by default. +core.compression: + An integer -1..9, indicating the compression level for objects that + are not in a pack file. -1 is the zlib and git default. 0 means no + compression, and 1..9 are various speed/size tradeoffs, 9 being + slowest. + alias.*:: Command aliases for the gitlink:git[1] command wrapper - e.g. after defining "alias.last = cat-file commit HEAD", the invocation diff --git a/cache.h b/cache.h index 87199396a..84770bf67 100644 --- a/cache.h +++ b/cache.h @@ -183,6 +183,7 @@ extern int log_all_ref_updates; extern int warn_ambiguous_refs; extern int shared_repository; extern const char *apply_default_whitespace; +extern int zlib_compression_level; #define GIT_REPO_VERSION 0 extern int repository_format_version; diff --git a/config.c b/config.c index ec44827da..b23f4bf48 100644 --- a/config.c +++ b/config.c @@ -279,6 +279,16 @@ int git_default_config(const char *var, const char *value) return 0; } + if (!strcmp(var, "core.compression")) { + int level = git_config_int(var, value); + if (level == -1) + level = Z_DEFAULT_COMPRESSION; + else if (level < 0 || level > Z_BEST_COMPRESSION) + die("bad zlib compression level %d", level); + zlib_compression_level = level; + return 0; + } + if (!strcmp(var, "user.name")) { strlcpy(git_default_name, value, sizeof(git_default_name)); return 0; diff --git a/csum-file.c b/csum-file.c index ebaad0397..6a7b40fd0 100644 --- a/csum-file.c +++ b/csum-file.c @@ -122,7 +122,7 @@ int sha1write_compressed(struct sha1file *f, void *in, unsigned int size) void *out; memset(&stream, 0, sizeof(stream)); - deflateInit(&stream, Z_DEFAULT_COMPRESSION); + deflateInit(&stream, zlib_compression_level); maxsize = deflateBound(&stream, size); out = xmalloc(maxsize); diff --git a/diff.c b/diff.c index 5a71489a4..428ff786e 100644 --- a/diff.c +++ b/diff.c @@ -583,7 +583,7 @@ static unsigned char *deflate_it(char *data, z_stream stream; memset(&stream, 0, sizeof(stream)); - deflateInit(&stream, Z_BEST_COMPRESSION); + deflateInit(&stream, zlib_compression_level); bound = deflateBound(&stream, size); deflated = xmalloc(bound); stream.next_out = deflated; diff --git a/environment.c b/environment.c index 3de8eb3b2..43823ff7d 100644 --- a/environment.c +++ b/environment.c @@ -20,6 +20,7 @@ int repository_format_version = 0; char git_commit_encoding[MAX_ENCODING_LENGTH] = "utf-8"; int shared_repository = PERM_UMASK; const char *apply_default_whitespace = NULL; +int zlib_compression_level = Z_DEFAULT_COMPRESSION; static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file; diff --git a/http-push.c b/http-push.c index e281f70e5..f761584d7 100644 --- a/http-push.c +++ b/http-push.c @@ -492,7 +492,7 @@ static void start_put(struct transfer_request *request) /* Set it up */ memset(&stream, 0, sizeof(stream)); - deflateInit(&stream, Z_BEST_COMPRESSION); + deflateInit(&stream, zlib_compression_level); size = deflateBound(&stream, len + hdrlen); request->buffer.buffer = xmalloc(size); diff --git a/sha1_file.c b/sha1_file.c index 817963045..bc3580844 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1458,7 +1458,7 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha /* Set it up */ memset(&stream, 0, sizeof(stream)); - deflateInit(&stream, Z_BEST_COMPRESSION); + deflateInit(&stream, zlib_compression_level); size = deflateBound(&stream, len+hdrlen); compressed = xmalloc(size); @@ -1511,7 +1511,7 @@ static void *repack_object(const unsigned char *sha1, unsigned long *objsize) /* Set it up */ memset(&stream, 0, sizeof(stream)); - deflateInit(&stream, Z_BEST_COMPRESSION); + deflateInit(&stream, zlib_compression_level); size = deflateBound(&stream, len + hdrlen); buf = xmalloc(size); -- cgit v1.2.1 From f560069bc59e155c3078ba5482ce69ded68849df Mon Sep 17 00:00:00 2001 From: Ryan Anderson Date: Mon, 3 Jul 2006 21:30:01 -0400 Subject: annotate: Support annotation of files on other revisions. This is a bug fix, and cleans up one or two other things spotted during the course of tracking down the main bug here. Also, the test-suite is updated to reflect this case. Signed-off-by: Ryan Anderson (cherry picked from 2f7554b4db3ab2c2d3866b160245c91c9236fc9a commit) Signed-off-by: Junio C Hamano --- t/t8001-annotate.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh index 2496397da..70e2ad23a 100755 --- a/t/t8001-annotate.sh +++ b/t/t8001-annotate.sh @@ -6,4 +6,10 @@ test_description='git-annotate' PROG='git annotate' . ../annotate-tests.sh +test_expect_success \ + 'Annotating an old revision works' \ + '[ $(git annotate file master | awk "{print \$3}" | grep -c "^A$") == 2 ] && \ + [ $(git annotate file master | awk "{print \$3}" | grep -c "^B$") == 2 ]' + + test_done -- cgit v1.2.1 From 3f492ba1fc4e63073378cc097154bed1ed2563c8 Mon Sep 17 00:00:00 2001 From: Ryan Anderson Date: Mon, 3 Jul 2006 21:30:02 -0400 Subject: annotate: Correct most merge following to annotate correctly. There is still a bug involving octopus merges, somewhere, but this gets normal merges correct, so it's still an improvement over the existing version. Signed-off-by: Ryan Anderson Signed-off-by: Junio C Hamano --- git-annotate.perl | 197 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 139 insertions(+), 58 deletions(-) diff --git a/git-annotate.perl b/git-annotate.perl index a6a7a482c..6db2f4824 100755 --- a/git-annotate.perl +++ b/git-annotate.perl @@ -102,10 +102,10 @@ while (my $bound = pop @stack) { push @revqueue, $head; init_claim( defined $starting_rev ? $head : 'dirty'); unless (defined $starting_rev) { - my $diff = open_pipe("git","diff","-R", "HEAD", "--",$filename) + my $diff = open_pipe("git","diff","HEAD", "--",$filename) or die "Failed to call git diff to check for dirty state: $!"; - _git_diff_parse($diff, $head, "dirty", ( + _git_diff_parse($diff, [$head], "dirty", ( 'author' => gitvar_name("GIT_AUTHOR_IDENT"), 'author_date' => sprintf("%s +0000",time()), ) @@ -154,14 +154,13 @@ sub handle_rev { my %revinfo = git_commit_info($rev); - foreach my $p (@{$revs{$rev}{'parents'}}) { - - git_diff_parse($p, $rev, %revinfo); - push @revqueue, $p; - } + if (exists $revs{$rev}{parents} && + scalar @{$revs{$rev}{parents}} != 0) { + git_diff_parse($revs{$rev}{'parents'}, $rev, %revinfo); + push @revqueue, @{$revs{$rev}{'parents'}}; - if (scalar @{$revs{$rev}{parents}} == 0) { + } else { # We must be at the initial rev here, so claim everything that is left. for (my $i = 0; $i < @{$revs{$rev}{lines}}; $i++) { if (ref ${$revs{$rev}{lines}}[$i] eq '' || ${$revs{$rev}{lines}}[$i][1] eq '') { @@ -252,89 +251,171 @@ sub git_find_parent { # Get a diff between the current revision and a parent. # Record the commit information that results. sub git_diff_parse { - my ($parent, $rev, %revinfo) = @_; + my ($parents, $rev, %revinfo) = @_; - my $diff = open_pipe("git-diff-tree","-M","-p",$rev,$parent,"--", - $revs{$rev}{'filename'}, $revs{$parent}{'filename'}) + my @filenames = ( $revs{$rev}{'filename'} ); + foreach my $parent (@$parents) { + push @filenames, $revs{$parent}{'filename'}; + } + + my $diff = open_pipe("git-diff-tree","-M","-p","-c",$rev,"--", + @filenames ) or die "Failed to call git-diff for annotation: $!"; - _git_diff_parse($diff, $parent, $rev, %revinfo); + _git_diff_parse($diff, $parents, $rev, %revinfo); close($diff); } sub _git_diff_parse { - my ($diff, $parent, $rev, %revinfo) = @_; + my ($diff, $parents, $rev, %revinfo) = @_; + + my $ri = 0; - my ($ri, $pi) = (0,0); my $slines = $revs{$rev}{'lines'}; - my @plines; + my (%plines, %pi); my $gotheader = 0; my ($remstart); - my ($hunk_start, $hunk_index); + my $parent_count = @$parents; + + my $diff_header_regexp = "^@"; + $diff_header_regexp .= "@" x @$parents; + $diff_header_regexp .= ' -\d+,\d+' x @$parents; + $diff_header_regexp .= ' \+(\d+),\d+'; + + my %claim_regexps; + my $allparentplus = '^' . '\\+' x @$parents . '(.*)$'; + + { + my $i = 0; + foreach my $parent (@$parents) { + + $pi{$parent} = 0; + my $r = '^' . '.' x @$parents . '(.*)$'; + my $p = $r; + substr($p,$i+1, 1) = '\\+'; + + my $m = $r; + substr($m,$i+1, 1) = '-'; + + $claim_regexps{$parent}{plus} = $p; + $claim_regexps{$parent}{minus} = $m; + + $plines{$parent} = []; + + $i++; + } + } + + DIFF: while(<$diff>) { chomp; - if (m/^@@ -(\d+),(\d+) \+(\d+),(\d+)/) { - $remstart = $1; - # Adjust for 0-based arrays - $remstart--; - # Reinit hunk tracking. - $hunk_start = $remstart; - $hunk_index = 0; + if (m/$diff_header_regexp/) { + $remstart = $1 - 1; + # (0-based arrays) + $gotheader = 1; - for (my $i = $ri; $i < $remstart; $i++) { - $plines[$pi++] = $slines->[$i]; - $ri++; + printf("Copying from %d to %d\n", $ri, $remstart); + foreach my $parent (@$parents) { + for (my $i = $ri; $i < $remstart; $i++) { + $plines{$parent}[$pi{$parent}++] = $slines->[$i]; + } } - next; - } elsif (!$gotheader) { - next; - } + $ri = $remstart; - if (m/^\+(.*)$/) { - my $line = $1; - $plines[$pi++] = [ $line, '', '', '', 0 ]; - next; + next DIFF; - } elsif (m/^-(.*)$/) { - my $line = $1; - if (get_line($slines, $ri) eq $line) { - # Found a match, claim - claim_line($ri, $rev, $slines, %revinfo); - } else { - die sprintf("Sync error: %d/%d\n|%s\n|%s\n%s => %s\n", - $ri, $hunk_start + $hunk_index, - $line, - get_line($slines, $ri), - $rev, $parent); - } - $ri++; + } elsif (!$gotheader) { + # Skip over the leadin. + next DIFF; + } - } elsif (m/^\\/) { + if (m/^\\/) { ; # Skip \No newline at end of file. # But this can be internationalized, so only look # for an initial \ } else { - if (substr($_,1) ne get_line($slines,$ri) ) { - die sprintf("Line %d (%d) does not match:\n|%s\n|%s\n%s => %s\n", - $hunk_start + $hunk_index, $ri, - substr($_,1), - get_line($slines,$ri), - $rev, $parent); + my %claims = (); + my $negclaim = 0; + my $allclaimed = 0; + my $line; + + if (m/$allparentplus/) { + claim_line($ri, $rev, $slines, %revinfo); + $allclaimed = 1; + + } + + PARENT: + foreach my $parent (keys %claim_regexps) { + my $m = $claim_regexps{$parent}{minus}; + my $p = $claim_regexps{$parent}{plus}; + + if (m/$m/) { + $line = $1; + $plines{$parent}[$pi{$parent}++] = [ $line, '', '', '', 0 ]; + $negclaim++; + + } elsif (m/$p/) { + $line = $1; + if (get_line($slines, $ri) eq $line) { + # Found a match, claim + $claims{$parent}++; + + } else { + die sprintf("Sync error: %d\n|%s\n|%s\n%s => %s\n", + $ri, $line, + get_line($slines, $ri), + $rev, $parent); + } + } + } + + if (%claims) { + foreach my $parent (@$parents) { + next if $claims{$parent} || $allclaimed; + $plines{$parent}[$pi{$parent}++] = $slines->[$ri]; + #[ $line, '', '', '', 0 ]; + } + $ri++; + + } elsif ($negclaim) { + next DIFF; + + } else { + if (substr($_,scalar @$parents) ne get_line($slines,$ri) ) { + foreach my $parent (@$parents) { + printf("parent %s is on line %d\n", $parent, $pi{$parent}); + } + + die sprintf("Line %d, does not match:\n|%s|\n|%s|\n%s\n", + $ri, + substr($_,scalar @$parents), + get_line($slines,$ri), $rev); + } + foreach my $parent (@$parents) { + $plines{$parent}[$pi{$parent}++] = $slines->[$ri]; + } + $ri++; } - $plines[$pi++] = $slines->[$ri++]; } - $hunk_index++; } + for (my $i = $ri; $i < @{$slines} ; $i++) { - push @plines, $slines->[$ri++]; + foreach my $parent (@$parents) { + push @{$plines{$parent}}, $slines->[$ri]; + } + $ri++; + } + + foreach my $parent (@$parents) { + $revs{$parent}{lines} = $plines{$parent}; } - $revs{$parent}{lines} = \@plines; return; } -- cgit v1.2.1 From 624314fda7e7bd1107db7de4e877ee6285d7d6eb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 3 Jul 2006 18:48:23 -0700 Subject: boolean: accept yes and no as well Signed-off-by: Junio C Hamano --- config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.c b/config.c index b23f4bf48..8445f7dca 100644 --- a/config.c +++ b/config.c @@ -244,9 +244,9 @@ int git_config_bool(const char *name, const char *value) return 1; if (!*value) return 0; - if (!strcasecmp(value, "true")) + if (!strcasecmp(value, "true") || !strcasecmp(value, "yes")) return 1; - if (!strcasecmp(value, "false")) + if (!strcasecmp(value, "false") || !strcasecmp(value, "no")) return 0; return git_config_int(name, value) != 0; } -- cgit v1.2.1 From 280242d1cc1fe2847f649d2f16b273e168fcbc48 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 2 Jul 2006 16:03:59 -0700 Subject: send-email: do not barf when Term::ReadLine does not like your terminal As long as we do not need to readline from the terminal, we should not barf when starting up the program. Without this patch, t9001 test on Cygwin occasionally died with the following error message: Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS and LINES environment variables didn't work. The resize program didn't work. at /usr/lib/perl5/vendor_perl/5.8/cygwin/Term/ReadKey.pm line 362. Compilation failed in require at /usr/lib/perl5/vendor_perl/5.8/Term/ReadLine/Perl.pm line 58. Acked-by: Ryan Anderson Signed-off-by: Junio C Hamano --- git-send-email.perl | 18 +++++++++++++++++- t/t9001-send-email.sh | 11 +++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/git-send-email.perl b/git-send-email.perl index c5d9e7335..b04b8f40e 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -22,6 +22,17 @@ use Term::ReadLine; use Getopt::Long; use Data::Dumper; +package FakeTerm; +sub new { + my ($class, $reason) = @_; + return bless \$reason, shift; +} +sub readline { + my $self = shift; + die "Cannot use readline on FakeTerm: $$self"; +} +package main; + # most mail servers generate the Date: header, but not all... $ENV{LC_ALL} = 'C'; use POSIX qw/strftime/; @@ -46,7 +57,12 @@ my $smtp_server; # Example reply to: #$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>'; -my $term = new Term::ReadLine 'git-send-email'; +my $term = eval { + new Term::ReadLine 'git-send-email'; +}; +if ($@) { + $term = new FakeTerm "$@: going non-interactive"; +} # Begin by accumulating all the variables (defined above), that we will end up # needing, first, from the command line: diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index a61da1efb..e9ea33c18 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -25,10 +25,13 @@ test_expect_success \ git add fake.sendmail GIT_AUTHOR_NAME="A" git commit -a -m "Second."' -test_expect_success \ - 'Extract patches and send' \ - 'git format-patch -n HEAD^1 - git send-email -from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" ./0001*txt' +test_expect_success 'Extract patches' ' + patches=`git format-patch -n HEAD^1` +' + +test_expect_success 'Send patches' ' + git send-email -from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors +' cat >expected <<\EOF !nobody@example.com! -- cgit v1.2.1 From 30a95f30730a5ee738ad6ef17e76e61ad7c1f53e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 3 Jul 2006 18:09:54 -0700 Subject: t6200: fmt-merge-msg test. Signed-off-by: Junio C Hamano --- t/t6200-fmt-merge-msg.sh | 163 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100755 t/t6200-fmt-merge-msg.sh diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh new file mode 100755 index 000000000..63e49f310 --- /dev/null +++ b/t/t6200-fmt-merge-msg.sh @@ -0,0 +1,163 @@ +#!/bin/sh +# +# Copyright (c) 2006, Junio C Hamano +# + +test_description='fmt-merge-msg test' + +. ./test-lib.sh + +datestamp=1151939923 +setdate () { + GIT_COMMITTER_DATE="$datestamp +0200" + GIT_AUTHOR_DATE="$datestamp +0200" + datestamp=`expr "$datestamp" + 1` + export GIT_COMMITTER_DATE GIT_AUTHOR_DATE +} + +test_expect_success setup ' + echo one >one && + git add one && + setdate && + git commit -m "Initial" && + + echo uno >one && + echo dos >two && + git add two && + setdate && + git commit -a -m "Second" && + + git checkout -b left && + + echo $datestamp >one && + setdate && + git commit -a -m "Common #1" && + + echo $datestamp >one && + setdate && + git commit -a -m "Common #2" && + + git branch right && + + echo $datestamp >two && + setdate && + git commit -a -m "Left #3" && + + echo $datestamp >two && + setdate && + git commit -a -m "Left #4" && + + echo $datestamp >two && + setdate && + git commit -a -m "Left #5" && + + git checkout right && + + echo $datestamp >three && + git add three && + setdate && + git commit -a -m "Right #3" && + + echo $datestamp >three && + setdate && + git commit -a -m "Right #4" && + + echo $datestamp >three && + setdate && + git commit -a -m "Right #5" && + + git show-branch +' + +cat >expected <<\EOF +Merge branch 'left' +EOF + +test_expect_success 'merge-msg test #1' ' + + git checkout master && + git fetch . left && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + diff -u actual expected +' + +cat >expected <<\EOF +Merge branch 'left' of ../trash +EOF + +test_expect_success 'merge-msg test #2' ' + + git checkout master && + git fetch ../trash left && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + diff -u actual expected +' + +cat >expected <<\EOF +Merge branch 'left' + +* left: + Left #5 + Left #4 + Left #3 + Common #2 + Common #1 +EOF + +test_expect_success 'merge-msg test #3' ' + + git repo-config merge.summary true && + + git checkout master && + setdate && + git fetch . left && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + diff -u actual expected +' + +cat >expected <<\EOF +Merge branches 'left' and 'right' + +* left: + Left #5 + Left #4 + Left #3 + Common #2 + Common #1 + +* right: + Right #5 + Right #4 + Right #3 + Common #2 + Common #1 +EOF + +test_expect_success 'merge-msg test #4' ' + + git repo-config merge.summary true && + + git checkout master && + setdate && + git fetch . left right && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + diff -u actual expected +' + +test_expect_success 'merge-msg test #5' ' + + git repo-config merge.summary yes && + + git checkout master && + setdate && + git fetch . left right && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + diff -u actual expected +' + +test_done -- cgit v1.2.1 From 00449f992b629f7f7884fb2cf46ff411a2a4f381 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 3 Jul 2006 17:18:43 +0200 Subject: Make git-fmt-merge-msg a builtin Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Makefile | 7 +- builtin-fmt-merge-msg.c | 355 ++++++++++++++++++++++++++++++++++++++++++++++++ builtin.h | 1 + git-fmt-merge-msg.perl | 173 ----------------------- git.c | 3 +- 5 files changed, 362 insertions(+), 177 deletions(-) create mode 100644 builtin-fmt-merge-msg.c delete mode 100755 git-fmt-merge-msg.perl diff --git a/Makefile b/Makefile index 76abcc473..a78d05dda 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ SCRIPT_SH = \ SCRIPT_PERL = \ git-archimport.perl git-cvsimport.perl git-relink.perl \ - git-shortlog.perl git-fmt-merge-msg.perl git-rerere.perl \ + git-shortlog.perl git-rerere.perl \ git-annotate.perl git-cvsserver.perl \ git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \ git-send-email.perl @@ -173,7 +173,8 @@ BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \ git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \ git-read-tree$X git-commit-tree$X git-write-tree$X \ git-apply$X git-show-branch$X git-diff-files$X git-update-index$X \ - git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X + git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X \ + git-fmt-merge-msg$X # what 'all' will build and 'install' will install, in gitexecdir ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS) @@ -229,7 +230,7 @@ BUILTIN_OBJS = \ builtin-apply.o builtin-show-branch.o builtin-diff-files.o \ builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o \ builtin-cat-file.o builtin-mailsplit.o builtin-stripspace.o \ - builtin-update-ref.o + builtin-update-ref.o builtin-fmt-merge-msg.o GITLIBS = $(LIB_FILE) $(XDIFF_LIB) LIBS = $(GITLIBS) -lz diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c new file mode 100644 index 000000000..65274824d --- /dev/null +++ b/builtin-fmt-merge-msg.c @@ -0,0 +1,355 @@ +#include "cache.h" +#include "commit.h" +#include "diff.h" +#include "revision.h" +#include "tag.h" + +static const char *fmt_merge_msg_usage = + "git-fmt-merge-msg [--summary] [--no-summary] [--file ]"; + +static int merge_summary = 0; + +static int fmt_merge_msg_config(const char *key, const char *value) +{ + if (!strcmp("merge.summary", key)) + merge_summary = git_config_bool(key, value); + return 0; +} + +struct list { + char **list; + void **payload; + unsigned nr, alloc; +}; + +static void append_to_list(struct list *list, char *value, void *payload) +{ + if (list->nr == list->alloc) { + list->alloc += 32; + list->list = realloc(list->list, sizeof(char *) * list->alloc); + list->payload = realloc(list->payload, + sizeof(char *) * list->alloc); + } + list->payload[list->nr] = payload; + list->list[list->nr++] = value; +} + +static int find_in_list(struct list *list, char *value) +{ + int i; + + for (i = 0; i < list->nr; i++) + if (!strcmp(list->list[i], value)) + return i; + + return -1; +} + +static void free_list(struct list *list) +{ + int i; + + if (list->alloc == 0) + return; + + for (i = 0; i < list->nr; i++) { + free(list->list[i]); + if (list->payload[i]) + free(list->payload[i]); + } + free(list->list); + free(list->payload); + list->nr = list->alloc = 0; +} + +struct src_data { + struct list branch, tag, r_branch, generic; + int head_status; +}; + +static struct list srcs = { NULL, NULL, 0, 0}; +static struct list origins = { NULL, NULL, 0, 0}; + +static int handle_line(char *line) +{ + int i, len = strlen(line); + unsigned char *sha1; + char *src, *origin; + struct src_data *src_data; + + if (len < 43 || line[40] != '\t') + return 1; + + if (!strncmp(line + 41, "not-for-merge", 13)) + return 0; + + if (line[41] != '\t') + return 2; + + line[40] = 0; + sha1 = xmalloc(20); + i = get_sha1(line, sha1); + line[40] = '\t'; + if (i) + return 3; + + if (line[len - 1] == '\n') + line[len - 1] = 0; + line += 42; + + src = strstr(line, " of "); + if (src) { + *src = 0; + src += 4; + } else + src = "HEAD"; + + i = find_in_list(&srcs, src); + if (i < 0) { + i = srcs.nr; + append_to_list(&srcs, strdup(src), + xcalloc(1, sizeof(struct src_data))); + } + src_data = srcs.payload[i]; + + if (!strncmp(line, "branch ", 7)) { + origin = strdup(line + 7); + append_to_list(&src_data->branch, origin, NULL); + src_data->head_status |= 2; + } else if (!strncmp(line, "tag ", 4)) { + origin = line; + append_to_list(&src_data->tag, strdup(origin + 4), NULL); + src_data->head_status |= 2; + } else if (!strncmp(line, "remote branch ", 14)) { + origin = strdup(line + 14); + append_to_list(&src_data->r_branch, origin, NULL); + src_data->head_status |= 2; + } else if (!strcmp(line, "HEAD")) { + origin = strdup(src); + src_data->head_status |= 1; + } else { + origin = strdup(src); + append_to_list(&src_data->generic, strdup(line), NULL); + src_data->head_status |= 2; + } + + if (!strcmp(".", src) || !strcmp(src, origin)) { + int len = strlen(origin); + if (origin[0] == '\'' && origin[len - 1] == '\'') { + char *new_origin = malloc(len - 1); + memcpy(new_origin, origin + 1, len - 2); + new_origin[len - 1] = 0; + origin = new_origin; + } else + origin = strdup(origin); + } else { + char *new_origin = malloc(strlen(origin) + strlen(src) + 5); + sprintf(new_origin, "%s of %s", origin, src); + origin = new_origin; + } + append_to_list(&origins, origin, sha1); + return 0; +} + +static void print_joined(const char *singular, const char *plural, + struct list *list) +{ + if (list->nr == 0) + return; + if (list->nr == 1) { + printf("%s%s", singular, list->list[0]); + } else { + int i; + printf("%s", plural); + for (i = 0; i < list->nr - 1; i++) + printf("%s%s", i > 0 ? ", " : "", list->list[i]); + printf(" and %s", list->list[list->nr - 1]); + } +} + +static void shortlog(const char *name, unsigned char *sha1, + struct commit *head, struct rev_info *rev, int limit) +{ + int i, count = 0; + struct commit *commit; + struct object *branch; + struct list subjects = { NULL, NULL, 0, 0 }; + int flags = UNINTERESTING | TREECHANGE | SEEN | SHOWN | ADDED; + + branch = deref_tag(parse_object(sha1), sha1_to_hex(sha1), 40); + if (!branch || branch->type != TYPE_COMMIT) + return; + + setup_revisions(0, NULL, rev, NULL); + rev->ignore_merges = 1; + add_pending_object(rev, branch, name); + add_pending_object(rev, &head->object, "^HEAD"); + head->object.flags |= UNINTERESTING; + prepare_revision_walk(rev); + while ((commit = get_revision(rev)) != NULL) { + char *oneline, *bol, *eol; + + /* ignore merges */ + if (commit->parents && commit->parents->next) + continue; + + count++; + if (subjects.nr > limit) + continue; + + bol = strstr(commit->buffer, "\n\n"); + if (!bol) { + append_to_list(&subjects, strdup(sha1_to_hex( + commit->object.sha1)), + NULL); + continue; + } + + bol += 2; + eol = strchr(bol, '\n'); + + if (eol) { + int len = eol - bol; + oneline = malloc(len + 1); + memcpy(oneline, bol, len); + oneline[len] = 0; + } else + oneline = strdup(bol); + append_to_list(&subjects, oneline, NULL); + } + + if (count > limit) + printf("\n* %s: (%d commits)\n", name, count); + else + printf("\n* %s:\n", name); + + for (i = 0; i < subjects.nr; i++) + if (i >= limit) + printf(" ...\n"); + else + printf(" %s\n", subjects.list[i]); + + clear_commit_marks((struct commit *)branch, flags); + clear_commit_marks(head, flags); + free_commit_list(rev->commits); + rev->commits = NULL; + rev->pending.nr = 0; + + free_list(&subjects); +} + +int cmd_fmt_merge_msg(int argc, char **argv, char **envp) +{ + int limit = 20, i = 0; + char line[1024]; + FILE *in = stdin; + const char *sep = ""; + unsigned char head_sha1[20]; + const char *head, *current_branch; + + git_config(fmt_merge_msg_config); + + while (argc > 1) { + if (!strcmp(argv[1], "--summary")) + merge_summary = 1; + else if (!strcmp(argv[1], "--no-summary")) + merge_summary = 0; + else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) { + if (argc < 2) + die ("Which file?"); + if (!strcmp(argv[2], "-")) + in = stdin; + else { + fclose(in); + in = fopen(argv[2], "r"); + } + argc--; argv++; + } else + break; + argc--; argv++; + } + + if (argc > 1) + usage(fmt_merge_msg_usage); + + /* get current branch */ + head = strdup(git_path("HEAD")); + current_branch = resolve_ref(head, head_sha1, 1); + current_branch += strlen(head) - 4; + free((char *)head); + if (!strncmp(current_branch, "refs/heads/", 11)) + current_branch += 11; + + while (fgets(line, sizeof(line), in)) { + i++; + if (line[0] == 0) + continue; + if (handle_line(line)) + die ("Error in line %d: %s", i, line); + } + + printf("Merge "); + for (i = 0; i < srcs.nr; i++) { + struct src_data *src_data = srcs.payload[i]; + const char *subsep = ""; + + printf(sep); + sep = "; "; + + if (src_data->head_status == 1) { + printf(srcs.list[i]); + continue; + } + if (src_data->head_status == 3) { + subsep = ", "; + printf("HEAD"); + } + if (src_data->branch.nr) { + printf(subsep); + subsep = ", "; + print_joined("branch ", "branches ", &src_data->branch); + } + if (src_data->r_branch.nr) { + printf(subsep); + subsep = ", "; + print_joined("remote branch ", "remote branches ", + &src_data->r_branch); + } + if (src_data->tag.nr) { + printf(subsep); + subsep = ", "; + print_joined("tag ", "tags ", &src_data->tag); + } + if (src_data->generic.nr) { + printf(subsep); + print_joined("commit ", "commits ", &src_data->generic); + } + if (strcmp(".", srcs.list[i])) + printf(" of %s", srcs.list[i]); + } + + if (!strcmp("master", current_branch)) + putchar('\n'); + else + printf(" into %s\n", current_branch); + + if (merge_summary) { + struct commit *head; + struct rev_info rev; + + head = lookup_commit(head_sha1); + init_revisions(&rev); + rev.commit_format = CMIT_FMT_ONELINE; + rev.ignore_merges = 1; + rev.limited = 1; + + for (i = 0; i < origins.nr; i++) + shortlog(origins.list[i], origins.payload[i], + head, &rev, limit); + } + + /* No cleanup yet; is standalone anyway */ + + return 0; +} + diff --git a/builtin.h b/builtin.h index f12d5e68f..d9e5483bd 100644 --- a/builtin.h +++ b/builtin.h @@ -49,6 +49,7 @@ extern int cmd_cat_file(int argc, const char **argv, char **envp); extern int cmd_rev_parse(int argc, const char **argv, char **envp); extern int cmd_update_index(int argc, const char **argv, char **envp); extern int cmd_update_ref(int argc, const char **argv, char **envp); +extern int cmd_fmt_merge_msg(int argc, const char **argv, char **envp); extern int cmd_write_tree(int argc, const char **argv, char **envp); extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix); diff --git a/git-fmt-merge-msg.perl b/git-fmt-merge-msg.perl deleted file mode 100755 index 5986e5414..000000000 --- a/git-fmt-merge-msg.perl +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (c) 2005 Junio C Hamano -# -# Read .git/FETCH_HEAD and make a human readable merge message -# by grouping branches and tags together to form a single line. - -use strict; - -my @src; -my %src; -sub andjoin { - my ($label, $labels, $stuff) = @_; - my $l = scalar @$stuff; - my $m = ''; - if ($l == 0) { - return (); - } - if ($l == 1) { - $m = "$label$stuff->[0]"; - } - else { - $m = ("$labels" . - join (', ', @{$stuff}[0..$l-2]) . - " and $stuff->[-1]"); - } - return ($m); -} - -sub repoconfig { - my ($val) = qx{git-repo-config --get merge.summary}; - return $val; -} - -sub current_branch { - my ($bra) = qx{git-symbolic-ref HEAD}; - chomp($bra); - $bra =~ s|^refs/heads/||; - if ($bra ne 'master') { - $bra = " into $bra"; - } else { - $bra = ""; - } - return $bra; -} - -sub shortlog { - my ($tip) = @_; - my @result; - foreach ( qx{git-log --no-merges --topo-order --pretty=oneline $tip ^HEAD} ) { - s/^[0-9a-f]{40}\s+//; - push @result, $_; - } - die "git-log failed\n" if $?; - return @result; -} - -my @origin = (); -while (<>) { - my ($bname, $tname, $gname, $src, $sha1, $origin); - chomp; - s/^([0-9a-f]*) //; - $sha1 = $1; - next if (/^not-for-merge/); - s/^ //; - if (s/ of (.*)$//) { - $src = $1; - } else { - # Pulling HEAD - $src = $_; - $_ = 'HEAD'; - } - if (! exists $src{$src}) { - push @src, $src; - $src{$src} = { - BRANCH => [], - TAG => [], - R_BRANCH => [], - GENERIC => [], - # &1 == has HEAD. - # &2 == has others. - HEAD_STATUS => 0, - }; - } - if (/^branch (.*)$/) { - $origin = $1; - push @{$src{$src}{BRANCH}}, $1; - $src{$src}{HEAD_STATUS} |= 2; - } - elsif (/^tag (.*)$/) { - $origin = $_; - push @{$src{$src}{TAG}}, $1; - $src{$src}{HEAD_STATUS} |= 2; - } - elsif (/^remote branch (.*)$/) { - $origin = $1; - push @{$src{$src}{R_BRANCH}}, $1; - $src{$src}{HEAD_STATUS} |= 2; - } - elsif (/^HEAD$/) { - $origin = $src; - $src{$src}{HEAD_STATUS} |= 1; - } - else { - push @{$src{$src}{GENERIC}}, $_; - $src{$src}{HEAD_STATUS} |= 2; - $origin = $src; - } - if ($src eq '.' || $src eq $origin) { - $origin =~ s/^'(.*)'$/$1/; - push @origin, [$sha1, "$origin"]; - } - else { - push @origin, [$sha1, "$origin of $src"]; - } -} - -my @msg; -for my $src (@src) { - if ($src{$src}{HEAD_STATUS} == 1) { - # Only HEAD is fetched, nothing else. - push @msg, $src; - next; - } - my @this; - if ($src{$src}{HEAD_STATUS} == 3) { - # HEAD is fetched among others. - push @this, andjoin('', '', ['HEAD']); - } - push @this, andjoin("branch ", "branches ", - $src{$src}{BRANCH}); - push @this, andjoin("remote branch ", "remote branches ", - $src{$src}{R_BRANCH}); - push @this, andjoin("tag ", "tags ", - $src{$src}{TAG}); - push @this, andjoin("commit ", "commits ", - $src{$src}{GENERIC}); - my $this = join(', ', @this); - if ($src ne '.') { - $this .= " of $src"; - } - push @msg, $this; -} - -my $into = current_branch(); - -print "Merge ", join("; ", @msg), $into, "\n"; - -if (!repoconfig) { - exit(0); -} - -# We limit the merge message to the latst 20 or so per each branch. -my $limit = 20; - -for (@origin) { - my ($sha1, $name) = @$_; - my @log = shortlog($sha1); - if ($limit + 1 <= @log) { - print "\n* $name: (" . scalar(@log) . " commits)\n"; - } - else { - print "\n* $name:\n"; - } - my $cnt = 0; - for my $log (@log) { - if ($limit < ++$cnt) { - print " ...\n"; - last; - } - print " $log"; - } -} diff --git a/git.c b/git.c index ca8961f07..256730112 100644 --- a/git.c +++ b/git.c @@ -187,7 +187,8 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "mailinfo", cmd_mailinfo }, { "stripspace", cmd_stripspace }, { "update-index", cmd_update_index }, - { "update-ref", cmd_update_ref } + { "update-ref", cmd_update_ref }, + { "fmt-merge-msg", cmd_fmt_merge_msg } }; int i; -- cgit v1.2.1 From 4d62eaabeb283d6dab56cfb2f2e54144b98afafd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 4 Jul 2006 01:04:24 -0700 Subject: t8001-annotate: fix a bash-ism in this test Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- t/t8001-annotate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh index 70e2ad23a..3a6490e8f 100755 --- a/t/t8001-annotate.sh +++ b/t/t8001-annotate.sh @@ -8,8 +8,8 @@ PROG='git annotate' test_expect_success \ 'Annotating an old revision works' \ - '[ $(git annotate file master | awk "{print \$3}" | grep -c "^A$") == 2 ] && \ - [ $(git annotate file master | awk "{print \$3}" | grep -c "^B$") == 2 ]' + '[ $(git annotate file master | awk "{print \$3}" | grep -c "^A$") -eq 2 ] && \ + [ $(git annotate file master | awk "{print \$3}" | grep -c "^B$") -eq 2 ]' test_done -- cgit v1.2.1 From 3dd4e7320de037a5b0adf3c53fbf5baf94a6c540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santi=20B=C3=A9jar?= Date: Tue, 4 Jul 2006 11:02:22 +0200 Subject: Teach rev-parse the ... syntax. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [jc: moved the difference code around into its own function.] Signed-off-by: Santi Béjar Signed-off-by: Junio C Hamano --- builtin-rev-parse.c | 65 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c index 5f5ade45a..4377d357c 100644 --- a/builtin-rev-parse.c +++ b/builtin-rev-parse.c @@ -164,6 +164,51 @@ static int show_file(const char *arg) return 0; } +static int try_difference(char *arg) +{ + char *dotdot; + unsigned char sha1[20]; + unsigned char end[20]; + const char *next; + const char *this; + int symmetric; + + if (!(dotdot = strstr(arg, ".."))) + return 0; + next = dotdot + 2; + this = arg; + symmetric = (*next == '.'); + + *dotdot = 0; + next += symmetric; + + if (!*next) + next = "HEAD"; + if (dotdot == arg) + this = "HEAD"; + if (!get_sha1(this, sha1) && !get_sha1(next, end)) { + show_rev(NORMAL, end, next); + show_rev(symmetric ? NORMAL : REVERSED, sha1, this); + if (symmetric) { + struct commit_list *exclude; + struct commit *a, *b; + a = lookup_commit_reference(sha1); + b = lookup_commit_reference(end); + exclude = get_merge_bases(a, b, 1); + while (exclude) { + struct commit_list *n = exclude->next; + show_rev(REVERSED, + exclude->item->object.sha1,NULL); + free(exclude); + exclude = n; + } + } + return 1; + } + *dotdot = '.'; + return 0; +} + int cmd_rev_parse(int argc, const char **argv, char **envp) { int i, as_is = 0, verify = 0; @@ -174,7 +219,6 @@ int cmd_rev_parse(int argc, const char **argv, char **envp) for (i = 1; i < argc; i++) { const char *arg = argv[i]; - char *dotdot; if (as_is) { if (show_file(arg) && as_is < 2) @@ -326,23 +370,8 @@ int cmd_rev_parse(int argc, const char **argv, char **envp) } /* Not a flag argument */ - dotdot = strstr(arg, ".."); - if (dotdot) { - unsigned char end[20]; - const char *next = dotdot + 2; - const char *this = arg; - *dotdot = 0; - if (!*next) - next = "HEAD"; - if (dotdot == arg) - this = "HEAD"; - if (!get_sha1(this, sha1) && !get_sha1(next, end)) { - show_rev(NORMAL, end, next); - show_rev(REVERSED, sha1, this); - continue; - } - *dotdot = '.'; - } + if (try_difference(arg)) + continue; if (!get_sha1(arg, sha1)) { show_rev(NORMAL, sha1, arg); continue; -- cgit v1.2.1 From 5390590f6d72ffb80da74ed4cbc8648400ea3481 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 4 Jul 2006 02:31:50 -0700 Subject: git-grep: fix parsing of pathspec separator '--' We used to misparse git grep -e foo -- '*.sh' Signed-off-by: Junio C Hamano --- builtin-grep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/builtin-grep.c b/builtin-grep.c index 2e7986cec..a8bec72f8 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -817,8 +817,12 @@ int cmd_grep(int argc, const char **argv, char **envp) } usage(builtin_grep_usage); } - if (!strcmp("--", arg)) + if (!strcmp("--", arg)) { + /* later processing wants to have this at argv[1] */ + argv--; + argc++; break; + } if (*arg == '-') usage(builtin_grep_usage); -- cgit v1.2.1 From fcfe34b5ace3e75d37c462712c7103e39cdb1fbc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 4 Jul 2006 02:43:40 -0700 Subject: git-grep: fix exit code when we use external grep. Upon hit, we should exit with status 0. Signed-off-by: Junio C Hamano --- builtin-grep.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/builtin-grep.c b/builtin-grep.c index a8bec72f8..bc53546dc 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -446,7 +446,7 @@ static int exec_grep(int argc, const char **argv) static int external_grep(struct grep_opt *opt, const char **paths, int cached) { - int i, nr, argc, hit, len; + int i, nr, argc, hit, len, status; const char *argv[MAXARGS+1]; char randarg[ARGBUF]; char *argptr = randarg; @@ -536,12 +536,17 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached) argv[argc++] = name; if (argc < MAXARGS) continue; - hit += exec_grep(argc, argv); + status = exec_grep(argc, argv); + if (0 < status) + hit = 1; argc = nr; } - if (argc > nr) - hit += exec_grep(argc, argv); - return 0; + if (argc > nr) { + status = exec_grep(argc, argv); + if (0 < status) + hit = 1; + } + return hit; } static int grep_cache(struct grep_opt *opt, const char **paths, int cached) -- cgit v1.2.1 From 088b084bbbb7c076a85db941ad60edce582017b4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 4 Jul 2006 02:44:48 -0700 Subject: git-grep: use a bit more specific error messages. Signed-off-by: Junio C Hamano --- builtin-grep.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/builtin-grep.c b/builtin-grep.c index bc53546dc..6973c6670 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -657,6 +657,13 @@ static int grep_object(struct grep_opt *opt, const char **paths, static const char builtin_grep_usage[] = "git-grep