Re: [PATCH] Teach 'git apply' to look at $GIT_DIR/config

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

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:

>> Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:
>> 
>> > On Sat, 17 Feb 2007, Junio C Hamano wrote:
>> > ...
>> >> But I think Jeff is right.  It would make sense to let apply
>> >> and perhaps 'diff', if we can somehow merge 'diff2' into it,
>> >> still read from $HOME/.gitconfig if available.
>> >
>> > Yes, especially if you are soo used to colours as I grew to be used to 
>> > them. This was literally one of the reasons I wrote diff2 in the first 
>> > place. Another was --color-words.
>> 
>> True.  Paches welcome ;-).
>
> I sent it out already... It was titled "[PATCH] Add `git diff2`, a GNU 
> diff workalike" ;-)

I thought we were talking about making 'git apply' to read from
$HOME/.gitconfig even outside a git repository.

A funny thing is that I was suspecting that calling git_config()
would fail if you are not in a git repository after you called
setup_git_directory_gently() with no_git_ok).  The lower level
does return error because ".git/config" does not exist, but it
does not call error() to say why it failed.  Callers typically
ignore the return value from the function, so it ends up
working.

So this simple patch is the welcomed one for now ;-)

-- >8 --

diff --git a/builtin-apply.c b/builtin-apply.c
index 6ed257d..20fb5bd 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2622,11 +2622,9 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 
 	prefix = setup_git_directory_gently(&is_not_gitdir);
 	prefix_length = prefix ? strlen(prefix) : 0;
-	if (!is_not_gitdir) {
-		git_config(git_apply_config);
-		if (apply_default_whitespace)
-			parse_whitespace_option(apply_default_whitespace);
-	}
+	git_config(git_apply_config);
+	if (apply_default_whitespace)
+		parse_whitespace_option(apply_default_whitespace);
 
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];

-- 8< --

> The longer I think about it, the more I am convinced that trying to 
> integrate diff2 into diff _will_ lead to errors due to my trained, but 
> disobeying, fingers.
>
> I also debated with myself calling it diff-two or diff-direct (both not 
> really convincing), or even diff-file (too similar to diff-files), but I 
> could not come up with a better name than diff2. Which is also very easy 
> to write, I have to say.

Hmmmmmmmmmmmmmmmmmmmm.

I do agree diff-file is too confusing with diff-files, but...

In any case, I am done for the evening, and your patch did not
apply to any of the well-known versions, so perhaps I can take a
rest and have dinner and hope to find a respun one that
everybody on the list agrees with its name in my mailbox later?
;-)

I've parked the --color --check one at near the tip of 'pu', but
it appears its handling of whitespace warning is broken.

For example, from a patch that does this (I replaced a HT with =
and SP with _):

        @@ -1,6 +1,6 @@
         # The default target of this Makefile is...
         all:
        -
        +_=ab_
         # Define NO_OPENSSL
         # This also implies
         #

I get:

        Makefile:3: space before tab.white space at end: +=ab_
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~

where ~ are colored in whitespace warning color.

	

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]