From 42a32174b600f139b489341b1281fb1bfa14c252 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 18 Oct 2007 16:24:47 -0700 Subject: [PATCH 1/6] Avoid scary errors about tagged trees/blobs during git-fetch Ok, what is going on is: - append_fetch_head() looks up the SHA1 for all heads (including tags): if (get_sha1(head, sha1)) return error("Not a valid object name: %s", head); - it then wants to check if it's a candidate for merging (because fetching also does the whole "list which heads to merge" in case it is going to be part of a "pull"): commit = lookup_commit_reference(sha1); if (!commit) not_for_merge = 1; - and that "lookup_commit_reference()" is just very vocal about the case where it fails. It really shouldn't be, and it shouldn't affect the actual end result, but that basically explains why you get that scary warning. In short, the warning is just bogus, and should be harmless, but I agree that it's ugly. I think the appended patch should fix it. Signed-off-by: Linus Torvalds Signed-off-by: Shawn O. Pearce --- builtin-fetch--tool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c index e2f8ede9ae..db133348a8 100644 --- a/builtin-fetch--tool.c +++ b/builtin-fetch--tool.c @@ -148,7 +148,7 @@ static int append_fetch_head(FILE *fp, if (get_sha1(head, sha1)) return error("Not a valid object name: %s", head); - commit = lookup_commit_reference(sha1); + commit = lookup_commit_reference_gently(sha1, 1); if (!commit) not_for_merge = 1; From fd0b9594d0c2bb50469bfc1481ea4395b7a76548 Mon Sep 17 00:00:00 2001 From: Alex Bennee Date: Thu, 18 Oct 2007 17:15:44 +0100 Subject: [PATCH 2/6] Ensure we add directories in the correct order CVS gets understandably upset if you try and add a subdirectory before it's parent directory. This patch fixes that. Signed-off-by: Shawn O. Pearce --- git-cvsexportcommit.perl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index a33fa8d4c8..7b19a33ad1 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -224,6 +224,17 @@ print "Patch applied successfully. Adding new files and directories to CVS\n"; my $dirtypatch = 0; + +# +# We have to add the directories in order otherwise we will have +# problems when we try and add the sub-directory of a directory we +# have not added yet. +# +# Luckily this is easy to deal with by sorting the directories and +# dealing with the shortest ones first. +# +@dirs = sort { length $a <=> length $b} @dirs; + foreach my $d (@dirs) { if (system(@cvs,'add',$d)) { $dirtypatch = 1; From 415e7b877c54440bf92137a7021416efdf0a29b5 Mon Sep 17 00:00:00 2001 From: Patrick Welche Date: Thu, 18 Oct 2007 18:17:39 +0100 Subject: [PATCH 3/6] Define NI_MAXSERV if not defined by operating system I found I needed NI_MAXSERV as it is defined in netdb.h, which is not included by daemon.c. Rather than including the whole header we can define a reasonable fallback value. Signed-off-by: Shawn O. Pearce --- daemon.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/daemon.c b/daemon.c index 9cf22fef41..660e1552d4 100644 --- a/daemon.c +++ b/daemon.c @@ -9,6 +9,10 @@ #define HOST_NAME_MAX 256 #endif +#ifndef NI_MAXSERV +#define NI_MAXSERV 32 +#endif + static int log_syslog; static int verbose; static int reuseaddr; From d7b0a09316fe8dcb62ad247dbbb45c3c777667ad Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Thu, 18 Oct 2007 22:02:35 +0200 Subject: [PATCH 4/6] attr: fix segfault in gitattributes parsing code git may segfault if gitattributes contains an invalid entry. A test is added to t0020 that triggers the segfault. The parsing code is fixed to avoid the crash. Signed-off-by: Steffen Prohaska Signed-off-by: Shawn O. Pearce --- attr.c | 5 ++++- t/t0020-crlf.sh | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/attr.c b/attr.c index 129399310a..6e82507be7 100644 --- a/attr.c +++ b/attr.c @@ -214,8 +214,11 @@ static struct match_attr *parse_attr_line(const char *line, const char *src, num_attr = 0; cp = name + namelen; cp = cp + strspn(cp, blank); - while (*cp) + while (*cp) { cp = parse_attr(src, lineno, cp, &num_attr, res); + if (!cp) + return NULL; + } if (pass) break; res = xcalloc(1, diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index 0807d9f01a..62bc4bb077 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -371,4 +371,11 @@ test_expect_success 'in-tree .gitattributes (4)' ' } ' +test_expect_success 'invalid .gitattributes (must not crash)' ' + + echo "three +crlf" >>.gitattributes && + git diff + +' + test_done From 89d750bf6fa025edeb31ad258cdd09a27a5c02fa Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 18 Oct 2007 21:28:43 -0400 Subject: [PATCH 5/6] Avoid invoking diff drivers during git-stash git-stash needs to restrict itself to plumbing when running automated diffs as part of its operation as the user may have configured a custom diff driver that opens an interactive UI for certain/all files. Doing that during scripted actions is very unfriendly to the end-user and may cause git-stash to fail to work. Reported by Johannes Sixt Acked-by: Johannes Schindelin Signed-off-by: Shawn O. Pearce --- git-stash.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-stash.sh b/git-stash.sh index 7ba61625ba..def3163ebb 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -110,7 +110,7 @@ show_stash () { w_commit=$(git rev-parse --verify "$s") && b_commit=$(git rev-parse --verify "$s^") && - git diff $flags $b_commit $w_commit + git diff-tree $flags $b_commit $w_commit } apply_stash () { @@ -139,7 +139,7 @@ apply_stash () { unstashed_index_tree= if test -n "$unstash_index" && test "$b_tree" != "$i_tree" then - git diff --binary $s^2^..$s^2 | git apply --cached + git diff-tree --binary $s^2^..$s^2 | git apply --cached test $? -ne 0 && die 'Conflicts in index. Try without --index.' unstashed_index_tree=$(git-write-tree) || @@ -162,7 +162,7 @@ apply_stash () { git read-tree "$unstashed_index_tree" else a="$TMP-added" && - git diff --cached --name-only --diff-filter=A $c_tree >"$a" && + git diff-index --cached --name-only --diff-filter=A $c_tree >"$a" && git read-tree --reset $c_tree && git update-index --add --stdin <"$a" || die "Cannot unstage modified files" From bbaf63f2f18242484868d6c03d5df9bd071d6deb Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 19 Oct 2007 01:18:29 -0400 Subject: [PATCH 6/6] Further 1.5.3.5 fixes described in release notes Signed-off-by: Shawn O. Pearce --- Documentation/RelNotes-1.5.3.5.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Documentation/RelNotes-1.5.3.5.txt b/Documentation/RelNotes-1.5.3.5.txt index 78df418257..49e52264ba 100644 --- a/Documentation/RelNotes-1.5.3.5.txt +++ b/Documentation/RelNotes-1.5.3.5.txt @@ -20,9 +20,9 @@ Fixes since v1.5.3.4 * "git-add -i" did not handle single line hunks correctly. - * "git-rebase -i" failed if external diff drivers were used for one - or more files in a commit. It now avoids calling the external - diff drivers. + * "git-rebase -i" and "git-stash apply" failed if external diff + drivers were used for one or more files in a commit. They now + avoid calling the external diff drivers. * "git-log --follow" did not work unless diff generation (e.g. -p) was also requested. @@ -38,6 +38,16 @@ Fixes since v1.5.3.4 * "git-instaweb" no longer fails on Mac OS X. + * "git-cvsexportcommit" didn't always create new parent directories + before trying to create new child directories. Fixed. + + * "git-fetch" printed a scary (but bogus) error message while + fetching a tag that pointed to a tree or blob. The error did + not impact correctness, only user perception. The bogus error + is no longer printed. + + * Git segfaulted when reading an invalid .gitattributes file. Fixed. + * post-receive-email example hook fixed was fixed for non-fast-forward updates.