Re: [PATCH v4] commit: add a commit.verbose config variable
- From
Pranit Bauva <pranit.bauva@gmail.com>
- Date
- Mar 11, 2016, 08:00 UTC
- Message-ID
- <CAFZEwPPbF30fr97WdZdbHwrF-b2VGkYiyTr3dDfdOAXd2SGFkQ@mail.gmail.com>
- In-Reply-To
- <20160311054412.GA10841@flurp.local>
On Fri, Mar 11, 2016 at 11:14 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 8 quoted lines
> It's a bit tricky if you're not used to it, but check-for-diff > actually does what you want, and does so in a more direct way. While > it's true that it's not an "editor" per se, it does get access to the > entire block of text that would normally appear in your editor during > an interactive commit. And, this is happening before the commit has > been written to history. So, check-for-diff gets a chance to look at > the full text that would appear in your editor, and can therefore > check if it contains the expected "diff --git" string.
Yes, this was new to me. Thanks for explaining it in an elaborate manner. It took me some time to actually understand the behavior of check-for-diff (a tricky one). And it does the task pretty nicely!
> 'test_i18ngrep' is intended for strings which may be translated, > however, since the expected "diff --git" string should never be > translated, check-for-diff's use of 'grep' is correct, whereas > 'test_i18ngrep' would be misleading (if not actively wrong).
I should have read the docs before using this method and not just blindly using it. I will definitely take care of that next time.
Show 22 quoted lines
> As an experiment, I rewrote the four new tests in terms of > check-for-diff (with "test_set_editor check-for-diff" already in > effect). Here's what they look like, and they function as expected: > > test_expect_success 'commit.verbose true and --verbose omitted' ' > git -c commit.verbose=true commit --amend > ' > > test_expect_success 'commit.verbose true and --no-verbose' ' > test_must_fail git -c commit.verbose=true commit --amend --no-verbose > ' > > test_expect_success 'commit.verbose false and --verbose' ' > git -c commit.verbose=false commit --amend --verbose > ' > > test_expect_success 'commit.verbose false and --verbose omitted' ' > test_must_fail git -c commit.verbose=false commit --amend > ' > > These are modeled after the "initial commit shows verbose diff" test > earlier in the script.
Thanks a lot for helping me with the tests. I will add the status tests and then resend the patch. This was a nice exercise!