Joel Brobecker 1d1d4e7b3a crash in git_attrs.git_attribute function
A recent change in this function sometimes causes a crash when
pushing a commit. This happens in a situation such as the following:

The user has a repository that looks like this:

     <root>/
        subdir/
           .gitattributes
           sub_sub_dir/
              .gitattributes
              some_file

If the user creates a commit which modifies some_file, the git_attribute
function will be passed a list of files which includes:

    subdir/sub_sub_dir/some_file

It will process that file by first looking at subdir/sub_sub_dir,
check if there is a .gitattributes in it (yes), so create that
directory, add it to the dirs_with_changes "list" so we know
we've already processed that directory. So far, so good.

Loop again, this time with os.path.dirname('subdir/sub_sub_dir'),
thus with 'subdir'. Is that directory in dirs_with_changes? No.
Does it have a .gitattribute in it? Yes.  So, rince-repeat, which
means first creating the subdir. That leads to the crash, since
we already just created it as a side-effect of creating its subdir.

This patch fixes the issue by simply remembering when a directory
has been created for a given file in filename_list.  Once that's
done, we know that the next iterations on the dir_path loop are
necessarily for parent directories, which have therefore been
created, even if they are not listed in the dirs_with_changes
"list" yet.

Another possible fix, which would be safer, would be to just
check the filesystem directly. But this code can be a hot-spot
in terms of performance, so we'll try really hard to avoid it.

Fixes P601-011.
Related to P531-036.
2016-06-07 09:27:28 -07:00
2012-04-27 13:44:51 -07:00
2014-12-06 13:14:11 +04:00
2014-12-06 13:22:58 +04:00

This directory contains the AdaCore Git Hooks.

The AdaCore Git Hooks project provides a set of scripts to be used as
server-side hooks for git repositories.  In addition to those scripts,
it also provides a testsuite to validate those scripts.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; see COPYING3 for a copy of the license.
Description
No description provided
Readme 7.4 MiB
Languages
Python 99.3%
Shell 0.7%