| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8724dfa commit cfc70fe
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -367,6 +367,17 @@ def raise_exc(e): | |||
| 367 | 367 | abs_path = os.path.join(r, path) | |
| 368 | 368 | # END make absolute path | |
| 369 | 369 | ||
| 370 | + try: | ||
| 371 | + st = os.lstat(abs_path) # handles non-symlinks as well | ||
| 372 | + except OSError: | ||
| 373 | + # the lstat call may fail as the path may contain globs as well | ||
| 374 | + pass | ||
| 375 | + else: | ||
| 376 | + if S_ISLNK(st.st_mode): | ||
| 377 | + yield abs_path.replace(rs, '') | ||
| 378 | + continue | ||
| 379 | + # end check symlink | ||
| 380 | + | ||
| 370 | 381 | # resolve globs if possible | |
| 371 | 382 | if '?' in path or '*' in path or '[' in path: | |
| 372 | 383 | for f in self._iter_expand_paths(glob.glob(abs_path)): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -542,18 +542,22 @@ def mixed_iterator(): | |||
| 542 | 542 | ||
| 543 | 543 | # add symlink | |
| 544 | 544 | if sys.platform != "win32": | |
| 545 | - basename = "my_real_symlink" | ||
| 546 | - target = "/etc/that" | ||
| 547 | - link_file = os.path.join(rw_repo.working_tree_dir, basename) | ||
| 548 | - os.symlink(target, link_file) | ||
| 549 | - entries = index.reset(new_commit).add([link_file], fprogress=self._fprogress_add) | ||
| 550 | - self._assert_entries(entries) | ||
| 551 | - self._assert_fprogress(entries) | ||
| 552 | - assert len(entries) == 1 and S_ISLNK(entries[0].mode) | ||
| 553 | - assert S_ISLNK(index.entries[index.entry_key("my_real_symlink", 0)].mode) | ||
| 554 | - | ||
| 555 | - # we expect only the target to be written | ||
| 556 | - assert index.repo.odb.stream(entries[0].binsha).read().decode('ascii') == target | ||
| 545 | + for target in ('/etc/nonexisting', '/etc/passwd', '/etc'): | ||
| 546 | + basename = "my_real_symlink" | ||
| 547 | + | ||
| 548 | + link_file = os.path.join(rw_repo.working_tree_dir, basename) | ||
| 549 | + os.symlink(target, link_file) | ||
| 550 | + entries = index.reset(new_commit).add([link_file], fprogress=self._fprogress_add) | ||
| 551 | + self._assert_entries(entries) | ||
| 552 | + self._assert_fprogress(entries) | ||
| 553 | + assert len(entries) == 1 and S_ISLNK(entries[0].mode) | ||
| 554 | + assert S_ISLNK(index.entries[index.entry_key("my_real_symlink", 0)].mode) | ||
| 555 | + | ||
| 556 | + # we expect only the target to be written | ||
| 557 | + assert index.repo.odb.stream(entries[0].binsha).read().decode('ascii') == target | ||
| 558 | + | ||
| 559 | + os.remove(link_file) | ||
| 560 | + # end for each target | ||
| 557 | 561 | # END real symlink test | |
| 558 | 562 | ||
| 559 | 563 | # add fake symlink and assure it checks-our as symlink | |
| Back | FazBrowse Home | New Git URL |
0 commit comments