Re: [feature] how to output absolute paths in git diff? => --show-abs-path

2018-08-23 Thread Timothee Cour
> Wanting such a feature seems sensible

happy to hear that!

> So this seems to work for --no-index, or if it doesn't what situations 
> doesn't it work in?

cases where path arguments are already absolute (as I showed earlier)


> Is this a mistake, or would you only like --show-abs-paths to implicitly 
> supply --src-prefix, but not --dst-prefix? If so, why?

notice I didn't use `--show-abs-paths` in that example; I'm showing
what `git diff` currently outputs (the `could show` meant depending on
your use case; eg when `get_file1` returns an absolute path and
`get_file2` returns a relative one)

> Ah, so it's about supplying both the prefix *and* absolute paths, whereas I 
> see without --no-index we seem to handle this sort of thing just fine:

indeed, without `--no-index` things work just fine as I noted in
https://stackoverflow.com/questions/22698505/how-to-show-full-paths-in-git-diff.
The problem is with `--no-index`
I tried messing around with `--src-prefix` and `--dst-prefix` to
remedy this but as I showed, it can't work currently.

> without --no-index we seem to handle this sort of thing just fine:

you also need `--relative` in case you're not at repo root in your
snippet (that' what I'm using, without `--no-index`)


> This is because the default prefixes are a/ and b/, respectively

that seems buggy:
with default options I get:
--- a/Users/timothee/help0.txt
+++ b/help1.txt

with `--src-prefix=FOO ` and `--dst-prefix=FOO ` I get:
--- FOOUsers/timothee/help0.txt
+++ FOOhelp1.txt

this seems buggy because there's not good option for FOO:
when FOO = /, relative paths become a broken absolute path (/help1.txt)
when FOO = ./, absolute paths become a broken relative path
(./Users/timothee/help0.txt)

I propose instead to show:
with `--src-prefix=FOO ` and `--dst-prefix=FOO ` I get:
--- join(FOO,path1)
+++ join(FOO,path2)

where join(prefix, path) simply appends prefix to path, taking care of
avoiding a double `//` in case prefix ends in / and path starts with
/,

that way, the defauls (with a/, b/) are unchanged and we can have:
with `--src-prefix=` and `--dst-prefix=` (empty FOO):
--- /Users/timothee/help0.txt
+++ help1.txt
=> the paths are not broken

## summary:

* `--show-abs-paths` would be useful
* `--src-prefix=FOO ` and `--dst-prefix=FOO ` could use join(FOO,path)
instead of the currently used join(FOO,path1.removeLeadingSlash)
On Thu, Aug 23, 2018 at 2:42 AM Ævar Arnfjörð Bjarmason
 wrote:
>
> On Thu, Aug 23, 2018 at 11:16 AM Timothee Cour  
> wrote:
> >
> > This has all the context:
> > https://stackoverflow.com/questions/22698505/how-to-show-full-paths-in-git-diff
>
> It's helpful to copy it anyway, so we can discuss it here:
>
> QUOTE
>
> How do I show full paths in git diff? One can use '--dst-prefix=$PWD'
> and '--src-prefix=$PWD' but this is fragile as it won't work in many
> cases, eg with --no-index, or when running the commond from a
> subdirectory without using --relative=realpath_to_cwd
>
> END QUOTE
>
> Wanting such a feature seems sensible. But I'm unclear on the details.
>
> You say that --{src,dst}-prefix is fragile and doesn't work for
> --no-index. But if I do this:
>
> (
> cd /tmp &&
> echo foo >a &&
> echo bar >b &&
> git --no-pager diff --src-prefix=$PWD/ --dst-prefix=$PWD/ a b
> )
>
> I get this diff:
>
> diff --git /tmp/a /tmp/b
> new file mode 100644
> index 257cc56..5716ca5 100644
> --- /tmp/a
> +++ /tmp/b
> @@ -1 +1 @@
> -foo
> +bar
>
> So this seems to work for --no-index, or if it doesn't what situations
> doesn't it work in?
>
> > I'd like `--show-abs-path` to show absolute paths in:
> > git diff --show-abs-path args...
> >
> > eg:
> > git diff --no-index `get_file1` `get_file2`
> > could show:
> > --- a/Users/timothee/temp/ripgrep/help0.txt
> > +++ b/help1.txt
>
> Is this a mistake, or would you only like --show-abs-paths to
> implicitly supply --src-prefix, but not --dst-prefix? If so, why?
>
> > * passing '--dst-prefix=$PWD' and '--src-prefix=$PWD' doesn't help
> > because path arguments could be absolute, so it'll create
> > $PWD/Users/timothee/temp/ripgrep/help0.txt (wrong)
>
> Ah, so it's about supplying both the prefix *and* absolute paths,
> whereas I see without --no-index we seem to handle this sort of thing
> just fine:
>
> git diff --src-prefix=$PWD/ --dst-prefix=$PWD HEAD~.. $PWD/some-file
>
> > * passing '--dst-prefix=.' will behave weirdly, replacing leading `/`
> > by `.` (seems wrong)
> > diff --git .Users/timothee/temp/ripgrep/help0.txt b/help1.txt
>
> This is because the default prefixes are a/ and b/, respectively, and
> the option allows you to entirely rep

[feature] how to output absolute paths in git diff? => --show-abs-path

2018-08-23 Thread Timothee Cour
This has all the context:
https://stackoverflow.com/questions/22698505/how-to-show-full-paths-in-git-diff

I'd like `--show-abs-path` to show absolute paths in:
git diff --show-abs-path args...

eg:
git diff --no-index `get_file1` `get_file2`
could show:
--- a/Users/timothee/temp/ripgrep/help0.txt
+++ b/help1.txt

* passing '--dst-prefix=$PWD' and '--src-prefix=$PWD' doesn't help
because path arguments could be absolute, so it'll create
$PWD/Users/timothee/temp/ripgrep/help0.txt (wrong)

* passing '--dst-prefix=.' will behave weirdly, replacing leading `/`
by `.` (seems wrong)
diff --git .Users/timothee/temp/ripgrep/help0.txt b/help1.txt

NOTE: I'm invoking the `git diff` command via a more complicated case
(with multiple arguments including git diff flags and git diff files),
so it's awkward for me to parse which arguments correspond to a file
vs a flag (ie prevents easily converting input file arguments to
absolute paths), but `git` could do it easily via a flag, eg
`--show-abs-path`


how to output absolute paths in git diff?

2018-08-23 Thread Timothee Cour
This has all the context:
https://stackoverflow.com/questions/22698505/how-to-show-full-paths-in-git-diff

I'd like `--show-abs-path` to show absolute paths in:
git diff --show-abs-path args...

eg:
git diff --no-index `get_file1` `get_file2`
could show:
--- a/Users/timothee/temp/ripgrep/help0.txt
+++ b/help1.txt

* passing '--dst-prefix=$PWD' and '--src-prefix=$PWD' doesn't help
because path arguments could be absolute, so it'll create
$PWD/Users/timothee/temp/ripgrep/help0.txt (wrong)

* passing '--dst-prefix=.' will behave weirdly, replacing leading `/`
by `.` (seems wrong)
diff --git .Users/timothee/temp/ripgrep/help0.txt b/help1.txt

NOTE: I'm invoking the `git diff` command via a more complicated case
(with multiple arguments including git diff flags and git diff files),
so it's awkward for me to parse which arguments correspond to a file
vs a flag (ie prevents easily converting input file arguments to
absolute paths), but `git` could do it easily via a flag, eg
`--show-abs-path`


how to ignore whitespace changes with --color-moved (git diff move detection)?

2018-02-01 Thread Timothee Cour
this PR from october 2017 was discussing a patch that'd introduce
`--color-moved-[no-]ignore-space-change`
https://public-inbox.org/git/20171025224620.27657-3-sbel...@google.com/

however not sure what happened since then as I can't find in `git help
diff` options even after `brew install --HEAD git`

it's a really useful feature as it's a common use case (ppl move
blocks and reformat in same PR)

If it's not merged in git repo yet is there an easy way to try out
this feature? (even if experimental)


support block comments in gitconfig

2016-04-04 Thread Timothee Cour
Could we have block comments in gitconfig?
It's a nice-to-have supported in most languages.
eg:

#{
commented out block
#}

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