# [PATCH] gitk: catch mkdtemp errors

7 messages from 2014-06-19 to 2014-06-27. Participants: David Aguilar, Junio C Hamano, Paul Mackerras.
Thread: https://gitlist.dev/t/36960

## David Aguilar, 2014-06-19 02:53

Subject: [PATCH] gitk: catch mkdtemp errors
Message-ID: <1403146394-9589-1-git-send-email-davvid@gmail.com>
URL: https://gitlist.dev/e/1403146394-9589-1-git-send-email-davvid%40gmail.com

```
105b5d3fbb1c00bb0aeaf9d3e0fbe26a7b1993fc introduced a dependency
on mkdtemp, which is not available on Windows.

Use the original temporary directory behavior when mkdtemp fails.
This makes the code use mkdtemp when available and gracefully
fallback to the existing behavior when it is not available.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
 gitk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gitk b/gitk
index 41e5071..9237830 100755
--- a/gitk
+++ b/gitk
@@ -3504,7 +3504,9 @@ proc gitknewtmpdir {} {
 	    set tmpdir $gitdir
 	}
 	set gitktmpformat [file join $tmpdir ".gitk-tmp.XXXXXX"]
-	set gitktmpdir [exec mktemp -d $gitktmpformat]
+	if {[catch {set gitktmpdir [exec mktemp -d $gitktmpformat]}]} {
+	    set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
+	}
 	if {[catch {file mkdir $gitktmpdir} err]} {
 	    error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err"
 	    unset gitktmpdir
-- 
2.0.0.257.g75cc6c6

```

## Junio C Hamano, 2014-06-26 20:42

Subject: Re: [PATCH] gitk: catch mkdtemp errors
Message-ID: <xmqq8uoj4d43.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq8uoj4d43.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1403146394-9589-1-git-send-email-davvid@gmail.com>

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

> 105b5d3fbb1c00bb0aeaf9d3e0fbe26a7b1993fc introduced a dependency
> on mkdtemp, which is not available on Windows.
>
> Use the original temporary directory behavior when mkdtemp fails.
> This makes the code use mkdtemp when available and gracefully
> fallback to the existing behavior when it is not available.
>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---

Does this still need to be applied before I can pull from Paulus?

