* Re: [msysGit] Pull request for msysGit patches
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
@ 2010-09-28 20:58 ` Erik Faye-Lund
2010-09-28 21:13 ` Johannes Sixt
2010-09-28 21:08 ` Jonathan Nieder
` (7 subsequent siblings)
8 siblings, 1 reply; 38+ messages in thread
From: Erik Faye-Lund @ 2010-09-28 20:58 UTC (permalink / raw)
To: Johannes Sixt
Cc: Pat Thoyts, msysgit, git, Junio C Hamano, Johannes Schindelin
On Tue, Sep 28, 2010 at 10:52 PM, Johannes Sixt <j6t@kdbg.org> wrote:
>> mingw: do not crash on open(NULL, ...)
>
> This one is bogus, and as it stands, it must have my Ack removed. :) Needs the
> same fix in mingw_fopen as mingw_freopen. (There remains an unprotected
> dereference of filename.)
>
I believe the version in for-junio already has this fix squashed in.
The following hunk, taken from
http://repo.or.cz/w/git/mingw/4msysgit.git/blobdiff/4e93566b07dcf47ecb6484d225418c04c1eedee6..b18500977d88b13803ecc60cf383538139ec09d8:/compat/mingw.c
shows that it is... Or are you thinking of something else?
@@ -346,7 +346,7 @@ FILE *mingw_fopen (const char *filename, const char *otype)
if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
basename((char*)filename)[0] == '.')
hide = access(filename, F_OK);
- if (!strcmp(filename, "/dev/null"))
+ if (filename && !strcmp(filename, "/dev/null"))
filename = "nul";
file = fopen(filename, otype);
if (file && hide && make_hidden(filename))
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-28 20:58 ` Erik Faye-Lund
@ 2010-09-28 21:13 ` Johannes Sixt
2010-09-28 21:20 ` Erik Faye-Lund
0 siblings, 1 reply; 38+ messages in thread
From: Johannes Sixt @ 2010-09-28 21:13 UTC (permalink / raw)
To: kusmabite; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano, Johannes Schindelin
On Dienstag, 28. September 2010, Erik Faye-Lund wrote:
> On Tue, Sep 28, 2010 at 10:52 PM, Johannes Sixt <j6t@kdbg.org> wrote:
> >> mingw: do not crash on open(NULL, ...)
> >
> > This one is bogus, and as it stands, it must have my Ack removed. :)
> > Needs the same fix in mingw_fopen as mingw_freopen. (There remains an
> > unprotected dereference of filename.)
>
> I believe the version in for-junio already has this fix squashed in.
> The following hunk, taken from
> http://repo.or.cz/w/git/mingw/4msysgit.git/blobdiff/4e93566b07dcf47ecb6484d
>225418c04c1eedee6..b18500977d88b13803ecc60cf383538139ec09d8:/compat/mingw.c
> shows that it is... Or are you thinking of something else?
>
> @@ -346,7 +346,7 @@ FILE *mingw_fopen (const char *filename, const char
> if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
> basename((char*)filename)[0] == '.')
^^^^^^^^
This can crash, too.
> hide = access(filename, F_OK);
> - if (!strcmp(filename, "/dev/null"))
> + if (filename && !strcmp(filename, "/dev/null"))
> filename = "nul";
> file = fopen(filename, otype);
> if (file && hide && make_hidden(filename))
-- Hannes
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-28 21:13 ` Johannes Sixt
@ 2010-09-28 21:20 ` Erik Faye-Lund
2010-09-28 21:35 ` Erik Faye-Lund
0 siblings, 1 reply; 38+ messages in thread
From: Erik Faye-Lund @ 2010-09-28 21:20 UTC (permalink / raw)
To: Johannes Sixt
Cc: Pat Thoyts, msysgit, git, Junio C Hamano, Johannes Schindelin
On Tue, Sep 28, 2010 at 11:13 PM, Johannes Sixt <j6t@kdbg.org> wrote:
> On Dienstag, 28. September 2010, Erik Faye-Lund wrote:
>> On Tue, Sep 28, 2010 at 10:52 PM, Johannes Sixt <j6t@kdbg.org> wrote:
>> >> mingw: do not crash on open(NULL, ...)
>> >
>> > This one is bogus, and as it stands, it must have my Ack removed. :)
>> > Needs the same fix in mingw_fopen as mingw_freopen. (There remains an
>> > unprotected dereference of filename.)
>>
>> I believe the version in for-junio already has this fix squashed in.
>> The following hunk, taken from
>> http://repo.or.cz/w/git/mingw/4msysgit.git/blobdiff/4e93566b07dcf47ecb6484d
>>225418c04c1eedee6..b18500977d88b13803ecc60cf383538139ec09d8:/compat/mingw.c
>> shows that it is... Or are you thinking of something else?
>>
>> @@ -346,7 +346,7 @@ FILE *mingw_fopen (const char *filename, const char
>> if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
>> basename((char*)filename)[0] == '.')
> ^^^^^^^^
> This can crash, too.
>
Ah, indeed. Thanks for pointing that out! I'll send out a new version,
with this squashed on top:
diff --git a/compat/mingw.c b/compat/mingw.c
index 2fbe381..2584e9f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -343,11 +343,13 @@ FILE *mingw_fopen (const char *filename, const
char *otype)
{
int hide = 0;
FILE *file;
- if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
- basename((char*)filename)[0] == '.')
- hide = access(filename, F_OK);
- if (filename && !strcmp(filename, "/dev/null"))
- filename = "nul";
+ if (filename) {
+ if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
+ basename((char*)filename)[0] == '.')
+ hide = access(filename, F_OK);
+ if (!strcmp(filename, "/dev/null"))
+ filename = "nul";
+ }
file = fopen(filename, otype);
if (file && hide && make_hidden(filename))
warning("Could not mark '%s' as hidden.", filename);
@@ -359,11 +361,13 @@ FILE *mingw_freopen (const char *filename, const
char *otype, FILE *stream)
{
int hide = 0;
FILE *file;
- if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
- basename((char*)filename)[0] == '.')
- hide = access(filename, F_OK);
- if (filename && !strcmp(filename, "/dev/null"))
- filename = "nul";
+ if (filename) {
+ if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
+ basename((char*)filename)[0] == '.')
+ hide = access(filename, F_OK);
+ if (!strcmp(filename, "/dev/null"))
+ filename = "nul";
+ }
file = freopen(filename, otype, stream);
if (file && hide && make_hidden(filename))
warning("Could not mark '%s' as hidden.", filename);
^ permalink raw reply related [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-28 21:20 ` Erik Faye-Lund
@ 2010-09-28 21:35 ` Erik Faye-Lund
0 siblings, 0 replies; 38+ messages in thread
From: Erik Faye-Lund @ 2010-09-28 21:35 UTC (permalink / raw)
To: Johannes Sixt
Cc: Pat Thoyts, msysgit, git, Junio C Hamano, Johannes Schindelin
On Tue, Sep 28, 2010 at 11:20 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:
> On Tue, Sep 28, 2010 at 11:13 PM, Johannes Sixt <j6t@kdbg.org> wrote:
>> On Dienstag, 28. September 2010, Erik Faye-Lund wrote:
>>> On Tue, Sep 28, 2010 at 10:52 PM, Johannes Sixt <j6t@kdbg.org> wrote:
>>> >> mingw: do not crash on open(NULL, ...)
>>> >
>>> > This one is bogus, and as it stands, it must have my Ack removed. :)
>>> > Needs the same fix in mingw_fopen as mingw_freopen. (There remains an
>>> > unprotected dereference of filename.)
>>>
>>> I believe the version in for-junio already has this fix squashed in.
>>> The following hunk, taken from
>>> http://repo.or.cz/w/git/mingw/4msysgit.git/blobdiff/4e93566b07dcf47ecb6484d
>>>225418c04c1eedee6..b18500977d88b13803ecc60cf383538139ec09d8:/compat/mingw.c
>>> shows that it is... Or are you thinking of something else?
>>>
>>> @@ -346,7 +346,7 @@ FILE *mingw_fopen (const char *filename, const char
>>> if (hide_dotfiles == HIDE_DOTFILES_TRUE &&
>>> basename((char*)filename)[0] == '.')
>> ^^^^^^^^
>> This can crash, too.
>>
>
> Ah, indeed. Thanks for pointing that out! I'll send out a new version,
> with this squashed on top:
>
And now that I assemble it, I all of a sudden understand where your
complaint came from. The issue wasn't in the original patch, it was
introduced when the patch was applied.
Basically, I introduced a similar crash-bug to the one this patch
fixes in the original hide-dotfiles patch, and my this patch was
written against junio's master, which doesn't contain that newer bug.
I also seem to remember there being some controversy over the
hide-dotfiles series, whether or not it was in git's scope to allow
hiding non-dotgit files at all etc. So, perhaps what makes the most
sense would be to eject the hide-dotfiles stuff out of for-junio, and
rework it on top, going through the main git mailing list? That series
did get quite a bit messy as patches were applied a little too quickly
IMO.
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
2010-09-28 20:58 ` Erik Faye-Lund
@ 2010-09-28 21:08 ` Jonathan Nieder
2010-09-29 17:51 ` Junio C Hamano
2010-09-29 2:23 ` Eric Sunshine
` (6 subsequent siblings)
8 siblings, 1 reply; 38+ messages in thread
From: Jonathan Nieder @ 2010-09-28 21:08 UTC (permalink / raw)
To: Johannes Sixt
Cc: Pat Thoyts, msysgit, git, Junio C Hamano, Johannes Schindelin
Johannes Sixt wrote:
> On Dienstag, 28. September 2010, Pat Thoyts wrote:
>> Johannes Schindelin (11):
>> Avoid TAGS/tags warning from GNU Make
>
> OK.
Wasn't this one reviewed on-list recently?
-- 8< --
From: Junio C Hamano <gitster@pobox.com>
Subject: MinGW: avoid collisions between "tags" and "TAGS"
On case insensitive filesystems, "tags" and "TAGS" target will try to
overwrite the same file. Allow MinGW to use "ETAGS" instead.
These two targets do produce real files; do not put them on .PHONY target
list.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Makefile | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index b7a62cf..d3dcfb1 100644
--- a/Makefile
+++ b/Makefile
@@ -390,6 +390,8 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
$(patsubst %.py,%,$(SCRIPT_PYTHON)) \
git-instaweb
+ETAGS_TARGET = TAGS
+
# Empty...
EXTRA_PROGRAMS =
@@ -1122,6 +1124,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_REGEX = YesPlease
NO_PYTHON = YesPlease
BLK_SHA1 = YesPlease
+ ETAGS_TARGET = ETAGS
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
@@ -1961,11 +1964,11 @@ info:
pdf:
$(MAKE) -C Documentation pdf
-TAGS:
- $(RM) TAGS
- $(FIND) . -name '*.[hcS]' -print | xargs etags -a
+$(ETAGS_TARGET): FORCE
+ $(RM) $(ETAGS_TARGET)
+ $(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
-tags:
+tags: FORCE
$(RM) tags
$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
@@ -2235,7 +2238,7 @@ clean:
$(RM) $(TEST_PROGRAMS)
$(RM) -r bin-wrappers
$(RM) -r $(dep_dirs)
- $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
+ $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
$(RM) -r autom4te.cache
$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
@@ -2259,7 +2262,7 @@ endif
.PHONY: all install clean strip
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
-.PHONY: FORCE TAGS tags cscope
+.PHONY: FORCE cscope
### Check documentation
#
--
1.7.3.1.gd86b1
^ permalink raw reply related [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-28 21:08 ` Jonathan Nieder
@ 2010-09-29 17:51 ` Junio C Hamano
2010-09-29 22:29 ` Pat Thoyts
0 siblings, 1 reply; 38+ messages in thread
From: Junio C Hamano @ 2010-09-29 17:51 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Johannes Sixt, Pat Thoyts, msysgit, git, Johannes Schindelin
Jonathan Nieder <jrnieder@gmail.com> writes:
> Johannes Sixt wrote:
>> On Dienstag, 28. September 2010, Pat Thoyts wrote:
>
>>> Johannes Schindelin (11):
>>> Avoid TAGS/tags warning from GNU Make
>>
>> OK.
>
> Wasn't this one reviewed on-list recently?
Yeah, I remember it vaguely ;-)
Although I do not care very much either way, this probably is a better
approach, I think, if there are people on MinGW and/or OS/X who use
tags/etags.
Will queue.
> -- 8< --
> From: Junio C Hamano <gitster@pobox.com>
> Subject: MinGW: avoid collisions between "tags" and "TAGS"
>
> On case insensitive filesystems, "tags" and "TAGS" target will try to
> overwrite the same file. Allow MinGW to use "ETAGS" instead.
>
> These two targets do produce real files; do not put them on .PHONY target
> list.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> Makefile | 15 +++++++++------
> 1 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index b7a62cf..d3dcfb1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -390,6 +390,8 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
> $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
> git-instaweb
>
> +ETAGS_TARGET = TAGS
> +
> # Empty...
> EXTRA_PROGRAMS =
>
> @@ -1122,6 +1124,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
> NO_REGEX = YesPlease
> NO_PYTHON = YesPlease
> BLK_SHA1 = YesPlease
> + ETAGS_TARGET = ETAGS
> COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
> COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
> COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
> @@ -1961,11 +1964,11 @@ info:
> pdf:
> $(MAKE) -C Documentation pdf
>
> -TAGS:
> - $(RM) TAGS
> - $(FIND) . -name '*.[hcS]' -print | xargs etags -a
> +$(ETAGS_TARGET): FORCE
> + $(RM) $(ETAGS_TARGET)
> + $(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
>
> -tags:
> +tags: FORCE
> $(RM) tags
> $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
>
> @@ -2235,7 +2238,7 @@ clean:
> $(RM) $(TEST_PROGRAMS)
> $(RM) -r bin-wrappers
> $(RM) -r $(dep_dirs)
> - $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
> + $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
> $(RM) -r autom4te.cache
> $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
> $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
> @@ -2259,7 +2262,7 @@ endif
>
> .PHONY: all install clean strip
> .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
> -.PHONY: FORCE TAGS tags cscope
> +.PHONY: FORCE cscope
>
> ### Check documentation
> #
> --
> 1.7.3.1.gd86b1
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-29 17:51 ` Junio C Hamano
@ 2010-09-29 22:29 ` Pat Thoyts
0 siblings, 0 replies; 38+ messages in thread
From: Pat Thoyts @ 2010-09-29 22:29 UTC (permalink / raw)
To: Junio C Hamano
Cc: Jonathan Nieder, Johannes Sixt, Pat Thoyts, msysgit, git,
Johannes Schindelin
On 29 September 2010 18:51, Junio C Hamano <gitster@pobox.com> wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
>
>> Johannes Sixt wrote:
>>> On Dienstag, 28. September 2010, Pat Thoyts wrote:
>>
>>>> Johannes Schindelin (11):
>>>> Avoid TAGS/tags warning from GNU Make
>>>
>>> OK.
>>
>> Wasn't this one reviewed on-list recently?
>
> Yeah, I remember it vaguely ;-)
>
> Although I do not care very much either way, this probably is a better
> approach, I think, if there are people on MinGW and/or OS/X who use
> tags/etags.
>
> Will queue.
I've just tested this suggested patch with msysGit and it's fine here.
We can go with this rather than Johannes' original.
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
2010-09-28 20:58 ` Erik Faye-Lund
2010-09-28 21:08 ` Jonathan Nieder
@ 2010-09-29 2:23 ` Eric Sunshine
2010-09-29 3:37 ` Junio C Hamano
2010-09-30 13:24 ` [PATCH] git-am: fix detection of absolute paths for windows Pat Thoyts
` (5 subsequent siblings)
8 siblings, 1 reply; 38+ messages in thread
From: Eric Sunshine @ 2010-09-29 2:23 UTC (permalink / raw)
To: Johannes Sixt
Cc: Pat Thoyts, msysgit, git, Junio C Hamano, Johannes Schindelin
Hi Hannes,
On 9/28/2010 4:52 PM, Johannes Sixt wrote:
> On Dienstag, 28. September 2010, Pat Thoyts wrote:
>> Junio,
>>
>> The msysGit tree currently tracks some 50+ patches on top of 'next'. I
>> have gathered 42 of these that look good to move upstream.
>
> I've browsed through the list, and I'll annotate my opinion below. When I
> say 'OK', then this means that the patch looks good, but it doesn't imply
> that I have tested it.
>
>> Side-step line-ending corruption leading to t3032 failures.
>
> This one has non-portable 'export foo=bar', but it is in a MinGW specific
> path, so it should be fine. But why do we need to export GREP_OPTIONS, but
> not SED_OPTIONS?
I also normally avoid unportable 'export foo=bar'. In the particular
case of GREP_OPTIONS, when commenting on my original patch submission,
Dscho suggested 'test_have_prereq MINGW && export GREP_OPTIONS=foo' so
that is the form which made it into the final patch. While considering
whether this unportable usage was worthwhile, I took into consideration
the fact that a much more senior project member preferred it, that the
MinGW-specific build environment is Bash-based, and that a couple other
test scripts (t1509, t5560) also employ this form. If preferred, the
patches can be re-submitted to avoid the unportable usage.
Regarding exporting GREP_OPTIONS but not SED_OPTIONS: grep explicitly
recognizes the GREP_OPTIONS environment variable. My original patch did
not export GREP_OPTIONS, but instead referenced it as $GREP_OPTIONS in
the grep invocation. Upon review, Dscho preferred the variable to be
exported rather than referenced manually as $GREP_OPTIONS. sed, on the
other hand, does not recognize any 'options' environment variable. It is
necessary, therefore, to interpolate $SED_OPTIONS directly during the
sed invocation. This variable is therefore local to the script and need
not be exported.
-- ES
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-29 2:23 ` Eric Sunshine
@ 2010-09-29 3:37 ` Junio C Hamano
2010-09-29 4:17 ` Eric Sunshine
0 siblings, 1 reply; 38+ messages in thread
From: Junio C Hamano @ 2010-09-29 3:37 UTC (permalink / raw)
To: Eric Sunshine
Cc: Johannes Sixt, Pat Thoyts, msysgit, git, Johannes Schindelin
Eric Sunshine <sunshine@sunshineco.com> writes:
> I also normally avoid unportable 'export foo=bar'. In the particular
> case of GREP_OPTIONS, when commenting on my original patch submission,
> Dscho suggested 'test_have_prereq MINGW && export GREP_OPTIONS=foo' so
> that is the form which made it into the final patch.
Well, since bbc09c2 (grep: rip out support for external grep, 2010-01-12)
we do not run external grep at all, so GREP_OPTIONS is irrelevant.
Unless you are planning to run tests on installed version of git older
than v1.7.0, that is ;-).
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [msysGit] Pull request for msysGit patches
2010-09-29 3:37 ` Junio C Hamano
@ 2010-09-29 4:17 ` Eric Sunshine
0 siblings, 0 replies; 38+ messages in thread
From: Eric Sunshine @ 2010-09-29 4:17 UTC (permalink / raw)
To: Junio C Hamano
Cc: Johannes Sixt, Pat Thoyts, msysgit, git, Johannes Schindelin
On 9/28/2010 11:37 PM, Junio C Hamano wrote:
> Eric Sunshine<sunshine@sunshineco.com> writes:
>> I also normally avoid unportable 'export foo=bar'. In the particular
>> case of GREP_OPTIONS, when commenting on my original patch submission,
>> Dscho suggested 'test_have_prereq MINGW&& export GREP_OPTIONS=foo' so
>> that is the form which made it into the final patch.
>
> Well, since bbc09c2 (grep: rip out support for external grep, 2010-01-12)
> we do not run external grep at all, so GREP_OPTIONS is irrelevant.
>
> Unless you are planning to run tests on installed version of git older
> than v1.7.0, that is ;-).
The patches in question involve test scripts which themselves invoke
external grep for various reasons. An example is t5560 where external
grep is invoked to extract the Status: header from an HTTP response. The
patches fix instances where grep invocations give incorrect results on
Windows due to grep undesirably swallowing CR from CRLF line-terminators
in the few tests where those terminators are actually significant (such
as t5560). In the context of these test scripts, external grep is still
employed, so GREP_OPTIONS may still be relevant.
-- ES
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH] git-am: fix detection of absolute paths for windows
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
` (2 preceding siblings ...)
2010-09-29 2:23 ` Eric Sunshine
@ 2010-09-30 13:24 ` Pat Thoyts
2010-10-01 17:46 ` Johannes Sixt
2010-11-07 14:56 ` [PATCH v2 0/4] make open/unlink failures user friendly on windows using retry/abort Heiko Voigt
` (4 subsequent siblings)
8 siblings, 1 reply; 38+ messages in thread
From: Pat Thoyts @ 2010-09-30 13:24 UTC (permalink / raw)
To: Johannes Sixt; +Cc: msysgit, git, Junio C Hamano, Johannes Schindelin
Add an is_absolute_path function to abstract out platform differences
in checking for an absolute or relative path.
Specifically fixes t4150-am on Windows.
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
In response to the following comment...
>Johannes Sixt <j6t@kdbg.org> writes:
>>> git-am: fix absolute path logic on Windows
>>
>>This mistakes a file that has a colon in the second position as absolute, even
>>on non-Windows. IIUC, this patch is not intended for upstream git.
>>
This patch is an alternative solution that only tries the Windows paths
on msysGit. This is_absolute_path might find use elsewhere in the future
so I elected to place it in the sh-setup script. Also added support for
identifying a UNC path as absolute.
git-am.sh | 12 ++++++------
git-sh-setup.sh | 15 +++++++++++++++
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index e7f008c..9317b38 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -444,12 +444,12 @@ else
set x
first=
}
- case "$arg" in
- /*)
- set "$@" "$arg" ;;
- *)
- set "$@" "$prefix$arg" ;;
- esac
+ if is_absolute_path "$arg"
+ then
+ set "$@" "$arg"
+ else
+ set "$@" "$prefix$arg"
+ fi
done
shift
fi
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 6131670..b9eb0bf 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -209,5 +209,20 @@ case $(uname -s) in
find () {
/usr/bin/find "$@"
}
+ is_absolute_path () {
+ case "$1" in
+ /* | ?:* | \\\\*)
+ return 0 ;;
+ esac
+ return 1
+ }
;;
+*)
+ is_absolute_path () {
+ case "$1" in
+ /*)
+ return 0 ;;
+ esac
+ return 1
+ }
esac
--
1.7.3
^ permalink raw reply related [flat|nested] 38+ messages in thread
* Re: [PATCH] git-am: fix detection of absolute paths for windows
2010-09-30 13:24 ` [PATCH] git-am: fix detection of absolute paths for windows Pat Thoyts
@ 2010-10-01 17:46 ` Johannes Sixt
2010-09-30 13:24 ` Pat Thoyts
0 siblings, 1 reply; 38+ messages in thread
From: Johannes Sixt @ 2010-10-01 17:46 UTC (permalink / raw)
To: Pat Thoyts; +Cc: msysgit, git, Junio C Hamano, Johannes Schindelin
On Donnerstag, 30. September 2010, Pat Thoyts wrote:
> Add an is_absolute_path function to abstract out platform differences
> in checking for an absolute or relative path.
> Specifically fixes t4150-am on Windows.
Thanks for tackling this!
> @@ -209,5 +209,20 @@ case $(uname -s) in
> find () {
> /usr/bin/find "$@"
> }
> + is_absolute_path () {
> + case "$1" in
> + /* | ?:* | \\\\*)
Absolute paths can also start with a backslash, and UNC paths can start with
double-slash. Therefore, this should be:
[/\\]* | [A-Za-z]:*)
> + return 0 ;;
> + esac
> + return 1
> + }
-- Hannes
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH] git-am: fix detection of absolute paths for windows
2010-10-01 17:46 ` Johannes Sixt
@ 2010-09-30 13:24 ` Pat Thoyts
0 siblings, 0 replies; 38+ messages in thread
From: Pat Thoyts @ 2010-09-30 13:24 UTC (permalink / raw)
To: Johannes Sixt; +Cc: msysgit, git, Junio C Hamano, Johannes Schindelin
Add an is_absolute_path function to abstract out platform differences
in checking for an absolute or relative path.
Specifically fixes t4150-am on Windows.
[PT: updated following suggestion from j6t to support \* and //*]
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
Johannes Sixt <j6t@kdbg.org> writes:
>On Donnerstag, 30. September 2010, Pat Thoyts wrote:
>> Add an is_absolute_path function to abstract out platform differences
>> in checking for an absolute or relative path.
>> Specifically fixes t4150-am on Windows.
>
>Thanks for tackling this!
>
>> @@ -209,5 +209,20 @@ case $(uname -s) in
>> find () {
>> /usr/bin/find "$@"
>> }
>> + is_absolute_path () {
>> + case "$1" in
>> + /* | ?:* | \\\\*)
>
>Absolute paths can also start with a backslash, and UNC paths can start with
>double-slash. Therefore, this should be:
>
> [/\\]* | [A-Za-z]:*)
>
>> + return 0 ;;
>> + esac
>> + return 1
>> + }
>
>-- Hannes
I've modified the patch and added your signoff - hopefully that is ok?
git-am.sh | 12 ++++++------
git-sh-setup.sh | 15 +++++++++++++++
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index e7f008c..9317b38 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -444,12 +444,12 @@ else
set x
first=
}
- case "$arg" in
- /*)
- set "$@" "$arg" ;;
- *)
- set "$@" "$prefix$arg" ;;
- esac
+ if is_absolute_path "$arg"
+ then
+ set "$@" "$arg"
+ else
+ set "$@" "$prefix$arg"
+ fi
done
shift
fi
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 6131670..58d30c9 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -209,5 +209,20 @@ case $(uname -s) in
find () {
/usr/bin/find "$@"
}
+ is_absolute_path () {
+ case "$1" in
+ [/\\]* | [A-Za-z]:*)
+ return 0 ;;
+ esac
+ return 1
+ }
;;
+*)
+ is_absolute_path () {
+ case "$1" in
+ /*)
+ return 0 ;;
+ esac
+ return 1
+ }
esac
--
1.7.3
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH v2 0/4] make open/unlink failures user friendly on windows using retry/abort
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
` (3 preceding siblings ...)
2010-09-30 13:24 ` [PATCH] git-am: fix detection of absolute paths for windows Pat Thoyts
@ 2010-11-07 14:56 ` Heiko Voigt
2010-11-07 15:49 ` Johannes Sixt
2010-11-07 14:56 ` [PATCH v2 1/4] mingw: move unlink wrapper to mingw.c Heiko Voigt
` (3 subsequent siblings)
8 siblings, 1 reply; 38+ messages in thread
From: Heiko Voigt @ 2010-11-07 14:56 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano
Hi,
here is a new iteration of my original patch series. This series
replaces the newest patches currently present in 4msysgit.git's master
and does not cleanly apply to git.git's master. Once everybody is happy
with the outcome I will port it to git.git so msysgit can fetch it from
upstream.
On Tue, Sep 28, 2010 at 10:52:25PM +0200, Johannes Sixt wrote:
> > Heiko Voigt (4):
> > mingw: work around irregular failures of unlink on windows
>
> The workaround is to retry the unlink() after a delay when it failed with
> EACCES. What happens if the EACCES is for a good reason? Doesn't this delay
> the process by 71ms per unlink() invocation? Can't this become a problem if
> many unlink()s are tried by git code?
I have changed the triggering error code to be ERROR_SHARING_VIOLATION
which seems to be the appropriate code for files that are in use by
another process.
http://msdn.microsoft.com/en-us/library/ms681382%28v=VS.85%29.aspx
Thus we do not need to worry about whether we are retrying on a valid
access error. I have tested this on my windows box and it works here.
j6t: I have not changed your error code in mingw_rename since you
explicitely compare with the windows error code ERROR_ACCESS_DENIED and
do not use the err_win_to_posix() function. Did you do this on purpose or
should I also refer to ERROR_SHARING_VIOLATION ?
> > mingw: make failures to unlink or move raise a question
>
> Gaah! But people seem to like it. Since the question is only triggered after
> all retries fail, I can live with this.
>
> But isn't the implementation a bit sloppy? Can strlen(answer)-2 be negative?
> What happens if the user typed more than 4 characters? Wouldn't it leave data
> in the buffer for the next question?
I have extracted reading of the answer into its own function and made
the reading more robust which should now take care of the above issues.
> > mingw: add fallback for rmdir in case directory is in use
>
> Depends on the previous patch. OK.
No changes.
During pick up of the series I had to gather my testing script which can
only be used manually for testing. Is there any place in git.git where
we can store such "manual testing tools" ?
Cheers Heiko
Heiko Voigt (4):
mingw: move unlink wrapper to mingw.c
mingw: work around irregular failures of unlink on windows
mingw: make failures to unlink or move raise a question
mingw: add fallback for rmdir in case directory is in use
compat/mingw.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
compat/mingw.h | 14 ++---
2 files changed, 144 insertions(+), 9 deletions(-)
--
1.7.2.2.177.geec0d
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 0/4] make open/unlink failures user friendly on windows using retry/abort
2010-11-07 14:56 ` [PATCH v2 0/4] make open/unlink failures user friendly on windows using retry/abort Heiko Voigt
@ 2010-11-07 15:49 ` Johannes Sixt
2010-11-07 17:06 ` Heiko Voigt
0 siblings, 1 reply; 38+ messages in thread
From: Johannes Sixt @ 2010-11-07 15:49 UTC (permalink / raw)
To: Heiko Voigt; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano
On Sonntag, 7. November 2010, Heiko Voigt wrote:
> j6t: I have not changed your error code in mingw_rename since you
> explicitely compare with the windows error code ERROR_ACCESS_DENIED and
> do not use the err_win_to_posix() function. Did you do this on purpose or
> should I also refer to ERROR_SHARING_VIOLATION ?
IIRC, I dumped the error code before I implemented the retry logic, and the
error was ERROR_ACCESS_DENIED. Did you verify that the occasions where you
want to retry the operations indeed fail due to ERROR_SHARING_VIOLATION, or
do you trust the documentation?
In any case, it is better to check for the Windows error code (which ever you
finally choose) rather than errno, IMO.
-- Hannes
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Re: [PATCH v2 0/4] make open/unlink failures user friendly on windows using retry/abort
2010-11-07 15:49 ` Johannes Sixt
@ 2010-11-07 17:06 ` Heiko Voigt
2010-11-07 19:11 ` Johannes Sixt
0 siblings, 1 reply; 38+ messages in thread
From: Heiko Voigt @ 2010-11-07 17:06 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano
Hi,
On Sun, Nov 07, 2010 at 04:49:20PM +0100, Johannes Sixt wrote:
> On Sonntag, 7. November 2010, Heiko Voigt wrote:
> > j6t: I have not changed your error code in mingw_rename since you
> > explicitely compare with the windows error code ERROR_ACCESS_DENIED and
> > do not use the err_win_to_posix() function. Did you do this on purpose or
> > should I also refer to ERROR_SHARING_VIOLATION ?
>
> IIRC, I dumped the error code before I implemented the retry logic, and the
> error was ERROR_ACCESS_DENIED. Did you verify that the occasions where you
> want to retry the operations indeed fail due to ERROR_SHARING_VIOLATION, or
> do you trust the documentation?
I tested this for my use case which is described by the manual testing
script[1]. I ran it once to create the test structure and then from
inside the test repository
./../block_read 5000 file
and manually checked out the other branch in parallel. In this situation
git will stop with the retry question. But I am not sure which use case you
where addressing. Do you have a script or some information to reproduce?
> In any case, it is better to check for the Windows error code (which ever you
> finally choose) rather than errno, IMO.
I agree because that should give us more fine grained control and since in
err_win_to_posix() many codes are mapped to EACCES.
Cheers Heiko
[1] http://groups.google.com/group/msysgit/msg/fcad5f1455b263ca
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 0/4] make open/unlink failures user friendly on windows using retry/abort
2010-11-07 17:06 ` Heiko Voigt
@ 2010-11-07 19:11 ` Johannes Sixt
0 siblings, 0 replies; 38+ messages in thread
From: Johannes Sixt @ 2010-11-07 19:11 UTC (permalink / raw)
To: Heiko Voigt; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano
On Sonntag, 7. November 2010, Heiko Voigt wrote:
> I tested this for my use case which is described by the manual testing
> script[1]. I ran it once to create the test structure and then from
> inside the test repository
>
> ./../block_read 5000 file
>
> and manually checked out the other branch in parallel. In this situation
> git will stop with the retry question. But I am not sure which use case you
> where addressing. Do you have a script or some information to reproduce?
Sorry, I don't have a reliable test case. I usually encountered this problem
in the test suite at random places when it was run with 'make -j2' and in a
production repository sometimes during rebase --interactive.
-- Hannes
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 1/4] mingw: move unlink wrapper to mingw.c
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
` (4 preceding siblings ...)
2010-11-07 14:56 ` [PATCH v2 0/4] make open/unlink failures user friendly on windows using retry/abort Heiko Voigt
@ 2010-11-07 14:56 ` Heiko Voigt
2010-11-07 14:56 ` [PATCH v2 2/4] mingw: work around irregular failures of unlink on windows Heiko Voigt
` (2 subsequent siblings)
8 siblings, 0 replies; 38+ messages in thread
From: Heiko Voigt @ 2010-11-07 14:56 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano
The next patch implements a workaround in case unlink fails on Windows.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
compat/mingw.c | 8 ++++++++
compat/mingw.h | 11 +++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 98163da..49c594f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -155,6 +155,14 @@ int mingw_mkdir(const char *path, int mode)
return ret;
}
+#undef unlink
+int mingw_unlink(const char *pathname)
+{
+ /* read-only files cannot be removed */
+ chmod(pathname, 0666);
+ return unlink(pathname);
+}
+
#undef open
int mingw_open (const char *filename, int oflags, ...)
{
diff --git a/compat/mingw.h b/compat/mingw.h
index 56e58ba..220ae90 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -119,14 +119,6 @@ static inline int fcntl(int fd, int cmd, ...)
int mingw_mkdir(const char *path, int mode);
#define mkdir mingw_mkdir
-static inline int mingw_unlink(const char *pathname)
-{
- /* read-only files cannot be removed */
- chmod(pathname, 0666);
- return unlink(pathname);
-}
-#define unlink mingw_unlink
-
static inline pid_t waitpid(pid_t pid, int *status, unsigned options)
{
if (options == 0)
@@ -177,6 +169,9 @@ int link(const char *oldpath, const char *newpath);
* replacements of existing functions
*/
+int mingw_unlink(const char *pathname);
+#define unlink mingw_unlink
+
int mingw_open (const char *filename, int oflags, ...);
#define open mingw_open
--
1.7.2.2.177.geec0d
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH v2 2/4] mingw: work around irregular failures of unlink on windows
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
` (5 preceding siblings ...)
2010-11-07 14:56 ` [PATCH v2 1/4] mingw: move unlink wrapper to mingw.c Heiko Voigt
@ 2010-11-07 14:56 ` Heiko Voigt
2010-11-07 14:56 ` [PATCH v2 3/4] mingw: make failures to unlink or move raise a question Heiko Voigt
2010-11-07 14:56 ` [PATCH v2 4/4] mingw: add fallback for rmdir in case directory is in use Heiko Voigt
8 siblings, 0 replies; 38+ messages in thread
From: Heiko Voigt @ 2010-11-07 14:56 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano
If a file is opened by another process (e.g. indexing of an IDE) for
reading it is not allowed to be deleted. So in case unlink fails retry
after waiting for some time. This extends the workaround from 6ac6f878.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
compat/mingw.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 49c594f..bf9ffb8 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -5,6 +5,7 @@
#include "../cache.h"
unsigned int _CRT_fmode = _O_BINARY;
+static const int delay[] = { 0, 1, 10, 20, 40 };
int err_win_to_posix(DWORD winerr)
{
@@ -119,6 +120,13 @@ int err_win_to_posix(DWORD winerr)
return error;
}
+static inline int is_file_in_use_error()
+{
+ if (GetLastError() == ERROR_SHARING_VIOLATION)
+ return 1;
+ return 0;
+}
+
static int make_hidden(const char *path)
{
DWORD attribs = GetFileAttributes(path);
@@ -158,9 +166,24 @@ int mingw_mkdir(const char *path, int mode)
#undef unlink
int mingw_unlink(const char *pathname)
{
+ int ret, tries = 0;
+
/* read-only files cannot be removed */
chmod(pathname, 0666);
- return unlink(pathname);
+ while ((ret = unlink(pathname)) == -1 && tries < ARRAY_SIZE(delay)) {
+ if (!is_file_in_use_error())
+ break;
+ /*
+ * We assume that some other process had the source or
+ * destination file open at the wrong moment and retry.
+ * In order to give the other process a higher chance to
+ * complete its operation, we give up our time slice now.
+ * If we have to retry again, we do sleep a bit.
+ */
+ Sleep(delay[tries]);
+ tries++;
+ }
+ return ret;
}
#undef open
@@ -1279,7 +1302,6 @@ int mingw_rename(const char *pold, const char *pnew)
{
DWORD attrs, gle;
int tries = 0;
- static const int delay[] = { 0, 1, 10, 20, 40 };
/*
* Try native rename() first to get errno right.
--
1.7.2.2.177.geec0d
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH v2 3/4] mingw: make failures to unlink or move raise a question
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
` (6 preceding siblings ...)
2010-11-07 14:56 ` [PATCH v2 2/4] mingw: work around irregular failures of unlink on windows Heiko Voigt
@ 2010-11-07 14:56 ` Heiko Voigt
2010-11-07 14:56 ` [PATCH v2 4/4] mingw: add fallback for rmdir in case directory is in use Heiko Voigt
8 siblings, 0 replies; 38+ messages in thread
From: Heiko Voigt @ 2010-11-07 14:56 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano
On Windows in case a program is accessing a file unlink or
move operations may fail. To give the user a chance to correct
this we simply wait until the user asks us to retry or fail.
This is useful because of the following use case which seem
to happen rarely but when it does it is a mess:
After making some changes the user realizes that he was on the
incorrect branch. When trying to change the branch some file
is still in use by some other process and git stops in the
middle of changing branches. Now the user has lots of files
with changes mixed with his own. This is especially confusing
on repositories that contain lots of files.
Although the recent implementation of automatic retry makes
this scenario much more unlikely lets provide a fallback as
a last resort.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
compat/mingw.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index bf9ffb8..b66bf89 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -3,6 +3,7 @@
#include <conio.h>
#include "../strbuf.h"
#include "../cache.h"
+#include "../run-command.h"
unsigned int _CRT_fmode = _O_BINARY;
static const int delay[] = { 0, 1, 10, 20, 40 };
@@ -163,6 +164,78 @@ int mingw_mkdir(const char *path, int mode)
return ret;
}
+static int read_yes_no_answer()
+{
+ char answer[1024];
+
+ if (fgets(answer, sizeof(answer), stdin)) {
+ size_t answer_len = strlen(answer);
+ int got_full_line = 0, c;
+
+ /* remove the newline */
+ if (answer_len >= 2 && answer[answer_len-2] == '\r') {
+ answer[answer_len-2] = '\0';
+ got_full_line = 1;
+ }
+ else if (answer_len >= 1 && answer[answer_len-1] == '\n') {
+ answer[answer_len-1] = '\0';
+ got_full_line = 1;
+ }
+ /* flush the buffer in case we did not get the full line */
+ if (!got_full_line)
+ while((c = getchar()) != EOF && c != '\n');
+ } else
+ /* we could not read, return the
+ * default answer which is no */
+ return 0;
+
+ if (answer[0] == 'y' && strlen(answer) == 1)
+ return 1;
+ if (!strncasecmp(answer, "yes", sizeof(answer)))
+ return 1;
+ if (answer[0] == 'n' && strlen(answer) == 1)
+ return 0;
+ if (!strncasecmp(answer, "no", sizeof(answer)))
+ return 0;
+
+ /* did not find an answer we understand */
+ return -1;
+}
+
+static int ask_user_yes_no(const char *format, ...)
+{
+ char question[4096];
+ const char *retry_hook[] = { NULL, NULL, NULL };
+ va_list args;
+
+ if ((retry_hook[0] = getenv("GIT_ASK_YESNO"))) {
+
+ va_start(args, format);
+ vsnprintf(question, sizeof(question), format, args);
+ va_end(args);
+
+ retry_hook[1] = question;
+ return !run_command_v_opt(retry_hook, 0);
+ }
+
+ if (!isatty(_fileno(stdin)))
+ return 0;
+
+ while (1) {
+ int answer;
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ va_end(args);
+ fprintf(stderr, " (y/n)? ");
+
+ if ((answer = read_yes_no_answer()) >= 0)
+ return answer;
+
+ fprintf(stderr, "Sorry, I did not understand your answer. "
+ "Please type 'y' or 'n'\n");
+ }
+}
+
#undef unlink
int mingw_unlink(const char *pathname)
{
@@ -183,6 +256,10 @@ int mingw_unlink(const char *pathname)
Sleep(delay[tries]);
tries++;
}
+ while (ret == -1 && is_file_in_use_error() &&
+ ask_user_yes_no("Unlink of file '%s' failed. "
+ "Should I try again?", pathname))
+ ret = unlink(pathname);
return ret;
}
@@ -1343,6 +1420,11 @@ repeat:
tries++;
goto repeat;
}
+ if (gle == ERROR_ACCESS_DENIED &&
+ ask_user_yes_no("Rename from '%s' to '%s' failed. "
+ "Should I try again?", pold, pnew))
+ goto repeat;
+
errno = EACCES;
return -1;
}
--
1.7.2.2.177.geec0d
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH v2 4/4] mingw: add fallback for rmdir in case directory is in use
2010-09-28 20:52 ` [msysGit] Pull request for msysGit patches Johannes Sixt
` (7 preceding siblings ...)
2010-11-07 14:56 ` [PATCH v2 3/4] mingw: make failures to unlink or move raise a question Heiko Voigt
@ 2010-11-07 14:56 ` Heiko Voigt
8 siblings, 0 replies; 38+ messages in thread
From: Heiko Voigt @ 2010-11-07 14:56 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Pat Thoyts, msysgit, git, Junio C Hamano
From: Heiko Voigt <heiko.voigt@mahr.de>
The same logic as for unlink and rename also applies to rmdir. For
example in case you have a shell open in a git controlled folder. This
will easily fail. So lets be nice for such cases as well.
Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de>
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
compat/mingw.c | 25 +++++++++++++++++++++++++
compat/mingw.h | 3 +++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index b66bf89..8e4f1e2 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -263,6 +263,31 @@ int mingw_unlink(const char *pathname)
return ret;
}
+#undef rmdir
+int mingw_rmdir(const char *pathname)
+{
+ int ret, tries = 0;
+
+ while ((ret = rmdir(pathname)) == -1 && tries < ARRAY_SIZE(delay)) {
+ if (!is_file_in_use_error())
+ break;
+ /*
+ * We assume that some other process had the source or
+ * destination file open at the wrong moment and retry.
+ * In order to give the other process a higher chance to
+ * complete its operation, we give up our time slice now.
+ * If we have to retry again, we do sleep a bit.
+ */
+ Sleep(delay[tries]);
+ tries++;
+ }
+ while (ret == -1 && is_file_in_use_error() &&
+ ask_user_yes_no("Deletion of directory '%s' failed. "
+ "Should I try again?", pathname))
+ ret = rmdir(pathname);
+ return ret;
+}
+
#undef open
int mingw_open (const char *filename, int oflags, ...)
{
diff --git a/compat/mingw.h b/compat/mingw.h
index 220ae90..cf69d39 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -172,6 +172,9 @@ int link(const char *oldpath, const char *newpath);
int mingw_unlink(const char *pathname);
#define unlink mingw_unlink
+int mingw_rmdir(const char *path);
+#define rmdir mingw_rmdir
+
int mingw_open (const char *filename, int oflags, ...);
#define open mingw_open
--
1.7.2.2.177.geec0d
^ permalink raw reply related [flat|nested] 38+ messages in thread