From: Cristian Le <cristian.le@mpsd.mpg.de>
To: <git@vger.kernel.org>
Subject: Bug in git archive + .gitattributes + relative path
Date: Fri, 3 Mar 2023 11:25:01 +0100 [thread overview]
Message-ID: <42f13cda-9de6-bfc6-7e81-64c94f5640db@mpsd.mpg.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1730 bytes --]
Using `git archive` with or without `--worktree-attributes` does not
properly read `.gitattributes` files if using a relative path in
`<tree-ish>`.
Related github comment:
https://github.com/rpm-software-management/tito/pull/445#issuecomment-1450298871
Related stackoverflow discussion:
https://stackoverflow.com/questions/52804334/how-to-ignore-files-directories-in-git-archive-and-only-create-an-archive-of-a
Git version: `2.39.2`
Mwe git repo: Two files:
```
# .gitattributes:
.git_archival.txt export-subst
```
```
# .git_archival.txt:
node: $Format:%H$
```
Commands to reproduce and expected behaviour:
```console
$ git archive HEAD:./ --output=test.tar.gz
$ tar -axf test.tar.gz .git_archival.txt -O
node: 745ce26169fb44e04d91d40ee581cccd591c941e
```
Important: Notice the path `./` given after `HEAD`.
Actual output:
```console
$ tar -axf test.tar.gz .git_archival.txt -O
node: $Format:%H$
```
It doesn't matter if `.gitattributes` is in a subfolder, or if I change
the relative path `./` to a subfolder, the files are still not properly
generated.
Using `--worktree-attributes` did not have any effect either.
According to the documentation, I understand that the expected behaviour
with regards to `--worktree-attributes`:
- Read the `.gitattributes` of the relative path, e.g. `./sub_dir`
regardless of `--worktree-attributes`. (similar behaviour as not passing
a relative path)
- Include the `.gitattributes` of the top-level path if
`--worktree-attributes` is passed
Maybe the intended behaviour is to completely ignore all
`.gitattributes` unless `--worktree-attributes` is provided, in which
case, it does not have the intended behaviour and please include a flag
to achieve the above behaviour.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4273 bytes --]
next reply other threads:[~2023-03-03 11:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 10:25 Cristian Le [this message]
2023-03-03 15:19 ` Bug in git archive + .gitattributes + relative path René Scharfe
2023-03-03 15:38 ` Cristian Le
2023-03-04 13:58 ` René Scharfe
2023-03-04 15:11 ` Cristian Le
2023-03-05 9:32 ` René Scharfe
2023-03-06 16:56 ` Junio C Hamano
2023-03-06 17:51 ` René Scharfe
2023-03-06 17:27 ` Junio C Hamano
2023-03-06 18:28 ` René Scharfe
2023-03-06 18:59 ` Junio C Hamano
2023-03-06 21:32 ` René Scharfe
2023-03-06 22:34 ` Junio C Hamano
2023-03-11 20:47 ` René Scharfe
2023-03-12 21:25 ` Junio C Hamano
2023-03-18 21:30 ` René Scharfe
2023-03-20 16:16 ` Junio C Hamano
2023-03-20 20:02 ` [PATCH] archive: improve support for running in a subdirectory René Scharfe
2023-03-21 22:59 ` Junio C Hamano
2023-03-24 22:26 ` René Scharfe
2023-03-24 22:27 ` [PATCH v2] archive: improve support for running in subdirectory René Scharfe
2023-03-27 16:09 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42f13cda-9de6-bfc6-7e81-64c94f5640db@mpsd.mpg.de \
--to=cristian.le@mpsd.mpg.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).