@matheusbsbs / matheus-bagliano / commits / 27dedf0c3b
Fork 0

GIT 0.99.9j aka 1.0rc3

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 16, 2005 at 21:32 UTC 27dedf0c3b78d1072fb5449149421284f9e5297b
46 files changed +895 -257
Documentation/diff-format.txt
+1 -1
@@ -81,7 +81,7 @@ The "diff" formatting options can be customized via the
81 environment variable 'GIT_DIFF_OPTS'. For example, if you
82 prefer context diff:
83
84 - GIT_DIFF_OPTS=-c git-diff-index -p $(cat .git/HEAD)
84 + GIT_DIFF_OPTS=-c git-diff-index -p HEAD
85
86
87 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
Documentation/diff-options.txt
+5
@@ -13,6 +13,11 @@
13 --name-status::
14 Show only names and status of changed files.
15
16 +--full-index::
17 + Instead of the first handful characters, show full
18 + object name of pre- and post-image blob on the "index"
19 + line when generating a patch format output.
20 +
21 -B::
22 Break complete rewrite changes into pairs of delete and create.
23
Documentation/git-apply.txt
+12 -1
@@ -8,7 +8,7 @@ git-apply - Apply patch on a git index file and a work tree
8
9 SYNOPSIS
10 --------
11 -'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [-z] [<patch>...]
11 +'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [<patch>...]
12
13 DESCRIPTION
14 -----------
@@ -79,6 +79,17 @@ OPTIONS
79 the result with this option, which would apply the
80 deletion part but not addition part.
81
82 +--allow-binary-replacement::
83 + When applying a patch, which is a git-enhanced patch
84 + that was prepared to record the pre- and post-image object
85 + name in full, and the path being patched exactly matches
86 + the object the patch applies to (i.e. "index" line's
87 + pre-image object name is what is in the working tree),
88 + and the post-image object is available in the object
89 + database, use the post-image object as the patch
90 + result. This allows binary files to be patched in a
91 + very limited way.
92 +
93 Author
94 ------
95 Written by Linus Torvalds <torvalds@osdl.org>
Documentation/git-commit-tree.txt
+3 -2
@@ -26,8 +26,9 @@ to get there.
26
27 Normally a commit would identify a new "HEAD" state, and while git
28 doesn't care where you save the note about that state, in practice we
29 -tend to just write the result to the file `.git/HEAD`, so that we can
30 -always see what the last committed state was.
29 +tend to just write the result to the file that is pointed at by
30 +`.git/HEAD`, so that we can always see what the last committed
31 +state was.
32
33 OPTIONS
34 -------
Documentation/git-daemon.txt
+1 -1
@@ -35,7 +35,7 @@ OPTIONS
35 do not have the 'git-daemon-export-ok' file.
36
37 --inetd::
38 - Have the server run as an inetd service.
38 + Have the server run as an inetd service. Implies --syslog.
39
40 --port::
41 Listen on an alternative port.
Documentation/git-diff-index.txt
+3 -3
@@ -57,14 +57,14 @@ some files in the index and are ready to commit. You want to see eactly
57 *what* you are going to commit is without having to write a new tree
58 object and compare it that way, and to do that, you just do
59
60 - git-diff-index --cached $(cat .git/HEAD)
60 + git-diff-index --cached HEAD
61
62 Example: let's say I had renamed `commit.c` to `git-commit.c`, and I had
63 done an "git-update-index" to make that effective in the index file.
64 "git-diff-files" wouldn't show anything at all, since the index file
65 matches my working directory. But doing a "git-diff-index" does:
66
67 - torvalds@ppc970:~/git> git-diff-index --cached $(cat .git/HEAD)
67 + torvalds@ppc970:~/git> git-diff-index --cached HEAD
68 -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
69 +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c
70
@@ -98,7 +98,7 @@ show that. So let's say that you have edited `kernel/sched.c`, but
98 have not actually done a "git-update-index" on it yet - there is no
99 "object" associated with the new state, and you get:
100
101 - torvalds@ppc970:~/v2.6/linux> git-diff-index $(cat .git/HEAD )
101 + torvalds@ppc970:~/v2.6/linux> git-diff-index HEAD
102 *100644->100664 blob 7476bb......->000000...... kernel/sched.c
103
104 ie it shows that the tree has changed, and that `kernel/sched.c` has is
Documentation/git-fsck-objects.txt
+1 -1
@@ -68,7 +68,7 @@ that aren't readable from any of the specified head nodes.
68
69 So for example
70
71 - git-fsck-objects --unreachable $(cat .git/HEAD .git/refs/heads/*)
71 + git-fsck-objects --unreachable HEAD $(cat .git/refs/heads/*)
72
73 will do quite a _lot_ of verification on the tree. There are a few
74 extra validity tests to be added (make sure that tree objects are
Documentation/git-log.txt
+1 -1
@@ -20,7 +20,7 @@ This manual page describes only the most frequently used options.
20
21 OPTIONS
22 -------
23 ---pretty=<format>:
23 +--pretty=<format>::
24 Controls the way the commit log is formatted.
25
26 --max-count=<n>::
Documentation/git-read-tree.txt
+1 -1
@@ -237,7 +237,7 @@ This is done to prevent you from losing your work-in-progress
237 changes. To illustrate, suppose you start from what has been
238 commited last to your repository:
239
240 - $ JC=`cat .git/HEAD`
240 + $ JC=`git-rev-parse --verify "HEAD^0"`
241 $ git-checkout-index -f -u -a $JC
242
243 You do random edits, without running git-update-index. And then
Documentation/git-symbolic-ref.txt
+2 -2
@@ -24,8 +24,8 @@ Traditionally, `.git/HEAD` is a symlink pointing at
24 we did `ln -sf refs/heads/newbranch .git/HEAD`, and when we want
25 to find out which branch we are on, we did `readlink .git/HEAD`.
26 This was fine, and internally that is what still happens by
27 -default, but on platforms that does not have working symlinks,
28 -or that does not have the `readlink(1)` command, this was a bit
27 +default, but on platforms that do not have working symlinks,
28 +or that do not have the `readlink(1)` command, this was a bit
29 cumbersome. On some platforms, `ln -sf` does not even work as
30 advertised (horrors).
31
Documentation/git.txt
+31 -8
@@ -8,13 +8,33 @@ git - the stupid content tracker
8
9 SYNOPSIS
10 --------
11 -'git-<command>' <args>
11 +'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ARGS]
12
13 DESCRIPTION
14 -----------
15 -
16 -This is reference information for the core git commands.
17 -
15 +'git' is both a program and a directory content tracker system.
16 +The program 'git' is just a wrapper to reach the core git programs
17 +(or a potty if you like, as it's not exactly porcelain but still
18 +brings your stuff to the plumbing).
19 +
20 +OPTIONS
21 +-------
22 +--version::
23 + prints the git suite version that the 'git' program came from.
24 +
25 +--help::
26 + prints the synopsis and a list of available commands.
27 + If a git command is named this option will bring up the
28 + man-page for that command.
29 +
30 +--exec-path::
31 + path to wherever your core git programs are installed.
32 + This can also be controlled by setting the GIT_EXEC_PATH
33 + environment variable. If no path is given 'git' will print
34 + the current setting and then exit.
35 +
36 +CORE GIT COMMANDS
37 +-----------------
38 Before reading this cover to cover, you may want to take a look
39 at the link:tutorial.html[tutorial] document.
40
@@ -67,7 +87,7 @@ gitlink:git-commit-tree[1]::
87 gitlink:git-hash-object[1]::
88 Computes the object ID from a file.
89
70 -gitlink:git-index-pack.html[1]::
90 +gitlink:git-index-pack[1]::
91 Build pack index file for an existing packed archive.
92
93 gitlink:git-init-db[1]::
@@ -533,9 +553,12 @@ Discussion[[Discussion]]
553 ------------------------
554 include::../README[]
555
536 -Author
537 -------
538 -Written by Linus Torvalds <torvalds@osdl.org> and the git-list <git@vger.kernel.org>.
556 +Authors
557 +-------
558 + git's founding father is Linus Torvalds <torvalds@osdl.org>.
559 + The current git nurse is Junio C. Hamano <junkio@cox.net>.
560 + The git potty was written by Andres Ericsson <ae@op5.se>.
561 + General upbringing is handled by the git-list <git@vger.kernel.org>.
562
563 Documentation
564 --------------
Makefile
+18 -22
@@ -50,7 +50,7 @@
50 # Define USE_STDEV below if you want git to care about the underlying device
51 # change being considered an inode change from the update-cache perspective.
52
53 -GIT_VERSION = 0.99.9i
53 +GIT_VERSION = 0.99.9j
54
55 # CFLAGS and LDFLAGS are for the users to override from the command line.
56
@@ -88,7 +88,7 @@ SCRIPT_SH = \
88 git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
89 git-repack.sh git-request-pull.sh git-reset.sh \
90 git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
91 - git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
91 + git-tag.sh git-verify-tag.sh git-whatchanged.sh \
92 git-applymbox.sh git-applypatch.sh git-am.sh \
93 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
94 git-merge-resolve.sh git-merge-ours.sh git-grep.sh \
@@ -105,7 +105,7 @@ SCRIPT_PYTHON = \
105 # The ones that do not have to link with lcrypto nor lz.
106 SIMPLE_PROGRAMS = \
107 git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
108 - git-stripspace$X git-var$X git-daemon$X
108 + git-stripspace$X git-daemon$X
109
110 # ... and all the rest
111 PROGRAMS = \
@@ -125,7 +125,7 @@ PROGRAMS = \
125 git-unpack-objects$X git-update-index$X git-update-server-info$X \
126 git-upload-pack$X git-verify-pack$X git-write-tree$X \
127 git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
128 - git-name-rev$X git-pack-redundant$X $(SIMPLE_PROGRAMS)
128 + git-name-rev$X git-pack-redundant$X git-var$X $(SIMPLE_PROGRAMS)
129
130 # Backward compatibility -- to be removed after 1.0
131 PROGRAMS += git-ssh-pull$X git-ssh-push$X
@@ -334,19 +334,15 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
334 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
335 ### Build rules
336
337 -all: $(PROGRAMS) $(SCRIPTS)
337 +all: $(PROGRAMS) $(SCRIPTS) git
338
339 all:
340 $(MAKE) -C templates
341
342 -git: git.sh Makefile
343 - rm -f $@+ $@
344 - sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
345 - -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
346 - -e 's/@@X@@/$(X)/g' \
347 - $(GIT_LIST_TWEAK) <$@.sh >$@+
348 - chmod +x $@+
349 - mv $@+ $@
342 +# Only use $(CFLAGS). We don't need anything else.
343 +git: git.c Makefile
344 + $(CC) -DGIT_EXEC_PATH='"$(bindir)"' -DGIT_VERSION='"$(GIT_VERSION)"' \
345 + $(CFLAGS) $@.c -o $@
346
347 $(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
348 rm -f $@
@@ -431,9 +427,9 @@ check:
427
428 ### Installation rules
429
434 -install: $(PROGRAMS) $(SCRIPTS)
430 +install: $(PROGRAMS) $(SCRIPTS) git
431 $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
436 - $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(call shellquote,$(DESTDIR)$(bindir))
432 + $(INSTALL) git $(PROGRAMS) $(SCRIPTS) $(call shellquote,$(DESTDIR)$(bindir))
433 $(MAKE) -C templates install
434 $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
435 $(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
@@ -446,20 +442,20 @@ install-doc:
442
443 ### Maintainer's dist rules
444
449 -git-core.spec: git-core.spec.in Makefile
445 +git.spec: git.spec.in Makefile
446 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
447
452 -GIT_TARNAME=git-core-$(GIT_VERSION)
453 -dist: git-core.spec git-tar-tree
448 +GIT_TARNAME=git-$(GIT_VERSION)
449 +dist: git.spec git-tar-tree
450 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
451 @mkdir -p $(GIT_TARNAME)
456 - @cp git-core.spec $(GIT_TARNAME)
457 - $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
452 + @cp git.spec $(GIT_TARNAME)
453 + $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git.spec
454 @rm -rf $(GIT_TARNAME)
455 gzip -f -9 $(GIT_TARNAME).tar
456
457 rpm: dist
462 - $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
458 + $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
459
460 deb: dist
461 rm -rf $(GIT_TARNAME)
@@ -472,7 +468,7 @@ deb: dist
468 clean:
469 rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
470 rm -f $(filter-out gitk,$(SCRIPTS))
475 - rm -f git-core.spec *.pyc *.pyo
471 + rm -f *.spec *.pyc *.pyo
472 rm -rf $(GIT_TARNAME)
473 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
474 rm -f git-core_$(GIT_VERSION)-*.dsc
README
+3 -3
@@ -396,8 +396,8 @@ git-commit-tree will return the name of the object that represents
396 that commit, and you should save it away for later use. Normally,
397 you'd commit a new `HEAD` state, and while git doesn't care where you
398 save the note about that state, in practice we tend to just write the
399 -result to the file `.git/HEAD`, so that we can always see what the
400 -last committed state was.
399 +result to the file pointed at by `.git/HEAD`, so that we can always see
400 +what the last committed state was.
401
402 Here is an ASCII art by Jon Loeliger that illustrates how
403 various pieces fit together.
@@ -464,7 +464,7 @@ tend to be small and fairly self-explanatory. In particular, if you
464 follow the convention of having the top commit name in `.git/HEAD`,
465 you can do
466
467 - git-cat-file commit $(cat .git/HEAD)
467 + git-cat-file commit HEAD
468
469 to see what the top commit was.
470
apply.c
+85 -7
@@ -16,6 +16,7 @@
16 // --numstat does numeric diffstat, and doesn't actually apply
17 // --index-info shows the old and new index info for paths if available.
18 //
19 +static int allow_binary_replacement = 0;
20 static int check_index = 0;
21 static int write_index = 0;
22 static int diffstat = 0;
@@ -27,7 +28,7 @@ static int no_add = 0;
28 static int show_index_info = 0;
29 static int line_termination = '\n';
30 static const char apply_usage[] =
30 -"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [-z] <patch>...";
31 +"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] <patch>...";
32
33 /*
34 * For "diff-stat" like behaviour, we keep track of the biggest change
@@ -891,7 +892,7 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
892
893 patchsize = parse_single_patch(buffer + offset + hdrsize, size - offset - hdrsize, patch);
894
894 - if (!patchsize && !metadata_changes(patch)) {
895 + if (!patchsize) {
896 static const char binhdr[] = "Binary files ";
897
898 if (sizeof(binhdr) - 1 < size - offset - hdrsize &&
@@ -899,9 +900,14 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
900 sizeof(binhdr)-1))
901 patch->is_binary = 1;
902
902 - if (patch->is_binary && !apply && !check)
903 - ;
904 - else
903 + /* Empty patch cannot be applied if:
904 + * - it is a binary patch and we do not do binary_replace, or
905 + * - text patch without metadata change
906 + */
907 + if ((apply || check) &&
908 + (patch->is_binary
909 + ? !allow_binary_replacement
910 + : !metadata_changes(patch)))
911 die("patch with only garbage at line %d", linenr);
912 }
913
@@ -1155,10 +1161,77 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag)
1161 static int apply_fragments(struct buffer_desc *desc, struct patch *patch)
1162 {
1163 struct fragment *frag = patch->fragments;
1164 + const char *name = patch->old_name ? patch->old_name : patch->new_name;
1165 +
1166 + if (patch->is_binary) {
1167 + unsigned char sha1[20];
1168 +
1169 + if (!allow_binary_replacement)
1170 + return error("cannot apply binary patch to '%s' "
1171 + "without --allow-binary-replacement",
1172 + name);
1173 +
1174 + /* For safety, we require patch index line to contain
1175 + * full 40-byte textual SHA1 for old and new, at least for now.
1176 + */
1177 + if (strlen(patch->old_sha1_prefix) != 40 ||
1178 + strlen(patch->new_sha1_prefix) != 40 ||
1179 + get_sha1_hex(patch->old_sha1_prefix, sha1) ||
1180 + get_sha1_hex(patch->new_sha1_prefix, sha1))
1181 + return error("cannot apply binary patch to '%s' "
1182 + "without full index line", name);
1183 +
1184 + if (patch->old_name) {
1185 + unsigned char hdr[50];
1186 + int hdrlen;
1187 +
1188 + /* See if the old one matches what the patch
1189 + * applies to.
1190 + */
1191 + write_sha1_file_prepare(desc->buffer, desc->size,
1192 + "blob", sha1, hdr, &hdrlen);
1193 + if (strcmp(sha1_to_hex(sha1), patch->old_sha1_prefix))
1194 + return error("the patch applies to '%s' (%s), "
1195 + "which does not match the "
1196 + "current contents.",
1197 + name, sha1_to_hex(sha1));
1198 + }
1199 + else {
1200 + /* Otherwise, the old one must be empty. */
1201 + if (desc->size)
1202 + return error("the patch applies to an empty "
1203 + "'%s' but it is not empty", name);
1204 + }
1205 +
1206 + /* For now, we do not record post-image data in the patch,
1207 + * and require the object already present in the recipient's
1208 + * object database.
1209 + */
1210 + if (desc->buffer) {
1211 + free(desc->buffer);
1212 + desc->alloc = desc->size = 0;
1213 + }
1214 + get_sha1_hex(patch->new_sha1_prefix, sha1);
1215 +
1216 + if (memcmp(sha1, null_sha1, 20)) {
1217 + char type[10];
1218 + unsigned long size;
1219 +
1220 + desc->buffer = read_sha1_file(sha1, type, &size);
1221 + if (!desc->buffer)
1222 + return error("the necessary postimage %s for "
1223 + "'%s' does not exist",
1224 + patch->new_sha1_prefix, name);
1225 + desc->alloc = desc->size = size;
1226 + }
1227 +
1228 + return 0;
1229 + }
1230
1231 while (frag) {
1232 if (apply_one_fragment(desc, frag) < 0)
1161 - return error("patch failed: %s:%ld", patch->old_name, frag->oldpos);
1233 + return error("patch failed: %s:%ld",
1234 + name, frag->oldpos);
1235 frag = frag->next;
1236 }
1237 return 0;
@@ -1200,6 +1273,7 @@ static int check_patch(struct patch *patch)
1273 struct stat st;
1274 const char *old_name = patch->old_name;
1275 const char *new_name = patch->new_name;
1276 + const char *name = old_name ? old_name : new_name;
1277
1278 if (old_name) {
1279 int changed;
@@ -1274,7 +1348,7 @@ static int check_patch(struct patch *patch)
1348 }
1349
1350 if (apply_data(patch, &st) < 0)
1277 - return error("%s: patch does not apply", old_name);
1351 + return error("%s: patch does not apply", name);
1352 return 0;
1353 }
1354
@@ -1723,6 +1797,10 @@ int main(int argc, char **argv)
1797 diffstat = 1;
1798 continue;
1799 }
1800 + if (!strcmp(arg, "--allow-binary-replacement")) {
1801 + allow_binary_replacement = 1;
1802 + continue;
1803 + }
1804 if (!strcmp(arg, "--numstat")) {
1805 apply = 0;
1806 numstat = 1;
cache.h
+2
@@ -179,6 +179,8 @@ extern int commit_index_file(struct cache_file *);
179 extern void rollback_index_file(struct cache_file *);
180
181 extern int trust_executable_bit;
182 +extern int only_use_symrefs;
183 +extern int diff_rename_limit_default;
184
185 #define MTIME_CHANGED 0x0001
186 #define CTIME_CHANGED 0x0002
commit.c
+16 -3
@@ -204,6 +204,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
204 unsigned char parent[20];
205 struct commit_list **pptr;
206 struct commit_graft *graft;
207 + unsigned n_refs = 0;
208
209 if (item->object.parsed)
210 return 0;
@@ -214,7 +215,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
215 return error("bad tree pointer in commit %s\n", sha1_to_hex(item->object.sha1));
216 item->tree = lookup_tree(parent);
217 if (item->tree)
217 - add_ref(&item->object, &item->tree->object);
218 + n_refs++;
219 bufptr += 46; /* "tree " + "hex sha1" + "\n" */
220 pptr = &item->parents;
221
@@ -230,7 +231,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
231 new_parent = lookup_commit(parent);
232 if (new_parent) {
233 pptr = &commit_list_insert(new_parent, pptr)->next;
233 - add_ref(&item->object, &new_parent->object);
234 + n_refs++;
235 }
236 }
237 if (graft) {
@@ -241,10 +242,22 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
242 if (!new_parent)
243 continue;
244 pptr = &commit_list_insert(new_parent, pptr)->next;
244 - add_ref(&item->object, &new_parent->object);
245 + n_refs++;
246 }
247 }
248 item->date = parse_commit_date(bufptr);
249 +
250 + if (track_object_refs) {
251 + unsigned i = 0;
252 + struct commit_list *p;
253 + struct object_refs *refs = alloc_object_refs(n_refs);
254 + if (item->tree)
255 + refs->ref[i++] = &item->tree->object;
256 + for (p = item->parents; p; p = p->next)
257 + refs->ref[i++] = &p->item->object;
258 + set_object_refs(&item->object, refs);
259 + }
260 +
261 return 0;
262 }
263
config.c
+10
@@ -214,6 +214,11 @@ int git_default_config(const char *var, const char *value)
214 return 0;
215 }
216
217 + if (!strcmp(var, "core.symrefsonly")) {
218 + only_use_symrefs = git_config_bool(var, value);
219 + return 0;
220 + }
221 +
222 if (!strcmp(var, "user.name")) {
223 strncpy(git_default_name, value, sizeof(git_default_name));
224 return 0;
@@ -224,6 +229,11 @@ int git_default_config(const char *var, const char *value)
229 return 0;
230 }
231
232 + if (!strcmp(var, "diff.renamelimit")) {
233 + diff_rename_limit_default = git_config_int(var, value);
234 + return 0;
235 + }
236 +
237 /* Add other config variables here.. */
238 return 0;
239 }
daemon.c
+8 -3
@@ -594,6 +594,7 @@ int main(int argc, char **argv)
594 }
595 if (!strcmp(arg, "--inetd")) {
596 inetd_mode = 1;
597 + log_syslog = 1;
598 continue;
599 }
600 if (!strcmp(arg, "--verbose")) {
@@ -602,7 +603,6 @@ int main(int argc, char **argv)
603 }
604 if (!strcmp(arg, "--syslog")) {
605 log_syslog = 1;
605 - openlog("git-daemon", 0, LOG_DAEMON);
606 continue;
607 }
608 if (!strcmp(arg, "--export-all")) {
@@ -611,9 +611,11 @@ int main(int argc, char **argv)
611 }
612 if (!strncmp(arg, "--timeout=", 10)) {
613 timeout = atoi(arg+10);
614 + continue;
615 }
616 if (!strncmp(arg, "--init-timeout=", 15)) {
617 init_timeout = atoi(arg+15);
618 + continue;
619 }
620 if (!strcmp(arg, "--")) {
621 ok_paths = &argv[i+1];
@@ -626,10 +628,13 @@ int main(int argc, char **argv)
628 usage(daemon_usage);
629 }
630
631 + if (log_syslog)
632 + openlog("git-daemon", 0, LOG_DAEMON);
633 +
634 if (inetd_mode) {
635 fclose(stderr); //FIXME: workaround
636 return execute();
632 - } else {
633 - return serve(port);
637 }
638 +
639 + return serve(port);
640 }
debian/changelog
+6
@@ -1,3 +1,9 @@
1 +git-core (0.99.9j-0) unstable; urgency=low
2 +
3 + * GIT 0.99.9j aka 1.0rc3
4 +
5 + -- Junio C Hamano <junkio@cox.net> Wed, 16 Nov 2005 20:39:55 -0800
6 +
7 git-core (0.99.9i-0) unstable; urgency=low
8
9 * GIT 0.99.9i aka 1.0rc2
diff.c
+15 -8
@@ -13,6 +13,8 @@ static const char *diff_opts = "-pu";
13
14 static int use_size_cache;
15
16 +int diff_rename_limit_default = -1;
17 +
18 static char *quote_one(const char *str)
19 {
20 int needlen;
@@ -648,7 +650,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
650 memset(one->sha1, 0, 20);
651 }
652
651 -static void run_diff(struct diff_filepair *p)
653 +static void run_diff(struct diff_filepair *p, struct diff_options *o)
654 {
655 const char *pgm = external_diff();
656 char msg[PATH_MAX*2+300], *xfrm_msg;
@@ -711,11 +713,11 @@ static void run_diff(struct diff_filepair *p)
713
714 if (memcmp(one->sha1, two->sha1, 20)) {
715 char one_sha1[41];
716 + const char *index_fmt = o->full_index ? "index %s..%s" : "index %.7s..%.7s";
717 memcpy(one_sha1, sha1_to_hex(one->sha1), 41);
718
719 len += snprintf(msg + len, sizeof(msg) - len,
717 - "index %.7s..%.7s", one_sha1,
718 - sha1_to_hex(two->sha1));
720 + index_fmt, one_sha1, sha1_to_hex(two->sha1));
721 if (one->mode == two->mode)
722 len += snprintf(msg + len, sizeof(msg) - len,
723 " %06o", one->mode);
@@ -761,9 +763,12 @@ void diff_setup(struct diff_options *options)
763
764 int diff_setup_done(struct diff_options *options)
765 {
764 - if ((options->find_copies_harder || 0 <= options->rename_limit) &&
765 - options->detect_rename != DIFF_DETECT_COPY)
766 + if ((options->find_copies_harder &&
767 + options->detect_rename != DIFF_DETECT_COPY) ||
768 + (0 <= options->rename_limit && !options->detect_rename))
769 return -1;
770 + if (options->detect_rename && options->rename_limit < 0)
771 + options->rename_limit = diff_rename_limit_default;
772 if (options->setup & DIFF_SETUP_USE_CACHE) {
773 if (!active_cache)
774 /* read-cache does not die even when it fails
@@ -789,6 +794,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
794 options->line_termination = 0;
795 else if (!strncmp(arg, "-l", 2))
796 options->rename_limit = strtoul(arg+2, NULL, 10);
797 + else if (!strcmp(arg, "--full-index"))
798 + options->full_index = 1;
799 else if (!strcmp(arg, "--name-only"))
800 options->output_format = DIFF_FORMAT_NAME;
801 else if (!strcmp(arg, "--name-status"))
@@ -1017,7 +1024,7 @@ int diff_unmodified_pair(struct diff_filepair *p)
1024 return 0;
1025 }
1026
1020 -static void diff_flush_patch(struct diff_filepair *p)
1027 +static void diff_flush_patch(struct diff_filepair *p, struct diff_options *o)
1028 {
1029 if (diff_unmodified_pair(p))
1030 return;
@@ -1026,7 +1033,7 @@ static void diff_flush_patch(struct diff_filepair *p)
1033 (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode)))
1034 return; /* no tree diffs in patch format */
1035
1029 - run_diff(p);
1036 + run_diff(p, o);
1037 }
1038
1039 int diff_queue_is_empty(void)
@@ -1158,7 +1165,7 @@ void diff_flush(struct diff_options *options)
1165 die("internal error in diff-resolve-rename-copy");
1166 switch (diff_output_format) {
1167 case DIFF_FORMAT_PATCH:
1161 - diff_flush_patch(p);
1168 + diff_flush_patch(p, options);
1169 break;
1170 case DIFF_FORMAT_RAW:
1171 case DIFF_FORMAT_NAME_STATUS:
diff.h
+3 -1
@@ -32,7 +32,8 @@ struct diff_options {
32 const char *orderfile;
33 const char *pickaxe;
34 unsigned recursive:1,
35 - tree_in_recursive:1;
35 + tree_in_recursive:1,
36 + full_index:1;
37 int break_opt;
38 int detect_rename;
39 int find_copies_harder;
@@ -96,6 +97,7 @@ extern void diffcore_std_no_resolve(struct diff_options *);
97 " -u synonym for -p.\n" \
98 " --name-only show only names of changed files.\n" \
99 " --name-status show names and status of changed files.\n" \
100 +" --full-index show full object name on index ines.\n" \
101 " -R swap input file pairs.\n" \
102 " -B detect complete rewrites.\n" \
103 " -M detect renames.\n" \
diffcore-rename.c
+1 -1
@@ -283,7 +283,7 @@ void diffcore_rename(struct diff_options *options)
283 register_rename_src(p->one, 1);
284 }
285 if (rename_dst_nr == 0 ||
286 - (0 <= rename_limit && rename_limit < rename_dst_nr))
286 + (0 < rename_limit && rename_limit < rename_dst_nr))
287 goto cleanup; /* nothing to do */
288
289 /* We really want to cull the candidates list early
environment.c
+1
@@ -12,6 +12,7 @@
12 char git_default_email[MAX_GITNAME];
13 char git_default_name[MAX_GITNAME];
14 int trust_executable_bit = 1;
15 +int only_use_symrefs = 0;
16
17 static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
18 *git_graft_file;
fsck-objects.c
+20 -9
@@ -56,7 +56,6 @@ static void check_connectivity(void)
56 /* Look up all the requirements, warn about missing objects.. */
57 for (i = 0; i < nr_objs; i++) {
58 struct object *obj = objs[i];
59 - struct object_list *refs;
59
60 if (!obj->parsed) {
61 if (!standalone && has_sha1_file(obj->sha1))
@@ -67,14 +66,19 @@ static void check_connectivity(void)
66 continue;
67 }
68
70 - for (refs = obj->refs; refs; refs = refs->next) {
71 - if (refs->item->parsed ||
72 - (!standalone && has_sha1_file(refs->item->sha1)))
73 - continue;
74 - printf("broken link from %7s %s\n",
75 - obj->type, sha1_to_hex(obj->sha1));
76 - printf(" to %7s %s\n",
77 - refs->item->type, sha1_to_hex(refs->item->sha1));
69 + if (obj->refs) {
70 + const struct object_refs *refs = obj->refs;
71 + unsigned j;
72 + for (j = 0; j < refs->count; j++) {
73 + struct object *ref = refs->ref[j];
74 + if (ref->parsed ||
75 + (!standalone && has_sha1_file(ref->sha1)))
76 + continue;
77 + printf("broken link from %7s %s\n",
78 + obj->type, sha1_to_hex(obj->sha1));
79 + printf(" to %7s %s\n",
80 + ref->type, sha1_to_hex(ref->sha1));
81 + }
82 }
83
84 if (show_unreachable && !(obj->flags & REACHABLE)) {
@@ -184,10 +188,17 @@ static int fsck_tree(struct tree *item)
188 default:
189 break;
190 }
191 + free(last->name);
192 + free(last);
193 }
194
195 last = entry;
196 }
197 + if (last) {
198 + free(last->name);
199 + free(last);
200 + }
201 + item->entries = NULL;
202
203 retval = 0;
204 if (has_full_path) {
git-am.sh
+53 -12
@@ -3,16 +3,10 @@
3 #
4 . git-sh-setup || die "Not a git archive"
5
6 -files=$(git-diff-index --cached --name-only HEAD) || exit
7 -if [ "$files" ]; then
8 - echo "Dirty index: cannot apply patches (dirty: $files)" >&2
9 - exit 1
10 -fi
11 -
6 usage () {
7 echo >&2 "usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--3way] <mbox>"
8 echo >&2 " or, when resuming"
15 - echo >&2 " $0 [--skip]"
9 + echo >&2 " $0 [--skip | --resolved]"
10 exit 1;
11 }
12
@@ -104,7 +98,7 @@ fall_back_3way () {
98 }
99
100 prec=4
107 -dotest=.dotest sign= utf8= keep= skip= interactive=
101 +dotest=.dotest sign= utf8= keep= skip= interactive= resolved=
102
103 while case "$#" in 0) break;; esac
104 do
@@ -128,6 +122,9 @@ do
122 -k|--k|--ke|--kee|--keep)
123 keep=t; shift ;;
124
125 + -r|--r|--re|--res|--reso|--resol|--resolv|--resolve|--resolved)
126 + resolved=t; shift ;;
127 +
128 --sk|--ski|--skip)
129 skip=t; shift ;;
130
@@ -140,6 +137,8 @@ do
137 esac
138 done
139
140 +# If the dotest directory exists, but we have finished applying all the
141 +# patches in them, clear it out.
142 if test -d "$dotest" &&
143 last=$(cat "$dotest/last") &&
144 next=$(cat "$dotest/next") &&
@@ -155,9 +154,9 @@ then
154 die "previous dotest directory $dotest still exists but mbox given."
155 resume=yes
156 else
158 - # Make sure we are not given --skip
159 - test ",$skip," = ,, ||
160 - die "we are not resuming."
157 + # Make sure we are not given --skip nor --resolved
158 + test ",$skip,$resolved," = ,,, ||
159 + die "we are not resuming."
160
161 # Start afresh.
162 mkdir -p "$dotest" || exit
@@ -170,12 +169,24 @@ else
169 exit 1
170 }
171
172 + # -s, -u and -k flags are kept for the resuming session after
173 + # a patch failure.
174 + # -3 and -i can and must be given when resuming.
175 echo "$sign" >"$dotest/sign"
176 echo "$utf8" >"$dotest/utf8"
177 echo "$keep" >"$dotest/keep"
178 echo 1 >"$dotest/next"
179 fi
180
181 +case "$resolved" in
182 +'')
183 + files=$(git-diff-index --cached --name-only HEAD) || exit
184 + if [ "$files" ]; then
185 + echo "Dirty index: cannot apply patches (dirty: $files)" >&2
186 + exit 1
187 + fi
188 +esac
189 +
190 if test "$(cat "$dotest/utf8")" = t
191 then
192 utf8=-u
@@ -216,6 +227,15 @@ do
227 go_next
228 continue
229 }
230 +
231 + # If we are not resuming, parse and extract the patch information
232 + # into separate files:
233 + # - info records the authorship and title
234 + # - msg is the rest of commit log message
235 + # - patch is the patch body.
236 + #
237 + # When we are resuming, these files are either already prepared
238 + # by the user, or the user can tell us to do so by --resolved flag.
239 case "$resume" in
240 '')
241 git-mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \
@@ -263,6 +283,13 @@ do
283 fi
284 } >"$dotest/final-commit"
285 ;;
286 + *)
287 + case "$resolved,$interactive" in
288 + tt)
289 + # This is used only for interactive view option.
290 + git-diff-index -p --cached HEAD >"$dotest/patch"
291 + ;;
292 + esac
293 esac
294
295 resume=
@@ -310,7 +337,21 @@ do
337 echo "Applying '$SUBJECT'"
338 echo
339
313 - git-apply --index "$dotest/patch"; apply_status=$?
340 + case "$resolved" in
341 + '')
342 + git-apply --index "$dotest/patch"
343 + apply_status=$?
344 + ;;
345 + t)
346 + # Resolved means the user did all the hard work, and
347 + # we do not have to do any patch application. Just
348 + # trust what the user has in the index file and the
349 + # working tree.
350 + resolved=
351 + apply_status=0
352 + ;;
353 + esac
354 +
355 if test $apply_status = 1 && test "$threeway" = t
356 then
357 if (fall_back_3way)
git-archimport.perl
+1 -2
@@ -410,8 +410,7 @@ foreach my $ps (@psets) {
410 open HEAD, ">$git_dir/refs/heads/$ps->{branch}";
411 print HEAD $commitid;
412 close HEAD;
413 - unlink ("$git_dir/HEAD");
414 - symlink("refs/heads/$ps->{branch}","$git_dir/HEAD");
413 + system('git-update-ref', 'HEAD', "$ps->{branch}");
414
415 # tag accordingly
416 ptag($ps->{id}, $commitid); # private tag
git-cvsexportcommit.perl
+6 -6
@@ -4,6 +4,7 @@ use strict;
4 use Getopt::Std;
5 use File::Temp qw(tempdir);
6 use Data::Dumper;
7 +use File::Basename qw(basename);
8
9 unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){
10 die "GIT_DIR is not defined or is unreadable";
@@ -11,7 +12,7 @@ unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){
12
13 our ($opt_h, $opt_p, $opt_v, $opt_c );
14
14 -getopt('hpvc');
15 +getopts('hpvc');
16
17 $opt_h && usage();
18
@@ -77,7 +78,7 @@ $opt_v && print "Applying to CVS commit $commit from parent $parent\n";
78
79 # grab the commit message
80 `git-cat-file commit $commit | sed -e '1,/^\$/d' > .msg`;
80 -$? && die "Error extraction the commit message";
81 +$? && die "Error extracting the commit message";
82
83 my (@afiles, @dfiles, @mfiles);
84 my @files = `git-diff-tree -r $parent $commit`;
@@ -187,9 +188,9 @@ my $cmd = "cvs commit -F .msg $commitfiles";
188
189 if ($dirtypatch) {
190 print "NOTE: One or more hunks failed to apply cleanly.\n";
190 - print "Resolve the conflicts and then commit using:n";
191 + print "Resolve the conflicts and then commit using:\n";
192 print "\n $cmd\n\n";
192 - exit;
193 + exit(1);
194 }
195
196
@@ -206,8 +207,7 @@ if ($opt_c) {
207 }
208 sub usage {
209 print STDERR <<END;
209 -Usage: GIT_DIR=/path/to/.gi ${\basename $0} # fetch/update GIT from CVS
210 - [-h] [-p] [ parent ] commit
210 +Usage: GIT_DIR=/path/to/.git ${\basename $0} [-h] [-p] [-v] [-c] [ parent ] commit
211 END
212 exit(1);
213 }
git-cvsimport.perl
+6 -3
@@ -437,7 +437,11 @@ unless(-d $git_dir) {
437 "Either use the correct '-o branch' option,\n".
438 "or import to a new repository.\n";
439
440 - $last_branch = basename(readlink("$git_dir/HEAD"));
440 + open(F, "git-symbolic-ref HEAD |") or
441 + die "Cannot run git-symbolic-ref: $!\n";
442 + chomp ($last_branch = <F>);
443 + $last_branch = basename($last_branch);
444 + close(F);
445 unless($last_branch) {
446 warn "Cannot read the last branch name: $! -- assuming 'master'\n";
447 $last_branch = "master";
@@ -829,8 +833,7 @@ if($orig_branch) {
833 print "DONE; creating $orig_branch branch\n" if $opt_v;
834 system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
835 unless -f "$git_dir/refs/heads/master";
832 - unlink("$git_dir/HEAD");
833 - symlink("refs/heads/$orig_branch","$git_dir/HEAD");
836 + system('git-update-ref', 'HEAD', "$orig_branch");
837 unless ($opt_i) {
838 system('git checkout');
839 die "checkout failed: $?\n" if $?;
git-grep.sh
+4
@@ -39,5 +39,9 @@ while : ; do
39 esac
40 shift
41 done
42 +[ "$pattern" ] || {
43 + echo >&2 "usage: 'git grep <pattern> [pathspec*]'"
44 + exit 1
45 +}
46 git-ls-files -z "${git_flags[@]}" "$@" |
47 xargs -0 grep "${flags[@]}" -e "$pattern"
git-merge-recursive.py
+4 -2
@@ -3,11 +3,13 @@
3 # Copyright (C) 2005 Fredrik Kuivinen
4 #
5
6 -import sys, math, random, os, re, signal, tempfile, stat, errno, traceback
6 +import sys
7 +sys.path.append('''@@GIT_PYTHON_PATH@@''')
8 +
9 +import math, random, os, re, signal, tempfile, stat, errno, traceback
10 from heapq import heappush, heappop
11 from sets import Set
12
10 -sys.path.append('''@@GIT_PYTHON_PATH@@''')
13 from gitMergeCommon import *
14
15 outputIndent = 0
git-svnimport.perl
+6 -3
@@ -216,7 +216,11 @@ unless(-d $git_dir) {
216 -f "$git_dir/svn2git"
217 or die "'$git_dir/svn2git' does not exist.\n".
218 "You need that file for incremental imports.\n";
219 - $last_branch = basename(readlink("$git_dir/HEAD"));
219 + open(F, "git-symbolic-ref HEAD |") or
220 + die "Cannot run git-symbolic-ref: $!\n";
221 + chomp ($last_branch = <F>);
222 + $last_branch = basename($last_branch);
223 + close(F);
224 unless($last_branch) {
225 warn "Cannot read the last branch name: $! -- assuming 'master'\n";
226 $last_branch = "master";
@@ -766,8 +770,7 @@ if($orig_branch) {
770 print "DONE; creating $orig_branch branch\n" if $opt_v and (not defined $opt_l or $opt_l > 0);
771 system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
772 unless -f "$git_dir/refs/heads/master";
769 - unlink("$git_dir/HEAD");
770 - symlink("refs/heads/$orig_branch","$git_dir/HEAD");
773 + system('git-update-ref', 'HEAD', "$orig_branch");
774 unless ($opt_i) {
775 system('git checkout');
776 die "checkout failed: $?\n" if $?;
git.c new
+295
@@ -0,0 +1,295 @@
1 +#include <stdio.h>
2 +#include <sys/types.h>
3 +#include <sys/stat.h>
4 +#include <dirent.h>
5 +#include <unistd.h>
6 +#include <stdlib.h>
7 +#include <string.h>
8 +#include <errno.h>
9 +#include <limits.h>
10 +#include <stdarg.h>
11 +
12 +#ifndef PATH_MAX
13 +# define PATH_MAX 4096
14 +#endif
15 +
16 +static const char git_usage[] =
17 + "Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
18 +
19 +/* most gui terms set COLUMNS (although some don't export it) */
20 +static int term_columns(void)
21 +{
22 + char *col_string = getenv("COLUMNS");
23 + int n_cols = 0;
24 +
25 + if (col_string && (n_cols = atoi(col_string)) > 0)
26 + return n_cols;
27 +
28 + return 80;
29 +}
30 +
31 +static void oom(void)
32 +{
33 + fprintf(stderr, "git: out of memory\n");
34 + exit(1);
35 +}
36 +
37 +static inline void mput_char(char c, unsigned int num)
38 +{
39 + while(num--)
40 + putchar(c);
41 +}
42 +
43 +static struct cmdname {
44 + size_t len;
45 + char name[1];
46 +} **cmdname;
47 +static int cmdname_alloc, cmdname_cnt;
48 +
49 +static void add_cmdname(const char *name, int len)
50 +{
51 + struct cmdname *ent;
52 + if (cmdname_alloc <= cmdname_cnt) {
53 + cmdname_alloc = cmdname_alloc + 200;
54 + cmdname = realloc(cmdname, cmdname_alloc * sizeof(*cmdname));
55 + if (!cmdname)
56 + oom();
57 + }
58 + ent = malloc(sizeof(*ent) + len);
59 + if (!ent)
60 + oom();
61 + ent->len = len;
62 + memcpy(ent->name, name, len+1);
63 + cmdname[cmdname_cnt++] = ent;
64 +}
65 +
66 +static int cmdname_compare(const void *a_, const void *b_)
67 +{
68 + struct cmdname *a = *(struct cmdname **)a_;
69 + struct cmdname *b = *(struct cmdname **)b_;
70 + return strcmp(a->name, b->name);
71 +}
72 +
73 +static void pretty_print_string_list(struct cmdname **cmdname, int longest)
74 +{
75 + int cols = 1;
76 + int space = longest + 1; /* min 1 SP between words */
77 + int max_cols = term_columns() - 1; /* don't print *on* the edge */
78 + int i;
79 +
80 + if (space < max_cols)
81 + cols = max_cols / space;
82 +
83 + qsort(cmdname, cmdname_cnt, sizeof(*cmdname), cmdname_compare);
84 +
85 + for (i = 0; i < cmdname_cnt; ) {
86 + int c;
87 + printf(" ");
88 +
89 + for (c = cols; c && i < cmdname_cnt; i++) {
90 + printf("%s", cmdname[i]->name);
91 +
92 + if (--c)
93 + mput_char(' ', space - cmdname[i]->len);
94 + }
95 + putchar('\n');
96 + }
97 +}
98 +
99 +static void list_commands(const char *exec_path, const char *pattern)
100 +{
101 + unsigned int longest = 0;
102 + char path[PATH_MAX];
103 + int dirlen;
104 + DIR *dir = opendir(exec_path);
105 + struct dirent *de;
106 +
107 + if (!dir) {
108 + fprintf(stderr, "git: '%s': %s\n", exec_path, strerror(errno));
109 + exit(1);
110 + }
111 +
112 + dirlen = strlen(exec_path);
113 + if (PATH_MAX - 20 < dirlen) {
114 + fprintf(stderr, "git: insanely long exec-path '%s'\n",
115 + exec_path);
116 + exit(1);
117 + }
118 +
119 + memcpy(path, exec_path, dirlen);
120 + path[dirlen++] = '/';
121 +
122 + while ((de = readdir(dir)) != NULL) {
123 + struct stat st;
124 + int entlen;
125 +
126 + if (strncmp(de->d_name, "git-", 4))
127 + continue;
128 + strcpy(path+dirlen, de->d_name);
129 + if (stat(path, &st) || /* stat, not lstat */
130 + !S_ISREG(st.st_mode) ||
131 + !(st.st_mode & S_IXUSR))
132 + continue;
133 +
134 + entlen = strlen(de->d_name);
135 +
136 + if (longest < entlen)
137 + longest = entlen;
138 +
139 + add_cmdname(de->d_name + 4, entlen-4);
140 + }
141 + closedir(dir);
142 +
143 + printf("git commands available in '%s'\n", exec_path);
144 + printf("----------------------------");
145 + mput_char('-', strlen(exec_path));
146 + putchar('\n');
147 + pretty_print_string_list(cmdname, longest - 4);
148 + putchar('\n');
149 +}
150 +
151 +#ifdef __GNUC__
152 +static void usage(const char *exec_path, const char *fmt, ...)
153 + __attribute__((__format__(__printf__, 2, 3), __noreturn__));
154 +#endif
155 +static void usage(const char *exec_path, const char *fmt, ...)
156 +{
157 + if (fmt) {
158 + va_list ap;
159 +
160 + va_start(ap, fmt);
161 + printf("git: ");
162 + vprintf(fmt, ap);
163 + va_end(ap);
164 + putchar('\n');
165 + }
166 + else
167 + puts(git_usage);
168 +
169 + putchar('\n');
170 +
171 + if(exec_path)
172 + list_commands(exec_path, "git-*");
173 +
174 + exit(1);
175 +}
176 +
177 +static void prepend_to_path(const char *dir, int len)
178 +{
179 + char *path, *old_path = getenv("PATH");
180 + int path_len = len;
181 +
182 + if (!old_path)
183 + old_path = "/usr/local/bin:/usr/bin:/bin";
184 +
185 + path_len = len + strlen(old_path) + 1;
186 +
187 + path = malloc(path_len + 1);
188 + path[path_len + 1] = '\0';
189 +
190 + memcpy(path, dir, len);
191 + path[len] = ':';
192 + memcpy(path + len + 1, old_path, path_len - len);
193 +
194 + setenv("PATH", path, 1);
195 +}
196 +
197 +static void show_man_page(char *git_cmd)
198 +{
199 + char *page;
200 +
201 + if (!strncmp(git_cmd, "git", 3))
202 + page = git_cmd;
203 + else {
204 + int page_len = strlen(git_cmd) + 4;
205 +
206 + page = malloc(page_len + 1);
207 + strcpy(page, "git-");
208 + strcpy(page + 4, git_cmd);
209 + page[page_len] = 0;
210 + }
211 +
212 + execlp("man", "man", page, NULL);
213 +}
214 +
215 +int main(int argc, char **argv, char **envp)
216 +{
217 + char git_command[PATH_MAX + 1];
218 + char wd[PATH_MAX + 1];
219 + int i, len, show_help = 0;
220 + char *exec_path = getenv("GIT_EXEC_PATH");
221 +
222 + getcwd(wd, PATH_MAX);
223 +
224 + if (!exec_path)
225 + exec_path = GIT_EXEC_PATH;
226 +
227 + for (i = 1; i < argc; i++) {
228 + char *arg = argv[i];
229 +
230 + if (strncmp(arg, "--", 2))
231 + break;
232 +
233 + arg += 2;
234 +
235 + if (!strncmp(arg, "exec-path", 9)) {
236 + arg += 9;
237 + if (*arg == '=')
238 + exec_path = arg + 1;
239 + else {
240 + puts(exec_path);
241 + exit(0);
242 + }
243 + }
244 + else if (!strcmp(arg, "version")) {
245 + printf("git version %s\n", GIT_VERSION);
246 + exit(0);
247 + }
248 + else if (!strcmp(arg, "help"))
249 + show_help = 1;
250 + else if (!show_help)
251 + usage(NULL, NULL);
252 + }
253 +
254 + if (i >= argc || show_help) {
255 + if (i >= argc)
256 + usage(exec_path, NULL);
257 +
258 + show_man_page(argv[i]);
259 + }
260 +
261 + if (*exec_path != '/') {
262 + if (!getcwd(git_command, sizeof(git_command))) {
263 + fprintf(stderr,
264 + "git: cannot determine current directory");
265 + exit(1);
266 + }
267 + len = strlen(git_command);
268 +
269 + /* Trivial cleanup */
270 + while (!strncmp(exec_path, "./", 2)) {
271 + exec_path += 2;
272 + while (*exec_path == '/')
273 + *exec_path++;
274 + }
275 + snprintf(git_command + len, sizeof(git_command) - len,
276 + "/%s", exec_path);
277 + }
278 + else
279 + strcpy(git_command, exec_path);
280 + len = strlen(git_command);
281 + prepend_to_path(git_command, len);
282 +
283 + strncat(&git_command[len], "/git-", sizeof(git_command) - len);
284 + len += 5;
285 + strncat(&git_command[len], argv[i], sizeof(git_command) - len);
286 +
287 + if (access(git_command, X_OK))
288 + usage(exec_path, "'%s' is not a git-command", argv[i]);
289 +
290 + /* execve() can only ever return if it fails */
291 + execve(git_command, &argv[i], envp);
292 + printf("Failed to run command '%s': %s\n", git_command, strerror(errno));
293 +
294 + return 1;
295 +}
git.sh deleted
-76
@@ -1,76 +0,0 @@
1 -#!/bin/sh
2 -
3 -cmd=
4 -path=$(dirname "$0")
5 -case "$#" in
6 -0) ;;
7 -*) cmd="$1"
8 - shift
9 - case "$cmd" in
10 - -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
11 - echo "git version @@GIT_VERSION@@"
12 - exit 0 ;;
13 - esac
14 -
15 - test -x "$path/git-$cmd" && exec "$path/git-$cmd" "$@"
16 -
17 - case '@@X@@' in
18 - '')
19 - ;;
20 - *)
21 - test -x "$path/git-$cmd@@X@@" &&
22 - exec "$path/git-$cmd@@X@@" "$@"
23 - ;;
24 - esac
25 - ;;
26 -esac
27 -
28 -echo "Usage: git COMMAND [OPTIONS] [TARGET]"
29 -if [ -n "$cmd" ]; then
30 - echo "git command '$cmd' not found."
31 -fi
32 -echo "git commands are:"
33 -
34 -fmt <<\EOF | sed -e 's/^/ /'
35 -add
36 -apply
37 -archimport
38 -bisect
39 -branch
40 -checkout
41 -cherry
42 -clone
43 -commit
44 -count-objects
45 -cvsimport
46 -diff
47 -fetch
48 -format-patch
49 -fsck-objects
50 -get-tar-commit-id
51 -init-db
52 -log
53 -ls-remote
54 -octopus
55 -pack-objects
56 -parse-remote
57 -patch-id
58 -prune
59 -pull
60 -push
61 -rebase
62 -relink
63 -rename
64 -repack
65 -request-pull
66 -reset
67 -resolve
68 -revert
69 -send-email
70 -shortlog
71 -show-branch
72 -status
73 -tag
74 -verify-tag
75 -whatchanged
76 -EOF
git.spec.in renamed
+30 -6
@@ -1,5 +1,5 @@
1 # Pass --without docs to rpmbuild if you don't want the documentation
2 -Name: git-core
2 +Name: git
3 Version: @@VERSION@@
4 Release: 1%{?dist}
5 Summary: Git core and tools
@@ -9,7 +9,7 @@ URL: http://kernel.org/pub/software/scm/git/
9 Source: http://kernel.org/pub/software/scm/git/%{name}-%{version}.tar.gz
10 BuildRequires: zlib-devel >= 1.2, openssl-devel, curl-devel, expat-devel %{!?_without_docs:, xmlto, asciidoc > 6.0.3}
11 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
12 -Requires: zlib >= 1.2, rsync, rcs, curl, less, openssh-clients, python >= 2.3, expat
12 +Requires: git-core, git-svn, git-cvs, git-arch, git-email, gitk
13
14 %description
15 This is a stupid (but extremely fast) directory content manager. It
@@ -19,6 +19,22 @@ distributed source code management system. This package includes
19 rudimentary tools that can be used as a SCM, but you should look
20 elsewhere for tools for ordinary humans layered on top of this.
21
22 +This is a dummy package which brings in all subpackages.
23 +
24 +%package core
25 +Summary: Core git tools
26 +Group: Development/Tools
27 +Requires: zlib >= 1.2, rsync, rcs, curl, less, openssh-clients, python >= 2.3, expat
28 +%description core
29 +This is a stupid (but extremely fast) directory content manager. It
30 +doesn't do a whole lot, but what it _does_ do is track directory
31 +contents efficiently. It is intended to be the base of an efficient,
32 +distributed source code management system. This package includes
33 +rudimentary tools that can be used as a SCM, but you should look
34 +elsewhere for tools for ordinary humans layered on top of this.
35 +
36 +These are the core tools with minimal dependencies.
37 +
38 %package svn
39 Summary: Git tools for importing Subversion repositories
40 Group: Development/Tools
@@ -47,11 +63,11 @@ Requires: git-core = %{version}-%{release}
63 %description email
64 Git tools for sending email.
65
50 -%package tk
66 +%package -n gitk
67 Summary: Git revision tree visualiser ('gitk')
68 Group: Development/Tools
69 Requires: git-core = %{version}-%{release}, tk >= 8.4
54 -%description tk
70 +%description -n gitk
71 Git revision tree visualiser ('gitk')
72
73 %prep
@@ -75,6 +91,9 @@ make %{_smp_mflags} DESTDIR=$RPM_BUILD_ROOT WITH_OWN_SUBPROCESS_PY=YesPlease WIT
91 %clean
92 rm -rf $RPM_BUILD_ROOT
93
94 +%files
95 +# These are no files in the root package
96 +
97 %files svn
98 %defattr(-,root,root)
99 %{_bindir}/*svn*
@@ -103,20 +122,25 @@ rm -rf $RPM_BUILD_ROOT
122 %{!?_without_docs: %{_mandir}/man1/*email*.1*}
123 %{!?_without_docs: %doc Documentation/*email*.html }
124
106 -%files tk
125 +%files -n gitk
126 %defattr(-,root,root)
127 %doc Documentation/*gitk*.txt
128 %{_bindir}/*gitk*
129 %{!?_without_docs: %{_mandir}/man1/*gitk*.1*}
130 %{!?_without_docs: %doc Documentation/*gitk*.html }
131
113 -%files -f bin-man-doc-files
132 +%files core -f bin-man-doc-files
133 %defattr(-,root,root)
134 %{_datadir}/git-core/
135 %doc README COPYING Documentation/*.txt
136 %{!?_without_docs: %doc Documentation/*.html }
137
138 %changelog
139 +* Mon Nov 14 2005 H. Peter Anvin <hpa@zytor.com> 0.99.9j-1
140 +- Change subpackage names to git-<name> instead of git-core-<name>
141 +- Create empty root package which brings in all subpackages
142 +- Rename git-tk -> gitk
143 +
144 * Thu Nov 10 2005 Chris Wright <chrisw@osdl.org> 0.99.9g-1
145 - zlib dependency fix
146 - Minor cleanups from split
http-fetch.c
+14 -2
@@ -425,6 +425,8 @@ static void start_request(struct transfer_request *request)
425 rename(request->tmpfile, prevfile);
426 unlink(request->tmpfile);
427
428 + if (request->local != -1)
429 + error("fd leakage in start: %d", request->local);
430 request->local = open(request->tmpfile,
431 O_WRONLY | O_CREAT | O_EXCL, 0666);
432 /* This could have failed due to the "lazy directory creation";
@@ -523,7 +525,7 @@ static void start_request(struct transfer_request *request)
525 /* Try to get the request started, abort the request on error */
526 if (!start_active_slot(slot)) {
527 request->state = ABORTED;
526 - close(request->local);
528 + close(request->local); request->local = -1;
529 free(request->url);
530 return;
531 }
@@ -537,7 +539,7 @@ static void finish_request(struct transfer_request *request)
539 struct stat st;
540
541 fchmod(request->local, 0444);
540 - close(request->local);
542 + close(request->local); request->local = -1;
543
544 if (request->http_code == 416) {
545 fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
@@ -569,6 +571,8 @@ static void release_request(struct transfer_request *request)
571 {
572 struct transfer_request *entry = request_queue_head;
573
574 + if (request->local != -1)
575 + error("fd leakage in release: %d", request->local);
576 if (request == request_queue_head) {
577 request_queue_head = request->next;
578 } else {
@@ -631,6 +635,8 @@ static void process_curl_messages(void)
635 if (request->repo->next != NULL) {
636 request->repo =
637 request->repo->next;
638 + close(request->local);
639 + request->local = -1;
640 start_request(request);
641 } else {
642 finish_request(request);
@@ -763,6 +769,7 @@ static int fetch_index(struct alt_base *repo, unsigned char *sha1)
769 curl_errorstr);
770 }
771 } else {
772 + fclose(indexfile);
773 return error("Unable to start request");
774 }
775
@@ -1083,6 +1090,7 @@ static int fetch_pack(struct alt_base *repo, unsigned char *sha1)
1090 curl_errorstr);
1091 }
1092 } else {
1093 + fclose(packfile);
1094 return error("Unable to start request");
1095 }
1096
@@ -1145,6 +1153,7 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
1153 fetch_alternates(alt->base);
1154 if (request->repo->next != NULL) {
1155 request->repo = request->repo->next;
1156 + close(request->local); request->local = -1;
1157 start_request(request);
1158 }
1159 } else {
@@ -1153,6 +1162,9 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
1162 }
1163 #endif
1164 }
1165 + if (request->local != -1) {
1166 + close(request->local); request->local = -1;
1167 + }
1168
1169 if (request->state == ABORTED) {
1170 release_request(request);
object.c
+44 -18
@@ -67,40 +67,66 @@ void created_object(const unsigned char *sha1, struct object *obj)
67 nr_objs++;
68 }
69
70 -void add_ref(struct object *refer, struct object *target)
70 +struct object_refs *alloc_object_refs(unsigned count)
71 {
72 - struct object_list **pp, *p;
72 + struct object_refs *refs;
73 + size_t size = sizeof(*refs) + count*sizeof(struct object *);
74
74 - if (!track_object_refs)
75 + refs = xmalloc(size);
76 + memset(refs, 0, size);
77 + refs->count = count;
78 + return refs;
79 +}
80 +
81 +static int compare_object_pointers(const void *a, const void *b)
82 +{
83 + const struct object * const *pa = a;
84 + const struct object * const *pb = b;
85 + return *pa - *pb;
86 +}
87 +
88 +void set_object_refs(struct object *obj, struct object_refs *refs)
89 +{
90 + unsigned int i, j;
91 +
92 + /* Do not install empty list of references */
93 + if (refs->count < 1) {
94 + free(refs);
95 return;
96 + }
97
77 - pp = &refer->refs;
78 - while ((p = *pp) != NULL) {
79 - if (p->item == target)
80 - return;
81 - pp = &p->next;
98 + /* Sort the list and filter out duplicates */
99 + qsort(refs->ref, refs->count, sizeof(refs->ref[0]),
100 + compare_object_pointers);
101 + for (i = j = 1; i < refs->count; i++) {
102 + if (refs->ref[i] != refs->ref[i - 1])
103 + refs->ref[j++] = refs->ref[i];
104 + }
105 + if (j < refs->count) {
106 + /* Duplicates were found - reallocate list */
107 + size_t size = sizeof(*refs) + j*sizeof(struct object *);
108 + refs->count = j;
109 + refs = xrealloc(refs, size);
110 }
111
84 - target->used = 1;
85 - p = xmalloc(sizeof(*p));
86 - p->item = target;
87 - p->next = NULL;
88 - *pp = p;
112 + for (i = 0; i < refs->count; i++)
113 + refs->ref[i]->used = 1;
114 + obj->refs = refs;
115 }
116
117 void mark_reachable(struct object *obj, unsigned int mask)
118 {
93 - struct object_list *p = obj->refs;
94 -
119 if (!track_object_refs)
120 die("cannot do reachability with object refs turned off");
121 /* If we've been here already, don't bother */
122 if (obj->flags & mask)
123 return;
124 obj->flags |= mask;
101 - while (p) {
102 - mark_reachable(p->item, mask);
103 - p = p->next;
125 + if (obj->refs) {
126 + const struct object_refs *refs = obj->refs;
127 + unsigned i;
128 + for (i = 0; i < refs->count; i++)
129 + mark_reachable(refs->ref[i], mask);
130 }
131 }
132
object.h
+8 -2
@@ -7,13 +7,18 @@ struct object_list {
7 const char *name;
8 };
9
10 +struct object_refs {
11 + unsigned count;
12 + struct object *ref[0];
13 +};
14 +
15 struct object {
16 unsigned parsed : 1;
17 unsigned used : 1;
18 unsigned int flags;
19 unsigned char sha1[20];
20 const char *type;
16 - struct object_list *refs;
21 + struct object_refs *refs;
22 void *util;
23 };
24
@@ -35,7 +40,8 @@ struct object *parse_object(const unsigned char *sha1);
40 /** Returns the object, with potentially excess memory allocated. **/
41 struct object *lookup_unknown_object(const unsigned char *sha1);
42
38 -void add_ref(struct object *refer, struct object *target);
43 +struct object_refs *alloc_object_refs(unsigned count);
44 +void set_object_refs(struct object *obj, struct object_refs *refs);
45
46 void mark_reachable(struct object *obj, unsigned int mask);
47
pack-redundant.c
+15 -32
@@ -127,38 +127,6 @@ inline struct llist_item * llist_insert_sorted_unique(struct llist *list,
127 return llist_insert_back(list, sha1);
128 }
129
130 -/* computes A\B */
131 -void llist_sorted_difference_inplace(struct llist *A,
132 - struct llist *B)
133 -{
134 - struct llist_item *prev, *a, *b, *x;
135 -
136 - prev = a = A->front;
137 - b = B->front;
138 -
139 - while (a != NULL && b != NULL) {
140 - int cmp = memcmp(a->sha1, b->sha1, 20);
141 - if (!cmp) {
142 - x = a;
143 - if (a == A->front)
144 - A->front = a->next;
145 - a = prev->next = a->next;
146 -
147 - if (a == NULL) /* end of list */
148 - A->back = prev;
149 - A->size--;
150 - free(x);
151 - b = b->next;
152 - } else
153 - if (cmp > 0)
154 - b = b->next;
155 - else {
156 - prev = a;
157 - a = a->next;
158 - }
159 - }
160 -}
161 -
130 /* returns a pointer to an item in front of sha1 */
131 inline struct llist_item * llist_sorted_remove(struct llist *list, char *sha1,
132 struct llist_item *hint)
@@ -194,6 +162,21 @@ redo_from_start:
162 return prev;
163 }
164
165 +/* computes A\B */
166 +void llist_sorted_difference_inplace(struct llist *A,
167 + struct llist *B)
168 +{
169 + struct llist_item *hint, *b;
170 +
171 + hint = NULL;
172 + b = B->front;
173 +
174 + while (b) {
175 + hint = llist_sorted_remove(A, b->sha1, hint);
176 + b = b->next;
177 + }
178 +}
179 +
180 inline struct pack_list * pack_list_insert(struct pack_list **pl,
181 struct pack_list *entry)
182 {
refs.c
+6 -4
@@ -121,10 +121,12 @@ int create_symref(const char *git_HEAD, const char *refs_heads_master)
121 int fd, len, written;
122
123 #if USE_SYMLINK_HEAD
124 - unlink(git_HEAD);
125 - if (!symlink(refs_heads_master, git_HEAD))
126 - return 0;
127 - fprintf(stderr, "no symlink - falling back to symbolic ref\n");
124 + if (!only_use_symrefs) {
125 + unlink(git_HEAD);
126 + if (!symlink(refs_heads_master, git_HEAD))
127 + return 0;
128 + fprintf(stderr, "no symlink - falling back to symbolic ref\n");
129 + }
130 #endif
131
132 len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
server-info.c
+18 -7
@@ -424,7 +424,6 @@ static void find_pack_info_one(int pack_ix)
424 {
425 unsigned char sha1[20];
426 struct object *o;
427 - struct object_list *ref;
427 int i;
428 struct packed_git *p = info[pack_ix]->p;
429 int num = num_packed_objects(p);
@@ -437,8 +436,12 @@ static void find_pack_info_one(int pack_ix)
436 die("corrupt pack file %s?", p->pack_name);
437 if ((o = lookup_object(sha1)) == NULL)
438 die("cannot parse %s", sha1_to_hex(sha1));
440 - for (ref = o->refs; ref; ref = ref->next)
441 - ref->item->flags = 0;
439 + if (o->refs) {
440 + struct object_refs *refs = o->refs;
441 + int j;
442 + for (j = 0; j < refs->count; j++)
443 + refs->ref[j]->flags = 0;
444 + }
445 o->flags = 0;
446 }
447
@@ -448,8 +451,12 @@ static void find_pack_info_one(int pack_ix)
451 die("corrupt pack file %s?", p->pack_name);
452 if ((o = lookup_object(sha1)) == NULL)
453 die("cannot find %s", sha1_to_hex(sha1));
451 - for (ref = o->refs; ref; ref = ref->next)
452 - ref->item->flags |= REFERENCED;
454 + if (o->refs) {
455 + struct object_refs *refs = o->refs;
456 + int j;
457 + for (j = 0; j < refs->count; j++)
458 + refs->ref[j]->flags |= REFERENCED;
459 + }
460 o->flags |= INTERNAL;
461 }
462
@@ -460,8 +467,12 @@ static void find_pack_info_one(int pack_ix)
467 die("cannot find %s", sha1_to_hex(sha1));
468
469 show(o, pack_ix);
463 - for (ref = o->refs; ref; ref = ref->next)
464 - show(ref->item, pack_ix);
470 + if (o->refs) {
471 + struct object_refs *refs = o->refs;
472 + int j;
473 + for (j = 0; j < refs->count; j++)
474 + show(refs->ref[j], pack_ix);
475 + }
476 }
477
478 }
sha1_file.c
+1 -1
@@ -424,7 +424,7 @@ struct packed_git *add_packed_git(char *path, int path_len, int local)
424 struct packed_git *p;
425 unsigned long idx_size;
426 void *idx_map;
427 - char sha1[20];
427 + unsigned char sha1[20];
428
429 if (check_packed_git_idx(path, &idx_size, &idx_map))
430 return NULL;
symbolic-ref.c
+1
@@ -20,6 +20,7 @@ static void check_symref(const char *HEAD)
20 int main(int argc, const char **argv)
21 {
22 setup_git_directory();
23 + git_config(git_default_config);
24 switch (argc) {
25 case 2:
26 check_symref(argv[1]);
t/t4103-apply-binary.sh new
+115
@@ -0,0 +1,115 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2005 Junio C Hamano
4 +#
5 +
6 +test_description='git-apply handling binary patches
7 +
8 +'
9 +. ./test-lib.sh
10 +
11 +# setup
12 +
13 +cat >file1 <<EOF
14 +A quick brown fox jumps over the lazy dog.
15 +A tiny little penguin runs around in circles.
16 +There is a flag with Linux written on it.
17 +A slow black-and-white panda just sits there,
18 +munching on his bamboo.
19 +EOF
20 +cat file1 >file2
21 +cat file1 >file4
22 +
23 +git-update-index --add --remove file1 file2 file4
24 +git-commit -m 'Initial Version' 2>/dev/null
25 +
26 +git-checkout -b binary
27 +tr 'x' '\0' <file1 >file3
28 +cat file3 >file4
29 +git-add file2
30 +tr '\0' 'v' <file3 >file1
31 +rm -f file2
32 +git-update-index --add --remove file1 file2 file3 file4
33 +git-commit -m 'Second Version'
34 +
35 +git-diff-tree -p master binary >B.diff
36 +git-diff-tree -p -C master binary >C.diff
37 +
38 +git-diff-tree -p --full-index master binary >BF.diff
39 +git-diff-tree -p --full-index -C master binary >CF.diff
40 +
41 +test_expect_success 'stat binary diff -- should not fail.' \
42 + 'git-checkout master
43 + git-apply --stat --summary B.diff'
44 +
45 +test_expect_success 'stat binary diff (copy) -- should not fail.' \
46 + 'git-checkout master
47 + git-apply --stat --summary C.diff'
48 +
49 +test_expect_failure 'check binary diff -- should fail.' \
50 + 'git-checkout master
51 + git-apply --check B.diff'
52 +
53 +test_expect_failure 'check binary diff (copy) -- should fail.' \
54 + 'git-checkout master
55 + git-apply --check C.diff'
56 +
57 +test_expect_failure 'check incomplete binary diff with replacement -- should fail.' \
58 + 'git-checkout master
59 + git-apply --check --allow-binary-replacement B.diff'
60 +
61 +test_expect_failure 'check incomplete binary diff with replacement (copy) -- should fail.' \
62 + 'git-checkout master
63 + git-apply --check --allow-binary-replacement C.diff'
64 +
65 +test_expect_success 'check binary diff with replacement.' \
66 + 'git-checkout master
67 + git-apply --check --allow-binary-replacement BF.diff'
68 +
69 +test_expect_success 'check binary diff with replacement (copy).' \
70 + 'git-checkout master
71 + git-apply --check --allow-binary-replacement CF.diff'
72 +
73 +# Now we start applying them.
74 +
75 +do_reset () {
76 + rm -f file?
77 + git-reset --hard
78 + git-checkout -f master
79 +}
80 +
81 +test_expect_failure 'apply binary diff -- should fail.' \
82 + 'do_reset
83 + git-apply B.diff'
84 +
85 +test_expect_failure 'apply binary diff -- should fail.' \
86 + 'do_reset
87 + git-apply --index B.diff'
88 +
89 +test_expect_failure 'apply binary diff (copy) -- should fail.' \
90 + 'do_reset
91 + git-apply C.diff'
92 +
93 +test_expect_failure 'apply binary diff (copy) -- should fail.' \
94 + 'do_reset
95 + git-apply --index C.diff'
96 +
97 +test_expect_failure 'apply binary diff without replacement -- should fail.' \
98 + 'do_reset
99 + git-apply BF.diff'
100 +
101 +test_expect_failure 'apply binary diff without replacement (copy) -- should fail.' \
102 + 'do_reset
103 + git-apply CF.diff'
104 +
105 +test_expect_success 'apply binary diff.' \
106 + 'do_reset
107 + git-apply --allow-binary-replacement --index BF.diff &&
108 + test -z "$(git-diff --name-status binary)"'
109 +
110 +test_expect_success 'apply binary diff (copy).' \
111 + 'do_reset
112 + git-apply --allow-binary-replacement --index CF.diff &&
113 + test -z "$(git-diff --name-status binary)"'
114 +
115 +test_done
t/test-lib.sh
+2
@@ -158,6 +158,8 @@ test_done () {
158 # Test the binaries we have just built. The tests are kept in
159 # t/ subdirectory and are run in trash subdirectory.
160 PATH=$(pwd)/..:$PATH
161 +GIT_EXEC_PATH=$(pwd)/..
162 +export GIT_EXEC_PATH
163
164 # Test repository
165 test=trash
tag.c
+5 -2
@@ -75,8 +75,11 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
75 item->tag[taglen] = '\0';
76
77 item->tagged = lookup_object_type(object, type);
78 - if (item->tagged)
79 - add_ref(&item->object, item->tagged);
78 + if (item->tagged && track_object_refs) {
79 + struct object_refs *refs = alloc_object_refs(1);
80 + refs->ref[0] = item->tagged;
81 + set_object_refs(&item->object, refs);
82 + }
83
84 return 0;
85 }
tree.c
+12 -1
@@ -148,6 +148,7 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
148 {
149 void *bufptr = buffer;
150 struct tree_entry_list **list_p;
151 + int n_refs = 0;
152
153 if (item->object.parsed)
154 return 0;
@@ -184,11 +185,21 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
185 obj = &entry->item.blob->object;
186 }
187 if (obj)
187 - add_ref(&item->object, obj);
188 + n_refs++;
189 entry->parent = NULL; /* needs to be filled by the user */
190 *list_p = entry;
191 list_p = &entry->next;
192 }
193 +
194 + if (track_object_refs) {
195 + struct tree_entry_list *entry;
196 + unsigned i = 0;
197 + struct object_refs *refs = alloc_object_refs(n_refs);
198 + for (entry = item->entries; entry; entry = entry->next)
199 + refs->ref[i++] = entry->item.any;
200 + set_object_refs(&item->object, refs);
201 + }
202 +
203 return 0;
204 }
205