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

Re: [PATCH v2] filter-branch: return 2 when nothing to rewrite

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 15, 2018, 17:58 UTC
Message-ID
<xmqqbmfp5ifw.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180315170918.1984-1-michele@locati.it>
Michele Locati <michele@locati.it> writes:
Show 10 quoted lines
> Using the --state-branch option allows us to perform incremental filtering.
> This may lead to having nothing to rewrite in subsequent filtering, so we need
> a way to recognize this case.
> So, let's exit with 2 instead of 1 when this "error" occurs.
>
> Signed-off-by: Michele Locati <michele@locati.it>
> ---
>  Documentation/git-filter-branch.txt | 8 ++++++++
>  git-filter-branch.sh                | 2 +-
>  2 files changed, 9 insertions(+), 1 deletion(-)
Thanks.  Will queue.
Show 33 quoted lines
>
> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
> index 3a52e4dce..b63404318 100644
> --- a/Documentation/git-filter-branch.txt
> +++ b/Documentation/git-filter-branch.txt
> @@ -222,6 +222,14 @@ this purpose, they are instead rewritten to point at the nearest ancestor that
>  was not excluded.
>  
>  
> +EXIT STATUS
> +-----------
> +
> +On success, the exit status is `0`.  If the filter can't find any commits to
> +rewrite, the exit status is `2`.  On any other error, the exit status may be
> +any other non-zero value.
> +
> +
>  Examples
>  --------
>  
> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index 1b7e4b2cd..c285fdb90 100755
> --- a/git-filter-branch.sh
> +++ b/git-filter-branch.sh
> @@ -310,7 +310,7 @@ git rev-list --reverse --topo-order --default HEAD \
>  	die "Could not get the commits"
>  commits=$(wc -l <../revs | tr -d " ")
>  
> -test $commits -eq 0 && die "Found nothing to rewrite"
> +test $commits -eq 0 && die_with_status 2 "Found nothing to rewrite"
>  
>  # Rewrite the commits
>  report_progress ()
Previous: Michele LocatiNext: Jeff King
Message 11 of 12 in “filter-branch: return 2 when nothing to rewrite”
  1. filter-branch: return 2 when nothing to rewriteMichele Locati, Mar 15, 2018
  2. Jeff KingMar 15, 2018
  3. Michele LocatiMar 15, 2018
  4. Jeff KingMar 15, 2018
  5. Junio C HamanoMar 15, 2018
  6. Jeff KingMar 15, 2018
  7. Junio C HamanoMar 15, 2018
  8. Michele LocatiMar 15, 2018
  9. Jeff KingMar 15, 2018
  10. filter-branch: return 2 when nothing to rewriteMichele Locati, Mar 15, 2018
  11. Junio C HamanoMar 15, 2018
  12. Jeff KingMar 15, 2018

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.