internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: borgbackup/borg

Issue:
build_man issues
```
building man page borg-recreate(1)
building man page borg-rename(1)
building man page borg-serve(1)
building man page borg-umount(1)
building man page borg-upgrade(1)
building man page borg-with-lock(1)
building man page borg-patterns(1)
building man page borg-placeholders(1)
building man page borg-compression(1)
building man page borg(1)
docs/usage_general.rst.inc:410: (ERROR/3) Unknown interpreted text role "issue".
docs/usage_general.rst.inc:412: (ERROR/3) Unknown interpreted text role "issue".
docs/usage_general.rst.inc:413: (ERROR/3) Unknown interpreted text role "issue".
docs/usage_general.rst.inc:: (WARNING/2) "table row spanning" not supported
docs/usage_general.rst.inc:: (WARNING/2) "table row spanning" not supported
docs/usage_general.rst.inc:: (WARNING/2) "table cell spanning" not supported
docs/usage_general.rst.inc:: (WARNING/2) "table row spanning" not supported
```


Discussion:
This is not only a error msg on the terminal, the error msg also gets written into the man page:

```
       [1]  Only "nodump", "immutable", "compressed" and "append" are supported.  Feature request
            :issue:`618`
             for more flags.

       System Message: ERROR/3 (docs/usage_general.rst.inc:, line 410)
            Unknown interpreted text role "issue".
```

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -653,6 +653,13 @@ def write_see_also(self, write, man_title):
     def gen_man_page(self, name, rst):
         from docutils.writers import manpage
         from docutils.core import publish_string
+        from docutils.nodes import inline
+        from docutils.parsers.rst import roles
+
+        def issue(name, rawtext, text, lineno, inliner, options={}, content=[]):
+            return [inline(rawtext, '#' + text)], []
+
+        roles.register_local_role('issue', issue)
         # We give the source_path so that docutils can find relative includes
         # as-if the document where located in the docs/ directory.
         man_page = publish_string(source=rst, source_path='docs/virtmanpage.rst', writer=manpage.Writer())


Test patch:
Repository: borgbackup/borg

Issue:
Encryption authenticated-blake2 not available in version 1.1
According to the [docs](https://borgbackup.readthedocs.io/en/stable/usage/init.html#) for version 1.1, the encryption mode `authenticated-blake2` should be available. However running 

```
borg init --encryption=authenticated-blake2 .
```
yields
```
usage: borg init [-h] [--critical] [--error] [--warning] [--info] [--debug]
                 [--debug-topic TOPIC] [-p] [--log-json] [--lock-wait SECONDS]
                 [--show-version] [--show-rc] [--no-files-cache] [--umask M]
                 [--remote-path PATH] [--remote-ratelimit RATE]
                 [--consider-part-files] [--debug-profile FILE] -e MODE
                 [--append-only] [--storage-quota QUOTA]
                 [REPOSITORY]
borg init: error: argument -e/--encryption: invalid choice: 'authenticated-blake2' (choose from 'none', 'keyfile', 'repokey', 'keyfile-blake2', 'repokey-blake2', 'authenticated')
```


Discussion:

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -40,7 +40,7 @@
 from .cache import Cache, assert_secure
 from .constants import *  # NOQA
 from .compress import CompressionSpec
-from .crypto.key import key_creator, tam_required_file, tam_required, RepoKey, PassphraseKey
+from .crypto.key import key_creator, key_argument_names, tam_required_file, tam_required, RepoKey, PassphraseKey
 from .crypto.keymanager import KeyManager
 from .helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
 from .helpers import Error, NoManifestError, set_ec
@@ -2383,7 +2383,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                type=location_validator(archive=False),
                                help='repository to create')
         subparser.add_argument('-e', '--encryption', metavar='MODE', dest='encryption', required=True,
-                               choices=('none', 'keyfile', 'repokey', 'keyfile-blake2', 'repokey-blake2', 'authenticated'),
+                               choices=key_argument_names(),
                                help='select encryption key mode **(required)**')
         subparser.add_argument('--append-only', dest='append_only', action='store_true',
                                help='create an append-only mode repository')
