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

Re: [PATCH 4/7] am: don't do housekeeping when rebasing

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 23, 2013, 16:51 UTC
Message-ID
<7v4nexjim0.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1366725724-1016-5-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 10 quoted lines
> Perform these two tasks:
>
>     git gc --auto
>     rm -fr "$dotest"
>
> only when not called with --rebasing (from git-rebase--am.sh).
> Otherwise, return control to the caller so that it can do the needful.
> The advantage of doing this is that the caller can implement a generic
> cleanup routine (that possibly does other things) independent of
> specific rebases.

The above justification and the patch text make a lot of sense, but they make me wonder why there is no corresponding removal from the other git-rebase--*backend*.

Unconditional changes from "exit" to "return $?" looked somewhat suspicious, but this is a sourced script so it should be safe.

Show 77 quoted lines
>  git-am.sh         | 9 +++++++--
>  git-rebase--am.sh | 8 ++++----
>  git-rebase.sh     | 7 +++++++
>  3 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/git-am.sh b/git-am.sh
> index f4ef8fc..47c1021 100755
> --- a/git-am.sh
> +++ b/git-am.sh
> @@ -904,5 +904,10 @@ if test -s "$dotest"/rewritten; then
>      fi
>  fi
>  
> -rm -fr "$dotest"
> -git gc --auto
> +# If am was called with --rebasing (from git-rebase--am), it's up to
> +# the caller to take care of housekeeping.
> +if ! test -f "$dotest/rebasing"
> +then
> +	rm -fr "$dotest"
> +	git gc --auto
> +fi
> diff --git a/git-rebase--am.sh b/git-rebase--am.sh
> index f84854f..8230094 100644
> --- a/git-rebase--am.sh
> +++ b/git-rebase--am.sh
> @@ -7,12 +7,12 @@ case "$action" in
>  continue)
>  	git am --resolved --resolvemsg="$resolvemsg" &&
>  	move_to_original_branch
> -	exit
> +	return $?
>  	;;
>  skip)
>  	git am --skip --resolvemsg="$resolvemsg" &&
>  	move_to_original_branch
> -	exit
> +	return $?
>  	;;
>  esac
>  
> @@ -56,7 +56,7 @@ else
>  
>  		As a result, git cannot rebase them.
>  		EOF
> -		exit $?
> +		return $?
>  	fi
>  
>  	git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" <"$GIT_DIR/rebased-patches"
> @@ -68,7 +68,7 @@ fi
>  if test 0 != $ret
>  then
>  	test -d "$state_dir" && write_basic_state
> -	exit $ret
> +	return $ret
>  fi
>  
>  move_to_original_branch
> diff --git a/git-rebase.sh b/git-rebase.sh
> index b2f1c76..8412d81 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -150,6 +150,13 @@ run_specific_rebase () {
>  		autosquash=
>  	fi
>  	. git-rebase--$type
> +	ret=$?
> +	if test $ret = 0
> +	then
> +		git gc --auto &&
> +		rm -rf "$state_dir"
> +	fi
> +	exit $ret
>  }
>  
>  run_pre_rebase_hook () {
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 15 of 28 in “Introduce rebase.autostash”
  1. 0/7 Introduce rebase.autostashRamkumar Ramachandra, Apr 23, 2013
  2. 1/7 am: suppress error output from a conditionalRamkumar Ramachandra, Apr 23, 2013
  3. Martin von ZweigbergkApr 23, 2013
  4. Junio C HamanoApr 23, 2013
  5. Ramkumar RamachandraApr 23, 2013
  6. Junio C HamanoApr 23, 2013
  7. Ramkumar RamachandraApr 23, 2013
  8. 2/7 rebase -i: don't error out if $state_dir already existsRamkumar Ramachandra, Apr 23, 2013
  9. Martin von ZweigbergkApr 23, 2013
  10. Junio C HamanoApr 23, 2013
  11. Ramkumar RamachandraApr 23, 2013
  12. 3/7 am: tighten a conditional that checks for $dotestRamkumar Ramachandra, Apr 23, 2013
  13. Junio C HamanoApr 23, 2013
  14. 4/7 am: don't do housekeeping when rebasingRamkumar Ramachandra, Apr 23, 2013
  15. Junio C HamanoApr 23, 2013
  16. 5/7 rebase -i: return control to the caller, for housekeepingRamkumar Ramachandra, Apr 23, 2013
  17. Martin von ZweigbergkApr 23, 2013
  18. Ramkumar RamachandraApr 25, 2013
  19. Junio C HamanoApr 23, 2013
  20. 6/7 sh-setup: introduce require_clean_work_tree --quietRamkumar Ramachandra, Apr 23, 2013
  21. Junio C HamanoApr 23, 2013
  22. 7/7 rebase: implement --[no-]autostash and rebase.autostashRamkumar Ramachandra, Apr 23, 2013
  23. Junio C HamanoApr 23, 2013
  24. Junio C HamanoApr 23, 2013
  25. Ramkumar RamachandraApr 23, 2013
  26. Phil HordApr 23, 2013
  27. Ramkumar RamachandraApr 24, 2013
  28. Matthieu MoyApr 24, 2013

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.