From 28f555f6357ee0706847aff5b476b31b472b325c Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 1 Sep 2011 20:50:33 -0400 Subject: [PATCH 01/10] remote: write correct fetch spec when renaming remote 'remote' When renaming a remote whose name is contained in a configured fetch refspec for that remote, we currently replace the first occurrence of the remote name in the refspec. This is correct in most cases, but breaks if the remote name occurs in the fetch refspec before the expected place. For example, we currently change [remote "remote"] url = git://git.kernel.org/pub/scm/git/git.git fetch = +refs/heads/*:refs/remotes/remote/* into [remote "origin"] url = git://git.kernel.org/pub/scm/git/git.git fetch = +refs/heads/*:refs/origins/remote/* Reduce the risk of changing incorrect sections of the refspec by matching the entire ":refs/remotes//" instead of just "". Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- builtin/remote.c | 12 ++++++++---- t/t5505-remote.sh | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index 1fb441c964..af96849dc9 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -631,7 +631,8 @@ static int mv(int argc, const char **argv) OPT_END() }; struct remote *oldremote, *newremote; - struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT; + struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT, + old_remote_context = STRBUF_INIT; struct string_list remote_branches = STRING_LIST_INIT_NODUP; struct rename_info rename; int i; @@ -669,15 +670,18 @@ static int mv(int argc, const char **argv) strbuf_addf(&buf, "remote.%s.fetch", rename.new); if (git_config_set_multivar(buf.buf, NULL, NULL, 1)) return error("Could not remove config section '%s'", buf.buf); + strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old); for (i = 0; i < oldremote->fetch_refspec_nr; i++) { char *ptr; strbuf_reset(&buf2); strbuf_addstr(&buf2, oldremote->fetch_refspec[i]); - ptr = strstr(buf2.buf, rename.old); + ptr = strstr(buf2.buf, old_remote_context.buf); if (ptr) - strbuf_splice(&buf2, ptr-buf2.buf, strlen(rename.old), - rename.new, strlen(rename.new)); + strbuf_splice(&buf2, + ptr-buf2.buf + strlen(":refs/remotes/"), + strlen(rename.old), rename.new, + strlen(rename.new)); if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0)) return error("Could not append '%s'", buf.buf); } diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 0d0222ea2a..36c807c608 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -631,6 +631,26 @@ test_expect_success 'rename a remote' ' ' +test_expect_success 'rename does not update a non-default fetch refspec' ' + + git clone one four.one && + (cd four.one && + git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* && + git remote rename origin upstream && + test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*") + +' + +test_expect_success 'rename a remote with name part of fetch spec' ' + + git clone one four.two && + (cd four.two && + git remote rename origin remote && + git remote rename remote upstream && + test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*") + +' + cat > remotes_origin << EOF URL: $(pwd)/one Push: refs/heads/master:refs/heads/upstream From 60e5eee0f1a70e09f28d1e55b3aaddb59eeea887 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 1 Sep 2011 20:50:34 -0400 Subject: [PATCH 02/10] remote: "rename o foo" should not rename ref "origin/bar" When renaming a remote called 'o' using 'git remote rename o foo', git should also rename any remote-tracking branches for the remote. This does happen, but any remote-tracking branches starting with 'refs/remotes/o', such as 'refs/remotes/origin/bar', will also be renamed (to 'refs/remotes/foorigin/bar' in this case). Fix it by simply matching one more character, up to the slash following the remote name. Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- builtin/remote.c | 2 +- t/t5505-remote.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/builtin/remote.c b/builtin/remote.c index af96849dc9..180da895be 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -580,7 +580,7 @@ static int read_remote_branches(const char *refname, unsigned char orig_sha1[20]; const char *symref; - strbuf_addf(&buf, "refs/remotes/%s", rename->old); + strbuf_addf(&buf, "refs/remotes/%s/", rename->old); if (!prefixcmp(refname, buf.buf)) { item = string_list_append(rename->remote_branches, xstrdup(refname)); symref = resolve_ref(refname, orig_sha1, 1, &flag); diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 36c807c608..15186c8cbf 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -651,6 +651,16 @@ test_expect_success 'rename a remote with name part of fetch spec' ' ' +test_expect_success 'rename a remote with name prefix of other remote' ' + + git clone one four.three && + (cd four.three && + git remote add o git://example.com/repo.git && + git remote rename o upstream && + test "$(git rev-parse origin/master)" = "$(git rev-parse master)") + +' + cat > remotes_origin << EOF URL: $(pwd)/one Push: refs/heads/master:refs/heads/upstream From 1822b86a515af708e2259bae2b6a1f2052a2d3aa Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 3 Sep 2011 11:26:59 -0400 Subject: [PATCH 03/10] remote rename: warn when refspec was not updated When renaming a remote, we also try to update the fetch refspec accordingly, but only if it has the default format. For others, such as refs/heads/master:refs/heads/origin, we are conservative and leave it untouched. Let's give the user a warning about refspecs that are not updated, so he can manually update the config if necessary. Suggested-by: Jeff King Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- builtin/remote.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builtin/remote.c b/builtin/remote.c index 180da895be..659c6ab71e 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -682,6 +682,12 @@ static int mv(int argc, const char **argv) ptr-buf2.buf + strlen(":refs/remotes/"), strlen(rename.old), rename.new, strlen(rename.new)); + else + warning("Not updating non-default fetch respec\n" + "\t%s\n" + "\tPlease update the configuration manually if necessary.", + buf2.buf); + if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0)) return error("Could not append '%s'", buf.buf); } From b52d00aedeb94f12a16afcef1bb33c989f9b4105 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 10 Sep 2011 15:39:23 -0400 Subject: [PATCH 04/10] remote: only update remote-tracking branch if updating refspec 'git remote rename' will only update the remote's fetch refspec if it looks like a default one. If the remote has no default fetch refspec, as in [remote "origin"] url = git://git.kernel.org/pub/scm/git/git.git fetch = +refs/heads/*:refs/remotes/upstream/* we would not update the fetch refspec and even if there is a ref called "refs/remotes/origin/master", we should not rename it, since it was not created by fetching from the remote. Suggested-by: Junio C Hamano Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- builtin/remote.c | 10 +++++++--- t/t5505-remote.sh | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index 659c6ab71e..9c746af460 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -635,7 +635,7 @@ static int mv(int argc, const char **argv) old_remote_context = STRBUF_INIT; struct string_list remote_branches = STRING_LIST_INIT_NODUP; struct rename_info rename; - int i; + int i, refspec_updated = 0; if (argc != 3) usage_with_options(builtin_remote_rename_usage, options); @@ -677,12 +677,13 @@ static int mv(int argc, const char **argv) strbuf_reset(&buf2); strbuf_addstr(&buf2, oldremote->fetch_refspec[i]); ptr = strstr(buf2.buf, old_remote_context.buf); - if (ptr) + if (ptr) { + refspec_updated = 1; strbuf_splice(&buf2, ptr-buf2.buf + strlen(":refs/remotes/"), strlen(rename.old), rename.new, strlen(rename.new)); - else + } else warning("Not updating non-default fetch respec\n" "\t%s\n" "\tPlease update the configuration manually if necessary.", @@ -705,6 +706,9 @@ static int mv(int argc, const char **argv) } } + if (!refspec_updated) + return 0; + /* * First remove symrefs, then rename the rest, finally create * the new symrefs. diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 15186c8cbf..e8af615e6d 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -637,7 +637,8 @@ test_expect_success 'rename does not update a non-default fetch refspec' ' (cd four.one && git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* && git remote rename origin upstream && - test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*") + test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" && + git rev-parse -q origin/master) ' From ee646eb48f9a7fc6c225facf2b7449a8a65ef8f2 Mon Sep 17 00:00:00 2001 From: Haitao Li Date: Fri, 9 Sep 2011 18:10:33 +0800 Subject: [PATCH 05/10] date.c: Support iso8601 timezone formats Timezone designators in the following formats are all valid according to ISO8601:2004, section 4.3.2: [+-]hh, [+-]hhmm, [+-]hh:mm but we have ignored the ones with colon so far. Signed-off-by: Haitao Li Helped-by: Jeff King Signed-off-by: Junio C Hamano --- date.c | 34 +++++++++++++++++++++++----------- t/t0006-date.sh | 6 ++++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/date.c b/date.c index 896fbb4806..353e0a5e53 100644 --- a/date.c +++ b/date.c @@ -552,23 +552,35 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt static int match_tz(const char *date, int *offp) { char *end; - int offset = strtoul(date+1, &end, 10); - int min, hour; - int n = end - date - 1; + int hour = strtoul(date + 1, &end, 10); + int n = end - (date + 1); + int min = 0; - min = offset % 100; - hour = offset / 100; + if (n == 4) { + /* hhmm */ + min = hour % 100; + hour = hour / 100; + } else if (n != 2) { + min = 99; /* random crap */ + } else if (*end == ':') { + /* hh:mm? */ + min = strtoul(end + 1, &end, 10); + if (end - (date + 1) != 5) + min = 99; /* random crap */ + } /* otherwise we parsed "hh" */ /* - * Don't accept any random crap.. At least 3 digits, and - * a valid minute. We might want to check that the minutes - * are divisible by 30 or something too. + * Don't accept any random crap. Even though some places have + * offset larger than 12 hours (e.g. Pacific/Kiritimati is at + * UTC+14), there is something wrong if hour part is much + * larger than that. We might also want to check that the + * minutes are divisible by 15 or something too. (Offset of + * Kathmandu, Nepal is UTC+5:45) */ - if (min < 60 && n > 2) { - offset = hour*60+min; + if (min < 60 && hour < 24) { + int offset = hour * 60 + min; if (*date == '-') offset = -offset; - *offp = offset; } return end - date; diff --git a/t/t0006-date.sh b/t/t0006-date.sh index f87abb5a06..1d29810a7a 100755 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@ -40,6 +40,12 @@ check_parse 2008-02 bad check_parse 2008-02-14 bad check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 +0000' check_parse '2008-02-14 20:30:45 -0500' '2008-02-14 20:30:45 -0500' +check_parse '2008-02-14 20:30:45 -0015' '2008-02-14 20:30:45 -0015' +check_parse '2008-02-14 20:30:45 -5' '2008-02-14 20:30:45 +0000' +check_parse '2008-02-14 20:30:45 -5:' '2008-02-14 20:30:45 +0000' +check_parse '2008-02-14 20:30:45 -05' '2008-02-14 20:30:45 -0500' +check_parse '2008-02-14 20:30:45 -:30' '2008-02-14 20:30:45 +0000' +check_parse '2008-02-14 20:30:45 -05:00' '2008-02-14 20:30:45 -0500' check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 -0500' EST5 check_approxidate() { From e29bee19012d6aa4fb02dae727caa53947d9e39a Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Sat, 10 Sep 2011 18:40:10 +0100 Subject: [PATCH 06/10] t9159-*.sh: skip for mergeinfo test for svn <= 1.4 t9159 relies on the command-line syntax of svn >= 1.5. Given the declining install base of older svn versions, it is not worth our time to support older svn syntax. Signed-off-by: Ramsay Jones Acked-by: Eric Wong Signed-off-by: Junio C Hamano --- t/t9159-git-svn-no-parent-mergeinfo.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t9159-git-svn-no-parent-mergeinfo.sh b/t/t9159-git-svn-no-parent-mergeinfo.sh index 85120b70db..69e4815781 100755 --- a/t/t9159-git-svn-no-parent-mergeinfo.sh +++ b/t/t9159-git-svn-no-parent-mergeinfo.sh @@ -2,6 +2,14 @@ test_description='git svn handling of root commits in merge ranges' . ./lib-git-svn.sh +svn_ver="$(svn --version --quiet)" +case $svn_ver in +0.* | 1.[0-4].*) + skip_all="skipping git-svn test - SVN too old ($svn_ver)" + test_done + ;; +esac + test_expect_success 'test handling of root commits in merge ranges' ' mkdir -p init/trunk init/branches init/tags && echo "r1" > init/trunk/file.txt && From 3e8e691abe4e1cce73a8a2ef413dada0278e7b3b Mon Sep 17 00:00:00 2001 From: Jonathon Mah Date: Thu, 15 Sep 2011 19:12:10 -0700 Subject: [PATCH 07/10] mergetool: Use args as pathspec to unmerged files Mergetool now treats its path arguments as a pathspec (like other git subcommands), restricting action to the given files and directories. Files matching the pathspec are filtered so mergetool only acts on unmerged paths; previously it would assume each path argument was in an unresolved state, and get confused when it couldn't check out their other stages. Running "git mergetool subdir" will prompt to resolve all conflicted blobs under subdir. Signed-off-by: Jonathon Mah Acked-by: David Aguilar Signed-off-by: Junio C Hamano --- Documentation/git-mergetool.txt | 7 +-- git-mergetool.sh | 80 +++++++++++++-------------------- t/t7610-mergetool.sh | 58 ++++++++++++++++-------- 3 files changed, 74 insertions(+), 71 deletions(-) diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt index 8c79ae8d2a..f1f4e7a07d 100644 --- a/Documentation/git-mergetool.txt +++ b/Documentation/git-mergetool.txt @@ -16,9 +16,10 @@ Use `git mergetool` to run one of several merge utilities to resolve merge conflicts. It is typically run after 'git merge'. If one or more parameters are given, the merge tool program will -be run to resolve differences on each file. If no names are -specified, 'git mergetool' will run the merge tool program on every file -with merge conflicts. +be run to resolve differences on each file (skipping those without +conflicts). Specifying a directory will include all unresolved files in +that path. If no names are specified, 'git mergetool' will run +the merge tool program on every file with merge conflicts. OPTIONS ------- diff --git a/git-mergetool.sh b/git-mergetool.sh index 3aab5aae84..83551c70c7 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -342,64 +342,44 @@ merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo fa last_status=0 rollup_status=0 -rerere=false - -files_to_merge() { - if test "$rerere" = true - then - git rerere remaining - else - git ls-files -u | sed -e 's/^[^ ]* //' | sort -u - fi -} - +files= if test $# -eq 0 ; then cd_to_toplevel if test -e "$GIT_DIR/MERGE_RR" then - rerere=true + files=$(git rerere remaining) + else + files=$(git ls-files -u | sed -e 's/^[^ ]* //' | sort -u) fi - - files=$(files_to_merge) - if test -z "$files" ; then - echo "No files need merging" - exit 0 - fi - - # Save original stdin - exec 3<&0 - - printf "Merging:\n" - printf "$files\n" - - files_to_merge | - while IFS= read i - do - if test $last_status -ne 0; then - prompt_after_failed_merge <&3 || exit 1 - fi - printf "\n" - merge_file "$i" <&3 - last_status=$? - if test $last_status -ne 0; then - rollup_status=1 - fi - done else - while test $# -gt 0; do - if test $last_status -ne 0; then - prompt_after_failed_merge || exit 1 - fi - printf "\n" - merge_file "$1" - last_status=$? - if test $last_status -ne 0; then - rollup_status=1 - fi - shift - done + files=$(git ls-files -u -- "$@" | sed -e 's/^[^ ]* //' | sort -u) fi +if test -z "$files" ; then + echo "No files need merging" + exit 0 +fi + +# Save original stdin +exec 3<&0 + +printf "Merging:\n" +printf "$files\n" + +IFS=' +'; for i in $files +do + if test $last_status -ne 0; then + prompt_after_failed_merge <&3 || exit 1 + fi + printf "\n" + merge_file "$i" <&3 + last_status=$? + if test $last_status -ne 0; then + rollup_status=1 + fi +done + exit $rollup_status diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index cbc08e3276..4aab2a75b8 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -16,6 +16,7 @@ Testing basic merge tool invocation' test_expect_success 'setup' ' git config rerere.enabled true && echo master >file1 && + echo master spaced >"spaced name" && echo master file11 >file11 && echo master file12 >file12 && echo master file13 >file13 && @@ -30,13 +31,14 @@ test_expect_success 'setup' ' git commit -m "Add foo" ) && git submodule add git://example.com/submod submod && - git add file1 file1[1-4] subdir/file3 .gitmodules submod && + git add file1 "spaced name" file1[1-4] subdir/file3 .gitmodules submod && git commit -m "add initial versions" && git checkout -b branch1 master && git submodule update -N && echo branch1 change >file1 && echo branch1 newfile >file2 && + echo branch1 spaced >"spaced name" && echo branch1 change file11 >file11 && echo branch1 change file13 >file13 && echo branch1 sub >subdir/file3 && @@ -47,7 +49,7 @@ test_expect_success 'setup' ' git commit -m "Add bar on branch1" && git checkout -b submod-branch1 ) && - git add file1 file11 file13 file2 subdir/file3 submod && + git add file1 "spaced name" file11 file13 file2 subdir/file3 submod && git rm file12 && git commit -m "branch1 changes" && @@ -55,6 +57,7 @@ test_expect_success 'setup' ' git submodule update -N && echo master updated >file1 && echo master new >file2 && + echo master updated spaced >"spaced name" && echo master updated file12 >file12 && echo master updated file14 >file14 && echo master new sub >subdir/file3 && @@ -65,7 +68,7 @@ test_expect_success 'setup' ' git commit -m "Add bar on master" && git checkout -b submod-master ) && - git add file1 file12 file14 file2 subdir/file3 submod && + git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && git rm file11 && git commit -m "master updates" && @@ -78,8 +81,8 @@ test_expect_success 'custom mergetool' ' git checkout -b test1 branch1 && git submodule update -N && test_must_fail git merge master >/dev/null 2>&1 && - ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && - ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file1 ) && + ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && @@ -97,6 +100,7 @@ test_expect_success 'mergetool crlf' ' test_must_fail git merge master >/dev/null 2>&1 && ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && + ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && @@ -126,7 +130,7 @@ test_expect_success 'mergetool on file in parent dir' ' ( cd subdir && ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && - ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) && + ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) && @@ -180,6 +184,24 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' ' git reset --hard ' +test_expect_success 'mergetool takes partial path' ' + git config rerere.enabled false && + git checkout -b test12 branch1 && + git submodule update -N && + test_must_fail git merge master && + + #shouldnt need these lines + #( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && + #( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && + #( yes "l" | git mergetool submod >/dev/null 2>&1 ) && + #( yes "" | git mergetool file1 file2 >/dev/null 2>&1 ) && + + ( yes "" | git mergetool subdir ) && + + test "$(cat subdir/file3)" = "master new sub" && + git reset --hard +' + test_expect_success 'deleted vs modified submodule' ' git checkout -b test6 branch1 && git submodule update -N && @@ -189,7 +211,7 @@ test_expect_success 'deleted vs modified submodule' ' git checkout -b test6.a test6 && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod && @@ -205,7 +227,7 @@ test_expect_success 'deleted vs modified submodule' ' git submodule update -N && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test ! -e submod && @@ -218,7 +240,7 @@ test_expect_success 'deleted vs modified submodule' ' git submodule update -N && test_must_fail git merge test6 && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test ! -e submod && @@ -233,7 +255,7 @@ test_expect_success 'deleted vs modified submodule' ' git submodule update -N && test_must_fail git merge test6 && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" && @@ -256,7 +278,7 @@ test_expect_success 'file vs modified submodule' ' git checkout -b test7.a branch1 && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod && @@ -271,7 +293,7 @@ test_expect_success 'file vs modified submodule' ' git checkout -b test7.b test7 && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && git submodule update -N && @@ -286,7 +308,7 @@ test_expect_success 'file vs modified submodule' ' git submodule update -N && test_must_fail git merge test7 && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "r" | git mergetool submod ) && test -d submod.orig && @@ -301,7 +323,7 @@ test_expect_success 'file vs modified submodule' ' git submodule update -N && test_must_fail git merge test7 && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" && @@ -388,7 +410,7 @@ test_expect_success 'directory vs modified submodule' ' test "$(cat submod/file16)" = "not a submodule" && rm -rf submod.orig && - git reset --hard && + git reset --hard >/dev/null 2>&1 && test_must_fail git merge master && test -n "$(git ls-files -u)" && test ! -e submod.orig && @@ -400,7 +422,7 @@ test_expect_success 'directory vs modified submodule' ' ( cd submod && git clean -f && git reset --hard ) && git submodule update -N && test "$(cat submod/bar)" = "master submodule" && - git reset --hard && rm -rf submod-movedaside && + git reset --hard >/dev/null 2>&1 && rm -rf submod-movedaside && git checkout -b test11.c master && git submodule update -N && @@ -410,7 +432,7 @@ test_expect_success 'directory vs modified submodule' ' git submodule update -N && test "$(cat submod/bar)" = "master submodule" && - git reset --hard && + git reset --hard >/dev/null 2>&1 && git submodule update -N && test_must_fail git merge test11 && test -n "$(git ls-files -u)" && @@ -418,7 +440,7 @@ test_expect_success 'directory vs modified submodule' ' ( yes "r" | git mergetool submod ) && test "$(cat submod/file16)" = "not a submodule" && - git reset --hard master && + git reset --hard master >/dev/null 2>&1 && ( cd submod && git clean -f && git reset --hard ) && git submodule update -N ' From 6d9990a959c0168ab6dfe75236980f95ac512ce5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 16 Sep 2011 13:19:33 -0700 Subject: [PATCH 08/10] mergetool: no longer need to save standard input Earlier code wanted to run merge_file and prompt_after_failed_merge both of which wanted to read from the standard input of the entire script inside a while loop, which read from a pipe, and in order to do so, it redirected the original standard input to another file descriptor. We no longer need to do so after the previous change. Signed-off-by: Junio C Hamano --- git-mergetool.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/git-mergetool.sh b/git-mergetool.sh index 83551c70c7..0a06bde843 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -362,20 +362,18 @@ if test -z "$files" ; then exit 0 fi -# Save original stdin -exec 3<&0 - printf "Merging:\n" printf "$files\n" IFS=' -'; for i in $files +' +for i in $files do if test $last_status -ne 0; then - prompt_after_failed_merge <&3 || exit 1 + prompt_after_failed_merge || exit 1 fi printf "\n" - merge_file "$i" <&3 + merge_file "$i" last_status=$? if test $last_status -ne 0; then rollup_status=1 From 2b07ff3ffa04a3d52bb4aec9df9f8b6378e2f2a7 Mon Sep 17 00:00:00 2001 From: Peter Stuge Date: Tue, 27 Sep 2011 11:51:00 +0200 Subject: [PATCH 09/10] gitweb: Fix links to lines in blobs when javascript-actions are enabled The fixLinks() function adds 'js=1' to each link that does not already have 'js' query parameter specified. This is used to signal to gitweb that the browser can actually do javascript when these links are used. There are two problems with the existing code: 1. URIs with fragment and 'js' query parameter, like e.g. ...foo?js=0#l199 were not recognized as having 'js' query parameter already. 2. The 'js' query parameter, in the form of either '?js=1' or ';js=1' was appended at the end of URI, even if it included a fragment (had a hash part). This lead to the incorrect links like this ...foo#l199?js=1 instead of adding query parameter as last part of query, but before the fragment part, i.e. ...foo?js=1#l199 Signed-off-by: Peter Stuge Acked-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/static/js/javascript-detection.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gitweb/static/js/javascript-detection.js b/gitweb/static/js/javascript-detection.js index 93dd2bdd91..fa2596f77c 100644 --- a/gitweb/static/js/javascript-detection.js +++ b/gitweb/static/js/javascript-detection.js @@ -16,7 +16,7 @@ * and other reasons to not add 'js=1' param at the end of link * @constant */ -var jsExceptionsRe = /[;?]js=[01]$/; +var jsExceptionsRe = /[;?]js=[01](#.*)?$/; /** * Add '?js=1' or ';js=1' to the end of every link in the document @@ -33,9 +33,9 @@ function fixLinks() { var allLinks = document.getElementsByTagName("a") || document.links; for (var i = 0, len = allLinks.length; i < len; i++) { var link = allLinks[i]; - if (!jsExceptionsRe.test(link)) { // =~ /[;?]js=[01]$/; - link.href += - (link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1'; + if (!jsExceptionsRe.test(link)) { + link.href = link.href.replace(/(#|$)/, + (link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1$1'); } } } From 852844561e8daaa6689cab48a725f764ad5779cb Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Tue, 27 Sep 2011 06:46:53 +0200 Subject: [PATCH 10/10] notes_merge_commit(): do not pass temporary buffer to other function It is unsafe to pass a temporary buffer as an argument to read_directory(). Signed-off-by: Michael Haggerty Acked-by: Johan Herland Signed-off-by: Junio C Hamano --- notes-merge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notes-merge.c b/notes-merge.c index e1aaf43b43..baaf31f4ae 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -680,7 +680,7 @@ int notes_merge_commit(struct notes_merge_options *o, * Finally store the new commit object SHA1 into 'result_sha1'. */ struct dir_struct dir; - const char *path = git_path(NOTES_MERGE_WORKTREE "/"); + char *path = xstrdup(git_path(NOTES_MERGE_WORKTREE "/")); int path_len = strlen(path), i; const char *msg = strstr(partial_commit->buffer, "\n\n"); @@ -720,6 +720,7 @@ int notes_merge_commit(struct notes_merge_options *o, result_sha1); OUTPUT(o, 4, "Finalized notes merge commit: %s", sha1_to_hex(result_sha1)); + free(path); return 0; }