diff --git a/src/borg/crypto/key.py b/src/borg/crypto/key.py
--- a/src/borg/crypto/key.py
+++ b/src/borg/crypto/key.py
@@ -103,11 +103,16 @@ class KeyBlobStorage:
 def key_creator(repository, args):
     for key in AVAILABLE_KEY_TYPES:
         if key.ARG_NAME == args.encryption:
+            assert key.ARG_NAME is not None
             return key.create(repository, args)
     else:
         raise ValueError('Invalid encryption mode "%s"' % args.encryption)
 
 
+def key_argument_names():
+    return [key.ARG_NAME for key in AVAILABLE_KEY_TYPES if key.ARG_NAME]
+
+
 def identify_key(manifest_data):
     key_type = manifest_data[0]
     if key_type == PassphraseKey.TYPE:


Test patch:
Repository: borgbackup/borg

Issue:
Exception: Path should be relative and local
I am backing up buildroot builds (~5 GB), to be used by other users on other machines eventually. Unfortunately, when restoring a buildroot build, I get the following error (late in the restore process)::

  ```Local Exception
  Traceback (most recent call last):
    File "borg/archiver.py", line 4024, in main
    File "borg/archiver.py", line 3952, in run
    File "borg/archiver.py", line 148, in wrapper
    File "borg/archiver.py", line 159, in wrapper
    File "borg/archiver.py", line 724, in do_extract
    File "borg/archive.py", line 561, in extract_item
  Exception: Path should be relative and local
  ```

The error doesn't contain more details about the file or path causing the problem, unfortunately. I'm trying to get the borg build working locally to add this info (CentOS 7), but I haven't had too much success so far.


Discussion:
Try the --list option to narrow it down a bit.
Thanks!

The problem is a file called '..config.tmp'. Since the check for relative and local files is as follows, it fails: `if item.path.startswith(('/', '..')):`

I propose changing the check to the following (if that is safe): `if item.path.startswith(('/', '../')):`
Introduced in af059fbdfc, affects all versions.

Resolving patch:
diff --git a/src/borg/archive.py b/src/borg/archive.py
--- a/src/borg/archive.py
+++ b/src/borg/archive.py
@@ -557,7 +557,7 @@ def extract_item(self, item, restore_attrs=True, dry_run=False, stdout=False, sp
 
         original_path = original_path or item.path
         dest = self.cwd
-        if item.path.startswith(('/', '..')):
+        if item.path.startswith(('/', '../')):
             raise Exception('Path should be relative and local')
         path = os.path.join(dest, item.path)
         # Attempt to remove existing files, ignore errors on failure


Test patch:
Repository: borgbackup/borg

Issue:
1.1.0: using a logging config causes exception
I've been using Borg 1.0.x with a [simple logging config](https://github.com/borgbackup/borg/files/1369192/logging.conf.txt) to get a logging behaviour suitable for cronjobs, that is: everything goes to the logfile, errors and warnings also go to stderr (and are sent via mail, by cron). Using the same logging config with Borg 1.1.0 causes an exception:

```
2017-10-09 06:05:09 [ERROR] Local Exception
2017-10-09 06:05:09 [ERROR] Traceback (most recent call last):
  File "borg/archiver.py", line 4024, in main
  File "borg/archiver.py", line 3952, in run
  File "borg/archiver.py", line 130, in wrapper
  File "borg/remote.py", line 562, in __init__
  File "borg/remote.py", line 699, in call
  File "borg/remote.py", line 841, in call_many
  File "borg/remote.py", line 989, in handle_remote_line
AttributeError: 'Logger' object has no attribute 'json'
```

When not using a logging config, `setup_logging` will set up two loggers, the second one explicitly named `borg` and having a custom `json` attribute (see logging.py, lines 97-99). While I could add a `borg` logger to my logging config there seems to be no way to add the required custom `json` attribute within the fileConfig format.


Discussion:

Resolving patch:
diff --git a/src/borg/logger.py b/src/borg/logger.py
--- a/src/borg/logger.py
+++ b/src/borg/logger.py
@@ -80,6 +80,8 @@ def setup_logging(stream=None, conf_fname=None, env_var='BORG_LOGGING_CONF', lev
                 logging.config.fileConfig(f)
             configured = True
             logger = logging.getLogger(__name__)
+            borg_logger = logging.getLogger('borg')
+            borg_logger.json = json
             logger.debug('using logging configuration read from "{0}"'.format(conf_fname))
             warnings.showwarning = _log_warning
             return None


Test patch:
Repository: borgbackup/borg

Issue:
Exception: Path should be relative and local
I am backing up buildroot builds (~5 GB), to be used by other users on other machines eventually. Unfortunately, when restoring a buildroot build, I get the following error (late in the restore process)::

  ```Local Exception
  Traceback (most recent call last):
    File "borg/archiver.py", line 4024, in main
    File "borg/archiver.py", line 3952, in run
    File "borg/archiver.py", line 148, in wrapper
    File "borg/archiver.py", line 159, in wrapper
    File "borg/archiver.py", line 724, in do_extract
    File "borg/archive.py", line 561, in extract_item
  Exception: Path should be relative and local
  ```

The error doesn't contain more details about the file or path causing the problem, unfortunately. I'm trying to get the borg build working locally to add this info (CentOS 7), but I haven't had too much success so far.


Discussion:
Try the --list option to narrow it down a bit.
Thanks!

The problem is a file called '..config.tmp'. Since the check for relative and local files is as follows, it fails: `if item.path.startswith(('/', '..')):`

I propose changing the check to the following (if that is safe): `if item.path.startswith(('/', '../')):`
Introduced in af059fbdfc, affects all versions.

Resolving patch:
diff --git a/borg/archive.py b/borg/archive.py
--- a/borg/archive.py
+++ b/borg/archive.py
@@ -374,7 +374,7 @@ def extract_item(self, item, restore_attrs=True, dry_run=False, stdout=False, sp
             return
 
         dest = self.cwd
-        if item[b'path'].startswith('/') or item[b'path'].startswith('..'):
+        if item[b'path'].startswith(('/', '../')):
             raise Exception('Path should be relative and local')
         path = os.path.join(dest, item[b'path'])
         # Attempt to remove existing files, ignore errors on failure


Test patch:
Repository: borgbackup/borg

Issue:
borg: error: unrecognized arguments: --files-cache=disabled
$ borg -V
borg 1.1.0

```
borg prune ... -v -s --list --no-files-cache ...
...
Warning: "--no-files-cache" has been deprecated. Use "--files-cache=disabled" instead.
```
and

```bash
borg prune ... -v -s --list --files-cache=disabled ...
...
borg: error: unrecognized arguments: --files-cache=disabled
```


Discussion:
Interesting. borg prune does not use the files cache anyway.

But looks like you discovered some discrepancy in how these 2 options are handled.

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -1326,7 +1326,7 @@ def do_prune(self, args, repository, manifest, key):
             keep += prune_split(archives, '%Y', args.yearly, keep)
         to_delete = (set(archives) | checkpoints) - (set(keep) | set(keep_checkpoints))
         stats = Statistics()
-        with Cache(repository, key, manifest, do_files=args.cache_files, lock_wait=self.lock_wait) as cache:
+        with Cache(repository, key, manifest, do_files=False, lock_wait=self.lock_wait) as cache:
             list_logger = logging.getLogger('borg.output.list')
             if args.output_list:
                 # set up counters for the progress display
@@ -2152,8 +2152,6 @@ def define_common_options(add_common_option):
                               help='show/log the borg version')
             add_common_option('--show-rc', dest='show_rc', action='store_true',
                               help='show/log the return code (rc)')
-            add_common_option('--no-files-cache', dest='cache_files', action='store_false',
-                              help='do not load/update the file metadata cache used to detect unchanged files')
             add_common_option('--umask', metavar='M', dest='umask', type=lambda s: int(s, 8), default=UMASK_DEFAULT,
                               help='set umask to M (local and remote, default: %(default)04o)')
             add_common_option('--remote-path', metavar='PATH', dest='remote_path',
@@ -2723,6 +2721,8 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                help='output stats as JSON. Implies ``--stats``.')
         subparser.add_argument('--no-cache-sync', dest='no_cache_sync', action='store_true',
                                help='experimental: do not synchronize the cache. Implies not using the files cache.')
+        subparser.add_argument('--no-files-cache', dest='cache_files', action='store_false',
+                               help='do not load/update the file metadata cache used to detect unchanged files')
 
         define_exclusion_group(subparser, tag_files=True)
 


Test patch:
Repository: borgbackup/borg

Issue:
--show-version in the docs, but --version in borg
I think --show-version doesn't exist:
```
frank@HomeC ~/Downloads> ./borg-linux64 --version
borg-linux64 1.1.0
frank@HomeC ~/Downloads> ./borg-linux64 --show-version
Traceback (most recent call last):
  File "borg/__main__.py", line 2, in <module>
  File "borg/archiver.py", line 4013, in main
  File "borg/archiver.py", line 3849, in get_args
  File "borg/archiver.py", line 3873, in parse_args
AttributeError: 'Namespace' object has no attribute 'fallback_func'
Failed to execute script __main__
```


Discussion:
So? Where's the issue?
The issue is that the documentation says --show-version, but borg gives an error on that. But it does understand the --version switch.
It was apparently implemented in #725
Works for me (borg 1.1):
```
(borg-env) tw@tux:~/w/borg$ borg --version
borg 1.1.1.dev3+gf407de0

(borg-env) tw@tux:~/w/borg$ borg create --show-version --show-rc --list -v repo::arch inp/
borgbackup version 1.1.1.dev3+gf407de0
b inp/fd0
d inp
terminating with success status, rc 0
```
So, guess the docs should say how to use these 2 options (== together with another borg command).

The intention is to have the borg version / the borg rc in the log when e.g. running borg create.
http://borgbackup.readthedocs.io/en/stable/usage/general.html?highlight=show-version#common-options
Oh, I see, thanks. Well then, --version is undocumented? 
+bug since it shouldn't crash

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -1959,6 +1959,8 @@ def do_subcommand_help(self, parser, args):
         parser.print_help()
         return EXIT_SUCCESS
 
+    do_maincommand_help = do_subcommand_help
+
     def preprocess_args(self, args):
         deprecations = [
             # ('--old', '--new' or None, 'Warning: "--old" has been deprecated. Use "--new" instead.'),
@@ -2226,6 +2228,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
 
         parser = argparse.ArgumentParser(prog=self.prog, description='Borg - Deduplicated Backups',
                                          add_help=False)
+        parser.set_defaults(func=functools.partial(self.do_maincommand_help, parser))
         parser.common_options = self.CommonOptions(define_common_options,
                                                    suffix_precedence=('_maincommand', '_midcommand', '_subcommand'))
         parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__,


Test patch:
Repository: borgbackup/borg

Issue:
--show-version in the docs, but --version in borg
I think --show-version doesn't exist:
```
frank@HomeC ~/Downloads> ./borg-linux64 --version
borg-linux64 1.1.0
frank@HomeC ~/Downloads> ./borg-linux64 --show-version
Traceback (most recent call last):
  File "borg/__main__.py", line 2, in <module>
  File "borg/archiver.py", line 4013, in main
  File "borg/archiver.py", line 3849, in get_args
  File "borg/archiver.py", line 3873, in parse_args
AttributeError: 'Namespace' object has no attribute 'fallback_func'
Failed to execute script __main__
```


Discussion:
So? Where's the issue?
The issue is that the documentation says --show-version, but borg gives an error on that. But it does understand the --version switch.
It was apparently implemented in #725
Works for me (borg 1.1):
```
(borg-env) tw@tux:~/w/borg$ borg --version
borg 1.1.1.dev3+gf407de0

(borg-env) tw@tux:~/w/borg$ borg create --show-version --show-rc --list -v repo::arch inp/
borgbackup version 1.1.1.dev3+gf407de0
b inp/fd0
d inp
terminating with success status, rc 0
```
So, guess the docs should say how to use these 2 options (== together with another borg command).

The intention is to have the borg version / the borg rc in the log when e.g. running borg create.
http://borgbackup.readthedocs.io/en/stable/usage/general.html?highlight=show-version#common-options
Oh, I see, thanks. Well then, --version is undocumented? 
+bug since it shouldn't crash

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -2156,6 +2156,8 @@ def do_subcommand_help(self, parser, args):
         parser.print_help()
         return EXIT_SUCCESS
 
+    do_maincommand_help = do_subcommand_help
+
     def preprocess_args(self, args):
         deprecations = [
             # ('--old', '--new' or None, 'Warning: "--old" has been deprecated. Use "--new" instead.'),
@@ -2423,6 +2425,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
 
         parser = argparse.ArgumentParser(prog=self.prog, description='Borg - Deduplicated Backups',
                                          add_help=False)
+        parser.set_defaults(func=functools.partial(self.do_maincommand_help, parser))
         parser.common_options = self.CommonOptions(define_common_options,
                                                    suffix_precedence=('_maincommand', '_midcommand', '_subcommand'))
         parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__,


Test patch:
Repository: borgbackup/borg

Issue:
borg: error: unrecognized arguments: --files-cache=disabled
$ borg -V
borg 1.1.0

```
borg prune ... -v -s --list --no-files-cache ...
...
Warning: "--no-files-cache" has been deprecated. Use "--files-cache=disabled" instead.
```
and

```bash
borg prune ... -v -s --list --files-cache=disabled ...
...
borg: error: unrecognized arguments: --files-cache=disabled
```


Discussion:
Interesting. borg prune does not use the files cache anyway.

But looks like you discovered some discrepancy in how these 2 options are handled.
Why exactly is --no-files-cache a common option anyway? It is only used by `borg create`.
As far as I remember - if I'm not using this option with `borg prune` - the local cache is downloaded in the beginning.
@enkore I reviewed the code and it seems that for prune, it can just be do_files=False.

So yes, it is only borg create left as a user of --files-cache and --no-files-cache.

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -1523,7 +1523,7 @@ def do_prune(self, args, repository, manifest, key):
             keep += prune_split(archives, '%Y', args.yearly, keep)
         to_delete = (set(archives) | checkpoints) - (set(keep) | set(keep_checkpoints))
         stats = Statistics()
-        with Cache(repository, key, manifest, do_files=args.cache_files, lock_wait=self.lock_wait) as cache:
+        with Cache(repository, key, manifest, do_files=False, lock_wait=self.lock_wait) as cache:
             list_logger = logging.getLogger('borg.output.list')
             if args.output_list:
                 # set up counters for the progress display
@@ -2351,8 +2351,6 @@ def define_common_options(add_common_option):
                               help='show/log the borg version')
             add_common_option('--show-rc', dest='show_rc', action='store_true',
                               help='show/log the return code (rc)')
-            add_common_option('--no-files-cache', dest='cache_files', action='store_false',
-                              help='do not load/update the file metadata cache used to detect unchanged files')
             add_common_option('--umask', metavar='M', dest='umask', type=lambda s: int(s, 8), default=UMASK_DEFAULT,
                               help='set umask to M (local and remote, default: %(default)04o)')
             add_common_option('--remote-path', metavar='PATH', dest='remote_path',
@@ -2923,6 +2921,8 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                help='output stats as JSON. Implies ``--stats``.')
         subparser.add_argument('--no-cache-sync', dest='no_cache_sync', action='store_true',
                                help='experimental: do not synchronize the cache. Implies not using the files cache.')
+        subparser.add_argument('--no-files-cache', dest='cache_files', action='store_false',
+                               help='do not load/update the file metadata cache used to detect unchanged files')
 
         define_exclusion_group(subparser, tag_files=True)
 


Test patch: