Skip to content

Commit fae22ac

Browse files
Junio C HamanoLinus Torvalds
authored andcommitted
[PATCH] git-apply: tests for --stat and --summary.
This adds tests (which also serves demonstration) for the --stat and --summary flags to the git-apply command. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent d0587fd commit fae22ac

15 files changed

+2152
-0
lines changed

t/t4100-apply-stat.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2005 Junio C Hamano
4+
#
5+
6+
test_description='git-apply --stat --summary test.
7+
8+
'
9+
. ./test-lib.sh
10+
11+
test_expect_success \
12+
'rename' \
13+
'git-apply --stat --summary <../t4100/t-apply-1.patch >current &&
14+
diff -u ../t4100/t-apply-1.expect current'
15+
16+
test_expect_success \
17+
'copy' \
18+
'git-apply --stat --summary <../t4100/t-apply-2.patch >current &&
19+
diff -u ../t4100/t-apply-2.expect current'
20+
21+
test_expect_success \
22+
'rewrite' \
23+
'git-apply --stat --summary <../t4100/t-apply-3.patch >current &&
24+
diff -u ../t4100/t-apply-3.expect current'
25+
26+
test_expect_success \
27+
'mode' \
28+
'git-apply --stat --summary <../t4100/t-apply-4.patch >current &&
29+
diff -u ../t4100/t-apply-4.expect current'
30+
31+
test_expect_success \
32+
'non git' \
33+
'git-apply --stat --summary <../t4100/t-apply-5.patch >current &&
34+
diff -u ../t4100/t-apply-5.expect current'
35+
36+
test_expect_success \
37+
'non git' \
38+
'git-apply --stat --summary <../t4100/t-apply-6.patch >current &&
39+
diff -u ../t4100/t-apply-6.expect current'
40+
41+
test_expect_success \
42+
'non git' \
43+
'git-apply --stat --summary <../t4100/t-apply-7.patch >current &&
44+
diff -u ../t4100/t-apply-7.expect current'
45+
46+
test_done
47+

t/t4100/t-apply-1.expect

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Documentation/git-ssh-pull.txt | 12 ++++++------
2+
Documentation/git-ssh-push.txt | 10 +++++-----
3+
Documentation/git.txt | 6 +++---
4+
Makefile | 6 +++---
5+
ssh-pull.c | 4 ++--
6+
ssh-push.c | 14 +++++++-------
7+
6 files changed, 26 insertions(+), 26 deletions(-)
8+
rename Documentation/{git-rpull.txt => git-ssh-pull.txt} (90%)
9+
rename Documentation/{git-rpush.txt => git-ssh-push.txt} (71%)
10+
rename rpull.c => ssh-pull.c (97%)
11+
rename rpush.c => ssh-push.c (93%)

