threads / patch / 20407

patchrebase: consistent error messages for staged and unstaged changes.

Subject: [PATCH] rebase: consistent error messages for staged and unstaged changes.

## tl;dr

3 messages between Aug 5, 2009 and Aug 6, 2009. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Matthieu Moy· Aug 5, 2009, 15:13 UTC · lore

Previous version expose the output of the plumbing update-index to the user, which novice users have difficulty to understand.

We still need to run update-index to refresh the cache (if
diff.autorefreshindex is false, git diff won't do it).
---
 git-rebase.sh |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Show changes to git-rebase.sh +4 −2
diff --git a/git-rebase.sh b/git-rebase.sh
index 18bc694..3555d17 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -382,8 +382,10 @@ else
 fi
 
 # The tree must be really really clean.
-if ! git update-index --ignore-submodules --refresh; then
-	die "cannot rebase: you have unstaged changes"
+if ! git update-index --ignore-submodules --refresh > /dev/null; then
+	echo >&2 "cannot rebase: you have unstaged changes"
+	git diff --name-status -r --ignore-submodules -- >&2
+	exit 1
 fi
 diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
 case "$diff" in
-- 
1.6.4.18.g07a4a.dirty
Junio C Hamano· Aug 5, 2009, 17:24 UTC · re: Matthieu Moy · lore

Re: [PATCH] rebase: consistent error messages for staged and unstaged changes.

Matthieu Moy <Matthieu.Moy@imag.fr> writes:
> Previous version expose the output of the plumbing update-index to the
> user, which novice users have difficulty to understand.
Can't -q(uiet) option of update-index be used for this?
Show 26 quoted lines
>
> We still need to run update-index to refresh the cache (if
> diff.autorefreshindex is false, git diff won't do it).
> ---
>  git-rebase.sh |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/git-rebase.sh b/git-rebase.sh
> index 18bc694..3555d17 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -382,8 +382,10 @@ else
>  fi
>  
>  # The tree must be really really clean.
> -if ! git update-index --ignore-submodules --refresh; then
> -	die "cannot rebase: you have unstaged changes"
> +if ! git update-index --ignore-submodules --refresh > /dev/null; then
> +	echo >&2 "cannot rebase: you have unstaged changes"
> +	git diff --name-status -r --ignore-submodules -- >&2
> +	exit 1
>  fi
>  diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
>  case "$diff" in
> -- 
> 1.6.4.18.g07a4a.dirty
Matthieu Moy· Aug 6, 2009, 09:56 UTC · re: Junio C Hamano · lore

Re: [PATCH] rebase: consistent error messages for staged and unstaged changes.

Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> Previous version expose the output of the plumbing update-index to the
>> user, which novice users have difficulty to understand.
>
> Can't -q(uiet) option of update-index be used for this?
No, since update-index -q doesn't set the exit status properly:

$ git update-index --ignore-submodules --refresh > /dev/null; echo $? 1 $ git update-index --ignore-submodules -q --refresh ; echo $? 0

-- 
Matthieu

← back to recent threads