git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Bagas Sanjaya <bagasdotme@gmail.com>,
	Elijah Newren <newren@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Elijah Newren <newren@gmail.com>
Subject: [PATCH v2 0/3] A pair of git am --abort issues
Date: Fri, 10 Sep 2021 10:31:13 +0000	[thread overview]
Message-ID: <pull.1087.v2.git.git.1631269876.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1087.git.git.1631067429.gitgitgadget@gmail.com>

This series documents a few issues with git am --abort in the form of new
testcases, and fixes one of them. However, while I was surprised the abort
left the working directory dirty, I couldn't find any documentation to
confirm it should or shouldn't be, and reading the code led me to question
if perhaps it was intentional. Anyway, if it's intended, let me know and
I'll drop that testcase.

For frame of reference, these were some issues I found while working on
unintentional removal of untracked files/directories and the current working
directory, and I'm just submitting them separately.

Changes since v1:

 * Added a patch to tweak the documentation to clarify that partial cleaning
   of worktree is expected with --abort
 * Tweaked the second test to be a test that unrelated dirty files are kept,
   as suggested by Junio

Elijah Newren (3):
  git-am.txt: clarify --abort behavior
  t4151: add a few am --abort tests
  am: fix incorrect exit status on am fail to abort

 Documentation/git-am.txt |  2 ++
 builtin/am.c             |  3 ++-
 t/t4151-am-abort.sh      | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)


base-commit: e0a2f5cbc585657e757385ad918f167f519cfb96
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1087%2Fnewren%2Fam-issues-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1087/newren/am-issues-v2
Pull-Request: https://github.com/git/git/pull/1087

Range-diff vs v1:

 -:  ----------- > 1:  e199df0f3bc git-am.txt: clarify --abort behavior
 1:  b8a418bc63a ! 2:  38a7063b959 t4151: document a pair of am --abort bugs
     @@ Metadata
      Author: Elijah Newren <newren@gmail.com>
      
       ## Commit message ##
     -    t4151: document a pair of am --abort bugs
     +    t4151: add a few am --abort tests
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
     @@ t/t4151-am-abort.sh: test_expect_success setup '
       	git format-patch --no-numbered initial &&
      +	git checkout -b conflicting initial &&
      +	echo different >>file-1 &&
     -+	git commit -a -m different &&
     ++	echo whatever >new-file &&
     ++	git add file-1 new-file &&
     ++	git commit -m different &&
       	git checkout -b side initial &&
       	echo local change >file-2-expect
       '
     @@ t/t4151-am-abort.sh: test_expect_success 'am --abort leaves index stat info alon
       '
       
      +test_expect_failure 'git am --abort return failed exit status when it fails' '
     -+	test_when_finished "rm -rf file-2/ && git reset --hard" &&
     ++	test_when_finished "rm -rf file-2/ && git reset --hard && git am --abort" &&
      +	git checkout changes &&
      +	git format-patch -1 --stdout conflicting >changes.mbox &&
      +	test_must_fail git am --3way changes.mbox &&
     @@ t/t4151-am-abort.sh: test_expect_success 'am --abort leaves index stat info alon
      +	test_path_is_dir file-2/
      +'
      +
     -+test_expect_failure 'git am --abort returns us to a clean state' '
     ++test_expect_success 'git am --abort cleans relevant files' '
      +	git checkout changes &&
      +	git format-patch -1 --stdout conflicting >changes.mbox &&
      +	test_must_fail git am --3way changes.mbox &&
      +
     -+	# Make a change related to the rest of the am work
     -+	echo related change >>file-2 &&
     ++	test_path_is_file new-file &&
     ++	echo further changes >>file-1 &&
     ++	echo change other file >>file-2 &&
      +
     -+	# Abort, and expect the related change to go away too
     ++	# Abort, and expect the files touched by am to be reverted
      +	git am --abort &&
     -+	git status --porcelain -uno >actual &&
     -+	test_must_be_empty actual
     ++
     ++	test_path_is_missing new-file &&
     ++
     ++	# Files not involved in am operation are left modified
     ++	git diff --name-only changes >actual &&
     ++	test_write_lines file-2 >expect &&
     ++	test_cmp expect actual
      +'
      +
       test_done
 2:  5fa7daf264b ! 3:  a46f5c79fbf am: fix incorrect exit status on am fail to abort
     @@ t/t4151-am-abort.sh: test_expect_success 'am --abort leaves index stat info alon
       
      -test_expect_failure 'git am --abort return failed exit status when it fails' '
      +test_expect_success 'git am --abort return failed exit status when it fails' '
     - 	test_when_finished "rm -rf file-2/ && git reset --hard" &&
     + 	test_when_finished "rm -rf file-2/ && git reset --hard && git am --abort" &&
       	git checkout changes &&
       	git format-patch -1 --stdout conflicting >changes.mbox &&

-- 
gitgitgadget

  parent reply	other threads:[~2021-09-10 10:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08  2:17 [PATCH 0/2] A pair of git am --abort issues Elijah Newren via GitGitGadget
2021-09-08  2:17 ` [PATCH 1/2] t4151: document a pair of am --abort bugs Elijah Newren via GitGitGadget
2021-09-08  5:13   ` Bagas Sanjaya
2021-09-08  5:24     ` Elijah Newren
2021-09-08  7:02   ` Junio C Hamano
2021-09-08  8:00     ` Elijah Newren
2021-09-08 16:33       ` Junio C Hamano
2021-09-08  2:17 ` [PATCH 2/2] am: fix incorrect exit status on am fail to abort Elijah Newren via GitGitGadget
2021-09-08 16:33   ` Junio C Hamano
2021-09-08  8:08 ` [PATCH 0/2] A pair of git am --abort issues Johannes Schindelin
2021-09-10 10:31 ` Elijah Newren via GitGitGadget [this message]
2021-09-10 10:31   ` [PATCH v2 1/3] git-am.txt: clarify --abort behavior Elijah Newren via GitGitGadget
2021-09-10 10:31   ` [PATCH v2 2/3] t4151: add a few am --abort tests Elijah Newren via GitGitGadget
2021-09-10 10:31   ` [PATCH v2 3/3] am: fix incorrect exit status on am fail to abort Elijah Newren via GitGitGadget
2021-09-13 12:08   ` [PATCH v2 0/3] A pair of git am --abort issues Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.1087.v2.git.git.1631269876.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).