git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-filter-branch: Add more error-handling

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Feb 11, 2009, 14:58 UTC
Message-ID
<4992E79D.10208@viscovery.net>
In-Reply-To
<1234361365-63711-1-git-send-email-git@randomhacks.net>
Eric Kidd schrieb:
Show 14 quoted lines
> In particular, the following hunk may change the public UI to
> git-filter-branch, although I'm not sure whether the change is for
> better or for worse.  As I understand it, this hunk would allow
> $filter_commit to abort the rewriting process by returning a non-0 exit
> status:
> 
>  	@SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
> -		$(git write-tree) $parentstr < ../message > ../map/$commit
> +		$(git write-tree) $parentstr < ../message > ../map/$commit ||
> +			die "could not write rewritten commit"
>  done <../revs
> 
> I'd be happy to add a test case for what happens when $filter_commit
> returns a non-0 exit status.  Is the old behavior preferable?
I think it's OK to die if the commit filter fails.

But generally, I think it is not necessary to use 'die with error message', a plain '|| exit' should be enough because an error will have been reported already by the tool that failed.

Show 6 quoted lines
> @@ -483,7 +486,7 @@ test -z "$ORIG_GIT_INDEX_FILE" || {
>  }
>  
>  if [ "$(is_bare_repository)" = false ]; then
> -	git read-tree -u -m HEAD
> +	git read-tree -u -m HEAD || die "Unable to checkout rewritten tree"

Here you shouldn't die. But unlike elsewhere, this case warrants an explanation for the user:

	git read-tree -u -m HEAD ||
		echo >&2 "WARNING: The working directory is not up-to-date!"
>  fi
>  
>  exit $ret
-- Hannes
Previous: Eric KiddNext: Johannes Sixt
Message 2 of 13 in “git-filter-branch: Add more error-handling”
  1. git-filter-branch: Add more error-handlingEric Kidd, Feb 11, 2009
  2. Johannes SixtFeb 11, 2009
  3. Johannes SixtFeb 11, 2009
  4. Johannes SchindelinFeb 11, 2009
  5. filter-branch: Add more error-handlingEric Kidd, Feb 11, 2009
  6. Junio C HamanoFeb 11, 2009
  7. Eric KiddFeb 11, 2009
  8. [PATCHv3] filter-branch: Add more error-handlingEric Kidd, Feb 11, 2009
  9. Johannes SchindelinFeb 11, 2009
  10. Eric KiddFeb 11, 2009
  11. [PATCHv4] filter-branch: Add more error-handlingEric Kidd, Feb 11, 2009
  12. Nanako ShiraishiFeb 11, 2009
  13. Junio C HamanoFeb 11, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.