From d48d298c9fbd972de44456ddffaac8a730db182e Mon Sep 17 00:00:00 2001 From: Brian Tuttle Date: Fri, 16 Sep 2011 00:45:58 -0600 Subject: [PATCH 1/2] simplify git completion while loop to prevent git PS1 from breaking in msys environment --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b36290fa6015d9..24a08a760515dc 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -110,6 +110,7 @@ __git_ps1_show_upstream () local upstream=git legacy="" verbose="" # get some config options from git-config + (git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ') |\ while read key value; do case "$key" in bash.showupstream) @@ -125,8 +126,7 @@ __git_ps1_show_upstream () upstream=svn+git # default upstream is SVN if available, else git ;; esac - done < <(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ') - + done # parse configuration values for option in ${GIT_PS1_SHOWUPSTREAM}; do case "$option" in @@ -2058,7 +2058,7 @@ _git_config () color.ui commit.status commit.template - core.abbrevguard + core.abbrev core.askpass core.attributesfile core.autocrlf From 1bffb9a1f0559465c486cf8aa1e035c619d2df01 Mon Sep 17 00:00:00 2001 From: Brian Tuttle Date: Fri, 16 Sep 2011 00:54:06 -0600 Subject: [PATCH 2/2] modify git-submodule local variable name to avoid msys confusing it with path environment variable --- git-submodule.sh | 152 +++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 26ad9dac70d002..3bedef54a8673b 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -79,12 +79,12 @@ module_list() my ($null_sha1) = ("0" x 40); while () { chomp; - my ($mode, $sha1, $stage, $path) = + my ($mode, $sha1, $stage, $modulepath) = /^([0-7]+) ([0-9a-f]{40}) ([0-3])\t(.*)$/; next unless $mode eq "160000"; if ($stage ne "0") { - if (!$unmerged{$path}++) { - print "$mode $null_sha1 U\t$path\n"; + if (!$unmerged{$modulepath}++) { + print "$mode $null_sha1 U\t$modulepath\n"; } next; } @@ -105,7 +105,7 @@ module_name() name=$( git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' ) test -z "$name" && - die "$(eval_gettext "No submodule mapping found in .gitmodules for path '\$path'")" + die "$(eval_gettext "No submodule mapping found in .gitmodules for path '\$modulepath'")" echo "$name" } @@ -119,17 +119,17 @@ module_name() # module_clone() { - path=$1 + modulepath=$1 url=$2 reference="$3" if test -n "$reference" then - git-clone "$reference" -n "$url" "$path" + git-clone "$reference" -n "$url" "$modulepath" else - git-clone -n "$url" "$path" + git-clone -n "$url" "$modulepath" fi || - die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")" + die "$(eval_gettext "Clone of '\$url' into submodule path '\$modulepath' failed")" } # @@ -180,14 +180,14 @@ cmd_add() done repo=$1 - path=$2 + modulepath=$2 - if test -z "$path"; then - path=$(echo "$repo" | + if test -z "$modulepath"; then + modulepath=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g') fi - if test -z "$repo" -o -z "$path"; then + if test -z "$repo" -o -z "$modulepath"; then usage fi @@ -208,7 +208,7 @@ cmd_add() # normalize path: # multiple //; leading ./; /./; /../; trailing / - path=$(printf '%s/\n' "$path" | + modulepath=$(printf '%s/\n' "$modulepath" | sed -e ' s|//*|/|g s|^\(\./\)*|| @@ -218,27 +218,27 @@ cmd_add() tstart s|/*$|| ') - git ls-files --error-unmatch "$path" > /dev/null 2>&1 && - die "$(eval_gettext "'\$path' already exists in the index")" + git ls-files --error-unmatch "$modulepath" > /dev/null 2>&1 && + die "$(eval_gettext "'\$modulepath' already exists in the index")" - if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1 + if test -z "$force" && ! git add --dry-run --ignore-missing "$modulepath" > /dev/null 2>&1 then cat >&2 <&2 "Skipping unmerged submodule $path" + echo >&2 "Skipping unmerged submodule $modulepath" continue fi - name=$(module_name "$path") || exit + name=$(module_name "$modulepath") || exit url=$(git config submodule."$name".url) update_module=$(git config submodule."$name".update) if test -z "$url" @@ -463,20 +463,20 @@ cmd_update() # Only mention uninitialized submodules when its # path have been specified test "$#" != "0" && - say "$(eval_gettext "Submodule path '\$path' not initialized + say "$(eval_gettext "Submodule path '\$modulepath' not initialized Maybe you want to use 'update --init'?")" continue fi - if ! test -d "$path"/.git -o -f "$path"/.git + if ! test -d "$modulepath"/.git -o -f "$modulepath"/.git then - module_clone "$path" "$url" "$reference"|| exit + module_clone "$modulepath" "$url" "$reference"|| exit cloned_modules="$cloned_modules;$name" subsha1= else - subsha1=$(clear_local_git_env; cd "$path" && + subsha1=$(clear_local_git_env; cd "$modulepath" && git rev-parse --verify HEAD) || - die "$(eval_gettext "Unable to find current revision in submodule path '\$path'")" + die "$(eval_gettext "Unable to find current revision in submodule path '\$modulepath'")" fi if ! test -z "$update" @@ -497,10 +497,10 @@ Maybe you want to use 'update --init'?")" then # Run fetch only if $sha1 isn't present or it # is not reachable from a ref. - (clear_local_git_env; cd "$path" && + (clear_local_git_env; cd "$modulepath" && ( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) && test -z "$rev") || git-fetch)) || - die "$(eval_gettext "Unable to fetch in submodule path '\$path'")" + die "$(eval_gettext "Unable to fetch in submodule path '\$modulepath'")" fi # Is this something we just cloned? @@ -513,29 +513,29 @@ Maybe you want to use 'update --init'?")" case "$update_module" in rebase) command="git rebase" - die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$path'")" - say_msg="$(eval_gettext "Submodule path '\$path': rebased into '\$sha1'")" + die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$modulepath'")" + say_msg="$(eval_gettext "Submodule path '\$modulepath': rebased into '\$sha1'")" ;; merge) command="git merge" - die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$path'")" - say_msg="$(eval_gettext "Submodule path '\$path': merged in '\$sha1'")" + die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$modulepath'")" + say_msg="$(eval_gettext "Submodule path '\$modulepath': merged in '\$sha1'")" ;; *) command="git checkout $subforce -q" - die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$path'")" - say_msg="$(eval_gettext "Submodule path '\$path': checked out '\$sha1'")" + die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$modulepath'")" + say_msg="$(eval_gettext "Submodule path '\$modulepath': checked out '\$sha1'")" ;; esac - (clear_local_git_env; cd "$path" && $command "$sha1") || die $die_msg + (clear_local_git_env; cd "$modulepath" && $command "$sha1") || die $die_msg say $say_msg fi if test -n "$recursive" then - (clear_local_git_env; cd "$path" && eval cmd_update "$orig_flags") || - die "$(eval_gettext "Failed to recurse into submodule path '\$path'")" + (clear_local_git_env; cd "$modulepath" && eval cmd_update "$orig_flags") || + die "$(eval_gettext "Failed to recurse into submodule path '\$modulepath'")" fi done } @@ -805,30 +805,30 @@ cmd_status() done module_list "$@" | - while read mode sha1 stage path + while read mode sha1 stage modulepath do - name=$(module_name "$path") || exit + name=$(module_name "$modulepath") || exit url=$(git config submodule."$name".url) - displaypath="$prefix$path" + displaypath="$prefix$modulepath" if test "$stage" = U then say "U$sha1 $displaypath" continue fi - if test -z "$url" || ! test -d "$path"/.git -o -f "$path"/.git + if test -z "$url" || ! test -d "$modulepath"/.git -o -f "$modulepath"/.git then say "-$sha1 $displaypath" continue; fi - set_name_rev "$path" "$sha1" - if git diff-files --ignore-submodules=dirty --quiet -- "$path" + set_name_rev "$modulepath" "$sha1" + if git diff-files --ignore-submodules=dirty --quiet -- "$modulepath" then say " $sha1 $displaypath$revname" else if test -z "$cached" then - sha1=$(clear_local_git_env; cd "$path" && git rev-parse --verify HEAD) - set_name_rev "$path" "$sha1" + sha1=$(clear_local_git_env; cd "$modulepath" && git rev-parse --verify HEAD) + set_name_rev "$modulepath" "$sha1" fi say "+$sha1 $displaypath$revname" fi @@ -838,10 +838,10 @@ cmd_status() ( prefix="$displaypath/" clear_local_git_env - cd "$path" && + cd "$modulepath" && eval cmd_status "$orig_args" ) || - die "$(eval_gettext "Failed to recurse into submodule path '\$path'")" + die "$(eval_gettext "Failed to recurse into submodule path '\$modulepath'")" fi done } @@ -873,9 +873,9 @@ cmd_sync() done cd_to_toplevel module_list "$@" | - while read mode sha1 stage path + while read mode sha1 stage modulepath do - name=$(module_name "$path") + name=$(module_name "$modulepath") url=$(git config -f .gitmodules --get submodule."$name".url) # Possibly a url relative to parent @@ -888,11 +888,11 @@ cmd_sync() say "$(eval_gettext "Synchronizing submodule url for '\$name'")" git config submodule."$name".url "$url" - if test -e "$path"/.git + if test -e "$modulepath"/.git then ( clear_local_git_env - cd "$path" + cd "$modulepath" remote=$(get_default_remote) git config remote."$remote".url "$url" )