bugGNU tar - Bugs: bug #62859, tar --exclude-vcs does not exclude...

 
 

bug #62859: tar --exclude-vcs does not exclude .git directory when extracting

Submitter:  Mohamed Akram <mohdakram>
Submitted:  Wed 03 Aug 2022 04:06:28 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 18 Apr 2023 07:53:40 AM UTC, comment #7: 

Fixed. Thank you.

Sergey Poznyakoff <gray>
Group administrator
Sun 19 Mar 2023 07:18:47 AM UTC, comment #6: 

I think proper fix is to ignore `/...' after a match with FNM_LEADING_DIR.

I will test, and, if no issues found, submit merge request.

diff --git a/src/names.c b/src/names.c
index 03457ba..08b8038 100644
--- a/src/names.c
+++ b/src/names.c
@@ -350,3 +350,3 @@ handle_file_selection_option (int key, const char *arg)
     case EXCLUDE_VCS_OPTION:
-      add_exclude_array (vcs_file_table, 0);
+      add_exclude_array (vcs_file_table, FNM_LEADING_DIR);
       break;

Anonymous
Fri 17 Mar 2023 06:41:33 PM UTC, comment #5: 

I will attempt to address this bug. WIP here https://github.com/atokama/tar

Anonymous
Thu 09 Mar 2023 03:59:09 PM UTC, comment #4: 

with EXCLUDE_REGEX option set for vcs_ignore_files, issue is fixed.
It is not a proper fix, just a demo:

diff --git a/src/names.c b/src/names.c
index 03457ba..08b8038 100644
--- a/src/names.c
+++ b/src/names.c
@@ -350,3 +350,3 @@ handle_file_selection_option (int key, const char *arg)
     case EXCLUDE_VCS_OPTION:
-      add_exclude_array (vcs_file_table, 0);
+      add_exclude_array (vcs_file_table, EXCLUDE_REGEX);
       break;

Anonymous
Thu 09 Mar 2023 03:55:21 PM UTC, comment #3: 

Bug caused

files for --exclude-vcs files excluded by filename, not by regex.

when creating an archive, when recursively iterating input directory files, excluded files are skipped.

When extracting, tar iterates over internal representation of file entries. '.git' dir excluded sucessfully, but not its children like '.git/HEAD'. When children created, parent dir created.

Anonymous
Thu 09 Mar 2023 01:05:52 PM UTC, comment #2: 

workaround:
tar --exclude=.git --exclude-vcs -xf gitrepo.tar.gz

Anonymous
Thu 09 Mar 2023 11:28:05 AM UTC, comment #1: 

Bug confirmed with tar 1.34 installed from arch pacman repository

Anonymous
Wed 03 Aug 2022 04:06:28 PM UTC, original submission:  

The --exclude-vcs flag seems to exclude .gitignore but not .git when extracting. To reproduce:

mkdir gitrepo
cd gitrepo
git init
touch .gitignore
cd ..
tar -caf gitrepo.tar.gz gitrepo
rm -r gitrepo
tar -xf gitrepo.tar.gz --exclude-vcs
[ -e gitrepo/.gitignore ] && echo .gitignore not excluded
[ -e gitrepo/.git ] && echo .git not excluded

Mohamed Akram <mohdakram>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gray (Posted a comment)
  • -email is unavailable- added by mohdakram (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-04-18 gray StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-12ab.
    Corresponding source code