From 904de44c1c2eb099c5696ad9d74e0e15cc57b55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Wed, 25 Nov 2015 15:10:18 +0100 Subject: [PATCH 1/2] wt-status: correct and simplify check for detached HEAD If a branch name is longer than four characters then memcmp() reads over the end of the static string "HEAD". This causes the following test failures with AddressSanitizer: t3203-branch-output.sh (Wstat: 256 Tests: 18 Failed: 4) Failed tests: 12, 15-17 Non-zero exit status: 1 t3412-rebase-root.sh (Wstat: 256 Tests: 31 Failed: 3) Failed tests: 28-29, 31 Non-zero exit status: 1 t3507-cherry-pick-conflict.sh (Wstat: 256 Tests: 31 Failed: 4) Failed tests: 14, 29-31 Non-zero exit status: 1 t3510-cherry-pick-sequence.sh (Wstat: 256 Tests: 39 Failed: 14) Failed tests: 17, 22-26, 28-30, 34-35, 37-39 Non-zero exit status: 1 t3420-rebase-autostash.sh (Wstat: 256 Tests: 28 Failed: 4) Failed tests: 24-27 Non-zero exit status: 1 t3404-rebase-interactive.sh (Wstat: 256 Tests: 91 Failed: 57) Failed tests: 17, 19, 21-42, 44, 46-74, 77, 81-82 Non-zero exit status: 1 t3900-i18n-commit.sh (Wstat: 256 Tests: 34 Failed: 1) Failed test: 34 Non-zero exit status: 1 t5407-post-rewrite-hook.sh (Wstat: 256 Tests: 14 Failed: 6) Failed tests: 9-14 Non-zero exit status: 1 t7001-mv.sh (Wstat: 256 Tests: 46 Failed: 5) Failed tests: 39-43 Non-zero exit status: 1 t7509-commit.sh (Wstat: 256 Tests: 12 Failed: 2) Failed tests: 11-12 Non-zero exit status: 1 t7512-status-help.sh (Wstat: 256 Tests: 39 Failed: 35) Failed tests: 5-39 Non-zero exit status: 1 t6030-bisect-porcelain.sh (Wstat: 256 Tests: 70 Failed: 1) Failed test: 13 Non-zero exit status: 1 And if a branch is named "H", "HE", or "HEA" then the current if clause erroneously considers it as matching "HEAD" because it only compares up to the end of the branch name. Fix that by doing the comparison using strcmp() and only after the branch name is extracted. This way neither too less nor too many characters are checked. While at it call strchrnul() to find the end of the branch name instead of open-coding it. Helped-by: Jeff King Signed-off-by: Rene Scharfe Signed-off-by: Jeff King --- wt-status.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/wt-status.c b/wt-status.c index 435fc2806..ced53dd1d 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1317,15 +1317,14 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1, target += strlen(" to "); strbuf_reset(&cb->buf); hashcpy(cb->nsha1, nsha1); - for (end = target; *end && *end != '\n'; end++) - ; - if (!memcmp(target, "HEAD", end - target)) { + end = strchrnul(target, '\n'); + strbuf_add(&cb->buf, target, end - target); + if (!strcmp(cb->buf.buf, "HEAD")) { /* HEAD is relative. Resolve it to the right reflog entry. */ + strbuf_reset(&cb->buf); strbuf_addstr(&cb->buf, find_unique_abbrev(nsha1, DEFAULT_ABBREV)); - return 1; } - strbuf_add(&cb->buf, target, end - target); return 1; } From bdfc6b364a51b19efbacbd46fcef5be41a5db50e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 8 Dec 2015 14:07:30 -0800 Subject: [PATCH 2/2] Git 2.6.4 Signed-off-by: Junio C Hamano --- Documentation/RelNotes/2.6.4.txt | 15 +++++++++++++++ Documentation/git.txt | 3 ++- GIT-VERSION-GEN | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/RelNotes/2.6.4.txt b/Documentation/RelNotes/2.6.4.txt index 621eb953b..b0256a2dc 100644 --- a/Documentation/RelNotes/2.6.4.txt +++ b/Documentation/RelNotes/2.6.4.txt @@ -44,5 +44,20 @@ Fixes since v2.6.3 computing the object name of the target of symbolic link, which may not even exist or may be a directory. + * There was no way to defeat a configured rebase.autostash variable + from the command line, as "git rebase --no-autostash" was missing. + + * Allow "git interpret-trailers" to run outside of a Git repository. + + * Produce correct "dirty" marker for shell prompts, even when we + are on an orphan or an unborn branch. + + * Some corner cases have been fixed in string-matching done in "git + status". + + * Apple's common crypto implementation of SHA1_Update() does not take + more than 4GB at a time, and we now have a compile-time workaround + for it. + Also contains typofixes, documentation updates and trivial code clean-ups. diff --git a/Documentation/git.txt b/Documentation/git.txt index 900272b1c..cbf157be4 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -43,9 +43,10 @@ unreleased) version of Git, that is available from the 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v2.6.3/git.html[documentation for release 2.6.3] +* link:v2.6.4/git.html[documentation for release 2.6.4] * release notes for + link:RelNotes/2.6.4.txt[2.6.4], link:RelNotes/2.6.3.txt[2.6.3], link:RelNotes/2.6.2.txt[2.6.2], link:RelNotes/2.6.1.txt[2.6.1], diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index abfdd9cb1..f2a001f6c 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v2.6.3 +DEF_VER=v2.6.4 LF=' '