From 436b0da13812d4ec9ba4cc6c969ff153e5b78a7e Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 23 Oct 2012 23:34:15 +1300 Subject: [PATCH 1/4] Further ll fixes for escaped spaces and quotes! --- lib/git/shell_shortcuts.sh | 4 +--- lib/git/status_shortcuts.sh | 2 +- test/lib/git/shell_shortcuts_test.sh | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 1134fdd..532eb61 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -154,13 +154,11 @@ EOF else ll_files="$(\ls "$@")" fi - # Escape single and double quotes - ll_files=$(echo "$ll_files" | \sed -e 's/"/\\\\\\"/g' -e "s/'"'/\\\\'"'/g") OLDIFS="$IFS"; IFS=$'\n' for file in $ll_files; do if [ -n "$rel_path" ]; then file="$rel_path/$file"; fi - export $git_env_char$e="$(eval $_abs_path_command \"$file\")" + export $git_env_char$e="$(eval $_abs_path_command \"${file//\"/\\\"}\")" if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi let e++ done diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index 345dcb4..2b6bde6 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -138,7 +138,7 @@ scmb_expand_args() { # Execute a command with expanded args, e.g. Delete files 6 to 12: $ ge rm 6-12 # Fails if command is a number or range (probably not worth fixing) -exec_scmb_expand_args() { eval "$(scmb_expand_args "$@" | sed -e 's/\([][()<>^ ]\)/\\\1/g')"; } +exec_scmb_expand_args() { eval "$(scmb_expand_args "$@" | sed -e "s/\([][()<>^ \"']\)/"'\\\1/g')"; } # Clear numbered env variables git_clear_vars() { diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 8608439..e5c860e 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -86,14 +86,20 @@ test_ls_with_file_shortcuts() { assertIncludes "$ls_output" '[5] test_file' F # Test filenames with single or double quotes escaped - assertEquals "$TEST_DIR/a \\\"b\\\"" "$e1" - assertEquals "$TEST_DIR/a \\'b\\'" "$e2" - assertEquals "$TEST_DIR/a [b]" "$e3" - assertEquals "$TEST_DIR/test file" "$e4" - assertEquals "$TEST_DIR/test_file" "$e5" + assertEquals "$TEST_DIR/"'a "b"' "$e1" + assertEquals "$TEST_DIR/a 'b'" "$e2" + assertEquals "$TEST_DIR/a [b]" "$e3" + assertEquals "$TEST_DIR/test file" "$e4" + assertEquals "$TEST_DIR/test_file" "$e5" # Test ls with subdirectory - ls_output=$(ls_with_file_shortcuts "a \"b\"" | strip_colors) + ls_with_file_shortcuts 'a "b"' > $temp_file + ls_output=$(<$temp_file strip_colors) + assertIncludes "$ls_output" '[1] c' F + # Test that env variable is set correctly + assertEquals "$TEST_DIR/a \"b\"/c" "$e1" + # Test arg with no quotes + ls_output=$(ls_with_file_shortcuts a\ \"b\" | strip_colors) assertIncludes "$ls_output" '[1] c' F } From 7375597407af37774f4440e67ebd42cbd88b96b9 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 10 Nov 2012 13:47:25 +1300 Subject: [PATCH 2/4] Added shortcut to commit README / Documentation with [ci skip] --- lib/git/tools.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/git/tools.sh b/lib/git/tools.sh index 2f64e72..8493517 100644 --- a/lib/git/tools.sh +++ b/lib/git/tools.sh @@ -136,3 +136,7 @@ git_branch_delete_all() { $_git_cmd branch -D -r origin/$1 $_git_cmd push origin :$1 } + +commit_docs() { + git commit -m "Update README / Documentation [ci skip]" +} \ No newline at end of file From 992b1866b272e03936761e4467f38cb3c79a1dcf Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 13 Nov 2012 12:45:01 +1300 Subject: [PATCH 3/4] Use type -p / -P to determine git binary --- lib/git/status_shortcuts.rb | 10 +++++----- lib/scm_breeze.sh | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/git/status_shortcuts.rb b/lib/git/status_shortcuts.rb index fcb37ec..9f2e4e3 100644 --- a/lib/git/status_shortcuts.rb +++ b/lib/git/status_shortcuts.rb @@ -20,11 +20,11 @@ # # groups => 1: staged, 2: unmerged, 3: unstaged, 4: untracked # -------------------------------------------------------------------- -@project_root = File.exist?(".git") ? Dir.pwd : `git rev-parse --git-dir 2> /dev/null`.sub(/\/\.git$/, '').strip +@project_root = File.exist?(".git") ? Dir.pwd : `\git rev-parse --git-dir 2> /dev/null`.sub(/\/\.git$/, '').strip -@git_status = `git status --porcelain 2> /dev/null` +@git_status = `\git status --porcelain 2> /dev/null` -git_branch = `git branch -v 2> /dev/null` +git_branch = `\git branch -v 2> /dev/null` @branch = git_branch[/^\* (\(no branch\)|[^ ]*)/, 1] @ahead = git_branch[/^\* [^ ]* *[^ ]* *\[ahead ?(\d+)\]/, 1] @@ -102,7 +102,7 @@ end @git_status_long = `git status`.gsub(/\033\[[^m]*m/, "") # (strip colors) end end - + msg, col, group = case change[0..1] when "DD"; [" both deleted", :del, :unmerged] @@ -156,7 +156,7 @@ def output_file_group(group) # Find relative path, i.e. ../../lib/path/to/file rel_file = relative_path(Dir.pwd, File.join(@project_root, h[:file])) - + # If some submodules have changed, parse their summaries from long git status sub_stat = nil if @git_status_long && (sub_stat = @git_status_long[/#{h[:file]} \((.*)\)/, 1]) diff --git a/lib/scm_breeze.sh b/lib/scm_breeze.sh index d2df923..b9f5a4d 100644 --- a/lib/scm_breeze.sh +++ b/lib/scm_breeze.sh @@ -12,7 +12,11 @@ disable_nullglob() { if [ $shell = "zsh" ]; then unsetopt NULL_GLOB; else shopt # Alias wrapper that ignores errors if alias is not defined. _alias(){ alias "$@" 2> /dev/null; } -export GIT_BINARY=$(which git) +if [ $shell = "zsh" ]; then + export GIT_BINARY=$(type -p git | sed 's/git is //') +else + export GIT_BINARY=$(type -P git) +fi # Updates SCM Breeze from GitHub. update_scm_breeze() { From 480045e5a4b82ca8c87a2f46a3433d0f9ec94bbd Mon Sep 17 00:00:00 2001 From: Yan Pritzker Date: Tue, 13 Nov 2012 10:27:57 -0600 Subject: [PATCH 4/4] Pick the first git in case there are multiple --- lib/scm_breeze.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scm_breeze.sh b/lib/scm_breeze.sh index b9f5a4d..0dc30ce 100644 --- a/lib/scm_breeze.sh +++ b/lib/scm_breeze.sh @@ -13,7 +13,7 @@ disable_nullglob() { if [ $shell = "zsh" ]; then unsetopt NULL_GLOB; else shopt _alias(){ alias "$@" 2> /dev/null; } if [ $shell = "zsh" ]; then - export GIT_BINARY=$(type -p git | sed 's/git is //') + export GIT_BINARY=$(type -p git | sed 's/git is //' | head -1) else export GIT_BINARY=$(type -P git) fi