zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] vcs_info: Silence an error message with new git versions
@ 2015-10-11  9:54 Frank Terbeck
  2015-10-11 10:25 ` Frank Terbeck
  0 siblings, 1 reply; 3+ messages in thread
From: Frank Terbeck @ 2015-10-11  9:54 UTC (permalink / raw)
  To: zsh-workers

Mikael informs me on IRC, that in new versions of git (he used 2.6.1)
where the "am" subcommand is now a builtin, a file that is used by the
git backend of vcs_info (namely .git/rebase-apply/msg-clean) is not
available anymore, leading to an annoying error message:

  VCS_INFO_get_data_git:232: no such file or directory: .git/rebase-apply/msg-clean

This patch checks for the availabiliy of the file before using it,
and adjusts the value of the dependant values accordingly.
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 34 +++++++++++++++--------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 8ecc7c7..dcff616 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -219,18 +219,28 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
     patchdir="${gitdir}/rebase-apply"
     local next="${patchdir}/next"
     if [[ -f $next ]]; then
-	local cur=$(< $next)
-	local p subject
-	for p in $(seq $(($cur - 1))); do
-	    git_patches_applied+=("$(printf "%04d" $p) ?")
-	done
-	subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
-	if [[ -f "${patchdir}/original-commit" ]]; then
-	    git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
-	else
-	    git_patches_applied+=("? $subject")
-	fi
-	git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
+        local cur=$(< $next)
+        local p subject
+        for p in $(seq $(($cur - 1))); do
+            git_patches_applied+=("$(printf "%04d" $p) ?")
+        done
+        if [[ -f "${patchdir}/msg-clean" ]]; then
+            subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
+        fi
+        if [[ -f "${patchdir}/original-commit" ]]; then
+            if [[ -n $subject ]]; then
+                git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
+            else
+                git_patches_applied+=("$(< ${patchdir}/original-commit)")
+            fi
+        else
+            if [[ -n $subject ]]; then
+                git_patches_applied+=("? $subject")
+            else
+                git_patches_applied+=("?")
+            fi
+        fi
+        git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
     fi
 
     VCS_INFO_git_handle_patches
-- 
2.1.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vcs_info: Silence an error message with new git versions
  2015-10-11  9:54 [PATCH] vcs_info: Silence an error message with new git versions Frank Terbeck
@ 2015-10-11 10:25 ` Frank Terbeck
  2015-10-14 12:26   ` Roman Neuhauser
  0 siblings, 1 reply; 3+ messages in thread
From: Frank Terbeck @ 2015-10-11 10:25 UTC (permalink / raw)
  To: zsh-workers

Frank Terbeck wrote:
>  Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 34 +++++++++++++++--------
>  1 file changed, 22 insertions(+), 12 deletions(-)

The diff looks a bit large: The reason is that the portion of the code
used tabs for indentation, which is done nowhere in the rest of
vcs_info. I called "M-x untabify" on it before making my changes to the
code. Ignoring the whitespace changes, the diff looks like this:


diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 8ecc7c7..dcff616 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -224,11 +224,21 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
         for p in $(seq $(($cur - 1))); do
             git_patches_applied+=("$(printf "%04d" $p) ?")
         done
+        if [[ -f "${patchdir}/msg-clean" ]]; then
             subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
+        fi
         if [[ -f "${patchdir}/original-commit" ]]; then
+            if [[ -n $subject ]]; then
                 git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
             else
+                git_patches_applied+=("$(< ${patchdir}/original-commit)")
+            fi
+        else
+            if [[ -n $subject ]]; then
                 git_patches_applied+=("? $subject")
+            else
+                git_patches_applied+=("?")
+            fi
         fi
         git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
     fi


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vcs_info: Silence an error message with new git versions
  2015-10-11 10:25 ` Frank Terbeck
@ 2015-10-14 12:26   ` Roman Neuhauser
  0 siblings, 0 replies; 3+ messages in thread
From: Roman Neuhauser @ 2015-10-14 12:26 UTC (permalink / raw)
  To: Frank Terbeck; +Cc: zsh-workers

# ft@bewatermyfriend.org / 2015-10-11 12:25:05 +0200:
> diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
> index 8ecc7c7..dcff616 100644
> --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
> +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
> @@ -224,11 +224,21 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
>          for p in $(seq $(($cur - 1))); do
>              git_patches_applied+=("$(printf "%04d" $p) ?")
>          done
> +        if [[ -f "${patchdir}/msg-clean" ]]; then
>              subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
> +        fi
>          if [[ -f "${patchdir}/original-commit" ]]; then
> +            if [[ -n $subject ]]; then
>                  git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
>              else
> +                git_patches_applied+=("$(< ${patchdir}/original-commit)")
> +            fi
> +        else
> +            if [[ -n $subject ]]; then
>                  git_patches_applied+=("? $subject")
> +            else
> +                git_patches_applied+=("?")
> +            fi
>          fi
>          git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
>      fi

  declare originalcommit='?'
  if [[ -f "${patchdir}/original-commit" ]]; then
      originalcommit="$(< ${patchdir}/original-commit)"
  fi
  git_patches_applied+=("$originalcommit${subject+ $subject}")

-- 
roman


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-14 12:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-11  9:54 [PATCH] vcs_info: Silence an error message with new git versions Frank Terbeck
2015-10-11 10:25 ` Frank Terbeck
2015-10-14 12:26   ` Roman Neuhauser

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).