From 4db42b38231b350138dd6b9c67af34e028006380 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 23 Nov 2012 09:02:22 -0500 Subject: [PATCH 1/2] Completion must sort before using uniq The user can be presented with invalid completion results when trying to complete a 'git checkout' command. This can happen when using a branch name prefix that matches multiple remote branches. For example, if available branches are: master remotes/GitHub/maint remotes/GitHub/master remotes/origin/maint remotes/origin/master When performing completion on 'git checkout ma' the user will be given the choices: maint master However, 'git checkout maint' will fail in this case, although completion previously said 'maint' was valid. Furthermore, when performing completion on 'git checkout mai', no choices will be suggested. So, the user is first told that the branch name 'maint' is valid, but when trying to complete 'mai' into 'maint', that completion is no longer valid. The completion results should never propose 'maint' as a valid branch name, since 'git checkout' will refuse it. The reason for this bug is that the uniq program only works with sorted input. The man page states "uniq prints the unique lines in a sorted file". When __git_refs uses the guess heuristic employed by checkout for tracking branches it wants to consider remote branches but only if the branch name is unique. To do that, it calls 'uniq -u'. However the input given to 'uniq -u' is not sorted. Therefore, in the above example, when dealing with 'git checkout ma', "__git_refs '' 1" will find the following list: master maint master maint master which, when passed to 'uniq -u' will remain the same. Therefore 'maint' will be wrongly suggested as a valid option. When dealing with 'git checkout mai', the list will be: maint maint which happens to be sorted and will be emptied by 'uniq -u', properly ignoring 'maint'. A solution for preventing the completion script from suggesting such invalid branch names is to first call 'sort' and then 'uniq -u'. Signed-off-by: Marc Khouzam Reviewed-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index be800e09bd..48c3abdf98 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -321,7 +321,7 @@ __git_refs () if [[ "$ref" == "$cur"* ]]; then echo "$ref" fi - done | uniq -u + done | sort | uniq -u fi return fi From ed9fe755130891fc878bb2433204faffb534697b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 25 Nov 2012 18:40:34 -0800 Subject: [PATCH 2/2] Git 1.8.0.1 Signed-off-by: Junio C Hamano --- Documentation/RelNotes/1.8.0.1.txt | 12 ++++++++++++ Documentation/git.txt | 5 +++-- GIT-VERSION-GEN | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/RelNotes/1.8.0.1.txt b/Documentation/RelNotes/1.8.0.1.txt index cda8b3e7a0..1f372fa0b5 100644 --- a/Documentation/RelNotes/1.8.0.1.txt +++ b/Documentation/RelNotes/1.8.0.1.txt @@ -49,4 +49,16 @@ Fixes since v1.8.0 * "git diff -G" did not honor textconv filter when looking for changes. + * Bash completion script (in contrib/) did not correctly complete a + lazy "git checkout $name_of_remote_tracking_branch_that_is_unique" + command line. + + * RSS feed from "gitweb" had a xss hole in its title output. + + * "git config --path $key" segfaulted on "[section] key" (a boolean + "true" spelled without "=", not "[section] key = true"). + + * "git checkout -b foo" while on an unborn branch did not say + "Switched to a new branch 'foo'" like other cases. + Also contains other minor fixes and documentation updates. diff --git a/Documentation/git.txt b/Documentation/git.txt index 4a89a12513..cbe0883534 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -43,10 +43,11 @@ unreleased) version of git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.8.0/git.html[documentation for release 1.8.0] +* link:v1.8.0.1/git.html[documentation for release 1.8.0.1] * release notes for - link:RelNotes/1.8.0.txt[1.8.0], + link:RelNotes/1.8.0.1.txt[1.8.0.1], + link:RelNotes/1.8.0.txt[1.8.0]. * link:v1.7.12.4/git.html[documentation for release 1.7.12.4] diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index b09d264a86..d66e54f12d 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.8.0 +DEF_VER=v1.8.0.1 LF=' '