Git development
 help / color / mirror / Atom feed
* [RFC] archive: behavior of --prefix with absolute or parent path components
@ 2026-04-07 16:21 Pushkar Singh
  2026-04-07 19:24 ` Jeff King
  2026-04-08 16:00 ` [PATCH] archive: document --prefix handling of absolute and parent paths Pushkar Singh
  0 siblings, 2 replies; 6+ messages in thread
From: Pushkar Singh @ 2026-04-07 16:21 UTC (permalink / raw)
  To: git; +Cc: gitster, peff

[-- 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-08 17:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07 16:21 [RFC] archive: behavior of --prefix with absolute or parent path components Pushkar Singh
2026-04-07 19:24 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox