git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Cristian Le <cristian.le@mpsd.mpg.de>, git@vger.kernel.org
Subject: Re: Bug in git archive + .gitattributes + relative path
Date: Sun, 5 Mar 2023 10:32:02 +0100	[thread overview]
Message-ID: <c91db499-fa26-b902-3ab8-14c52959482f@web.de> (raw)
In-Reply-To: <566c2d09-5e18-49c9-fc7c-7b92d1d7c198@mpsd.mpg.de>

Am 04.03.23 um 16:11 schrieb Cristian Le:
> I should have explained more thoroughly, I have tried to work around
> by doing a `git archive` and then extracting and re-compressing after
> fixing the paths, but this does not preserve the owner and timestamp
> of the original `git archive`, nor can I use the current
> implementation of their tar fixer to correct these since the headers
> are different. I do not have enough expertise to know what headers
> need to be set, how to set the timestamps and so on.

GNU tar has the options --owner, --group and --mtime that allow you to
specify arbitrary values for these fields when archiving, no header
tinkering needed.  That said, tarring with git archive, untarring and
retarring with GNU tar is overly complicated and horrible when git
archive can do the whole job itself.

> I don't know if the `gzip -n -c` could do a better job at that,

That just compresses tar files to tgz (or tar.gz) format and does not
affect any tar headers.

> but we would still
> not be able to use it as is because we would want the correctly
> generate `export-subst` files, for example for a project built with
> `setuptools_scm` that injects the version of the python package from
> the last tag:
>
> https://github.com/pypa/setuptools_scm#git-archives

Note that git archive allows injecting extra files with the options
 --add-file and --add-virtual-file.  Could that feature perhaps be used
instead of export-subst?

>> There it was introduced along with a script that changes the mtime
>> of archive entries from the current time to the commit timestamp by
>> https://github.com/spacewalkproject/spacewalk/commit/34267e39d472.
> Thanks for pointing me to this. From your understanding, if we only use the git commit directly, we would in principle not need the whole tar fixer (https://github.com/rpm-software-management/tito/blob/91ef962220ec5154722760dbbd982bed032ee484/src/tito/tar.py#L28-L60 and https://github.com/rpm-software-management/tito/blob/91ef962220ec5154722760dbbd982bed032ee484/src/tito/common.py#L871-L890)? If there is no crucial information in the header that is different between the `git archive` and the `tar`/`gzip` with appropriate `mtime`, `mode` and maybe others, maybe there is some hope in fixing this locally.

The tar fixer was rewritten in Python in the meantime and I didn't look
it it closely, but if it only sets the mtime of all archive entries to
the commit date then it's not needed when giving git archive a commit
or tag instead of a tree.

> I'll be looking forward to `--strip-components`, but just to confirm
> my reading of the email, the intent is to have it working with
> `export-subst` right?
That option would work the same regardless whether git archive is given
a tree, commit or tag, and it doesn't care about attributes or file
contents.  It would be especially helpful when giving a commit or tag
and a pathspec, and export-subst needs a commit or tag.  So in short:
Yes. :)

René

  reply	other threads:[~2023-03-05  9:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 10:25 Bug in git archive + .gitattributes + relative path Cristian Le
2023-03-03 15:19 ` 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 [this message]
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=c91db499-fa26-b902-3ab8-14c52959482f@web.de \
    --to=l.s.r@web.de \
    --cc=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).