From e5f591720caea0c6645fa9852903a1c43d7c3672 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 4 Dec 2009 05:35:57 -0500 Subject: [PATCH 1/6] rerere: don't segfault on failure to open rr-cache The rr-cache directory should always exist if we are doing garbage collection (earlier code paths check this explicitly), but we may not necessarily succeed in opening it (for example, due to permissions problems). In that case, we should print an error message rather than simply segfaulting. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-rerere.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin-rerere.c b/builtin-rerere.c index adfb7b5f48..31fda73ae7 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -48,6 +48,8 @@ static void garbage_collect(struct string_list *rr) git_config(git_rerere_gc_config, NULL); dir = opendir(git_path("rr-cache")); + if (!dir) + die_errno("unable to open rr-cache directory"); while ((e = readdir(dir))) { if (is_dot_or_dotdot(e->d_name)) continue; From 165ca62108464faa42367bcda6b278ac3a0d98cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 5 Dec 2009 00:11:01 +0100 Subject: [PATCH 2/6] archive: clarify description of path parameter Mention that path parameters are based on the current working directory. Signed-off-by: Rene Scharfe -- Documentation/git-archive.txt | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Signed-off-by: Junio C Hamano --- Documentation/git-archive.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt index 3d1c1e75b7..e57979198b 100644 --- a/Documentation/git-archive.txt +++ b/Documentation/git-archive.txt @@ -74,8 +74,9 @@ OPTIONS The tree or commit to produce an archive for. path:: - If one or more paths are specified, include only these in the - archive, otherwise include all files and subdirectories. + Without an optional path parameter, all files and subdirectories + of the current working directory are included in the archive. + If one or more paths are specified, only these are included. BACKEND EXTRA OPTIONS --------------------- From 50d9bbba92c9dd5611a1bb592fc42463212413ad Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Fri, 4 Dec 2009 12:53:21 -0500 Subject: [PATCH 3/6] Documentation: Avoid use of xmlto --stringparam The --stringparam option is not available on older xmlto versions. Instead, set man.base.url.for.relative.links via a .xsl file. Older docbook versions will ignore this without causing grief to users of older xmlto versions. Signed-off-by: Todd Zullinger Signed-off-by: Junio C Hamano --- Documentation/.gitignore | 1 + Documentation/Makefile | 23 ++++++++++++----------- Documentation/manpage-base-url.xsl.in | 10 ++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 Documentation/manpage-base-url.xsl.in diff --git a/Documentation/.gitignore b/Documentation/.gitignore index d8edd90406..1c3a9fead5 100644 --- a/Documentation/.gitignore +++ b/Documentation/.gitignore @@ -8,3 +8,4 @@ gitman.info howto-index.txt doc.dep cmds-*.txt +manpage-base-url.xsl diff --git a/Documentation/Makefile b/Documentation/Makefile index 1c9dfcea5a..037220f544 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -104,18 +104,15 @@ XMLTO_EXTRA += -m manpage-suppress-sp.xsl endif # Newer DocBook stylesheet emits warning cruft in the output when -# this is not set, and if set it shows an absolute link. We can -# use MAN_BASE_URL=http://www.kernel.org/pub/software/scm/git/docs/ -# but distros may want to set it to /usr/share/doc/git-core/docs/ or -# something like that. +# this is not set, and if set it shows an absolute link. Older +# stylesheets simply ignore this parameter. # -# As older stylesheets simply ignore this parameter, it ought to be -# safe to set it to empty string when the base URL is not specified, -# but unfortunately we cannot do so unconditionally because at least -# xmlto 0.0.18 is reported to lack --stringparam option. -ifdef MAN_BASE_URL -XMLTO_EXTRA += --stringparam man.base.url.for.relative.links=$(MAN_BASE_URL) +# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/ +# or similar. +ifndef MAN_BASE_URL +MAN_BASE_URL = file://$(htmldir)/ endif +XMLTO_EXTRA += -m manpage-base-url.xsl # If your target system uses GNU groff, it may try to render # apostrophes as a "pretty" apostrophe using unicode. This breaks @@ -244,6 +241,7 @@ clean: $(RM) howto-index.txt howto/*.html doc.dep $(RM) technical/api-*.html technical/api-index.txt $(RM) $(cmds_txt) *.made + $(RM) manpage-base-url.xsl $(MAN_HTML): %.html : %.txt $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ @@ -251,7 +249,10 @@ $(MAN_HTML): %.html : %.txt $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \ mv $@+ $@ -%.1 %.5 %.7 : %.xml +manpage-base-url.xsl: manpage-base-url.xsl.in + sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@ + +%.1 %.5 %.7 : %.xml manpage-base-url.xsl $(QUIET_XMLTO)$(RM) $@ && \ xmlto -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< diff --git a/Documentation/manpage-base-url.xsl.in b/Documentation/manpage-base-url.xsl.in new file mode 100644 index 0000000000..e800904df3 --- /dev/null +++ b/Documentation/manpage-base-url.xsl.in @@ -0,0 +1,10 @@ + + + + +@@MAN_BASE_URL@@ + + From 952dfc6944b29582482ff50a85c04879406c06ba Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 4 Dec 2009 06:11:58 -0500 Subject: [PATCH 4/6] reset: improve worktree safety valves The existing code checked to make sure we were not in a bare repository when doing a hard reset. However, we should take this one step further, and make sure we are in a worktree. Otherwise, we can end up munging files inside of '.git'. Furthermore, we should do the same check for --merge resets, which have the same properties. Actually, a merge reset of HEAD^ would already complain, since further down in the code we want a worktree. However, it is nicer to check up-front; then we are sure we cover all cases ("git reset --merge" would run, even though it wasn't doing anything) and we can give a more specific message. Add tests to t7103 to cover these cases and some missing ones. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-reset.c | 6 ++++-- t/t7103-reset-bare.sh | 32 +++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/builtin-reset.c b/builtin-reset.c index 73e60223db..11d1c6e4d6 100644 --- a/builtin-reset.c +++ b/builtin-reset.c @@ -286,8 +286,10 @@ int cmd_reset(int argc, const char **argv, const char *prefix) if (reset_type == NONE) reset_type = MIXED; /* by default */ - if (reset_type == HARD && is_bare_repository()) - die("hard reset makes no sense in a bare repository"); + if ((reset_type == HARD || reset_type == MERGE) + && !is_inside_work_tree()) + die("%s reset requires a work tree", + reset_type_names[reset_type]); /* Soft reset does not touch the index file nor the working tree * at all, but requires them in a good order. Other resets reset diff --git a/t/t7103-reset-bare.sh b/t/t7103-reset-bare.sh index 42bf518c68..68041df5f4 100755 --- a/t/t7103-reset-bare.sh +++ b/t/t7103-reset-bare.sh @@ -11,16 +11,42 @@ test_expect_success 'setup non-bare' ' git commit -a -m two ' +test_expect_success 'hard reset requires a worktree' ' + (cd .git && + test_must_fail git reset --hard) +' + +test_expect_success 'merge reset requires a worktree' ' + (cd .git && + test_must_fail git reset --merge) +' + +test_expect_success 'mixed reset is ok' ' + (cd .git && git reset) +' + +test_expect_success 'soft reset is ok' ' + (cd .git && git reset --soft) +' + test_expect_success 'setup bare' ' git clone --bare . bare.git && cd bare.git ' -test_expect_success 'hard reset is not allowed' ' - test_must_fail git reset --hard HEAD^ +test_expect_success 'hard reset is not allowed in bare' ' + test_must_fail git reset --hard HEAD^ ' -test_expect_success 'soft reset is allowed' ' +test_expect_success 'merge reset is not allowed in bare' ' + test_must_fail git reset --merge HEAD^ +' + +test_expect_success 'mixed reset is not allowed in bare' ' + test_must_fail git reset --mixed HEAD^ +' + +test_expect_success 'soft reset is allowed in bare' ' git reset --soft HEAD^ && test "`git show --pretty=format:%s | head -n 1`" = "one" ' From 77cd6ab62108c2d4ddd4343abd9bae17c406be4b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 4 Dec 2009 12:07:47 -0800 Subject: [PATCH 5/6] Fix diff -B/--dirstat miscounting of newly added contents What used to happen is that diffcore_count_changes() simply ignored any hashes in the destination that didn't match hashes in the source. EXCEPT if the source hash didn't exist at all, in which case it would count _one_ destination hash that happened to have the "next" hash value. As a consequence, newly added material was often undercounted, making output from --dirstat and "complete rewrite" detection used by -B unrelialble. This changes it so that: - whenever it bypasses a destination hash (because it doesn't match a source), it counts the bytes associated with that as "literal added" - at the end (once we have used up all the source hashes), we do the same thing with the remaining destination hashes. - when hashes do match, and we use the difference in counts as a value, we also use up that destination hash entry (the 'd++'). Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- diffcore-delta.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/diffcore-delta.c b/diffcore-delta.c index e670f85125..7cf431d261 100644 --- a/diffcore-delta.c +++ b/diffcore-delta.c @@ -201,10 +201,15 @@ int diffcore_count_changes(struct diff_filespec *src, while (d->cnt) { if (d->hashval >= s->hashval) break; + la += d->cnt; d++; } src_cnt = s->cnt; - dst_cnt = d->hashval == s->hashval ? d->cnt : 0; + dst_cnt = 0; + if (d->cnt && d->hashval == s->hashval) { + dst_cnt = d->cnt; + d++; + } if (src_cnt < dst_cnt) { la += dst_cnt - src_cnt; sc += src_cnt; @@ -213,6 +218,10 @@ int diffcore_count_changes(struct diff_filespec *src, sc += dst_cnt; s++; } + while (d->cnt) { + la += d->cnt; + d++; + } if (!src_count_p) free(src_count); From aa031314bf8189a15290d5bd0d85fa2a0307ceb7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 5 Dec 2009 11:08:35 -0800 Subject: [PATCH 6/6] Git 1.6.5.5 Signed-off-by: Junio C Hamano --- Documentation/RelNotes-1.6.5.5.txt | 9 +++++++-- Documentation/git.txt | 3 ++- GIT-VERSION-GEN | 2 +- RelNotes | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Documentation/RelNotes-1.6.5.5.txt b/Documentation/RelNotes-1.6.5.5.txt index 616e0dd0fd..ecfc57d875 100644 --- a/Documentation/RelNotes-1.6.5.5.txt +++ b/Documentation/RelNotes-1.6.5.5.txt @@ -18,6 +18,9 @@ Fixes since v1.6.5.4 twice, and held onto memory after it has used the data in it unnecessarily before it freed. + * "git diff -B" and "git diff --dirstat" was not counting newly added + contents correctly. + * "git format-patch revisions... -- path" issued an incorrect error message that suggested to use "--" on the command line when path does not exist in the current work tree (it is a separate matter if @@ -39,6 +42,8 @@ Fixes since v1.6.5.4 * "git rebase" got confused when the log message began with certain strings that looked like Subject:, Date: or From: header. -Other minor documentation updates are included. + * "git reset" accidentally run in .git/ directory checked out the + work tree contents in there. -v1.6.5.4-47-gdda8f4b + +Other minor documentation updates are included. diff --git a/Documentation/git.txt b/Documentation/git.txt index 7aa2edee58..8e93d35e44 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -43,9 +43,10 @@ unreleased) version of git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.6.5.4/git.html[documentation for release 1.6.5.4] +* link:v1.6.5.5/git.html[documentation for release 1.6.5.5] * release notes for + link:RelNotes-1.6.5.5.txt[1.6.5.5], link:RelNotes-1.6.5.4.txt[1.6.5.4], link:RelNotes-1.6.5.3.txt[1.6.5.3], link:RelNotes-1.6.5.2.txt[1.6.5.2], diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 6b4f708c0d..0c9be2080b 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.6.5.4 +DEF_VER=v1.6.5.5 LF=' ' diff --git a/RelNotes b/RelNotes index 918bab855c..5b19dba037 120000 --- a/RelNotes +++ b/RelNotes @@ -1 +1 @@ -Documentation/RelNotes-1.6.5.4.txt \ No newline at end of file +Documentation/RelNotes-1.6.5.5.txt \ No newline at end of file