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

Issue:
borg info gives wrong info about encryption for "authenticated" mode
## Have you checked borgbackup docs, FAQ, and open Github issues?  
Yes  

## Is this a BUG / ISSUE report or a QUESTION?  
BUG

#### Your borg version (borg -V).  
borg 1.1.15

#### Full borg commandline that lead to the problem (leave away excludes and passwords)  
```
borg init --encryption=authenticated /path/to/repository
borg info /path/to/repository
```

## Describe the problem you're observing.
The [documentation here](https://borgbackup.readthedocs.io/en/stable/usage/init.html) state "If you do not want to encrypt the contents of your backups, but still want to detect malicious tampering use --encryption authenticated."

But `borg info` reports that:
```
Encrypted: Yes (authenticated)
```

What is the real status about that? All informations welcome!

EDIT: following [this link](https://github.com/borgbackup/borg/issues/4042) it looks to not be encrypted.



Discussion:
`authenticated` is not encrypted. That's a bug in `borg info` due to a bad check for unencrypted (only `plaintext` is considered not encrypted, `authenticated` missing there).

Also, guess for the Yes/No we could better use `KEYCLASS.logically_encrypted` which also considers the case that an empty passphrase repokey should be considered as logically not encrypted. And we should give `KEYCLASS.NAME` in any case to make clear what mode we have specifically.

I'd like to work on this issue!
@bybwang Thanks! Just open a PR against master branch with your changes.
@bybwang do you need help?
Hi there! I'm a novice at Python and I was wondering if this would be a good open source for me to contribute to at my skill level? :)
@cmcgee0308 It depends. Some parts are easy, some parts are hard.

Maybe check the issues for tag "easy" or "good first issue".
This issue had those tags so I was hoping it would be right up my alley. 😁
@ThomasWaldmann I'm ok thanks for asking! Sorry I had some stuff come up but I will be taking a look soon
i want to release 1.1.18 soon, can we speed up a bit?
I'll fix this myself.

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -1471,7 +1471,7 @@ def _info_repository(self, args, repository, manifest, key, cache):
             json_print(info)
         else:
             encryption = 'Encrypted: '
-            if key.NAME == 'plaintext':
+            if key.NAME in ('plaintext', 'authenticated'):
                 encryption += 'No'
             else:
                 encryption += 'Yes (%s)' % key.NAME


Test patch:
Repository: borgbackup/borg

Issue:
borg info gives wrong info about encryption for "authenticated" mode
## Have you checked borgbackup docs, FAQ, and open Github issues?  
Yes  

## Is this a BUG / ISSUE report or a QUESTION?  
BUG

#### Your borg version (borg -V).  
borg 1.1.15

#### Full borg commandline that lead to the problem (leave away excludes and passwords)  
```
borg init --encryption=authenticated /path/to/repository
borg info /path/to/repository
```

## Describe the problem you're observing.
The [documentation here](https://borgbackup.readthedocs.io/en/stable/usage/init.html) state "If you do not want to encrypt the contents of your backups, but still want to detect malicious tampering use --encryption authenticated."

But `borg info` reports that:
```
Encrypted: Yes (authenticated)
```

What is the real status about that? All informations welcome!

EDIT: following [this link](https://github.com/borgbackup/borg/issues/4042) it looks to not be encrypted.



Discussion:
`authenticated` is not encrypted. That's a bug in `borg info` due to a bad check for unencrypted (only `plaintext` is considered not encrypted, `authenticated` missing there).

Also, guess for the Yes/No we could better use `KEYCLASS.logically_encrypted` which also considers the case that an empty passphrase repokey should be considered as logically not encrypted. And we should give `KEYCLASS.NAME` in any case to make clear what mode we have specifically.

I'd like to work on this issue!
@bybwang Thanks! Just open a PR against master branch with your changes.
@bybwang do you need help?
Hi there! I'm a novice at Python and I was wondering if this would be a good open source for me to contribute to at my skill level? :)
@cmcgee0308 It depends. Some parts are easy, some parts are hard.

Maybe check the issues for tag "easy" or "good first issue".
This issue had those tags so I was hoping it would be right up my alley. 😁
@ThomasWaldmann I'm ok thanks for asking! Sorry I had some stuff come up but I will be taking a look soon
i want to release 1.1.18 soon, can we speed up a bit?
I'll fix this myself.

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -1660,7 +1660,7 @@ def _info_repository(self, args, repository, manifest, key, cache):
             json_print(info)
         else:
             encryption = 'Encrypted: '
-            if key.NAME == 'plaintext':
+            if key.NAME in ('plaintext', 'authenticated'):
                 encryption += 'No'
             else:
                 encryption += 'Yes (%s)' % key.NAME


Test patch:
Repository: borgbackup/borg

Issue:
crashing with UnboundLocalError in create_filter_process
```
        try:
            yield stream
    
        except Exception:
            # something went wrong with processing the stream by borg
            logger.debug('Exception, killing the filter...')
>           proc.kill()
E           UnboundLocalError: local variable 'proc' referenced before assignment

src/borg/helpers/process.py:335: UnboundLocalError
```

Guess cmd can be None and there should be a `if cmd:`.


Discussion:
Fix in master, check whether fix is needed in 1.2-maint and 1.1-maint and backport.

Resolving patch:
diff --git a/src/borg/helpers/process.py b/src/borg/helpers/process.py
--- a/src/borg/helpers/process.py
+++ b/src/borg/helpers/process.py
@@ -332,7 +332,8 @@ def create_filter_process(cmd, stream, stream_close, inbound=True):
     except Exception:
         # something went wrong with processing the stream by borg
         logger.debug('Exception, killing the filter...')
-        proc.kill()
+        if cmd:
+            proc.kill()
         borg_succeeded = False
         raise
     else:


Test patch:
Repository: borgbackup/borg

Issue:
allow msgpack 1.0.4 after it is released and tested
msgpack 1.0.4 is a recompile with current cython and enables python 3.11 compatibility.

https://github.com/msgpack/msgpack-python/releases

note: only 1.2/master, borg 1.1.x can't work with msgpack 1.x.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -67,7 +67,7 @@
 install_requires = [
     # we are rather picky about msgpack versions, because a good working msgpack is
     # very important for borg, see: https://github.com/borgbackup/borg/issues/3753
-    'msgpack >=0.5.6, <=1.0.3, !=1.0.1',
+    'msgpack >=0.5.6, <=1.0.4, !=1.0.1',
     # Please note:
     # using any other version is not supported by borg development and
     # any feedback related to issues caused by this will be ignored.
@@ -285,6 +285,7 @@ def members_appended(*ds):
         'Programming Language :: Python :: 3.8',
         'Programming Language :: Python :: 3.9',
         'Programming Language :: Python :: 3.10',
+        'Programming Language :: Python :: 3.11',
         'Topic :: Security :: Cryptography',
         'Topic :: System :: Archiving :: Backup',
     ],
diff --git a/src/borg/helpers/msgpack.py b/src/borg/helpers/msgpack.py
--- a/src/borg/helpers/msgpack.py
+++ b/src/borg/helpers/msgpack.py
@@ -182,7 +182,7 @@ def is_slow_msgpack():
 def is_supported_msgpack():
     # DO NOT CHANGE OR REMOVE! See also requirements and comments in setup.py.
     import msgpack
-    return (0, 5, 6) <= msgpack.version <= (1, 0, 3) and \
+    return (0, 5, 6) <= msgpack.version <= (1, 0, 4) and \
            msgpack.version not in [(1, 0, 1), ]  # < add bad releases here to deny list
 
 


Test patch:
Repository: borgbackup/borg

Issue:
allow msgpack 1.0.4 after it is released and tested
msgpack 1.0.4 is a recompile with current cython and enables python 3.11 compatibility.

https://github.com/msgpack/msgpack-python/releases

note: only 1.2/master, borg 1.1.x can't work with msgpack 1.x.


Discussion:

Resolving patch:
diff --git a/src/borg/helpers/msgpack.py b/src/borg/helpers/msgpack.py
--- a/src/borg/helpers/msgpack.py
+++ b/src/borg/helpers/msgpack.py
@@ -142,7 +142,7 @@ def is_slow_msgpack():
 def is_supported_msgpack():
     # DO NOT CHANGE OR REMOVE! See also requirements and comments in setup.py.
     import msgpack
-    return (1, 0, 3) <= msgpack.version <= (1, 0, 3) and \
+    return (1, 0, 3) <= msgpack.version <= (1, 0, 4) and \
            msgpack.version not in []  # < add bad releases here to deny list
 
 


Test patch:
Repository: borgbackup/borg

Issue:
create --paths-from-*: paths are not normalised by borg
Within archives created with borg 1.2.0/1.2.1 and the options 

```
--paths-from-stdin --paths-delimiter "\0"
```

each path begins with ```./```:

```
./path/to/file1
./path/to/file2
etc...
```

```borg extract``` can extract the entire archive, but if a path is given no
files are extracted because there is no way to match ```./``` 

If the archive is mounted, the top directory under the mount is named ```.```
(dot), and thus there is no way to access the files under it.






Discussion:
Hmm, guess this is about responsibilities.

If borg does the recursion by itself, it makes sure archived paths look like e.g. `home/user/Downloads/file.txt` (e.g. it removes leading slashes and also `.` or `..`).

If you use --paths-from-stdin, you switch off that part of borg and take full control yourself, telling borg exactly what to back up, file by file.

So it could be argued that borg shall exactly take what you give it (that's what it does now) and just use that as is.

OTOH, if that leads to strange / impossible to deal with situations like you described, that would rather speak for that borg shall make sure some requirements are enforced, either by rejecting bad paths or by transforming them to a valid path.



Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -554,6 +554,7 @@ def create_inner(archive, cache, fso):
                     pipe_bin = sys.stdin.buffer
                 pipe = TextIOWrapper(pipe_bin, errors='surrogateescape')
                 for path in iter_separated(pipe, paths_sep):
+                    path = os.path.normpath(path)
                     try:
                         with backup_io('stat'):
                             st = os_stat(path=path, parent_fd=None, name=None, follow_symlinks=False)


Test patch:
Repository: borgbackup/borg

Issue:
create --paths-from-*: paths are not normalised by borg
Within archives created with borg 1.2.0/1.2.1 and the options 

```
--paths-from-stdin --paths-delimiter "\0"
```

each path begins with ```./```:

```
./path/to/file1
./path/to/file2
etc...
```

```borg extract``` can extract the entire archive, but if a path is given no
files are extracted because there is no way to match ```./``` 

If the archive is mounted, the top directory under the mount is named ```.```
(dot), and thus there is no way to access the files under it.






Discussion:
Hmm, guess this is about responsibilities.

If borg does the recursion by itself, it makes sure archived paths look like e.g. `home/user/Downloads/file.txt` (e.g. it removes leading slashes and also `.` or `..`).

If you use --paths-from-stdin, you switch off that part of borg and take full control yourself, telling borg exactly what to back up, file by file.

So it could be argued that borg shall exactly take what you give it (that's what it does now) and just use that as is.

OTOH, if that leads to strange / impossible to deal with situations like you described, that would rather speak for that borg shall make sure some requirements are enforced, either by rejecting bad paths or by transforming them to a valid path.



Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -779,6 +779,7 @@ def create_inner(archive, cache, fso):
                     pipe_bin = sys.stdin.buffer
                 pipe = TextIOWrapper(pipe_bin, errors='surrogateescape')
                 for path in iter_separated(pipe, paths_sep):
+                    path = os.path.normpath(path)
                     try:
                         with backup_io('stat'):
                             st = os_stat(path=path, parent_fd=None, name=None, follow_symlinks=False)


Test patch:
Repository: borgbackup/borg

Issue:
fix docs markup
https://borgbackup.readthedocs.io/en/2.0.0a2/usage/transfer.html



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
@@ -4653,6 +4653,7 @@ def define_borg_mount(parser):
 
         The following keys are always available:
 
+
         """) + BaseFormatter.keys_help() + textwrap.dedent("""
 
         Keys available only when listing files in an archive:
@@ -4710,6 +4711,7 @@ def define_borg_mount(parser):
 
         The following keys are always available:
 
+
         """) + BaseFormatter.keys_help() + textwrap.dedent("""
 
         Keys available only when listing archives in a repository:


Test patch:
Repository: borgbackup/borg

Issue:
hardlinked symlinks test not supported on macOS
creating a hardlink of a symlink fs object is not possible on macOS, raises "OSError: operation not supported".

borg2 tests need fixing to consider this.



Discussion:

Resolving patch:
diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py
--- a/src/borg/testsuite/archiver.py
+++ b/src/borg/testsuite/archiver.py
@@ -56,7 +56,7 @@
 from . import has_lchflags, llfuse
 from . import BaseTestCase, changedir, environment_variable, no_selinux
 from . import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported, is_utime_fully_supported, is_birthtime_fully_supported
-from .platform import fakeroot_detected
+from .platform import fakeroot_detected, is_darwin
 from . import key
 
 
@@ -505,8 +505,8 @@ def test_symlink_extract(self):
             self.cmd(f'--repo={self.repository_location}', 'extract', 'test')
             assert os.readlink('input/link1') == 'somewhere'
 
-    @pytest.mark.skipif(not are_symlinks_supported() or not are_hardlinks_supported(),
-                        reason='symlinks or hardlinks not supported')
+    @pytest.mark.skipif(not are_symlinks_supported() or not are_hardlinks_supported() or is_darwin,
+                        reason='symlinks or hardlinks or hardlinked symlinks not supported')
     def test_hardlinked_symlinks_extract(self):
         self.create_regular_file('target', size=1024)
         with changedir('input'):


Test patch:
Repository: borgbackup/borg

Issue:
do not require repo version = 2 for borg transfer --other-repo
the old repos have version 1.


Discussion:

Resolving patch:
diff --git a/src/borg/repository.py b/src/borg/repository.py
--- a/src/borg/repository.py
+++ b/src/borg/repository.py
@@ -198,6 +198,10 @@ def __init__(self, path, create=False, exclusive=False, lock_wait=None, lock=Tru
         self.transaction_doomed = None
         self.check_segment_magic = check_segment_magic
         self.make_parent_dirs = make_parent_dirs
+        # v2 is the default repo version for borg 2.0
+        # v1 repos must only be used in a read-only way, e.g. for
+        # --other-repo=V1_REPO with borg init and borg transfer!
+        self.acceptable_repo_versions = (1, 2, )
 
     def __del__(self):
         if self.lock:
@@ -460,7 +464,7 @@ def open(self, path, exclusive, lock_wait=None, lock=True):
             self.close()
             raise self.InvalidRepositoryConfig(path, 'no repository section found')
         self.version = self.config.getint('repository', 'version')
-        if self.version not in (2, ):  # for now, only work on new repos
+        if self.version not in self.acceptable_repo_versions:
             self.close()
             raise self.InvalidRepositoryConfig(
                 path,


Test patch:
Repository: borgbackup/borg

Issue:
document FUSE limitations better
```
ender$ re borg and fuse: it'd be nice if borg warned that ACLs aren't preserved on fuse mounts
ThomasWaldmann$ well, that's documented.
ender$ where? I can't find any mention of acls on https://borgbackup.readthedocs.io/en/stable/usage/mount.html#
ThomasWaldmann$ https://borgbackup.readthedocs.io/en/stable/quickstart.html?highlight=fuse%20acl#restoring-a-backup
ThomasWaldmann$ that could be improved by actually documenting that within the "borg mount" docs page
ThomasWaldmann$ or at the other place where it talks about borg supporting acls on some systems
```


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
@@ -3221,10 +3221,13 @@ def define_borg_mount(parser):
 
         # borg mount
         mount_epilog = process_epilog("""
-        This command mounts an archive as a FUSE filesystem. This can be useful for
-        browsing an archive or restoring individual files. Unless the ``--foreground``
-        option is given the command will run in the background until the filesystem
-        is ``umounted``.
+        This command mounts an archive as a FUSE filesystem. This can be useful
+        for browsing an archive or restoring individual files. When restoring,
+        take into account that the current FUSE implementation does not support
+        special fs flags and ACLs.
+
+        Unless the ``--foreground`` option is given the command will run in the
+        background until the filesystem is ``umounted``.
 
         The command ``borgfs`` provides a wrapper for ``borg mount``. This can also be
         used in fstab entries:


Test patch:
Repository: borgbackup/borg

Issue:
borg2: remove scp style tilde expansion
scp style repo urls were removed, so the related expansion code can also get removed.


Discussion:

Resolving patch:
diff --git a/src/borg/remote.py b/src/borg/remote.py
--- a/src/borg/remote.py
+++ b/src/borg/remote.py
@@ -332,15 +332,10 @@ def negotiate(self, client_data):
     def _resolve_path(self, path):
         if isinstance(path, bytes):
             path = os.fsdecode(path)
-        # Leading slash is always present with URI (ssh://), but not with short-form (who@host:path).
         if path.startswith("/~/"):  # /~/x = path x relative to home dir
             path = os.path.join(get_base_dir(), path[3:])
-        elif path.startswith("~/"):
-            path = os.path.join(get_base_dir(), path[2:])
         elif path.startswith("/~"):  # /~username/x = relative to "user" home dir
             path = os.path.expanduser(path[1:])
-        elif path.startswith("~"):
-            path = os.path.expanduser(path)
         elif path.startswith("/./"):  # /./x = path x relative to cwd
             path = path[3:]
         return os.path.realpath(path)


Test patch:
Repository: borgbackup/borg

Issue:
Running `borg check` causes `local variable 'segment' referenced before assignment`
## Have you checked borgbackup docs, FAQ, and open Github issues?

Yes.

## Is this a BUG / ISSUE report or a QUESTION?

Bug report.

## System information. For client/server mode post info for both machines.

#### Your borg version (borg -V).

1.2.0

#### Operating system (distribution) and version.

macOS 12.5.1

#### Hardware / network configuration, and filesystems used.

APFS

#### How much data is handled by borg?

Repository is empty.

#### Full borg commandline that lead to the problem (leave away excludes and passwords)

    BORG_PASSCOMMAND=test borg check koffer

## Describe the problem you're observing.

When a repository is corrupt, and `borg check` is run, the following error is written to stderr:

    UnboundLocalError: local variable 'segment' referenced before assignment

#### Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.

- Create repository
- Corrupt it, e.g. by moving away files in `data/`
- Run `borg check`

#### Include any warning/errors/backtraces from the system logs

```
Local Exception
Traceback (most recent call last):
  File "/usr/local/Cellar/borgbackup/1.2.0/libexec/lib/python3.10/site-packages/borg/archiver.py", line 5089, in main
    exit_code = archiver.run(args)
  File "/usr/local/Cellar/borgbackup/1.2.0/libexec/lib/python3.10/site-packages/borg/archiver.py", line 5020, in run
    return set_ec(func(args))
  File "/usr/local/Cellar/borgbackup/1.2.0/libexec/lib/python3.10/site-packages/borg/archiver.py", line 183, in wrapper
    return method(self, args, repository=repository, **kwargs)
  File "/usr/local/Cellar/borgbackup/1.2.0/libexec/lib/python3.10/site-packages/borg/archiver.py", line 342, in do_check
    if not repository.check(repair=args.repair, save_space=args.save_space, max_duration=args.max_duration):
  File "/usr/local/Cellar/borgbackup/1.2.0/libexec/lib/python3.10/site-packages/borg/repository.py", line 1040, in check
    logger.info('finished segment check at segment %d', segment)
UnboundLocalError: local variable 'segment' referenced before assignment
```


Discussion:
Good catch, you found a bug! I could reproduce it with 1.2-maint code. :-)

Resolving patch:
diff --git a/src/borg/repository.py b/src/borg/repository.py
--- a/src/borg/repository.py
+++ b/src/borg/repository.py
@@ -1027,6 +1027,7 @@ def report_error(msg):
         t_start = time.monotonic()
         pi = ProgressIndicatorPercent(total=segment_count, msg='Checking segments %3.1f%%', step=0.1,
                                       msgid='repository.check')
+        segment = -1  # avoid uninitialized variable if there are no segment files at all
         for i, (segment, filename) in enumerate(self.io.segment_iterator()):
             pi.show(i)
             if segment <= last_segment_checked:


Test patch: