Re: [PATCH v2 4/4] add-patch: add diff.context command line overrides
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- May 13, 2025, 14:39 UTC
- Message-ID
- <0862a881-2e0a-4051-949f-3d0b94408fd5@gmail.com>
- In-Reply-To
- <431d6fec-3955-4703-8bb3-376eae7ff052@gmail.com>
On 13/05/2025 14:52, Phillip Wood wrote:
Show 19 quoted lines
>> diff --git a/builtin/stash.c b/builtin/stash.c
>> [...]
>> @@ -1826,8 +1831,15 @@ static int push_stash(int argc, const char
>> **argv, const char *prefix,
>> die(_("the option '%s' requires '%s'"), "--pathspec-file-
>> nul", "--pathspec-from-file");
>> }
>> + if (!patch_mode) {
>> + if (add_p_opt.context != -1)
>> + die(_("the option '%s' requires '%s'"), "--unified", "--
>> patch");
>> + if (add_p_opt.interhunkcontext != -1)
>> + die(_("the option '%s' requires '%s'"), "--inter-hunk-
>> context", "--patch");
>> + }
>> +
>
> This needs to die on invalid context values as "git stash" seems to
> ignore the exit code of the subprocess that checks for negative values.Looking more closely the problem is that it quits if there are no changes to stash before validating -U or --inter-hunk-context. I think it should validate the options before checking if there is anything to stash.
Best Wishes
Phillip