>  gitk | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gitk b/gitk
> index 41e5071..9237830 100755
> --- a/gitk
> +++ b/gitk
> @@ -3504,7 +3504,9 @@ proc gitknewtmpdir {} {
>  	    set tmpdir $gitdir
>  	}
>  	set gitktmpformat [file join $tmpdir ".gitk-tmp.XXXXXX"]
> -	set gitktmpdir [exec mktemp -d $gitktmpformat]
> +	if {[catch {set gitktmpdir [exec mktemp -d $gitktmpformat]}]} {
> +	    set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
> +	}
>  	if {[catch {file mkdir $gitktmpdir} err]} {
>  	    error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err"
>  	    unset gitktmpdir

```

## Junio C Hamano, 2014-06-26 20:47

Subject: Re: [PATCH] gitk: catch mkdtemp errors
Message-ID: <xmqq4mz74cuv.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq4mz74cuv.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1403146394-9589-1-git-send-email-davvid@gmail.com>

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

> 105b5d3fbb1c00bb0aeaf9d3e0fbe26a7b1993fc introduced a dependency
> on mkdtemp, which is not available on Windows.
>
> Use the original temporary directory behavior when mkdtemp fails.
> This makes the code use mkdtemp when available and gracefully
> fallback to the existing behavior when it is not available.
>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---

In the meantime, I've fetched from you and merged up to your
master~2 aka 17f9836c (gitk: Show staged submodules regardless of
ignore config, 2014-04-08).

Thanks.

>  gitk | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gitk b/gitk
> index 41e5071..9237830 100755
> --- a/gitk
> +++ b/gitk
> @@ -3504,7 +3504,9 @@ proc gitknewtmpdir {} {
>  	    set tmpdir $gitdir
>  	}
>  	set gitktmpformat [file join $tmpdir ".gitk-tmp.XXXXXX"]
> -	set gitktmpdir [exec mktemp -d $gitktmpformat]
> +	if {[catch {set gitktmpdir [exec mktemp -d $gitktmpformat]}]} {
> +	    set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
> +	}
>  	if {[catch {file mkdir $gitktmpdir} err]} {
>  	    error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err"
>  	    unset gitktmpdir

```

## David Aguilar, 2014-06-27 03:05

Subject: Re: [PATCH] gitk: catch mkdtemp errors
Message-ID: <20140627030540.GB50083@gmail.com>
URL: https://gitlist.dev/e/20140627030540.GB50083%40gmail.com
In-Reply-To: <xmqq8uoj4d43.fsf@gitster.dls.corp.google.com>

```
On Thu, Jun 26, 2014 at 01:42:04PM -0700, Junio C Hamano wrote:
> David Aguilar <davvid@gmail.com> writes:
> 
> > 105b5d3fbb1c00bb0aeaf9d3e0fbe26a7b1993fc introduced a dependency
> > on mkdtemp, which is not available on Windows.
> >
> > Use the original temporary directory behavior when mkdtemp fails.
> > This makes the code use mkdtemp when available and gracefully
> > fallback to the existing behavior when it is not available.
> >
> > Helped-by: Junio C Hamano <gitster@pobox.com>
> > Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
> > Signed-off-by: David Aguilar <davvid@gmail.com>
> > ---
> 
> Does this still need to be applied before I can pull from Paulus?

Yes, it would be nice to have this, especially for Windows users.
-- 
David

```

## Paul Mackerras, 2014-06-27 06:58

Subject: Re: [PATCH] gitk: catch mkdtemp errors
Message-ID: <20140627065842.GA21103@iris.ozlabs.ibm.com>
URL: https://gitlist.dev/e/20140627065842.GA21103%40iris.ozlabs.ibm.com
In-Reply-To: <1403146394-9589-1-git-send-email-davvid@gmail.com>

```
On Wed, Jun 18, 2014 at 07:53:14PM -0700, David Aguilar wrote:
> 105b5d3fbb1c00bb0aeaf9d3e0fbe26a7b1993fc introduced a dependency
> on mkdtemp, which is not available on Windows.
> 
> Use the original temporary directory behavior when mkdtemp fails.
> This makes the code use mkdtemp when available and gracefully
> fallback to the existing behavior when it is not available.
> 
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
> Signed-off-by: David Aguilar <davvid@gmail.com>

Thanks, applied (with slight modification to commit message).

Paul.

```

## Paul Mackerras, 2014-06-27 06:59

Subject: Re: [PATCH] gitk: catch mkdtemp errors
Message-ID: <20140627065924.GB21103@iris.ozlabs.ibm.com>
URL: https://gitlist.dev/e/20140627065924.GB21103%40iris.ozlabs.ibm.com
In-Reply-To: <xmqq4mz74cuv.fsf@gitster.dls.corp.google.com>

```
On Thu, Jun 26, 2014 at 01:47:36PM -0700, Junio C Hamano wrote:
> David Aguilar <davvid@gmail.com> writes:
> 
> > 105b5d3fbb1c00bb0aeaf9d3e0fbe26a7b1993fc introduced a dependency
> > on mkdtemp, which is not available on Windows.
> >
> > Use the original temporary directory behavior when mkdtemp fails.
> > This makes the code use mkdtemp when available and gracefully
> > fallback to the existing behavior when it is not available.
> >
> > Helped-by: Junio C Hamano <gitster@pobox.com>
> > Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
> > Signed-off-by: David Aguilar <davvid@gmail.com>
> > ---
> 
> In the meantime, I've fetched from you and merged up to your
> master~2 aka 17f9836c (gitk: Show staged submodules regardless of
> ignore config, 2014-04-08).

I have applied and pushed out this patch, along with one from Max
Kirillov, so please do another fetch.

Thanks,
Paul.

```

## Junio C Hamano, 2014-06-27 17:16

Subject: Re: [PATCH] gitk: catch mkdtemp errors
Message-ID: <xmqqmwcy2ryp.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqmwcy2ryp.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20140627065924.GB21103@iris.ozlabs.ibm.com>

```
Paul Mackerras <paulus@samba.org> writes:

> On Thu, Jun 26, 2014 at 01:47:36PM -0700, Junio C Hamano wrote:
>> 
>> In the meantime, I've fetched from you and merged up to your
>> master~2 aka 17f9836c (gitk: Show staged submodules regardless of
>> ignore config, 2014-04-08).
>
> I have applied and pushed out this patch, along with one from Max
> Kirillov, so please do another fetch.

Thanks, will do.

```
