# configure names for temporary files

4 messages from 2014-10-07 to 2014-10-10. Participants: Sergio Ferrero, David Aguilar, Junio C Hamano.
Thread: https://gitlist.dev/t/37681

## Sergio Ferrero, 2014-10-07 14:33

Subject: configure names for temporary files
Message-ID: <CALpL35mjtg9ge321Vz_kS1wzbYz+z9H5R3L8FcpVSNO3AtZzVA@mail.gmail.com>
URL: https://gitlist.dev/e/CALpL35mjtg9ge321Vz_kS1wzbYz%2Bz9H5R3L8FcpVSNO3AtZzVA%40mail.gmail.com

```
Hello,

I'd like to configure git with a specific merge tool to merge Simulink
model files.
I have followed the steps to configure the merge tool successfully.

I typed the following on Git Bash:

   git config --system mergetool.<merge_tool_name>.cmd '"<merge_tool_path>"
-base "$BASE" -local "$LOCAL" -remote "$REMOTE" -merged "$MERGED"'

where:

   - <merge_tool_name> is the name of the specific merge tool
   - <merge_tool_path> is the full path to the .exe file for the merge tool
   - the merge tool accepts the -base, -local, -remote and -merged arguments


Then, after a merge detects conflicts on a Simulink model, I run the
following command on the Git Bash:

   git mergetool -t <merge_tool_name> <model_name>.mdl


This command properly launches the GUI of the merge tool, however it
indicates that provided file names are invalid. They are of the form:
<model_name>.mdl.<revision>.#.mdl,
where <revision> is either LOCAL, REMOTE or BASE and # is a number.

The merge tool needs to open the model in MATLAB and MATLAB does not allow
opening models with '.' in their names.

Thus, is there a way to configure Git so that temporary models are of the
form <model_name>_mdl_<revision>_#.mdl instead of <
model_name>.mdl.<revision>.#.mdl?

Other temp file name should also be ok as long as the file does not
contains dots in the part that corresponds to the file name.

Thanks in advance,
Sergio

```

## David Aguilar, 2014-10-08 08:22

Subject: Re: configure names for temporary files
Message-ID: <20141008082228.GA78852@gmail.com>
URL: https://gitlist.dev/e/20141008082228.GA78852%40gmail.com
In-Reply-To: <CALpL35mjtg9ge321Vz_kS1wzbYz+z9H5R3L8FcpVSNO3AtZzVA@mail.gmail.com>

```
On Tue, Oct 07, 2014 at 11:33:16AM -0300, Sergio Ferrero wrote:
> Hello,
> 
> I'd like to configure git with a specific merge tool to merge Simulink
> model files.
> I have followed the steps to configure the merge tool successfully.
> 
> I typed the following on Git Bash:
> 
>    git config --system mergetool.<merge_tool_name>.cmd '"<merge_tool_path>"
> -base "$BASE" -local "$LOCAL" -remote "$REMOTE" -merged "$MERGED"'
> 
> where:
> 
>    - <merge_tool_name> is the name of the specific merge tool
>    - <merge_tool_path> is the full path to the .exe file for the merge tool
>    - the merge tool accepts the -base, -local, -remote and -merged arguments
> 
> 
> Then, after a merge detects conflicts on a Simulink model, I run the
> following command on the Git Bash:
> 
>    git mergetool -t <merge_tool_name> <model_name>.mdl
> 
> 
> This command properly launches the GUI of the merge tool, however it
> indicates that provided file names are invalid. They are of the form:
> <model_name>.mdl.<revision>.#.mdl,
> where <revision> is either LOCAL, REMOTE or BASE and # is a number.
> 
> The merge tool needs to open the model in MATLAB and MATLAB does not allow
> opening models with '.' in their names.
> 
> Thus, is there a way to configure Git so that temporary models are of the
> form <model_name>_mdl_<revision>_#.mdl instead of <
> model_name>.mdl.<revision>.#.mdl?

No such option exists.

In theory you could come up with a way to make this configurable.
A configuration variable could define a file pattern, for example.

The downside is making it configurable means supporting some
micro-format and the implementation would probably be ugly and
require eval. I don't think it needs to be configurable.

Right now the code flow is roughly:

	MERGED=foo/bar.baz

	ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
	BACKUP="./$MERGED.BACKUP.$ext"
	LOCAL="./$MERGED.LOCAL.$ext"
	REMOTE="./$MERGED.REMOTE.$ext"
	BASE="./$MERGED.BASE.$ext"

This results in a path that looks like:

	./foo/bar.baz.BASE.81001.baz

I think we can do better by default.
A more conservative result would something like:

	./foo/bar_BASE_81001.baz

Consequently, matlab (and perhaps other overly-picky tools) are
more likely to accept this path since it fits into their
windows-esque worldview where filenames can have at most 1 dot.

You should also email matlab support and kindly ask them to fix
their buggy software! ;-P foo.bar.baz is a perfectly valid
filename.

In any case, it might be worth adjusting mergetool to use a more
conservative path (underscores instead of dots) since there
doesn't seem to be much downside to doing so.
-- 
David

```

## Junio C Hamano, 2014-10-08 17:25

Subject: Re: configure names for temporary files
Message-ID: <xmqqtx3ebhip.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqtx3ebhip.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20141008082228.GA78852@gmail.com>

```
David Aguilar <davvid@gmail.com> writes:

> In any case, it might be worth adjusting mergetool to use a more
> conservative path (underscores instead of dots) since there
> doesn't seem to be much downside to doing so.

Hopefully there won't be tools that reject paths with "_" in them
;-)

```

## Sergio Ferrero, 2014-10-10 14:39

Subject: Re: configure names for temporary files
Message-ID: <CALpL35nPE+MxSKNc3cRyAbNW3SBz50EGu7P6cF+PcA-vky7jXg@mail.gmail.com>
URL: https://gitlist.dev/e/CALpL35nPE%2BMxSKNc3cRyAbNW3SBz50EGu7P6cF%2BPcA-vky7jXg%40mail.gmail.com
In-Reply-To: <xmqqtx3ebhip.fsf@gitster.dls.corp.google.com>

```
Ok. thanks!
David: I'm pretty sure matlab won't do that change soon :)

Sergio

On Wed, Oct 8, 2014 at 2:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
> David Aguilar <davvid@gmail.com> writes:
>
>> In any case, it might be worth adjusting mergetool to use a more
>> conservative path (underscores instead of dots) since there
>> doesn't seem to be much downside to doing so.
>
> Hopefully there won't be tools that reject paths with "_" in them
> ;-)

```
