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

Re: [PATCH 1/2] am: handle stray $dotest directory

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 14, 2013, 15:06 UTC
Message-ID
<7vli6crau5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1371196058-23948-2-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 68 quoted lines
> The following bug has been observed:
>
>   $ git am  # no input file
>   ^C
>   $ git am --abort
>   Resolve operation not in progress, we are not resuming.
>
> This happens because the following test fails:
>
>   test -d "$dotest" && test -f "$dotest/last" && test -f "$dotest/next"
>
> and the codepath for an "am in-progress" is not executed.  It falls back
> to the codepath that treats this as a "fresh execution".  Before
> rr/rebase-autostash, this condition was
>
>   test -d "$dotest"
>
> It would incorrectly execute the "normal" am --abort codepath:
>
>   git read-tree --reset -u HEAD ORIG_HEAD
>   git reset ORIG_HEAD
>
> by incorrectly assuming that an am is "in progress" (i.e. ORIG_HEAD
> etc. was written during the previous execution).
>
> Notice that
>
>   $ git am
>   ^C
>
> executes nothing of significance, is equivalent to
>
>   $ mkdir .git/rebase-apply
>
> Therefore, the correct solution is to treat .git/rebase-apply as a
> "stray directory" and remove it on --abort in the fresh-execution
> codepath.
>
> While at it, tell the user to run "git am --abort" to get rid of the
> stray $dotest directory, if she attempts anything else.
>
> Reported-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  git-am.sh     | 14 ++++++++++++++
>  t/t4150-am.sh |  6 ++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/git-am.sh b/git-am.sh
> index 1cf3d1d..37ee18b 100755
> --- a/git-am.sh
> +++ b/git-am.sh
> @@ -506,6 +506,20 @@ then
>  	esac
>  	rm -f "$dotest/dirtyindex"
>  else
> +	# Possible stray $dotest directory
> +	if test -d "$dotest"; then
> +	case "$skip,$resolved,$abort" in
> +		,,t)
> +			rm -fr "$dotest"
> +			exit 0
> +			;;
> +		*)
> +			die "$(eval_gettext "Stray $dotest directory found.
> +Use \"git am --abort\" to remove it.")"
> +			;;
> +	esac

These two case arms are indented one level too deep (will locally touch up).

Show 22 quoted lines
> +	fi
> +
>  	# Make sure we are not given --skip, --resolved, nor --abort
>  	test "$skip$resolved$abort" = "" ||
>  		die "$(gettext "Resolve operation not in progress, we are not resuming.")"
> diff --git a/t/t4150-am.sh b/t/t4150-am.sh
> index 12f6b02..6c2cc3e 100755
> --- a/t/t4150-am.sh
> +++ b/t/t4150-am.sh
> @@ -363,6 +363,12 @@ test_expect_success 'am --skip works' '
>  	test_cmp expected another
>  '
>  
> +test_expect_success 'am --abort removes a stray directory' '
> +	mkdir .git/rebase-apply &&
> +	git am --abort &&
> +	test_path_is_missing .git/rebase-apply
> +'
> +
>  test_expect_success 'am --resolved works' '
>  	echo goodbye >expected &&
>  	rm -fr .git/rebase-apply &&
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 3 of 16 in “Fix am with stray $dotest directory”
  1. 0/2 Fix am with stray $dotest directoryRamkumar Ramachandra, Jun 14, 2013
  2. 1/2 am: handle stray $dotest directoryRamkumar Ramachandra, Jun 14, 2013
  3. Junio C HamanoJun 14, 2013
  4. Ramkumar RamachandraJun 14, 2013
  5. Ramkumar RamachandraJun 16, 2013
  6. Junio C HamanoJun 14, 2013
  7. Ramkumar RamachandraJun 14, 2013
  8. Junio C HamanoJun 14, 2013
  9. Junio C HamanoJun 14, 2013
  10. Ramkumar RamachandraJun 15, 2013
  11. Junio C HamanoJun 14, 2013
  12. Ramkumar RamachandraJun 14, 2013
  13. Junio C HamanoJun 14, 2013
  14. Ramkumar RamachandraJun 14, 2013
  15. Junio C HamanoJun 14, 2013
  16. 2/2 t/am: use test_path_is_missing() where appropriateRamkumar Ramachandra, Jun 14, 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.