{"thread":{"id":"17724","subject":"[PATCH 1/3] completion: For consistency, changed \"git rev-parse\" to __gitdir calls.","startedAt":"2009-02-11T15:37:11Z","lastAt":"2009-02-11T18:01:00Z","messageCount":16,"participants":["Ted Pavlic","Shawn O. Pearce","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"104197","messageId":"1234366634-17900-1-git-send-email-ted@tedpavlic.com","threadId":"17724","inReplyTo":null,"subject":"[PATCH 0/3] completion: Convention updates and DIRTYSTATE fix","fromName":"Ted Pavlic","fromEmail":"ted@tedpavlic.com","sentAt":"2009-02-11T15:37:11Z","receivedAt":"2009-02-11T15:37:11Z","isPatch":true,"sender":{"key":"ted@tedpavlic.com","avatar":"https://gravatar.com/avatar/d085392370ff4c028cf17a0e81e0647744c9682fbcb36b499f31d08ef80ef569?d=mp&s=160"},"body":"Three more patches to git's bash completion script.\n\nThe first two are non-critical:\n* The first patch changes two \"git rev-parse\" calls to \"__gitdir\" to\n  match the convention used in the rest of the script.\n* The second patch changes \"[...]\" to \"test ...\" to match git\n  convention. In the one case of \"[...] || [...]\", a \"test || test\" call\n  is used. Alternatively, a \"test ... -o ...\" call could be used, but\n  that might not be as readable.\n\nThe third fixes an ugly error in the new GIT_PS1_DIRTYSTATE. In order to\ndetermine whether the branch name needs a \"*\" following it, the\nDIRTYSTATE implementation uses a \"git diff.\" Because \"git diff\" is\nillegal when not in a working tree, this command gives an ugly error\nwhen changing directory to \".git\". This patch detects this case and sets\n\"--work-tree=..\". Is there a better fix?\n\nTed Pavlic (3):\n  completion: For consistency, changed \"git rev-parse\" to __gitdir\n    calls.\n  completion: Change \"if [...]\" to \"if test ...\" to match git\n    convention\n  completion: Prevents GIT_PS1_DIRTYSTATE from breaking when CWD is\n    .git\n\n contrib/completion/git-completion.bash |  101 +++++++++++++++-----------------\n 1 files changed, 48 insertions(+), 53 deletions(-)\n"},{"id":"104195","messageId":"1234366634-17900-2-git-send-email-ted@tedpavlic.com","threadId":"17724","inReplyTo":"1234366634-17900-1-git-send-email-ted@tedpavlic.com","subject":"[PATCH 1/3] completion: For consistency, changed \"git rev-parse\" to __gitdir calls.","fromName":"Ted Pavlic","fromEmail":"ted@tedpavlic.com","sentAt":"2009-02-11T15:37:12Z","receivedAt":"2009-02-11T15:37:12Z","isPatch":true,"sender":{"key":"ted@tedpavlic.com","avatar":"https://gravatar.com/avatar/d085392370ff4c028cf17a0e81e0647744c9682fbcb36b499f31d08ef80ef569?d=mp&s=160"},"body":"Signed-off-by: Ted Pavlic <ted@tedpavlic.com>\n---\n contrib/completion/git-completion.bash |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex f44f63c..6bbe09a 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -80,7 +80,7 @@ __gitdir ()\n # returns text to add to bash PS1 prompt (includes branch name)\n __git_ps1 ()\n {\n-\tlocal g=\"$(git rev-parse --git-dir 2>/dev/null)\"\n+\tlocal g=\"$(__gitdir)\"\n \tif [ -n \"$g\" ]; then\n \t\tlocal r\n \t\tlocal b\n@@ -1797,7 +1797,7 @@ _gitk ()\n \t__git_has_doubledash && return\n \n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n-\tlocal g=\"$(git rev-parse --git-dir 2>/dev/null)\"\n+\tlocal g=\"$(__gitdir)\"\n \tlocal merge=\"\"\n \tif [ -f $g/MERGE_HEAD ]; then\n \t\tmerge=\"--merge\"\n-- \n1.6.1.2.390.gba743\n"},{"id":"104196","messageId":"1234366634-17900-3-git-send-email-ted@tedpavlic.com","threadId":"17724","inReplyTo":"1234366634-17900-2-git-send-email-ted@tedpavlic.com","subject":"[PATCH 2/3] completion: Change \"if [...]\" to \"if test ...\" to match git convention","fromName":"Ted Pavlic","fromEmail":"ted@tedpavlic.com","sentAt":"2009-02-11T15:37:13Z","receivedAt":"2009-02-11T15:37:13Z","isPatch":true,"sender":{"key":"ted@tedpavlic.com","avatar":"https://gravatar.com/avatar/d085392370ff4c028cf17a0e81e0647744c9682fbcb36b499f31d08ef80ef569?d=mp&s=160"},"body":"In the single case of:\n\n    if [...] || [...]\n\nchanged to:\n\n    if test ... || test ...\n\nHowever,\n\n    if test ... -o ...\n\nmight be favorable (although arguably less readable).\n\nAlso changed:\n\n    if test ...\n    then\n\nto:\n\n    if test ...; then\n\nSigned-off-by: Ted Pavlic <ted@tedpavlic.com>\n---\n contrib/completion/git-completion.bash |   91 ++++++++++++++-----------------\n 1 files changed, 41 insertions(+), 50 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6bbe09a..6772be7 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -61,15 +61,15 @@ esac\n # returns location of .git repo\n __gitdir ()\n {\n-\tif [ -z \"${1-}\" ]; then\n-\t\tif [ -n \"$__git_dir\" ]; then\n+\tif test -z \"${1-}\"; then\n+\t\tif test -n \"$__git_dir\"; then\n \t\t\techo \"$__git_dir\"\n-\t\telif [ -d .git ]; then\n+\t\telif test -d .git; then\n \t\t\techo .git\n \t\telse\n \t\t\tgit rev-parse --git-dir 2>/dev/null\n \t\tfi\n-\telif [ -d \"$1/.git\" ]; then\n+\telif test -d \"$1/.git\"; then\n \t\techo \"$1/.git\"\n \telse\n \t\techo \"$1\"\n@@ -81,42 +81,33 @@ __gitdir ()\n __git_ps1 ()\n {\n \tlocal g=\"$(__gitdir)\"\n-\tif [ -n \"$g\" ]; then\n+\tif test -n \"$g\"; then\n \t\tlocal r\n \t\tlocal b\n-\t\tif [ -d \"$g/rebase-apply\" ]\n-\t\tthen\n-\t\t\tif test -f \"$g/rebase-apply/rebasing\"\n-\t\t\tthen\n+\t\tif test -d \"$g/rebase-apply\"; then\n+\t\t\tif test -f \"$g/rebase-apply/rebasing\"; then\n \t\t\t\tr=\"|REBASE\"\n-\t\t\telif test -f \"$g/rebase-apply/applying\"\n-\t\t\tthen\n+\t\t\telif test -f \"$g/rebase-apply/applying\"; then\n \t\t\t\tr=\"|AM\"\n \t\t\telse\n \t\t\t\tr=\"|AM/REBASE\"\n \t\t\tfi\n \t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n-\t\telif [ -f \"$g/rebase-merge/interactive\" ]\n-\t\tthen\n+\t\telif test -f \"$g/rebase-merge/interactive\"; then\n \t\t\tr=\"|REBASE-i\"\n \t\t\tb=\"$(cat \"$g/rebase-merge/head-name\")\"\n-\t\telif [ -d \"$g/rebase-merge\" ]\n-\t\tthen\n+\t\telif test -d \"$g/rebase-merge\"; then\n \t\t\tr=\"|REBASE-m\"\n \t\t\tb=\"$(cat \"$g/rebase-merge/head-name\")\"\n-\t\telif [ -f \"$g/MERGE_HEAD\" ]\n-\t\tthen\n+\t\telif test -f \"$g/MERGE_HEAD\"; then\n \t\t\tr=\"|MERGING\"\n \t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n \t\telse\n-\t\t\tif [ -f \"$g/BISECT_LOG\" ]\n-\t\t\tthen\n+\t\t\tif test -f \"$g/BISECT_LOG\"; then\n \t\t\t\tr=\"|BISECTING\"\n \t\t\tfi\n-\t\t\tif ! b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n-\t\t\tthen\n-\t\t\t\tif ! b=\"$(git describe --exact-match HEAD 2>/dev/null)\"\n-\t\t\t\tthen\n+\t\t\tif ! b=\"$(git symbolic-ref HEAD 2>/dev/null)\"; then\n+\t\t\t\tif ! b=\"$(git describe --exact-match HEAD 2>/dev/null)\"; then\n \t\t\t\t\tb=\"$(cut -c1-7 \"$g/HEAD\")...\"\n \t\t\t\tfi\n \t\t\tfi\n@@ -138,7 +129,7 @@ __git_ps1 ()\n \t\t\tfi\n \t\tfi\n \n-\t\tif [ -n \"${1-}\" ]; then\n+\t\tif test -n \"${1-}\"; then\n \t\t\tprintf \"$1\" \"${b##refs/heads/}$w$i$r\"\n \t\telse\n \t\t\tprintf \" (%s)\" \"${b##refs/heads/}$w$i$r\"\n@@ -164,7 +155,7 @@ __gitcomp_1 ()\n __gitcomp ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n-\tif [ $# -gt 2 ]; then\n+\tif test $# -gt 2; then\n \t\tcur=\"$3\"\n \tfi\n \tcase \"$cur\" in\n@@ -184,7 +175,7 @@ __gitcomp ()\n __git_heads ()\n {\n \tlocal cmd i is_hash=y dir=\"$(__gitdir \"${1-}\")\"\n-\tif [ -d \"$dir\" ]; then\n+\tif test -d \"$dir\"; then\n \t\tgit --git-dir=\"$dir\" for-each-ref --format='%(refname:short)' \\\n \t\t\trefs/heads\n \t\treturn\n@@ -203,7 +194,7 @@ __git_heads ()\n __git_tags ()\n {\n \tlocal cmd i is_hash=y dir=\"$(__gitdir \"${1-}\")\"\n-\tif [ -d \"$dir\" ]; then\n+\tif test -d \"$dir\"; then\n \t\tgit --git-dir=\"$dir\" for-each-ref --format='%(refname:short)' \\\n \t\t\trefs/tags\n \t\treturn\n@@ -223,14 +214,14 @@ __git_refs ()\n {\n \tlocal i is_hash=y dir=\"$(__gitdir \"${1-}\")\"\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\" format refs\n-\tif [ -d \"$dir\" ]; then\n+\tif test -d \"$dir\"; then\n \t\tcase \"$cur\" in\n \t\trefs|refs/*)\n \t\t\tformat=\"refname\"\n \t\t\trefs=\"${cur%/*}\"\n \t\t\t;;\n \t\t*)\n-\t\t\tif [ -e \"$dir/HEAD\" ]; then echo HEAD; fi\n+\t\t\tif test -e \"$dir/HEAD\"; then echo HEAD; fi\n \t\t\tformat=\"refname:short\"\n \t\t\trefs=\"refs/tags refs/heads refs/remotes\"\n \t\t\t;;\n@@ -299,7 +290,7 @@ __git_remotes ()\n \n __git_merge_strategies ()\n {\n-\tif [ -n \"$__git_merge_strategylist\" ]; then\n+\tif test -n \"$__git_merge_strategylist\"; then\n \t\techo \"$__git_merge_strategylist\"\n \t\treturn\n \tfi\n@@ -385,7 +376,7 @@ __git_complete_revlist ()\n \n __git_all_commands ()\n {\n-\tif [ -n \"$__git_all_commandlist\" ]; then\n+\tif test -n \"$__git_all_commandlist\"; then\n \t\techo \"$__git_all_commandlist\"\n \t\treturn\n \tfi\n@@ -403,7 +394,7 @@ __git_all_commandlist=\"$(__git_all_commands 2>/dev/null)\"\n \n __git_porcelain_commands ()\n {\n-\tif [ -n \"$__git_porcelain_commandlist\" ]; then\n+\tif test -n \"$__git_porcelain_commandlist\"; then\n \t\techo \"$__git_porcelain_commandlist\"\n \t\treturn\n \tfi\n@@ -511,7 +502,7 @@ __git_aliased_command ()\n \tlocal word cmdline=$(git --git-dir=\"$(__gitdir)\" \\\n \t\tconfig --get \"alias.$1\")\n \tfor word in $cmdline; do\n-\t\tif [ \"${word##-*}\" ]; then\n+\t\tif test \"${word##-*}\"; then\n \t\t\techo $word\n \t\t\treturn\n \t\tfi\n@@ -526,7 +517,7 @@ __git_find_subcommand ()\n \twhile [ $c -lt $COMP_CWORD ]; do\n \t\tword=\"${COMP_WORDS[c]}\"\n \t\tfor subcommand in $1; do\n-\t\t\tif [ \"$subcommand\" = \"$word\" ]; then\n+\t\t\tif test \"$subcommand\" = \"$word\"; then\n \t\t\t\techo \"$subcommand\"\n \t\t\t\treturn\n \t\t\tfi\n@@ -539,7 +530,7 @@ __git_has_doubledash ()\n {\n \tlocal c=1\n \twhile [ $c -lt $COMP_CWORD ]; do\n-\t\tif [ \"--\" = \"${COMP_WORDS[c]}\" ]; then\n+\t\tif test \"--\" = \"${COMP_WORDS[c]}\"; then\n \t\t\treturn 0\n \t\tfi\n \t\tc=$((++c))\n@@ -552,7 +543,7 @@ __git_whitespacelist=\"nowarn warn error error-all fix\"\n _git_am ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\" dir=\"$(__gitdir)\"\n-\tif [ -d \"$dir\"/rebase-apply ]; then\n+\tif test -d \"$dir\"/rebase-apply; then\n \t\t__gitcomp \"--skip --resolved --abort\"\n \t\treturn\n \tfi\n@@ -636,7 +627,7 @@ _git_bisect ()\n \n \tlocal subcommands=\"start bad good skip reset visualize replay log run\"\n \tlocal subcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n-\tif [ -z \"$subcommand\" ]; then\n+\tif test -z \"$subcommand\"; then\n \t\t__gitcomp \"$subcommands\"\n \t\treturn\n \tfi\n@@ -672,7 +663,7 @@ _git_branch ()\n \t\t\t\"\n \t\t;;\n \t*)\n-\t\tif [ $only_local_ref = \"y\" -a $has_r = \"n\" ]; then\n+\t\tif test $only_local_ref = \"y\" -a $has_r = \"n\"; then\n \t\t\t__gitcomp \"$(__git_heads)\"\n \t\telse\n \t\t\t__gitcomp \"$(__git_refs)\"\n@@ -830,7 +821,7 @@ _git_fetch ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \n-\tif [ \"$COMP_CWORD\" = 2 ]; then\n+\tif test \"$COMP_CWORD\" = 2; then\n \t\t__gitcomp \"$(__git_remotes)\"\n \telse\n \t\tcase \"$cur\" in\n@@ -1088,7 +1079,7 @@ _git_pull ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \n-\tif [ \"$COMP_CWORD\" = 2 ]; then\n+\tif test \"$COMP_CWORD\" = 2; then\n \t\t__gitcomp \"$(__git_remotes)\"\n \telse\n \t\t__gitcomp \"$(__git_refs \"${COMP_WORDS[2]}\")\"\n@@ -1099,7 +1090,7 @@ _git_push ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \n-\tif [ \"$COMP_CWORD\" = 2 ]; then\n+\tif test \"$COMP_CWORD\" = 2; then\n \t\t__gitcomp \"$(__git_remotes)\"\n \telse\n \t\tcase \"$cur\" in\n@@ -1125,7 +1116,7 @@ _git_push ()\n _git_rebase ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\" dir=\"$(__gitdir)\"\n-\tif [ -d \"$dir\"/rebase-apply ] || [ -d \"$dir\"/rebase-merge ]; then\n+\tif test -d \"$dir\"/rebase-apply || test -d \"$dir\"/rebase-merge; then\n \t\t__gitcomp \"--continue --skip --abort\"\n \t\treturn\n \tfi\n@@ -1416,7 +1407,7 @@ _git_remote ()\n {\n \tlocal subcommands=\"add rename rm show prune update\"\n \tlocal subcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n-\tif [ -z \"$subcommand\" ]; then\n+\tif test -z \"$subcommand\"; then\n \t\t__gitcomp \"$subcommands\"\n \t\treturn\n \tfi\n@@ -1546,7 +1537,7 @@ _git_stash ()\n {\n \tlocal subcommands='save list show apply clear drop pop create branch'\n \tlocal subcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n-\tif [ -z \"$subcommand\" ]; then\n+\tif test -z \"$subcommand\"; then\n \t\t__gitcomp \"$subcommands\"\n \telse\n \t\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n@@ -1576,7 +1567,7 @@ _git_submodule ()\n \t__git_has_doubledash && return\n \n \tlocal subcommands=\"add status init update summary foreach sync\"\n-\tif [ -z \"$(__git_find_subcommand \"$subcommands\")\" ]; then\n+\tif test -z \"$(__git_find_subcommand \"$subcommands\")\"; then\n \t\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \t\tcase \"$cur\" in\n \t\t--*)\n@@ -1598,7 +1589,7 @@ _git_svn ()\n \t\tproplist show-ignore show-externals\n \t\t\"\n \tlocal subcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n-\tif [ -z \"$subcommand\" ]; then\n+\tif test -z \"$subcommand\"; then\n \t\t__gitcomp \"$subcommands\"\n \telse\n \t\tlocal remote_opts=\"--username= --config-dir= --no-auth-cache\"\n@@ -1690,7 +1681,7 @@ _git_tag ()\n \t\tCOMPREPLY=()\n \t\t;;\n \t-*|tag)\n-\t\tif [ $f = 1 ]; then\n+\t\tif test $f = 1; then\n \t\t\t__gitcomp \"$(__git_tags)\"\n \t\telse\n \t\t\tCOMPREPLY=()\n@@ -1718,7 +1709,7 @@ _git ()\n \t\tc=$((++c))\n \tdone\n \n-\tif [ -z \"$command\" ]; then\n+\tif test -z \"$command\"; then\n \t\tcase \"${COMP_WORDS[COMP_CWORD]}\" in\n \t\t--*)   __gitcomp \"\n \t\t\t--paginate\n@@ -1799,7 +1790,7 @@ _gitk ()\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \tlocal g=\"$(__gitdir)\"\n \tlocal merge=\"\"\n-\tif [ -f $g/MERGE_HEAD ]; then\n+\tif test -f $g/MERGE_HEAD; then\n \t\tmerge=\"--merge\"\n \tfi\n \tcase \"$cur\" in\n@@ -1820,7 +1811,7 @@ complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \\\n # when the user has tab-completed the executable name and consequently\n # included the '.exe' suffix.\n #\n-if [ Cygwin = \"$(uname -o 2>/dev/null)\" ]; then\n+if test Cygwin = \"$(uname -o 2>/dev/null)\"; then\n complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \\\n \t|| complete -o default -o nospace -F _git git.exe\n fi\n-- \n1.6.1.2.390.gba743\n"},{"id":"104198","messageId":"1234366634-17900-4-git-send-email-ted@tedpavlic.com","threadId":"17724","inReplyTo":"1234366634-17900-3-git-send-email-ted@tedpavlic.com","subject":"[PATCH 3/3] completion: Prevents GIT_PS1_DIRTYSTATE from breaking when CWD is .git","fromName":"Ted Pavlic","fromEmail":"ted@tedpavlic.com","sentAt":"2009-02-11T15:37:14Z","receivedAt":"2009-02-11T15:37:14Z","isPatch":true,"sender":{"key":"ted@tedpavlic.com","avatar":"https://gravatar.com/avatar/d085392370ff4c028cf17a0e81e0647744c9682fbcb36b499f31d08ef80ef569?d=mp&s=160"},"body":"The GIT_PS1_DIRTYSTATE support uses a \"git diff\" to see if a \"*\" should\nbe placed after the branch name. The \"git diff\" fails with an ugly error\nif the user has just changed directory into GIT_DIR.\n\nThis patch uses \"git rev-parse --is-inside-work-tree\" to determine\nwhether a \"--work-tree=..\" should be added to the \"git diff\".\n\nSigned-off-by: Ted Pavlic <ted@tedpavlic.com>\n---\n contrib/completion/git-completion.bash |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6772be7..ffde82a 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -115,10 +115,14 @@ __git_ps1 ()\n \n \t\tlocal w\n \t\tlocal i\n+\t\tlocal worktreestr\n \n \t\tif test -n \"${GIT_PS1_SHOWDIRTYSTATE-}\"; then\n \t\t\tif test \"$(git config --bool bash.showDirtyState)\" != \"false\"; then\n-\t\t\t\tgit diff --no-ext-diff --ignore-submodules \\\n+\t\t\t\tif test \"false\" = \"$(git rev-parse --is-inside-work-tree 2>/dev/null)\"; then\n+\t\t\t\t\tworktreestr=\"--work-tree=..\"\n+\t\t\t\tfi\n+\t\t\t\tgit ${worktreestr} diff --no-ext-diff --ignore-submodules \\\n \t\t\t\t\t--quiet --exit-code || w=\"*\"\n \t\t\t\tif git rev-parse --quiet --verify HEAD >/dev/null; then\n \t\t\t\t\tgit diff-index --cached --quiet \\\n-- \n1.6.1.2.390.gba743\n"},{"id":"104203","messageId":"1234369132-22063-1-git-send-email-ted@tedpavlic.com","threadId":"17724","inReplyTo":"1234366634-17900-4-git-send-email-ted@tedpavlic.com","subject":"[PATCH 4/3] completion: More fixes to prevent unbound variable errors.","fromName":"Ted Pavlic","fromEmail":"ted@tedpavlic.com","sentAt":"2009-02-11T16:18:52Z","receivedAt":"2009-02-11T16:18:52Z","isPatch":true,"sender":{"key":"ted@tedpavlic.com","avatar":"https://gravatar.com/avatar/d085392370ff4c028cf17a0e81e0647744c9682fbcb36b499f31d08ef80ef569?d=mp&s=160"},"body":"Several functions make use of \"test -n\" and \"test -z\". In many cases,\nthe variables being tested were declared with \"local.\" However, several\n__variables are not, and so they must be replaced with their ${__-}\nequivalents.\n\nSigned-off-by: Ted Pavlic <ted@tedpavlic.com>\n---\n\nThis patch depends on:\n\n    <1234366634-17900-3-git-send-email-ted@tedpavlic.com>\n    \"[PATCH 2/3] completion: Change \"if [...]\" to \"if test ...\" to \n                             match git convention\"\n\nIf that patch is not applied, I can submit a new patch.\n\n contrib/completion/git-completion.bash |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex ffde82a..055e4ac 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -62,7 +62,7 @@ esac\n __gitdir ()\n {\n \tif test -z \"${1-}\"; then\n-\t\tif test -n \"$__git_dir\"; then\n+\t\tif test -n \"${__git_dir-}\"; then\n \t\t\techo \"$__git_dir\"\n \t\telif test -d .git; then\n \t\t\techo .git\n@@ -294,7 +294,7 @@ __git_remotes ()\n \n __git_merge_strategies ()\n {\n-\tif test -n \"$__git_merge_strategylist\"; then\n+\tif test -n \"${__git_merge_strategylist-}\"; then\n \t\techo \"$__git_merge_strategylist\"\n \t\treturn\n \tfi\n@@ -380,7 +380,7 @@ __git_complete_revlist ()\n \n __git_all_commands ()\n {\n-\tif test -n \"$__git_all_commandlist\"; then\n+\tif test -n \"${__git_all_commandlist-}\"; then\n \t\techo \"$__git_all_commandlist\"\n \t\treturn\n \tfi\n@@ -398,7 +398,7 @@ __git_all_commandlist=\"$(__git_all_commands 2>/dev/null)\"\n \n __git_porcelain_commands ()\n {\n-\tif test -n \"$__git_porcelain_commandlist\"; then\n+\tif test -n \"${__git_porcelain_commandlist-}\"; then\n \t\techo \"$__git_porcelain_commandlist\"\n \t\treturn\n \tfi\n-- \n1.6.1.2.390.gba743\n"},{"id":"104204","messageId":"20090211162235.GE30949@spearce.org","threadId":"17724","inReplyTo":"1234366634-17900-2-git-send-email-ted@tedpavlic.com","subject":"Re: [PATCH 1/3] completion: For consistency, changed \"git rev-parse\" to __gitdir calls.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-11T16:22:35Z","receivedAt":"2009-02-11T16:22:35Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Ted Pavlic <ted@tedpavlic.com> wrote:\n> Signed-off-by: Ted Pavlic <ted@tedpavlic.com>\n> ---\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n\n>  contrib/completion/git-completion.bash |    4 ++--\n>  1 files changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index f44f63c..6bbe09a 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -80,7 +80,7 @@ __gitdir ()\n>  # returns text to add to bash PS1 prompt (includes branch name)\n>  __git_ps1 ()\n>  {\n> -\tlocal g=\"$(git rev-parse --git-dir 2>/dev/null)\"\n> +\tlocal g=\"$(__gitdir)\"\n>  \tif [ -n \"$g\" ]; then\n>  \t\tlocal r\n>  \t\tlocal b\n> @@ -1797,7 +1797,7 @@ _gitk ()\n>  \t__git_has_doubledash && return\n>  \n>  \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n> -\tlocal g=\"$(git rev-parse --git-dir 2>/dev/null)\"\n> +\tlocal g=\"$(__gitdir)\"\n>  \tlocal merge=\"\"\n>  \tif [ -f $g/MERGE_HEAD ]; then\n>  \t\tmerge=\"--merge\"\n> -- \n> 1.6.1.2.390.gba743\n> \n\n-- \nShawn.\n"},{"id":"104205","messageId":"20090211162432.GF30949@spearce.org","threadId":"17724","inReplyTo":"1234366634-17900-3-git-send-email-ted@tedpavlic.com","subject":"Re: [PATCH 2/3] completion: Change \"if [...]\" to \"if test ...\" to match git convention","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-11T16:24:32Z","receivedAt":"2009-02-11T16:24:32Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Ted Pavlic <ted@tedpavlic.com> wrote:\n> In the single case of:\n> \n>     if [...] || [...]\n> \n> changed to:\n> \n>     if test ... || test ...\n\nNAK.\n\nThis script only runs in bash.  bash supports [...].  The\nprevailing convention in the script is to use [...].  Only\n4 tests inside of __git_ps1 use \"test\", the rest of the code\nis using [...].\n\nI would agree to a test->[...] conversion patch as its fairly small,\nbut not this one.  Too large, too much code churn, no benefit.\n \n-- \nShawn.\n"},{"id":"104207","messageId":"20090211162612.GG30949@spearce.org","threadId":"17724","inReplyTo":"1234366634-17900-4-git-send-email-ted@tedpavlic.com","subject":"Re: [PATCH 3/3] completion: Prevents GIT_PS1_DIRTYSTATE from breaking when CWD is .git","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-11T16:26:12Z","receivedAt":"2009-02-11T16:26:12Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Ted Pavlic <ted@tedpavlic.com> wrote:\n> The GIT_PS1_DIRTYSTATE support uses a \"git diff\" to see if a \"*\" should\n> be placed after the branch name. The \"git diff\" fails with an ugly error\n> if the user has just changed directory into GIT_DIR.\n> \n> This patch uses \"git rev-parse --is-inside-work-tree\" to determine\n> whether a \"--work-tree=..\" should be added to the \"git diff\".\n\nI think it makes more sense to just drop the work tree stuff from\nthe prompt if we aren't inside the work tree anymore.  Meaning,\nwe should behave as though bash.showDirtyState is false.\n\n \n> Signed-off-by: Ted Pavlic <ted@tedpavlic.com>\n> ---\n>  contrib/completion/git-completion.bash |    6 +++++-\n>  1 files changed, 5 insertions(+), 1 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 6772be7..ffde82a 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -115,10 +115,14 @@ __git_ps1 ()\n>  \n>  \t\tlocal w\n>  \t\tlocal i\n> +\t\tlocal worktreestr\n>  \n>  \t\tif test -n \"${GIT_PS1_SHOWDIRTYSTATE-}\"; then\n>  \t\t\tif test \"$(git config --bool bash.showDirtyState)\" != \"false\"; then\n> -\t\t\t\tgit diff --no-ext-diff --ignore-submodules \\\n> +\t\t\t\tif test \"false\" = \"$(git rev-parse --is-inside-work-tree 2>/dev/null)\"; then\n> +\t\t\t\t\tworktreestr=\"--work-tree=..\"\n> +\t\t\t\tfi\n> +\t\t\t\tgit ${worktreestr} diff --no-ext-diff --ignore-submodules \\\n>  \t\t\t\t\t--quiet --exit-code || w=\"*\"\n>  \t\t\t\tif git rev-parse --quiet --verify HEAD >/dev/null; then\n>  \t\t\t\t\tgit diff-index --cached --quiet \\\n> -- \n> 1.6.1.2.390.gba743\n> \n\n-- \nShawn.\n"},{"id":"104208","messageId":"20090211162814.GH30949@spearce.org","threadId":"17724","inReplyTo":"1234369132-22063-1-git-send-email-ted@tedpavlic.com","subject":"Re: [PATCH 4/3] completion: More fixes to prevent unbound variable errors.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-11T16:28:14Z","receivedAt":"2009-02-11T16:28:14Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Ted Pavlic <ted@tedpavlic.com> wrote:\n> Several functions make use of \"test -n\" and \"test -z\". In many cases,\n> the variables being tested were declared with \"local.\" However, several\n> __variables are not, and so they must be replaced with their ${__-}\n> equivalents.\n> \n> Signed-off-by: Ted Pavlic <ted@tedpavlic.com>\n> ---\n> \n> This patch depends on:\n> \n>     <1234366634-17900-3-git-send-email-ted@tedpavlic.com>\n>     \"[PATCH 2/3] completion: Change \"if [...]\" to \"if test ...\" to \n>                              match git convention\"\n> \n> If that patch is not applied, I can submit a new patch.\n\nLooks OK to me, but I NAK'd the dependency, so you'll have to rebase\nit without the dependency in there.  Or talk me into why that much\nchurn is a good thing.\n\n \n>  contrib/completion/git-completion.bash |    8 ++++----\n>  1 files changed, 4 insertions(+), 4 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index ffde82a..055e4ac 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -62,7 +62,7 @@ esac\n>  __gitdir ()\n>  {\n>  \tif test -z \"${1-}\"; then\n> -\t\tif test -n \"$__git_dir\"; then\n> +\t\tif test -n \"${__git_dir-}\"; then\n>  \t\t\techo \"$__git_dir\"\n>  \t\telif test -d .git; then\n>  \t\t\techo .git\n> @@ -294,7 +294,7 @@ __git_remotes ()\n>  \n>  __git_merge_strategies ()\n>  {\n> -\tif test -n \"$__git_merge_strategylist\"; then\n> +\tif test -n \"${__git_merge_strategylist-}\"; then\n>  \t\techo \"$__git_merge_strategylist\"\n>  \t\treturn\n>  \tfi\n> @@ -380,7 +380,7 @@ __git_complete_revlist ()\n>  \n>  __git_all_commands ()\n>  {\n> -\tif test -n \"$__git_all_commandlist\"; then\n> +\tif test -n \"${__git_all_commandlist-}\"; then\n>  \t\techo \"$__git_all_commandlist\"\n>  \t\treturn\n>  \tfi\n> @@ -398,7 +398,7 @@ __git_all_commandlist=\"$(__git_all_commands 2>/dev/null)\"\n>  \n>  __git_porcelain_commands ()\n>  {\n> -\tif test -n \"$__git_porcelain_commandlist\"; then\n> +\tif test -n \"${__git_porcelain_commandlist-}\"; then\n>  \t\techo \"$__git_porcelain_commandlist\"\n>  \t\treturn\n>  \tfi\n> -- \n> 1.6.1.2.390.gba743\n> \n\n-- \nShawn.\n"},{"id":"104209","messageId":"4992FE78.6000206@tedpavlic.com","threadId":"17724","inReplyTo":"20090211162432.GF30949@spearce.org","subject":"Re: [PATCH 2/3] completion: Change \"if [...]\" to \"if test ...\" to match git convention","fromName":"Ted Pavlic","fromEmail":"ted@tedpavlic.com","sentAt":"2009-02-11T16:36:08Z","receivedAt":"2009-02-11T16:36:08Z","isPatch":true,"sender":{"key":"ted@tedpavlic.com","avatar":"https://gravatar.com/avatar/d085392370ff4c028cf17a0e81e0647744c9682fbcb36b499f31d08ef80ef569?d=mp&s=160"},"body":"> NAK.\n>\n> This script only runs in bash.  bash supports [...].  The\n> prevailing convention in the script is to use [...].  Only\n> 4 tests inside of __git_ps1 use \"test\", the rest of the code\n> is using [...].\n\nSo this trumps Documentation/CodingGuidelines, which says:\n\n  - We prefer \"test\" over \"[ ... ]\".\n\n?\n\nThanks --\nTed\n\n-- \nTed Pavlic <ted@tedpavlic.com>\n\n   Please visit my ALS association page:\n         http://web.alsa.org/goto/tedpavlic\n   My family appreciates your support in the fight to defeat ALS.\n"},{"id":"104210","messageId":"7vwsbwgbw6.fsf@gitster.siamese.dyndns.org","threadId":"17724","inReplyTo":"1234366634-17900-3-git-send-email-ted@tedpavlic.com","subject":"Re: [PATCH 2/3] completion: Change \"if [...]\" to \"if test ...\" to match git convention","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-11T16:46:01Z","receivedAt":"2009-02-11T16:46:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ted Pavlic <ted@tedpavlic.com> writes:\n\n> In the single case of:\n>\n>     if [...] || [...]\n>\n> changed to:\n>\n>     if test ... || test ...\n\nIn [0/3] you talked about \"git convention\", but please match the local\nconvention, especially inside contrib/ area.  That is, consistency of the\nstyle within the same file (and files in vicinity), is more important.\n\n> Also changed:\n>\n>     if test ...\n>     then\n>\n> to:\n>\n>     if test ...; then\n\nThe prevailing style in bash completion script is to write \"then\" on the\nsame line as \"if\", so I think this is a good example of matching the local\nconvention (if you are trying to match \"git convention\", \"then\" is written\non the same column as \"if\" on a line by itself for readability, so this\nchange is going backwards).\n"},{"id":"104211","messageId":"4993028C.4010204@tedpavlic.com","threadId":"17724","inReplyTo":"20090211162612.GG30949@spearce.org","subject":"Re: [PATCH 3/3] completion: Prevents GIT_PS1_DIRTYSTATE from breaking when CWD is .git","fromName":"Ted Pavlic","fromEmail":"ted@tedpavlic.com","sentAt":"2009-02-11T16:53:32Z","receivedAt":"2009-02-11T16:53:32Z","isPatch":true,"sender":{"key":"ted@tedpavlic.com","avatar":"https://gravatar.com/avatar/d085392370ff4c028cf17a0e81e0647744c9682fbcb36b499f31d08ef80ef569?d=mp&s=160"},"body":">> This patch uses \"git rev-parse --is-inside-work-tree\" to determine\n>> whether a \"--work-tree=..\" should be added to the \"git diff\".\n>\n> I think it makes more sense to just drop the work tree stuff from\n> the prompt if we aren't inside the work tree anymore.  Meaning,\n> we should behave as though bash.showDirtyState is false.\n\nI see.\n\nAt first, it seemed like it would be useful to know if the working \ndirectory was dirty even when you're within .git. However, I guess \nthat's problematic when your working tree is in some completely \nunpredictable location. It's probably a bad idea to assume that work-tree=..\n\nSo you're right... there's a logical problem with having showDirtyState \nturned on when within .git. It should be disabled there.\n\nSo I'll check for \"git rev-parse --is-inside-git-dir\" and disable \nshowDirtyState appropriately.\n\n--Ted\n\n-- \nTed Pavlic <ted@tedpavlic.com>\n\n   Please visit my ALS association page:\n         http://web.alsa.org/goto/tedpavlic\n   My family appreciates your support in the fight to defeat ALS.\n"},{"id":"104212","messageId":"7vprhogbfa.fsf@gitster.siamese.dyndns.org","threadId":"17724","inReplyTo":"1234366634-17900-4-git-send-email-ted@tedpavlic.com","subject":"Re: [PATCH 3/3] completion: Prevents GIT_PS1_DIRTYSTATE from breaking when CWD is .git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-11T16:56:09Z","receivedAt":"2009-02-11T16:56:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ted Pavlic <ted@tedpavlic.com> writes:\n\n> The GIT_PS1_DIRTYSTATE support uses a \"git diff\" to see if a \"*\" should\n> be placed after the branch name. The \"git diff\" fails with an ugly error\n> if the user has just changed directory into GIT_DIR.\n>\n> This patch uses \"git rev-parse --is-inside-work-tree\" to determine\n> whether a \"--work-tree=..\" should be added to the \"git diff\".\n\nWhy \"..\"?  What prevents you from \"cd .git/refs/heads\"?\n\nYour \"is-inside-work-tree\" might be a good change, but if you were to\nspend a letter to notify the users, \"Warning: You are inside GIT_DIR! This\nis something unusual, proceed with caution.\" is a lot more important\nnotice to give them than \"You seem to have unstaged changes\" notice.\n\nYou have at least three possible states:\n\n * You are not in git repository at all;\n\n * You are somewhere in $GIT_DIR, perhaps in a bare repository, perhaps a\n   repository with a work tree.\n\n * You are inside a work tree.\n\nThe first should be quiet, the second should say \"Proceed with caution,\nany 'rm -f file' or 'edit file' you do here should be to recover from\nunusual repository corruptoin only; you are welcome to look but don't\ntouch.\", and the last one is Ok to say \"You have unstaged changes.\"\n"},{"id":"104217","messageId":"7vljscgak4.fsf@gitster.siamese.dyndns.org","threadId":"17724","inReplyTo":"4992FE78.6000206@tedpavlic.com","subject":"Re: [PATCH 2/3] completion: Change \"if [...]\" to \"if test ...\" to match git convention","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-11T17:14:51Z","receivedAt":"2009-02-11T17:14:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ted Pavlic <ted@tedpavlic.com> writes:\n\n>> NAK.\n>>\n>> This script only runs in bash.  bash supports [...].  The\n>> prevailing convention in the script is to use [...].  Only\n>> 4 tests inside of __git_ps1 use \"test\", the rest of the code\n>> is using [...].\n>\n> So this trumps Documentation/CodingGuidelines, which says:\n>\n>  - We prefer \"test\" over \"[ ... ]\".\n>\n> ?\n\nNo, this paragraph from Documentation/CodingGuidelines trumps you.\n\n    As for more concrete guidelines, just imitate the existing code\n    (this is a good guideline, no matter which project you are\n    contributing to). It is always preferable to match the _local_\n    convention. New code added to git suite is expected to match\n    the overall style of existing code. Modifications to existing\n    code is expected to match the style the surrounding code already\n    uses (even if it doesn't match the overall style of existing code).\n"},{"id":"104219","messageId":"499308DA.9090208@tedpavlic.com","threadId":"17724","inReplyTo":"7vprhogbfa.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/3] completion: Prevents GIT_PS1_DIRTYSTATE from breaking when CWD is .git","fromName":"Ted Pavlic","fromEmail":"ted@tedpavlic.com","sentAt":"2009-02-11T17:20:26Z","receivedAt":"2009-02-11T17:20:26Z","isPatch":true,"sender":{"key":"ted@tedpavlic.com","avatar":"https://gravatar.com/avatar/d085392370ff4c028cf17a0e81e0647744c9682fbcb36b499f31d08ef80ef569?d=mp&s=160"},"body":">> This patch uses \"git rev-parse --is-inside-work-tree\" to determine\n>> whether a \"--work-tree=..\" should be added to the \"git diff\".\n>\n> Why \"..\"?  What prevents you from \"cd .git/refs/heads\"?\n\nIt was my impression that --work-tree=.. was relative to the GIT_DIR. My \ntests seem to confirm that. Within the git work tree I do:\n\n\techo \"test\">>COPYING\n\nthen\n\n\tcd .git/refs/heads\n\tgit --work=tree=.. diff\n\nand that produces a diff of COPYING showing the new line.\n\n(\"man git\" confused me about how WORK_TREE was supposed to work)\n\n> Your \"is-inside-work-tree\" might be a good change, but if you were to\n> spend a letter to notify the users, \"Warning: You are inside GIT_DIR! This\n> is something unusual, proceed with caution.\" is a lot more important\n> notice to give them than \"You seem to have unstaged changes\" notice.\n\nOk, so if \"is-inside-git-dir\" then send a special \"!\" flag (and no \ndirtyState flags)? Does that seem reasonable?\n\nAdditionally, is it a good idea to echo the branch name when inside the \ngit dir? That is, what does it \"mean\" to be on \"master\" when you're \ninside .git?\n\n> You have at least three possible states:\n>   * You are not in git repository at all;\n>   * You are somewhere in $GIT_DIR, perhaps in a bare repository, perhaps a\n>     repository with a work tree.\n>   * You are inside a work tree.\n\nIt seems like (psuedocode)...\n\n\tif git rev-parse --is-inside-git-dir; then\n\t\tuse '!' flag to indicate caution\n\n\telif git rev-parse --is-inside-work-tree; then\n\t\tproceed as before (with '*' and '+' flags)\n\n\telse\n\t\tdo nothing\n\nI think that handles those cases. No?\n\nThanks --\n--Ted\n\n-- \nTed Pavlic <ted@tedpavlic.com>\n\n   Please visit my ALS association page:\n         http://web.alsa.org/goto/tedpavlic\n   My family appreciates your support in the fight to defeat ALS.\n"},{"id":"104227","messageId":"20090211180100.GJ30949@spearce.org","threadId":"17724","inReplyTo":"499308DA.9090208@tedpavlic.com","subject":"Re: [PATCH 3/3] completion: Prevents GIT_PS1_DIRTYSTATE from breaking when CWD is .git","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-11T18:01:00Z","receivedAt":"2009-02-11T18:01:00Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Ted Pavlic <ted@tedpavlic.com> wrote:\n>\n>> You have at least three possible states:\n>>   * You are not in git repository at all;\n>>   * You are somewhere in $GIT_DIR, perhaps in a bare repository, perhaps a\n>>     repository with a work tree.\n>>   * You are inside a work tree.\n>\n> It seems like (psuedocode)...\n>\n> \tif git rev-parse --is-inside-git-dir; then\n> \t\tuse '!' flag to indicate caution\n>\n> \telif git rev-parse --is-inside-work-tree; then\n> \t\tproceed as before (with '*' and '+' flags)\n>\n> \telse\n> \t\tdo nothing\n>\n> I think that handles those cases. No?\n\nYes, that looks right to me.\n\n-- \nShawn.\n"}]}