Git development
 help / color / mirror / Atom feed
From: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net
Subject: [RFC] archive: behavior of --prefix with absolute or parent path components
Date: Tue,  7 Apr 2026 16:21:01 +0000	[thread overview]
Message-ID: <20260407162101.2285-1-pushkarkumarsingh1970@gmail.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]

Hi,

While experimenting with "git archive", I noticed some behavior around
the --prefix option that might be worth clarifying.

Currently, --prefix accepts values such as absolute paths or ones with ..,
e.g.:
    git archive --prefix=/ HEAD > out.tar
    git archive --prefix=//// HEAD > out.tar
    git archive --prefix=../../ HEAD > out.tar

Upon listing the archive contents (e.g., tar -tf), you get entries like:
    /a.txt
    ////a.txt
    ../../a.txt

In such cases, tar emits warnings like:
    "Removing leading '/' from member names"
    "Removing leading '../' from member names"

This suggests that Git passes the prefix through as-is, relying on 
downstream tools to sanitize potentially unsafe paths.

From a user perspective, I was wondering:
  - Is this behavior intentional (i.e., leaving validation to archive
    consumers)?
  - Would it be worth documenting this explicitly?
  - Or should there be any normalization or validation at the Git level?

I understand that Git generally avoids enforcing policy decisions in 
such cases, but I wanted to confirm whether this behavior is intentional.

I’d appreciate any thoughts on this :-)

Thanks,
Pushkar

             reply	other threads:[~2026-04-07 16:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 16:21 Pushkar Singh [this message]
2026-04-07 19:24 ` [RFC] archive: behavior of --prefix with absolute or parent path components Jeff King
2026-04-07 19:57   ` Junio C Hamano
2026-04-07 22:24   ` brian m. carlson
2026-04-08 16:00 ` [PATCH] archive: document --prefix handling of absolute and parent paths Pushkar Singh
2026-04-08 17:40   ` Jeff King

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260407162101.2285-1-pushkarkumarsingh1970@gmail.com \
    --to=pushkarkumarsingh1970@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox