Re: Discussion for interactive --patch commands to get --unified support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Correction to my above message, I meant to reference
`repo_diff_setup`, not `git_diff_ui_config` as that lets you
initialise a struct with the default context value that diff uses
(assuming I have understood correctly)

On Fri, 2 May 2025 at 17:14, Leon Michalak <leonmichalak6@xxxxxxxxx> wrote:
>
> Inheriting the diff.context setting is what scratches my itch the most, although
> also being able to set the context in the command list of `add -i`
> sounds interesting too. Personally, I don't think I would use the
> command line overrides too much myself as most of the time (like with
> diff) I'd like to set the option and forget it but it does have a
> certain consistency to it.
>
> Slightly off-topic to the discussion, but does anyone have advice on
> how to deal with providing a sentinel value for something like
> context? I'd expect to pass `--unified` to the underlying diff command
> *only* if the user specifically has overridden it via command line
> option or a diff.context config, just like diff.algorithm has done,
> however diff.algorithm is a `char *` so the value can be NULL which is
> a good sentinel value. My thinking is then the underlying command can
> just deal with the value as it sees it, such as giving a default if
> not provided or making sure it's a minimum of 0 etc. Otherwise the
> level above has to deal with it which then probably involves
> `git_diff_ui_config` and other validations which I don't even think is
> it's responsibility and would probably duplicate logic unncessarily?
>
> I may be completely off in my assumptions here being new to the
> codebase, so if anyone has any thoughts I'd greatly appreciate any
> comments!
>
> On Fri, 2 May 2025 at 15:39, Phillip Wood <phillip.wood123@xxxxxxxxx> wrote:
> >
> > On 29/04/2025 10:16, Leon Michalak wrote:
> > >
> > > (https://stackoverflow.com/questions/6711670/git-show-more-context-when-using-git-add-i-or-git-add-e)
> > > which mentions you can do `GIT_DIFF_OPTS=-u<number> git add -p` which
> > > does work however isn't very user friendly or convenient.
> > This is a question for others on the list rather than Leon - is it
> > intentional that the plumbing diff commands respect GIT_DIFF_OPTS? If a
> > script that wants to create a diff with a certain number of context
> > lines runs `git diff-index -U <context>` is it helpful for that to be
> > overridden if GIT_DIFF_OPTS happens to be set in the environment?
> > Looking at the history it seems that environment variable used to be the
> > only way to override the default context setting but that's not the case
> > now.
> >
> > Best Wishes
> >
> > Phillip




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux