4

I wish to use the output from git status in a script but, because the output is always giving repo-relative file paths, other commands can't find their args. This question mentioned the relativePaths option but it has no effect on output when given as a command option:

git -c status.relativePaths=true status --short

If I've got a changed file at C:\projects\myproject\config\module\feature.src, and I'm sitting at a command prompt in C:\projects\myproject\web\somepage , then I'd need a path like either of these:

  • ..\..\config\module\feature.src
  • C:\projects\myproject\config\module\feature.src

...to be able to hand that off to other tools that I want to invoke on newly-changed files. Instead, with the repo based in myproject\, every combination of options I've tried has yielded only

  • config\module\feature.src

So how can I get actual relative paths, or even absolute paths? Am I missing something basic?

I'm using git version 1.9.4.msysgit.2 on Windows 7 with the repo files in an external folder. I can provide a List Of Things I've Tried That Didn't Work. I can have my script query and cd to the repo root before running other commands, or do it myself first, but those are just workarounds.

Community
  • 1
  • 1
gws
  • 459
  • 1
  • 7
  • 16
  • You want relativepaths=false not true – Andrew C Feb 07 '15 at 03:14
  • @Andrew `git -c status.relativePaths=false status` still gives paths relative to the repository root. According to all the documentation this is _supposed_ to work. Maybe there's a Windows-specific bug? – gws Feb 09 '15 at 17:30
  • 2
    Unsure. Linux 2.3.0 works as advertised. I don't use windows. – Andrew C Feb 09 '15 at 17:41

1 Answers1

4

You need to use git config status.relativePaths true. Read more in the configuration section here.

tejasbubane
  • 914
  • 1
  • 8
  • 11
  • I don't know what's going on with my work project but I set up a folder structure and new repository as in the example paths above, and status.relativePaths has the expected effects when I use it there.Accepting this answer since it is evidently accurate as long as no other factors are introducing insanity. (For now I'm going to cast a suspicious eye on msysgit and the fairly old version of the Windows build!) – gws Feb 10 '15 at 19:58