t/t4100/t-apply-1.patch

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
418aaf847a8b3ffffb4f777a2dd5262ca5ce0ef7 (from dc93841715dfa9a9cdda6f2c4a25eec831ea7aa0)
2+
diff --git a/Documentation/git-rpull.txt b/Documentation/git-ssh-pull.txt
3+
similarity index 90%
4+
rename from Documentation/git-rpull.txt
5+
rename to Documentation/git-ssh-pull.txt
6+
--- a/Documentation/git-rpull.txt
7+
+++ b/Documentation/git-ssh-pull.txt
8+
@@ -1,21 +1,21 @@
9+
-git-rpull(1)
10+
-============
11+
+git-ssh-pull(1)
12+
+===============
13+
v0.1, May 2005
14+
15+
NAME
16+
----
17+
-git-rpull - Pulls from a remote repository over ssh connection
18+
+git-ssh-pull - Pulls from a remote repository over ssh connection
19+
20+
21+
22+
SYNOPSIS
23+
--------
24+
-'git-rpull' [-c] [-t] [-a] [-d] [-v] [--recover] commit-id url
25+
+'git-ssh-pull' [-c] [-t] [-a] [-d] [-v] [--recover] commit-id url
26+
27+
DESCRIPTION
28+
-----------
29+
-Pulls from a remote repository over ssh connection, invoking git-rpush on
30+
-the other end.
31+
+Pulls from a remote repository over ssh connection, invoking git-ssh-push
32+
+on the other end.
33+
34+
OPTIONS
35+
-------
36+
diff --git a/Documentation/git-rpush.txt b/Documentation/git-ssh-push.txt
37+
similarity index 71%
38+
rename from Documentation/git-rpush.txt
39+
rename to Documentation/git-ssh-push.txt
40+
--- a/Documentation/git-rpush.txt
41+
+++ b/Documentation/git-ssh-push.txt
42+
@@ -1,19 +1,19 @@
43+
-git-rpush(1)
44+
-============
45+
+git-ssh-push(1)
46+
+===============
47+
v0.1, May 2005
48+
49+
NAME
50+
----
51+
-git-rpush - Helper "server-side" program used by git-rpull
52+
+git-ssh-push - Helper "server-side" program used by git-ssh-pull
53+
54+
55+
SYNOPSIS
56+
--------
57+
-'git-rpush'
58+
+'git-ssh-push'
59+
60+
DESCRIPTION
61+
-----------
62+
-Helper "server-side" program used by git-rpull.
63+
+Helper "server-side" program used by git-ssh-pull.
64+
65+
66+
Author
67+
diff --git a/Documentation/git.txt b/Documentation/git.txt
68+
--- a/Documentation/git.txt
69+
+++ b/Documentation/git.txt
70+
@@ -148,7 +148,7 @@ link:git-resolve-script.html[git-resolve
71+
link:git-tag-script.html[git-tag-script]::
72+
An example script to create a tag object signed with GPG
73+
74+
-link:git-rpull.html[git-rpull]::
75+
+link:git-ssh-pull.html[git-ssh-pull]::
76+
Pulls from a remote repository over ssh connection
77+
78+
Interogators:
79+
@@ -156,8 +156,8 @@ Interogators:
80+
link:git-diff-helper.html[git-diff-helper]::
81+
Generates patch format output for git-diff-*
82+
83+
-link:git-rpush.html[git-rpush]::
84+
- Helper "server-side" program used by git-rpull
85+
+link:git-ssh-push.html[git-ssh-push]::
86+
+ Helper "server-side" program used by git-ssh-pull
87+
88+
89+
90+
diff --git a/Makefile b/Makefile
91+
--- a/Makefile
92+
+++ b/Makefile
93+
@@ -30,7 +30,7 @@ PROG= git-update-cache git-diff-files
94+
git-checkout-cache git-diff-tree git-rev-tree git-ls-files \
95+
git-check-files git-ls-tree git-merge-base git-merge-cache \
96+
git-unpack-file git-export git-diff-cache git-convert-cache \
97+
- git-http-pull git-rpush git-rpull git-rev-list git-mktag \
98+
+ git-http-pull git-ssh-push git-ssh-pull git-rev-list git-mktag \
99+
git-diff-helper git-tar-tree git-local-pull git-write-blob \
100+
git-get-tar-commit-id git-mkdelta git-apply git-stripspace
101+
102+
@@ -105,8 +105,8 @@ git-diff-cache: diff-cache.c
103+
git-convert-cache: convert-cache.c
104+
git-http-pull: http-pull.c pull.c
105+
git-local-pull: local-pull.c pull.c
106+
-git-rpush: rsh.c
107+
-git-rpull: rsh.c pull.c
108+
+git-ssh-push: rsh.c
109+
+git-ssh-pull: rsh.c pull.c
110+
git-rev-list: rev-list.c
111+
git-mktag: mktag.c
112+
git-diff-helper: diff-helper.c
113+
diff --git a/rpull.c b/ssh-pull.c
114+
similarity index 97%
115+
rename from rpull.c
116+
rename to ssh-pull.c
117+
--- a/rpull.c
118+
+++ b/ssh-pull.c
119+
@@ -64,13 +64,13 @@ int main(int argc, char **argv)
120+
arg++;
121+
}
122+
if (argc < arg + 2) {
123+
- usage("git-rpull [-c] [-t] [-a] [-v] [-d] [--recover] commit-id url");
124+
+ usage("git-ssh-pull [-c] [-t] [-a] [-v] [-d] [--recover] commit-id url");
125+
return 1;
126+
}
127+
commit_id = argv[arg];
128+
url = argv[arg + 1];
129+
130+
- if (setup_connection(&fd_in, &fd_out, "git-rpush", url, arg, argv + 1))
131+
+ if (setup_connection(&fd_in, &fd_out, "git-ssh-push", url, arg, argv + 1))
132+
return 1;
133+
134+
if (get_version())
135+
diff --git a/rpush.c b/ssh-push.c
136+
similarity index 93%
137+
rename from rpush.c
138+
rename to ssh-push.c
139+
--- a/rpush.c
140+
+++ b/ssh-push.c
141+
@@ -16,7 +16,7 @@ int serve_object(int fd_in, int fd_out)
142+
do {
143+
size = read(fd_in, sha1 + posn, 20 - posn);
144+
if (size < 0) {
145+
- perror("git-rpush: read ");
146+
+ perror("git-ssh-push: read ");
147+
return -1;
148+
}
149+
if (!size)
150+
@@ -30,7 +30,7 @@ int serve_object(int fd_in, int fd_out)
151+
buf = map_sha1_file(sha1, &objsize);
152+
153+
if (!buf) {
154+
- fprintf(stderr, "git-rpush: could not find %s\n",
155+
+ fprintf(stderr, "git-ssh-push: could not find %s\n",
156+
sha1_to_hex(sha1));
157+
remote = -1;
158+
}
159+
@@ -45,9 +45,9 @@ int serve_object(int fd_in, int fd_out)
160+
size = write(fd_out, buf + posn, objsize - posn);
161+
if (size <= 0) {
162+
if (!size) {
163+
- fprintf(stderr, "git-rpush: write closed");
164+
+ fprintf(stderr, "git-ssh-push: write closed");
165+
} else {
166+
- perror("git-rpush: write ");
167+
+ perror("git-ssh-push: write ");
168+
}
169+
return -1;
170+
}
171+
@@ -71,7 +71,7 @@ void service(int fd_in, int fd_out) {
172+
retval = read(fd_in, &type, 1);
173+
if (retval < 1) {
174+
if (retval < 0)
175+
- perror("rpush: read ");
176+
+ perror("git-ssh-push: read ");
177+
return;
178+
}
179+
if (type == 'v' && serve_version(fd_in, fd_out))
180+
@@ -91,12 +91,12 @@ int main(int argc, char **argv)
181+
arg++;
182+
}
183+
if (argc < arg + 2) {
184+
- usage("git-rpush [-c] [-t] [-a] commit-id url");
185+
+ usage("git-ssh-push [-c] [-t] [-a] commit-id url");
186+
return 1;
187+
}
188+
commit_id = argv[arg];
189+
url = argv[arg + 1];
190+
- if (setup_connection(&fd_in, &fd_out, "git-rpull", url, arg, argv + 1))
191+
+ if (setup_connection(&fd_in, &fd_out, "git-ssh-pull", url, arg, argv + 1))
192+
return 1;
193+
194+
service(fd_in, fd_out);

t/t4100/t-apply-2.expect

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Makefile | 2 +-
2+
git-fetch-script | 5 -----
3+
git-pull-script | 34 +---------------------------------
4+
3 files changed, 2 insertions(+), 39 deletions(-)
5+
copy git-pull-script => git-fetch-script (87%)

t/t4100/t-apply-2.patch

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
7ef76925d9c19ef74874e1735e2436e56d0c4897 (from 6b14d7faf0bad026a81a27bac07b47691f621b8f)
2+
diff --git a/Makefile b/Makefile
3+
--- a/Makefile
4+
+++ b/Makefile
5+
@@ -20,7 +20,7 @@ INSTALL=install
6+
7+
SCRIPTS=git-apply-patch-script git-merge-one-file-script git-prune-script \
8+
git-pull-script git-tag-script git-resolve-script git-whatchanged \
9+
- git-deltafy-script
10+
+ git-deltafy-script git-fetch-script
11+
12+
PROG= git-update-cache git-diff-files git-init-db git-write-tree \
13+
git-read-tree git-commit-tree git-cat-file git-fsck-cache \
14+
diff --git a/git-pull-script b/git-fetch-script
15+
similarity index 87%
16+
copy from git-pull-script
17+
copy to git-fetch-script
18+
--- a/git-pull-script
19+
+++ b/git-fetch-script
20+
@@ -39,8 +39,3 @@ download_one "$merge_repo/$merge_name" "
21+
22+
echo "Getting object database"
23+
download_objects "$merge_repo" "$(cat "$GIT_DIR"/MERGE_HEAD)"
24+
-
25+
-git-resolve-script \
26+
- "$(cat "$GIT_DIR"/HEAD)" \
27+
- "$(cat "$GIT_DIR"/MERGE_HEAD)" \
28+
- "$merge_repo"
29+
diff --git a/git-pull-script b/git-pull-script
30+
--- a/git-pull-script
31+
+++ b/git-pull-script
32+
@@ -6,39 +6,7 @@ merge_name=${2:-HEAD}
33+
: ${GIT_DIR=.git}
34+
: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
35+
36+
-download_one () {
37+
- # remote_path="$1" local_file="$2"
38+
- case "$1" in
39+
- http://*)
40+
- wget -q -O "$2" "$1" ;;
41+
- /*)
42+
- test -f "$1" && cat >"$2" "$1" ;;
43+
- *)
44+
- rsync -L "$1" "$2" ;;
45+
- esac
46+
-}
47+
-
48+
-download_objects () {
49+
- # remote_repo="$1" head_sha1="$2"
50+
- case "$1" in
51+
- http://*)
52+
- git-http-pull -a "$2" "$1/"
53+
- ;;
54+
- /*)
55+
- git-local-pull -l -a "$2" "$1/"
56+
- ;;
57+
- *)
58+
- rsync -avz --ignore-existing \
59+
- "$1/objects/." "$GIT_OBJECT_DIRECTORY"/.
60+
- ;;
61+
- esac
62+
-}
63+
-
64+
-echo "Getting remote $merge_name"
65+
-download_one "$merge_repo/$merge_name" "$GIT_DIR"/MERGE_HEAD
66+
-
67+
-echo "Getting object database"
68+
-download_objects "$merge_repo" "$(cat "$GIT_DIR"/MERGE_HEAD)"
69+
+git-fetch-script "$merge_repo" "$merge_name"
70+
71+
git-resolve-script \
72+
"$(cat "$GIT_DIR"/HEAD)" \

t/t4100/t-apply-3.expect

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Documentation/git-ls-tree.txt | 20 +-
2+
ls-tree.c | 459 ++++++++++++++++++++++-------------------
3+
t/t3100-ls-tree-restrict.sh | 3
4+
tree.c | 2
5+
tree.h | 1
6+
5 files changed, 262 insertions(+), 223 deletions(-)
7+
rewrite ls-tree.c (82%)

0 commit comments

Comments
 (0)