[Geany-devel] [PATCH 12/19] Use relative paths in the project files

Lex Trotman elextr at xxxxx
Thu Aug 5 09:28:10 UTC 2010


On 5 August 2010 19:13, Jiří Techet <techet at gmail.com> wrote:
> On Thu, Aug 5, 2010 at 04:48, Lex Trotman <elextr at gmail.com> wrote:
>> On 5 August 2010 09:59, Jiří Techet <techet at gmail.com> wrote:
>>>
>>> Right now projects cannot be moved to other directories without
>>> losing the base directory setting of the project and the list
>>> of open files. This makes the project totally unportable to different
>>> machines because even if the directory structure under your home is
>>> identical, the user name can be different so the path is different too.
>>>
>>> The paths should be relative to the project file, which is what
>>> every other IDE I know does. If you keep the project file in the
>>> same relative path to the project files, you can move it wherever you
>>> want.
>>>
>>> This patch does this in a backwards-compatible way - when the path
>>> in the project settings file is absolute, it uses the absoulte path.
>>> However, when the project is saved, all paths are converted to relative.
>>> This means that all new applications will be able to read the old
>>> project definition files but the old applications won't read
>>> the new files (or more precisely, the paths in them).
>>>
>>> For the global session file absolute paths are still used mainly because in
>>> Windows you cannot create a relative path to a different volume and the
>>> global settings file can be at a volume different from the project dir.
>>> (I don't expect anyone has the project definition file at different
>>> volume than the project files so this shouldn't be an issue for projects).
>>>
>>> As Dimitar suggested, absolute paths could be used for files outside
>>> the base directory which makes sense because the paths outside the project
>>> would be preserved even if the project moves somewhere else. This feature
>>> can be included depending on the further discussion.
>>>
>>> One more possibility is to add a settings option (either per project or
>>> global) that determines what kind of paths should be used.
>>
>>
>> Hi Jiri,
>>
>> If I understand correctly this patch depends on the project file being
>> in the project tree, but that is not the Geany default.  Some people
>> don't like storing the project file in the project tree because it
>> contains an individual users session files and these shouldn't be in a
>> version controlled tree, imagine if you did a git commit -a.
>
> Sure, I had this in mind - but the patch is completely independent of
> where the project file is located. So for instance if you have:
>
> ~/foo.geany
> and project directory is in: ~/projects/foo
> then foo.geany refers to files as: ./projects/foo


But then how does it work when I move projects/foo somewhere,
foo.geany is again disconnected.  Thats why I suggested that the
project file had to move with the project tree so the relative
addresses kept working.

Maybe the paths in foo.geany should be relative to the project base
directory, not the project file, then if you move the project you only
have to correct the base directory and it will all work again.

Cheers
Lex

>
> Another example:
>
> the project directory is in: ~/projects/bar
> and the project file under: ~/project_files/baz/bar.geany
> then bar.geany refers to files as: ../../projects/bar
>
> The only problem might be under Windows if you store the project file
> on different volume than the project directory - then you cannot
> construct the relative path but I think nobody would do that. And of
> course you should move project files so that the relative path against
> the project file and the project directory remains unchanged. This
> would work well if you have:
>
> ~/projects/foo.geany
> ~/projects/bar.geany
> ~/projects/baz.geany
> ~/projects/foo
> ~/projects/bar
> ~/projects/baz
>
> which is something geany defaults to with having project file one
> directory above the project directory. (In this case without the patch
> if you rename "projects" to something else, all the paths get broken
> but they remain preserved with my patch applied.)
>
> That said, I'm not against making this behavior optional - depends on
> what others think.
>
> Cheers,
>
> Jiri
>
>>
>> I think this patch is a good idea, but only if the project file is in
>> the tree, so maybe it needs to be dependent on that preference
>> setting, or better still have its own preference setting so that the
>> user has to choose to not be backward compatible.
>>
>> Cheers
>> Lex
>>
>>>
>>> Signed-off-by: Jiří Techet <techet at gmail.com>
>>> ---
>>>  src/keyfile.c |   39 ++++++++++++++++++++++++++++++++++-----
>>>  src/keyfile.h |    2 +-
>>>  src/project.c |   26 +++++++++++++++++++++++---
>>>  3 files changed, 58 insertions(+), 9 deletions(-)
>>>
>>>
>>> _______________________________________________
>>> Geany-devel mailing list
>>> Geany-devel at uvena.de
>>> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>>>
>>>
>> _______________________________________________
>> Geany-devel mailing list
>> Geany-devel at uvena.de
>> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>>
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>



More information about the Devel mailing list